Modern Apps git

← Modern-Apps.git

office: make dialog routes and screenshot coverage lint-clean

Commit
b08395713aaebb9bec1a229cf1f95231911e3446
Author
Vayun Mathur <[email protected]>
When
2026-12-02 03:46 UTC (4 days ago)
Parents
e707d12
Convert the three locally gated dialogs into Route destinations with
DialogPage() metadata, their arguments in the route, and stateless
contents under ui/dialogs/ hosted by OfficeDialogEntries: the online
document delete/remove confirmation (DeleteOnlineDocumentDialog, pushed
from OnlineDocCard through the threaded back stack), the go-to-slide
picker and the full-screen slideshow (GoToSlideDialog/SlideshowDialog,
pushed from PresentationView through the back stack threaded via
DocumentScreen, its shells, the scaffold body and OfficeDocumentPane).
Slide choices return through the nav result registry, which
PresentationView observes. The old ui/GoToSlideDialog file is removed;
compose tests host the dialog contents directly.

Give every route a deterministic screenshot capture: rename the home
and editor previews to their route keys (offline-home, online-home,
offline-editor variants) and add online-editor plus
delete-online-document-dialog, go-to-slide-dialog and slideshow-dialog
previews rendering the stateless contents from fixed literals.

The editor find bar is an expandable find-in-document overlay whose
match/replace controls have no scaffold search host, so
OfficeDocumentFindBars carries the scaffold-search exception marker
(recorded in docs/structure/exceptions.tsv). office/AGENTS.md is
updated for the new routes, dialog files and entries.

Verified: ./gradlew :office:lint :office:lintVitalRelease
:office:testDevUnitTest :office:compileDevScreenshotTestKotlin all pass.

Diff

