From d7a4925a5a6f66e53453de860bc8934cb9c1e3d5 Mon Sep 17 00:00:00 2001 From: Gabriel Luong Date: Tue, 6 Oct 2020 15:19:10 -0400 Subject: [PATCH] [fenix] For https://github.com/mozilla-mobile/fenix/issues/15115 - Part 8: Add a feature flag for showing the grid view in the tabs setting --- app/src/main/java/org/mozilla/fenix/FeatureFlags.kt | 5 +++++ .../org/mozilla/fenix/settings/SecretSettingsFragment.kt | 6 ++++++ .../java/org/mozilla/fenix/settings/TabsSettingsFragment.kt | 6 ++++++ app/src/main/java/org/mozilla/fenix/utils/Settings.kt | 6 ++++++ app/src/main/res/values/preference_keys.xml | 2 ++ app/src/main/res/values/static_strings.xml | 2 ++ app/src/main/res/xml/secret_settings_preferences.xml | 5 +++++ app/src/main/res/xml/tabs_preferences.xml | 4 +++- 8 files changed, 35 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/mozilla/fenix/FeatureFlags.kt b/app/src/main/java/org/mozilla/fenix/FeatureFlags.kt index b68d5f35fe..0a0641ea40 100644 --- a/app/src/main/java/org/mozilla/fenix/FeatureFlags.kt +++ b/app/src/main/java/org/mozilla/fenix/FeatureFlags.kt @@ -26,6 +26,11 @@ object FeatureFlags { */ const val topFrecentSite = true + /** + * Shows the grid view settings for the tabs tray. + */ + val showGridViewInTabsSettings = Config.channel.isNightlyOrDebug + /** * Enables wait til first contentful paint */ 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 4fcfa280f8..3dcd31e597 100644 --- a/app/src/main/java/org/mozilla/fenix/settings/SecretSettingsFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/settings/SecretSettingsFragment.kt @@ -25,6 +25,12 @@ class SecretSettingsFragment : PreferenceFragmentCompat() { override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { setPreferencesFromResource(R.xml.secret_settings_preferences, rootKey) + requirePreference(R.string.pref_key_show_grid_view_tabs_settings).apply { + isVisible = FeatureFlags.showGridViewInTabsSettings + isChecked = context.settings().showGridViewInTabsSettings + onPreferenceChangeListener = SharedPreferenceUpdater() + } + requirePreference(R.string.pref_key_enable_top_frecent_sites).apply { isVisible = FeatureFlags.topFrecentSite isChecked = context.settings().showTopFrecentSites diff --git a/app/src/main/java/org/mozilla/fenix/settings/TabsSettingsFragment.kt b/app/src/main/java/org/mozilla/fenix/settings/TabsSettingsFragment.kt index 6898f493b3..b6aa9cf32e 100644 --- a/app/src/main/java/org/mozilla/fenix/settings/TabsSettingsFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/settings/TabsSettingsFragment.kt @@ -5,8 +5,10 @@ package org.mozilla.fenix.settings import android.os.Bundle +import androidx.preference.PreferenceCategory import androidx.preference.PreferenceFragmentCompat import org.mozilla.fenix.R +import org.mozilla.fenix.ext.settings import org.mozilla.fenix.ext.showToolbar import org.mozilla.fenix.utils.view.addToRadioGroup @@ -41,6 +43,10 @@ class TabsSettingsFragment : PreferenceFragmentCompat() { radioOneMonth = requirePreference(R.string.pref_key_close_tabs_after_one_month) setupRadioGroups() + + requirePreference(R.string.pref_key_tab_view_category).apply { + isVisible = context.settings().showGridViewInTabsSettings + } } private fun setupRadioGroups() { 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 247ce6696e..2f22677865 100644 --- a/app/src/main/java/org/mozilla/fenix/utils/Settings.kt +++ b/app/src/main/java/org/mozilla/fenix/utils/Settings.kt @@ -124,6 +124,12 @@ class Settings(private val appContext: Context) : PreferencesHolder { val canShowCfr: Boolean get() = (System.currentTimeMillis() - lastCfrShownTimeInMillis) > THREE_DAYS_MS + var showGridViewInTabsSettings by featureFlagPreference( + appContext.getPreferenceKey(R.string.pref_key_show_grid_view_tabs_settings), + default = false, + featureFlag = FeatureFlags.showGridViewInTabsSettings + ) + var waitToShowPageUntilFirstPaint by featureFlagPreference( appContext.getPreferenceKey(R.string.pref_key_wait_first_paint), default = false, diff --git a/app/src/main/res/values/preference_keys.xml b/app/src/main/res/values/preference_keys.xml index 6a22c6dcef..e6bc0618a9 100644 --- a/app/src/main/res/values/preference_keys.xml +++ b/app/src/main/res/values/preference_keys.xml @@ -224,6 +224,7 @@ pref_key_show_collections_home + pref_key_tab_view_category pref_key_tab_view_list pref_key_tab_view_grid pref_key_tabs @@ -231,6 +232,7 @@ pref_key_close_tabs_after_one_day pref_key_close_tabs_after_one_week pref_key_close_tabs_after_one_month + pref_key_show_grid_view_tabs_settings pref_key_camera_permissions_needed diff --git a/app/src/main/res/values/static_strings.xml b/app/src/main/res/values/static_strings.xml index 2d46b333c6..e8fa3a8fc2 100644 --- a/app/src/main/res/values/static_strings.xml +++ b/app/src/main/res/values/static_strings.xml @@ -32,6 +32,8 @@ Secret Settings + + Show Grid View in Tabs Settings Show Top Frequently Visited Sites diff --git a/app/src/main/res/xml/secret_settings_preferences.xml b/app/src/main/res/xml/secret_settings_preferences.xml index 3a20cef48b..f5d8b26cf3 100644 --- a/app/src/main/res/xml/secret_settings_preferences.xml +++ b/app/src/main/res/xml/secret_settings_preferences.xml @@ -4,6 +4,11 @@ - file, You can obtain one at http://mozilla.org/MPL/2.0/. --> + + app:iconSpaceReserved="false" + app:isPreferenceVisible="false">