commit c6b9644ae2177acd9dbffc6d6a41f4d6aa1b4281
parent eeabfce203fe6d8993674496ea377a8139d1e6ab
Author: Akhil Pindiprolu <apindiprolu@mozilla.com>
Date: Thu, 27 Nov 2025 20:48:35 +0000
Bug 1991767 - Update "Close all tabs" to have a confirmation dialog r=android-reviewers,android-l10n-reviewers,flod,calu
Differential Revision: https://phabricator.services.mozilla.com/D273873
Diffstat:
3 files changed, 79 insertions(+), 1 deletion(-)
diff --git a/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/ui/robots/TabDrawerRobot.kt b/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/ui/robots/TabDrawerRobot.kt
@@ -10,6 +10,7 @@ import android.util.Log
import androidx.compose.ui.semantics.SemanticsActions
import androidx.compose.ui.test.ExperimentalTestApi
import androidx.compose.ui.test.assert
+import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.assertIsNotSelected
import androidx.compose.ui.test.assertIsSelected
import androidx.compose.ui.test.click
@@ -26,6 +27,7 @@ import androidx.compose.ui.test.onChildren
import androidx.compose.ui.test.onFirst
import androidx.compose.ui.test.onNodeWithContentDescription
import androidx.compose.ui.test.onNodeWithTag
+import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
import androidx.compose.ui.test.performScrollTo
import androidx.compose.ui.test.performSemanticsAction
@@ -477,6 +479,16 @@ class TabDrawerRobot(private val composeTestRule: ComposeTestRule) {
Log.i(TAG, "closeAllTabs: Trying to click the \"Close all tabs\" menu button")
composeTestRule.dropdownMenuItemCloseAllTabs().performClick()
Log.i(TAG, "closeAllTabs: Clicked the \"Close all tabs\" menu button")
+
+ val confirmButtonText = getStringResource(R.string.tab_manager_close_all_tabs_dialog_confirm)
+
+ Log.i(TAG, "closeAllTabs: Waiting for the \"$confirmButtonText\" dialog button to be displayed")
+ composeTestRule
+ .onNodeWithText(confirmButtonText, useUnmergedTree = true)
+ .assertIsDisplayed()
+ .performClick()
+ Log.i(TAG, "closeAllTabs: Clicked the \"$confirmButtonText\" dialog button")
+
HomeScreenRobot().interact()
return HomeScreenRobot.Transition()
}
diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/tabstray/ui/fab/TabManagerFloatingToolbar.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/tabstray/ui/fab/TabManagerFloatingToolbar.kt
@@ -17,11 +17,14 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.CircleShape
+import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.Text
+import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
@@ -148,6 +151,8 @@ private fun FloatingToolbarActions(
onDeleteAllTabsClick: () -> Unit,
) {
var showBottomAppBarMenu by remember { mutableStateOf(false) }
+ var showCloseAllTabsDialog by remember { mutableStateOf(false) }
+
val menuItems = generateMenuItems(
selectedPage = state.selectedPage,
normalTabCount = state.normalTabs.size,
@@ -156,7 +161,7 @@ private fun FloatingToolbarActions(
onTabSettingsClick = onTabSettingsClick,
onRecentlyClosedClick = onRecentlyClosedClick,
onEnterMultiselectModeClick = onEnterMultiselectModeClick,
- onDeleteAllTabsClick = onDeleteAllTabsClick,
+ onDeleteAllTabsClick = { showCloseAllTabsDialog = true },
)
Card(
@@ -192,6 +197,16 @@ private fun FloatingToolbarActions(
}
}
}
+
+ if (showCloseAllTabsDialog) {
+ CloseAllTabsConfirmationDialog(
+ onConfirm = {
+ showCloseAllTabsDialog = false
+ onDeleteAllTabsClick()
+ },
+ onDismiss = { showCloseAllTabsDialog = false },
+ )
+ }
}
@Composable
@@ -267,6 +282,49 @@ private fun FloatingToolbarFAB(
}
}
+/**
+ * Confirmation dialog shown when the user selects the "Close all tabs" action
+ * from the tab manager.
+ *
+ * @param onConfirm Invoked when the user confirms in closing all open tabs.
+ * @param onDismiss Invoked when the dialog is dismissed without confirming.
+ */
+@Composable
+private fun CloseAllTabsConfirmationDialog(
+ onConfirm: () -> Unit,
+ onDismiss: () -> Unit,
+) {
+ AlertDialog(
+ onDismissRequest = onDismiss,
+ title = {
+ Text(
+ text = stringResource(R.string.tab_manager_close_all_tabs_dialog_title),
+ style = FirefoxTheme.typography.headline6,
+ )
+ },
+ text = {
+ Text(
+ text = stringResource(R.string.tab_manager_close_all_tabs_dialog_body),
+ style = FirefoxTheme.typography.body2,
+ )
+ },
+ confirmButton = {
+ TextButton(onClick = onConfirm) {
+ Text(
+ text = stringResource(R.string.tab_manager_close_all_tabs_dialog_confirm),
+ )
+ }
+ },
+ dismissButton = {
+ TextButton(onClick = onDismiss) {
+ Text(
+ text = stringResource(R.string.tab_manager_close_all_tabs_dialog_cancel),
+ )
+ }
+ },
+ )
+}
+
@Suppress("LongParameterList")
private fun generateMenuItems(
selectedPage: Page,
diff --git a/mobile/android/fenix/app/src/main/res/values/strings.xml b/mobile/android/fenix/app/src/main/res/values/strings.xml
@@ -1333,6 +1333,14 @@
<string name="tab_tray_menu_tab_settings">Tab settings</string>
<!-- Text shown in the menu for closing all tabs -->
<string name="tab_tray_menu_item_close">Close all tabs</string>
+ <!-- Text shown as the title of the Close all tabs confirmation dialog in Tab Manager -->
+ <string name="tab_manager_close_all_tabs_dialog_title">Close all tabs?</string>Í
+ <!-- Text shown in the body of the Close all tabs confirmation dialog in Tab Manager -->
+ <string name="tab_manager_close_all_tabs_dialog_body">This will close all open tabs.</string>
+ <!-- Text shown on the confirm button in the Close all tabs confirmation dialog -->
+ <string name="tab_manager_close_all_tabs_dialog_confirm">Close tabs</string>
+ <!-- Text shown on the cancel button in the Close all tabs confirmation dialog -->
+ <string name="tab_manager_close_all_tabs_dialog_cancel">Cancel</string>
<!-- Text shown in the multiselect menu for bookmarking selected tabs. -->
<string name="tab_tray_multiselect_menu_item_bookmark">Bookmark</string>
<!-- Content description (not visible, for screen readers etc.): Bookmarks selected tabs. -->