tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit f20aa5e87fbdfd18aac9235edfe25c83349099b9
parent 53dc82d8357ecaad556f8ae235f68396be4e6a93
Author: Harrison Oglesby <oglesby.harrison@gmail.com>
Date:   Wed, 19 Nov 2025 22:12:18 +0000

Bug 2000589 - Fixed order of tab counter menu on bottom toolbar r=android-reviewers,petru

Differential Revision: https://phabricator.services.mozilla.com/D273109

Diffstat:
Mmobile/android/fenix/app/src/main/java/org/mozilla/fenix/components/toolbar/BrowserToolbarMiddleware.kt | 55++++++++++++++++++++++++++++++++-----------------------
Mmobile/android/fenix/app/src/test/java/org/mozilla/fenix/components/toolbar/BrowserToolbarMiddlewareTest.kt | 34+++++++++++++++++++++++++++++++++-
2 files changed, 65 insertions(+), 24 deletions(-)

diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/components/toolbar/BrowserToolbarMiddleware.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/components/toolbar/BrowserToolbarMiddleware.kt @@ -832,32 +832,41 @@ class BrowserToolbarMiddleware( ) } - private fun buildTabCounterMenu(source: Source) = + private fun buildTabCounterMenu(source: Source, toolbarPosition: ToolbarPosition) = CombinedEventAndMenu(TabCounterLongClicked(source)) { - listOf( - BrowserToolbarMenuButton( - icon = DrawableResIcon(iconsR.drawable.mozac_ic_plus_24), - text = StringResText(tabcounterR.string.mozac_browser_menu_new_tab), - contentDescription = StringResContentDescription(tabcounterR.string.mozac_browser_menu_new_tab), - onClick = AddNewTab(source), - ), + val list = listOf( + BrowserToolbarMenuButton( + icon = DrawableResIcon(iconsR.drawable.mozac_ic_plus_24), + text = StringResText(tabcounterR.string.mozac_browser_menu_new_tab), + contentDescription = StringResContentDescription(tabcounterR.string.mozac_browser_menu_new_tab), + onClick = AddNewTab(source), + ), - BrowserToolbarMenuButton( - icon = DrawableResIcon(iconsR.drawable.mozac_ic_private_mode_24), - text = StringResText(tabcounterR.string.mozac_browser_menu_new_private_tab), - contentDescription = StringResContentDescription(tabcounterR.string.mozac_browser_menu_new_private_tab), - onClick = AddNewPrivateTab(source), - ), + BrowserToolbarMenuButton( + icon = DrawableResIcon(iconsR.drawable.mozac_ic_private_mode_24), + text = StringResText(tabcounterR.string.mozac_browser_menu_new_private_tab), + contentDescription = + StringResContentDescription(tabcounterR.string.mozac_browser_menu_new_private_tab), + onClick = AddNewPrivateTab(source), + ), - BrowserToolbarMenuDivider, + BrowserToolbarMenuDivider, - BrowserToolbarMenuButton( - icon = DrawableResIcon(iconsR.drawable.mozac_ic_cross_24), - text = StringResText(tabcounterR.string.mozac_close_tab), - contentDescription = StringResContentDescription(tabcounterR.string.mozac_close_tab), - onClick = CloseCurrentTab, - ), - ) + BrowserToolbarMenuButton( + icon = DrawableResIcon(iconsR.drawable.mozac_ic_cross_24), + text = StringResText(tabcounterR.string.mozac_close_tab), + contentDescription = StringResContentDescription(tabcounterR.string.mozac_close_tab), + onClick = CloseCurrentTab, + ), + ) + when (toolbarPosition) { + ToolbarPosition.TOP -> { + list + } + ToolbarPosition.BOTTOM -> { + list.reversed() + } + } } private fun buildProgressBar(progress: Int = 0) = ProgressBarConfig(progress) @@ -1227,7 +1236,7 @@ class BrowserToolbarMiddleware( contentDescription = tabCounterDescription, showPrivacyMask = isInPrivateMode, onClick = TabCounterClicked(source), - onLongClick = buildTabCounterMenu(source), + onLongClick = buildTabCounterMenu(source, settings.toolbarPosition), ) } diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/components/toolbar/BrowserToolbarMiddlewareTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/components/toolbar/BrowserToolbarMiddlewareTest.kt @@ -238,6 +238,7 @@ class BrowserToolbarMiddlewareTest { screenWidthDp = 400 } every { mockContext.resources.configuration } returns configuration + every { settings.toolbarPosition } returns ToolbarPosition.TOP } @Test @@ -251,7 +252,6 @@ class BrowserToolbarMiddlewareTest { @Test fun `WHEN initializing the toolbar THEN add browser end actions`() = runTest { val toolbarStore = buildStore() - val toolbarBrowserActions = toolbarStore.state.displayState.browserActionsEnd assertEquals(3, toolbarBrowserActions.size) val newTabButton = toolbarBrowserActions[0] @@ -263,6 +263,20 @@ class BrowserToolbarMiddlewareTest { } @Test + fun `WHEN initializing the toolbar on bottom THEN add browser end actions`() = runTest { + every { settings.toolbarPosition } returns ToolbarPosition.BOTTOM + val toolbarStore = buildStore() + val toolbarBrowserActions = toolbarStore.state.displayState.browserActionsEnd + assertEquals(3, toolbarBrowserActions.size) + val newTabButton = toolbarBrowserActions[0] + val tabCounterButton = toolbarBrowserActions[1] as TabCounterAction + val menuButton = toolbarBrowserActions[2] + assertEquals(expectedNewTabButton(), newTabButton) + assertEqualsTabCounterButton(expectedBottomTabCounterButton(), tabCounterButton) + assertEquals(expectedMenuButton(), menuButton) + } + + @Test fun `GIVEN normal browsing mode WHEN initializing the toolbar THEN show the number of normal tabs in the tabs counter button`() = runTest { val browsingModeManager = SimpleBrowsingModeManager(Normal) val browserStore = BrowserStore( @@ -3359,6 +3373,24 @@ class BrowserToolbarMiddlewareTest { }, ) + fun expectedBottomTabCounterButton( + tabCount: Int = 0, + isPrivate: Boolean = false, + shouldUseBottomToolbar: Boolean = false, + source: Source = Source.AddressBar, + ) = expectedTabCounterButton( + tabCount = tabCount, + isPrivate = isPrivate, + shouldUseBottomToolbar = shouldUseBottomToolbar, + source = source, + ).run { + copy( + onLongClick = (onLongClick as CombinedEventAndMenu).copy( + menu = BrowserToolbarMenu { (onLongClick as CombinedEventAndMenu).menu.items().reversed() }, + ), + ) + } + private fun expectedNewTabButton(source: Source = Source.AddressBar) = ActionButtonRes( drawableResId = iconsR.drawable.mozac_ic_plus_24, contentDescription = R.string.home_screen_shortcut_open_new_tab_2,