From 50f7a7affa33293a68ad3addf61ff52be6a7aa8d Mon Sep 17 00:00:00 2001 From: kyori19 Date: Sat, 9 May 2020 02:17:02 +0900 Subject: [PATCH] Add "account" filter context (#1776) --- app/src/main/java/com/keylesspalace/tusky/entity/Filter.kt | 1 + .../com/keylesspalace/tusky/fragment/TimelineFragment.java | 7 ++++++- .../fragment/preference/AccountPreferencesFragment.kt | 6 ++++++ app/src/main/res/xml/account_preferences.xml | 4 ++++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/entity/Filter.kt b/app/src/main/java/com/keylesspalace/tusky/entity/Filter.kt index 6d6cbaa5..58bdc79a 100644 --- a/app/src/main/java/com/keylesspalace/tusky/entity/Filter.kt +++ b/app/src/main/java/com/keylesspalace/tusky/entity/Filter.kt @@ -30,6 +30,7 @@ data class Filter ( const val NOTIFICATIONS = "notifications" const val PUBLIC = "public" const val THREAD = "thread" + const val ACCOUNT = "account" } override fun hashCode(): Int { diff --git a/app/src/main/java/com/keylesspalace/tusky/fragment/TimelineFragment.java b/app/src/main/java/com/keylesspalace/tusky/fragment/TimelineFragment.java index f63e692f..2ecf6faf 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/TimelineFragment.java +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/TimelineFragment.java @@ -380,6 +380,10 @@ public class TimelineFragment extends SFragment implements return filterContext.contains(Filter.PUBLIC); case FAVOURITES: return (filterContext.contains(Filter.PUBLIC) || filterContext.contains(Filter.NOTIFICATIONS)); + case USER: + case USER_WITH_REPLIES: + case USER_PINNED: + return filterContext.contains(Filter.ACCOUNT); default: return false; } @@ -896,7 +900,8 @@ public class TimelineFragment extends SFragment implements case Filter.HOME: case Filter.NOTIFICATIONS: case Filter.THREAD: - case Filter.PUBLIC: { + case Filter.PUBLIC: + case Filter.ACCOUNT: { if (filterContextMatchesKind(kind, Collections.singletonList(key))) { reloadFilters(true); } diff --git a/app/src/main/java/com/keylesspalace/tusky/fragment/preference/AccountPreferencesFragment.kt b/app/src/main/java/com/keylesspalace/tusky/fragment/preference/AccountPreferencesFragment.kt index 574c32b0..2323fa3b 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/preference/AccountPreferencesFragment.kt +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/preference/AccountPreferencesFragment.kt @@ -75,6 +75,7 @@ class AccountPreferencesFragment : PreferenceFragmentCompat(), private lateinit var notificationFiltersPreference: Preference private lateinit var publicFiltersPreference: Preference private lateinit var threadFiltersPreference: Preference + private lateinit var accountFiltersPreference: Preference override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { addPreferencesFromResource(R.xml.account_preferences) @@ -94,6 +95,7 @@ class AccountPreferencesFragment : PreferenceFragmentCompat(), notificationFiltersPreference = requirePreference("notificationFilters") publicFiltersPreference = requirePreference("publicFilters") threadFiltersPreference = requirePreference("threadFilters") + accountFiltersPreference = requirePreference("accountFilters") notificationPreference.icon = IconicsDrawable(notificationPreference.context, GoogleMaterial.Icon.gmd_notifications).apply { sizeRes = R.dimen.preference_icon_size; colorInt = ThemeUtils.getColor(notificationPreference.context, R.attr.iconColor) } mutedUsersPreference.icon = getTintedIcon(R.drawable.ic_mute_24dp) @@ -109,6 +111,7 @@ class AccountPreferencesFragment : PreferenceFragmentCompat(), notificationFiltersPreference.onPreferenceClickListener = this publicFiltersPreference.onPreferenceClickListener = this threadFiltersPreference.onPreferenceClickListener = this + accountFiltersPreference.onPreferenceClickListener = this defaultPostPrivacyPreference.onPreferenceChangeListener = this defaultMediaSensitivityPreference.onPreferenceChangeListener = this @@ -249,6 +252,9 @@ class AccountPreferencesFragment : PreferenceFragmentCompat(), threadFiltersPreference -> { launchFilterActivity(Filter.THREAD, R.string.pref_title_thread_filter_keywords) } + accountFiltersPreference -> { + launchFilterActivity(Filter.ACCOUNT, R.string.title_accounts) + } else -> false } diff --git a/app/src/main/res/xml/account_preferences.xml b/app/src/main/res/xml/account_preferences.xml index a2535c5c..935b7857 100644 --- a/app/src/main/res/xml/account_preferences.xml +++ b/app/src/main/res/xml/account_preferences.xml @@ -81,5 +81,9 @@ + +