From 9a29c792332627c47f776bb301e3e4c875f596c6 Mon Sep 17 00:00:00 2001 From: NIkita Fedrunov Date: Tue, 6 Sep 2022 00:41:58 +0200 Subject: [PATCH 1/2] obsolete settings are hidden when app layout flag is enabled --- changelog.d/6646.misc | 1 + .../im/vector/app/features/settings/VectorPreferences.kt | 5 +++++ .../app/features/settings/VectorSettingsLabsFragment.kt | 6 ++++++ .../features/settings/VectorSettingsPreferencesFragment.kt | 7 +++++++ vector/src/main/res/xml/vector_settings_preferences.xml | 4 +++- 5 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 changelog.d/6646.misc diff --git a/changelog.d/6646.misc b/changelog.d/6646.misc new file mode 100644 index 0000000000..0f2e3f0881 --- /dev/null +++ b/changelog.d/6646.misc @@ -0,0 +1 @@ +[App Layout] Obsolete settings are not shown when App Layout flag is enabled diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt b/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt index cefbe64d9d..d60d0ea73a 100755 --- a/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt @@ -165,6 +165,11 @@ class VectorPreferences @Inject constructor( const val SETTINGS_LABS_AUTO_REPORT_UISI = "SETTINGS_LABS_AUTO_REPORT_UISI" const val SETTINGS_PREF_SPACE_SHOW_ALL_ROOM_IN_HOME = "SETTINGS_PREF_SPACE_SHOW_ALL_ROOM_IN_HOME" + /** + * This is not preference, but category on preferences screen which contains [SETTINGS_PREF_SPACE_SHOW_ALL_ROOM_IN_HOME]. + * Needed to show/hide this category, depending on visibility of [SETTINGS_PREF_SPACE_SHOW_ALL_ROOM_IN_HOME]. */ + const val SETTINGS_PREF_SPACE_SHOW_ALL_ROOM_IN_HOME_CATEGORY = "SETTINGS_PREF_SPACE_SHOW_ALL_ROOM_IN_HOME_CATEGORY" + private const val SETTINGS_DEVELOPER_MODE_PREFERENCE_KEY = "SETTINGS_DEVELOPER_MODE_PREFERENCE_KEY" private const val SETTINGS_LABS_SHOW_HIDDEN_EVENTS_PREFERENCE_KEY = "SETTINGS_LABS_SHOW_HIDDEN_EVENTS_PREFERENCE_KEY" private const val SETTINGS_LABS_ENABLE_SWIPE_TO_REPLY = "SETTINGS_LABS_ENABLE_SWIPE_TO_REPLY" diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsLabsFragment.kt b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsLabsFragment.kt index eb7864a89d..c1253f4ab4 100644 --- a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsLabsFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsLabsFragment.kt @@ -27,6 +27,7 @@ import im.vector.app.R import im.vector.app.core.preference.VectorSwitchPreference import im.vector.app.features.MainActivity import im.vector.app.features.MainActivityArgs +import im.vector.app.features.VectorFeatures import im.vector.app.features.analytics.plan.MobileScreen import im.vector.app.features.home.room.threads.ThreadsManager import org.matrix.android.sdk.api.settings.LightweightSettingsStorage @@ -39,6 +40,7 @@ class VectorSettingsLabsFragment : @Inject lateinit var vectorPreferences: VectorPreferences @Inject lateinit var lightweightSettingsStorage: LightweightSettingsStorage @Inject lateinit var threadsManager: ThreadsManager + @Inject lateinit var vectorFeatures: VectorFeatures override var titleRes = R.string.room_settings_labs_pref_title override val preferenceXmlRes = R.xml.vector_settings_labs @@ -72,6 +74,10 @@ class VectorSettingsLabsFragment : true } } + + findPreference(VectorPreferences.SETTINGS_LABS_UNREAD_NOTIFICATIONS_AS_TAB)!!.let { + it.isVisible = !vectorFeatures.isNewAppLayoutEnabled() + } } /** diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsPreferencesFragment.kt b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsPreferencesFragment.kt index 0bd5316b8f..458ba79ee3 100644 --- a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsPreferencesFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsPreferencesFragment.kt @@ -28,9 +28,11 @@ import im.vector.app.core.dialogs.PhotoOrVideoDialog import im.vector.app.core.extensions.restart import im.vector.app.core.preference.VectorListPreference import im.vector.app.core.preference.VectorPreference +import im.vector.app.core.preference.VectorPreferenceCategory import im.vector.app.core.preference.VectorSwitchPreference import im.vector.app.features.MainActivity import im.vector.app.features.MainActivityArgs +import im.vector.app.features.VectorFeatures import im.vector.app.features.analytics.plan.MobileScreen import im.vector.app.features.settings.font.FontScaleSettingActivity import im.vector.app.features.themes.ThemeUtils @@ -44,6 +46,7 @@ class VectorSettingsPreferencesFragment : @Inject lateinit var vectorPreferences: VectorPreferences @Inject lateinit var fontScalePreferences: FontScalePreferences + @Inject lateinit var vectorFeatures: VectorFeatures override var titleRes = R.string.settings_preferences override val preferenceXmlRes = R.xml.vector_settings_preferences @@ -99,6 +102,10 @@ class VectorSettingsPreferencesFragment : } } + findPreference(VectorPreferences.SETTINGS_PREF_SPACE_SHOW_ALL_ROOM_IN_HOME_CATEGORY)!!.let { pref -> + pref.isVisible = !vectorFeatures.isNewAppLayoutEnabled() + } + // Url preview /* TODO Note: we keep the setting client side for now diff --git a/vector/src/main/res/xml/vector_settings_preferences.xml b/vector/src/main/res/xml/vector_settings_preferences.xml index a3b8a3476c..7700de6986 100644 --- a/vector/src/main/res/xml/vector_settings_preferences.xml +++ b/vector/src/main/res/xml/vector_settings_preferences.xml @@ -30,7 +30,9 @@ - + Date: Tue, 6 Sep 2022 10:08:32 +0200 Subject: [PATCH 2/2] update according to code review --- .../java/im/vector/app/features/settings/VectorPreferences.kt | 2 +- .../app/features/settings/VectorSettingsPreferencesFragment.kt | 3 +-- vector/src/main/res/xml/vector_settings_preferences.xml | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt b/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt index d60d0ea73a..5e0cdf3baf 100755 --- a/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt @@ -168,7 +168,7 @@ class VectorPreferences @Inject constructor( /** * This is not preference, but category on preferences screen which contains [SETTINGS_PREF_SPACE_SHOW_ALL_ROOM_IN_HOME]. * Needed to show/hide this category, depending on visibility of [SETTINGS_PREF_SPACE_SHOW_ALL_ROOM_IN_HOME]. */ - const val SETTINGS_PREF_SPACE_SHOW_ALL_ROOM_IN_HOME_CATEGORY = "SETTINGS_PREF_SPACE_SHOW_ALL_ROOM_IN_HOME_CATEGORY" + const val SETTINGS_PREF_SPACE_CATEGORY = "SETTINGS_PREF_SPACE_CATEGORY" private const val SETTINGS_DEVELOPER_MODE_PREFERENCE_KEY = "SETTINGS_DEVELOPER_MODE_PREFERENCE_KEY" private const val SETTINGS_LABS_SHOW_HIDDEN_EVENTS_PREFERENCE_KEY = "SETTINGS_LABS_SHOW_HIDDEN_EVENTS_PREFERENCE_KEY" diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsPreferencesFragment.kt b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsPreferencesFragment.kt index 458ba79ee3..135c25cd8d 100644 --- a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsPreferencesFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsPreferencesFragment.kt @@ -28,7 +28,6 @@ import im.vector.app.core.dialogs.PhotoOrVideoDialog import im.vector.app.core.extensions.restart import im.vector.app.core.preference.VectorListPreference import im.vector.app.core.preference.VectorPreference -import im.vector.app.core.preference.VectorPreferenceCategory import im.vector.app.core.preference.VectorSwitchPreference import im.vector.app.features.MainActivity import im.vector.app.features.MainActivityArgs @@ -102,7 +101,7 @@ class VectorSettingsPreferencesFragment : } } - findPreference(VectorPreferences.SETTINGS_PREF_SPACE_SHOW_ALL_ROOM_IN_HOME_CATEGORY)!!.let { pref -> + findPreference(VectorPreferences.SETTINGS_PREF_SPACE_CATEGORY)!!.let { pref -> pref.isVisible = !vectorFeatures.isNewAppLayoutEnabled() } diff --git a/vector/src/main/res/xml/vector_settings_preferences.xml b/vector/src/main/res/xml/vector_settings_preferences.xml index 7700de6986..172fa5606c 100644 --- a/vector/src/main/res/xml/vector_settings_preferences.xml +++ b/vector/src/main/res/xml/vector_settings_preferences.xml @@ -32,7 +32,7 @@ + android:key="SETTINGS_PREF_SPACE_CATEGORY">