|
|
@ -11,9 +11,8 @@ import androidx.preference.Preference
|
|
|
|
import androidx.preference.PreferenceFragmentCompat
|
|
|
|
import androidx.preference.PreferenceFragmentCompat
|
|
|
|
import androidx.preference.SwitchPreference
|
|
|
|
import androidx.preference.SwitchPreference
|
|
|
|
import org.mozilla.fenix.FeatureFlags
|
|
|
|
import org.mozilla.fenix.FeatureFlags
|
|
|
|
|
|
|
|
import org.mozilla.fenix.GleanMetrics.CustomizeHome
|
|
|
|
import org.mozilla.fenix.R
|
|
|
|
import org.mozilla.fenix.R
|
|
|
|
import org.mozilla.fenix.components.metrics.Event
|
|
|
|
|
|
|
|
import org.mozilla.fenix.ext.components
|
|
|
|
|
|
|
|
import org.mozilla.fenix.ext.settings
|
|
|
|
import org.mozilla.fenix.ext.settings
|
|
|
|
import org.mozilla.fenix.ext.showToolbar
|
|
|
|
import org.mozilla.fenix.ext.showToolbar
|
|
|
|
import org.mozilla.fenix.utils.view.addToRadioGroup
|
|
|
|
import org.mozilla.fenix.utils.view.addToRadioGroup
|
|
|
@ -36,37 +35,91 @@ class HomeSettingsFragment : PreferenceFragmentCompat() {
|
|
|
|
private fun setupPreferences() {
|
|
|
|
private fun setupPreferences() {
|
|
|
|
requirePreference<SwitchPreference>(R.string.pref_key_show_top_sites).apply {
|
|
|
|
requirePreference<SwitchPreference>(R.string.pref_key_show_top_sites).apply {
|
|
|
|
isChecked = context.settings().showTopSitesFeature
|
|
|
|
isChecked = context.settings().showTopSitesFeature
|
|
|
|
onPreferenceChangeListener = CustomizeHomeMetricsUpdater()
|
|
|
|
onPreferenceChangeListener = object : SharedPreferenceUpdater() {
|
|
|
|
|
|
|
|
override fun onPreferenceChange(preference: Preference, newValue: Any?): Boolean {
|
|
|
|
|
|
|
|
CustomizeHome.preferenceToggled.record(
|
|
|
|
|
|
|
|
CustomizeHome.PreferenceToggledExtra(
|
|
|
|
|
|
|
|
newValue as Boolean,
|
|
|
|
|
|
|
|
"most_visited_sites"
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return super.onPreferenceChange(preference, newValue)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
requirePreference<CheckBoxPreference>(R.string.pref_key_enable_contile).apply {
|
|
|
|
requirePreference<CheckBoxPreference>(R.string.pref_key_enable_contile).apply {
|
|
|
|
isVisible = FeatureFlags.contileFeature
|
|
|
|
isVisible = FeatureFlags.contileFeature
|
|
|
|
isChecked = context.settings().showContileFeature
|
|
|
|
isChecked = context.settings().showContileFeature
|
|
|
|
onPreferenceChangeListener = CustomizeHomeMetricsUpdater()
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
requirePreference<SwitchPreference>(R.string.pref_key_recent_tabs).apply {
|
|
|
|
requirePreference<SwitchPreference>(R.string.pref_key_recent_tabs).apply {
|
|
|
|
isVisible = FeatureFlags.showRecentTabsFeature
|
|
|
|
isVisible = FeatureFlags.showRecentTabsFeature
|
|
|
|
isChecked = context.settings().showRecentTabsFeature
|
|
|
|
isChecked = context.settings().showRecentTabsFeature
|
|
|
|
onPreferenceChangeListener = CustomizeHomeMetricsUpdater()
|
|
|
|
onPreferenceChangeListener = object : SharedPreferenceUpdater() {
|
|
|
|
|
|
|
|
override fun onPreferenceChange(preference: Preference, newValue: Any?): Boolean {
|
|
|
|
|
|
|
|
CustomizeHome.preferenceToggled.record(
|
|
|
|
|
|
|
|
CustomizeHome.PreferenceToggledExtra(
|
|
|
|
|
|
|
|
newValue as Boolean,
|
|
|
|
|
|
|
|
"jump_back_in"
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return super.onPreferenceChange(preference, newValue)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
requirePreference<SwitchPreference>(R.string.pref_key_recent_bookmarks).apply {
|
|
|
|
requirePreference<SwitchPreference>(R.string.pref_key_recent_bookmarks).apply {
|
|
|
|
isVisible = FeatureFlags.recentBookmarksFeature
|
|
|
|
isVisible = FeatureFlags.recentBookmarksFeature
|
|
|
|
isChecked = context.settings().showRecentBookmarksFeature
|
|
|
|
isChecked = context.settings().showRecentBookmarksFeature
|
|
|
|
onPreferenceChangeListener = CustomizeHomeMetricsUpdater()
|
|
|
|
onPreferenceChangeListener = object : SharedPreferenceUpdater() {
|
|
|
|
|
|
|
|
override fun onPreferenceChange(preference: Preference, newValue: Any?): Boolean {
|
|
|
|
|
|
|
|
CustomizeHome.preferenceToggled.record(
|
|
|
|
|
|
|
|
CustomizeHome.PreferenceToggledExtra(
|
|
|
|
|
|
|
|
newValue as Boolean,
|
|
|
|
|
|
|
|
"recently_saved"
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return super.onPreferenceChange(preference, newValue)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
requirePreference<SwitchPreference>(R.string.pref_key_pocket_homescreen_recommendations).apply {
|
|
|
|
requirePreference<SwitchPreference>(R.string.pref_key_pocket_homescreen_recommendations).apply {
|
|
|
|
isVisible = FeatureFlags.isPocketRecommendationsFeatureEnabled(context)
|
|
|
|
isVisible = FeatureFlags.isPocketRecommendationsFeatureEnabled(context)
|
|
|
|
isChecked = context.settings().showPocketRecommendationsFeature
|
|
|
|
isChecked = context.settings().showPocketRecommendationsFeature
|
|
|
|
onPreferenceChangeListener = CustomizeHomeMetricsUpdater()
|
|
|
|
onPreferenceChangeListener = object : SharedPreferenceUpdater() {
|
|
|
|
|
|
|
|
override fun onPreferenceChange(preference: Preference, newValue: Any?): Boolean {
|
|
|
|
|
|
|
|
CustomizeHome.preferenceToggled.record(
|
|
|
|
|
|
|
|
CustomizeHome.PreferenceToggledExtra(
|
|
|
|
|
|
|
|
newValue as Boolean,
|
|
|
|
|
|
|
|
"pocket"
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return super.onPreferenceChange(preference, newValue)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
requirePreference<SwitchPreference>(R.string.pref_key_history_metadata_feature).apply {
|
|
|
|
requirePreference<SwitchPreference>(R.string.pref_key_history_metadata_feature).apply {
|
|
|
|
isVisible = FeatureFlags.historyMetadataUIFeature
|
|
|
|
isVisible = FeatureFlags.historyMetadataUIFeature
|
|
|
|
isChecked = context.settings().historyMetadataUIFeature
|
|
|
|
isChecked = context.settings().historyMetadataUIFeature
|
|
|
|
onPreferenceChangeListener = CustomizeHomeMetricsUpdater()
|
|
|
|
onPreferenceChangeListener = object : SharedPreferenceUpdater() {
|
|
|
|
|
|
|
|
override fun onPreferenceChange(preference: Preference, newValue: Any?): Boolean {
|
|
|
|
|
|
|
|
CustomizeHome.preferenceToggled.record(
|
|
|
|
|
|
|
|
CustomizeHome.PreferenceToggledExtra(
|
|
|
|
|
|
|
|
newValue as Boolean,
|
|
|
|
|
|
|
|
"recently_visited"
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return super.onPreferenceChange(preference, newValue)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
val openingScreenRadioHomepage =
|
|
|
|
val openingScreenRadioHomepage =
|
|
|
@ -92,22 +145,4 @@ class HomeSettingsFragment : PreferenceFragmentCompat() {
|
|
|
|
openingScreenAfterFourHours
|
|
|
|
openingScreenAfterFourHours
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inner class CustomizeHomeMetricsUpdater : SharedPreferenceUpdater() {
|
|
|
|
|
|
|
|
override fun onPreferenceChange(preference: Preference, newValue: Any?): Boolean {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
val context = preference.context
|
|
|
|
|
|
|
|
context.components.analytics.metrics.track(
|
|
|
|
|
|
|
|
Event.CustomizeHomePreferenceToggled(
|
|
|
|
|
|
|
|
preference.key,
|
|
|
|
|
|
|
|
newValue as Boolean,
|
|
|
|
|
|
|
|
context
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
} catch (e: IllegalArgumentException) {
|
|
|
|
|
|
|
|
// The event is not tracked
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return super.onPreferenceChange(preference, newValue)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|