diff --git a/app/src/main/java/com/keylesspalace/tusky/TuskyApplication.kt b/app/src/main/java/com/keylesspalace/tusky/TuskyApplication.kt
index 37efe1dbc0..da272db62d 100644
--- a/app/src/main/java/com/keylesspalace/tusky/TuskyApplication.kt
+++ b/app/src/main/java/com/keylesspalace/tusky/TuskyApplication.kt
@@ -146,6 +146,13 @@ class TuskyApplication : Application(), HasAndroidInjector {
editor.putString(APP_THEME, AppTheme.NIGHT.value)
}
}
+
+ if (oldVersion < 2023112001) {
+ editor.remove(PrefKeys.TAB_FILTER_HOME_REPLIES)
+ editor.remove(PrefKeys.TAB_FILTER_HOME_BOOSTS)
+ editor.remove(PrefKeys.TAB_SHOW_HOME_SELF_BOOSTS)
+ }
+
editor.putInt(PrefKeys.SCHEMA_VERSION, newVersion)
editor.apply()
}
diff --git a/app/src/main/java/com/keylesspalace/tusky/components/preference/AccountPreferencesFragment.kt b/app/src/main/java/com/keylesspalace/tusky/components/preference/AccountPreferencesFragment.kt
index 629c3709d5..4247a0a751 100644
--- a/app/src/main/java/com/keylesspalace/tusky/components/preference/AccountPreferencesFragment.kt
+++ b/app/src/main/java/com/keylesspalace/tusky/components/preference/AccountPreferencesFragment.kt
@@ -267,6 +267,12 @@ class AccountPreferencesFragment : PreferenceFragmentCompat(), Injectable {
preferenceDataStore = accountPreferenceDataStore
}
}
+ preferenceCategory(R.string.pref_title_per_timeline_preferences) {
+ preference {
+ setTitle(R.string.pref_title_post_tabs)
+ fragment = TabFilterPreferencesFragment::class.qualifiedName
+ }
+ }
}
}
diff --git a/app/src/main/java/com/keylesspalace/tusky/components/preference/PreferencesFragment.kt b/app/src/main/java/com/keylesspalace/tusky/components/preference/PreferencesFragment.kt
index 17c8e13ae2..b01b320f44 100644
--- a/app/src/main/java/com/keylesspalace/tusky/components/preference/PreferencesFragment.kt
+++ b/app/src/main/java/com/keylesspalace/tusky/components/preference/PreferencesFragment.kt
@@ -246,13 +246,6 @@ class PreferencesFragment : PreferenceFragmentCompat(), Injectable {
}
}
- preferenceCategory(R.string.pref_title_timeline_filters) {
- preference {
- setTitle(R.string.pref_title_post_tabs)
- fragment = TabFilterPreferencesFragment::class.qualifiedName
- }
- }
-
preferenceCategory(R.string.pref_title_wellbeing_mode) {
switchPreference {
title = getString(R.string.limit_notifications)
diff --git a/app/src/main/java/com/keylesspalace/tusky/components/preference/TabFilterPreferencesFragment.kt b/app/src/main/java/com/keylesspalace/tusky/components/preference/TabFilterPreferencesFragment.kt
index 15697f6444..cb6eeb46e6 100644
--- a/app/src/main/java/com/keylesspalace/tusky/components/preference/TabFilterPreferencesFragment.kt
+++ b/app/src/main/java/com/keylesspalace/tusky/components/preference/TabFilterPreferencesFragment.kt
@@ -18,12 +18,19 @@ package com.keylesspalace.tusky.components.preference
import android.os.Bundle
import androidx.preference.PreferenceFragmentCompat
import com.keylesspalace.tusky.R
+import com.keylesspalace.tusky.di.Injectable
+import com.keylesspalace.tusky.settings.AccountPreferenceDataStore
import com.keylesspalace.tusky.settings.PrefKeys
import com.keylesspalace.tusky.settings.makePreferenceScreen
import com.keylesspalace.tusky.settings.preferenceCategory
import com.keylesspalace.tusky.settings.switchPreference
+import javax.inject.Inject
+
+class TabFilterPreferencesFragment : PreferenceFragmentCompat(), Injectable {
+
+ @Inject
+ lateinit var accountPreferenceDataStore: AccountPreferenceDataStore
-class TabFilterPreferencesFragment : PreferenceFragmentCompat() {
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
makePreferenceScreen {
preferenceCategory(R.string.title_home) { category ->
@@ -32,14 +39,14 @@ class TabFilterPreferencesFragment : PreferenceFragmentCompat() {
switchPreference {
setTitle(R.string.pref_title_show_boosts)
key = PrefKeys.TAB_FILTER_HOME_BOOSTS
- setDefaultValue(true)
+ preferenceDataStore = accountPreferenceDataStore
isIconSpaceReserved = false
}
switchPreference {
setTitle(R.string.pref_title_show_replies)
key = PrefKeys.TAB_FILTER_HOME_REPLIES
- setDefaultValue(true)
+ preferenceDataStore = accountPreferenceDataStore
isIconSpaceReserved = false
}
@@ -47,7 +54,7 @@ class TabFilterPreferencesFragment : PreferenceFragmentCompat() {
setTitle(R.string.pref_title_show_self_boosts)
setSummary(R.string.pref_title_show_self_boosts_description)
key = PrefKeys.TAB_SHOW_HOME_SELF_BOOSTS
- setDefaultValue(true)
+ preferenceDataStore = accountPreferenceDataStore
isIconSpaceReserved = false
}.apply { dependency = PrefKeys.TAB_FILTER_HOME_BOOSTS }
}
diff --git a/app/src/main/java/com/keylesspalace/tusky/components/timeline/viewmodel/TimelineViewModel.kt b/app/src/main/java/com/keylesspalace/tusky/components/timeline/viewmodel/TimelineViewModel.kt
index 953c3cfd57..7ae8663077 100644
--- a/app/src/main/java/com/keylesspalace/tusky/components/timeline/viewmodel/TimelineViewModel.kt
+++ b/app/src/main/java/com/keylesspalace/tusky/components/timeline/viewmodel/TimelineViewModel.kt
@@ -89,11 +89,11 @@ abstract class TimelineViewModel(
if (kind == Kind.HOME) {
// Note the variable is "true if filter" but the underlying preference/settings text is "true if show"
filterRemoveReplies =
- !sharedPreferences.getBoolean(PrefKeys.TAB_FILTER_HOME_REPLIES, true)
+ !(accountManager.activeAccount?.isShowHomeBoosts ?: true)
filterRemoveReblogs =
- !sharedPreferences.getBoolean(PrefKeys.TAB_FILTER_HOME_BOOSTS, true)
+ !(accountManager.activeAccount?.isShowHomeReplies ?: true)
filterRemoveSelfReblogs =
- !sharedPreferences.getBoolean(PrefKeys.TAB_SHOW_HOME_SELF_BOOSTS, true)
+ !(accountManager.activeAccount?.isShowHomeSelfBoosts ?: true)
}
readingOrder = ReadingOrder.from(sharedPreferences.getString(PrefKeys.READING_ORDER, null))
@@ -201,7 +201,7 @@ abstract class TimelineViewModel(
private fun onPreferenceChanged(key: String) {
when (key) {
PrefKeys.TAB_FILTER_HOME_REPLIES -> {
- val filter = sharedPreferences.getBoolean(PrefKeys.TAB_FILTER_HOME_REPLIES, true)
+ val filter = accountManager.activeAccount?.isShowHomeReplies ?: true
val oldRemoveReplies = filterRemoveReplies
filterRemoveReplies = kind == Kind.HOME && !filter
if (oldRemoveReplies != filterRemoveReplies) {
@@ -209,7 +209,7 @@ abstract class TimelineViewModel(
}
}
PrefKeys.TAB_FILTER_HOME_BOOSTS -> {
- val filter = sharedPreferences.getBoolean(PrefKeys.TAB_FILTER_HOME_BOOSTS, true)
+ val filter = accountManager.activeAccount?.isShowHomeBoosts ?: true
val oldRemoveReblogs = filterRemoveReblogs
filterRemoveReblogs = kind == Kind.HOME && !filter
if (oldRemoveReblogs != filterRemoveReblogs) {
@@ -217,7 +217,7 @@ abstract class TimelineViewModel(
}
}
PrefKeys.TAB_SHOW_HOME_SELF_BOOSTS -> {
- val filter = sharedPreferences.getBoolean(PrefKeys.TAB_SHOW_HOME_SELF_BOOSTS, true)
+ val filter = accountManager.activeAccount?.isShowHomeSelfBoosts ?: true
val oldRemoveSelfReblogs = filterRemoveSelfReblogs
filterRemoveSelfReblogs = kind == Kind.HOME && !filter
if (oldRemoveSelfReblogs != filterRemoveSelfReblogs) {
diff --git a/app/src/main/java/com/keylesspalace/tusky/db/AccountEntity.kt b/app/src/main/java/com/keylesspalace/tusky/db/AccountEntity.kt
index ee3ad6cd5d..1f88d3a10c 100644
--- a/app/src/main/java/com/keylesspalace/tusky/db/AccountEntity.kt
+++ b/app/src/main/java/com/keylesspalace/tusky/db/AccountEntity.kt
@@ -107,7 +107,11 @@ data class AccountEntity(
var locked: Boolean = false,
@ColumnInfo(defaultValue = "0")
- var hasDirectMessageBadge: Boolean = false
+ var hasDirectMessageBadge: Boolean = false,
+
+ var isShowHomeBoosts: Boolean = true,
+ var isShowHomeReplies: Boolean = true,
+ var isShowHomeSelfBoosts: Boolean = true,
) {
val identifier: String
diff --git a/app/src/main/java/com/keylesspalace/tusky/db/AppDatabase.java b/app/src/main/java/com/keylesspalace/tusky/db/AppDatabase.java
index f80cfed88b..45e186e046 100644
--- a/app/src/main/java/com/keylesspalace/tusky/db/AppDatabase.java
+++ b/app/src/main/java/com/keylesspalace/tusky/db/AppDatabase.java
@@ -42,7 +42,7 @@
TimelineAccountEntity.class,
ConversationEntity.class
},
- version = 54,
+ version = 56,
autoMigrations = {
@AutoMigration(from = 48, to = 49),
@AutoMigration(from = 49, to = 50, spec = AppDatabase.MIGRATION_49_50.class),
@@ -686,4 +686,13 @@ public void migrate(@NonNull SupportSQLiteDatabase database) {
database.execSQL("UPDATE `AccountEntity` SET `tabpreferences` = REPLACE(tabpreferences, 'Trending:', 'TrendingTags:')");
}
};
+
+ public static final Migration MIGRATION_54_56 = new Migration(54, 56) {
+ @Override
+ public void migrate(@NonNull SupportSQLiteDatabase database) {
+ database.execSQL("ALTER TABLE `AccountEntity` ADD COLUMN `isShowHomeBoosts` INTEGER NOT NULL DEFAULT 1");
+ database.execSQL("ALTER TABLE `AccountEntity` ADD COLUMN `isShowHomeReplies` INTEGER NOT NULL DEFAULT 1");
+ database.execSQL("ALTER TABLE `AccountEntity` ADD COLUMN `isShowHomeSelfBoosts` INTEGER NOT NULL DEFAULT 1");
+ }
+ };
}
diff --git a/app/src/main/java/com/keylesspalace/tusky/di/AppModule.kt b/app/src/main/java/com/keylesspalace/tusky/di/AppModule.kt
index 0f65d6c258..95284f1ade 100644
--- a/app/src/main/java/com/keylesspalace/tusky/di/AppModule.kt
+++ b/app/src/main/java/com/keylesspalace/tusky/di/AppModule.kt
@@ -68,7 +68,7 @@ class AppModule {
AppDatabase.MIGRATION_38_39, AppDatabase.MIGRATION_39_40, AppDatabase.MIGRATION_40_41,
AppDatabase.MIGRATION_41_42, AppDatabase.MIGRATION_42_43, AppDatabase.MIGRATION_43_44,
AppDatabase.MIGRATION_44_45, AppDatabase.MIGRATION_45_46, AppDatabase.MIGRATION_46_47,
- AppDatabase.MIGRATION_47_48, AppDatabase.MIGRATION_52_53
+ AppDatabase.MIGRATION_47_48, AppDatabase.MIGRATION_52_53, AppDatabase.MIGRATION_54_56,
)
.build()
}
diff --git a/app/src/main/java/com/keylesspalace/tusky/di/FragmentBuildersModule.kt b/app/src/main/java/com/keylesspalace/tusky/di/FragmentBuildersModule.kt
index 825eff6cfc..929c1920f9 100644
--- a/app/src/main/java/com/keylesspalace/tusky/di/FragmentBuildersModule.kt
+++ b/app/src/main/java/com/keylesspalace/tusky/di/FragmentBuildersModule.kt
@@ -24,6 +24,7 @@ import com.keylesspalace.tusky.components.domainblocks.DomainBlocksFragment
import com.keylesspalace.tusky.components.preference.AccountPreferencesFragment
import com.keylesspalace.tusky.components.preference.NotificationPreferencesFragment
import com.keylesspalace.tusky.components.preference.PreferencesFragment
+import com.keylesspalace.tusky.components.preference.TabFilterPreferencesFragment
import com.keylesspalace.tusky.components.report.fragments.ReportDoneFragment
import com.keylesspalace.tusky.components.report.fragments.ReportNoteFragment
import com.keylesspalace.tusky.components.report.fragments.ReportStatusesFragment
@@ -103,4 +104,7 @@ abstract class FragmentBuildersModule {
@ContributesAndroidInjector
abstract fun viewVideoFragment(): ViewVideoFragment
+
+ @ContributesAndroidInjector
+ abstract fun tabFilterPreferencesFragment(): TabFilterPreferencesFragment
}
diff --git a/app/src/main/java/com/keylesspalace/tusky/settings/AccountPreferenceDataStore.kt b/app/src/main/java/com/keylesspalace/tusky/settings/AccountPreferenceDataStore.kt
index a951344141..b50deebd5d 100644
--- a/app/src/main/java/com/keylesspalace/tusky/settings/AccountPreferenceDataStore.kt
+++ b/app/src/main/java/com/keylesspalace/tusky/settings/AccountPreferenceDataStore.kt
@@ -22,6 +22,9 @@ class AccountPreferenceDataStore @Inject constructor(
PrefKeys.ALWAYS_SHOW_SENSITIVE_MEDIA -> account.alwaysShowSensitiveMedia
PrefKeys.ALWAYS_OPEN_SPOILER -> account.alwaysOpenSpoiler
PrefKeys.MEDIA_PREVIEW_ENABLED -> account.mediaPreviewEnabled
+ PrefKeys.TAB_FILTER_HOME_BOOSTS -> account.isShowHomeBoosts
+ PrefKeys.TAB_FILTER_HOME_REPLIES -> account.isShowHomeReplies
+ PrefKeys.TAB_SHOW_HOME_SELF_BOOSTS -> account.isShowHomeSelfBoosts
else -> defValue
}
}
@@ -31,6 +34,9 @@ class AccountPreferenceDataStore @Inject constructor(
PrefKeys.ALWAYS_SHOW_SENSITIVE_MEDIA -> account.alwaysShowSensitiveMedia = value
PrefKeys.ALWAYS_OPEN_SPOILER -> account.alwaysOpenSpoiler = value
PrefKeys.MEDIA_PREVIEW_ENABLED -> account.mediaPreviewEnabled = value
+ PrefKeys.TAB_FILTER_HOME_BOOSTS -> account.isShowHomeBoosts = value
+ PrefKeys.TAB_FILTER_HOME_REPLIES -> account.isShowHomeReplies = value
+ PrefKeys.TAB_SHOW_HOME_SELF_BOOSTS -> account.isShowHomeSelfBoosts = value
}
accountManager.saveAccount(account)
diff --git a/app/src/main/java/com/keylesspalace/tusky/settings/SettingsConstants.kt b/app/src/main/java/com/keylesspalace/tusky/settings/SettingsConstants.kt
index 64a5461daa..241c1461b8 100644
--- a/app/src/main/java/com/keylesspalace/tusky/settings/SettingsConstants.kt
+++ b/app/src/main/java/com/keylesspalace/tusky/settings/SettingsConstants.kt
@@ -45,7 +45,7 @@ enum class AppTheme(val value: String) {
*
* - Adding a new preference that does not change the interpretation of an existing preference
*/
-const val SCHEMA_VERSION = 2023082301
+const val SCHEMA_VERSION = 2023112001
/** The schema version for fresh installs */
const val NEW_INSTALL_SCHEMA_VERSION = 0
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index d206e7b3f9..af6e5d9257 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -298,6 +298,7 @@
App theme
Timelines
Filters
+ Per-timeline preferences
Dark
Light
@@ -316,7 +317,7 @@
Animate custom emojis
Timeline filtering
- Tabs
+ Home timeline
Show boosts
Show replies
Download media previews