Changes vector feature preference key and function name for clarity

This commit is contained in:
ericdecanini 2022-09-06 16:07:12 +02:00
parent 31a3552e26
commit b7efd6384c
9 changed files with 20 additions and 13 deletions

View File

@ -152,7 +152,7 @@ class ElementRobot {
} }
fun signout(expectSignOutWarning: Boolean) { fun signout(expectSignOutWarning: Boolean) {
if (features.isNewAppLayoutEnabled()) { if (features.isNewAppLayoutFeatureEnabled()) {
onView(withId((R.id.avatar))) onView(withId((R.id.avatar)))
.perform(click()) .perform(click())
waitUntilActivityVisible<VectorSettingsActivity> { waitUntilActivityVisible<VectorSettingsActivity> {

View File

@ -88,7 +88,7 @@ class DebugFeaturesStateFactory @Inject constructor(
createBooleanFeature( createBooleanFeature(
label = "Enable New App Layout", label = "Enable New App Layout",
key = DebugFeatureKeys.newAppLayoutEnabled, key = DebugFeatureKeys.newAppLayoutEnabled,
factory = VectorFeatures::isNewAppLayoutEnabled factory = VectorFeatures::isNewAppLayoutFeatureEnabled
), ),
createBooleanFeature( createBooleanFeature(
label = "Enable New Device Management", label = "Enable New Device Management",

View File

@ -76,8 +76,8 @@ class DebugVectorFeatures(
override fun shouldStartDmOnFirstMessage(): Boolean = read(DebugFeatureKeys.startDmOnFirstMsg) override fun shouldStartDmOnFirstMessage(): Boolean = read(DebugFeatureKeys.startDmOnFirstMsg)
?: vectorFeatures.shouldStartDmOnFirstMessage() ?: vectorFeatures.shouldStartDmOnFirstMessage()
override fun isNewAppLayoutEnabled(): Boolean = read(DebugFeatureKeys.newAppLayoutEnabled) override fun isNewAppLayoutFeatureEnabled(): Boolean = read(DebugFeatureKeys.newAppLayoutEnabled)
?: vectorFeatures.isNewAppLayoutEnabled() ?: vectorFeatures.isNewAppLayoutFeatureEnabled()
override fun isNewDeviceManagementEnabled(): Boolean = read(DebugFeatureKeys.newDeviceManagementEnabled) override fun isNewDeviceManagementEnabled(): Boolean = read(DebugFeatureKeys.newDeviceManagementEnabled)
?: vectorFeatures.isNewDeviceManagementEnabled() ?: vectorFeatures.isNewDeviceManagementEnabled()

View File

@ -18,6 +18,7 @@ package im.vector.app.features
import im.vector.app.config.Config import im.vector.app.config.Config
import im.vector.app.config.OnboardingVariant import im.vector.app.config.OnboardingVariant
import im.vector.app.features.settings.VectorPreferences
interface VectorFeatures { interface VectorFeatures {
@ -33,7 +34,13 @@ interface VectorFeatures {
fun isLocationSharingEnabled(): Boolean fun isLocationSharingEnabled(): Boolean
fun forceUsageOfOpusEncoder(): Boolean fun forceUsageOfOpusEncoder(): Boolean
fun shouldStartDmOnFirstMessage(): Boolean fun shouldStartDmOnFirstMessage(): Boolean
fun isNewAppLayoutEnabled(): Boolean
/**
* This is only to enable if the labs flag should be visible and effective
* If on the client-side you want functionality that should be enabled with the new layout,
* use [VectorPreferences.isNewAppLayoutEnabled] instead
*/
fun isNewAppLayoutFeatureEnabled(): Boolean
fun isNewDeviceManagementEnabled(): Boolean fun isNewDeviceManagementEnabled(): Boolean
} }
@ -50,6 +57,6 @@ class DefaultVectorFeatures : VectorFeatures {
override fun isLocationSharingEnabled() = Config.ENABLE_LOCATION_SHARING override fun isLocationSharingEnabled() = Config.ENABLE_LOCATION_SHARING
override fun forceUsageOfOpusEncoder(): Boolean = false override fun forceUsageOfOpusEncoder(): Boolean = false
override fun shouldStartDmOnFirstMessage(): Boolean = false override fun shouldStartDmOnFirstMessage(): Boolean = false
override fun isNewAppLayoutEnabled(): Boolean = true override fun isNewAppLayoutFeatureEnabled(): Boolean = true
override fun isNewDeviceManagementEnabled(): Boolean = false override fun isNewDeviceManagementEnabled(): Boolean = false
} }

View File

@ -120,7 +120,7 @@ class HomeActivityViewModel @AssistedInject constructor(
private fun observeReleaseNotes() = withState { state -> private fun observeReleaseNotes() = withState { state ->
// we don't want to show release notes for new users or after relogin // we don't want to show release notes for new users or after relogin
if (state.authenticationDescription == null && vectorFeatures.isNewAppLayoutEnabled()) { if (state.authenticationDescription == null && vectorFeatures.isNewAppLayoutFeatureEnabled()) {
releaseNotesPreferencesStore.appLayoutOnboardingShown.onEach { isAppLayoutOnboardingShown -> releaseNotesPreferencesStore.appLayoutOnboardingShown.onEach { isAppLayoutOnboardingShown ->
if (!isAppLayoutOnboardingShown) { if (!isAppLayoutOnboardingShown) {
releaseNotesPreferencesStore.setAppLayoutOnboardingShown(true) releaseNotesPreferencesStore.setAppLayoutOnboardingShown(true)

View File

@ -65,7 +65,7 @@ class VectorPreferences @Inject constructor(
const val SETTINGS_BACKGROUND_SYNC_PREFERENCE_KEY = "SETTINGS_BACKGROUND_SYNC_PREFERENCE_KEY" const val SETTINGS_BACKGROUND_SYNC_PREFERENCE_KEY = "SETTINGS_BACKGROUND_SYNC_PREFERENCE_KEY"
const val SETTINGS_BACKGROUND_SYNC_DIVIDER_PREFERENCE_KEY = "SETTINGS_BACKGROUND_SYNC_DIVIDER_PREFERENCE_KEY" const val SETTINGS_BACKGROUND_SYNC_DIVIDER_PREFERENCE_KEY = "SETTINGS_BACKGROUND_SYNC_DIVIDER_PREFERENCE_KEY"
const val SETTINGS_LABS_PREFERENCE_KEY = "SETTINGS_LABS_PREFERENCE_KEY" const val SETTINGS_LABS_PREFERENCE_KEY = "SETTINGS_LABS_PREFERENCE_KEY"
const val SETTINGS_LABS_NEW_APP_LAYOUT_KEY = "SETTINGS_LABS_ENABLE_NEW_LAYOUT" const val SETTINGS_LABS_NEW_APP_LAYOUT_KEY = "SETTINGS_LABS_NEW_APP_LAYOUT_KEY"
const val SETTINGS_CRYPTOGRAPHY_PREFERENCE_KEY = "SETTINGS_CRYPTOGRAPHY_PREFERENCE_KEY" const val SETTINGS_CRYPTOGRAPHY_PREFERENCE_KEY = "SETTINGS_CRYPTOGRAPHY_PREFERENCE_KEY"
const val SETTINGS_CRYPTOGRAPHY_DIVIDER_PREFERENCE_KEY = "SETTINGS_CRYPTOGRAPHY_DIVIDER_PREFERENCE_KEY" const val SETTINGS_CRYPTOGRAPHY_DIVIDER_PREFERENCE_KEY = "SETTINGS_CRYPTOGRAPHY_DIVIDER_PREFERENCE_KEY"
const val SETTINGS_CRYPTOGRAPHY_MANAGE_PREFERENCE_KEY = "SETTINGS_CRYPTOGRAPHY_MANAGE_PREFERENCE_KEY" const val SETTINGS_CRYPTOGRAPHY_MANAGE_PREFERENCE_KEY = "SETTINGS_CRYPTOGRAPHY_MANAGE_PREFERENCE_KEY"
@ -1158,7 +1158,7 @@ class VectorPreferences @Inject constructor(
* Indicates whether or not new app layout is enabled. * Indicates whether or not new app layout is enabled.
*/ */
fun isNewAppLayoutEnabled(): Boolean { fun isNewAppLayoutEnabled(): Boolean {
return vectorFeatures.isNewAppLayoutEnabled() && return vectorFeatures.isNewAppLayoutFeatureEnabled() &&
defaultPrefs.getBoolean(SETTINGS_LABS_NEW_APP_LAYOUT_KEY, getDefault(R.bool.settings_labs_new_app_layout_default)) defaultPrefs.getBoolean(SETTINGS_LABS_NEW_APP_LAYOUT_KEY, getDefault(R.bool.settings_labs_new_app_layout_default))
} }

View File

@ -76,11 +76,11 @@ class VectorSettingsLabsFragment :
} }
findPreference<VectorSwitchPreference>(VectorPreferences.SETTINGS_LABS_NEW_APP_LAYOUT_KEY)?.let { pref -> findPreference<VectorSwitchPreference>(VectorPreferences.SETTINGS_LABS_NEW_APP_LAYOUT_KEY)?.let { pref ->
pref.isVisible = vectorFeatures.isNewAppLayoutEnabled() pref.isVisible = vectorFeatures.isNewAppLayoutFeatureEnabled()
} }
findPreference<VectorSwitchPreference>(VectorPreferences.SETTINGS_LABS_UNREAD_NOTIFICATIONS_AS_TAB)?.let { pref -> findPreference<VectorSwitchPreference>(VectorPreferences.SETTINGS_LABS_UNREAD_NOTIFICATIONS_AS_TAB)?.let { pref ->
pref.isVisible = !vectorFeatures.isNewAppLayoutEnabled() pref.isVisible = !vectorFeatures.isNewAppLayoutFeatureEnabled()
} }
} }

View File

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

View File

@ -85,7 +85,7 @@
<im.vector.app.core.preference.VectorSwitchPreference <im.vector.app.core.preference.VectorSwitchPreference
android:defaultValue="@bool/settings_labs_new_app_layout_default" android:defaultValue="@bool/settings_labs_new_app_layout_default"
android:key="SETTINGS_LABS_ENABLE_NEW_LAYOUT" android:key="SETTINGS_LABS_NEW_APP_LAYOUT_KEY"
android:summary="@string/labs_enable_new_app_layout_summary" android:summary="@string/labs_enable_new_app_layout_summary"
android:title="@string/labs_enable_new_app_layout_title" /> android:title="@string/labs_enable_new_app_layout_title" />