Modern Apps git

← Modern-Apps.git

launcher: make the uninstall confirmation a dialog route

Commit
4ffabc9855a05b56db8afc5d035b727cc1e2893c
Author
Vayun Mathur <[email protected]>
When
2026-12-02 03:46 UTC (4 days ago)
Parents
8403636
The item menu held a remember-gated ConfirmDialog for uninstall, which
the DialogAsRoute lint flags: a dialog is a navigation destination.
Add Route.UninstallDialog(itemId, label) with DialogPage() metadata and
a stateless UninstallDialogContent under ui/dialogs/; the menu row now
requests the route (threaded ItemMenuContent -> HomePopups ->
HomeContent -> HomePage) and the route entry uninstalls by item ID via
HomeActions.uninstallItem. Give the new route a deterministic capture
(6-uninstall-dialog) and host the dialog content in the item-menu
compose test the way the route entry does. Update launcher/AGENTS.md.

Verified: ./gradlew :launcher:lint :launcher:lintVitalRelease
:launcher:testDevUnitTest and :launcher:compileDevScreenshotTestKotlin
all pass.

Diff

launcher/AGENTS.md
diff --git a/launcher/AGENTS.md b/launcher/AGENTS.mdindex b1f0d534dd..c786f29b73 100644--- a/launcher/AGENTS.md+++ b/launcher/AGENTS.md@@ -104,6 +104,7 @@ _Install: ./install launcher (dev by default). For a TV over Wi-Fi: `sh launcher - com/vayunmathur/launcher/ui/DrawerCells.kt - com/vayunmathur/launcher/ui/DrawerFastScroll.kt - com/vayunmathur/launcher/ui/ItemMenuContent.kt+- com/vayunmathur/launcher/ui/dialogs/UninstallDialogContent.kt (stateless content of the `Route.UninstallDialog` destination) - com/vayunmathur/launcher/ui/SettingsPage.kt - com/vayunmathur/launcher/ui/SettingsContent.kt - com/vayunmathur/launcher/ui/WidgetPickerContent.kt
launcher/src/main/java/com/vayunmathur/launcher/Navigation.kt
diff --git a/launcher/src/main/java/com/vayunmathur/launcher/Navigation.kt b/launcher/src/main/java/com/vayunmathur/launcher/Navigation.ktindex 08977c64eb..edf92e09eb 100644--- a/launcher/src/main/java/com/vayunmathur/launcher/Navigation.kt+++ b/launcher/src/main/java/com/vayunmathur/launcher/Navigation.kt@@ -10,6 +10,7 @@ import com.vayunmathur.launcher.platform.LocalActivityBridge import com.vayunmathur.launcher.platform.LocalIconLoader import com.vayunmathur.launcher.ui.HomePage import com.vayunmathur.launcher.ui.SettingsPage+import com.vayunmathur.launcher.ui.dialogs.UninstallDialogContent import com.vayunmathur.launcher.ui.components.LauncherDragController import com.vayunmathur.launcher.ui.components.LocalLauncherDrag import com.vayunmathur.library.util.DialogPage@@ -40,6 +41,16 @@ fun Navigation(         MainNavigation(backStack, containerColor = Color.Transparent) {             entry<Route.Home> { HomePage(backStack, viewModel) }             entry<Route.Settings>(metadata = DialogPage()) { SettingsPage(backStack, viewModel) }+            entry<Route.UninstallDialog>(metadata = DialogPage()) { route ->+                UninstallDialogContent(+                    label = route.label,+                    onConfirm = {+                        backStack.pop()+                        viewModel.uninstallItem(route.itemId)+                    },+                    onDismiss = { backStack.pop() },+                )+            }         }     } }
launcher/src/main/java/com/vayunmathur/launcher/Route.kt
diff --git a/launcher/src/main/java/com/vayunmathur/launcher/Route.kt b/launcher/src/main/java/com/vayunmathur/launcher/Route.ktindex 57fa9e3179..42f3b2bb25 100644--- a/launcher/src/main/java/com/vayunmathur/launcher/Route.kt+++ b/launcher/src/main/java/com/vayunmathur/launcher/Route.kt@@ -21,4 +21,12 @@ sealed interface Route : NavKey {     /** Singleton holding settings state and operations. */     @Serializable     data object Settings : Route++    /**+     * Uninstall confirmation for the workspace item [itemId] named [label].+     * The item menu that asks for it is an overlay, but the confirmation+     * itself is a dialog destination.+     */+    @Serializable+    data class UninstallDialog(val itemId: Long, val label: String) : Route }
launcher/src/main/java/com/vayunmathur/launcher/ui/HomeContent.kt
diff --git a/launcher/src/main/java/com/vayunmathur/launcher/ui/HomeContent.kt b/launcher/src/main/java/com/vayunmathur/launcher/ui/HomeContent.ktindex 69bc545d71..88a0fdb57d 100644--- a/launcher/src/main/java/com/vayunmathur/launcher/ui/HomeContent.kt+++ b/launcher/src/main/java/com/vayunmathur/launcher/ui/HomeContent.kt@@ -24,6 +24,7 @@ import com.vayunmathur.launcher.platform.HomeUiState import com.vayunmathur.launcher.platform.ItemMenuActions import com.vayunmathur.launcher.platform.ItemMenuUiState import com.vayunmathur.launcher.platform.WidgetPickerActions+import com.vayunmathur.launcher.platform.WorkspaceItem import com.vayunmathur.launcher.platform.WidgetPickerUiState import com.vayunmathur.launcher.ui.components.FastScrollStrip import com.vayunmathur.launcher.ui.components.LocalLauncherDrag@@ -63,6 +64,7 @@ fun HomeContent(     onPickWallpaper: () -> Unit = {},     widgetPickerState: WidgetPickerUiState = WidgetPickerUiState(),     widgetPickerActions: WidgetPickerActions = WidgetPickerActions.Noop,+    onRequestUninstall: (WorkspaceItem) -> Unit = {},     widgetView: (Int) -> AppWidgetHostView? = { null },     updateWidgetSize: (AppWidgetHostView, Int, Int) -> Unit = { _, _, _ -> },     initialDrawerOpen: Boolean = false,@@ -311,5 +313,6 @@ fun HomeContent(         settleDrawer = ::settleDrawer,         closePopup = ::closePopup,         widgetPickerState = widgetPickerState,+        onRequestUninstall = onRequestUninstall,     ) }
launcher/src/main/java/com/vayunmathur/launcher/ui/HomePage.kt
diff --git a/launcher/src/main/java/com/vayunmathur/launcher/ui/HomePage.kt b/launcher/src/main/java/com/vayunmathur/launcher/ui/HomePage.ktindex 80c9d41702..04ef7c77cf 100644--- a/launcher/src/main/java/com/vayunmathur/launcher/ui/HomePage.kt+++ b/launcher/src/main/java/com/vayunmathur/launcher/ui/HomePage.kt@@ -8,6 +8,7 @@ import androidx.compose.runtime.remember import com.vayunmathur.launcher.Route import com.vayunmathur.launcher.platform.LauncherViewModel import com.vayunmathur.launcher.platform.LauncherWidgetOpsHolder+import com.vayunmathur.launcher.platform.WorkspaceItem import com.vayunmathur.launcher.platform.openItemMenuImpl import com.vayunmathur.library.util.NavBackStack @@ -46,6 +47,11 @@ fun HomePage(backStack: NavBackStack<Route>, viewModel: LauncherViewModel) {         }     }     val onOpenSettings = remember(backStack) { { backStack.add(Route.Settings) } }+    val onRequestUninstall = remember(backStack) {+        { item: WorkspaceItem ->+            backStack.add(Route.UninstallDialog(item.id, item.label))+        }+    }      HomeContent(         state = state,@@ -58,6 +64,7 @@ fun HomePage(backStack: NavBackStack<Route>, viewModel: LauncherViewModel) {         onOpenItemMenu = onOpenItemMenu,         itemMenuState = itemMenuState,         itemMenuActions = viewModel,+        onRequestUninstall = onRequestUninstall,         onOpenSettings = onOpenSettings,         onPickWallpaper = onPickWallpaper,         widgetPickerState = widgetPickerState,
launcher/src/main/java/com/vayunmathur/launcher/ui/HomePopups.kt
diff --git a/launcher/src/main/java/com/vayunmathur/launcher/ui/HomePopups.kt b/launcher/src/main/java/com/vayunmathur/launcher/ui/HomePopups.ktindex 90e1d2599b..f228474bfb 100644--- a/launcher/src/main/java/com/vayunmathur/launcher/ui/HomePopups.kt+++ b/launcher/src/main/java/com/vayunmathur/launcher/ui/HomePopups.kt@@ -6,6 +6,7 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.geometry.Rect import com.vayunmathur.launcher.platform.ItemMenuActions import com.vayunmathur.launcher.platform.ItemMenuUiState+import com.vayunmathur.launcher.platform.WorkspaceItem import com.vayunmathur.launcher.platform.WidgetPickerActions import com.vayunmathur.launcher.platform.WidgetPickerUiState import com.vayunmathur.launcher.ui.components.LauncherPopup@@ -26,6 +27,7 @@ internal fun HomePopups(     settleDrawer: (Float) -> Unit,     closePopup: () -> Unit,     widgetPickerState: WidgetPickerUiState,+    onRequestUninstall: (WorkspaceItem) -> Unit = {}, ) {     // The three windows, all outside the gesture-owning root above. Each hosts its content in a     // window of its own, which is exactly what keeps its rows tappable while the finger that opened@@ -39,6 +41,7 @@ internal fun HomePopups(                 placement = placement,                 progress = { popup.value },                 onDismiss = onClosePopup,+                onRequestUninstall = onRequestUninstall,             )         }     }
launcher/src/main/java/com/vayunmathur/launcher/ui/ItemMenuContent.kt
diff --git a/launcher/src/main/java/com/vayunmathur/launcher/ui/ItemMenuContent.kt b/launcher/src/main/java/com/vayunmathur/launcher/ui/ItemMenuContent.ktindex 0030e36155..9520d176ee 100644--- a/launcher/src/main/java/com/vayunmathur/launcher/ui/ItemMenuContent.kt+++ b/launcher/src/main/java/com/vayunmathur/launcher/ui/ItemMenuContent.kt@@ -19,12 +19,12 @@ import com.vayunmathur.launcher.domain.LauncherItemType import com.vayunmathur.launcher.platform.ItemMenuActions import com.vayunmathur.launcher.platform.ItemMenuUiState import com.vayunmathur.launcher.platform.ShortcutEntry+import com.vayunmathur.launcher.platform.WorkspaceItem import com.vayunmathur.launcher.ui.components.DragPayload import com.vayunmathur.launcher.ui.components.PopupPlacement import com.vayunmathur.launcher.ui.components.dragSource import com.vayunmathur.launcher.ui.components.launcherPopupSurface import com.vayunmathur.launcher.ui.components.onAppWindowBounds-import com.vayunmathur.library.ui.ConfirmDialog import com.vayunmathur.library.ui.IconApps import com.vayunmathur.library.ui.IconInfo import com.vayunmathur.library.ui.IconUninstall@@ -54,9 +54,9 @@ fun ItemMenuContent(     placement: PopupPlacement = PopupPlacement(),     progress: () -> Float = { 1f },     onDismiss: () -> Unit = {},+    onRequestUninstall: (WorkspaceItem) -> Unit = {}, ) {     val item = state.item ?: return-    var confirmUninstall by remember { mutableStateOf(false) }      Column(         modifier = modifier@@ -97,25 +97,13 @@ fun ItemMenuContent(             SettingsRow(                 title = "Uninstall",                 leadingContent = { IconUninstall() },-                onClick = { confirmUninstall = true },+                onClick = {+                    onRequestUninstall(item)+                    onDismiss()+                },             )         }     }--    if (confirmUninstall) {-        ConfirmDialog(-            title = "Uninstall ${item.label}?",-            message = "The app and its data will be removed from this device.",-            confirmLabel = "Uninstall",-            dismissLabel = "Cancel",-            destructive = true,-            onConfirm = {-                actions.uninstall(item)-                onDismiss()-            },-            onDismiss = { confirmUninstall = false },-        )-    } }  /**
launcher/src/main/java/com/vayunmathur/launcher/ui/dialogs/UninstallDialogContent.kt
diff --git a/launcher/src/main/java/com/vayunmathur/launcher/ui/dialogs/UninstallDialogContent.kt b/launcher/src/main/java/com/vayunmathur/launcher/ui/dialogs/UninstallDialogContent.ktnew file mode 100644index 0000000000..44cea617d3--- /dev/null+++ b/launcher/src/main/java/com/vayunmathur/launcher/ui/dialogs/UninstallDialogContent.kt@@ -0,0 +1,22 @@+package com.vayunmathur.launcher.ui.dialogs++import androidx.compose.runtime.Composable+import com.vayunmathur.library.ui.ConfirmDialog++/** Stateless uninstall confirmation for the item named [label]. */+@Composable+fun UninstallDialogContent(+    label: String,+    onConfirm: () -> Unit,+    onDismiss: () -> Unit,+) {+    ConfirmDialog(+        title = "Uninstall ${label.ifBlank { "Item" }}?",+        message = "The app and its data will be removed from this device.",+        confirmLabel = "Uninstall",+        dismissLabel = "Cancel",+        destructive = true,+        onConfirm = onConfirm,+        onDismiss = onDismiss,+    )+}
launcher/src/screenshotTest/kotlin/com/vayunmathur/launcher/ui/MetadataPreviews.kt
diff --git a/launcher/src/screenshotTest/kotlin/com/vayunmathur/launcher/ui/MetadataPreviews.kt b/launcher/src/screenshotTest/kotlin/com/vayunmathur/launcher/ui/MetadataPreviews.ktindex 6d6be6b145..50ab818414 100644--- a/launcher/src/screenshotTest/kotlin/com/vayunmathur/launcher/ui/MetadataPreviews.kt+++ b/launcher/src/screenshotTest/kotlin/com/vayunmathur/launcher/ui/MetadataPreviews.kt@@ -27,6 +27,7 @@ import com.vayunmathur.launcher.platform.WidgetPickerUiState import com.vayunmathur.launcher.platform.WorkspaceItem import com.vayunmathur.launcher.ui.components.LauncherDragController import com.vayunmathur.launcher.ui.components.LocalLauncherDrag+import com.vayunmathur.launcher.ui.dialogs.UninstallDialogContent import com.vayunmathur.library.ui.DynamicTheme import com.vayunmathur.library.ui.Surface @@ -160,6 +161,15 @@ class MetadataPreviews {         }     } +    @PreviewTest+    @Preview(name = "6-uninstall-dialog", device = PHONE, group = "phone", showSystemUi = true)+    @Composable+    fun Preview6UninstallDialog() {+        DynamicTheme(darkTheme = true) {+            UninstallDialogContent(label = "Mail", onConfirm = {}, onDismiss = {})+        }+    }+     /**      * The home screen reads its drag state from a composition local with no default, since      * every real entry point provides one. A preview has to stand one up itself.
launcher/src/test/java/com/vayunmathur/launcher/ui/LauncherItemMenuUiTest.kt
diff --git a/launcher/src/test/java/com/vayunmathur/launcher/ui/LauncherItemMenuUiTest.kt b/launcher/src/test/java/com/vayunmathur/launcher/ui/LauncherItemMenuUiTest.ktindex 5d0398d23d..b7c2d5c0a5 100644--- a/launcher/src/test/java/com/vayunmathur/launcher/ui/LauncherItemMenuUiTest.kt+++ b/launcher/src/test/java/com/vayunmathur/launcher/ui/LauncherItemMenuUiTest.kt@@ -1,6 +1,11 @@ package com.vayunmathur.launcher.ui  import androidx.compose.runtime.CompositionLocalProvider+import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableStateOf+import androidx.compose.runtime.remember+import androidx.compose.runtime.setValue+import com.vayunmathur.launcher.ui.dialogs.UninstallDialogContent import androidx.compose.ui.test.assertIsDisplayed import androidx.compose.ui.test.junit4.createComposeRule import androidx.compose.ui.test.onAllNodesWithText@@ -56,14 +61,26 @@ class LauncherItemMenuUiTest {     ) {         rule.setContent {             CompositionLocalProvider(LocalLauncherDrag provides LauncherDragController()) {+            // Host the dialog content the way the UninstallDialog route entry does.+            var pendingUninstall by remember { mutableStateOf<WorkspaceItem?>(null) }             ItemMenuContent(                 state = state,                 actions = object : ItemMenuActions {                     override fun openAppInfo(item: WorkspaceItem) = onAppInfo(item)-                    override fun uninstall(item: WorkspaceItem) = onUninstall(item)                     override fun launchShortcut(entry: ShortcutEntry) = onLaunchShortcut(entry)                 },+                onRequestUninstall = { pendingUninstall = it },             )+            pendingUninstall?.let { target ->+                UninstallDialogContent(+                    label = target.label,+                    onConfirm = {+                        pendingUninstall = null+                        onUninstall(target)+                    },+                    onDismiss = { pendingUninstall = null },+                )+            }             }         }     }