Changes some preferences to be enabled or disabled by labs flag

This commit is contained in:
ericdecanini 2022-09-06 17:32:08 +02:00
parent d77ce27953
commit 9564c8f144
2 changed files with 18 additions and 0 deletions

View File

@ -77,10 +77,20 @@ class VectorSettingsLabsFragment :
findPreference<VectorSwitchPreference>(VectorPreferences.SETTINGS_LABS_NEW_APP_LAYOUT_KEY)?.let { pref ->
pref.isVisible = vectorFeatures.isNewAppLayoutFeatureEnabled()
pref.onPreferenceClickListener = Preference.OnPreferenceClickListener {
onNewLayoutPreferenceClicked()
true
}
}
configureUnreadNotificationsAsTabPreference()
}
private fun configureUnreadNotificationsAsTabPreference() {
findPreference<VectorSwitchPreference>(VectorPreferences.SETTINGS_LABS_UNREAD_NOTIFICATIONS_AS_TAB)?.let { pref ->
pref.isVisible = !vectorFeatures.isNewAppLayoutFeatureEnabled()
pref.isEnabled = !vectorPreferences.isNewAppLayoutEnabled()
}
}
@ -123,4 +133,11 @@ class VectorSettingsLabsFragment :
displayLoadingView()
MainActivity.restartApp(requireActivity(), MainActivityArgs(clearCache = true))
}
/**
* Action when new layout preference switch is actually clicked.
*/
private fun onNewLayoutPreferenceClicked() {
configureUnreadNotificationsAsTabPreference()
}
}

View File

@ -103,6 +103,7 @@ class VectorSettingsPreferencesFragment :
findPreference<Preference>(VectorPreferences.SETTINGS_PREF_SPACE_CATEGORY)!!.let { pref ->
pref.isVisible = !vectorFeatures.isNewAppLayoutFeatureEnabled()
pref.isEnabled = !vectorPreferences.isNewAppLayoutEnabled()
}
// Url preview