docs/structure/exceptions.tsv
diff --git a/docs/structure/exceptions.tsv b/docs/structure/exceptions.tsvindex 38b0fea6aa..495d3b2810 100644--- a/docs/structure/exceptions.tsv+++ b/docs/structure/exceptions.tsv@@ -35,6 +35,7 @@ SCAFFOLD_SEARCH	launcher/src/main/java/com/vayunmathur/launcher/ui/WidgetPickerC SCAFFOLD_SEARCH	launcher/src/test/java/com/vayunmathur/launcher/ui/LauncherDrawerUiTest.kt	(malformed: no colon prefix)	1 SCAFFOLD_SEARCH	library/ui/src/main/java/com/vayunmathur/library/ui/AppScaffold.kt	<reason>` marker.	1 SCAFFOLD_SEARCH	library/ui/src/main/java/com/vayunmathur/library/ui/CommonSearchBar.kt	<reason>` marker (sheet/drawer-local pickers).	1+SCAFFOLD_SEARCH	office/src/main/java/com/vayunmathur/office/ui/OfficeDocumentFindBars.kt	expandable find-in-document bar in the editor; its match/replace controls and document-list results surface have no scaffold search host	1 SCAFFOLD_SEARCH	photos/src/main/java/com/vayunmathur/photos/ui/GalleryScreen.kt	expandable SearchBar supplied as the AppScaffold topBar; its expanded overlay is the search-results photo grid	1 SCAFFOLD_SEARCH	taxi/src/main/java/com/vayunmathur/taxi/ui/RideInputs.kt	inline two-field origin/destination pair on the Ride booking screen (Route.Ride SiblingPage, not a DialogPage); ScaffoldSearch is a single top-bar field and cannot host both pickup and destination fields sharing one active-field suggestion list	1 SCAFFOLD_SEARCH	weather/src/main/java/com/vayunmathur/weather/ui/SearchLocationPage.kt	dialog-local location search inside a DialogPage route's Surface; no scaffold host	1
office/AGENTS.md
diff --git a/office/AGENTS.md b/office/AGENTS.mdindex 47b52a723f..908ee5a1b2 100644--- a/office/AGENTS.md+++ b/office/AGENTS.md@@ -5,7 +5,7 @@ _Install: ./install office (dev by default)._ - Gradle: :office / dir: office/ - Package roots present: ui-- Entry files: MainActivity.kt (no Route.kt — `OfficeRoute` is inline)+- Entry files: MainActivity.kt, Route.kt (`Route` sealed interface), Navigation.kt - Deps: :library:network, :library:e2ee-p2p - Metadata: metadata_data/office.md (present) - Rust: yes / screenshotTest: yes@@ -21,7 +21,7 @@ Host: `api.maproj.org` (Cloudflare FIRST_PARTY pins). Server checkout: `../locat - Native Rust formula engine + document CRDT (`OfficeNative`); online collaboration is E2EE with no accounts — the relay only forwards ciphertext - Opens files shared from other apps or `office://join` collaboration links **Architecture / data-flow:** Root-level document chrome + `ui/` type-specific views over the `util/OfficeViewModel*` family (split per surface: documents, text, sheet, slides, tables, sync A/B/C, export) backed by `:library:ui`'s `OdfDocument` model; sync goes through `util/OfficeSync` + `util/DocumentTreeCrdt` to the E2EE relay. `onCreateBeforeContent`: `NetworkClient.init(FIRST_PARTY)` → load settings → split join-links from document URIs; `Content()` roots the `OfficeRoute` (`OfflineHome` / `OnlineHome` / `OfflineEditor` / `OnlineEditor`) graph and fires `initSync`.-**Entry points + reading order:** `OfficeRoute` (`OfflineHome` / `OnlineHome` / `OfflineEditor(uri)` / `OnlineEditor(docId)`, inline) → `MainActivity.kt` (`OfficeRoot`, `OfficeNavGraph`) → `OfficeDocumentPane.kt` → `util/OfficeViewModel.kt` → `odf/DocumentImporter.kt`.+**Entry points + reading order:** `Route` in Route.kt (`OfflineHome` / `OnlineHome` / `OfflineEditor(uri)` / `OnlineEditor(docId)` plus the `DeleteOnlineDocumentDialog`, `GoToSlideDialog` and `SlideshowDialog` dialog routes) → `MainActivity.kt` → `Navigation.kt` (`OfficeTabs` + `officeDialogEntries`) → `OfficeDocumentPane.kt`. **Gotchas:** - Display names must come from `OpenableColumns.DISPLAY_NAME`, not the URI path — `DocumentImporter` routes by extension and content URIs often have extensionless ids - The document "paper" stays light in dark mode by design (`OfficeLightTheme`); dark mode inverts luminance via a color matrix, never the model colors@@ -43,6 +43,8 @@ Host: `api.maproj.org` (Cloudflare FIRST_PARTY pins). Server checkout: `../locat - com/vayunmathur/office/OfficeDocumentFindBars.kt - com/vayunmathur/office/OfficeHomeScreens.kt - com/vayunmathur/office/OfficeOnlineScreens.kt+- com/vayunmathur/office/Route.kt — `Route` destinations incl. dialog routes+- com/vayunmathur/office/ui/OfficeDialogEntries.kt — DialogPage entries for the dialog routes (delete-online-document, go-to-slide, slideshow; slide results via the nav result registry) - com/vayunmathur/office/OfficeEnableOnlineDialog.kt - com/vayunmathur/office/OfficeOutlinePane.kt - com/vayunmathur/office/OfficeExportMenu.kt@@ -102,13 +104,15 @@ Host: `api.maproj.org` (Cloudflare FIRST_PARTY pins). Server checkout: `../locat - com/vayunmathur/office/ui/ColorPickerDialog.kt - com/vayunmathur/office/ui/FontSizePickerDialog.kt - com/vayunmathur/office/ui/FootnoteDialog.kt-- com/vayunmathur/office/ui/GoToSlideDialog.kt - com/vayunmathur/office/ui/HeaderFooterDialog.kt - com/vayunmathur/office/ui/InsertHyperlinkDialog.kt - com/vayunmathur/office/ui/InsertTableDialog.kt - com/vayunmathur/office/ui/SortDialog.kt - com/vayunmathur/office/ui/SpecialCharsDialog.kt - com/vayunmathur/office/ui/SettingsDialog.kt+- com/vayunmathur/office/ui/dialogs/DeleteOnlineDocumentDialogContent.kt — stateless delete/remove confirmation hosted by the `DeleteOnlineDocumentDialog` route+- com/vayunmathur/office/ui/dialogs/GoToSlideDialogContent.kt — stateless go-to-slide picker hosted by the `GoToSlideDialog` route+- com/vayunmathur/office/ui/dialogs/SlideshowDialogContent.kt — stateless slideshow hosted by the `SlideshowDialog` route ### util/ — ViewModels, sync, CRDT, native bridge - com/vayunmathur/office/util/OfficeViewModel.kt - com/vayunmathur/office/util/OfficeViewModelDocuments.kt
office/src/main/java/com/vayunmathur/office/Navigation.kt
diff --git a/office/src/main/java/com/vayunmathur/office/Navigation.kt b/office/src/main/java/com/vayunmathur/office/Navigation.ktindex 9bf8179923..e181e58ecb 100644--- a/office/src/main/java/com/vayunmathur/office/Navigation.kt+++ b/office/src/main/java/com/vayunmathur/office/Navigation.kt@@ -65,6 +65,7 @@ fun Navigation(viewModel: OfficeViewModel, activity: MainActivity, intentUri: Ur             when (val s = state) {                 is OfficeViewModel.ViewState.Loaded -> DocumentScreen(                     document = s.document, viewModel = viewModel, activity = activity,+                    backStack = backStack,                     onBack = { leaveEditor() },                     // When an offline doc is shared it becomes a cloud doc — switch its route.                     onBecameOnline = { id -> backStack.setLast(Route.OnlineEditor(id)) }
office/src/main/java/com/vayunmathur/office/Route.kt
diff --git a/office/src/main/java/com/vayunmathur/office/Route.kt b/office/src/main/java/com/vayunmathur/office/Route.ktindex af2f8135e9..6b247804ed 100644--- a/office/src/main/java/com/vayunmathur/office/Route.kt+++ b/office/src/main/java/com/vayunmathur/office/Route.kt@@ -14,4 +14,27 @@ sealed interface Route : NavKey {     @Serializable data class OfflineEditor(val uri: String? = null) : Route     /** Editing a cloud-synced document, identified by its document id. */     @Serializable data class OnlineEditor(val docId: String) : Route++    /**+     * Delete/remove confirmation for one online document. The document it+     * acts on ([docId], its [title] and whether the user [owner]s it)+     * travels in the route, never as pending state in the online list.+     */+    @Serializable data class DeleteOnlineDocumentDialog(+        val docId: String,+        val title: String,+        val owner: Boolean,+    ) : Route++    /**+     * Go-to-slide picker for the presentation editor. [total] is the slide+     * count; the chosen index returns through the nav result registry.+     */+    @Serializable data class GoToSlideDialog(val total: Int) : Route++    /**+     * Full-screen slideshow for the presentation editor, starting at+     * [startIndex]; the final index returns through the nav result registry.+     */+    @Serializable data class SlideshowDialog(val startIndex: Int) : Route }
office/src/main/java/com/vayunmathur/office/ui/DocumentScaffoldBody.kt
diff --git a/office/src/main/java/com/vayunmathur/office/ui/DocumentScaffoldBody.kt b/office/src/main/java/com/vayunmathur/office/ui/DocumentScaffoldBody.ktindex d1691ef5bd..25501f2090 100644--- a/office/src/main/java/com/vayunmathur/office/ui/DocumentScaffoldBody.kt+++ b/office/src/main/java/com/vayunmathur/office/ui/DocumentScaffoldBody.kt@@ -42,7 +42,9 @@ import com.vayunmathur.office.platform.OfficeViewModel import com.vayunmathur.office.platform.needsSaveAs import com.vayunmathur.office.platform.save import kotlinx.coroutines.CoroutineScope+import com.vayunmathur.library.util.NavBackStack import com.vayunmathur.office.MainActivity+import com.vayunmathur.office.Route import com.vayunmathur.office.Navigation import com.vayunmathur.office.R @@ -64,6 +66,7 @@ internal fun DocumentScaffoldBody(     onCellSelected: (Int, Int, Int) -> Unit,     onSlideChange: (Int) -> Unit,     onSlideElementSelected: (Int, Int) -> Unit,+    backStack: NavBackStack<Route>? = null,     modifier: Modifier = Modifier,     bodyFocusRequester: FocusRequester? = null,     onBodyFocusChanged: (Boolean) -> Unit = {},@@ -87,6 +90,7 @@ internal fun DocumentScaffoldBody(             onCellSelected = onCellSelected,             onSlideChange = onSlideChange,             onSlideElementSelected = onSlideElementSelected,+            backStack = backStack,             modifier = modifier,             bodyFocusRequester = bodyFocusRequester,             onBodyFocusChanged = onBodyFocusChanged,@@ -157,6 +161,7 @@ internal fun DocumentEditorPane(     onCellSelected: (Int, Int, Int) -> Unit,     onSlideChange: (Int) -> Unit,     onSlideElementSelected: (Int, Int) -> Unit,+    backStack: NavBackStack<Route>? = null,     modifier: Modifier = Modifier,     bodyFocusRequester: FocusRequester? = null,     onBodyFocusChanged: (Boolean) -> Unit = {},@@ -179,6 +184,7 @@ internal fun DocumentEditorPane(                         listState = listState, onRunSelectionChange = onRunSelectionChange,                         onCellFocus = onCellFocus, onCellSelected = onCellSelected,                         onSlideChange = onSlideChange, onSlideElementSelected = onSlideElementSelected,+                        backStack = backStack,                         modifier = Modifier.fillMaxSize(),                         bodyFocusRequester = bodyFocusRequester,                         onBodyFocusChanged = onBodyFocusChanged)@@ -190,6 +196,7 @@ internal fun DocumentEditorPane(                 listState = listState, onRunSelectionChange = onRunSelectionChange,                 onCellFocus = onCellFocus, onCellSelected = onCellSelected,                 onSlideChange = onSlideChange, onSlideElementSelected = onSlideElementSelected,+                backStack = backStack,                 modifier = Modifier.fillMaxSize(),                 bodyFocusRequester = bodyFocusRequester,                 onBodyFocusChanged = onBodyFocusChanged)@@ -210,6 +217,7 @@ internal fun EditorDocumentPane(     onCellSelected: (Int, Int, Int) -> Unit,     onSlideChange: (Int) -> Unit,     onSlideElementSelected: (Int, Int) -> Unit,+    backStack: NavBackStack<Route>? = null,     modifier: Modifier = Modifier,     bodyFocusRequester: FocusRequester? = null,     onBodyFocusChanged: (Boolean) -> Unit = {},@@ -234,6 +242,7 @@ internal fun EditorDocumentPane(         onCropImage = { bi -> s.cropImageBlock = bi },         onCropSlide = { si, e -> s.cropSlideTarget = si to e },         onCropSheet = { si, e -> s.cropSheetTarget = si to e },+        backStack = backStack,         modifier = modifier,         bodyFocusRequester = bodyFocusRequester,         onBodyFocusChanged = onBodyFocusChanged,
office/src/main/java/com/vayunmathur/office/ui/DocumentScaffoldShell.kt
diff --git a/office/src/main/java/com/vayunmathur/office/ui/DocumentScaffoldShell.kt b/office/src/main/java/com/vayunmathur/office/ui/DocumentScaffoldShell.ktindex 89e67645b5..da44df8a4b 100644--- a/office/src/main/java/com/vayunmathur/office/ui/DocumentScaffoldShell.kt+++ b/office/src/main/java/com/vayunmathur/office/ui/DocumentScaffoldShell.kt@@ -46,7 +46,9 @@ import com.vayunmathur.office.platform.OfficeViewModel import com.vayunmathur.office.platform.needsSaveAs import com.vayunmathur.office.platform.save import kotlinx.coroutines.CoroutineScope+import com.vayunmathur.library.util.NavBackStack import com.vayunmathur.office.MainActivity+import com.vayunmathur.office.Route import com.vayunmathur.office.Navigation import com.vayunmathur.office.R @@ -70,6 +72,7 @@ internal fun DocumentScaffoldShell(     onCellSelected: (Int, Int, Int) -> Unit,     onSlideChange: (Int) -> Unit,     onSlideElementSelected: (Int, Int) -> Unit,+    backStack: NavBackStack<Route>? = null,     onBack: () -> Unit,     bodyFocusRequester: FocusRequester? = null,     onBodyFocusChanged: (Boolean) -> Unit = {},@@ -127,6 +130,7 @@ internal fun DocumentScaffoldShell(             onCellSelected = onCellSelected,             onSlideChange = onSlideChange,             onSlideElementSelected = onSlideElementSelected,+            backStack = backStack,             bodyFocusRequester = bodyFocusRequester,             onBodyFocusChanged = onBodyFocusChanged,         )
office/src/main/java/com/vayunmathur/office/ui/DocumentScreen.kt
diff --git a/office/src/main/java/com/vayunmathur/office/ui/DocumentScreen.kt b/office/src/main/java/com/vayunmathur/office/ui/DocumentScreen.ktindex 59e6ebc1a1..eda880cca8 100644--- a/office/src/main/java/com/vayunmathur/office/ui/DocumentScreen.kt+++ b/office/src/main/java/com/vayunmathur/office/ui/DocumentScreen.kt@@ -20,6 +20,8 @@ import com.vayunmathur.library.ui.EditorFormat import com.vayunmathur.library.ui.ExperimentalMaterial3Api import com.vayunmathur.library.ui.odf.OdfDocument import com.vayunmathur.library.ui.rememberDrawerState+import com.vayunmathur.library.util.NavBackStack+import com.vayunmathur.office.Route import com.vayunmathur.office.platform.OfficeViewModel import com.vayunmathur.office.platform.needsSaveAs import com.vayunmathur.office.platform.runParagraphIndexAt@@ -35,6 +37,7 @@ fun DocumentScreen(     viewModel: OfficeViewModel,     activity: ComponentActivity,     onBack: () -> Unit,+    backStack: NavBackStack<Route>? = null,     onBecameOnline: (String) -> Unit = {}) {     val s = rememberDocumentScreenState()     val sel = rememberScreenSelection(s)@@ -135,6 +138,7 @@ fun DocumentScreen(         onCellSelected = { si, r, c -> sel.activeCell = Triple(si, r, c) },         onSlideChange = { sel.activeSlide = it },         onSlideElementSelected = { si, e -> sel.activeSlide = si; sel.activeSlideEl = e },+        backStack = backStack,         focusedPara = focusedPara,         onBack = onBack,         onBecameOnline = onBecameOnline,
office/src/main/java/com/vayunmathur/office/ui/DocumentScreenShell.kt
diff --git a/office/src/main/java/com/vayunmathur/office/ui/DocumentScreenShell.kt b/office/src/main/java/com/vayunmathur/office/ui/DocumentScreenShell.ktindex ecf11da1fb..3932e23d15 100644--- a/office/src/main/java/com/vayunmathur/office/ui/DocumentScreenShell.kt+++ b/office/src/main/java/com/vayunmathur/office/ui/DocumentScreenShell.kt@@ -44,7 +44,9 @@ import com.vayunmathur.office.platform.save import kotlinx.coroutines.CoroutineScope  import com.vayunmathur.office.MainActivity+import com.vayunmathur.library.util.NavBackStack import com.vayunmathur.office.Navigation+import com.vayunmathur.office.Route import com.vayunmathur.office.R internal val DrawerWidth = 280.dp internal val SavingSpinnerSize = 20.dp@@ -116,6 +118,7 @@ internal fun DocumentDrawerShell(     onCellSelected: (Int, Int, Int) -> Unit,     onSlideChange: (Int) -> Unit,     onSlideElementSelected: (Int, Int) -> Unit,+    backStack: NavBackStack<Route>? = null,     focusedPara: Int,     onBack: () -> Unit,     onBecameOnline: (String) -> Unit,@@ -148,6 +151,7 @@ internal fun DocumentDrawerShell(             onCellSelected = onCellSelected,             onSlideChange = onSlideChange,             onSlideElementSelected = onSlideElementSelected,+            backStack = backStack,             onBack = onBack,             bodyFocusRequester = bodyFocusRequester,             onBodyFocusChanged = onBodyFocusChanged,
office/src/main/java/com/vayunmathur/office/ui/OfficeDialogEntries.kt
diff --git a/office/src/main/java/com/vayunmathur/office/ui/OfficeDialogEntries.kt b/office/src/main/java/com/vayunmathur/office/ui/OfficeDialogEntries.ktnew file mode 100644index 0000000000..cf07e3a501--- /dev/null+++ b/office/src/main/java/com/vayunmathur/office/ui/OfficeDialogEntries.kt@@ -0,0 +1,83 @@+package com.vayunmathur.office.ui++import androidx.compose.runtime.Composable+import androidx.compose.runtime.collectAsState+import androidx.compose.runtime.getValue+import androidx.compose.runtime.rememberCoroutineScope+import com.vayunmathur.library.ui.odf.OdfDocument+import com.vayunmathur.library.util.DialogPage+import com.vayunmathur.library.util.EntryProviderScope+import com.vayunmathur.library.util.LocalNavResultRegistry+import com.vayunmathur.library.util.NavBackStack+import com.vayunmathur.office.Route+import com.vayunmathur.office.platform.OfficeViewModel+import com.vayunmathur.office.platform.deleteOnlineDocument+import com.vayunmathur.office.ui.dialogs.DeleteOnlineDocumentDialogContent+import com.vayunmathur.office.ui.dialogs.GoToSlideDialogContent+import com.vayunmathur.office.ui.dialogs.SlideshowDialogContent+import kotlinx.coroutines.launch++/** Result key: the go-to-slide dialog chose a zero-based slide index (Int). */+const val RESULT_GO_TO_SLIDE = "office.go-to-slide"++/** Result key: the slideshow's current/final zero-based slide index (Int). */+const val RESULT_SLIDESHOW_SLIDE = "office.slideshow-slide"++/** Dialog destinations for office: DialogPage routes with stateless contents. */+internal fun EntryProviderScope<Route>.officeDialogEntries(+    backStack: NavBackStack<Route>,+    viewModel: OfficeViewModel,+) {+    entry<Route.DeleteOnlineDocumentDialog>(metadata = DialogPage()) { route ->+        DeleteOnlineDocumentDialogContent(+            title = route.title,+            owner = route.owner,+            onDismiss = { backStack.pop() },+            onConfirm = {+                backStack.pop()+                viewModel.deleteOnlineDocument(route.docId)+            },+        )+    }+    entry<Route.GoToSlideDialog>(metadata = DialogPage()) { route ->+        GoToSlideDialogHost(backStack, route)+    }+    entry<Route.SlideshowDialog>(metadata = DialogPage()) { route ->+        SlideshowDialogHost(backStack, viewModel, route)+    }+}++@Composable+private fun GoToSlideDialogHost(backStack: NavBackStack<Route>, route: Route.GoToSlideDialog) {+    val registry = LocalNavResultRegistry.current+    val scope = rememberCoroutineScope()+    GoToSlideDialogContent(+        total = route.total,+        onDismiss = { backStack.pop() },+        onGo = { index ->+            scope.launch { registry.dispatchResult(RESULT_GO_TO_SLIDE, index) }+        },+    )+}++@Composable+private fun SlideshowDialogHost(+    backStack: NavBackStack<Route>,+    viewModel: OfficeViewModel,+    route: Route.SlideshowDialog,+) {+    val registry = LocalNavResultRegistry.current+    val scope = rememberCoroutineScope()+    val state by viewModel.state.collectAsState()+    val slides = (state as? OfficeViewModel.ViewState.Loaded)+        ?.document as? OdfDocument.Presentation+    if (slides == null || slides.slides.isEmpty()) return+    SlideshowDialogContent(+        slides = slides.slides,+        startIndex = route.startIndex,+        onSlideChange = { index ->+            scope.launch { registry.dispatchResult(RESULT_SLIDESHOW_SLIDE, index) }+        },+        onDismiss = { backStack.pop() },+    )+}
office/src/main/java/com/vayunmathur/office/ui/OfficeDocumentFindBars.kt
diff --git a/office/src/main/java/com/vayunmathur/office/ui/OfficeDocumentFindBars.kt b/office/src/main/java/com/vayunmathur/office/ui/OfficeDocumentFindBars.ktindex 2b8f91c3aa..17c781891e 100644--- a/office/src/main/java/com/vayunmathur/office/ui/OfficeDocumentFindBars.kt+++ b/office/src/main/java/com/vayunmathur/office/ui/OfficeDocumentFindBars.kt@@ -1,5 +1,6 @@ package com.vayunmathur.office.ui +// SCAFFOLD SEARCH EXCEPTION: expandable find-in-document bar in the editor; its match/replace controls and document-list results surface have no scaffold search host import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer
office/src/main/java/com/vayunmathur/office/ui/OfficeDocumentPane.kt
diff --git a/office/src/main/java/com/vayunmathur/office/ui/OfficeDocumentPane.kt b/office/src/main/java/com/vayunmathur/office/ui/OfficeDocumentPane.ktindex 85085cddfa..e00035a280 100644--- a/office/src/main/java/com/vayunmathur/office/ui/OfficeDocumentPane.kt+++ b/office/src/main/java/com/vayunmathur/office/ui/OfficeDocumentPane.kt@@ -62,6 +62,8 @@ import com.vayunmathur.office.platform.updateSheetElementText import com.vayunmathur.office.platform.updateSlideElementText import com.vayunmathur.office.platform.updateTextTableCell +import com.vayunmathur.office.Route+import com.vayunmathur.library.util.NavBackStack import com.vayunmathur.office.platform.OfficePresence import com.vayunmathur.office.platform.save import com.vayunmathur.office.R@@ -94,6 +96,7 @@ fun OfficeDocumentPane(     onCropImage: (Int) -> Unit,     onCropSlide: (Int, Int) -> Unit,     onCropSheet: (Int, Int) -> Unit,+    backStack: NavBackStack<Route>? = null,     modifier: Modifier = Modifier,     bodyFocusRequester: FocusRequester? = null,     onBodyFocusChanged: (Boolean) -> Unit = {},@@ -118,7 +121,7 @@ fun OfficeDocumentPane(                 onCellSelected, onCropSheet)             is OdfDocument.Presentation -> SlidePane(                 document, viewModel, isEditMode, activeSlideEl,-                onSlideChange, onSlideElementSelected, onCropSlide)+                onSlideChange, onSlideElementSelected, onCropSlide, backStack)             is OdfDocument.Drawing -> DrawingView(document)         }           }@@ -241,6 +244,7 @@ private fun SlidePane(     onSlideChange: (Int) -> Unit,     onSlideElementSelected: (Int, Int) -> Unit,     onCropSlide: (Int, Int) -> Unit,+    backStack: NavBackStack<Route>? = null, ) {     PresentationView(         doc = document, isEditMode = isEditMode,@@ -254,6 +258,7 @@ private fun SlidePane(         onElementBoundsChange = { s, e, x, y, w, h -> viewModel.setSlideElementBounds(s, e, x, y, w, h) },         onDeleteElement = { s, e -> viewModel.deleteSlideElement(s, e) },         selectedElement = activeSlideEl,+        backStack = backStack,         onSlideChange = { onSlideChange(it); viewModel.setLocalLocation("Slide ${it + 1}") },         onElementSelected = { s, e -> onSlideElementSelected(s, e) },         onCropImage = { s, e -> onCropSlide(s, e) })
office/src/main/java/com/vayunmathur/office/ui/OfficeHomeScreens.kt
diff --git a/office/src/main/java/com/vayunmathur/office/ui/OfficeHomeScreens.kt b/office/src/main/java/com/vayunmathur/office/ui/OfficeHomeScreens.ktindex b56f7bb251..d72e414007 100644--- a/office/src/main/java/com/vayunmathur/office/ui/OfficeHomeScreens.kt+++ b/office/src/main/java/com/vayunmathur/office/ui/OfficeHomeScreens.kt@@ -66,10 +66,11 @@ internal fun OfficeTabs(                 )             }             entry<Route.OnlineHome>(metadata = SiblingPage()) {-                OnlineTab(viewModel = viewModel, onOpenDoc = onOpenOnlineDoc)+                OnlineTab(viewModel = viewModel, onOpenDoc = onOpenOnlineDoc, backStack = backStack)             }             entry<Route.OfflineEditor> { editorContent() }             entry<Route.OnlineEditor> { editorContent() }+            officeDialogEntries(backStack, viewModel)         }     } }
office/src/main/java/com/vayunmathur/office/ui/OfficeOnlineScreens.kt
diff --git a/office/src/main/java/com/vayunmathur/office/ui/OfficeOnlineScreens.kt b/office/src/main/java/com/vayunmathur/office/ui/OfficeOnlineScreens.ktindex 441e0885e9..5cec803f71 100644--- a/office/src/main/java/com/vayunmathur/office/ui/OfficeOnlineScreens.kt+++ b/office/src/main/java/com/vayunmathur/office/ui/OfficeOnlineScreens.kt@@ -34,7 +34,6 @@ import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import com.vayunmathur.library.ui.R as UiR-import com.vayunmathur.library.ui.AlertDialog import com.vayunmathur.library.ui.AppScaffold import com.vayunmathur.library.ui.Button import com.vayunmathur.library.ui.Card@@ -54,6 +53,8 @@ import com.vayunmathur.library.ui.Text import com.vayunmathur.library.ui.TextButton import com.vayunmathur.library.util.OfflineBanner import com.vayunmathur.library.util.rememberIsOnline+import com.vayunmathur.library.util.NavBackStack+import com.vayunmathur.office.Route import com.vayunmathur.office.platform.OfficeDocMeta import com.vayunmathur.office.platform.OfficeMember import com.vayunmathur.office.platform.OfficeRoles@@ -181,6 +182,7 @@ internal fun OnlineDocLists(     requests: List<com.vayunmathur.office.sync.OfficeSync.JoinRequest>,     context: android.content.Context,     onOpenDoc: (OfficeDocMeta) -> Unit,+    backStack: NavBackStack<Route>? = null, ) {     if (docs.isEmpty() && requests.isEmpty()) {         Text(stringResource(R.string.no_online_documents_yet_open_a_document),@@ -200,7 +202,7 @@ internal fun OnlineDocLists(             }         }         items(docs, key = { it.docId }) { meta ->-            OnlineDocCard(viewModel, meta, context, onOpenDoc)+            OnlineDocCard(viewModel, meta, context, onOpenDoc, backStack)         }     } }@@ -242,8 +244,8 @@ private fun OnlineDocCard(     meta: OfficeDocMeta,     context: android.content.Context,     onOpenDoc: (OfficeDocMeta) -> Unit,+    backStack: NavBackStack<Route>? = null, ) {-    var confirmDelete by remember { mutableStateOf(false) }     Card(Modifier.fillMaxWidth().clickable { onOpenDoc(meta) }) {         ListItem(             content = { Text(meta.title) },@@ -265,35 +267,9 @@ private fun OnlineDocCard(                             viewModel.shareLinkFor(meta.docId),                             context.getString(R.string.share_link_chooser))                     }) { IconShare() }-                    IconButton(onClick = { confirmDelete = true }) { IconDelete() }+                    IconButton(onClick = { backStack?.add(Route.DeleteOnlineDocumentDialog(meta.docId, meta.title, meta.owner)) }) { IconDelete() }                 }             }         )     }-    if (confirmDelete) {-        AlertDialog(-            onDismissRequest = { confirmDelete = false },-            title = { Text(stringResource(R.string.delete_document)) },-            text = {-                Text(-                    stringResource(-                        if (meta.owner) R.string.delete_document_message-                        else R.string.remove_document_message,-                        meta.title,-                    ),-                )-            },-            confirmButton = {-                TextButton(onClick = {-                    confirmDelete = false-                    viewModel.deleteOnlineDocument(meta.docId)-                }) { Text(stringResource(R.string.delete_document)) }-            },-            dismissButton = {-                TextButton(onClick = { confirmDelete = false }) {-                    Text(stringResource(UiR.string.cancel))-                }-            },-        )-    } }
office/src/main/java/com/vayunmathur/office/ui/OnlineTab.kt
diff --git a/office/src/main/java/com/vayunmathur/office/ui/OnlineTab.kt b/office/src/main/java/com/vayunmathur/office/ui/OnlineTab.ktindex a51fdbfdea..6f240056d5 100644--- a/office/src/main/java/com/vayunmathur/office/ui/OnlineTab.kt+++ b/office/src/main/java/com/vayunmathur/office/ui/OnlineTab.kt@@ -54,6 +54,8 @@ import com.vayunmathur.library.ui.Text import com.vayunmathur.library.ui.TextButton import com.vayunmathur.library.util.OfflineBanner import com.vayunmathur.library.util.rememberIsOnline+import com.vayunmathur.library.util.NavBackStack+import com.vayunmathur.office.Route import com.vayunmathur.office.platform.OfficeDocMeta import com.vayunmathur.office.platform.OfficeMember import com.vayunmathur.office.platform.OfficeRoles@@ -71,7 +73,7 @@ import com.vayunmathur.office.platform.refreshOnline  @OptIn(ExperimentalMaterial3Api::class) @Composable-fun OnlineTab(viewModel: OfficeViewModel, onOpenDoc: (OfficeDocMeta) -> Unit) {+fun OnlineTab(viewModel: OfficeViewModel, onOpenDoc: (OfficeDocMeta) -> Unit, backStack: NavBackStack<Route>? = null) {     val onlineEnabled by viewModel.onlineEnabled.collectAsState()     if (!onlineEnabled) {         OnlineDisabledScreen(onEnable = { viewModel.enableOnlineSharing() })@@ -98,7 +100,7 @@ fun OnlineTab(viewModel: OfficeViewModel, onOpenDoc: (OfficeDocMeta) -> Unit) {             Column(Modifier.fillMaxSize().padding(horizontal = SpacingContent)) {                 OnlineDeviceHeader(deviceId, scope, clipboard)                 Spacer(Modifier.height(SpacingSm))-                OnlineDocLists(viewModel, docs, requests, context, onOpenDoc)+                OnlineDocLists(viewModel, docs, requests, context, onOpenDoc, backStack)             }         }     }
office/src/main/java/com/vayunmathur/office/ui/PresentationViews.kt
diff --git a/office/src/main/java/com/vayunmathur/office/ui/PresentationViews.kt b/office/src/main/java/com/vayunmathur/office/ui/PresentationViews.ktindex 1c14a2c7ad..c331604b91 100644--- a/office/src/main/java/com/vayunmathur/office/ui/PresentationViews.kt+++ b/office/src/main/java/com/vayunmathur/office/ui/PresentationViews.kt@@ -39,8 +39,6 @@ import androidx.compose.ui.text.input.TextFieldValue import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp-import androidx.compose.ui.window.Dialog-import androidx.compose.ui.window.DialogProperties import com.vayunmathur.library.ui.Card import com.vayunmathur.library.ui.CardDefaults import com.vayunmathur.library.ui.HorizontalDivider@@ -56,7 +54,9 @@ import com.vayunmathur.library.ui.odf.OdfSlide import com.vayunmathur.library.ui.odf.OdfSlideElement import com.vayunmathur.office.R -import com.vayunmathur.office.Navigation+import com.vayunmathur.library.util.NavBackStack+import com.vayunmathur.library.util.ResultEffect+import com.vayunmathur.office.Route @Composable fun PresentationView(     doc: OdfDocument.Presentation,@@ -71,6 +71,7 @@ fun PresentationView(     onElementBoundsChange: (Int, Int, Float, Float, Float, Float) -> Unit = { _, _, _, _, _, _ -> },     onDeleteElement: (Int, Int) -> Unit = { _, _ -> },     selectedElement: Int = -1,+    backStack: NavBackStack<Route>? = null,     onSlideChange: (Int) -> Unit = {},     onElementSelected: (Int, Int) -> Unit = { _, _ -> },     onCropImage: (Int, Int) -> Unit = { _, _ -> }@@ -80,8 +81,11 @@ fun PresentationView(         modifier = Modifier.padding(16.dp)); return }      var currentSlide by remember { mutableIntStateOf(0) }-    var showGoToSlide by remember { mutableStateOf(false) }-    var showSlideshow by remember { mutableStateOf(false) }+    // Dialog results arrive through the nav result registry when hosted.+    if (backStack != null) {+        ResultEffect<Int>(RESULT_GO_TO_SLIDE) { currentSlide = it }+        ResultEffect<Int>(RESULT_SLIDESHOW_SLIDE) { currentSlide = it }+    }     var dragAccumulator by remember { mutableFloatStateOf(0f) }     currentSlide = currentSlide.coerceIn(0, doc.slides.size - 1)     LaunchedEffect(currentSlide) { onSlideChange(currentSlide); onElementSelected(currentSlide, -1) }@@ -154,8 +158,8 @@ fun PresentationView(                 TextButton(                     onClick = { if (currentSlide > 0) currentSlide-- },                     enabled = currentSlide > 0) { Text(stringResource(R.string.prev)) }-                TextButton(onClick = { showSlideshow = true }) { Text(stringResource(UiR.string.play)) }-                TextButton(onClick = { showGoToSlide = true }) {+                TextButton(onClick = { backStack?.add(Route.SlideshowDialog(currentSlide)) }) { Text(stringResource(UiR.string.play)) }+                TextButton(onClick = { backStack?.add(Route.GoToSlideDialog(doc.slides.size)) }) {                     Text(                         stringResource(R.string.slide_of, currentSlide + 1, doc.slides.size),                         style = MaterialTheme.typography.titleSmall)@@ -166,54 +170,6 @@ fun PresentationView(             }         }     }--    if (showGoToSlide) GoToSlideDialog(-        doc.slides.size,-        onGo = { currentSlide = it },-        onDismiss = { showGoToSlide = false })-    if (showSlideshow) SlideshowDialog(-        doc.slides,-        currentSlide,-        onSlideChange = { currentSlide = it },-        onDismiss = { showSlideshow = false })-}--@Composable-private fun SlideshowDialog(-    slides: List<OdfSlide>,-    startIndex: Int,-    onSlideChange: (Int) -> Unit,-    onDismiss: () -> Unit) {-    var index by remember { mutableIntStateOf(startIndex.coerceIn(0, slides.size - 1)) }-    // Slides may shrink via a live merge while the slideshow is open.-    if (slides.isNotEmpty()) index = index.coerceIn(0, slides.size - 1)-    Dialog(-        onDismissRequest = { onSlideChange(index); onDismiss() },-        properties = DialogProperties(usePlatformDefaultWidth = false)) {-        Box(Modifier.fillMaxSize().background(Color.Black)) {-            val slide = slides[index]-            val (refW, refH) = slideBounds(slide)-            Box(Modifier.fillMaxWidth().aspectRatio((refW / refH).coerceIn(-                0.5f,-                3f)).align(Alignment.Center).background(Color.White)) {-                SlideCanvas(slide, refW, refH)-            }-            // Tap zones-            Row(Modifier.fillMaxSize()) {-                Box(Modifier.weight(1f).fillMaxHeight().clickable { if (index > 0) { index--; onSlideChange(index) } })-                Box(Modifier.weight(1f).fillMaxHeight().clickable { if (index < slides.size - 1) { index++; onSlideChange(index) } else { onSlideChange(index); onDismiss() } })-            }-            Text(-                "${index + 1} / ${slides.size}",-                color = Color.White,-                style = MaterialTheme.typography.labelMedium,-                modifier = Modifier.align(Alignment.BottomCenter).padding(12.dp))-            TextButton(-                onClick = { onSlideChange(index); onDismiss() },-                modifier = Modifier.align(Alignment.TopEnd).padding(8.dp))-            { Text(stringResource(R.string.close_search), color = Color.White) }-        }-    } }  @Composable@@ -309,7 +265,7 @@ internal fun SlideCard(     } } -private fun slideBounds(slide: OdfSlide): Pair<Float, Float> {+internal fun slideBounds(slide: OdfSlide): Pair<Float, Float> {     var maxR = 0f; var maxB = 0f     for (el in slide.elements) {         val (x, y, w, h) = when (el) {@@ -324,7 +280,7 @@ private fun slideBounds(slide: OdfSlide): Pair<Float, Float> { }  @Composable-private fun SlideCanvas(+internal fun SlideCanvas(     slide: OdfSlide,     refW: Float,     refH: Float,
office/src/main/java/com/vayunmathur/office/ui/dialogs/DeleteOnlineDocumentDialogContent.kt
diff --git a/office/src/main/java/com/vayunmathur/office/ui/dialogs/DeleteOnlineDocumentDialogContent.kt b/office/src/main/java/com/vayunmathur/office/ui/dialogs/DeleteOnlineDocumentDialogContent.ktnew file mode 100644index 0000000000..87f7d16fb4--- /dev/null+++ b/office/src/main/java/com/vayunmathur/office/ui/dialogs/DeleteOnlineDocumentDialogContent.kt@@ -0,0 +1,40 @@+package com.vayunmathur.office.ui.dialogs++import androidx.compose.runtime.Composable+import androidx.compose.ui.res.stringResource+import com.vayunmathur.library.ui.AlertDialog+import com.vayunmathur.library.ui.R as UiR+import com.vayunmathur.library.ui.Text+import com.vayunmathur.library.ui.TextButton+import com.vayunmathur.office.R++/** Stateless delete/remove confirmation for one online document. */+@Composable+fun DeleteOnlineDocumentDialogContent(+    title: String,+    owner: Boolean,+    onConfirm: () -> Unit,+    onDismiss: () -> Unit,+) {+    AlertDialog(+        onDismissRequest = onDismiss,+        title = { Text(stringResource(R.string.delete_document)) },+        text = {+            Text(+                stringResource(+                    if (owner) R.string.delete_document_message+                    else R.string.remove_document_message,+                    title,+                ),+            )+        },+        confirmButton = {+            TextButton(onClick = onConfirm) { Text(stringResource(R.string.delete_document)) }+        },+        dismissButton = {+            TextButton(onClick = onDismiss) {+                Text(stringResource(UiR.string.cancel))+            }+        },+    )+}
office/src/main/java/com/vayunmathur/office/ui/dialogs/GoToSlideDialogContent.kt
diff --git a/office/src/main/java/com/vayunmathur/office/ui/GoToSlideDialog.kt b/office/src/main/java/com/vayunmathur/office/ui/dialogs/GoToSlideDialogContent.ktsimilarity index 85%rename from office/src/main/java/com/vayunmathur/office/ui/GoToSlideDialog.ktrename to office/src/main/java/com/vayunmathur/office/ui/dialogs/GoToSlideDialogContent.ktindex 139a56a34d..9ae9491731 100644--- a/office/src/main/java/com/vayunmathur/office/ui/GoToSlideDialog.kt+++ b/office/src/main/java/com/vayunmathur/office/ui/dialogs/GoToSlideDialogContent.kt@@ -1,20 +1,21 @@-package com.vayunmathur.office.ui+package com.vayunmathur.office.ui.dialogs -import com.vayunmathur.library.ui.R as UiR-import com.vayunmathur.library.ui.AlertDialog-import com.vayunmathur.library.ui.Text-import com.vayunmathur.library.ui.TextButton-import com.vayunmathur.library.ui.TextField 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.res.stringResource+import com.vayunmathur.library.ui.AlertDialog+import com.vayunmathur.library.ui.R as UiR+import com.vayunmathur.library.ui.Text+import com.vayunmathur.library.ui.TextButton+import com.vayunmathur.library.ui.TextField import com.vayunmathur.office.R +/** Stateless go-to-slide picker; [onGo] receives the zero-based slide index. */ @Composable-fun GoToSlideDialog(total: Int, onGo: (Int) -> Unit, onDismiss: () -> Unit) {+fun GoToSlideDialogContent(total: Int, onGo: (Int) -> Unit, onDismiss: () -> Unit) {     var input by remember { mutableStateOf("") }     AlertDialog(         onDismissRequest = onDismiss,
office/src/main/java/com/vayunmathur/office/ui/dialogs/SlideshowDialogContent.kt
diff --git a/office/src/main/java/com/vayunmathur/office/ui/dialogs/SlideshowDialogContent.kt b/office/src/main/java/com/vayunmathur/office/ui/dialogs/SlideshowDialogContent.ktnew file mode 100644index 0000000000..e3aec00e53--- /dev/null+++ b/office/src/main/java/com/vayunmathur/office/ui/dialogs/SlideshowDialogContent.kt@@ -0,0 +1,70 @@+package com.vayunmathur.office.ui.dialogs++import androidx.compose.foundation.background+import androidx.compose.foundation.clickable+import androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.Row+import androidx.compose.foundation.layout.aspectRatio+import androidx.compose.foundation.layout.fillMaxHeight+import androidx.compose.foundation.layout.fillMaxSize+import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.padding+import androidx.compose.runtime.Composable+import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableIntStateOf+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.res.stringResource+import androidx.compose.ui.unit.dp+import androidx.compose.ui.window.Dialog+import androidx.compose.ui.window.DialogProperties+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.Text+import com.vayunmathur.library.ui.TextButton+import com.vayunmathur.library.ui.odf.OdfSlide+import com.vayunmathur.office.R+import com.vayunmathur.office.ui.SlideCanvas+import com.vayunmathur.office.ui.slideBounds++/** Stateless full-screen slideshow over [slides], starting at [startIndex]. */+@Composable+fun SlideshowDialogContent(+    slides: List<OdfSlide>,+    startIndex: Int,+    onSlideChange: (Int) -> Unit,+    onDismiss: () -> Unit,+) {+    var index by remember { mutableIntStateOf(startIndex.coerceIn(0, slides.size - 1)) }+    // Slides may shrink via a live merge while the slideshow is open.+    if (slides.isNotEmpty()) index = index.coerceIn(0, slides.size - 1)+    Dialog(+        onDismissRequest = { onSlideChange(index); onDismiss() },+        properties = DialogProperties(usePlatformDefaultWidth = false)) {+        Box(Modifier.fillMaxSize().background(Color.Black)) {+            val slide = slides[index]+            val (refW, refH) = slideBounds(slide)+            Box(Modifier.fillMaxWidth().aspectRatio((refW / refH).coerceIn(+                0.5f,+                3f)).align(Alignment.Center).background(Color.White)) {+                SlideCanvas(slide, refW, refH)+            }+            // Tap zones+            Row(Modifier.fillMaxSize()) {+                Box(Modifier.weight(1f).fillMaxHeight().clickable { if (index > 0) { index--; onSlideChange(index) } })+                Box(Modifier.weight(1f).fillMaxHeight().clickable { if (index < slides.size - 1) { index++; onSlideChange(index) } else { onSlideChange(index); onDismiss() } })+            }+            Text(+                "${index + 1} / ${slides.size}",+                color = Color.White,+                style = MaterialTheme.typography.labelMedium,+                modifier = Modifier.align(Alignment.BottomCenter).padding(12.dp))+            TextButton(+                onClick = { onSlideChange(index); onDismiss() },+                modifier = Modifier.align(Alignment.TopEnd).padding(8.dp))+            { Text(stringResource(R.string.close_search), color = Color.White) }+        }+    }+}
office/src/screenshotTest/kotlin/com/vayunmathur/office/ui/MetadataPreviews.kt
diff --git a/office/src/screenshotTest/kotlin/com/vayunmathur/office/ui/MetadataPreviews.kt b/office/src/screenshotTest/kotlin/com/vayunmathur/office/ui/MetadataPreviews.ktindex 0ebb7b4452..fb9a20cedd 100644--- a/office/src/screenshotTest/kotlin/com/vayunmathur/office/ui/MetadataPreviews.kt+++ b/office/src/screenshotTest/kotlin/com/vayunmathur/office/ui/MetadataPreviews.kt@@ -36,6 +36,9 @@ import com.vayunmathur.office.ui.DocumentChrome import com.vayunmathur.office.ui.DrawerOutline import com.vayunmathur.office.ui.HomeScreen import com.vayunmathur.office.ui.OfficeLightTheme+import com.vayunmathur.office.ui.dialogs.DeleteOnlineDocumentDialogContent+import com.vayunmathur.office.ui.dialogs.GoToSlideDialogContent+import com.vayunmathur.office.ui.dialogs.SlideshowDialogContent  /** Phone-shaped, roughly 1080x2340 at xxhdpi — comfortably above the F-Droid minimum. */ private const val PHONE = "spec:width=411dp,height=891dp,dpi=420"@@ -200,13 +203,14 @@ private val SamplePresentation = OdfDocument.Presentation(  * functions. Order comes from the function names (Preview1…, Preview2…).  *  * Coverage: `OfflineHome`, the three offline editor bodies (text/sheet/slides,- * the renderable form of `OfflineEditor`), the outline drawer, and- * `OnlineHome` in its disabled state on phone, plus the wide editor layout on- * large-tablet (main/editor wide variant).- * Exceptions: the enabled `OnlineHome` list and `OnlineEditor` need the E2EE- * relay session + OfficeViewModel, and the full editor chrome needs the native- * `office_engine` (above) — Layoutlib cannot load that native library, so only- * the document bodies are shown, exactly as the header above describes.+ * the renderable form of `OfflineEditor`), the outline drawer,+ * `OnlineHome` in its disabled state, the `OnlineEditor` document body, and+ * the three dialog routes (delete-online-document, go-to-slide, slideshow)+ * on phone, plus the wide editor layout on large-tablet.+ * The enabled `OnlineHome` list needs the E2EE relay session + OfficeViewModel,+ * and the full editor chrome needs the native `office_engine` (above) —+ * Layoutlib cannot load that native library, so only the document bodies are+ * shown, exactly as the header above describes.  */ class MetadataPreviews { @@ -223,14 +227,14 @@ class MetadataPreviews {     }      @PreviewTest-    @Preview(name = "1-document", device = PHONE, group = "phone", showSystemUi = true)+    @Preview(name = "1-offline-editor", device = PHONE, group = "phone", showSystemUi = true)     @Composable     fun Preview1Document() {         Paper { TextDocumentView(doc = SampleTextDocument) }     }      @PreviewTest-    @Preview(name = "2-spreadsheet", device = PHONE, group = "phone", showSystemUi = true)+    @Preview(name = "2-offline-editor-spreadsheet", device = PHONE, group = "phone", showSystemUi = true)     @Composable     fun Preview2Spreadsheet() {         Paper {@@ -242,28 +246,28 @@ class MetadataPreviews {     }      @PreviewTest-    @Preview(name = "3-presentation", device = PHONE, group = "phone", showSystemUi = true)+    @Preview(name = "3-offline-editor-presentation", device = PHONE, group = "phone", showSystemUi = true)     @Composable     fun Preview3Presentation() {         Paper { PresentationView(doc = SamplePresentation) }     }      @PreviewTest-    @Preview(name = "4-home", device = PHONE, group = "phone", showSystemUi = true)+    @Preview(name = "4-offline-home", device = PHONE, group = "phone", showSystemUi = true)     @Composable     fun Preview4Home() {         ChromePreview()     }      @PreviewTest-    @Preview(name = "8-home-expanded", device = EXPANDED, group = "large-tablet", showSystemUi = true)+    @Preview(name = "8-offline-home-expanded", device = EXPANDED, group = "large-tablet", showSystemUi = true)     @Composable     fun Preview8HomeExpanded() {         ChromePreview()     }      @PreviewTest-    @Preview(name = "7-online-disabled", device = PHONE, group = "phone", showSystemUi = true)+    @Preview(name = "7-online-home-disabled", device = PHONE, group = "phone", showSystemUi = true)     @Composable     fun Preview7OnlineDisabled() {         DynamicTheme(darkTheme = true) {@@ -324,6 +328,38 @@ class MetadataPreviews {             }         }     }+    @PreviewTest+    @Preview(name = "9-online-editor", device = PHONE, group = "phone", showSystemUi = true)+    @Composable+    fun Preview9OnlineEditor() {+        Paper { TextDocumentView(doc = SampleTextDocument) }+    }++    @PreviewTest+    @Preview(name = "10-delete-online-document-dialog", device = PHONE, group = "phone", showSystemUi = true)+    @Composable+    fun Preview10DeleteOnlineDocumentDialog() {+        DynamicTheme(darkTheme = true) {+            DeleteOnlineDocumentDialogContent(title = "Q3 Report", owner = true, onConfirm = {}, onDismiss = {})+        }+    }++    @PreviewTest+    @Preview(name = "11-go-to-slide-dialog", device = PHONE, group = "phone", showSystemUi = true)+    @Composable+    fun Preview11GoToSlideDialog() {+        DynamicTheme(darkTheme = true) {+            GoToSlideDialogContent(total = 3, onGo = {}, onDismiss = {})+        }+    }++    @PreviewTest+    @Preview(name = "12-slideshow-dialog", device = PHONE, group = "phone", showSystemUi = true)+    @Composable+    fun Preview12SlideshowDialog() {+        Paper { SlideshowDialogContent(slides = SamplePresentation.slides, startIndex = 0, onSlideChange = {}, onDismiss = {}) }+    }+ }  /**
office/src/test/java/com/vayunmathur/office/ui/Slice4DialogsTest.kt
diff --git a/office/src/test/java/com/vayunmathur/office/ui/Slice4DialogsTest.kt b/office/src/test/java/com/vayunmathur/office/ui/Slice4DialogsTest.ktindex cb6009722a..d06d02a7ab 100644--- a/office/src/test/java/com/vayunmathur/office/ui/Slice4DialogsTest.kt+++ b/office/src/test/java/com/vayunmathur/office/ui/Slice4DialogsTest.kt@@ -160,13 +160,13 @@ class Slice4DialogsTest {         assertTrue(dismissed)     } -    // ---- GoToSlideDialog ----+    // ---- GoToSlideDialogContent ----      @Test fun goToSlideOutOfRangeIgnored() {         var went: Int? = null         var dismissed = false         rule.setContent {-            GoToSlideDialog(total = 10, onGo = { went = it }, onDismiss = { dismissed = true })+            com.vayunmathur.office.ui.dialogs.GoToSlideDialogContent(total = 10, onGo = { went = it }, onDismiss = { dismissed = true })         }         rule.onNodeWithText("Go to Slide").assertIsDisplayed()         rule.onNode(hasSetTextAction()).performTextInput("99")@@ -179,7 +179,7 @@ class Slice4DialogsTest {         var went: Int? = null         var dismissed = false         rule.setContent {-            GoToSlideDialog(total = 10, onGo = { went = it }, onDismiss = { dismissed = true })+            com.vayunmathur.office.ui.dialogs.GoToSlideDialogContent(total = 10, onGo = { went = it }, onDismiss = { dismissed = true })         }         rule.onNode(hasSetTextAction()).performTextInput("3")         rule.onNodeWithText("Go").performClick()@@ -190,7 +190,7 @@ class Slice4DialogsTest {     @Test fun goToSlideNonNumericIgnored() {         var went: Int? = null         rule.setContent {-            GoToSlideDialog(total = 10, onGo = { went = it }, onDismiss = {})+            com.vayunmathur.office.ui.dialogs.GoToSlideDialogContent(total = 10, onGo = { went = it }, onDismiss = {})         }         rule.onNode(hasSetTextAction()).performTextInput("abc")         rule.onNodeWithText("Go").performClick()
office/src/test/java/com/vayunmathur/office/ui/Slice4PresentationTest.kt
diff --git a/office/src/test/java/com/vayunmathur/office/ui/Slice4PresentationTest.kt b/office/src/test/java/com/vayunmathur/office/ui/Slice4PresentationTest.ktindex 43c56e2c8e..7d6f35119f 100644--- a/office/src/test/java/com/vayunmathur/office/ui/Slice4PresentationTest.kt+++ b/office/src/test/java/com/vayunmathur/office/ui/Slice4PresentationTest.kt@@ -95,20 +95,27 @@ class Slice4PresentationTest {     }      @Test fun slideshowDialogShowsAndCloses() {-        rule.setContent { PresentationView(doc = deck()) }-        rule.onNodeWithText("Play", substring = true).performClick()+        var dismissed = false+        rule.setContent {+            com.vayunmathur.office.ui.dialogs.SlideshowDialogContent(+                slides = deck().slides, startIndex = 0,+                onSlideChange = {}, onDismiss = { dismissed = true })+        }         // Slideshow renders the slide canvas plus a position counter.         rule.onNodeWithText("1 / 2").assertIsDisplayed()         rule.onNodeWithText("Close").performClick()-        rule.onNodeWithText("1 / 2").assertDoesNotExist()+        assertTrue(dismissed)     }      @Test fun goToSlideJumps() {-        rule.setContent { PresentationView(doc = deck()) }-        rule.onNodeWithText("Slide 1 of 2", substring = true).performClick()+        var chosen = -1+        rule.setContent {+            com.vayunmathur.office.ui.dialogs.GoToSlideDialogContent(+                total = 2, onGo = { chosen = it }, onDismiss = {})+        }         rule.onNode(hasSetTextAction()).performTextInput("2")         rule.onNodeWithText("Go").performClick()-        rule.onNodeWithText("Slide 2 of 2").assertIsDisplayed()+        assertEquals(1, chosen)     }      @Test fun deleteSlideInEditMode() {