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

For #14119 - Add a setting to toggle the display of frequently visited top sites (#14183)

This commit is contained in:
Gabriel Luong 2020-08-27 16:17:57 -04:00 committed by GitHub
parent 4cbbc52ad0
commit 31455070b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 38 additions and 4 deletions

View File

@ -9,7 +9,10 @@ import android.os.Build
import android.os.Build.VERSION.SDK_INT import android.os.Build.VERSION.SDK_INT
import android.os.Bundle import android.os.Bundle
import androidx.appcompat.app.AppCompatDelegate import androidx.appcompat.app.AppCompatDelegate
import androidx.preference.PreferenceCategory
import androidx.preference.PreferenceFragmentCompat import androidx.preference.PreferenceFragmentCompat
import androidx.preference.SwitchPreference
import org.mozilla.fenix.FeatureFlags
import org.mozilla.fenix.R import org.mozilla.fenix.R
import org.mozilla.fenix.components.metrics.Event import org.mozilla.fenix.components.metrics.Event
import org.mozilla.fenix.components.toolbar.ToolbarPosition import org.mozilla.fenix.components.toolbar.ToolbarPosition
@ -47,6 +50,7 @@ class CustomizationFragment : PreferenceFragmentCompat() {
bindAutoBatteryTheme() bindAutoBatteryTheme()
setupRadioGroups() setupRadioGroups()
setupToolbarCategory() setupToolbarCategory()
setupHomeCategory()
} }
private fun setupRadioGroups() { private fun setupRadioGroups() {
@ -129,4 +133,15 @@ class CustomizationFragment : PreferenceFragmentCompat() {
addToRadioGroup(topPreference, bottomPreference) addToRadioGroup(topPreference, bottomPreference)
} }
private fun setupHomeCategory() {
requirePreference<PreferenceCategory>(R.string.pref_home_category).apply {
isVisible = FeatureFlags.topFrecentSite
}
requirePreference<SwitchPreference>(R.string.pref_key_enable_top_frecent_sites).apply {
isVisible = FeatureFlags.topFrecentSite
isChecked = context.settings().showTopFrecentSites
onPreferenceChangeListener = SharedPreferenceUpdater()
}
}
} }

View File

@ -122,6 +122,9 @@
<string name="pref_key_auto_battery_theme" translatable="false">pref_key_auto_battery_theme</string> <string name="pref_key_auto_battery_theme" translatable="false">pref_key_auto_battery_theme</string>
<string name="pref_key_follow_device_theme" translatable="false">pref_key_follow_device_theme</string> <string name="pref_key_follow_device_theme" translatable="false">pref_key_follow_device_theme</string>
<!-- Customization Settings -->
<string name="pref_home_category" translatable="false">pref_home_category</string>
<!-- Tracking Protection Settings --> <!-- Tracking Protection Settings -->
<string name="pref_key_etp_learn_more" translatable="false">pref_key_etp_learn_more</string> <string name="pref_key_etp_learn_more" translatable="false">pref_key_etp_learn_more</string>
<string name="pref_key_tracking_protection_settings" translatable="false">pref_key_tracking_protection_settings</string> <string name="pref_key_tracking_protection_settings" translatable="false">pref_key_tracking_protection_settings</string>

View File

@ -280,6 +280,8 @@
<string name="preferences_toolbar">Toolbar</string> <string name="preferences_toolbar">Toolbar</string>
<!-- Preference for changing default theme to dark or light mode --> <!-- Preference for changing default theme to dark or light mode -->
<string name="preferences_theme">Theme</string> <string name="preferences_theme">Theme</string>
<!-- Preference for customizing the home screen -->
<string name="preferences_home">Home</string>
<!-- Preference for settings related to visual options --> <!-- Preference for settings related to visual options -->
<string name="preferences_customize">Customize</string> <string name="preferences_customize">Customize</string>
<!-- Preference description for banner about signing in --> <!-- Preference description for banner about signing in -->
@ -1488,6 +1490,8 @@
<string name="top_sites_max_limit_content">To add a new top site, remove one. Long press the site and select remove.</string> <string name="top_sites_max_limit_content">To add a new top site, remove one. Long press the site and select remove.</string>
<!-- Confirmation dialog button text when top sites limit is reached. --> <!-- Confirmation dialog button text when top sites limit is reached. -->
<string name="top_sites_max_limit_confirmation_button">OK, Got It</string> <string name="top_sites_max_limit_confirmation_button">OK, Got It</string>
<!-- Label for the show most visited sites preference -->
<string name="top_sites_toggle_top_frecent_sites">Show most visited sites</string>
<!-- Content description for close button in collection placeholder. --> <!-- Content description for close button in collection placeholder. -->
<string name="remove_home_collection_placeholder_content_description">Remove</string> <string name="remove_home_collection_placeholder_content_description">Remove</string>

View File

@ -5,10 +5,10 @@
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" <androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"> xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.preference.PreferenceCategory <androidx.preference.PreferenceCategory
android:layout="@layout/preference_cat_style"
android:title="@string/preferences_theme" android:title="@string/preferences_theme"
app:iconSpaceReserved="false"
app:allowDividerBelow="false" app:allowDividerBelow="false"
android:layout="@layout/preference_cat_style"> app:iconSpaceReserved="false">
<org.mozilla.fenix.settings.RadioButtonPreference <org.mozilla.fenix.settings.RadioButtonPreference
android:defaultValue="@bool/underAPI28" android:defaultValue="@bool/underAPI28"
android:key="@string/pref_key_light_theme" android:key="@string/pref_key_light_theme"
@ -33,10 +33,10 @@
</androidx.preference.PreferenceCategory> </androidx.preference.PreferenceCategory>
<androidx.preference.PreferenceCategory <androidx.preference.PreferenceCategory
android:layout="@layout/preference_cat_style"
android:title="@string/preferences_toolbar" android:title="@string/preferences_toolbar"
app:iconSpaceReserved="false"
app:allowDividerAbove="false" app:allowDividerAbove="false"
android:layout="@layout/preference_cat_style"> app:iconSpaceReserved="false">
<org.mozilla.fenix.settings.RadioButtonPreference <org.mozilla.fenix.settings.RadioButtonPreference
android:key="@string/pref_key_toolbar_top" android:key="@string/pref_key_toolbar_top"
android:title="@string/preference_top_toolbar" /> android:title="@string/preference_top_toolbar" />
@ -44,4 +44,16 @@
android:key="@string/pref_key_toolbar_bottom" android:key="@string/pref_key_toolbar_bottom"
android:title="@string/preference_bottom_toolbar" /> android:title="@string/preference_bottom_toolbar" />
</androidx.preference.PreferenceCategory> </androidx.preference.PreferenceCategory>
<androidx.preference.PreferenceCategory
android:key="@string/pref_home_category"
android:layout="@layout/preference_cat_style"
android:title="@string/preferences_home"
app:allowDividerAbove="false"
app:iconSpaceReserved="false"
app:isPreferenceVisible="false">
<androidx.preference.SwitchPreference
android:key="@string/pref_key_enable_top_frecent_sites"
android:title="@string/top_sites_toggle_top_frecent_sites" />
</androidx.preference.PreferenceCategory>
</androidx.preference.PreferenceScreen> </androidx.preference.PreferenceScreen>