commit a0e7334489e49a076bf97b9226a3865ce595b5d3 parent 9663bdfc9d264723a6815154dd1865d70de5b025 Author: Mugurell <Mugurell@users.noreply.github.com> Date: Wed, 17 Dec 2025 16:06:38 +0000 Bug 1988730 - part 6 - Staged rollout for the minimal toolbar r=android-reviewers,moyin,Roger Safer to go with a staged rollout given the complexity of the changes. Differential Revision: https://phabricator.services.mozilla.com/D276606 Diffstat:
10 files changed, 86 insertions(+), 9 deletions(-)
diff --git a/mobile/android/android-components/components/compose/browser-toolbar/src/main/java/mozilla/components/compose/browser/toolbar/BrowserDisplayToolbar.kt b/mobile/android/android-components/components/compose/browser-toolbar/src/main/java/mozilla/components/compose/browser/toolbar/BrowserDisplayToolbar.kt @@ -17,6 +17,7 @@ import androidx.compose.animation.togetherWith import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.geometry.Rect @@ -80,8 +81,12 @@ fun BrowserDisplayToolbar( pageActionsEnd: List<Action> = emptyList(), browserActionsEnd: List<Action> = emptyList(), onInteraction: (BrowserToolbarEvent) -> Unit, + useMinimalBottomToolbarWhenEnteringText: Boolean = false, ) { - val isKeyboardShowing by keyboardAsState() + val isKeyboardShowing by when (useMinimalBottomToolbarWhenEnteringText) { + true -> keyboardAsState() + false -> remember { mutableStateOf(KeyboardState.Closed) } + } val toolbarsTransitionAnimationSpec = remember { tween<Float>( diff --git a/mobile/android/android-components/components/compose/browser-toolbar/src/main/java/mozilla/components/compose/browser/toolbar/BrowserToolbar.kt b/mobile/android/android-components/components/compose/browser-toolbar/src/main/java/mozilla/components/compose/browser/toolbar/BrowserToolbar.kt @@ -58,11 +58,14 @@ data class BrowserToolbarCFR( * * @param store The [BrowserToolbarStore] to observe the UI state from. * @param cfr The [BrowserToolbarCFR] to hold properties of Toolbar's CFR. + * @property useMinimalBottomToolbarWhenEnteringText Whether to show a smaller height addressbar + * with just the URL when using a bottom toolbar and the user is entering text in a website. */ @Composable fun BrowserToolbar( store: BrowserToolbarStore, cfr: BrowserToolbarCFR? = null, + useMinimalBottomToolbarWhenEnteringText: Boolean = false, ) { val uiState by store.observeAsComposableState { it } val cfrProperties = browserToolbarCFRProperties(uiState.gravity) @@ -92,6 +95,7 @@ fun BrowserToolbar( pageActionsEnd = uiState.displayState.pageActionsEnd, browserActionsEnd = uiState.displayState.browserActionsEnd, onInteraction = { store.dispatch(it) }, + useMinimalBottomToolbarWhenEnteringText = useMinimalBottomToolbarWhenEnteringText, ) } diff --git a/mobile/android/fenix/app/nimbus.fml.yaml b/mobile/android/fenix/app/nimbus.fml.yaml @@ -394,6 +394,22 @@ features: type: Boolean default: true + minimal-addressbar: + description: Show a smaller height bottom addressbar with just the URL. + variables: + at-bottom-while-entering-text: + description: > + Whether to show the smaller height bottom addressbar with just the URL when entering text in a website. + type: Boolean + default: false + defaults: + - channel: nightly + value: + at-bottom-while-entering-text: true + - channel: developer + value: + at-bottom-while-entering-text: true + remote-tab-management: description: > Features that let users manage tabs on other devices that are diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/components/toolbar/BrowserToolbarComposable.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/components/toolbar/BrowserToolbarComposable.kt @@ -143,6 +143,8 @@ class BrowserToolbarComposable( BrowserToolbar( store = toolbarStore, cfr = toolbarCFR, + useMinimalBottomToolbarWhenEnteringText = + settings.shouldUseMinimalBottomToolbarWhenEnteringText, ) if (customTabSession == null) { searchSuggestionsContent(Modifier.weight(1f)) @@ -161,12 +163,16 @@ class BrowserToolbarComposable( BrowserToolbar( store = toolbarStore, cfr = toolbarCFR, + useMinimalBottomToolbarWhenEnteringText = + settings.shouldUseMinimalBottomToolbarWhenEnteringText, ) navigationBarContent?.invoke() } else { BrowserToolbar( store = toolbarStore, cfr = toolbarCFR, + useMinimalBottomToolbarWhenEnteringText = + settings.shouldUseMinimalBottomToolbarWhenEnteringText, ) if (customTabSession == null) { searchSuggestionsContent(Modifier.weight(1f)) diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/components/toolbar/ToolbarsIntegration.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/components/toolbar/ToolbarsIntegration.kt @@ -51,20 +51,24 @@ class ToolbarsIntegration( private var layoutListener: ViewTreeObserver.OnGlobalLayoutListener? = null override fun start() { - var wasKeyboardShown = false + if (settings.shouldUseMinimalBottomToolbarWhenEnteringText) { + var wasKeyboardShown = false - layoutListener = ViewTreeObserver.OnGlobalLayoutListener { - val isKeyboardShown = browserLayout.isKeyboardVisible() - if (wasKeyboardShown != isKeyboardShown) { - wasKeyboardShown = isKeyboardShown - onKeyboardShown(isKeyboardShown) + layoutListener = ViewTreeObserver.OnGlobalLayoutListener { + val isKeyboardShown = browserLayout.isKeyboardVisible() + if (wasKeyboardShown != isKeyboardShown) { + wasKeyboardShown = isKeyboardShown + onKeyboardShown(isKeyboardShown) + } } + browserLayout.viewTreeObserver.addOnGlobalLayoutListener(layoutListener) } - browserLayout.viewTreeObserver.addOnGlobalLayoutListener(layoutListener) } override fun stop() { - browserLayout.viewTreeObserver.removeOnGlobalLayoutListener(layoutListener) + layoutListener?.let { + browserLayout.viewTreeObserver.removeOnGlobalLayoutListener(it) + } } @VisibleForTesting diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/settings/SecretSettingsFragment.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/settings/SecretSettingsFragment.kt @@ -110,6 +110,24 @@ class SecretSettingsFragment : PreferenceFragmentCompat() { } } } + requirePreference<SwitchPreference>( + R.string.pref_key_use_minimal_bottom_toolbar_while_entering_text, + ).apply { + isEnabled = newOption + when (newOption) { + true -> { + summary = null + } + + false -> { + isEnabled = context.settings().shouldUseComposableToolbar + summary = when (context.settings().shouldUseComposableToolbar) { + true -> null + false -> getString(R.string.preferences_debug_settings_toolbar_redesign_summary) + } + } + } + } } true } @@ -154,6 +172,17 @@ class SecretSettingsFragment : PreferenceFragmentCompat() { } } + requirePreference<SwitchPreference>(R.string.pref_key_use_minimal_bottom_toolbar_while_entering_text).apply { + isVisible = Config.channel.isNightlyOrDebug + isEnabled = context.settings().shouldUseComposableToolbar + isChecked = context.settings().shouldUseMinimalBottomToolbarWhenEnteringText + summary = when (context.settings().shouldUseComposableToolbar) { + true -> null + false -> getString(R.string.preferences_debug_settings_toolbar_redesign_summary) + } + onPreferenceChangeListener = SharedPreferenceUpdater() + } + requirePreference<SwitchPreference>(R.string.pref_key_use_scroll_data_for_dynamic_toolbar).apply { isVisible = Config.channel.isNightlyOrDebug isChecked = context.settings().useNewDynamicToolbarBehaviour diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/utils/Settings.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/utils/Settings.kt @@ -2194,6 +2194,11 @@ class Settings( default = { FxNimbus.features.composableToolbar.value().enabled }, ) + var shouldUseMinimalBottomToolbarWhenEnteringText by booleanPreference( + key = appContext.getPreferenceKey(R.string.pref_key_use_minimal_bottom_toolbar_while_entering_text), + default = { FxNimbus.features.minimalAddressbar.value().atBottomWhileEnteringText }, + ) + /** * Indicates if the user has access to the toolbar redesign option in settings. */ diff --git a/mobile/android/fenix/app/src/main/res/values/preference_keys.xml b/mobile/android/fenix/app/src/main/res/values/preference_keys.xml @@ -445,6 +445,7 @@ <string name="pref_key_enable_firefox_labs" translatable="false">pref_key_enable_firefox_labs</string> <string name="pref_key_enable_unified_trust_panel" translatable="false">pref_key_enable_unified_trust_panel</string> <string name="pref_key_enable_composable_toolbar" translatable="false">pref_key_enable_composable_toolbar</string>" + <string name="pref_key_use_minimal_bottom_toolbar_while_entering_text" translatable="false">pref_key_use_minimal_bottom_toolbar_while_entering_text</string>" <string name="pref_key_enable_toolbar_redesign" translatable="false">pref_key_enable_toolbar_redesign</string>" <string name="pref_key_enable_address_sync" translatable="false">pref_key_enable_address_sync</string>" <string name="pref_key_enable_toolbar_customization">pref_key_enable_toolbar_customization</string> diff --git a/mobile/android/fenix/app/src/main/res/values/static_strings.xml b/mobile/android/fenix/app/src/main/res/values/static_strings.xml @@ -95,6 +95,8 @@ <string name="preferences_debug_settings_toolbar_customization">Enable Toolbar Customization</string> <!-- Label for a longer description of the redesigned toolbar depending on the composable toolbar feature --> <string name="preferences_debug_settings_toolbar_redesign_summary" translatable="false">This needs the Composable Toolbar feature enabled</string> + <!-- Label for the option of using a minimal bottom tolbar while entering text in a website --> + <string name="preferences_debug_settings_use_minimal_bottom_toolbar_while_entering_text" translatable="false">Use a minimal bottom toolbar while entering text in a website</string> <!-- Label for the option of using new scroll data for animating the dynamic toolbar --> <string name="preferences_debug_settings_use_scroll_data_for_dynamic_toolbar" translatable="false">Animate dynamic toolbars based on website scroll data</string> <!-- Label for a longer description of the redesigned toolbar depending on the redesigned toolbar options feature --> diff --git a/mobile/android/fenix/app/src/main/res/xml/secret_settings_preferences.xml b/mobile/android/fenix/app/src/main/res/xml/secret_settings_preferences.xml @@ -75,6 +75,11 @@ app:iconSpaceReserved="false" /> <SwitchPreference android:defaultValue="false" + android:key="@string/pref_key_use_minimal_bottom_toolbar_while_entering_text" + android:title="@string/preferences_debug_settings_use_minimal_bottom_toolbar_while_entering_text" + app:iconSpaceReserved="false" /> + <SwitchPreference + android:defaultValue="false" android:key="@string/pref_key_use_scroll_data_for_dynamic_toolbar" android:title="@string/preferences_debug_settings_use_scroll_data_for_dynamic_toolbar" app:iconSpaceReserved="false" />