diff --git a/app/src/main/java/org/mozilla/fenix/browser/BaseBrowserFragment.kt b/app/src/main/java/org/mozilla/fenix/browser/BaseBrowserFragment.kt index 9df643b056..8021a951ae 100644 --- a/app/src/main/java/org/mozilla/fenix/browser/BaseBrowserFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/browser/BaseBrowserFragment.kt @@ -657,9 +657,9 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, Session } } - view.swipeRefresh.isEnabled = FeatureFlags.pullToRefreshEnabled - @Suppress("ConstantConditionIf") - if (FeatureFlags.pullToRefreshEnabled) { + view.swipeRefresh.isEnabled = + FeatureFlags.pullToRefreshEnabled && context.settings().isPullToRefreshEnabledInBrowser + if (view.swipeRefresh.isEnabled) { val primaryTextColor = ThemeManager.resolveAttribute(R.attr.primaryText, context) view.swipeRefresh.setColorSchemeColors(primaryTextColor) diff --git a/app/src/main/java/org/mozilla/fenix/browser/BrowserFragment.kt b/app/src/main/java/org/mozilla/fenix/browser/BrowserFragment.kt index 22564c5e94..56964573be 100644 --- a/app/src/main/java/org/mozilla/fenix/browser/BrowserFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/browser/BrowserFragment.kt @@ -72,15 +72,17 @@ class BrowserFragment : BaseBrowserFragment(), UserInteractionHandler { val components = context.components return super.initializeUI(view)?.also { - gestureLayout.addGestureListener( - ToolbarGestureHandler( - activity = requireActivity(), - contentLayout = browserLayout, - tabPreview = tabPreview, - toolbarLayout = browserToolbarView.view, - sessionManager = components.core.sessionManager + if (context.settings().isSwipeToolbarToSwitchTabsEnabled) { + gestureLayout.addGestureListener( + ToolbarGestureHandler( + activity = requireActivity(), + contentLayout = browserLayout, + tabPreview = tabPreview, + toolbarLayout = browserToolbarView.view, + sessionManager = components.core.sessionManager + ) ) - ) + } val readerModeAction = BrowserToolbar.ToggleButton( diff --git a/app/src/main/java/org/mozilla/fenix/components/toolbar/BrowserToolbarView.kt b/app/src/main/java/org/mozilla/fenix/components/toolbar/BrowserToolbarView.kt index a1c8e55d78..57b5222968 100644 --- a/app/src/main/java/org/mozilla/fenix/components/toolbar/BrowserToolbarView.kt +++ b/app/src/main/java/org/mozilla/fenix/components/toolbar/BrowserToolbarView.kt @@ -209,7 +209,8 @@ class BrowserToolbarView( when (settings.toolbarPosition) { ToolbarPosition.BOTTOM -> { (view.layoutParams as CoordinatorLayout.LayoutParams).apply { - (behavior as BrowserToolbarBottomBehavior).forceExpand(view) + // behavior can be null if the "Scroll to hide toolbar" setting is toggled off. + (behavior as? BrowserToolbarBottomBehavior)?.forceExpand(view) } } ToolbarPosition.TOP -> { @@ -220,7 +221,8 @@ class BrowserToolbarView( /** * Dynamically sets scroll flags for the toolbar when the user does not have a screen reader enabled - * Note that the bottom toolbar has a feature flag for being dynamic, so it may not get flags set. + * Note that the toolbar will have the flags set and be able to be hidden + * only if the user didn't disabled this behavior in app's settings. */ fun setScrollFlags(shouldDisableScroll: Boolean = false) { when (settings.toolbarPosition) { @@ -231,7 +233,10 @@ class BrowserToolbarView( } ToolbarPosition.TOP -> { view.updateLayoutParams { - scrollFlags = if (settings.shouldUseFixedTopToolbar || shouldDisableScroll) { + scrollFlags = + if (settings.shouldUseFixedTopToolbar || + !settings.isDynamicToolbarEnabled || + shouldDisableScroll) { // Force expand the toolbar so the user is not stuck with a hidden toolbar expand() 0 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 14f3c2a96e..be37bcd1be 100644 --- a/app/src/main/java/org/mozilla/fenix/settings/CustomizationFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/settings/CustomizationFragment.kt @@ -51,6 +51,7 @@ class CustomizationFragment : PreferenceFragmentCompat() { setupRadioGroups() setupToolbarCategory() setupHomeCategory() + setupGesturesCategory() } private fun setupRadioGroups() { @@ -144,4 +145,20 @@ class CustomizationFragment : PreferenceFragmentCompat() { onPreferenceChangeListener = SharedPreferenceUpdater() } } + + private fun setupGesturesCategory() { + requirePreference(R.string.pref_key_website_pull_to_refresh).apply { + isVisible = FeatureFlags.pullToRefreshEnabled + isChecked = context.settings().isPullToRefreshEnabledInBrowser + onPreferenceChangeListener = SharedPreferenceUpdater() + } + requirePreference(R.string.pref_key_dynamic_toolbar).apply { + isChecked = context.settings().isDynamicToolbarEnabled + onPreferenceChangeListener = SharedPreferenceUpdater() + } + requirePreference(R.string.pref_key_swipe_toolbar_switch_tabs).apply { + isChecked = context.settings().isSwipeToolbarToSwitchTabsEnabled + onPreferenceChangeListener = SharedPreferenceUpdater() + } + } } 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 25f8f64d03..4c2e0874b3 100644 --- a/app/src/main/java/org/mozilla/fenix/utils/Settings.kt +++ b/app/src/main/java/org/mozilla/fenix/utils/Settings.kt @@ -888,4 +888,19 @@ class Settings(private val appContext: Context) : PreferencesHolder { SavedLoginsSortingStrategyMenu.Item.LastUsedSort.strategyString } } + + var isPullToRefreshEnabledInBrowser by booleanPreference( + appContext.getPreferenceKey(R.string.pref_key_website_pull_to_refresh), + default = true + ) + + var isDynamicToolbarEnabled by booleanPreference( + appContext.getPreferenceKey(R.string.pref_key_dynamic_toolbar), + default = true + ) + + var isSwipeToolbarToSwitchTabsEnabled by booleanPreference( + appContext.getPreferenceKey(R.string.pref_key_swipe_toolbar_switch_tabs), + default = true + ) } diff --git a/app/src/main/res/values/preference_keys.xml b/app/src/main/res/values/preference_keys.xml index 31df44e5a6..cb27836a47 100644 --- a/app/src/main/res/values/preference_keys.xml +++ b/app/src/main/res/values/preference_keys.xml @@ -125,6 +125,12 @@ pref_home_category + + pref_key_website_pull_to_refresh + pref_key_dynamic_toolbar + pref_key_swipe_toolbar_switch_tabs + pref_key_swipe_toolbar_show_tabs + 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 6c905ecc71..5db7fdec9d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -284,6 +284,8 @@ Theme Home + + Gestures Customize @@ -453,6 +455,16 @@ Follow device theme + + + Pull to refresh + + Scroll to hide toolbar + + Swipe toolbar sideways to switch tabs + + Swipe toolbar up to open tabs + Sessions diff --git a/app/src/main/res/xml/customization_preferences.xml b/app/src/main/res/xml/customization_preferences.xml index 8398cf705a..4efd0aa29b 100644 --- a/app/src/main/res/xml/customization_preferences.xml +++ b/app/src/main/res/xml/customization_preferences.xml @@ -56,4 +56,24 @@ android:key="@string/pref_key_enable_top_frecent_sites" android:title="@string/top_sites_toggle_top_frecent_sites" /> + + + + + + +