Modern Apps git

← Modern-Apps.git

photos: dialog routes and screenshot coverage for lint

Commit
f632edf46c01b6b11b49a00b7de7a09b7e42bb52
Author
Vayun Mathur <[email protected]>
When
2026-12-02 00:46 UTC (4 days ago)
Parents
ad28615
DialogAsRoute (9): album rename/delete, album picker, delete-person
and secure-folder relock dialogs are now Route destinations with
DialogPage() entries in Navigation.kt, their stateless contents under
ui/dialogs/, pushed from the click handlers. The album dialogs own
their MediaStore consent flow through the new
rememberAlbumMoveLauncher (the dialog entry stays alive until its
write-request launcher delivers), delete-person and relock act
straight on their ViewModels, and the video editor's save dialog is
a SaveDialog destination in the new VideoEditNavigation host (its
own file, so the entry is not gated by the activity's intent state).
Gallery/Favorites/AlbumDetail screens and the people grid no longer
hold show-dialog or pending-delete state; tests were adapted to the
route-request contract (route carrying the album name / picker
destination asserted on the back stack).

RouteScreenshotCoverage (6): real deterministic captures added in
MetadataPreviews for PhotoPage (wide viewer layout), Trash (new
stateless TrashScreen extracted from TrashPage with a thumbnail
seam), VaultViewer (stateless VaultViewerScreen), Wallpaper
(failed-load WallpaperPreview + controls slice) and the five new
dialog routes - all render non-blank PNGs under
updateDevScreenshotTest. Map (MapLibre GL surface) and SecureFolder
(biometric/Keystore-gated decrypted vault grid) are exempted per
route in Route.kt with honest reasons; the regenerated
docs/structure/exceptions.tsv is included. photos/AGENTS.md updated
for the new files.

Verified: ./gradlew :photos:lint :photos:lintVitalRelease
:photos:testDevUnitTest :photos:compileReleaseKotlin all green
(run individually), plus :photos:updateDevScreenshotTest
rendering all 17 previews non-blank.

Diff

docs/structure/exceptions.tsv
diff --git a/docs/structure/exceptions.tsv b/docs/structure/exceptions.tsvindex dcc3d475bb..a47c386c94 100644--- a/docs/structure/exceptions.tsv+++ b/docs/structure/exceptions.tsv@@ -91,4 +91,6 @@ SCREENSHOT_COVERAGE	health/src/main/java/com/vayunmathur/health/Route.kt	LogMeal SCREENSHOT_COVERAGE	health/src/main/java/com/vayunmathur/health/Route.kt	Medical: medical page reads MedicalViewModel record flows and Health Connect/PHR state; no stateless slice for Layoutlib	1 SCREENSHOT_COVERAGE	notes/src/main/java/com/vayunmathur/notes/Route.kt	ExternalNote: external note opens a shared/dropped file URI through the ViewModel; no stateless slice for Layoutlib	1 SCREENSHOT_COVERAGE	notes/src/main/java/com/vayunmathur/notes/Route.kt	InkEditor: ink editor draws on Room-backed block state with a stylus canvas; no stateless slice for Layoutlib	1+SCREENSHOT_COVERAGE	photos/src/main/java/com/vayunmathur/photos/Route.kt	Map: MapLibre GL surface backed by live basemap tiles; Layoutlib has no GL surface or tile source to render	1+SCREENSHOT_COVERAGE	photos/src/main/java/com/vayunmathur/photos/Route.kt	SecureFolder: biometric/Keystore-gated vault grid whose thumbnails are decrypted with the vault password; no stateless Layoutlib slice	1 TOAST	share/src/main/java/com/vayunmathur/share/platform/receive/ShareSaveActivity.kt	no UI to host a snackbar.	1
photos/AGENTS.md
diff --git a/photos/AGENTS.md b/photos/AGENTS.mdindex 2827bf15d9..1d4d52342c 100644--- a/photos/AGENTS.md+++ b/photos/AGENTS.md@@ -5,7 +5,7 @@ _Install: ./install photos (dev by default)._ - Gradle: :photos / dir: photos/ - Package roots present: ui, data, domain, platform, service, widget-- Entry files: MainActivity.kt (no Route.kt — `Route` + `Navigation` are inline)+- Entry files: MainActivity.kt, Route.kt, Navigation.kt - Deps: :library:map, :library:image, :library:ml, :library:room, :library:ink, :library:widgets, :library:biometric, :library:ocr, :library:downloadservice - Metadata: metadata_data/photos.md (present) - Rust: yes / screenshotTest: yes@@ -28,8 +28,10 @@ _Install: ./install photos (dev by default)._ - Upgrades from app versions before v2.6.0 start with a fresh local database (supported upgrade floor: Photo DB v12 and Vault DB v1; Photo DB versions 1–11 open destructively, v12 onward migrates normally; Vault DB has no pre-floor versions)  ## Key files-### Root — entry + inline navigation-- com/vayunmathur/photos/MainActivity.kt — Route, Navigation, pushPhoto, relock logic+### Root — entry + navigation+- com/vayunmathur/photos/MainActivity.kt — entry, pushPhoto, relock logic+- com/vayunmathur/photos/Route.kt — sealed `Route` incl. dialog destinations+- com/vayunmathur/photos/Navigation.kt — nav graph + dialog entries ### data/ — Room + edit-document model - com/vayunmathur/photos/data/PhotosRepository.kt - com/vayunmathur/photos/data/PhotoDatabase.kt@@ -89,10 +91,19 @@ _Install: ./install photos (dev by default)._ - com/vayunmathur/photos/ui/AlbumsScreen.kt - com/vayunmathur/photos/ui/AlbumDetailPage.kt - com/vayunmathur/photos/ui/AlbumDetailScreen.kt-- com/vayunmathur/photos/ui/AlbumPickerDialog.kt - com/vayunmathur/photos/ui/PeoplePage.kt - com/vayunmathur/photos/ui/MapPage.kt - com/vayunmathur/photos/ui/TrashPage.kt+- com/vayunmathur/photos/ui/TrashScreen.kt — stateless trash grid (preview seam)+- com/vayunmathur/photos/ui/RememberAlbumMoveLauncher.kt — MANAGE_MEDIA + MediaStore write-request launcher for album dialog routes+- com/vayunmathur/photos/ui/VideoEditNavigation.kt — video-editor nav host incl. save dialog entry+### ui/dialogs/ — dialog route contents (stateless)+- com/vayunmathur/photos/ui/dialogs/AlbumNameDialog.kt+- com/vayunmathur/photos/ui/dialogs/AlbumPickerDialog.kt+- com/vayunmathur/photos/ui/dialogs/DeleteAlbumDialog.kt+- com/vayunmathur/photos/ui/dialogs/DeletePersonDialog.kt+- com/vayunmathur/photos/ui/dialogs/SecureFolderRelockDialog.kt+- com/vayunmathur/photos/ui/dialogs/SaveDialog.kt - com/vayunmathur/photos/ui/ImageFit.kt ### ui/ — viewer + metadata - com/vayunmathur/photos/ui/PhotoPage.kt
photos/src/main/java/com/vayunmathur/photos/Navigation.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/Navigation.kt b/photos/src/main/java/com/vayunmathur/photos/Navigation.ktindex 18b2b37011..f049a89621 100644--- a/photos/src/main/java/com/vayunmathur/photos/Navigation.kt+++ b/photos/src/main/java/com/vayunmathur/photos/Navigation.kt@@ -10,6 +10,7 @@ import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.runtime.remember import androidx.lifecycle.compose.collectAsStateWithLifecycle+import com.vayunmathur.library.util.DialogPage import com.vayunmathur.library.util.ListDetailPage import com.vayunmathur.library.util.ListPage import com.vayunmathur.library.util.MainNavigation@@ -19,6 +20,7 @@ import com.vayunmathur.library.util.rememberNavBackStack import com.vayunmathur.photos.platform.GalleryViewModel import com.vayunmathur.photos.platform.PhotoMapViewModel import com.vayunmathur.photos.platform.SecureFolderViewModel+import com.vayunmathur.photos.platform.AlbumMediaStore import com.vayunmathur.photos.platform.viewerRouteFor import com.vayunmathur.photos.ui.AlbumDetailPage import com.vayunmathur.photos.ui.AlbumsPage@@ -30,6 +32,7 @@ import com.vayunmathur.photos.ui.RelockEffect import com.vayunmathur.photos.ui.SecureFolderEntry import com.vayunmathur.photos.ui.VaultViewerEntry import com.vayunmathur.photos.ui.WallpaperPage+import com.vayunmathur.photos.ui.rememberAlbumMoveLauncher  @Composable fun Navigation(@@ -116,5 +119,88 @@ fun Navigation(         entry<Route.VaultViewer>(metadata = ListDetailPage()) {             VaultViewerEntry(backStack, it.vaultId, vaultPassword, secureFolderViewModel)         }++        entry<Route.RenameAlbumDialog>(metadata = DialogPage()) {+            val albums by galleryViewModel.albums.collectAsStateWithLifecycle()+            val launchMove = rememberAlbumMoveLauncher(galleryViewModel)+            com.vayunmathur.photos.ui.dialogs.AlbumNameDialog(+                titleRes = R.string.album_rename,+                initialValue = it.albumName,+                onDismiss = { backStack.pop() },+                onConfirm = { newName ->+                    val sanitized = AlbumMediaStore.sanitizeAlbumName(newName)+                    val photos = albums.firstOrNull { album -> album.name == it.albumName }?.photos.orEmpty()+                    if (sanitized.isNotBlank() && sanitized != it.albumName && photos.isNotEmpty()) {+                        launchMove(photos, sanitized) { backStack.pop() }+                    } else {+                        backStack.pop()+                    }+                },+            )+        }++        entry<Route.DeleteAlbumDialog>(metadata = DialogPage()) {+            val albums by galleryViewModel.albums.collectAsStateWithLifecycle()+            val launchMove = rememberAlbumMoveLauncher(galleryViewModel)+            com.vayunmathur.photos.ui.dialogs.DeleteAlbumDialog(+                albumName = it.albumName,+                onDismiss = { backStack.pop() },+                onConfirm = {+                    val photos = albums.firstOrNull { album -> album.name == it.albumName }?.photos.orEmpty()+                    if (photos.isNotEmpty()) {+                        launchMove(photos, null) { success ->+                            backStack.pop()+                            if (success) backStack.pop()+                        }+                    } else {+                        backStack.pop()+                    }+                },+            )+        }++        entry<Route.AlbumPickerDialog>(metadata = DialogPage()) {+            val albums by galleryViewModel.albums.collectAsStateWithLifecycle()+            val galleryPhotos by galleryViewModel.galleryPhotos.collectAsStateWithLifecycle()+            val selectedIds by galleryViewModel.selectedIds.collectAsStateWithLifecycle()+            val launchMove = rememberAlbumMoveLauncher(galleryViewModel)+            com.vayunmathur.photos.ui.dialogs.AlbumPickerDialog(+                existingAlbums = albums.map { album -> album.name },+                onDismiss = { backStack.pop() },+                onConfirm = { name ->+                    val sanitized = AlbumMediaStore.sanitizeAlbumName(name)+                    val selected = galleryPhotos.filter { photo -> photo.id in selectedIds }+                    if (sanitized.isNotBlank() && selected.isNotEmpty()) {+                        launchMove(selected, sanitized) { success ->+                            if (success) galleryViewModel.clearSelection()+                            backStack.pop()+                        }+                    } else {+                        backStack.pop()+                    }+                },+            )+        }++        entry<Route.DeletePersonDialog>(metadata = DialogPage()) {+            com.vayunmathur.photos.ui.dialogs.DeletePersonDialog(+                personName = it.personName,+                onDismiss = { backStack.pop() },+                onConfirm = {+                    galleryViewModel.deletePerson(it.personId)+                    backStack.pop()+                },+            )+        }++        entry<Route.SecureFolderRelockDialog>(metadata = DialogPage()) {+            val relock by secureFolderViewModel.relockOnExit.collectAsStateWithLifecycle()+            com.vayunmathur.photos.ui.dialogs.SecureFolderRelockDialog(+                relockOnExit = relock,+                onCheckedChange = { checked -> secureFolderViewModel.setRelockOnExit(checked) },+                onDismiss = { backStack.pop() },+            )+        }     } }+
photos/src/main/java/com/vayunmathur/photos/Route.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/Route.kt b/photos/src/main/java/com/vayunmathur/photos/Route.ktindex 24b102bea1..6e6489ee9a 100644--- a/photos/src/main/java/com/vayunmathur/photos/Route.kt+++ b/photos/src/main/java/com/vayunmathur/photos/Route.kt@@ -4,6 +4,8 @@ import com.vayunmathur.library.util.NavKey import com.vayunmathur.photos.domain.PhotoSource import kotlinx.serialization.Serializable +// SCREENSHOT COVERAGE EXCEPTION: Map: MapLibre GL surface backed by live basemap tiles; Layoutlib has no GL surface or tile source to render+// SCREENSHOT COVERAGE EXCEPTION: SecureFolder: biometric/Keystore-gated vault grid whose thumbnails are decrypted with the vault password; no stateless Layoutlib slice /** Contract for route. */ @Serializable sealed interface Route: NavKey {@@ -50,4 +52,24 @@ sealed interface Route: NavKey {     /** Immutable value describing wallpaper; carries id, uri. */     @Serializable     data class Wallpaper(val id: Long, val uri: String? = null) : Route++    /** Rename dialog destination for the album named [albumName]. */+    @Serializable+    data class RenameAlbumDialog(val albumName: String) : Route++    /** Delete confirmation dialog destination for the album named [albumName]. */+    @Serializable+    data class DeleteAlbumDialog(val albumName: String) : Route++    /** Album picker dialog destination for the current selection. */+    @Serializable+    data object AlbumPickerDialog : Route++    /** Delete confirmation dialog destination for the person cluster [personId]. */+    @Serializable+    data class DeletePersonDialog(val personId: Long, val personName: String?) : Route++    /** Secure-folder relock settings dialog destination. */+    @Serializable+    data object SecureFolderRelockDialog : Route }
photos/src/main/java/com/vayunmathur/photos/ui/AlbumDetailPage.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/AlbumDetailPage.kt b/photos/src/main/java/com/vayunmathur/photos/ui/AlbumDetailPage.ktindex 5602cb1058..618bac8c65 100644--- a/photos/src/main/java/com/vayunmathur/photos/ui/AlbumDetailPage.kt+++ b/photos/src/main/java/com/vayunmathur/photos/ui/AlbumDetailPage.kt@@ -99,16 +99,6 @@ fun AlbumDetailPage(             galleryViewModel.setAlbumCover(albumName, photoId)             galleryViewModel.clearSelection()         },-        onRenameAlbum = { newName ->-            val sanitized = AlbumMediaStore.sanitizeAlbumName(newName)-            if (sanitized.isNotBlank() && sanitized != albumName) {-                launchMove(album?.photos.orEmpty(), sanitized)-            }-        },-        onDeleteAlbum = {-            pendingPop = true-            launchMove(album?.photos.orEmpty(), null)-        },         isRefreshing = isRefreshing,         onRefresh = { galleryViewModel.runSync() },     )
photos/src/main/java/com/vayunmathur/photos/ui/AlbumDetailScreen.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/AlbumDetailScreen.kt b/photos/src/main/java/com/vayunmathur/photos/ui/AlbumDetailScreen.ktindex fac3ec1232..533a5e2e05 100644--- a/photos/src/main/java/com/vayunmathur/photos/ui/AlbumDetailScreen.kt+++ b/photos/src/main/java/com/vayunmathur/photos/ui/AlbumDetailScreen.kt@@ -3,7 +3,6 @@ package com.vayunmathur.photos.ui import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.fillMaxSize-import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.grid.GridCells import androidx.compose.foundation.lazy.grid.GridItemSpan@@ -11,7 +10,6 @@ import androidx.compose.foundation.lazy.grid.LazyVerticalGrid import androidx.compose.foundation.lazy.grid.items import com.vayunmathur.library.ui.ExperimentalMaterial3Api import com.vayunmathur.library.ui.EmptyState-import com.vayunmathur.library.ui.AlertDialog import com.vayunmathur.library.ui.DropdownMenu import com.vayunmathur.library.ui.DropdownMenuItem import com.vayunmathur.library.ui.IconAlbum@@ -21,9 +19,7 @@ import com.vayunmathur.library.ui.IconEdit import com.vayunmathur.library.ui.IconImage import com.vayunmathur.library.ui.IconMoreVert import com.vayunmathur.library.ui.MaterialTheme-import com.vayunmathur.library.ui.OutlinedTextField import com.vayunmathur.library.ui.Text-import com.vayunmathur.library.ui.TextButton import com.vayunmathur.library.ui.AppScaffold import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue@@ -69,8 +65,6 @@ fun AlbumDetailScreen(     onClearSelection: () -> Unit = {},     onRemoveFromAlbum: () -> Unit = {},     onSetCover: (Long) -> Unit = {},-    onRenameAlbum: (String) -> Unit = {},-    onDeleteAlbum: () -> Unit = {},     isRefreshing: Boolean = false,     onRefresh: () -> Unit = {},     /**@@ -84,8 +78,6 @@ fun AlbumDetailScreen(     val title = if (isUnknown) stringResource(R.string.albums_unknown) else albumName     val isSelectionMode = selectedIds.isNotEmpty()     var menuExpanded by remember { mutableStateOf(false) }-    var showRenameDialog by remember { mutableStateOf(false) }-    var showDeleteDialog by remember { mutableStateOf(false) }     var columnCount by LocalColumnCount.current      val photos = album?.photos.orEmpty()@@ -130,7 +122,7 @@ fun AlbumDetailScreen(                         leadingIcon = { IconEdit() },                         onClick = {                             menuExpanded = false-                            showRenameDialog = true+                            backStack.add(Route.RenameAlbumDialog(albumName))                         },                     )                     DropdownMenuItem(@@ -138,7 +130,7 @@ fun AlbumDetailScreen(                         leadingIcon = { IconDelete() },                         onClick = {                             menuExpanded = false-                            showDeleteDialog = true+                            backStack.add(Route.DeleteAlbumDialog(albumName))                         },                     )                 }@@ -193,70 +185,4 @@ fun AlbumDetailScreen(                 }         }     }--    if (showRenameDialog) {-        AlbumNameDialog(-            titleRes = R.string.album_rename,-            initialValue = albumName,-            onDismiss = { showRenameDialog = false },-            onConfirm = { newName ->-                showRenameDialog = false-                onRenameAlbum(newName)-            },-        )-    }--    if (showDeleteDialog) {-        AlertDialog(-            onDismissRequest = { showDeleteDialog = false },-            title = { Text(stringResource(R.string.album_delete)) },-            text = { Text(stringResource(R.string.album_delete_confirm, title)) },-            confirmButton = {-                TextButton(onClick = {-                    showDeleteDialog = false-                    onDeleteAlbum()-                }) {-                    Text(stringResource(R.string.album_delete))-                }-            },-            dismissButton = {-                TextButton(onClick = { showDeleteDialog = false }) {-                    Text(stringResource(R.string.action_cancel))-                }-            },-        )-    }-}--@Composable-private fun AlbumNameDialog(-    titleRes: Int,-    initialValue: String,-    onDismiss: () -> Unit,-    onConfirm: (String) -> Unit,-) {-    var name by remember { mutableStateOf(initialValue) }-    AlertDialog(-        onDismissRequest = onDismiss,-        title = { Text(stringResource(titleRes)) },-        text = {-            OutlinedTextField(-                value = name,-                onValueChange = { name = it },-                label = { Text(stringResource(R.string.album_name_hint)) },-                singleLine = true,-                modifier = Modifier.fillMaxWidth(),-            )-        },-        confirmButton = {-            TextButton(onClick = { onConfirm(name) }, enabled = name.isNotBlank()) {-                Text(stringResource(R.string.album_rename))-            }-        },-        dismissButton = {-            TextButton(onClick = onDismiss) {-                Text(stringResource(R.string.action_cancel))-            }-        },-    ) }
photos/src/main/java/com/vayunmathur/photos/ui/FavoritesPage.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/FavoritesPage.kt b/photos/src/main/java/com/vayunmathur/photos/ui/FavoritesPage.ktindex dcba3f3c81..8cde4cbd7b 100644--- a/photos/src/main/java/com/vayunmathur/photos/ui/FavoritesPage.kt+++ b/photos/src/main/java/com/vayunmathur/photos/ui/FavoritesPage.kt@@ -29,6 +29,7 @@ fun FavoritesPage(         derivedStateOf { allSelected.intersect(favorites.mapTo(HashSet()) { it.id }) }     } +    val actions = rememberGalleryActions(galleryViewModel, secureFolderViewModel, favorites, selectedIds)     FavoritesScreen(         backStack = backStack,         state = GalleryUiState(@@ -37,6 +38,6 @@ fun FavoritesPage(             isRefreshing = isRefreshing,             albums = albums,         ),-        actions = rememberGalleryActions(galleryViewModel, secureFolderViewModel, favorites, selectedIds),+        actions = actions,     ) }
photos/src/main/java/com/vayunmathur/photos/ui/FavoritesScreen.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/FavoritesScreen.kt b/photos/src/main/java/com/vayunmathur/photos/ui/FavoritesScreen.ktindex cb33d7f967..c5bbaf057f 100644--- a/photos/src/main/java/com/vayunmathur/photos/ui/FavoritesScreen.kt+++ b/photos/src/main/java/com/vayunmathur/photos/ui/FavoritesScreen.kt@@ -65,7 +65,6 @@ fun FavoritesScreen(     val allFavorite = remember(photos, state.selectedIds) {         !FavoriteRule.targetValue(photos.filter { it.id in state.selectedIds }.map { it.isFavorite })     }-    var showAlbumPicker by remember { mutableStateOf(false) }     var columnCount by LocalColumnCount.current     val resources = LocalResources.current @@ -86,7 +85,7 @@ fun FavoritesScreen(         onClose = if (isSelectionMode) ({ actions.clearSelection() }) else null,         actions = {             if (isSelectionMode) {-                GallerySelectionActions(allFavorite, actions, onAddToAlbum = { showAlbumPicker = true })+                GallerySelectionActions(allFavorite, actions, onAddToAlbum = { backStack.add(Route.AlbumPickerDialog) })             }         },         isRefreshing = state.isRefreshing,@@ -141,14 +140,4 @@ fun FavoritesScreen(         }     } -    if (showAlbumPicker) {-        AlbumPickerDialog(-            existingAlbums = state.albums.map { it.name },-            onDismiss = { showAlbumPicker = false },-            onConfirm = { name ->-                showAlbumPicker = false-                actions.addSelectionToAlbum(name)-            },-        )-    } }
photos/src/main/java/com/vayunmathur/photos/ui/GalleryScreen.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/GalleryScreen.kt b/photos/src/main/java/com/vayunmathur/photos/ui/GalleryScreen.ktindex 0a924a81ca..90d511e9d2 100644--- a/photos/src/main/java/com/vayunmathur/photos/ui/GalleryScreen.kt+++ b/photos/src/main/java/com/vayunmathur/photos/ui/GalleryScreen.kt@@ -103,7 +103,6 @@ fun GalleryScreen( ) {     var columnCount by LocalColumnCount.current     var searchActive by remember { mutableStateOf(initialSearchActive) }-    var showAlbumPicker by remember { mutableStateOf(false) }     val isSelectionMode = state.selectedIds.isNotEmpty()     val allFavorite = remember(state.photos, state.selectedIds) {         !FavoriteRule.targetValue(state.photos.filter { it.id in state.selectedIds }.map { it.isFavorite })@@ -154,7 +153,7 @@ fun GalleryScreen(                             }                         },                         actions = {-                            GallerySelectionActions(allFavorite, actions, onAddToAlbum = { showAlbumPicker = true })+                            GallerySelectionActions(allFavorite, actions, onAddToAlbum = { backStack.add(Route.AlbumPickerDialog) })                         }                     )                 } else {@@ -318,14 +317,4 @@ fun GalleryScreen(             }     } -    if (showAlbumPicker) {-        AlbumPickerDialog(-            existingAlbums = state.albums.map { it.name },-            onDismiss = { showAlbumPicker = false },-            onConfirm = { name ->-                showAlbumPicker = false-                actions.addSelectionToAlbum(name)-            },-        )-    } }
photos/src/main/java/com/vayunmathur/photos/ui/PeoplePage.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/PeoplePage.kt b/photos/src/main/java/com/vayunmathur/photos/ui/PeoplePage.ktindex 47cbd38996..106f0c5630 100644--- a/photos/src/main/java/com/vayunmathur/photos/ui/PeoplePage.kt+++ b/photos/src/main/java/com/vayunmathur/photos/ui/PeoplePage.kt@@ -17,7 +17,6 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.grid.LazyVerticalGrid import androidx.compose.foundation.lazy.grid.items import androidx.compose.foundation.shape.CircleShape-import com.vayunmathur.library.ui.AlertDialog import com.vayunmathur.library.ui.DropdownMenu import com.vayunmathur.library.ui.DropdownMenuItem import com.vayunmathur.library.ui.ExperimentalMaterial3Api@@ -26,7 +25,6 @@ import com.vayunmathur.library.ui.IconDelete import com.vayunmathur.library.ui.IconEdit import com.vayunmathur.library.ui.IconMoreVert import com.vayunmathur.library.ui.IconVisibilityOff-import com.vayunmathur.library.ui.TextButton import com.vayunmathur.library.ui.adaptiveGridCells import com.vayunmathur.library.ui.LinearProgressIndicator import com.vayunmathur.library.ui.MaterialTheme@@ -172,11 +170,9 @@ internal fun PeopleGrid(     onHideClick: (PersonCluster) -> Unit = {},     onDeleteClick: (PersonCluster) -> Unit = {},     onClick: (PersonCluster) -> Unit,+    backStack: NavBackStack<Route>? = null, ) {-    // Cluster whose overflow menu is open, and cluster awaiting the delete-    // confirmation — the same pending-state shape as the album delete flow.     var menuPersonId by remember { mutableStateOf<Long?>(null) }-    var pendingDelete by remember { mutableStateOf<PersonCluster?>(null) }     LazyVerticalGrid(         columns = adaptiveGridCells(100.dp),         horizontalArrangement = Arrangement.spacedBy(8.dp),@@ -225,7 +221,11 @@ internal fun PeopleGrid(                                 leadingIcon = { IconDelete() },                                 onClick = {                                     menuPersonId = null-                                    pendingDelete = person+                                    if (backStack != null) {+                                        backStack.add(Route.DeletePersonDialog(person.id, person.name))+                                    } else {+                                        onDeleteClick(person)+                                    }                                 },                             )                         }@@ -252,33 +252,6 @@ internal fun PeopleGrid(             }         }     }-    pendingDelete?.let { person ->-        AlertDialog(-            onDismissRequest = { pendingDelete = null },-            title = { Text(stringResource(R.string.people_delete)) },-            text = {-                Text(-                    stringResource(-                        R.string.people_delete_confirm,-                        person.name ?: stringResource(R.string.people_unnamed),-                    )-                )-            },-            confirmButton = {-                TextButton(onClick = {-                    pendingDelete = null-                    onDeleteClick(person)-                }) {-                    Text(stringResource(R.string.people_delete))-                }-            },-            dismissButton = {-                TextButton(onClick = { pendingDelete = null }) {-                    Text(stringResource(R.string.action_cancel))-                }-            },-        )-    } }  /** The representative face of a cluster, cropped from its cover photo. */
photos/src/main/java/com/vayunmathur/photos/ui/PeopleScreen.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/PeopleScreen.kt b/photos/src/main/java/com/vayunmathur/photos/ui/PeopleScreen.ktindex 5df6939cda..084cb66830 100644--- a/photos/src/main/java/com/vayunmathur/photos/ui/PeopleScreen.kt+++ b/photos/src/main/java/com/vayunmathur/photos/ui/PeopleScreen.kt@@ -110,9 +110,11 @@ fun PeopleScreen(                             onNameClick = onNameClick,                             onHideClick = onHideClick,                             onDeleteClick = onDeleteClick,-                        ) { person ->-                            backStack.pushPhoto(Route.PhotoPage(person.coverPhoto.id, com.vayunmathur.photos.domain.PhotoSource.Person(person.id)))-                        }+                            onClick = { person ->+                                backStack.pushPhoto(Route.PhotoPage(person.coverPhoto.id, com.vayunmathur.photos.domain.PhotoSource.Person(person.id)))+                            },+                            backStack = backStack,+                        )                     } else {                         Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {                             Text(
photos/src/main/java/com/vayunmathur/photos/ui/RememberAlbumMoveLauncher.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/RememberAlbumMoveLauncher.kt b/photos/src/main/java/com/vayunmathur/photos/ui/RememberAlbumMoveLauncher.ktnew file mode 100644index 0000000000..663bd72358--- /dev/null+++ b/photos/src/main/java/com/vayunmathur/photos/ui/RememberAlbumMoveLauncher.kt@@ -0,0 +1,67 @@+package com.vayunmathur.photos.ui++import android.app.Activity+import android.provider.MediaStore+import androidx.activity.compose.rememberLauncherForActivityResult+import androidx.activity.result.IntentSenderRequest+import androidx.activity.result.contract.ActivityResultContracts+import androidx.compose.runtime.Composable+import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableStateOf+import androidx.compose.runtime.remember+import androidx.compose.runtime.setValue+import androidx.compose.ui.platform.LocalContext+import androidx.compose.ui.res.stringResource+import com.vayunmathur.library.ui.rememberMessenger+import com.vayunmathur.photos.R+import com.vayunmathur.photos.data.Photo+import com.vayunmathur.photos.platform.AlbumMediaStore+import com.vayunmathur.photos.platform.GalleryViewModel++/**+ * Album-move launcher for the dialog routes: asks for MANAGE_MEDIA at the+ * action, then launches the MediaStore write request for the pending move+ * recorded on the ViewModel. [onDone] reports whether the move was granted;+ * the caller pops its dialog route there, once this entry's launcher has+ * delivered the result.+ */+@Composable+fun rememberAlbumMoveLauncher(+    galleryViewModel: GalleryViewModel,+): (List<Photo>, String?, (Boolean) -> Unit) -> Unit {+    val context = LocalContext.current+    val messenger = rememberMessenger()+    val deniedMessage = stringResource(R.string.manage_media_required)+    var pendingDone by remember { mutableStateOf<((Boolean) -> Unit)?>(null) }+    val ensureManageMedia = rememberManageMediaAction {+        pendingDone?.invoke(false)+        pendingDone = null+        messenger.show(deniedMessage)+    }+    val launcher = rememberLauncherForActivityResult(+        ActivityResultContracts.StartIntentSenderForResult(),+    ) { result ->+        val done = pendingDone+        pendingDone = null+        if (result.resultCode == Activity.RESULT_OK) {+            galleryViewModel.consumePendingMove()+            done?.invoke(true)+        } else {+            galleryViewModel.abandonPendingMove()+            done?.invoke(false)+        }+    }+    return remember(galleryViewModel, context) {+        { photos, target, onDone ->+            pendingDone = onDone+            ensureManageMedia {+                galleryViewModel.requestAlbumMove(photos, target)+                val pendingIntent = MediaStore.createWriteRequest(+                    context.contentResolver,+                    AlbumMediaStore.urisOf(photos),+                )+                launcher.launch(IntentSenderRequest.Builder(pendingIntent.intentSender).build())+            }+        }+    }+}
photos/src/main/java/com/vayunmathur/photos/ui/SecureFolderPage.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/SecureFolderPage.kt b/photos/src/main/java/com/vayunmathur/photos/ui/SecureFolderPage.ktindex 47bfd7bf5f..b54872ac58 100644--- a/photos/src/main/java/com/vayunmathur/photos/ui/SecureFolderPage.kt+++ b/photos/src/main/java/com/vayunmathur/photos/ui/SecureFolderPage.kt@@ -6,8 +6,6 @@ import androidx.compose.foundation.background import androidx.compose.foundation.combinedClickable import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box-import androidx.compose.foundation.layout.Column-import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.aspectRatio import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth@@ -20,15 +18,9 @@ import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.shape.RoundedCornerShape import com.vayunmathur.library.ui.EmptyState import com.vayunmathur.library.ui.ExperimentalMaterial3Api-import com.vayunmathur.library.ui.AlertDialog import com.vayunmathur.library.ui.AppScaffold import com.vayunmathur.library.ui.IconButton import com.vayunmathur.library.ui.IconSettings-import com.vayunmathur.library.ui.Switch-import com.vayunmathur.library.ui.TextButton-import com.vayunmathur.library.ui.R as UiR-import com.vayunmathur.library.ui.MaterialTheme-import com.vayunmathur.library.ui.Surface import com.vayunmathur.library.ui.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect@@ -72,18 +64,9 @@ fun SecureFolderPage(     var columnCount by LocalColumnCount.current     val selectedIds by secureFolderViewModel.selectedIds.collectAsState()     val isSelectionMode = selectedIds.isNotEmpty()-    var showRelockSettings by remember { mutableStateOf(false) }-    val relockOnExit by secureFolderViewModel.relockOnExit.collectAsState()      val closeSelection: (() -> Unit)? =         if (isSelectionMode) ({ secureFolderViewModel.clearSelection() }) else null-    if (showRelockSettings) {-        SecureFolderRelockDialog(-            relockOnExit = relockOnExit,-            onCheckedChange = { secureFolderViewModel.setRelockOnExit(it) },-            onDismiss = { showRelockSettings = false },-        )-    }     AppScaffold(         title = if (isSelectionMode) {             pluralStringResource(R.plurals.items_selected, selectedIds.size, selectedIds.size)@@ -101,7 +84,7 @@ fun SecureFolderPage(                     IconUnarchive()                 }             } else {-                IconButton(onClick = { showRelockSettings = true }) {+                IconButton(onClick = { backStack.add(Route.SecureFolderRelockDialog) }) {                     IconSettings()                 }                 BackupButtons(@@ -154,36 +137,4 @@ fun SecureFolderPage(     } } -@Composable-private fun SecureFolderRelockDialog(-    relockOnExit: Boolean,-    onCheckedChange: (Boolean) -> Unit,-    onDismiss: () -> Unit,-) {-    AlertDialog(-        onDismissRequest = onDismiss,-        title = { Text(stringResource(R.string.secure_folder_relock_title)) },-        text = {-            Column(modifier = Modifier.fillMaxWidth()) {-                Row(-                    modifier = Modifier.fillMaxWidth(),-                    horizontalArrangement = Arrangement.SpaceBetween,-                    verticalAlignment = Alignment.CenterVertically,-                ) {-                    Text(stringResource(R.string.secure_folder_relock_label))-                    Switch(checked = relockOnExit, onCheckedChange = onCheckedChange)-                }-                Text(-                    stringResource(R.string.secure_folder_relock_description),-                    style = MaterialTheme.typography.bodySmall,-                )-            }-        },-        confirmButton = {-            TextButton(onClick = onDismiss) {-                Text(stringResource(UiR.string.done))-            }-        },-    )-} 
photos/src/main/java/com/vayunmathur/photos/ui/TrashPage.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/TrashPage.kt b/photos/src/main/java/com/vayunmathur/photos/ui/TrashPage.ktindex 00199448ee..0e2a5dda8e 100644--- a/photos/src/main/java/com/vayunmathur/photos/ui/TrashPage.kt+++ b/photos/src/main/java/com/vayunmathur/photos/ui/TrashPage.kt@@ -1,78 +1,45 @@ package com.vayunmathur.photos.ui-import com.vayunmathur.photos.R  import android.app.Activity import android.provider.MediaStore import androidx.activity.compose.rememberLauncherForActivityResult import androidx.activity.result.IntentSenderRequest import androidx.activity.result.contract.ActivityResultContracts-import androidx.compose.foundation.layout.Arrangement-import androidx.compose.foundation.layout.Box-import androidx.compose.foundation.layout.fillMaxSize-import androidx.compose.foundation.layout.padding-import androidx.compose.foundation.lazy.grid.GridCells-import androidx.compose.foundation.lazy.grid.GridItemSpan-import androidx.compose.foundation.lazy.grid.LazyVerticalGrid-import androidx.compose.foundation.lazy.grid.items-import com.vayunmathur.library.ui.EmptyState-import com.vayunmathur.library.ui.ExperimentalMaterial3Api-import com.vayunmathur.library.ui.AppScaffold-import com.vayunmathur.library.ui.IconButton-import com.vayunmathur.library.ui.MaterialTheme-import com.vayunmathur.library.ui.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.collectAsState import androidx.compose.runtime.derivedStateOf import androidx.compose.runtime.getValue-import androidx.compose.runtime.mutableFloatStateOf import androidx.compose.runtime.mutableStateListOf-import androidx.compose.runtime.produceState import androidx.compose.runtime.remember-import androidx.compose.runtime.setValue-import androidx.compose.ui.Alignment-import androidx.compose.ui.Modifier-import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalContext-import androidx.compose.ui.platform.LocalResources import androidx.compose.ui.res.stringResource-import androidx.compose.ui.res.pluralStringResource-import androidx.compose.ui.unit.dp import androidx.core.net.toUri-import com.vayunmathur.library.ui.IconDelete-import com.vayunmathur.library.ui.IconUnarchive import com.vayunmathur.library.ui.rememberMessenger import com.vayunmathur.library.util.NavBackStack-import com.vayunmathur.photos.ui.LocalColumnCount+import com.vayunmathur.photos.R import com.vayunmathur.photos.Route-import com.vayunmathur.photos.data.Photo import com.vayunmathur.photos.platform.GalleryViewModel-import com.vayunmathur.photos.platform.ImageLoader import com.vayunmathur.photos.platform.enqueueSyncWork import com.vayunmathur.photos.platform.runSyncOnce-import kotlinx.coroutines.Dispatchers-import kotlinx.coroutines.withContext-import kotlin.math.roundToInt -@OptIn(ExperimentalMaterial3Api::class)+/** Binds [GalleryViewModel] to the stateless [TrashScreen]. */ @Composable fun TrashPage(backStack: NavBackStack<Route>, galleryViewModel: GalleryViewModel) {     val allPhotos by galleryViewModel.photos.collectAsState()     val trashedPhotos by remember { derivedStateOf { allPhotos.filter { it.isTrashed } } }     val context = LocalContext.current-    val resources = LocalResources.current      LaunchedEffect(Unit) {         runSyncOnce(context)         enqueueSyncWork(context)     } -    var columnCount by LocalColumnCount.current-     val selectedIds = remember { mutableStateListOf<Long>() }-    val isSelectionMode by remember { derivedStateOf { selectedIds.isNotEmpty() } } -    val trashLauncher = rememberLauncherForActivityResult(ActivityResultContracts.StartIntentSenderForResult()) { result ->+    val trashLauncher = rememberLauncherForActivityResult(+        ActivityResultContracts.StartIntentSenderForResult(),+    ) { result ->         if (result.resultCode == Activity.RESULT_OK) {             selectedIds.clear()             runSyncOnce(context)@@ -87,109 +54,42 @@ fun TrashPage(backStack: NavBackStack<Route>, galleryViewModel: GalleryViewModel         messenger.show(manageMediaDeniedMessage)     } -    // Grouping is O(N) with a timezone conversion per photo, so it runs on-    // Dispatchers.Default. The seed is computed once so the grid isn't blank on the-    // first frame; produceState's initialValue is eagerly evaluated, hence the-    // remember rather than an inline call.-    val initialGrouping = remember { groupPhotosByMonth(trashedPhotos, resources) }-    val photosGroupedByMonth by produceState(-        initialValue = initialGrouping,-        trashedPhotos,-        resources,-    ) {-        value = withContext(Dispatchers.Default) { groupPhotosByMonth(trashedPhotos, resources) }+    fun launchTrashRequest(photos: List<com.vayunmathur.photos.data.Photo>, trash: Boolean) {+        ensureManageMedia {+            val uris = photos.map { it.uri.toUri() }+            val pendingIntent = if (trash) {+                MediaStore.createTrashRequest(context.contentResolver, uris, false)+            } else {+                MediaStore.createDeleteRequest(context.contentResolver, uris)+            }+            trashLauncher.launch(IntentSenderRequest.Builder(pendingIntent.intentSender).build())+        }     } -    val closeSelection: (() -> Unit)? = if (isSelectionMode) ({ selectedIds.clear() }) else null-    AppScaffold(-        title = if (isSelectionMode) {-            pluralStringResource(com.vayunmathur.photos.R.plurals.items_selected, selectedIds.size, selectedIds.size)-        } else {-            stringResource(com.vayunmathur.photos.R.string.label_trash)+    TrashScreen(+        backStack = backStack,+        photos = trashedPhotos,+        selectedIds = selectedIds.toList(),+        onToggleSelection = { id ->+            if (id in selectedIds) selectedIds.remove(id) else selectedIds.add(id)         },-        onNavigateBack = if (isSelectionMode) null else ({ backStack.pop() }),-        onClose = closeSelection,-        actions = {-            if (isSelectionMode) {-                IconButton(onClick = {-                    ensureManageMedia {-                        val uris = trashedPhotos.filter { it.id in selectedIds }.map { it.uri.toUri() }-                        val pendingIntent = MediaStore.createTrashRequest(context.contentResolver, uris, false)-                        trashLauncher.launch(IntentSenderRequest.Builder(pendingIntent.intentSender).build())-                    }-                }) {-                    IconUnarchive() // Restore icon-                }-                IconButton(onClick = {-                    ensureManageMedia {-                        val uris = trashedPhotos.filter { it.id in selectedIds }.map { it.uri.toUri() }-                        val pendingIntent = MediaStore.createDeleteRequest(context.contentResolver, uris)-                        trashLauncher.launch(IntentSenderRequest.Builder(pendingIntent.intentSender).build())-                    }-                }) {-                    IconDelete() // Permanent delete icon-                }-            } else {-                if (trashedPhotos.isNotEmpty()) {-                    IconButton(onClick = {-                        ensureManageMedia {-                            val uris = trashedPhotos.map { it.uri.toUri() }-                            val pendingIntent = MediaStore.createDeleteRequest(context.contentResolver, uris)-                            trashLauncher.launch(IntentSenderRequest.Builder(pendingIntent.intentSender).build())-                        }-                    }) {-                        IconDelete()-                    }-                }+        onClearSelection = { selectedIds.clear() },+        onRestore = {+            launchTrashRequest(trashedPhotos.filter { it.id in selectedIds }, trash = true)+        },+        onDeleteSelected = {+            ensureManageMedia {+                val uris = trashedPhotos.filter { it.id in selectedIds }.map { it.uri.toUri() }+                val pendingIntent = MediaStore.createDeleteRequest(context.contentResolver, uris)+                trashLauncher.launch(IntentSenderRequest.Builder(pendingIntent.intentSender).build())             }         },-    ) { paddingValues ->-        if (trashedPhotos.isEmpty()) {-            EmptyState(-                title = stringResource(R.string.trash_is_empty),-                modifier = Modifier.fillMaxSize().padding(paddingValues),-            )-        } else {-            Box(-                modifier = Modifier-                    .fillMaxSize()-                    .pinchToZoomColumns({ columnCount }, { columnCount = it })-            ) {-                LazyVerticalGrid(-                    GridCells.Fixed(columnCount.roundToInt().coerceIn(2, 8)),-                    Modifier.padding(paddingValues),-                    horizontalArrangement = Arrangement.spacedBy(4.dp),-                    verticalArrangement = Arrangement.spacedBy(4.dp)-                ) {-                    photosGroupedByMonth.forEach { (month, photosInMonth) ->-                        item(span = { GridItemSpan(maxLineSpan) }) {-                            Text(-                                month,-                                Modifier.padding(top = 16.dp, bottom = 8.dp, start = 16.dp),-                                style = MaterialTheme.typography.titleLarge-                            )-                        }-                        items(photosInMonth, { it.id }, contentType = { "photo_thumbnail" }) { photo ->-                            val isSelected = photo.id in selectedIds-                            ImageLoader.SelectablePhotoItem(-                                photo = photo,-                                isSelected = isSelected,-                                isSelectionMode = isSelectionMode,-                                onToggleSelection = {-                                    if (isSelected) selectedIds.remove(photo.id) else selectedIds.add(photo.id)-                                },-                                onClick = {-                                    if (isSelectionMode) {-                                        if (isSelected) selectedIds.remove(photo.id) else selectedIds.add(photo.id)-                                    } else {-                                        selectedIds.add(photo.id)-                                    }-                                }-                            )-                        }-                    }-                }+        onDeleteAll = {+            ensureManageMedia {+                val uris = trashedPhotos.map { it.uri.toUri() }+                val pendingIntent = MediaStore.createDeleteRequest(context.contentResolver, uris)+                trashLauncher.launch(IntentSenderRequest.Builder(pendingIntent.intentSender).build())             }-        }-    }+        },+    ) }
photos/src/main/java/com/vayunmathur/photos/ui/TrashScreen.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/TrashScreen.kt b/photos/src/main/java/com/vayunmathur/photos/ui/TrashScreen.ktnew file mode 100644index 0000000000..bf067a70a2--- /dev/null+++ b/photos/src/main/java/com/vayunmathur/photos/ui/TrashScreen.kt@@ -0,0 +1,118 @@+package com.vayunmathur.photos.ui++import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.fillMaxSize+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.lazy.grid.GridCells+import androidx.compose.foundation.lazy.grid.GridItemSpan+import androidx.compose.foundation.lazy.grid.LazyVerticalGrid+import androidx.compose.foundation.lazy.grid.items+import androidx.compose.runtime.Composable+import androidx.compose.runtime.getValue+import androidx.compose.runtime.produceState+import androidx.compose.runtime.setValue+import androidx.compose.runtime.remember+import androidx.compose.ui.Modifier+import androidx.compose.ui.platform.LocalResources+import androidx.compose.ui.res.pluralStringResource+import androidx.compose.ui.res.stringResource+import androidx.compose.ui.unit.dp+import com.vayunmathur.library.ui.AppScaffold+import com.vayunmathur.library.ui.EmptyState+import com.vayunmathur.library.ui.ExperimentalMaterial3Api+import com.vayunmathur.library.ui.IconButton+import com.vayunmathur.library.ui.IconDelete+import com.vayunmathur.library.ui.IconUnarchive+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.Text+import com.vayunmathur.library.util.NavBackStack+import com.vayunmathur.photos.R+import com.vayunmathur.photos.Route+import com.vayunmathur.photos.data.Photo+import com.vayunmathur.photos.platform.ImageLoader+import kotlinx.coroutines.Dispatchers+import kotlinx.coroutines.withContext+import kotlin.math.roundToInt++/** Stateless trash grid, rendered from a preview with placeholder thumbnails. */+@OptIn(ExperimentalMaterial3Api::class)+@Composable+fun TrashScreen(+    backStack: NavBackStack<Route>,+    photos: List<Photo>,+    selectedIds: List<Long>,+    onToggleSelection: (Long) -> Unit = {},+    onClearSelection: () -> Unit = {},+    onRestore: () -> Unit = {},+    onDeleteSelected: () -> Unit = {},+    onDeleteAll: () -> Unit = {},+    thumbnail: @Composable (Photo, Modifier) -> Unit = { photo, modifier ->+        ImageLoader.PhotoItem(photo, modifier)+    },+) {+    var columnCount by LocalColumnCount.current+    val resources = LocalResources.current+    val isSelectionMode = selectedIds.isNotEmpty()+    val initialGrouping = remember { groupPhotosByMonth(photos, resources) }+    val photosGroupedByMonth by produceState(initialValue = initialGrouping, photos, resources) {+        value = withContext(Dispatchers.Default) { groupPhotosByMonth(photos, resources) }+    }+    AppScaffold(+        title = if (isSelectionMode) {+            pluralStringResource(R.plurals.items_selected, selectedIds.size, selectedIds.size)+        } else {+            stringResource(R.string.label_trash)+        },+        onNavigateBack = if (isSelectionMode) null else ({ backStack.pop() }),+        onClose = if (isSelectionMode) ({ onClearSelection() }) else null,+        actions = {+            if (isSelectionMode) {+                IconButton(onClick = onRestore) { IconUnarchive() }+                IconButton(onClick = onDeleteSelected) { IconDelete() }+            } else if (photos.isNotEmpty()) {+                IconButton(onClick = onDeleteAll) { IconDelete() }+            }+        },+    ) { paddingValues ->+        if (photos.isEmpty()) {+            EmptyState(+                title = stringResource(R.string.trash_is_empty),+                modifier = Modifier.fillMaxSize().padding(paddingValues),+            )+        } else {+            Box(+                modifier = Modifier+                    .fillMaxSize()+                    .pinchToZoomColumns({ columnCount }, { columnCount = it }),+            ) {+                LazyVerticalGrid(+                    GridCells.Fixed(columnCount.roundToInt().coerceIn(2, 8)),+                    Modifier.padding(paddingValues),+                    horizontalArrangement = Arrangement.spacedBy(4.dp),+                    verticalArrangement = Arrangement.spacedBy(4.dp),+                ) {+                    photosGroupedByMonth.forEach { (month, photosInMonth) ->+                        item(span = { GridItemSpan(maxLineSpan) }) {+                            Text(+                                month,+                                Modifier.padding(top = 16.dp, bottom = 8.dp, start = 16.dp),+                                style = MaterialTheme.typography.titleLarge,+                            )+                        }+                        items(photosInMonth, { it.id }, contentType = { "photo_thumbnail" }) { photo ->+                            ImageLoader.SelectablePhotoItem(+                                photo = photo,+                                isSelected = photo.id in selectedIds,+                                isSelectionMode = isSelectionMode,+                                onToggleSelection = { onToggleSelection(photo.id) },+                                onClick = { onToggleSelection(photo.id) },+                                thumbnail = thumbnail,+                            )+                        }+                    }+                }+            }+        }+    }+}
photos/src/main/java/com/vayunmathur/photos/ui/VideoEditActivity.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/VideoEditActivity.kt b/photos/src/main/java/com/vayunmathur/photos/ui/VideoEditActivity.ktindex 457ab7a603..bba5e56e30 100644--- a/photos/src/main/java/com/vayunmathur/photos/ui/VideoEditActivity.kt+++ b/photos/src/main/java/com/vayunmathur/photos/ui/VideoEditActivity.kt@@ -9,6 +9,7 @@ import androidx.activity.compose.setContent import androidx.activity.enableEdgeToEdge import androidx.activity.viewModels import androidx.compose.runtime.Composable+import androidx.compose.runtime.collectAsState import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableLongStateOf@@ -66,17 +67,3 @@ class VideoEditActivity : ComponentActivity() {     } } -@OptIn(UnstableApi::class)-@Composable-fun VideoEditNavigation(-    videoEditViewModel: VideoEditViewModel,-    photoId: Long,-    photoUri: String?,-) {-    val backStack = rememberNavBackStack<VideoEditRoute>(VideoEditRoute.EditVideo(photoId, photoUri))-    MainNavigation(backStack) {-        entry<VideoEditRoute.EditVideo>(metadata = FullscreenPage()) {-            VideoEditPage(videoEditViewModel, it.id, it.uri)-        }-    }-}
photos/src/main/java/com/vayunmathur/photos/ui/VideoEditDialogs.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/VideoEditDialogs.kt b/photos/src/main/java/com/vayunmathur/photos/ui/VideoEditDialogs.ktindex 6c05c0962e..6573dd0572 100644--- a/photos/src/main/java/com/vayunmathur/photos/ui/VideoEditDialogs.kt+++ b/photos/src/main/java/com/vayunmathur/photos/ui/VideoEditDialogs.kt@@ -13,25 +13,6 @@ import com.vayunmathur.library.ui.Text import com.vayunmathur.library.ui.TextButton import com.vayunmathur.photos.R -@Composable-internal fun SaveDialog(-    onDismiss: () -> Unit,-    onSaveCopy: () -> Unit,-    onOverwrite: () -> Unit,-) {-    com.vayunmathur.library.ui.AlertDialog(-        onDismissRequest = onDismiss,-        title = { Text(stringResource(R.string.action_save)) },-        text = { Text(stringResource(R.string.video_save_prompt)) },-        confirmButton = {-            TextButton(onClick = onSaveCopy) { Text(stringResource(R.string.action_save_as_copy)) }-        },-        dismissButton = {-            TextButton(onClick = onOverwrite) { Text(stringResource(R.string.video_overwrite)) }-        },-    )-}- @Composable internal fun ExportProgressDialog(progress: Float, onCancel: () -> Unit) {     com.vayunmathur.library.ui.AlertDialog(
photos/src/main/java/com/vayunmathur/photos/ui/VideoEditNavigation.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/VideoEditNavigation.kt b/photos/src/main/java/com/vayunmathur/photos/ui/VideoEditNavigation.ktnew file mode 100644index 0000000000..bd26722d75--- /dev/null+++ b/photos/src/main/java/com/vayunmathur/photos/ui/VideoEditNavigation.kt@@ -0,0 +1,52 @@+package com.vayunmathur.photos.ui++import android.app.Activity+import androidx.annotation.OptIn+import androidx.compose.runtime.Composable+import androidx.compose.runtime.collectAsState+import androidx.compose.runtime.getValue+import androidx.compose.ui.platform.LocalContext+import androidx.media3.common.util.UnstableApi+import com.vayunmathur.library.util.DialogPage+import com.vayunmathur.library.util.FullscreenPage+import com.vayunmathur.library.util.MainNavigation+import com.vayunmathur.library.util.rememberNavBackStack+import com.vayunmathur.photos.platform.VideoEditViewModel+import com.vayunmathur.photos.ui.dialogs.SaveDialog++/** Navigation host for the video editor activity. */+@OptIn(UnstableApi::class)+@Composable+fun VideoEditNavigation(+    videoEditViewModel: VideoEditViewModel,+    photoId: Long,+    photoUri: String?,+) {+    val backStack = rememberNavBackStack<VideoEditRoute>(VideoEditRoute.EditVideo(photoId, photoUri))+    MainNavigation(backStack) {+        entry<VideoEditRoute.EditVideo>(metadata = FullscreenPage()) {+            VideoEditPage(videoEditViewModel, it.id, it.uri, backStack)+        }+        entry<VideoEditRoute.SaveDialog>(metadata = DialogPage()) {+            val context = LocalContext.current+            val activity = context as? Activity+            val photo by videoEditViewModel.photo.collectAsState()+            val currentPhoto = photo+            SaveDialog(+                onDismiss = { backStack.pop() },+                onSaveCopy = {+                    backStack.pop()+                    if (currentPhoto != null) {+                        videoEditViewModel.export(context, currentPhoto, asCopy = true) { activity?.finish() }+                    }+                },+                onOverwrite = {+                    backStack.pop()+                    if (currentPhoto != null) {+                        videoEditViewModel.export(context, currentPhoto, asCopy = false) { activity?.finish() }+                    }+                },+            )+        }+    }+}
photos/src/main/java/com/vayunmathur/photos/ui/VideoEditPage.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/VideoEditPage.kt b/photos/src/main/java/com/vayunmathur/photos/ui/VideoEditPage.ktindex 0933ef9905..0131e4eca5 100644--- a/photos/src/main/java/com/vayunmathur/photos/ui/VideoEditPage.kt+++ b/photos/src/main/java/com/vayunmathur/photos/ui/VideoEditPage.kt@@ -36,7 +36,13 @@ import com.vayunmathur.photos.platform.VideoEditViewModel  @OptIn(UnstableApi::class) @Composable-fun VideoEditPage(vm: VideoEditViewModel, id: Long, uri: String?) {+fun VideoEditPage(+    vm: VideoEditViewModel,+    id: Long,+    uri: String?,+    backStack: com.vayunmathur.library.util.NavBackStack<VideoEditRoute> =+        com.vayunmathur.library.util.NavBackStack(arrayOf(VideoEditRoute.EditVideo(id, uri))),+) {     val context = LocalContext.current     val activity = context as? Activity @@ -61,7 +67,6 @@ fun VideoEditPage(vm: VideoEditViewModel, id: Long, uri: String?) {     }      var selectedTool by remember { mutableStateOf(VideoTool.Trim) }-    var showSaveDialog by remember { mutableStateOf(false) }      val currentPhoto = photo     if (currentPhoto == null) {@@ -76,7 +81,7 @@ fun VideoEditPage(vm: VideoEditViewModel, id: Long, uri: String?) {         title = { Text(stringResource(R.string.title_edit_video), maxLines = 1, overflow = TextOverflow.Ellipsis) },         onNavigateBack = { activity?.finish() },         actions = {-            IconButton(onClick = { showSaveDialog = true }, enabled = !exporting) { IconSave() }+            IconButton(onClick = { backStack.add(VideoEditRoute.SaveDialog) }, enabled = !exporting) { IconSave() }         },     ) { padding ->         Column(@@ -100,20 +105,6 @@ fun VideoEditPage(vm: VideoEditViewModel, id: Long, uri: String?) {         }     } -    if (showSaveDialog) {-        SaveDialog(-            onDismiss = { showSaveDialog = false },-            onSaveCopy = {-                showSaveDialog = false-                vm.export(context, currentPhoto, asCopy = true) { activity?.finish() }-            },-            onOverwrite = {-                showSaveDialog = false-                vm.export(context, currentPhoto, asCopy = false) { activity?.finish() }-            },-        )-    }-     if (exporting) {         ExportProgressDialog(progress = progress, onCancel = { vm.cancelExport() })     }
photos/src/main/java/com/vayunmathur/photos/ui/VideoEditRoute.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/VideoEditRoute.kt b/photos/src/main/java/com/vayunmathur/photos/ui/VideoEditRoute.ktindex 25239f298a..98f849aea3 100644--- a/photos/src/main/java/com/vayunmathur/photos/ui/VideoEditRoute.kt+++ b/photos/src/main/java/com/vayunmathur/photos/ui/VideoEditRoute.kt@@ -9,4 +9,8 @@ sealed interface VideoEditRoute : NavKey {     /** Immutable value describing edit video; carries id, uri. */     @Serializable     data class EditVideo(val id: Long, val uri: String? = null) : VideoEditRoute++    /** Save dialog destination for the video being edited. */+    @Serializable+    data object SaveDialog : VideoEditRoute }
photos/src/main/java/com/vayunmathur/photos/ui/dialogs/AlbumNameDialog.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/dialogs/AlbumNameDialog.kt b/photos/src/main/java/com/vayunmathur/photos/ui/dialogs/AlbumNameDialog.ktnew file mode 100644index 0000000000..9347417cf8--- /dev/null+++ b/photos/src/main/java/com/vayunmathur/photos/ui/dialogs/AlbumNameDialog.kt@@ -0,0 +1,49 @@+package com.vayunmathur.photos.ui.dialogs++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.runtime.setValue+import androidx.compose.ui.Modifier+import androidx.compose.ui.res.stringResource+import com.vayunmathur.library.ui.AlertDialog+import com.vayunmathur.library.ui.OutlinedTextField+import com.vayunmathur.library.ui.Text+import com.vayunmathur.library.ui.TextButton+import com.vayunmathur.photos.R++/** Name entry dialog for creating or renaming an album. */+@Composable+fun AlbumNameDialog(+    titleRes: Int,+    initialValue: String,+    onDismiss: () -> Unit,+    onConfirm: (String) -> Unit,+) {+    var name by remember { mutableStateOf(initialValue) }+    AlertDialog(+        onDismissRequest = onDismiss,+        title = { Text(stringResource(titleRes)) },+        text = {+            OutlinedTextField(+                value = name,+                onValueChange = { name = it },+                label = { Text(stringResource(R.string.album_name_hint)) },+                singleLine = true,+                modifier = Modifier.fillMaxWidth(),+            )+        },+        confirmButton = {+            TextButton(onClick = { onConfirm(name) }, enabled = name.isNotBlank()) {+                Text(stringResource(R.string.album_rename))+            }+        },+        dismissButton = {+            TextButton(onClick = onDismiss) {+                Text(stringResource(R.string.action_cancel))+            }+        },+    )+}
photos/src/main/java/com/vayunmathur/photos/ui/dialogs/AlbumPickerDialog.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/AlbumPickerDialog.kt b/photos/src/main/java/com/vayunmathur/photos/ui/dialogs/AlbumPickerDialog.ktsimilarity index 98%rename from photos/src/main/java/com/vayunmathur/photos/ui/AlbumPickerDialog.ktrename to photos/src/main/java/com/vayunmathur/photos/ui/dialogs/AlbumPickerDialog.ktindex ee47ff44fd..5fa01e6c70 100644--- a/photos/src/main/java/com/vayunmathur/photos/ui/AlbumPickerDialog.kt+++ b/photos/src/main/java/com/vayunmathur/photos/ui/dialogs/AlbumPickerDialog.kt@@ -1,4 +1,4 @@-package com.vayunmathur.photos.ui+package com.vayunmathur.photos.ui.dialogs  import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Column
photos/src/main/java/com/vayunmathur/photos/ui/dialogs/DeleteAlbumDialog.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/dialogs/DeleteAlbumDialog.kt b/photos/src/main/java/com/vayunmathur/photos/ui/dialogs/DeleteAlbumDialog.ktnew file mode 100644index 0000000000..d8808bdd14--- /dev/null+++ b/photos/src/main/java/com/vayunmathur/photos/ui/dialogs/DeleteAlbumDialog.kt@@ -0,0 +1,32 @@+package com.vayunmathur.photos.ui.dialogs++import androidx.compose.runtime.Composable+import androidx.compose.ui.res.stringResource+import com.vayunmathur.library.ui.AlertDialog+import com.vayunmathur.library.ui.Text+import com.vayunmathur.library.ui.TextButton+import com.vayunmathur.photos.R++/** Confirmation dialog for deleting the album named [albumName]. */+@Composable+fun DeleteAlbumDialog(+    albumName: String,+    onDismiss: () -> Unit,+    onConfirm: () -> Unit,+) {+    AlertDialog(+        onDismissRequest = onDismiss,+        title = { Text(stringResource(R.string.album_delete)) },+        text = { Text(stringResource(R.string.album_delete_confirm, albumName)) },+        confirmButton = {+            TextButton(onClick = onConfirm) {+                Text(stringResource(R.string.album_delete))+            }+        },+        dismissButton = {+            TextButton(onClick = onDismiss) {+                Text(stringResource(R.string.action_cancel))+            }+        },+    )+}
photos/src/main/java/com/vayunmathur/photos/ui/dialogs/DeletePersonDialog.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/dialogs/DeletePersonDialog.kt b/photos/src/main/java/com/vayunmathur/photos/ui/dialogs/DeletePersonDialog.ktnew file mode 100644index 0000000000..8382e65f64--- /dev/null+++ b/photos/src/main/java/com/vayunmathur/photos/ui/dialogs/DeletePersonDialog.kt@@ -0,0 +1,39 @@+package com.vayunmathur.photos.ui.dialogs++import androidx.compose.runtime.Composable+import androidx.compose.ui.res.stringResource+import com.vayunmathur.library.ui.AlertDialog+import com.vayunmathur.library.ui.Text+import com.vayunmathur.library.ui.TextButton+import com.vayunmathur.photos.R++/** Confirmation dialog for deleting the person cluster named [personName]. */+@Composable+fun DeletePersonDialog(+    personName: String?,+    onDismiss: () -> Unit,+    onConfirm: () -> Unit,+) {+    AlertDialog(+        onDismissRequest = onDismiss,+        title = { Text(stringResource(R.string.people_delete)) },+        text = {+            Text(+                stringResource(+                    R.string.people_delete_confirm,+                    personName ?: stringResource(R.string.people_unnamed),+                )+            )+        },+        confirmButton = {+            TextButton(onClick = onConfirm) {+                Text(stringResource(R.string.people_delete))+            }+        },+        dismissButton = {+            TextButton(onClick = onDismiss) {+                Text(stringResource(R.string.action_cancel))+            }+        },+    )+}
photos/src/main/java/com/vayunmathur/photos/ui/dialogs/SaveDialog.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/dialogs/SaveDialog.kt b/photos/src/main/java/com/vayunmathur/photos/ui/dialogs/SaveDialog.ktnew file mode 100644index 0000000000..bfa75c843f--- /dev/null+++ b/photos/src/main/java/com/vayunmathur/photos/ui/dialogs/SaveDialog.kt@@ -0,0 +1,28 @@+package com.vayunmathur.photos.ui.dialogs++import androidx.compose.runtime.Composable+import androidx.compose.ui.res.stringResource+import com.vayunmathur.library.ui.AlertDialog+import com.vayunmathur.library.ui.Text+import com.vayunmathur.library.ui.TextButton+import com.vayunmathur.photos.R++/** Save dialog for the video editor: save a copy or overwrite the original. */+@Composable+fun SaveDialog(+    onDismiss: () -> Unit,+    onSaveCopy: () -> Unit,+    onOverwrite: () -> Unit,+) {+    AlertDialog(+        onDismissRequest = onDismiss,+        title = { Text(stringResource(R.string.action_save)) },+        text = { Text(stringResource(R.string.video_save_prompt)) },+        confirmButton = {+            TextButton(onClick = onSaveCopy) { Text(stringResource(R.string.action_save_as_copy)) }+        },+        dismissButton = {+            TextButton(onClick = onOverwrite) { Text(stringResource(R.string.video_overwrite)) }+        },+    )+}
photos/src/main/java/com/vayunmathur/photos/ui/dialogs/SecureFolderRelockDialog.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/dialogs/SecureFolderRelockDialog.kt b/photos/src/main/java/com/vayunmathur/photos/ui/dialogs/SecureFolderRelockDialog.ktnew file mode 100644index 0000000000..dab27a726d--- /dev/null+++ b/photos/src/main/java/com/vayunmathur/photos/ui/dialogs/SecureFolderRelockDialog.kt@@ -0,0 +1,51 @@+package com.vayunmathur.photos.ui.dialogs++import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.Row+import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.runtime.Composable+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.res.stringResource+import com.vayunmathur.library.ui.AlertDialog+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.Switch+import com.vayunmathur.library.ui.Text+import com.vayunmathur.library.ui.TextButton+import com.vayunmathur.library.ui.R as UiR+import com.vayunmathur.photos.R++/** Relock-on-exit settings dialog for the secure folder. */+@Composable+fun SecureFolderRelockDialog(+    relockOnExit: Boolean,+    onCheckedChange: (Boolean) -> Unit,+    onDismiss: () -> Unit,+) {+    AlertDialog(+        onDismissRequest = onDismiss,+        title = { Text(stringResource(R.string.secure_folder_relock_title)) },+        text = {+            Column(modifier = Modifier.fillMaxWidth()) {+                Row(+                    modifier = Modifier.fillMaxWidth(),+                    horizontalArrangement = Arrangement.SpaceBetween,+                    verticalAlignment = Alignment.CenterVertically,+                ) {+                    Text(stringResource(R.string.secure_folder_relock_label))+                    Switch(checked = relockOnExit, onCheckedChange = onCheckedChange)+                }+                Text(+                    stringResource(R.string.secure_folder_relock_description),+                    style = MaterialTheme.typography.bodySmall,+                )+            }+        },+        confirmButton = {+            TextButton(onClick = onDismiss) {+                Text(stringResource(UiR.string.done))+            }+        },+    )+}
photos/src/screenshotTest/kotlin/com/vayunmathur/photos/ui/MetadataPreviews.kt
diff --git a/photos/src/screenshotTest/kotlin/com/vayunmathur/photos/ui/MetadataPreviews.kt b/photos/src/screenshotTest/kotlin/com/vayunmathur/photos/ui/MetadataPreviews.ktindex 1233fa79c1..30508a2c87 100644--- a/photos/src/screenshotTest/kotlin/com/vayunmathur/photos/ui/MetadataPreviews.kt+++ b/photos/src/screenshotTest/kotlin/com/vayunmathur/photos/ui/MetadataPreviews.kt@@ -28,6 +28,12 @@ import com.vayunmathur.photos.platform.GalleryActions import com.vayunmathur.photos.platform.GalleryUiState import com.vayunmathur.photos.platform.PeopleUiState import com.vayunmathur.photos.platform.PersonCluster+import com.vayunmathur.photos.platform.WallpaperLoadState+import com.vayunmathur.photos.ui.dialogs.AlbumNameDialog+import com.vayunmathur.photos.ui.dialogs.AlbumPickerDialog+import com.vayunmathur.photos.ui.dialogs.DeleteAlbumDialog+import com.vayunmathur.photos.ui.dialogs.DeletePersonDialog+import com.vayunmathur.photos.ui.dialogs.SecureFolderRelockDialog  /** Phone-shaped, roughly 1080x2340 at xxhdpi — comfortably above the F-Droid minimum. */ private const val PHONE = "spec:width=411dp,height=891dp,dpi=420"@@ -62,14 +68,13 @@ private const val EXPANDED = "spec:width=1280dp,height=800dp,dpi=420"  * is nothing for Layoutlib to draw.  *  * Coverage: `Gallery`, `People`, `Albums`, `AlbumDetail` and `Favorites` on phone,- * plus the wide viewer layout on large-tablet.- * Exceptions: `Map` is a MapLibre GL surface (above). `PhotoPage` (viewer),- * `Trash`, `SecureFolder`/`VaultViewer`, `Wallpaper` and the photo/video editors- * have no placeholder seam at the page level — they need a decoded MediaStore- * bitmap/pager, MediaStore trash intents, a decrypted vault file behind- * biometrics, WallpaperManager/WindowManager, or a native-ML editor canvas /- * video surface, none of which Layoutlib can supply. The wide layout above is- * the renderable wide form of the viewer.+ * plus the wide viewer layout on large-tablet; `PhotoPage` as the wide viewer+ * layout, `Trash`, `VaultViewer`, `Wallpaper` (failed-load slice) and the five+ * dialog routes on phone.+ * Exceptions: `Map` is a MapLibre GL surface and `SecureFolder` is a+ * biometric/Keystore-gated decrypted vault grid; both are exempted in Route.kt.+ * The photo/video editors need a native-ML editor canvas / video surface,+ * none of which Layoutlib can supply.  */ class MetadataPreviews { @@ -188,6 +193,138 @@ class MetadataPreviews {             )         }     }++    @PreviewTest+    @Preview(name = "9-photo-page", device = EXPANDED, group = "large-tablet", showSystemUi = true)+    @Composable+    fun Preview9PhotoPage() {+        DynamicTheme(darkTheme = true) {+            PhotoViewerWideLayout(+                viewer = { GalleryPreview(GalleryUiState(photos = samplePhotos())) },+                filmstrip = { GalleryPreview(GalleryUiState(photos = samplePhotos().take(4))) },+            )+        }+    }++    @PreviewTest+    @Preview(name = "10-trash", device = PHONE, group = "phone", showSystemUi = true)+    @Composable+    fun Preview10Trash() {+        DynamicTheme(darkTheme = true) {+            CompositionLocalProvider(LocalColumnCount provides remember { mutableFloatStateOf(3f) }) {+                TrashScreen(+                    backStack = NavBackStack(arrayOf<Route>(Route.Trash)),+                    photos = samplePhotos().take(6),+                    selectedIds = emptyList(),+                    thumbnail = { photo, modifier -> PlaceholderTile(photo, modifier) },+                )+            }+        }+    }++    @PreviewTest+    @Preview(name = "11-vault-viewer", device = PHONE, group = "phone", showSystemUi = true)+    @Composable+    fun Preview11VaultViewer() {+        DynamicTheme(darkTheme = true) {+            VaultViewerScreen(+                fileName = "IMG_20250715_121804.jpg",+                file = null,+                isVideo = false,+                onBack = {},+            )+        }+    }++    @PreviewTest+    @Preview(name = "12-wallpaper", device = PHONE, group = "phone", showSystemUi = true)+    @Composable+    fun Preview12Wallpaper() {+        DynamicTheme(darkTheme = true) {+            androidx.compose.foundation.layout.Column(+                Modifier.background(Color.Black),+            ) {+                WallpaperPreview(+                    bitmap = null,+                    loadState = WallpaperLoadState.Failed,+                    targetAspect = 9f / 16f,+                    zoomScale = 1f,+                    zoomOffset = androidx.compose.ui.geometry.Offset.Zero,+                    currentScale = remember { mutableFloatStateOf(1f) },+                    currentOffset = remember {+                        androidx.compose.runtime.mutableStateOf(androidx.compose.ui.geometry.Offset.Zero)+                    },+                    onZoomChange = { _, _ -> },+                    onCoverMin = {},+                    onSnapshot = {},+                    modifier = Modifier.weight(1f),+                )+                WallpaperControls(+                    which = android.app.WallpaperManager.FLAG_SYSTEM,+                    onWhichChange = {},+                    isScrollable = false,+                    onScrollableChange = {},+                    canSet = false,+                    isSetting = false,+                    onSetWallpaper = {},+                )+            }+        }+    }++    @PreviewTest+    @Preview(name = "13-rename-album-dialog", device = PHONE, group = "phone")+    @Composable+    fun Preview13RenameAlbumDialog() {+        DynamicTheme(darkTheme = true) {+            AlbumNameDialog(+                titleRes = com.vayunmathur.photos.R.string.album_rename,+                initialValue = "Trip",+                onDismiss = {},+                onConfirm = {},+            )+        }+    }++    @PreviewTest+    @Preview(name = "14-delete-album-dialog", device = PHONE, group = "phone")+    @Composable+    fun Preview14DeleteAlbumDialog() {+        DynamicTheme(darkTheme = true) {+            DeleteAlbumDialog(albumName = "Trip", onDismiss = {}, onConfirm = {})+        }+    }++    @PreviewTest+    @Preview(name = "15-album-picker-dialog", device = PHONE, group = "phone")+    @Composable+    fun Preview15AlbumPickerDialog() {+        DynamicTheme(darkTheme = true) {+            AlbumPickerDialog(+                existingAlbums = listOf("Camera", "Trip"),+                onDismiss = {},+                onConfirm = {},+            )+        }+    }++    @PreviewTest+    @Preview(name = "16-delete-person-dialog", device = PHONE, group = "phone")+    @Composable+    fun Preview16DeletePersonDialog() {+        DynamicTheme(darkTheme = true) {+            DeletePersonDialog(personName = "Ana Ruiz", onDismiss = {}, onConfirm = {})+        }+    }++    @PreviewTest+    @Preview(name = "17-secure-folder-relock-dialog", device = PHONE, group = "phone")+    @Composable+    fun Preview17SecureFolderRelockDialog() {+        DynamicTheme(darkTheme = true) {+            SecureFolderRelockDialog(relockOnExit = true, onCheckedChange = {}, onDismiss = {})+        }+    } }  /**@@ -206,6 +343,138 @@ private fun GalleryPreview(state: GalleryUiState) {             )         }     }++    @PreviewTest+    @Preview(name = "9-photo-page", device = EXPANDED, group = "large-tablet", showSystemUi = true)+    @Composable+    fun Preview9PhotoPage() {+        DynamicTheme(darkTheme = true) {+            PhotoViewerWideLayout(+                viewer = { GalleryPreview(GalleryUiState(photos = samplePhotos())) },+                filmstrip = { GalleryPreview(GalleryUiState(photos = samplePhotos().take(4))) },+            )+        }+    }++    @PreviewTest+    @Preview(name = "10-trash", device = PHONE, group = "phone", showSystemUi = true)+    @Composable+    fun Preview10Trash() {+        DynamicTheme(darkTheme = true) {+            CompositionLocalProvider(LocalColumnCount provides remember { mutableFloatStateOf(3f) }) {+                TrashScreen(+                    backStack = NavBackStack(arrayOf<Route>(Route.Trash)),+                    photos = samplePhotos().take(6),+                    selectedIds = emptyList(),+                    thumbnail = { photo, modifier -> PlaceholderTile(photo, modifier) },+                )+            }+        }+    }++    @PreviewTest+    @Preview(name = "11-vault-viewer", device = PHONE, group = "phone", showSystemUi = true)+    @Composable+    fun Preview11VaultViewer() {+        DynamicTheme(darkTheme = true) {+            VaultViewerScreen(+                fileName = "IMG_20250715_121804.jpg",+                file = null,+                isVideo = false,+                onBack = {},+            )+        }+    }++    @PreviewTest+    @Preview(name = "12-wallpaper", device = PHONE, group = "phone", showSystemUi = true)+    @Composable+    fun Preview12Wallpaper() {+        DynamicTheme(darkTheme = true) {+            androidx.compose.foundation.layout.Column(+                Modifier.background(Color.Black),+            ) {+                WallpaperPreview(+                    bitmap = null,+                    loadState = WallpaperLoadState.Failed,+                    targetAspect = 9f / 16f,+                    zoomScale = 1f,+                    zoomOffset = androidx.compose.ui.geometry.Offset.Zero,+                    currentScale = remember { mutableFloatStateOf(1f) },+                    currentOffset = remember {+                        androidx.compose.runtime.mutableStateOf(androidx.compose.ui.geometry.Offset.Zero)+                    },+                    onZoomChange = { _, _ -> },+                    onCoverMin = {},+                    onSnapshot = {},+                    modifier = Modifier.weight(1f),+                )+                WallpaperControls(+                    which = android.app.WallpaperManager.FLAG_SYSTEM,+                    onWhichChange = {},+                    isScrollable = false,+                    onScrollableChange = {},+                    canSet = false,+                    isSetting = false,+                    onSetWallpaper = {},+                )+            }+        }+    }++    @PreviewTest+    @Preview(name = "13-rename-album-dialog", device = PHONE, group = "phone")+    @Composable+    fun Preview13RenameAlbumDialog() {+        DynamicTheme(darkTheme = true) {+            AlbumNameDialog(+                titleRes = com.vayunmathur.photos.R.string.album_rename,+                initialValue = "Trip",+                onDismiss = {},+                onConfirm = {},+            )+        }+    }++    @PreviewTest+    @Preview(name = "14-delete-album-dialog", device = PHONE, group = "phone")+    @Composable+    fun Preview14DeleteAlbumDialog() {+        DynamicTheme(darkTheme = true) {+            DeleteAlbumDialog(albumName = "Trip", onDismiss = {}, onConfirm = {})+        }+    }++    @PreviewTest+    @Preview(name = "15-album-picker-dialog", device = PHONE, group = "phone")+    @Composable+    fun Preview15AlbumPickerDialog() {+        DynamicTheme(darkTheme = true) {+            AlbumPickerDialog(+                existingAlbums = listOf("Camera", "Trip"),+                onDismiss = {},+                onConfirm = {},+            )+        }+    }++    @PreviewTest+    @Preview(name = "16-delete-person-dialog", device = PHONE, group = "phone")+    @Composable+    fun Preview16DeletePersonDialog() {+        DynamicTheme(darkTheme = true) {+            DeletePersonDialog(personName = "Ana Ruiz", onDismiss = {}, onConfirm = {})+        }+    }++    @PreviewTest+    @Preview(name = "17-secure-folder-relock-dialog", device = PHONE, group = "phone")+    @Composable+    fun Preview17SecureFolderRelockDialog() {+        DynamicTheme(darkTheme = true) {+            SecureFolderRelockDialog(relockOnExit = true, onCheckedChange = {}, onDismiss = {})+        }+    } }  /** Stand-in for a decoded thumbnail, picked from a fixed palette so runs are identical. */
photos/src/test/java/com/vayunmathur/photos/photoslice2/Slice2Pass2PanelsTest.kt
diff --git a/photos/src/test/java/com/vayunmathur/photos/photoslice2/Slice2Pass2PanelsTest.kt b/photos/src/test/java/com/vayunmathur/photos/photoslice2/Slice2Pass2PanelsTest.ktindex dae49207f5..a5ea130fc4 100644--- a/photos/src/test/java/com/vayunmathur/photos/photoslice2/Slice2Pass2PanelsTest.kt+++ b/photos/src/test/java/com/vayunmathur/photos/photoslice2/Slice2Pass2PanelsTest.kt@@ -67,7 +67,7 @@ import com.vayunmathur.photos.ui.PaintPanel import com.vayunmathur.photos.ui.PhotoFilterPanel import com.vayunmathur.photos.ui.PolygonOverlay import com.vayunmathur.photos.ui.PosterizePanel-import com.vayunmathur.photos.ui.SaveDialog+import com.vayunmathur.photos.ui.dialogs.SaveDialog import com.vayunmathur.photos.ui.SelectionMaskOverlay import com.vayunmathur.photos.ui.SelectionOverlay import com.vayunmathur.photos.ui.SelectionPanel
photos/src/test/java/com/vayunmathur/photos/ui/AlbumDetailAndPickerTest.kt
diff --git a/photos/src/test/java/com/vayunmathur/photos/ui/AlbumDetailAndPickerTest.kt b/photos/src/test/java/com/vayunmathur/photos/ui/AlbumDetailAndPickerTest.ktindex 1c61c30b82..4d0a0eb2d4 100644--- a/photos/src/test/java/com/vayunmathur/photos/ui/AlbumDetailAndPickerTest.kt+++ b/photos/src/test/java/com/vayunmathur/photos/ui/AlbumDetailAndPickerTest.kt@@ -1,4 +1,5 @@ package com.vayunmathur.photos.ui+import com.vayunmathur.photos.ui.dialogs.AlbumPickerDialog import com.vayunmathur.photos.platform.Album  import android.app.Application
photos/src/test/java/com/vayunmathur/photos/ui/DialogsAndViewerActionsTest.kt
diff --git a/photos/src/test/java/com/vayunmathur/photos/ui/DialogsAndViewerActionsTest.kt b/photos/src/test/java/com/vayunmathur/photos/ui/DialogsAndViewerActionsTest.ktindex 4392452230..9c703245bf 100644--- a/photos/src/test/java/com/vayunmathur/photos/ui/DialogsAndViewerActionsTest.kt+++ b/photos/src/test/java/com/vayunmathur/photos/ui/DialogsAndViewerActionsTest.kt@@ -1,4 +1,5 @@ package com.vayunmathur.photos.ui+import com.vayunmathur.photos.ui.dialogs.SaveDialog  import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.size
photos/src/test/java/com/vayunmathur/photos/util/PhotosSlice3ScreensTest.kt
diff --git a/photos/src/test/java/com/vayunmathur/photos/util/PhotosSlice3ScreensTest.kt b/photos/src/test/java/com/vayunmathur/photos/util/PhotosSlice3ScreensTest.ktindex df267d0c8c..b84cd3b772 100644--- a/photos/src/test/java/com/vayunmathur/photos/util/PhotosSlice3ScreensTest.kt+++ b/photos/src/test/java/com/vayunmathur/photos/util/PhotosSlice3ScreensTest.kt@@ -37,7 +37,7 @@ import com.vayunmathur.photos.R import com.vayunmathur.photos.Route import com.vayunmathur.photos.data.Photo import com.vayunmathur.photos.ui.AlbumDetailScreen-import com.vayunmathur.photos.ui.AlbumPickerDialog+import com.vayunmathur.photos.ui.dialogs.AlbumPickerDialog import com.vayunmathur.photos.ui.AlbumsScreen import com.vayunmathur.photos.ui.GalleryScreen import com.vayunmathur.photos.ui.PeopleScreen@@ -173,14 +173,11 @@ class PhotosSlice3ScreensTest {      @Test     fun gallerySelectionAlbumButtonOpensPicker() {-        val actions = object : GalleryActions {-            override fun addSelectionToAlbum(name: String) {}-        }-        setGallery(GalleryUiState(selectedIds = setOf(5L)), actions)+        val stack = backStack()+        setGallery(GalleryUiState(selectedIds = setOf(5L)), GalleryActions.Noop, stack)         composeRule.onNodeWithContentDescription("Album").performClick()-        // Picker dialog renders the new-album field and create button.-        composeRule.onNodeWithText(str(R.string.album_name_hint)).assertIsDisplayed()-        composeRule.onNodeWithText(str(R.string.album_create)).assertIsDisplayed()+        // Add-to-album is a dialog route.+        assertEquals(Route.AlbumPickerDialog, stack.backStack.last())     }      @Test@@ -456,8 +453,6 @@ class PhotosSlice3ScreensTest {         selectedIds: Set<Long> = emptySet(),         onSetCover: (Long) -> Unit = {},         onRemoveFromAlbum: () -> Unit = {},-        onRenameAlbum: (String) -> Unit = {},-        onDeleteAlbum: () -> Unit = {},     ) {         val columns = mutableFloatStateOf(3f)         composeRule.setContent {@@ -469,8 +464,6 @@ class PhotosSlice3ScreensTest {                     selectedIds = selectedIds,                     onRemoveFromAlbum = onRemoveFromAlbum,                     onSetCover = onSetCover,-                    onRenameAlbum = onRenameAlbum,-                    onDeleteAlbum = onDeleteAlbum,                     thumbnail = stubThumbnail(),                 )             }@@ -500,19 +493,13 @@ class PhotosSlice3ScreensTest {      @Test     fun albumDetailMenuRenamesAlbum() {-        var renamed: String? = null         val a = photo("a", 100L, "Trip")-        setAlbumDetail("Trip", album("Trip", a), onRenameAlbum = { renamed = it })+        val stack = backStack()+        setAlbumDetail("Trip", album("Trip", a), stack = stack)         composeRule.onNodeWithContentDescription("More").performClick()-        // Menu item and dialog confirm button share the Rename label; the dialog-        // text field starts with the current name, so replace it wholesale.         composeRule.onNodeWithText(str(R.string.album_rename)).performClick()-        // Two nodes hold "Trip": the app-bar title and the dialog's text field-        // (dialog content traverses after the screen). The field is the editable one.-        composeRule.onAllNodesWithText("Trip")[1].performTextClearance()-        composeRule.onAllNodesWithText("", useUnmergedTree = true)[0].performTextInput("Holiday")-        composeRule.onAllNodesWithText(str(R.string.album_rename))[1].performClick()-        assertEquals("Holiday", renamed)+        // Rename is a dialog route carrying the album name.+        assertEquals(Route.RenameAlbumDialog("Trip"), stack.backStack.last())     }      // ---- AlbumPickerDialog ----@@ -553,15 +540,13 @@ class PhotosSlice3ScreensTest {      @Test     fun albumDetailDeleteFlowConfirms() {-        var deleted = false         val a = photo("del-a", 100L, "Trip")-        setAlbumDetail("Trip", album("Trip", a), onDeleteAlbum = { deleted = true })+        val stack = backStack()+        setAlbumDetail("Trip", album("Trip", a), stack = stack)         composeRule.onNodeWithContentDescription("More").performClick()         composeRule.onNodeWithText(str(R.string.album_delete)).performClick()-        // Confirm dialog appears; confirming fires the callback.-        composeRule.onNodeWithText(str(R.string.album_delete_confirm, "Trip")).assertIsDisplayed()-        composeRule.onAllNodesWithText(str(R.string.album_delete))[1].performClick()-        assertEquals(true, deleted)+        // Delete is a dialog route carrying the album name.+        assertEquals(Route.DeleteAlbumDialog("Trip"), stack.backStack.last())     }      @Test