From bbb602a2fd55614e5c5dda64e0173054f6fd6ba3 Mon Sep 17 00:00:00 2001 From: sarah541 Date: Wed, 3 Aug 2022 16:03:26 -0400 Subject: [PATCH] For #26308 - Add feature flag for MR onboarding --- .experimenter.yaml | 8 +++++++ .../java/org/mozilla/fenix/FeatureFlags.kt | 5 +++++ .../java/org/mozilla/fenix/utils/Settings.kt | 14 ++++++++++++ app/src/main/res/values/preference_keys.xml | 2 ++ nimbus.fml.yaml | 22 +++++++++++++++++++ 5 files changed, 51 insertions(+) diff --git a/.experimenter.yaml b/.experimenter.yaml index 2b3eaeb84..883006b14 100644 --- a/.experimenter.yaml +++ b/.experimenter.yaml @@ -58,6 +58,14 @@ nimbus-validation: settings-title: type: string description: The title of displayed in the Settings screen and app menu. +onboarding: + description: The onboarding features displayed on homescreen. + hasExposure: true + exposureDescription: "" + variables: + sections-enabled: + type: json + description: This property provides a lookup table of whether or not the given section should be enabled. pocket-sponsored-stories: description: A feature showing sponsored stories in between the other Pocket recommended stories on homescreen. hasExposure: true diff --git a/app/src/main/java/org/mozilla/fenix/FeatureFlags.kt b/app/src/main/java/org/mozilla/fenix/FeatureFlags.kt index fec76af57..7a86a524e 100644 --- a/app/src/main/java/org/mozilla/fenix/FeatureFlags.kt +++ b/app/src/main/java/org/mozilla/fenix/FeatureFlags.kt @@ -23,6 +23,11 @@ object FeatureFlags { */ const val syncAddressesFeature = false + /** + * Enables the on-boarding sync cfr on the home screen. + */ + val showSynCFR = Config.channel.isDebug + /** * Enables the "recent" tabs feature in the home screen. */ 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 e2631cf1d..187a75f84 100644 --- a/app/src/main/java/org/mozilla/fenix/utils/Settings.kt +++ b/app/src/main/java/org/mozilla/fenix/utils/Settings.kt @@ -44,6 +44,7 @@ import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.getPreferenceKey import org.mozilla.fenix.nimbus.FxNimbus import org.mozilla.fenix.nimbus.HomeScreenSection +import org.mozilla.fenix.nimbus.OnboardingSection import org.mozilla.fenix.settings.PhoneFeature import org.mozilla.fenix.settings.deletebrowsingdata.DeleteBrowsingDataOnQuitType import org.mozilla.fenix.settings.logins.SavedLoginsSortingStrategyMenu @@ -1200,6 +1201,9 @@ class Settings(private val appContext: Context) : PreferencesHolder { default = false ) + private val onboardScreenSection: Map get() = + FxNimbus.features.onboarding.value().sectionsEnabled + private val homescreenSections: Map get() = try { FxNimbus.features.homescreen.value().sectionsEnabled } catch (e: NimbusFeatureException) { @@ -1212,6 +1216,16 @@ class Settings(private val appContext: Context) : PreferencesHolder { featureFlag = FeatureFlags.historyMetadataUIFeature || isHistoryMetadataEnabled ) + /** + * Indicates if sync on-boarding CFR should be shown + * Returns true if the [FeatureFlags.showSynCFR] and [R.string.pref_key_should_show_sync_cfr] are true. + */ + var showSyncCFR by lazyFeatureFlagPreference( + appContext.getPreferenceKey(R.string.pref_key_should_show_sync_cfr), + featureFlag = FeatureFlags.showSynCFR, + default = { onboardScreenSection[OnboardingSection.SYNC_CFR] == true }, + ) + /** * Indicates if the recent tabs functionality should be visible. * Returns true if the [FeatureFlags.showRecentTabsFeature] and [R.string.pref_key_recent_tabs] are true. diff --git a/app/src/main/res/values/preference_keys.xml b/app/src/main/res/values/preference_keys.xml index 599b989de..5f92548e1 100644 --- a/app/src/main/res/values/preference_keys.xml +++ b/app/src/main/res/values/preference_keys.xml @@ -236,6 +236,8 @@ pref_key_has_inactive_tabs_auto_close_dialog_dismissed pref_key_should_show_jump_back_in_tabs_popup + + pref_key_should_show_sync_cfr pref_key_debug_settings diff --git a/nimbus.fml.yaml b/nimbus.fml.yaml index 81cd9979e..86873a277 100644 --- a/nimbus.fml.yaml +++ b/nimbus.fml.yaml @@ -33,6 +33,23 @@ features: "contile-top-sites": false, } } + onboarding: + description: The homescreen that the user goes to when they press home or new tab. + variables: + sections-enabled: + description: "This property provides a lookup table of whether or not the given section should be enabled." + type: Map + default: + { + "sync-cfr": false + } + defaults: + - channel: nightly + value: { + "sections-enabled": { + "sync-cfr": false + } + } nimbus-validation: description: "A feature that does not correspond to an application feature suitable for showing that Nimbus is working. This should never be used in production." @@ -305,4 +322,9 @@ types: description: A setting in the settings screen. homescreen-banner: description: A banner in the homescreen. + OnboardingSection: + description: The identifiers for the sections of the onboarding. + variants: + sync-cfr: + description: Sync onboarding CFR.