From 188ba0b4213faf10bc9722c53184eeba2fafc4f7 Mon Sep 17 00:00:00 2001 From: Gabriel Luong Date: Thu, 27 Aug 2020 16:17:57 -0400 Subject: [PATCH] [fenix] For https://github.com/mozilla-mobile/fenix/issues/14119 - Add a setting to toggle the display of frequently visited top sites (https://github.com/mozilla-mobile/fenix/pull/14183) --- .../fenix/settings/CustomizationFragment.kt | 15 ++++++++++++++ app/src/main/res/values/preference_keys.xml | 3 +++ app/src/main/res/values/strings.xml | 4 ++++ .../res/xml/customization_preferences.xml | 20 +++++++++++++++---- 4 files changed, 38 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/mozilla/fenix/settings/CustomizationFragment.kt b/app/src/main/java/org/mozilla/fenix/settings/CustomizationFragment.kt index 3d586befd9..14f3c2a96e 100644 --- a/app/src/main/java/org/mozilla/fenix/settings/CustomizationFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/settings/CustomizationFragment.kt @@ -9,7 +9,10 @@ import android.os.Build import android.os.Build.VERSION.SDK_INT import android.os.Bundle import androidx.appcompat.app.AppCompatDelegate +import androidx.preference.PreferenceCategory import androidx.preference.PreferenceFragmentCompat +import androidx.preference.SwitchPreference +import org.mozilla.fenix.FeatureFlags import org.mozilla.fenix.R import org.mozilla.fenix.components.metrics.Event import org.mozilla.fenix.components.toolbar.ToolbarPosition @@ -47,6 +50,7 @@ class CustomizationFragment : PreferenceFragmentCompat() { bindAutoBatteryTheme() setupRadioGroups() setupToolbarCategory() + setupHomeCategory() } private fun setupRadioGroups() { @@ -129,4 +133,15 @@ class CustomizationFragment : PreferenceFragmentCompat() { addToRadioGroup(topPreference, bottomPreference) } + + private fun setupHomeCategory() { + requirePreference(R.string.pref_home_category).apply { + isVisible = FeatureFlags.topFrecentSite + } + requirePreference(R.string.pref_key_enable_top_frecent_sites).apply { + isVisible = FeatureFlags.topFrecentSite + isChecked = context.settings().showTopFrecentSites + onPreferenceChangeListener = SharedPreferenceUpdater() + } + } } diff --git a/app/src/main/res/values/preference_keys.xml b/app/src/main/res/values/preference_keys.xml index 0043ba7b36..ffa959a25f 100644 --- a/app/src/main/res/values/preference_keys.xml +++ b/app/src/main/res/values/preference_keys.xml @@ -122,6 +122,9 @@ pref_key_auto_battery_theme pref_key_follow_device_theme + + pref_home_category + pref_key_etp_learn_more pref_key_tracking_protection_settings diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 714e19d6ef..5f62d7dc10 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -280,6 +280,8 @@ Toolbar Theme + + Home Customize @@ -1488,6 +1490,8 @@ To add a new top site, remove one. Long press the site and select remove. OK, Got It + + Show most visited sites Remove diff --git a/app/src/main/res/xml/customization_preferences.xml b/app/src/main/res/xml/customization_preferences.xml index 19ab4c97f1..8398cf705a 100644 --- a/app/src/main/res/xml/customization_preferences.xml +++ b/app/src/main/res/xml/customization_preferences.xml @@ -5,10 +5,10 @@ + app:iconSpaceReserved="false"> + app:iconSpaceReserved="false"> @@ -44,4 +44,16 @@ android:key="@string/pref_key_toolbar_bottom" android:title="@string/preference_bottom_toolbar" /> + + + +