2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-11 13:11:01 +00:00

Bug 1848377 - Add secret setting to control the visibility of the Shopping feature

This commit is contained in:
Noah Bond 2023-08-15 08:24:50 -07:00 committed by mergify[bot]
parent 4c52f74add
commit d0f75706c0
8 changed files with 43 additions and 5 deletions

View File

@ -50,6 +50,7 @@ import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.nimbus.FxNimbus import org.mozilla.fenix.nimbus.FxNimbus
import org.mozilla.fenix.settings.quicksettings.protections.cookiebanners.dialog.CookieBannerReEngagementDialogUtils import org.mozilla.fenix.settings.quicksettings.protections.cookiebanners.dialog.CookieBannerReEngagementDialogUtils
import org.mozilla.fenix.settings.quicksettings.protections.cookiebanners.getCookieBannerUIMode import org.mozilla.fenix.settings.quicksettings.protections.cookiebanners.getCookieBannerUIMode
import org.mozilla.fenix.shopping.DefaultShoppingExperienceFeature
import org.mozilla.fenix.shopping.ReviewQualityCheckFeature import org.mozilla.fenix.shopping.ReviewQualityCheckFeature
import org.mozilla.fenix.shortcut.PwaOnboardingObserver import org.mozilla.fenix.shortcut.PwaOnboardingObserver
import org.mozilla.fenix.theme.ThemeManager import org.mozilla.fenix.theme.ThemeManager
@ -226,6 +227,9 @@ class BrowserFragment : BaseBrowserFragment(), UserInteractionHandler {
reviewQualityCheckFeature.set( reviewQualityCheckFeature.set(
feature = ReviewQualityCheckFeature( feature = ReviewQualityCheckFeature(
browserStore = context.components.core.store, browserStore = context.components.core.store,
shoppingExperienceFeature = DefaultShoppingExperienceFeature(
settings = requireContext().settings(),
),
onAvailabilityChange = { reviewQualityCheckAvailable = it }, onAvailabilityChange = { reviewQualityCheckAvailable = it },
), ),
owner = this, owner = this,

View File

@ -64,6 +64,12 @@ class SecretSettingsFragment : PreferenceFragmentCompat() {
onPreferenceChangeListener = SharedPreferenceUpdater() onPreferenceChangeListener = SharedPreferenceUpdater()
} }
requirePreference<SwitchPreference>(R.string.pref_key_enable_shopping_experience).apply {
isVisible = Config.channel.isNightlyOrDebug
isChecked = context.settings().enableShoppingExperience
onPreferenceChangeListener = SharedPreferenceUpdater()
}
// for performance reasons, this is only available in Nightly or Debug builds // for performance reasons, this is only available in Nightly or Debug builds
requirePreference<EditTextPreference>(R.string.pref_key_custom_glean_server_url).apply { requirePreference<EditTextPreference>(R.string.pref_key_custom_glean_server_url).apply {
isVisible = Config.channel.isNightlyOrDebug && BuildConfig.GLEAN_CUSTOM_URL.isNullOrEmpty() isVisible = Config.channel.isNightlyOrDebug && BuildConfig.GLEAN_CUSTOM_URL.isNullOrEmpty()

View File

@ -25,7 +25,7 @@ import mozilla.components.support.base.feature.LifecycleAwareFeature
*/ */
class ReviewQualityCheckFeature( class ReviewQualityCheckFeature(
private val browserStore: BrowserStore, private val browserStore: BrowserStore,
private val shoppingExperienceFeature: ShoppingExperienceFeature = ShoppingExperienceFeature(), private val shoppingExperienceFeature: ShoppingExperienceFeature,
private val onAvailabilityChange: (isAvailable: Boolean) -> Unit, private val onAvailabilityChange: (isAvailable: Boolean) -> Unit,
) : LifecycleAwareFeature { ) : LifecycleAwareFeature {
private var scope: CoroutineScope? = null private var scope: CoroutineScope? = null

View File

@ -4,16 +4,28 @@
package org.mozilla.fenix.shopping package org.mozilla.fenix.shopping
import org.mozilla.fenix.nimbus.FxNimbus import org.mozilla.fenix.utils.Settings
/** /**
* An abstraction for shopping experience feature flag. * An abstraction for shopping experience feature flag.
*/ */
class ShoppingExperienceFeature { interface ShoppingExperienceFeature {
/** /**
* Returns true if the shopping experience feature is enabled. * Returns true if the shopping experience feature is enabled.
*/ */
val isEnabled val isEnabled: Boolean
get() = FxNimbus.features.shoppingExperience.value().enabled }
/**
* The default implementation of [ShoppingExperienceFeature].
*
* @property settings Used to check if the feature is enabled.
*/
class DefaultShoppingExperienceFeature(
private val settings: Settings,
) : ShoppingExperienceFeature {
override val isEnabled
get() = settings.enableShoppingExperience
} }

View File

@ -1789,6 +1789,14 @@ class Settings(private val appContext: Context) : PreferencesHolder {
default = FeatureFlags.composeTopSites, default = FeatureFlags.composeTopSites,
) )
/**
* Indicates if the shopping experience feature is enabled.
*/
val enableShoppingExperience by booleanPreference(
key = appContext.getPreferenceKey(R.string.pref_key_enable_shopping_experience),
default = FxNimbus.features.shoppingExperience.value().enabled,
)
/** /**
* Adjust Activated User sent * Adjust Activated User sent
*/ */

View File

@ -350,6 +350,7 @@
<string name="pref_key_custom_sponsored_stories_country" translatable="false">pref_key_custom_sponsored_stories_country</string> <string name="pref_key_custom_sponsored_stories_country" translatable="false">pref_key_custom_sponsored_stories_country</string>
<string name="pref_key_custom_sponsored_stories_city" translatable="false">pref_key_custom_sponsored_stories_city</string> <string name="pref_key_custom_sponsored_stories_city" translatable="false">pref_key_custom_sponsored_stories_city</string>
<string name="pref_key_enable_compose_top_sites" translatable="false">pref_key_enable_compose_top_sites</string> <string name="pref_key_enable_compose_top_sites" translatable="false">pref_key_enable_compose_top_sites</string>
<string name="pref_key_enable_shopping_experience" translatable="false">pref_key_enable_shopping_experience</string>
<!-- Growth Data --> <!-- Growth Data -->
<string name="pref_key_growth_set_as_default" translatable="false">pref_key_growth_set_as_default</string> <string name="pref_key_growth_set_as_default" translatable="false">pref_key_growth_set_as_default</string>

View File

@ -66,6 +66,8 @@
<string name="preferences_debug_settings_tabs_tray_to_compose" translatable="false">Enable Tabs Tray to Compose rewrite</string> <string name="preferences_debug_settings_tabs_tray_to_compose" translatable="false">Enable Tabs Tray to Compose rewrite</string>
<!-- Label for enabling the Compose Top Sites --> <!-- Label for enabling the Compose Top Sites -->
<string name="preferences_debug_settings_compose_top_sites" translatable="false">Enable Compose Top Sites</string> <string name="preferences_debug_settings_compose_top_sites" translatable="false">Enable Compose Top Sites</string>
<!-- Label for enabling the shopping experience -->
<string name="preferences_debug_settings_shopping_experience" translatable="false">Enable Shopping Experience</string>
<!-- A secret menu option in the tabs tray for making a tab inactive for testing. --> <!-- A secret menu option in the tabs tray for making a tab inactive for testing. -->
<string name="inactive_tabs_menu_item">Make inactive</string> <string name="inactive_tabs_menu_item">Make inactive</string>

View File

@ -30,6 +30,11 @@
android:key="@string/pref_key_enable_compose_top_sites" android:key="@string/pref_key_enable_compose_top_sites"
android:title="@string/preferences_debug_settings_compose_top_sites" android:title="@string/preferences_debug_settings_compose_top_sites"
app:iconSpaceReserved="false" /> app:iconSpaceReserved="false" />
<SwitchPreference
android:defaultValue="false"
android:key="@string/pref_key_enable_shopping_experience"
android:title="@string/preferences_debug_settings_shopping_experience"
app:iconSpaceReserved="false" />
<EditTextPreference <EditTextPreference
android:key="@string/pref_key_custom_glean_server_url" android:key="@string/pref_key_custom_glean_server_url"
android:title="@string/preferences_debug_settings_custom_glean_server_url" android:title="@string/preferences_debug_settings_custom_glean_server_url"