From 74ca206ed534b570b3af3a99aa10b4f51d3f3cb6 Mon Sep 17 00:00:00 2001 From: Harrison Oglesby Date: Thu, 30 Nov 2023 13:02:33 -0800 Subject: [PATCH] Bug 1864759 - Add secret setting and feature flag for toolbar redesign --- .../java/org/mozilla/fenix/FeatureFlags.kt | 10 +++++ .../toolbar/RedesignToolbarFeature.kt | 42 +++++++++++++++++++ .../fenix/settings/SecretSettingsFragment.kt | 6 +++ .../java/org/mozilla/fenix/utils/Settings.kt | 20 +++++++++ app/src/main/res/values/preference_keys.xml | 4 ++ app/src/main/res/values/static_strings.xml | 2 + .../res/xml/secret_settings_preferences.xml | 5 +++ 7 files changed, 89 insertions(+) create mode 100644 app/src/main/java/org/mozilla/fenix/components/toolbar/RedesignToolbarFeature.kt diff --git a/app/src/main/java/org/mozilla/fenix/FeatureFlags.kt b/app/src/main/java/org/mozilla/fenix/FeatureFlags.kt index d58812f67f..42a9ca5c8b 100644 --- a/app/src/main/java/org/mozilla/fenix/FeatureFlags.kt +++ b/app/src/main/java/org/mozilla/fenix/FeatureFlags.kt @@ -78,4 +78,14 @@ object FeatureFlags { * Enable Meta attribution. */ val metaAttributionEnabled = Config.channel.isNightlyOrDebug + + /** + * Enable Toolbar Redesign components and behaviors ready for Nightly. + */ + val completeToolbarRedesignEnabled = Config.channel.isNightlyOrDebug + + /** + * Enable Toolbar Redesign partial components and behaviors. + */ + val incompleteToolbarRedesignEnabled = Config.channel.isDebug } diff --git a/app/src/main/java/org/mozilla/fenix/components/toolbar/RedesignToolbarFeature.kt b/app/src/main/java/org/mozilla/fenix/components/toolbar/RedesignToolbarFeature.kt new file mode 100644 index 0000000000..2529b038bf --- /dev/null +++ b/app/src/main/java/org/mozilla/fenix/components/toolbar/RedesignToolbarFeature.kt @@ -0,0 +1,42 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +package org.mozilla.fenix.components.toolbar + +import org.mozilla.fenix.utils.Settings + +/** + * An abstraction for the Toolbar Redesign feature. + */ +interface RedesignToolbarFeature { + + /** + * Returns true if the toolbar redesign feature is enabled. + */ + val isEnabled: Boolean +} + +/** + * The complete portions of the redesigned Toolbar ready for Nightly. + * + */ +class CompleteRedesignToolbarFeature( + private val settings: Settings, +) : RedesignToolbarFeature { + + override val isEnabled: Boolean + get() = settings.enableRedesignToolbar +} + +/** + * The incomplete portions of the redesigned Toolbar still in progress. + * + */ +class IncompleteRedesignToolbarFeature( + private val settings: Settings, +) : RedesignToolbarFeature { + + override val isEnabled: Boolean + get() = settings.enableIncompleteToolbarRedesign +} diff --git a/app/src/main/java/org/mozilla/fenix/settings/SecretSettingsFragment.kt b/app/src/main/java/org/mozilla/fenix/settings/SecretSettingsFragment.kt index c69d94c2bd..6c23b54184 100644 --- a/app/src/main/java/org/mozilla/fenix/settings/SecretSettingsFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/settings/SecretSettingsFragment.kt @@ -48,6 +48,12 @@ class SecretSettingsFragment : PreferenceFragmentCompat() { onPreferenceChangeListener = SharedPreferenceUpdater() } + requirePreference(R.string.pref_key_toolbar_use_redesign_incomplete).apply { + isVisible = Config.channel.isDebug + isChecked = context.settings().enableIncompleteToolbarRedesign + onPreferenceChangeListener = SharedPreferenceUpdater() + } + requirePreference(R.string.pref_key_enable_tabs_tray_to_compose).apply { isVisible = true isChecked = context.settings().enableTabsTrayToCompose diff --git a/app/src/main/java/org/mozilla/fenix/utils/Settings.kt b/app/src/main/java/org/mozilla/fenix/utils/Settings.kt index 530a26336a..6a08be1ff5 100644 --- a/app/src/main/java/org/mozilla/fenix/utils/Settings.kt +++ b/app/src/main/java/org/mozilla/fenix/utils/Settings.kt @@ -1942,4 +1942,24 @@ class Settings(private val appContext: Context) : PreferencesHolder { default = { enableFxSuggest }, featureFlag = FeatureFlags.fxSuggest, ) + + /** + * Indicates if the user is shown new redesigned Toolbar UI. + */ + var enableRedesignToolbar by lazyFeatureFlagPreference( + key = appContext.getPreferenceKey(R.string.pref_key_toolbar_use_redesign), + default = { false }, + featureFlag = FeatureFlags.completeToolbarRedesignEnabled, + ) + + /** + * Indicates if the user is shown incomplete new redesigned Toolbar UI components and behaviors. + * + * DEV ONLY + */ + var enableIncompleteToolbarRedesign by lazyFeatureFlagPreference( + key = appContext.getPreferenceKey(R.string.pref_key_toolbar_use_redesign_incomplete), + default = { false }, + featureFlag = FeatureFlags.incompleteToolbarRedesignEnabled, + ) } diff --git a/app/src/main/res/values/preference_keys.xml b/app/src/main/res/values/preference_keys.xml index c3dc8a9941..281607fbac 100644 --- a/app/src/main/res/values/preference_keys.xml +++ b/app/src/main/res/values/preference_keys.xml @@ -138,6 +138,10 @@ pref_key_toolbar_top pref_key_toolbar_bottom + + pref_key_toolbar_use_redesign + pref_key_toolbar_use_redesign_incomplete + pref_key_privacy_pop_window diff --git a/app/src/main/res/values/static_strings.xml b/app/src/main/res/values/static_strings.xml index a6256868e4..d08972c211 100644 --- a/app/src/main/res/values/static_strings.xml +++ b/app/src/main/res/values/static_strings.xml @@ -70,6 +70,8 @@ Enable Firefox Translations Enable Firefox Suggest + + Enable Toolbar Redesign incomplete portions Enable Felt Privacy diff --git a/app/src/main/res/xml/secret_settings_preferences.xml b/app/src/main/res/xml/secret_settings_preferences.xml index 2821482b57..e48886a32a 100644 --- a/app/src/main/res/xml/secret_settings_preferences.xml +++ b/app/src/main/res/xml/secret_settings_preferences.xml @@ -25,6 +25,11 @@ android:key="@string/pref_key_enable_compose_top_sites" android:title="@string/preferences_debug_settings_compose_top_sites" app:iconSpaceReserved="false" /> +