Modern Apps git

← Modern-Apps.git

web: dialogs are routes and every route has a capture

Commit
840363679667254edcc71db0bd3b699a281f7a96
Author
Vayun Mathur <[email protected]>
When
2026-12-02 04:16 UTC (4 days ago)
Parents
4c07292
Convert the seven remember-gated dialogs into Route destinations
with DialogPage() entries in WebDialogEntries rendering the library
dialogs unconditionally: NewFolderDialog, DeleteBookmarkDialog and
DeleteFolderDialog (identity/label in the route), ClearHistoryDialog,
CacheModeDialog, SearchEngineDialog and ClearBrowsingDataDialog.
BookmarksPage/HistoryPage/SettingsPage request dialogs via
callbacks whose default pushes the route; BookmarksScreen's folder
selection clears itself when its folder is deleted via the route.
The omnibox SCAFFOLD SEARCH EXCEPTION markers are untouched.

Give every Route leaf a deterministic capture: rename the browser
captures to 1-browser/2-browser-tabs/4-browser-expanded, keep
3-bookmarks, and add 5-history through 10-shields plus 11-17 for
the dialog routes. New stateless slices (HistoryContent,
DownloadsContent, InstalledSitesContent, SiteDataContent,
SettingsContent, ShieldsContent) split out of their pages, which
now delegate, render from fixed literals (JUL_2026), and the dialog
captures render the library dialog primitives.

Adapt compose tests to host the dialog contents as route entries
do (BookmarksScreenTest, WebPagesDeepTest, WebPagesTest,
MiscDeepTest) and add FIXTURE RELATIVE-TIME EXCEPTION markers to
the test files that seed history/download timestamps relative to
the real clock their grouping logic reads. Update web/AGENTS.md.

Verified: ./gradlew :web:lint :web:lintVitalRelease
:web:testDevUnitTest and :web:compileDevScreenshotTestKotlin pass
(368 unit tests).

Diff

web/AGENTS.md
diff --git a/web/AGENTS.md b/web/AGENTS.mdindex 255cc5930d..9feffa124b 100644--- a/web/AGENTS.md+++ b/web/AGENTS.md@@ -25,6 +25,7 @@ _Install: ./install web (dev by default)._ - Shields filtering runs on the request path — regressions break all browsing; test with Shields on AND off - PWA windows run outside the browser chrome (`PwaActivity` + `PwaHelper`); window-launch bugs live there, not in `BrowserPage` - The omnibox is browser navigation chrome, not screen-level search: the read-only address pill (`BrowserChrome`) and the editable address field anchored to its suggestions overlay (`BrowserOmniboxEditor`) carry `// SCAFFOLD SEARCH EXCEPTION:` markers — do not migrate them to `ScaffoldSearch` (String-typed top-title filter field; it cannot host the pill's read-only display, the editor's `TextFieldValue` selection control/Uri IME navigation submit, or bottom docking)+- Dialogs are `Route` destinations (`NewFolderDialog`, `DeleteBookmarkDialog`, `DeleteFolderDialog`, `ClearHistoryDialog`, `CacheModeDialog`, `SearchEngineDialog`, `ClearBrowsingDataDialog`) with `DialogPage()` entries in `ui/WebDialogEntries.kt`; pages request them via callbacks (default: push the route) and never hold dialog state. Every `Route` leaf has a deterministic capture in `src/screenshotTest` (`<n>-<route-kebab>` in `MetadataPreviews`), rendered from stateless slices (`HistoryContent`, `DownloadsContent`, `InstalledSitesContent`, `SiteDataContent`, `SettingsContent`, `ShieldsContent`, `BookmarksScreen`) or the library dialog primitives  ## Key files ### Root — entry + navigation@@ -82,12 +83,10 @@ _Install: ./install web (dev by default)._ - com/vayunmathur/web/ui/TabSwitcher.kt - com/vayunmathur/web/ui/LinkContextMenu.kt - com/vayunmathur/web/ui/BookmarksPage.kt-- com/vayunmathur/web/ui/HistoryPage.kt-- com/vayunmathur/web/ui/DownloadsPage.kt-- com/vayunmathur/web/ui/InstalledSitesPage.kt-- com/vayunmathur/web/ui/PermissionSheets.kt-- com/vayunmathur/web/ui/SettingsPage.kt-- com/vayunmathur/web/ui/ShieldsPanel.kt+- com/vayunmathur/web/ui/HistoryPage.kt, HistoryContent.kt, DownloadsPage.kt, DownloadsContent.kt, InstalledSitesPage.kt, InstalledSitesContent.kt — page hosts + stateless screenshot slices+- com/vayunmathur/web/ui/PermissionSheets.kt, SiteDataContent.kt — permission sheets + stateless site-data slice+- com/vayunmathur/web/ui/SettingsPage.kt, SettingsContent.kt, ShieldsPanel.kt, ShieldsContent.kt — settings/shields hosts + stateless slices+- com/vayunmathur/web/ui/WebDialogEntries.kt — `DialogPage()` entries for the seven dialog routes - com/vayunmathur/web/ui/components/SiteIcon.kt - com/vayunmathur/web/ui/components/TabTile.kt 
web/src/main/java/com/vayunmathur/web/Navigation.kt
diff --git a/web/src/main/java/com/vayunmathur/web/Navigation.kt b/web/src/main/java/com/vayunmathur/web/Navigation.ktindex 9315da4255..bfe371ff1a 100644--- a/web/src/main/java/com/vayunmathur/web/Navigation.kt+++ b/web/src/main/java/com/vayunmathur/web/Navigation.kt@@ -13,6 +13,7 @@ import com.vayunmathur.web.ui.InstalledSitesPage import com.vayunmathur.web.ui.SettingsPage import com.vayunmathur.web.ui.ShieldsPage import com.vayunmathur.web.ui.SiteDataPage+import com.vayunmathur.web.ui.webDialogEntries  @Composable fun Navigation(viewModel: WebViewModel) {@@ -34,5 +35,6 @@ fun Navigation(viewModel: WebViewModel) {             InstalledSitesPage(viewModel = viewModel, backStack = backStack)         }         entry<Route.Shields> { ShieldsPage(viewModel = viewModel, backStack = backStack) }+        webDialogEntries(viewModel, backStack)     } }
web/src/main/java/com/vayunmathur/web/Route.kt
diff --git a/web/src/main/java/com/vayunmathur/web/Route.kt b/web/src/main/java/com/vayunmathur/web/Route.ktindex c95717632d..427f78a6a4 100644--- a/web/src/main/java/com/vayunmathur/web/Route.kt+++ b/web/src/main/java/com/vayunmathur/web/Route.kt@@ -22,4 +22,18 @@ sealed interface Route : NavKey {     @Serializable data object InstalledSites : Route     /** Shields settings route. */     @Serializable data object Shields : Route+    /** New bookmark folder dialog. */+    @Serializable data object NewFolderDialog : Route+    /** Delete one bookmark dialog; identity and label travel in the route. */+    @Serializable data class DeleteBookmarkDialog(val bookmarkId: Long, val title: String, val url: String) : Route+    /** Delete one bookmark folder dialog; identity and name travel in the route. */+    @Serializable data class DeleteFolderDialog(val folderId: Long, val folderName: String) : Route+    /** Clear all browsing history dialog. */+    @Serializable data object ClearHistoryDialog : Route+    /** Cache mode picker dialog. */+    @Serializable data object CacheModeDialog : Route+    /** Search engine picker dialog. */+    @Serializable data object SearchEngineDialog : Route+    /** Clear browsing data dialog. */+    @Serializable data object ClearBrowsingDataDialog : Route }
web/src/main/java/com/vayunmathur/web/ui/BookmarksPage.kt
diff --git a/web/src/main/java/com/vayunmathur/web/ui/BookmarksPage.kt b/web/src/main/java/com/vayunmathur/web/ui/BookmarksPage.ktindex 679f825317..8b1ccd68a4 100644--- a/web/src/main/java/com/vayunmathur/web/ui/BookmarksPage.kt+++ b/web/src/main/java/com/vayunmathur/web/ui/BookmarksPage.kt@@ -29,10 +29,8 @@ import androidx.compose.ui.unit.dp import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.vayunmathur.library.ui.R as UiR import com.vayunmathur.library.ui.AppScaffold-import com.vayunmathur.library.ui.ConfirmDialog import com.vayunmathur.library.ui.DesktopMaxWidthContainer 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.ExperimentalMaterial3Api@@ -41,21 +39,15 @@ import com.vayunmathur.library.ui.IconButton import com.vayunmathur.library.ui.IconFolder import com.vayunmathur.library.ui.IconNavigation import com.vayunmathur.library.ui.MaterialTheme-import com.vayunmathur.library.ui.OutlinedTextField-import com.vayunmathur.library.ui.TextInputDialog import com.vayunmathur.library.ui.Surface import com.vayunmathur.library.ui.Text-import com.vayunmathur.library.ui.TextButton import com.vayunmathur.web.Route import com.vayunmathur.library.util.NavBackStack import com.vayunmathur.web.data.Bookmark import com.vayunmathur.web.data.BookmarkFolder import com.vayunmathur.web.platform.BrowserUtils import com.vayunmathur.web.platform.WebViewModel-import com.vayunmathur.web.platform.createFolder-import com.vayunmathur.web.platform.deleteFolder import com.vayunmathur.web.platform.externalIntentUrl-import com.vayunmathur.web.platform.removeBookmark  @OptIn(ExperimentalMaterial3Api::class, ExperimentalFoundationApi::class) @Composable@@ -76,9 +68,13 @@ fun BookmarksPage(             viewModel.externalIntentUrl(bm.url)             backStack.pop()         },-        onDelete = { viewModel.removeBookmark(it) },-        onCreateFolder = { viewModel.createFolder(it) },-        onDeleteFolder = { viewModel.deleteFolder(it) },+        onRequestNewFolder = { backStack.add(Route.NewFolderDialog) },+        onRequestDeleteBookmark = { bm ->+            backStack.add(Route.DeleteBookmarkDialog(bm.id, bm.title, bm.url))+        },+        onRequestDeleteFolder = { folder ->+            backStack.add(Route.DeleteFolderDialog(folder.id, folder.name))+        },     ) } @@ -95,14 +91,19 @@ internal fun BookmarksScreen(     hasLoaded: Boolean = true,     navigationIcon: @Composable () -> Unit = {},     onOpen: (Bookmark) -> Unit = {},-    onDelete: (Bookmark) -> Unit = {},-    onCreateFolder: (String) -> Unit = {},-    onDeleteFolder: (BookmarkFolder) -> Unit = {},+    onRequestNewFolder: () -> Unit = {},+    onRequestDeleteBookmark: (Bookmark) -> Unit = {},+    onRequestDeleteFolder: (BookmarkFolder) -> Unit = {}, ) {     var selectedFolder by remember { mutableStateOf<Long?>(null) }-    var showNewFolderDialog by remember { mutableStateOf(false) }-    var showDeleteDialog by remember { mutableStateOf<Bookmark?>(null) }-    var showFolderDeleteDialog by remember { mutableStateOf<BookmarkFolder?>(null) }++    // A folder deleted through its dialog route no longer exists; fall back+    // to the unfiled list instead of filtering on a stale folder id.+    androidx.compose.runtime.LaunchedEffect(selectedFolder, folders) {+        if (selectedFolder != null && folders.none { it.id == selectedFolder }) {+            selectedFolder = null+        }+    }      val filtered = remember(bookmarks, selectedFolder) {         if (selectedFolder == null) bookmarks.filter { it.folderId == null }@@ -114,7 +115,7 @@ internal fun BookmarksScreen(         isRefreshing = !hasLoaded,         navigationIcon = navigationIcon,         actions = {-            IconButton(onClick = { showNewFolderDialog = true }) {+            IconButton(onClick = onRequestNewFolder) {                 IconFolder()             }         },@@ -150,7 +151,7 @@ internal fun BookmarksScreen(                                         text = { Text(stringResource(R.string.delete_folder)) },                                         onClick = {                                             showFolderMenu = false-                                            showFolderDeleteDialog = folder+                                            onRequestDeleteFolder(folder)                                         }                                     )                                 }@@ -202,7 +203,7 @@ internal fun BookmarksScreen(                         BookmarkRow(                             bookmark = bm,                             onClick = { onOpen(bm) },-                            onLongClick = { showDeleteDialog = bm }+                            onLongClick = { onRequestDeleteBookmark(bm) }                         )                     }                 }@@ -211,42 +212,6 @@ internal fun BookmarksScreen(         }     } -    if (showNewFolderDialog) {-        TextInputDialog(-            title = stringResource(R.string.new_folder),-            placeholder = stringResource(R.string.folder_name),-            confirmLabel = stringResource(UiR.string.create),-            dismissLabel = stringResource(UiR.string.cancel),-            confirmEnabled = { it.isNotBlank() },-            onConfirm = { onCreateFolder(it.trim()) },-            onDismiss = { showNewFolderDialog = false },-        )-    }--    showDeleteDialog?.let { bm ->-        ConfirmDialog(-            title = stringResource(R.string.delete_bookmark),-            message = bm.title.ifBlank { bm.url },-            confirmLabel = stringResource(UiR.string.delete),-            dismissLabel = stringResource(UiR.string.cancel),-            destructive = true,-            onConfirm = { onDelete(bm) },-            onDismiss = { showDeleteDialog = null },-        )-    }--    showFolderDeleteDialog?.let { folder ->-        ConfirmDialog(-            title = stringResource(R.string.delete_folder_2),-            message = stringResource(R.string.bookmarks_inside_will_also_be_deleted, folder.name),-            confirmLabel = stringResource(UiR.string.delete),-            dismissLabel = stringResource(UiR.string.cancel),-            onConfirm = { onDeleteFolder(folder)-                    if (selectedFolder == folder.id) selectedFolder = null },-            onDismiss = { showFolderDeleteDialog = null },-            destructive = true,-        )-    } }  @Composable
web/src/main/java/com/vayunmathur/web/ui/DownloadsContent.kt
diff --git a/web/src/main/java/com/vayunmathur/web/ui/DownloadsContent.kt b/web/src/main/java/com/vayunmathur/web/ui/DownloadsContent.ktnew file mode 100644index 0000000000..91030e79d5--- /dev/null+++ b/web/src/main/java/com/vayunmathur/web/ui/DownloadsContent.kt@@ -0,0 +1,96 @@+package com.vayunmathur.web.ui++import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.fillMaxSize+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.lazy.LazyColumn+import androidx.compose.foundation.lazy.items+import androidx.compose.material3.ExperimentalMaterial3Api+import androidx.compose.runtime.Composable+import androidx.compose.ui.Modifier+import androidx.compose.ui.res.stringResource+import androidx.compose.ui.text.style.TextOverflow+import androidx.compose.ui.unit.dp+import com.vayunmathur.library.ui.AppScaffold+import com.vayunmathur.library.ui.DesktopMaxWidthContainer+import com.vayunmathur.library.ui.EmptyState+import com.vayunmathur.library.ui.IconButton+import com.vayunmathur.library.ui.IconDelete+import com.vayunmathur.library.ui.IconDownload+import com.vayunmathur.library.ui.IconNavigation+import com.vayunmathur.library.ui.ListItem+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.Text+import com.vayunmathur.web.R+import com.vayunmathur.web.data.DownloadEntry+import kotlin.time.Instant+import kotlinx.datetime.LocalDateTime+import kotlinx.datetime.TimeZone+import kotlinx.datetime.format+import kotlinx.datetime.format.char+import kotlinx.datetime.toLocalDateTime++/**+ * Stateless downloads body. Split out of the downloads page so screenshot+ * captures render it from literal entries.+ */+@OptIn(ExperimentalMaterial3Api::class)+@Composable+fun DownloadsContent(+    downloads: List<DownloadEntry>,+    hasLoaded: Boolean,+    onNavigateBack: () -> Unit,+    onClearAll: () -> Unit = {},+) {+    AppScaffold(+        title = stringResource(R.string.downloads),+        isRefreshing = !hasLoaded,+        navigationIcon = { IconNavigation(onNavigateBack) },+        actions = {+            if (downloads.isNotEmpty()) {+                IconButton(onClick = onClearAll) { IconDelete() }+            }+        },+    ) { paddingValues ->+        DesktopMaxWidthContainer(modifier = Modifier.padding(paddingValues)) {+            if (!hasLoaded && downloads.isEmpty()) {+                Box(Modifier.fillMaxSize())+            } else if (downloads.isEmpty()) {+                EmptyState(+                    title = stringResource(R.string.no_downloads),+                    modifier = Modifier.fillMaxSize(),+                )+            } else {+                LazyColumn(Modifier.fillMaxSize(), verticalArrangement = Arrangement.spacedBy(2.dp)) {+                    items(downloads, key = { it.id }) { dl ->+                        ListItem(+                            headlineContent = { Text(dl.fileName, maxLines = 1, overflow = TextOverflow.Ellipsis) },+                            supportingContent = {+                                Column {+                                    Text(dl.url, maxLines = 1, overflow = TextOverflow.Ellipsis, style = MaterialTheme.typography.bodySmall)+                                    Text("${dl.mimeType ?: ""} \u2022 ${formatDownloadTime(dl.startedAt)}", style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant)+                                }+                            },+                            leadingContent = { IconDownload() },+                        )+                    }+                }+            }+        }+    }+}++private fun formatDownloadTime(millis: Long): String {+    return try {+        Instant.fromEpochMilliseconds(millis)+            .toLocalDateTime(TimeZone.currentSystemDefault())+            .format(+                LocalDateTime.Format {+                    year(); char('-'); monthNumber(); char('-'); day()+                    char(' '); hour(); char(':'); minute()+                },+            )+    } catch (_: Exception) { "" }+}
web/src/main/java/com/vayunmathur/web/ui/DownloadsPage.kt
diff --git a/web/src/main/java/com/vayunmathur/web/ui/DownloadsPage.kt b/web/src/main/java/com/vayunmathur/web/ui/DownloadsPage.ktindex cdf9fabf1b..e04dbd15ed 100644--- a/web/src/main/java/com/vayunmathur/web/ui/DownloadsPage.kt+++ b/web/src/main/java/com/vayunmathur/web/ui/DownloadsPage.kt@@ -1,45 +1,14 @@ package com.vayunmathur.web.ui -import androidx.compose.ui.res.stringResource-import com.vayunmathur.web.R-import kotlin.time.Clock-import kotlin.time.Instant-import kotlinx.datetime.LocalDateTime-import kotlinx.datetime.LocalTime-import kotlinx.datetime.TimeZone-import kotlinx.datetime.format-import kotlinx.datetime.format.char-import kotlinx.datetime.toLocalDateTime-import androidx.compose.foundation.layout.Arrangement-import androidx.compose.foundation.layout.Box-import androidx.compose.foundation.layout.Column-import androidx.compose.foundation.layout.fillMaxSize-import androidx.compose.foundation.layout.padding-import androidx.compose.foundation.lazy.LazyColumn-import androidx.compose.foundation.lazy.items-import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue-import androidx.compose.ui.Alignment-import androidx.compose.ui.Modifier-import androidx.compose.ui.text.style.TextOverflow-import androidx.compose.ui.unit.dp import androidx.lifecycle.compose.collectAsStateWithLifecycle-import com.vayunmathur.library.ui.AppScaffold-import com.vayunmathur.library.ui.DesktopMaxWidthContainer-import com.vayunmathur.library.ui.EmptyState-import com.vayunmathur.library.ui.IconButton-import com.vayunmathur.library.ui.IconDelete-import com.vayunmathur.library.ui.IconDownload-import com.vayunmathur.library.ui.ListItem-import com.vayunmathur.library.ui.MaterialTheme-import com.vayunmathur.library.ui.Text-import com.vayunmathur.web.Route import com.vayunmathur.library.util.NavBackStack+import com.vayunmathur.web.Route import com.vayunmathur.web.platform.WebViewModel import com.vayunmathur.web.platform.clearAllDownloads -@OptIn(ExperimentalMaterial3Api::class)+/** Downloads host: collects entries and renders [DownloadsContent]. */ @Composable fun DownloadsPage(     viewModel: WebViewModel,@@ -47,54 +16,10 @@ fun DownloadsPage( ) {     val downloads by viewModel.downloads.collectAsStateWithLifecycle()     val hasLoaded by viewModel.hasLoadedDownloads.collectAsStateWithLifecycle()--    AppScaffold(-        title = stringResource(R.string.downloads),-        isRefreshing = !hasLoaded,-        backStack = backStack,-        actions = {-            if (downloads.isNotEmpty()) {-                IconButton(onClick = { viewModel.clearAllDownloads() }) { IconDelete() }-            }-        },-    ) { paddingValues ->-        DesktopMaxWidthContainer(modifier = Modifier.padding(paddingValues)) {-        if (!hasLoaded && downloads.isEmpty()) {-            Box(Modifier.fillMaxSize())-        } else if (downloads.isEmpty()) {-            EmptyState(-                title = stringResource(R.string.no_downloads),-                modifier = Modifier.fillMaxSize(),-            )-        } else {-            LazyColumn(Modifier.fillMaxSize(), verticalArrangement = Arrangement.spacedBy(2.dp)) {-                items(downloads, key = { it.id }) { dl ->-                    ListItem(-                        headlineContent = { Text(dl.fileName, maxLines = 1, overflow = TextOverflow.Ellipsis) },-                        supportingContent = {-                            Column {-                                Text(dl.url, maxLines = 1, overflow = TextOverflow.Ellipsis, style = MaterialTheme.typography.bodySmall)-                                Text("${dl.mimeType ?: ""} • ${formatTime(dl.startedAt)}", style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant)-                            }-                        },-                        leadingContent = { IconDownload() }-                    )-                }-            }-        }-        }-    }-}--private fun formatTime(millis: Long): String {-    return try {-        Instant.fromEpochMilliseconds(millis)-            .toLocalDateTime(TimeZone.currentSystemDefault())-            .format(-                LocalDateTime.Format {-                    year(); char('-'); monthNumber(); char('-'); day()-                    char(' '); hour(); char(':'); minute()-                },-            )-    } catch (_: Exception) { "" }+    DownloadsContent(+        downloads = downloads,+        hasLoaded = hasLoaded,+        onNavigateBack = { backStack.pop() },+        onClearAll = { viewModel.clearAllDownloads() },+    ) }
web/src/main/java/com/vayunmathur/web/ui/HistoryContent.kt
diff --git a/web/src/main/java/com/vayunmathur/web/ui/HistoryContent.kt b/web/src/main/java/com/vayunmathur/web/ui/HistoryContent.ktnew file mode 100644index 0000000000..89ac38dc08--- /dev/null+++ b/web/src/main/java/com/vayunmathur/web/ui/HistoryContent.kt@@ -0,0 +1,151 @@+package com.vayunmathur.web.ui++import androidx.compose.foundation.ExperimentalFoundationApi+import androidx.compose.foundation.background+import androidx.compose.foundation.clickable+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.Spacer+import androidx.compose.foundation.layout.fillMaxSize+import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.layout.width+import androidx.compose.foundation.lazy.LazyColumn+import androidx.compose.foundation.lazy.items+import androidx.compose.foundation.shape.RoundedCornerShape+import androidx.compose.runtime.Composable+import androidx.compose.ui.res.stringResource+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.draw.clip+import androidx.compose.ui.text.style.TextOverflow+import androidx.compose.ui.unit.dp+import com.vayunmathur.library.ui.AppScaffold+import com.vayunmathur.library.ui.DesktopMaxWidthContainer+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.IconNavigation+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.Text+import com.vayunmathur.web.R+import com.vayunmathur.web.platform.BrowserUtils+import com.vayunmathur.web.data.HistoryEntry+import kotlin.time.Instant+import kotlinx.datetime.LocalTime+import kotlinx.datetime.TimeZone+import kotlinx.datetime.format+import kotlinx.datetime.format.char+import kotlinx.datetime.toLocalDateTime++/**+ * Stateless history body: date-grouped entries plus the clear action.+ * Split out of [HistoryPage] so screenshot captures render it from+ * literal grouped entries.+ */+@OptIn(ExperimentalMaterial3Api::class, ExperimentalFoundationApi::class)+@Composable+fun HistoryContent(+    grouped: List<Pair<String, List<HistoryEntry>>>,+    historyEmpty: Boolean,+    hasLoaded: Boolean,+    onNavigateBack: () -> Unit,+    onOpen: (HistoryEntry) -> Unit = {},+    onRequestClearHistory: () -> Unit = {},+) {+    AppScaffold(+        title = stringResource(R.string.history),+        isRefreshing = !hasLoaded,+        navigationIcon = { IconNavigation(onNavigateBack) },+        actions = {+            if (!historyEmpty) {+                IconButton(onClick = onRequestClearHistory) {+                    IconDelete()+                }+            }+        },+    ) { paddingValues ->+        DesktopMaxWidthContainer(modifier = Modifier.padding(paddingValues)) {+            if (!hasLoaded && historyEmpty) {+                Box(Modifier.fillMaxSize())+            } else if (historyEmpty) {+                EmptyState(+                    title = stringResource(R.string.no_history_yet),+                    modifier = Modifier.fillMaxSize(),+                )+            } else {+                LazyColumn(+                    modifier = Modifier.fillMaxSize(),+                    verticalArrangement = Arrangement.spacedBy(2.dp),+                ) {+                    grouped.forEach { (dateLabel, entries) ->+                        stickyHeader {+                            Text(+                                dateLabel,+                                style = MaterialTheme.typography.titleSmall,+                                color = MaterialTheme.colorScheme.onSurfaceVariant,+                                modifier = Modifier+                                    .fillMaxWidth()+                                    .background(MaterialTheme.colorScheme.surface)+                                    .padding(horizontal = 16.dp, vertical = 8.dp),+                            )+                        }+                        items(entries, key = { it.id }) { entry ->+                            HistoryRow(entry = entry, onClick = { onOpen(entry) })+                        }+                    }+                }+            }+        }+    }+}++@Composable+private fun HistoryRow(+    entry: HistoryEntry,+    onClick: () -> Unit,+) {+    Row(+        modifier = Modifier+            .fillMaxWidth()+            .clip(RoundedCornerShape(0.dp))+            .clickable(onClick = onClick)+            .padding(horizontal = 16.dp, vertical = 12.dp),+        verticalAlignment = Alignment.CenterVertically,+    ) {+        Column(Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(2.dp)) {+            Text(+                entry.title.ifBlank { entry.url },+                maxLines = 1,+                overflow = TextOverflow.Ellipsis,+                style = MaterialTheme.typography.bodyMedium,+            )+            Text(+                BrowserUtils.prettyUrl(entry.url),+                maxLines = 1,+                overflow = TextOverflow.Ellipsis,+                style = MaterialTheme.typography.bodySmall,+                color = MaterialTheme.colorScheme.onSurfaceVariant,+            )+        }+        Spacer(Modifier.width(8.dp))+        Text(+            formatHistoryTime(entry.visitedAt),+            style = MaterialTheme.typography.labelSmall,+            color = MaterialTheme.colorScheme.onSurfaceVariant,+        )+    }+}++private fun formatHistoryTime(millis: Long): String {+    return try {+        Instant.fromEpochMilliseconds(millis)+            .toLocalDateTime(TimeZone.currentSystemDefault()).time+            .format(LocalTime.Format { hour(); char(':'); minute() })+    } catch (_: Exception) {+        ""+    }+}
web/src/main/java/com/vayunmathur/web/ui/HistoryPage.kt
diff --git a/web/src/main/java/com/vayunmathur/web/ui/HistoryPage.kt b/web/src/main/java/com/vayunmathur/web/ui/HistoryPage.ktindex f88999351b..93b93e44c0 100644--- a/web/src/main/java/com/vayunmathur/web/ui/HistoryPage.kt+++ b/web/src/main/java/com/vayunmathur/web/ui/HistoryPage.kt@@ -1,200 +1,55 @@ package com.vayunmathur.web.ui -import androidx.compose.ui.res.stringResource-import com.vayunmathur.web.R import android.content.Context import android.text.format.DateFormat import android.text.format.DateUtils-import androidx.compose.ui.platform.LocalContext-import java.util.Date-import kotlin.time.Clock-import kotlin.time.Instant-import kotlinx.datetime.LocalDateTime-import kotlinx.datetime.LocalTime-import kotlinx.datetime.format-import kotlinx.datetime.format.char-import androidx.compose.foundation.ExperimentalFoundationApi-import androidx.compose.foundation.background-import androidx.compose.foundation.clickable-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.Spacer-import androidx.compose.foundation.layout.fillMaxSize-import androidx.compose.foundation.layout.fillMaxWidth-import androidx.compose.foundation.layout.padding-import androidx.compose.foundation.layout.width-import androidx.compose.foundation.lazy.LazyColumn-import androidx.compose.foundation.lazy.items-import androidx.compose.foundation.shape.RoundedCornerShape 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.Alignment-import androidx.compose.ui.Modifier-import androidx.compose.ui.draw.clip-import androidx.compose.ui.text.style.TextOverflow-import androidx.compose.ui.unit.dp+import androidx.compose.ui.platform.LocalContext import androidx.lifecycle.compose.collectAsStateWithLifecycle-import com.vayunmathur.library.ui.R as UiR-import com.vayunmathur.library.ui.AppScaffold-import com.vayunmathur.library.ui.ConfirmDialog-import com.vayunmathur.library.ui.DesktopMaxWidthContainer-import com.vayunmathur.library.ui.EmptyState-import com.vayunmathur.library.ui.AlertDialog-import com.vayunmathur.library.ui.ExperimentalMaterial3Api-import com.vayunmathur.library.ui.IconButton-import com.vayunmathur.library.ui.IconDelete-import com.vayunmathur.library.ui.MaterialTheme-import com.vayunmathur.library.ui.Text-import com.vayunmathur.library.ui.TextButton-import com.vayunmathur.web.Route import com.vayunmathur.library.util.NavBackStack+import com.vayunmathur.web.Route import com.vayunmathur.web.data.HistoryEntry-import com.vayunmathur.web.platform.BrowserUtils import com.vayunmathur.web.platform.WebViewModel-import com.vayunmathur.web.platform.clearHistory import com.vayunmathur.web.platform.externalIntentUrl+import java.util.Date+import kotlin.time.Instant import kotlinx.datetime.TimeZone import kotlinx.datetime.toLocalDateTime -@OptIn(ExperimentalMaterial3Api::class, ExperimentalFoundationApi::class)+/** History host: groups entries by date and renders [HistoryContent]. */ @Composable fun HistoryPage(     viewModel: WebViewModel,     backStack: NavBackStack<Route>,+    onRequestClearHistory: () -> Unit = { backStack.add(Route.ClearHistoryDialog) }, ) {     val history by viewModel.history.collectAsStateWithLifecycle()     val hasLoaded by viewModel.hasLoadedHistory.collectAsStateWithLifecycle()-    var showClearConfirm by remember { mutableStateOf(false) }-     val context = LocalContext.current     val grouped = remember(history, context) {-        groupByDate(context, history)+        groupHistoryByDate(context, history)     }--    AppScaffold(-        title = stringResource(R.string.history),-        isRefreshing = !hasLoaded,-        backStack = backStack,-        actions = {-            if (history.isNotEmpty()) {-                IconButton(onClick = { showClearConfirm = true }) {-                    IconDelete()-                }-            }+    HistoryContent(+        grouped = grouped,+        historyEmpty = history.isEmpty(),+        hasLoaded = hasLoaded,+        onNavigateBack = { backStack.pop() },+        onOpen = { entry ->+            viewModel.externalIntentUrl(entry.url)+            backStack.pop()         },-    ) { paddingValues ->-        DesktopMaxWidthContainer(modifier = Modifier.padding(paddingValues)) {-            if (!hasLoaded && history.isEmpty()) {-                Box(Modifier.fillMaxSize())-            } else if (history.isEmpty()) {-                EmptyState(-                    title = stringResource(R.string.no_history_yet),-                    modifier = Modifier.fillMaxSize(),-                )-            } else {-                LazyColumn(-                    modifier = Modifier.fillMaxSize(),-                    verticalArrangement = Arrangement.spacedBy(2.dp)-                ) {-                grouped.forEach { (dateLabel, entries) ->-                    stickyHeader {-                        Text(-                            dateLabel,-                            style = MaterialTheme.typography.titleSmall,-                            color = MaterialTheme.colorScheme.onSurfaceVariant,-                            modifier = Modifier-                                .fillMaxWidth()-                                .background(MaterialTheme.colorScheme.surface)-                                .padding(horizontal = 16.dp, vertical = 8.dp)-                        )-                    }-                    items(entries, key = { it.id }) { entry ->-                        HistoryRow(-                            entry = entry,-                            onClick = {-                                viewModel.externalIntentUrl(entry.url)-                                backStack.pop()-                            }-                        )-                    }-                }-                }-            }-        }-    }--    if (showClearConfirm) {-        ConfirmDialog(-            title = stringResource(R.string.clear_history),-            message = stringResource(R.string.this_will_permanently_delete_your_browsi),-            confirmLabel = stringResource(UiR.string.clear),-            dismissLabel = stringResource(UiR.string.cancel),-            onConfirm = { viewModel.clearHistory() },-            onDismiss = { showClearConfirm = false },-            destructive = true,-        )-    }-}--@Composable-private fun HistoryRow(-    entry: HistoryEntry,-    onClick: () -> Unit,-) {-    Row(-        modifier = Modifier-            .fillMaxWidth()-            .clip(RoundedCornerShape(0.dp))-            .clickable(onClick = onClick)-            .padding(horizontal = 16.dp, vertical = 12.dp),-        verticalAlignment = Alignment.CenterVertically-    ) {-        Column(Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(2.dp)) {-            Text(-                entry.title.ifBlank { entry.url },-                maxLines = 1,-                overflow = TextOverflow.Ellipsis,-                style = MaterialTheme.typography.bodyMedium-            )-            Text(-                BrowserUtils.prettyUrl(entry.url),-                maxLines = 1,-                overflow = TextOverflow.Ellipsis,-                style = MaterialTheme.typography.bodySmall,-                color = MaterialTheme.colorScheme.onSurfaceVariant-            )-        }-        Spacer(Modifier.width(8.dp))-        Text(-            formatTime(entry.visitedAt),-            style = MaterialTheme.typography.labelSmall,-            color = MaterialTheme.colorScheme.onSurfaceVariant-        )-    }-}--private fun formatTime(millis: Long): String {-    return try {-        Instant.fromEpochMilliseconds(millis)-            .toLocalDateTime(TimeZone.currentSystemDefault()).time-            .format(LocalTime.Format { hour(); char(':'); minute() })-    } catch (_: Exception) {-        ""-    }+        onRequestClearHistory = onRequestClearHistory,+    ) } -private fun groupByDate(context: Context, entries: List<HistoryEntry>): List<Pair<String, List<HistoryEntry>>> {+private fun groupHistoryByDate(context: Context, entries: List<HistoryEntry>): List<Pair<String, List<HistoryEntry>>> {     val tz = TimeZone.currentSystemDefault()     val now = Instant.fromEpochMilliseconds(System.currentTimeMillis()).toLocalDateTime(tz).date     return entries.groupBy { entry ->         val date = Instant.fromEpochMilliseconds(entry.visitedAt).toLocalDateTime(tz).date         when (now.toEpochDays() - date.toEpochDays()) {-            // DateUtils yields a localized "Today"/"Yesterday" in every locale Android ships.             0L, 1L -> DateUtils.getRelativeTimeSpanString(                 entry.visitedAt,                 System.currentTimeMillis(),
web/src/main/java/com/vayunmathur/web/ui/InstalledSitesContent.kt
diff --git a/web/src/main/java/com/vayunmathur/web/ui/InstalledSitesContent.kt b/web/src/main/java/com/vayunmathur/web/ui/InstalledSitesContent.ktnew file mode 100644index 0000000000..fe031394e4--- /dev/null+++ b/web/src/main/java/com/vayunmathur/web/ui/InstalledSitesContent.kt@@ -0,0 +1,116 @@+package com.vayunmathur.web.ui++import androidx.compose.foundation.clickable+import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.PaddingValues+import androidx.compose.foundation.layout.Row+import androidx.compose.foundation.layout.Spacer+import androidx.compose.foundation.layout.fillMaxSize+import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.layout.size+import androidx.compose.foundation.layout.width+import androidx.compose.foundation.lazy.LazyColumn+import androidx.compose.foundation.lazy.items+import androidx.compose.foundation.shape.CircleShape+import androidx.compose.foundation.shape.RoundedCornerShape+import androidx.compose.runtime.Composable+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.res.stringResource+import androidx.compose.ui.text.style.TextOverflow+import androidx.compose.ui.unit.dp+import com.vayunmathur.library.ui.AppScaffold+import com.vayunmathur.library.ui.Card+import com.vayunmathur.library.ui.CardDefaults+import com.vayunmathur.library.ui.DesktopMaxWidthContainer+import com.vayunmathur.library.ui.ExperimentalMaterial3Api+import com.vayunmathur.library.ui.IconButton+import com.vayunmathur.library.ui.IconClose+import com.vayunmathur.library.ui.IconNavigation+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.Surface+import com.vayunmathur.library.ui.Text+import com.vayunmathur.web.R+import com.vayunmathur.web.data.InstalledSite+import com.vayunmathur.web.platform.BrowserUtils++/**+ * Stateless installed-sites (PWA) body. Split out of the installed-sites+ * page so screenshot captures render it from literal sites.+ */+@OptIn(ExperimentalMaterial3Api::class)+@Composable+fun InstalledSitesContent(+    installed: List<InstalledSite>,+    onNavigateBack: () -> Unit,+    onOpenSite: (InstalledSite) -> Unit = {},+    onRemoveSite: (InstalledSite) -> Unit = {},+) {+    AppScaffold(+        title = stringResource(R.string.installed_apps),+        navigationIcon = { IconNavigation(onNavigateBack) },+    ) { paddingValues ->+        DesktopMaxWidthContainer(modifier = Modifier.padding(paddingValues)) {+            if (installed.isEmpty()) {+                Box(+                    Modifier.fillMaxSize().padding(24.dp),+                    contentAlignment = Alignment.Center,+                ) {+                    Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {+                        Text(stringResource(R.string.no_installed_apps), style = MaterialTheme.typography.titleMedium)+                        Text(+                            stringResource(R.string.open_a_site_and_tap_menu_install_app_add),+                            style = MaterialTheme.typography.bodyMedium,+                            color = MaterialTheme.colorScheme.onSurfaceVariant,+                        )+                    }+                }+            } else {+                LazyColumn(+                    modifier = Modifier.fillMaxSize(),+                    contentPadding = PaddingValues(12.dp),+                    verticalArrangement = Arrangement.spacedBy(10.dp),+                ) {+                    items(installed, key = { it.id }) { site ->+                        Card(+                            shape = RoundedCornerShape(16.dp),+                            colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surfaceVariant),+                            modifier = Modifier.fillMaxWidth(),+                        ) {+                            Row(+                                Modifier.fillMaxWidth().clickable { onOpenSite(site) }.padding(14.dp),+                                verticalAlignment = Alignment.CenterVertically,+                            ) {+                                Surface(shape = CircleShape, color = MaterialTheme.colorScheme.secondaryContainer, modifier = Modifier.size(40.dp)) {+                                    Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {+                                        Text(site.title.take(1).uppercase().ifBlank { "W" }, style = MaterialTheme.typography.titleSmall)+                                    }+                                }+                                Spacer(Modifier.width(12.dp))+                                Column(Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(2.dp)) {+                                    Text(site.title, maxLines = 1, overflow = TextOverflow.Ellipsis, style = MaterialTheme.typography.titleSmall)+                                    Text(BrowserUtils.prettyUrl(site.url), maxLines = 1, overflow = TextOverflow.Ellipsis, style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant)+                                    if (site.iconUrl != null) {+                                        Text(stringResource(R.string.icon, site.iconUrl.take(56)), maxLines = 1, overflow = TextOverflow.Ellipsis, style = MaterialTheme.typography.labelSmall, color = MaterialTheme.colorScheme.onSurfaceVariant)+                                    }+                                }+                                IconButton(onClick = { onRemoveSite(site) }) { IconClose() }+                            }+                        }+                    }+                    item {+                        Text(+                            stringResource(R.string.shortcuts_launch_pwaactivity_standalone),+                            style = MaterialTheme.typography.bodySmall,+                            color = MaterialTheme.colorScheme.onSurfaceVariant,+                            modifier = Modifier.padding(8.dp),+                        )+                    }+                }+            }+        }+    }+}
web/src/main/java/com/vayunmathur/web/ui/InstalledSitesPage.kt
diff --git a/web/src/main/java/com/vayunmathur/web/ui/InstalledSitesPage.kt b/web/src/main/java/com/vayunmathur/web/ui/InstalledSitesPage.ktindex bf4a396a1c..bb65809114 100644--- a/web/src/main/java/com/vayunmathur/web/ui/InstalledSitesPage.kt+++ b/web/src/main/java/com/vayunmathur/web/ui/InstalledSitesPage.kt@@ -1,53 +1,16 @@ package com.vayunmathur.web.ui -import androidx.compose.ui.res.stringResource-import com.vayunmathur.web.R-import androidx.compose.foundation.clickable-import androidx.compose.foundation.layout.Arrangement-import androidx.compose.foundation.layout.Box-import androidx.compose.foundation.layout.Column-import androidx.compose.foundation.layout.PaddingValues-import androidx.compose.foundation.layout.Row-import androidx.compose.foundation.layout.Spacer-import androidx.compose.foundation.layout.fillMaxSize-import androidx.compose.foundation.layout.fillMaxWidth-import androidx.compose.foundation.layout.padding-import androidx.compose.foundation.layout.size-import androidx.compose.foundation.layout.width-import androidx.compose.foundation.lazy.LazyColumn-import androidx.compose.foundation.lazy.items-import androidx.compose.foundation.shape.CircleShape-import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue-import androidx.compose.ui.Alignment-import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext-import androidx.compose.ui.text.style.TextOverflow-import androidx.compose.ui.unit.dp import androidx.lifecycle.compose.collectAsStateWithLifecycle-import com.vayunmathur.library.ui.AppScaffold-import com.vayunmathur.library.ui.Card-import com.vayunmathur.library.ui.CardDefaults-import com.vayunmathur.library.ui.DesktopMaxWidthContainer-import com.vayunmathur.library.ui.ExperimentalMaterial3Api-import com.vayunmathur.library.ui.IconButton-import com.vayunmathur.library.ui.IconClose-import com.vayunmathur.library.ui.IconNavigation-import com.vayunmathur.library.ui.MaterialTheme-import com.vayunmathur.library.ui.Scaffold-import com.vayunmathur.library.ui.Surface-import com.vayunmathur.library.ui.Text-import com.vayunmathur.library.ui.TopAppBar-import com.vayunmathur.web.Route import com.vayunmathur.library.util.NavBackStack-import com.vayunmathur.web.platform.BrowserUtils+import com.vayunmathur.web.Route import com.vayunmathur.web.platform.PwaHelper import com.vayunmathur.web.platform.WebViewModel import com.vayunmathur.web.platform.removeInstalledSite --@OptIn(ExperimentalMaterial3Api::class)+/** Installed-sites host: collects PWAs and renders [InstalledSitesContent]. */ @Composable fun InstalledSitesPage(     viewModel: WebViewModel,@@ -55,79 +18,15 @@ fun InstalledSitesPage( ) {     val context = LocalContext.current     val installed by viewModel.installedSites.collectAsStateWithLifecycle()--    AppScaffold(-        title = stringResource(R.string.installed_apps),-        backStack = backStack,-    ) { paddingValues ->-        DesktopMaxWidthContainer(modifier = Modifier.padding(paddingValues)) {-        if (installed.isEmpty()) {-            Box(-                Modifier-                    .fillMaxSize()-                    .padding(24.dp),-                contentAlignment = Alignment.Center-            ) {-                Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {-                    Text(stringResource(R.string.no_installed_apps), style = MaterialTheme.typography.titleMedium)-                    Text(-                        stringResource(R.string.open_a_site_and_tap_menu_install_app_add),-                        style = MaterialTheme.typography.bodyMedium,-                        color = MaterialTheme.colorScheme.onSurfaceVariant-                    )-                }-            }-        } else {-            LazyColumn(-                modifier = Modifier.fillMaxSize(),-                contentPadding = PaddingValues(12.dp),-                verticalArrangement = Arrangement.spacedBy(10.dp)-            ) {-                items(installed, key = { it.id }) { site ->-                    Card(-                        shape = RoundedCornerShape(16.dp),-                        colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surfaceVariant),-                        modifier = Modifier.fillMaxWidth()-                    ) {-                        Row(-                            Modifier-                                .fillMaxWidth()-                                .clickable {-                                    try {-                                        val intent = PwaHelper.createPwaIntent(context, site.url, site.title)-                                        context.startActivity(intent)-                                    } catch (_: Exception) {}-                                }-                                .padding(14.dp),-                            verticalAlignment = Alignment.CenterVertically-                        ) {-                            Surface(shape = CircleShape, color = MaterialTheme.colorScheme.secondaryContainer, modifier = Modifier.size(40.dp)) {-                                Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {-                                    Text(site.title.take(1).uppercase().ifBlank { "W" }, style = MaterialTheme.typography.titleSmall)-                                }-                            }-                            Spacer(Modifier.width(12.dp))-                            Column(Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(2.dp)) {-                                Text(site.title, maxLines = 1, overflow = TextOverflow.Ellipsis, style = MaterialTheme.typography.titleSmall)-                                Text(BrowserUtils.prettyUrl(site.url), maxLines = 1, overflow = TextOverflow.Ellipsis, style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant)-                                if (site.iconUrl != null) {-                                    Text(stringResource(R.string.icon, site.iconUrl.take(56)), maxLines = 1, overflow = TextOverflow.Ellipsis, style = MaterialTheme.typography.labelSmall, color = MaterialTheme.colorScheme.onSurfaceVariant)-                                }-                            }-                            IconButton(onClick = { viewModel.removeInstalledSite(site.id) }) { IconClose() }-                        }-                    }-                }-                item {-                    Text(-                        stringResource(R.string.shortcuts_launch_pwaactivity_standalone),-                        style = MaterialTheme.typography.bodySmall,-                        color = MaterialTheme.colorScheme.onSurfaceVariant,-                        modifier = Modifier.padding(8.dp)-                    )-                }-            }-        }-        }-    }+    InstalledSitesContent(+        installed = installed,+        onNavigateBack = { backStack.pop() },+        onOpenSite = { site ->+            try {+                val intent = PwaHelper.createPwaIntent(context, site.url, site.title)+                context.startActivity(intent)+            } catch (_: Exception) {}+        },+        onRemoveSite = { site -> viewModel.removeInstalledSite(site.id) },+    ) }
web/src/main/java/com/vayunmathur/web/ui/PermissionSheets.kt
diff --git a/web/src/main/java/com/vayunmathur/web/ui/PermissionSheets.kt b/web/src/main/java/com/vayunmathur/web/ui/PermissionSheets.ktindex 2d5790f6d0..ae14c41522 100644--- a/web/src/main/java/com/vayunmathur/web/ui/PermissionSheets.kt+++ b/web/src/main/java/com/vayunmathur/web/ui/PermissionSheets.kt@@ -159,112 +159,12 @@ internal fun SiteDataPage( ) {     val storages by viewModel.storageInfos.collectAsStateWithLifecycle()     val permissions by viewModel.sitePermissions.collectAsStateWithLifecycle()--    LazyListScaffold(-        horizontalPadding = 12.dp,-        verticalArrangement = Arrangement.spacedBy(10.dp),-        topBar = {-            TopAppBar(-                title = { Text(stringResource(R.string.site_data)) },-                navigationIcon = { IconNavigation(backStack) },-                actions = {-                    if (storages.isNotEmpty() || permissions.isNotEmpty()) {-                        IconButton(onClick = { viewModel.clearAllSiteData() }) { IconDelete() }-                    }-                },-            )-        },-    ) {-        if (storages.isEmpty() && permissions.isEmpty()) {-            item {-                Text(-                    stringResource(R.string.no_site_data_yet_cookies_localstorage_in),-                    style = MaterialTheme.typography.bodyMedium,-                    color = MaterialTheme.colorScheme.onSurfaceVariant-                )-            }-        }--        if (storages.isNotEmpty()) {-            item { Text(stringResource(R.string.storage), style = MaterialTheme.typography.titleMedium) }-            items(storages, key = { "storage-${it.id}" }) { info ->-                StorageInfoCard(info, viewModel)-            }-        }--        if (permissions.isNotEmpty()) {-            item {-                Spacer(Modifier.height(8.dp))-                Text(stringResource(R.string.permissions), style = MaterialTheme.typography.titleMedium)-            }-            items(permissions, key = { "perm-${it.id}" }) { perm ->-                PermissionInfoCard(perm, viewModel)-            }-        }-    }-}--@OptIn(ExperimentalLayoutApi::class)-@Composable-private fun StorageInfoCard(info: StorageInfo, viewModel: WebViewModel) {-    Card(-        shape = RoundedCornerShape(16.dp),-        colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surfaceVariant),-        modifier = Modifier.fillMaxWidth()-    ) {-        Column(Modifier.padding(14.dp), verticalArrangement = Arrangement.spacedBy(6.dp)) {-            Row(verticalAlignment = Alignment.CenterVertically) {-                Column(Modifier.weight(1f)) {-                    Text(info.host, style = MaterialTheme.typography.titleSmall, maxLines = 1, overflow = TextOverflow.Ellipsis)-                    Text(info.origin, style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant, maxLines = 1, overflow = TextOverflow.Ellipsis)-                }-                IconButton(onClick = { viewModel.clearSiteData(info.origin) }) { IconClose() }-            }-            FlowRow(horizontalArrangement = Arrangement.spacedBy(8.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) {-                if (info.cookieCount > 0) ChipBadge("${info.cookieCount} cookies")-                if (info.hasLocalStorage) ChipBadge("localStorage")-                if (info.hasIndexedDb) ChipBadge("IndexedDB")-                if (info.hasServiceWorker) ChipBadge("ServiceWorker")-                if (info.estimatedBytes > 0) ChipBadge("${info.estimatedBytes / 1024} KB")-            }-        }-    }-}--@Composable-private fun PermissionInfoCard(perm: SitePermission, viewModel: WebViewModel) {-    Card(-        shape = RoundedCornerShape(16.dp),-        colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surfaceVariant),-        modifier = Modifier.fillMaxWidth()-    ) {-        Column(Modifier.padding(14.dp), verticalArrangement = Arrangement.spacedBy(6.dp)) {-            Text(BrowserUtils.hostFromUrl(perm.origin), style = MaterialTheme.typography.titleSmall)-            Column(verticalArrangement = Arrangement.spacedBy(2.dp)) {-                PermRow("Camera", perm.cameraAllowed) { viewModel.revokePermission(perm.origin, SitePermissionType.CAMERA) }-                PermRow("Microphone", perm.microphoneAllowed) { viewModel.revokePermission(perm.origin, SitePermissionType.MICROPHONE) }-                PermRow("Location", perm.locationAllowed) { viewModel.revokePermission(perm.origin, SitePermissionType.LOCATION) }-                PermRow("Notifications", perm.notificationsAllowed) { viewModel.revokePermission(perm.origin, SitePermissionType.NOTIFICATIONS) }-            }-            if (perm.cameraAllowed == null && perm.microphoneAllowed == null && perm.locationAllowed == null && perm.notificationsAllowed == null) {-                Text(stringResource(R.string.no_permissions_set), style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant)-            }-        }-    }-}--@Composable-private fun PermRow(label: String, allowed: Boolean?, onClear: () -> Unit) {-    if (allowed == null) return-    Row(verticalAlignment = Alignment.CenterVertically) {-        Text("$label: ${if (allowed) "Allowed" else "Blocked"}", style = MaterialTheme.typography.bodySmall, modifier = Modifier.weight(1f))-        TextButton(onClick = onClear) { Text(stringResource(UiR.string.clear)) }-    }-}--@Composable-private fun ChipBadge(text: String) {-    Surface(shape = RoundedCornerShape(20.dp), color = MaterialTheme.colorScheme.secondaryContainer) {-        Text(text, style = MaterialTheme.typography.labelSmall, modifier = Modifier.padding(horizontal = 8.dp, vertical = 4.dp))-    }+    SiteDataContent(+        storages = storages,+        permissions = permissions,+        onNavigateBack = { backStack.pop() },+        onClearAll = { viewModel.clearAllSiteData() },+        onClearStorage = { viewModel.clearSiteData(it) },+        onRevokePermission = { origin, type -> viewModel.revokePermission(origin, type) },+    ) }
web/src/main/java/com/vayunmathur/web/ui/SettingsContent.kt
diff --git a/web/src/main/java/com/vayunmathur/web/ui/SettingsContent.kt b/web/src/main/java/com/vayunmathur/web/ui/SettingsContent.ktnew file mode 100644index 0000000000..5a3f606b71--- /dev/null+++ b/web/src/main/java/com/vayunmathur/web/ui/SettingsContent.kt@@ -0,0 +1,171 @@+package com.vayunmathur.web.ui++import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.fillMaxSize+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.lazy.LazyColumn+import androidx.compose.runtime.Composable+import androidx.compose.ui.Modifier+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.DesktopMaxWidthContainer+import com.vayunmathur.library.ui.ExperimentalMaterial3Api+import com.vayunmathur.library.ui.HorizontalDivider+import com.vayunmathur.library.ui.IconNavigation+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.SettingsRow+import com.vayunmathur.library.ui.SettingsSwitchRow+import com.vayunmathur.library.ui.Text+import com.vayunmathur.library.ui.R as UiR+import com.vayunmathur.web.R+import com.vayunmathur.web.domain.ShieldLevel++/**+ * Stateless browser-settings body. Split out of [SettingsPage] so+ * screenshot captures render it from literal values.+ */+@OptIn(ExperimentalMaterial3Api::class)+@Composable+fun SettingsContent(+    searchEngineLabel: String,+    cacheModeLabel: String,+    shieldsLevel: ShieldLevel?,+    searchBarAtBottom: Boolean,+    jsEnabled: Boolean,+    blockThirdPartyCookies: Boolean,+    desktopMode: Boolean,+    historyCount: Int,+    downloadCount: Int,+    storageCount: Int,+    permissionCount: Int,+    installedCount: Int,+    onNavigateBack: () -> Unit,+    onRequestSearchEngine: () -> Unit = {},+    onRequestCacheMode: () -> Unit = {},+    onSearchBarAtBottomChange: (Boolean) -> Unit = {},+    onJsEnabledChange: (Boolean) -> Unit = {},+    onBlockThirdPartyChange: (Boolean) -> Unit = {},+    onDesktopModeChange: (Boolean) -> Unit = {},+    onOpenShields: () -> Unit = {},+    onRequestClearBrowsingData: () -> Unit = {},+    onOpenSiteData: () -> Unit = {},+    onOpenHistory: () -> Unit = {},+    onOpenDownloads: () -> Unit = {},+    onOpenInstalledSites: () -> Unit = {},+) {+    AppScaffold(+        title = stringResource(UiR.string.settings),+        navigationIcon = { IconNavigation(onNavigateBack) },+    ) { paddingValues ->+        DesktopMaxWidthContainer(modifier = Modifier.padding(paddingValues)) {+            LazyColumn(+                modifier = Modifier.fillMaxSize(),+                verticalArrangement = Arrangement.spacedBy(0.dp),+            ) {+                item {+                    Text(stringResource(R.string.general), style = MaterialTheme.typography.titleSmall, color = MaterialTheme.colorScheme.primary, modifier = Modifier.padding(horizontal = 16.dp, vertical = 12.dp))+                }+                item {+                    SettingsRow(+                        title = stringResource(R.string.search_engine),+                        supportingText = searchEngineLabel,+                        onClick = onRequestSearchEngine,+                    )+                }+                item {+                    SettingsRow(+                        title = stringResource(R.string.cache_mode),+                        supportingText = cacheModeLabel,+                        onClick = onRequestCacheMode,+                    )+                }+                item {+                    SettingsSwitchRow(+                        title = stringResource(R.string.toolbar_at_bottom),+                        supportingText = stringResource(R.string.keeps_the_address_bar_within_thumb_reach),+                        checked = searchBarAtBottom,+                        onCheckedChange = onSearchBarAtBottomChange,+                    )+                }+                item {+                    SettingsSwitchRow(+                        title = stringResource(R.string.javascript),+                        supportingText = stringResource(R.string.required_by_most_sites),+                        checked = jsEnabled,+                        onCheckedChange = onJsEnabledChange,+                    )+                }+                item {+                    SettingsSwitchRow(+                        title = stringResource(R.string.block_third_party_cookies),+                        supportingText = stringResource(R.string.may_break_logins),+                        checked = blockThirdPartyCookies,+                        onCheckedChange = onBlockThirdPartyChange,+                    )+                }+                item {+                    SettingsSwitchRow(+                        title = stringResource(R.string.desktop_mode),+                        supportingText = stringResource(R.string.request_desktop_site),+                        checked = desktopMode,+                        onCheckedChange = onDesktopModeChange,+                    )+                }+                item {+                    SettingsRow(+                        title = stringResource(R.string.shields),+                        supportingText = stringResource(+                            when (shieldsLevel) {+                                ShieldLevel.OFF -> R.string.shields_level_off_desc+                                ShieldLevel.STANDARD -> R.string.shields_level_standard_desc+                                else -> R.string.shields_level_aggressive_desc+                            },+                        ),+                        onClick = onOpenShields,+                    )+                }+                item { HorizontalDivider(Modifier.padding(vertical = 8.dp)) }+                item {+                    Text(stringResource(R.string.privacy_data), style = MaterialTheme.typography.titleSmall, color = MaterialTheme.colorScheme.primary, modifier = Modifier.padding(horizontal = 16.dp, vertical = 12.dp))+                }+                item {+                    SettingsRow(+                        title = stringResource(R.string.clear_browsing_data),+                        supportingText = stringResource(R.string.cookies_cache_history_storage_permission),+                        onClick = onRequestClearBrowsingData,+                    )+                }+                item {+                    SettingsRow(+                        title = stringResource(R.string.site_data),+                        supportingText = stringResource(R.string.sites_permission_grants, storageCount, permissionCount),+                        onClick = onOpenSiteData,+                    )+                }+                item {+                    SettingsRow(+                        title = stringResource(R.string.history),+                        supportingText = pluralStringResource(R.plurals.entries, historyCount, historyCount),+                        onClick = onOpenHistory,+                    )+                }+                item {+                    SettingsRow(+                        title = stringResource(R.string.downloads),+                        supportingText = pluralStringResource(R.plurals.files, downloadCount, downloadCount),+                        onClick = onOpenDownloads,+                    )+                }+                item {+                    SettingsRow(+                        title = stringResource(R.string.installed_apps),+                        supportingText = pluralStringResource(R.plurals.pwas, installedCount, installedCount),+                        onClick = onOpenInstalledSites,+                    )+                }+            }+        }+    }+}
web/src/main/java/com/vayunmathur/web/ui/SettingsPage.kt
diff --git a/web/src/main/java/com/vayunmathur/web/ui/SettingsPage.kt b/web/src/main/java/com/vayunmathur/web/ui/SettingsPage.ktindex 63516fcacf..d85810b367 100644--- a/web/src/main/java/com/vayunmathur/web/ui/SettingsPage.kt+++ b/web/src/main/java/com/vayunmathur/web/ui/SettingsPage.kt@@ -1,240 +1,55 @@ package com.vayunmathur.web.ui -import androidx.compose.ui.res.pluralStringResource-import androidx.compose.ui.res.stringResource-import com.vayunmathur.web.R-import android.webkit.CookieManager-import android.webkit.WebStorage-import android.webkit.WebView-import androidx.compose.foundation.layout.Arrangement-import androidx.compose.foundation.layout.fillMaxSize-import androidx.compose.foundation.layout.fillMaxWidth-import androidx.compose.foundation.layout.padding-import androidx.compose.foundation.lazy.LazyColumn 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.platform.LocalContext-import androidx.compose.ui.unit.dp import androidx.lifecycle.compose.collectAsStateWithLifecycle-import com.vayunmathur.library.ui.R as UiR-import com.vayunmathur.library.ui.AppScaffold-import com.vayunmathur.library.ui.DesktopMaxWidthContainer-import com.vayunmathur.library.ui.ExperimentalMaterial3Api-import com.vayunmathur.library.ui.HorizontalDivider-import com.vayunmathur.library.ui.IconNavigation-import com.vayunmathur.library.ui.MaterialTheme-import com.vayunmathur.library.ui.ConfirmDialog-import com.vayunmathur.library.ui.SettingsRow-import com.vayunmathur.library.ui.SingleChoiceDialog-import com.vayunmathur.library.ui.SettingsSwitchRow-import com.vayunmathur.library.ui.Scaffold-import com.vayunmathur.library.ui.Text-import com.vayunmathur.library.ui.TopAppBar-import com.vayunmathur.web.Route import com.vayunmathur.library.util.NavBackStack-import com.vayunmathur.web.platform.CacheMode-import com.vayunmathur.web.platform.SearchEngine+import com.vayunmathur.web.Route import com.vayunmathur.web.platform.WebViewModel-import com.vayunmathur.web.platform.clearAllDownloads-import com.vayunmathur.web.platform.clearAllSiteData-import com.vayunmathur.web.platform.clearHistory import com.vayunmathur.web.platform.updateBlockThirdParty-import com.vayunmathur.web.platform.updateCacheMode import com.vayunmathur.web.platform.updateDesktopMode import com.vayunmathur.web.platform.updateJsEnabled import com.vayunmathur.web.platform.updateSearchBarAtBottom-import com.vayunmathur.web.platform.updateSearchEngine -@OptIn(ExperimentalMaterial3Api::class)+/** Settings host: collects counts and renders [SettingsContent]. */ @Composable fun SettingsPage(     viewModel: WebViewModel,     backStack: NavBackStack<Route>,+    onRequestClearBrowsingData: () -> Unit = { backStack.add(Route.ClearBrowsingDataDialog) },+    onRequestCacheMode: () -> Unit = { backStack.add(Route.CacheModeDialog) },+    onRequestSearchEngine: () -> Unit = { backStack.add(Route.SearchEngineDialog) }, ) {-    val context = LocalContext.current-    var showClearDataDialog by remember { mutableStateOf(false) }-    var showCacheDialog by remember { mutableStateOf(false) }-    var showSearchEngineDialog by remember { mutableStateOf(false) }-     val historyEntries by viewModel.history.collectAsStateWithLifecycle()     val downloadEntries by viewModel.downloads.collectAsStateWithLifecycle()     val storageCount by viewModel.storageInfos.collectAsStateWithLifecycle()     val permCount by viewModel.sitePermissions.collectAsStateWithLifecycle()     val installedCount by viewModel.installedSites.collectAsStateWithLifecycle()--    AppScaffold(-        title = stringResource(UiR.string.settings),-        backStack = backStack,-    ) { paddingValues ->-        DesktopMaxWidthContainer(modifier = Modifier.padding(paddingValues)) {-        LazyColumn(-            modifier = Modifier.fillMaxSize(),-            verticalArrangement = Arrangement.spacedBy(0.dp)-        ) {-            item {-                Text(stringResource(R.string.general), style = MaterialTheme.typography.titleSmall, color = MaterialTheme.colorScheme.primary, modifier = Modifier.padding(horizontal = 16.dp, vertical = 12.dp))-            }--            item {-                SettingsRow(-                    title = stringResource(R.string.search_engine),-                    supportingText = viewModel.searchEngine.displayName,-                    onClick = { showSearchEngineDialog = true },-                )-            }--            item {-                SettingsRow(-                    title = stringResource(R.string.cache_mode),-                    supportingText = "${viewModel.cacheMode.title} — ${viewModel.cacheMode.description}",-                    onClick = { showCacheDialog = true },-                )-            }--            item {-                SettingsSwitchRow(-                    title = stringResource(R.string.toolbar_at_bottom),-                    supportingText = stringResource(R.string.keeps_the_address_bar_within_thumb_reach),-                    checked = viewModel.searchBarAtBottom,-                    onCheckedChange = { viewModel.updateSearchBarAtBottom(it) },-                )-            }--            item {-                SettingsSwitchRow(-                    title = stringResource(R.string.javascript),-                    supportingText = stringResource(R.string.required_by_most_sites),-                    checked = viewModel.jsEnabled,-                    onCheckedChange = { viewModel.updateJsEnabled(it) },-                )-            }--            item {-                SettingsSwitchRow(-                    title = stringResource(R.string.block_third_party_cookies),-                    supportingText = stringResource(R.string.may_break_logins),-                    checked = viewModel.blockThirdPartyCookies,-                    onCheckedChange = { viewModel.updateBlockThirdParty(it) },-                )-            }--            item {-                SettingsSwitchRow(-                    title = stringResource(R.string.desktop_mode),-                    supportingText = stringResource(R.string.request_desktop_site),-                    checked = viewModel.desktopMode,-                    onCheckedChange = { viewModel.updateDesktopMode(it) },-                )-            }--            item {-                SettingsRow(-                    title = stringResource(R.string.shields),-                    supportingText = stringResource(-                        when (viewModel.shields.level) {-                            com.vayunmathur.web.domain.ShieldLevel.OFF -> R.string.shields_level_off_desc-                            com.vayunmathur.web.domain.ShieldLevel.STANDARD -> R.string.shields_level_standard_desc-                            else -> R.string.shields_level_aggressive_desc-                        }-                    ),-                    onClick = { backStack.add(Route.Shields) },-                )-            }--            item { HorizontalDivider(Modifier.padding(vertical = 8.dp)) }--            item {-                Text(stringResource(R.string.privacy_data), style = MaterialTheme.typography.titleSmall, color = MaterialTheme.colorScheme.primary, modifier = Modifier.padding(horizontal = 16.dp, vertical = 12.dp))-            }--            item {-                SettingsRow(-                    title = stringResource(R.string.clear_browsing_data),-                    supportingText = stringResource(R.string.cookies_cache_history_storage_permission),-                    onClick = { showClearDataDialog = true },-                )-            }--            item {-                SettingsRow(-                    title = stringResource(R.string.site_data),-                    supportingText = stringResource(R.string.sites_permission_grants, storageCount.size, permCount.size),-                    onClick = { backStack.add(Route.SiteData) },-                )-            }--            item {-                SettingsRow(-                    title = stringResource(R.string.history),-                    supportingText = pluralStringResource(R.plurals.entries, historyEntries.size, historyEntries.size),-                    onClick = { backStack.add(Route.History) },-                )-            }--            item {-                SettingsRow(-                    title = stringResource(R.string.downloads),-                    supportingText = pluralStringResource(R.plurals.files, downloadEntries.size, downloadEntries.size),-                    onClick = { backStack.add(Route.Downloads) },-                )-            }--            item {-                SettingsRow(-                    title = stringResource(R.string.installed_apps),-                    supportingText = pluralStringResource(R.plurals.pwas, installedCount.size, installedCount.size),-                    onClick = { backStack.add(Route.InstalledSites) },-                )-            }--        }-        }-    }--    if (showCacheDialog) {-        SingleChoiceDialog(-            title = stringResource(R.string.cache_mode),-            options = CacheMode.entries,-            selected = viewModel.cacheMode,-            label = { it.title },-            supportingLabel = { it.description },-            onSelect = { viewModel.updateCacheMode(it) },-            onDismiss = { showCacheDialog = false },-        )-    }--    if (showSearchEngineDialog) {-        SingleChoiceDialog(-            title = stringResource(R.string.search_engine),-            options = SearchEngine.PICKABLE,-            selected = viewModel.searchEngine,-            label = { it.displayName },-            supportingLabel = { it.homepage },-            onSelect = { viewModel.updateSearchEngine(it) },-            onDismiss = { showSearchEngineDialog = false },-        )-    }--    if (showClearDataDialog) {-        ConfirmDialog(-            title = stringResource(R.string.clear_browsing_data_2),-            message = stringResource(R.string.clears_cookies_cache_storage_history_dow),-            confirmLabel = stringResource(UiR.string.clear),-            dismissLabel = stringResource(UiR.string.cancel),-            destructive = true,-            onConfirm = {-                try { CookieManager.getInstance().removeAllCookies(null); CookieManager.getInstance().flush() } catch (_: Exception) {}-                try { WebStorage.getInstance().deleteAllData() } catch (_: Exception) {}-                try { WebView(context).clearCache(true) } catch (_: Exception) {}-                viewModel.clearHistory()-                viewModel.clearAllDownloads()-                viewModel.clearAllSiteData()-            },-            onDismiss = { showClearDataDialog = false },-        )-    }+    SettingsContent(+        searchEngineLabel = viewModel.searchEngine.displayName,+        cacheModeLabel = "${viewModel.cacheMode.title} — ${viewModel.cacheMode.description}",+        shieldsLevel = viewModel.shields.level,+        searchBarAtBottom = viewModel.searchBarAtBottom,+        jsEnabled = viewModel.jsEnabled,+        blockThirdPartyCookies = viewModel.blockThirdPartyCookies,+        desktopMode = viewModel.desktopMode,+        historyCount = historyEntries.size,+        downloadCount = downloadEntries.size,+        storageCount = storageCount.size,+        permissionCount = permCount.size,+        installedCount = installedCount.size,+        onNavigateBack = { backStack.pop() },+        onRequestSearchEngine = onRequestSearchEngine,+        onRequestCacheMode = onRequestCacheMode,+        onSearchBarAtBottomChange = { viewModel.updateSearchBarAtBottom(it) },+        onJsEnabledChange = { viewModel.updateJsEnabled(it) },+        onBlockThirdPartyChange = { viewModel.updateBlockThirdParty(it) },+        onDesktopModeChange = { viewModel.updateDesktopMode(it) },+        onOpenShields = { backStack.add(Route.Shields) },+        onRequestClearBrowsingData = onRequestClearBrowsingData,+        onOpenSiteData = { backStack.add(Route.SiteData) },+        onOpenHistory = { backStack.add(Route.History) },+        onOpenDownloads = { backStack.add(Route.Downloads) },+        onOpenInstalledSites = { backStack.add(Route.InstalledSites) },+    ) }
web/src/main/java/com/vayunmathur/web/ui/ShieldsContent.kt
diff --git a/web/src/main/java/com/vayunmathur/web/ui/ShieldsContent.kt b/web/src/main/java/com/vayunmathur/web/ui/ShieldsContent.ktnew file mode 100644index 0000000000..24485e6c03--- /dev/null+++ b/web/src/main/java/com/vayunmathur/web/ui/ShieldsContent.kt@@ -0,0 +1,182 @@+package com.vayunmathur.web.ui++import androidx.compose.foundation.clickable+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.Row+import androidx.compose.foundation.layout.Spacer+import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.layout.width+import androidx.compose.foundation.lazy.LazyColumn+import androidx.compose.foundation.lazy.items+import androidx.compose.foundation.shape.RoundedCornerShape+import androidx.compose.runtime.Composable+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.res.stringResource+import androidx.compose.ui.unit.dp+import com.vayunmathur.library.ui.AppScaffold+import com.vayunmathur.library.ui.ExperimentalMaterial3Api+import com.vayunmathur.library.ui.HorizontalDivider+import com.vayunmathur.library.ui.IconNavigation+import com.vayunmathur.library.ui.ListItem+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.RadioButton+import com.vayunmathur.library.ui.Surface+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.web.R+import com.vayunmathur.web.data.ShieldSetting+import com.vayunmathur.web.domain.EffectiveShields+import com.vayunmathur.web.domain.ShieldLevel+import com.vayunmathur.web.domain.ShieldsSettings++/**+ * Stateless shields settings body: global defaults plus site exceptions.+ * Split out of the shields page so screenshot captures render it from+ * literal settings.+ */+@OptIn(ExperimentalMaterial3Api::class)+@Composable+fun ShieldsContent(+    global: ShieldsSettings,+    overrides: List<ShieldSetting>,+    onNavigateBack: () -> Unit,+    onUpdateGlobal: (ShieldsSettings) -> Unit = {},+    onResetOverride: (String) -> Unit = {},+    onClearOverrides: () -> Unit = {},+) {+    AppScaffold(+        title = stringResource(R.string.shields),+        navigationIcon = { IconNavigation(onNavigateBack) },+    ) { padding ->+        LazyColumn(Modifier.padding(padding)) {+            item {+                Text(+                    stringResource(R.string.shields_level),+                    style = MaterialTheme.typography.titleSmall,+                    color = MaterialTheme.colorScheme.primary,+                    modifier = Modifier.padding(horizontal = 16.dp, vertical = 12.dp),+                )+            }+            items(ShieldLevel.entries) { level ->+                Row(+                    Modifier.fillMaxWidth().clickable { onUpdateGlobal(global.copy(level = level)) }+                        .padding(horizontal = 16.dp, vertical = 10.dp),+                    verticalAlignment = Alignment.CenterVertically,+                ) {+                    RadioButton(+                        selected = global.level == level,+                        onClick = { onUpdateGlobal(global.copy(level = level)) },+                    )+                    Spacer(Modifier.width(12.dp))+                    Column {+                        Text(stringResource(shieldLevelTitleRes(level)), style = MaterialTheme.typography.bodyMedium)+                        Text(+                            stringResource(shieldLevelDescriptionRes(level)),+                            style = MaterialTheme.typography.bodySmall,+                            color = MaterialTheme.colorScheme.onSurfaceVariant,+                        )+                    }+                }+            }+            item { HorizontalDivider(Modifier.padding(vertical = 8.dp)) }+            item {+                ShieldToggleRow(+                    R.string.shields_block_trackers,+                    R.string.shields_block_trackers_desc,+                    global.blockTrackers != false,+                ) { on -> onUpdateGlobal(global.copy(blockTrackers = on)) }+            }+            item {+                ShieldToggleRow(+                    R.string.shields_cosmetic,+                    R.string.shields_cosmetic_desc,+                    global.cosmeticFiltering != false,+                ) { on -> onUpdateGlobal(global.copy(cosmeticFiltering = on)) }+            }+            item {+                ShieldToggleRow(+                    R.string.shields_fingerprint,+                    R.string.shields_fingerprint_desc,+                    global.fingerprintProtection != false,+                ) { on -> onUpdateGlobal(global.copy(fingerprintProtection = on)) }+            }+            item {+                ShieldToggleRow(+                    R.string.shields_https,+                    R.string.shields_https_desc,+                    global.httpsUpgrade != false,+                ) { on -> onUpdateGlobal(global.copy(httpsUpgrade = on)) }+            }+            item { HorizontalDivider(Modifier.padding(vertical = 8.dp)) }+            item {+                Text(+                    stringResource(R.string.shields_site_exceptions),+                    style = MaterialTheme.typography.titleSmall,+                    color = MaterialTheme.colorScheme.primary,+                    modifier = Modifier.padding(horizontal = 16.dp, vertical = 12.dp),+                )+            }+            if (overrides.isEmpty()) {+                item {+                    Surface(+                        shape = RoundedCornerShape(16.dp),+                        color = MaterialTheme.colorScheme.surfaceVariant,+                        modifier = Modifier.padding(16.dp),+                    ) {+                        Text(+                            stringResource(R.string.shields_no_site_exceptions),+                            style = MaterialTheme.typography.bodySmall,+                            modifier = Modifier.padding(14.dp),+                        )+                    }+                }+            } else {+                items(overrides, key = { it.host }) { override ->+                    ListItem(+                        headlineContent = { Text(override.host) },+                        supportingContent = {+                            Text(stringResource(shieldLevelTitleRes(EffectiveShields.resolve(global, override.toSettings()).level)))+                        },+                        modifier = Modifier.clickable { onResetOverride(override.host) },+                    )+                }+                item {+                    TextButton(+                        onClick = onClearOverrides,+                        modifier = Modifier.padding(horizontal = 8.dp),+                    ) { Text(stringResource(R.string.shields_clear_exceptions)) }+                }+            }+        }+    }+}++@Composable+private fun ShieldToggleRow(+    titleRes: Int,+    descriptionRes: Int,+    checked: Boolean,+    onCheckedChange: (Boolean) -> Unit,+) {+    ListItem(+        headlineContent = { Text(stringResource(titleRes)) },+        supportingContent = { Text(stringResource(descriptionRes)) },+        trailingContent = { Switch(checked = checked, onCheckedChange = onCheckedChange) },+    )+}++private fun shieldLevelTitleRes(level: ShieldLevel): Int = when (level) {+    ShieldLevel.OFF -> UiR.string.off+    ShieldLevel.STANDARD -> R.string.shields_level_standard+    ShieldLevel.AGGRESSIVE -> R.string.shields_level_aggressive+}++private fun shieldLevelDescriptionRes(level: ShieldLevel): Int = when (level) {+    ShieldLevel.OFF -> R.string.shields_level_off_desc+    ShieldLevel.STANDARD -> R.string.shields_level_standard_desc+    ShieldLevel.AGGRESSIVE -> R.string.shields_level_aggressive_desc+}
web/src/main/java/com/vayunmathur/web/ui/ShieldsPanel.kt
diff --git a/web/src/main/java/com/vayunmathur/web/ui/ShieldsPanel.kt b/web/src/main/java/com/vayunmathur/web/ui/ShieldsPanel.ktindex 427ee19719..45045cec71 100644--- a/web/src/main/java/com/vayunmathur/web/ui/ShieldsPanel.kt+++ b/web/src/main/java/com/vayunmathur/web/ui/ShieldsPanel.kt@@ -180,7 +180,7 @@ private val ShieldLevel.descriptionRes: Int         ShieldLevel.AGGRESSIVE -> R.string.shields_level_aggressive_desc     } -/** Global shield defaults plus the list of sites that deviate from them. */+/** Global shields host: collects overrides and renders [ShieldsContent]. */ @OptIn(ExperimentalMaterial3Api::class) @Composable internal fun ShieldsPage(@@ -188,117 +188,12 @@ internal fun ShieldsPage(     backStack: NavBackStack<Route>, ) {     val overrides by viewModel.shieldSettings.collectAsStateWithLifecycle()-    val global = viewModel.shields--    AppScaffold(title = stringResource(R.string.shields), backStack = backStack) { padding ->-        LazyColumn(Modifier.padding(padding)) {-            item {-                Text(-                    stringResource(R.string.shields_level),-                    style = MaterialTheme.typography.titleSmall,-                    color = MaterialTheme.colorScheme.primary,-                    modifier = Modifier.padding(horizontal = 16.dp, vertical = 12.dp),-                )-            }-            items(ShieldLevel.entries) { level ->-                Row(-                    Modifier-                        .fillMaxWidth()-                        .clickable { viewModel.updateShields(global.copy(level = level)) }-                        .padding(horizontal = 16.dp, vertical = 10.dp),-                    verticalAlignment = Alignment.CenterVertically,-                ) {-                    RadioButton(-                        selected = global.level == level,-                        onClick = { viewModel.updateShields(global.copy(level = level)) },-                    )-                    Spacer(Modifier.width(12.dp))-                    Column {-                        Text(stringResource(level.titleRes), style = MaterialTheme.typography.bodyMedium)-                        Text(-                            stringResource(level.descriptionRes),-                            style = MaterialTheme.typography.bodySmall,-                            color = MaterialTheme.colorScheme.onSurfaceVariant,-                        )-                    }-                }-            }--            item { HorizontalDivider(Modifier.padding(vertical = 8.dp)) }--            item {-                ShieldToggle(-                    R.string.shields_block_trackers,-                    R.string.shields_block_trackers_desc,-                    global.blockTrackers != false,-                ) { on -> viewModel.updateShields(global.copy(blockTrackers = on)) }-            }-            item {-                ShieldToggle(-                    R.string.shields_cosmetic,-                    R.string.shields_cosmetic_desc,-                    global.cosmeticFiltering != false,-                ) { on -> viewModel.updateShields(global.copy(cosmeticFiltering = on)) }-            }-            item {-                ShieldToggle(-                    R.string.shields_fingerprint,-                    R.string.shields_fingerprint_desc,-                    global.fingerprintProtection != false,-                ) { on -> viewModel.updateShields(global.copy(fingerprintProtection = on)) }-            }-            item {-                ShieldToggle(-                    R.string.shields_https,-                    R.string.shields_https_desc,-                    global.httpsUpgrade != false,-                ) { on -> viewModel.updateShields(global.copy(httpsUpgrade = on)) }-            }--            item { HorizontalDivider(Modifier.padding(vertical = 8.dp)) }--            item {-                Text(-                    stringResource(R.string.shields_site_exceptions),-                    style = MaterialTheme.typography.titleSmall,-                    color = MaterialTheme.colorScheme.primary,-                    modifier = Modifier.padding(horizontal = 16.dp, vertical = 12.dp),-                )-            }--            if (overrides.isEmpty()) {-                item {-                    Surface(-                        shape = RoundedCornerShape(16.dp),-                        color = MaterialTheme.colorScheme.surfaceVariant,-                        modifier = Modifier.padding(16.dp),-                    ) {-                        Text(-                            stringResource(R.string.shields_no_site_exceptions),-                            style = MaterialTheme.typography.bodySmall,-                            modifier = Modifier.padding(14.dp),-                        )-                    }-                }-            } else {-                items(overrides, key = { it.host }) { override ->-                    ListItem(-                        headlineContent = { Text(override.host) },-                        supportingContent = {-                            Text(stringResource(EffectiveShields.resolve(global, override.toSettings()).level.titleRes))-                        },-                        modifier = Modifier.clickable {-                            viewModel.updateSiteShields(override.host, ShieldsSettings())-                        },-                    )-                }-                item {-                    TextButton(-                        onClick = { viewModel.clearSiteShields() },-                        modifier = Modifier.padding(horizontal = 8.dp),-                    ) { Text(stringResource(R.string.shields_clear_exceptions)) }-                }-            }-        }-    }+    ShieldsContent(+        global = viewModel.shields,+        overrides = overrides,+        onNavigateBack = { backStack.pop() },+        onUpdateGlobal = { viewModel.updateShields(it) },+        onResetOverride = { host -> viewModel.updateSiteShields(host, ShieldsSettings()) },+        onClearOverrides = { viewModel.clearSiteShields() },+    ) }
web/src/main/java/com/vayunmathur/web/ui/SiteDataContent.kt
diff --git a/web/src/main/java/com/vayunmathur/web/ui/SiteDataContent.kt b/web/src/main/java/com/vayunmathur/web/ui/SiteDataContent.ktnew file mode 100644index 0000000000..bde3540d0a--- /dev/null+++ b/web/src/main/java/com/vayunmathur/web/ui/SiteDataContent.kt@@ -0,0 +1,158 @@+package com.vayunmathur.web.ui++import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.FlowRow+import androidx.compose.foundation.layout.Row+import androidx.compose.foundation.layout.Spacer+import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.height+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.lazy.items+import androidx.compose.foundation.shape.RoundedCornerShape+import androidx.compose.runtime.Composable+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.res.stringResource+import androidx.compose.ui.text.style.TextOverflow+import androidx.compose.ui.unit.dp+import com.vayunmathur.library.ui.Card+import com.vayunmathur.library.ui.CardDefaults+import com.vayunmathur.library.ui.ExperimentalMaterial3Api+import com.vayunmathur.library.ui.IconButton+import com.vayunmathur.library.ui.IconClose+import com.vayunmathur.library.ui.IconDelete+import com.vayunmathur.library.ui.IconNavigation+import com.vayunmathur.library.ui.LazyListScaffold+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.Surface+import com.vayunmathur.library.ui.Text+import com.vayunmathur.library.ui.TextButton+import com.vayunmathur.library.ui.TopAppBar+import com.vayunmathur.library.ui.R as UiR+import com.vayunmathur.web.R+import com.vayunmathur.web.data.SitePermission+import com.vayunmathur.web.data.StorageInfo+import com.vayunmathur.web.platform.BrowserUtils+import com.vayunmathur.web.platform.SitePermissionType++/**+ * Stateless per-site data body: storage and permission grants. Split out+ * of the site-data page so screenshot captures render it from literals.+ */+@OptIn(ExperimentalMaterial3Api::class)+@Composable+fun SiteDataContent(+    storages: List<StorageInfo>,+    permissions: List<SitePermission>,+    onNavigateBack: () -> Unit,+    onClearAll: () -> Unit = {},+    onClearStorage: (String) -> Unit = {},+    onRevokePermission: (String, SitePermissionType) -> Unit = { _, _ -> },+) {+    LazyListScaffold(+        horizontalPadding = 12.dp,+        verticalArrangement = Arrangement.spacedBy(10.dp),+        topBar = {+            TopAppBar(+                title = { Text(stringResource(R.string.site_data)) },+                navigationIcon = { IconNavigation(onNavigateBack) },+                actions = {+                    if (storages.isNotEmpty() || permissions.isNotEmpty()) {+                        IconButton(onClick = onClearAll) { IconDelete() }+                    }+                },+            )+        },+    ) {+        if (storages.isEmpty() && permissions.isEmpty()) {+            item {+                Text(+                    stringResource(R.string.no_site_data_yet_cookies_localstorage_in),+                    style = MaterialTheme.typography.bodyMedium,+                    color = MaterialTheme.colorScheme.onSurfaceVariant,+                )+            }+        }+        if (storages.isNotEmpty()) {+            item { Text(stringResource(R.string.storage), style = MaterialTheme.typography.titleMedium) }+            items(storages, key = { "storage-${it.id}" }) { info ->+                StorageInfoCard(info, onClearStorage)+            }+        }+        if (permissions.isNotEmpty()) {+            item {+                Spacer(Modifier.height(8.dp))+                Text(stringResource(R.string.permissions), style = MaterialTheme.typography.titleMedium)+            }+            items(permissions, key = { "perm-${it.id}" }) { perm ->+                PermissionInfoCard(perm, onRevokePermission)+            }+        }+    }+}++@Composable+private fun StorageInfoCard(info: StorageInfo, onClearStorage: (String) -> Unit) {+    Card(+        shape = RoundedCornerShape(16.dp),+        colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surfaceVariant),+        modifier = Modifier.fillMaxWidth(),+    ) {+        Column(Modifier.padding(14.dp), verticalArrangement = Arrangement.spacedBy(6.dp)) {+            Row(verticalAlignment = Alignment.CenterVertically) {+                Column(Modifier.weight(1f)) {+                    Text(info.host, style = MaterialTheme.typography.titleSmall, maxLines = 1, overflow = TextOverflow.Ellipsis)+                    Text(info.origin, style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant, maxLines = 1, overflow = TextOverflow.Ellipsis)+                }+                IconButton(onClick = { onClearStorage(info.origin) }) { IconClose() }+            }+            @OptIn(androidx.compose.foundation.layout.ExperimentalLayoutApi::class)+            FlowRow(horizontalArrangement = Arrangement.spacedBy(8.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) {+                if (info.cookieCount > 0) ChipBadge("${info.cookieCount} cookies")+                if (info.hasLocalStorage) ChipBadge("localStorage")+                if (info.hasIndexedDb) ChipBadge("IndexedDB")+                if (info.hasServiceWorker) ChipBadge("ServiceWorker")+                if (info.estimatedBytes > 0) ChipBadge("${info.estimatedBytes / 1024} KB")+            }+        }+    }+}++@Composable+private fun PermissionInfoCard(perm: SitePermission, onRevokePermission: (String, SitePermissionType) -> Unit) {+    Card(+        shape = RoundedCornerShape(16.dp),+        colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surfaceVariant),+        modifier = Modifier.fillMaxWidth(),+    ) {+        Column(Modifier.padding(14.dp), verticalArrangement = Arrangement.spacedBy(6.dp)) {+            Text(BrowserUtils.hostFromUrl(perm.origin), style = MaterialTheme.typography.titleSmall)+            Column(verticalArrangement = Arrangement.spacedBy(2.dp)) {+                PermRow("Camera", perm.cameraAllowed) { onRevokePermission(perm.origin, SitePermissionType.CAMERA) }+                PermRow("Microphone", perm.microphoneAllowed) { onRevokePermission(perm.origin, SitePermissionType.MICROPHONE) }+                PermRow("Location", perm.locationAllowed) { onRevokePermission(perm.origin, SitePermissionType.LOCATION) }+                PermRow("Notifications", perm.notificationsAllowed) { onRevokePermission(perm.origin, SitePermissionType.NOTIFICATIONS) }+            }+            if (perm.cameraAllowed == null && perm.microphoneAllowed == null && perm.locationAllowed == null && perm.notificationsAllowed == null) {+                Text(stringResource(R.string.no_permissions_set), style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant)+            }+        }+    }+}++@Composable+private fun PermRow(label: String, allowed: Boolean?, onClear: () -> Unit) {+    if (allowed == null) return+    Row(verticalAlignment = Alignment.CenterVertically) {+        Text("$label: ${if (allowed) "Allowed" else "Blocked"}", style = MaterialTheme.typography.bodySmall, modifier = Modifier.weight(1f))+        TextButton(onClick = onClear) { Text(stringResource(UiR.string.clear)) }+    }+}++@Composable+private fun ChipBadge(text: String) {+    Surface(shape = RoundedCornerShape(20.dp), color = MaterialTheme.colorScheme.secondaryContainer) {+        Text(text, style = MaterialTheme.typography.labelSmall, modifier = Modifier.padding(horizontal = 8.dp, vertical = 4.dp))+    }+}
web/src/main/java/com/vayunmathur/web/ui/WebDialogEntries.kt
diff --git a/web/src/main/java/com/vayunmathur/web/ui/WebDialogEntries.kt b/web/src/main/java/com/vayunmathur/web/ui/WebDialogEntries.ktnew file mode 100644index 0000000000..2a3295f020--- /dev/null+++ b/web/src/main/java/com/vayunmathur/web/ui/WebDialogEntries.kt@@ -0,0 +1,141 @@+package com.vayunmathur.web.ui++import android.webkit.CookieManager+import android.webkit.WebStorage+import android.webkit.WebView+import androidx.compose.runtime.Composable+import androidx.compose.ui.platform.LocalContext+import androidx.compose.ui.res.stringResource+import com.vayunmathur.library.ui.ConfirmDialog+import com.vayunmathur.library.ui.R as UiR+import com.vayunmathur.library.ui.SingleChoiceDialog+import com.vayunmathur.library.ui.TextInputDialog+import com.vayunmathur.library.util.DialogPage+import com.vayunmathur.library.util.EntryProviderScope+import com.vayunmathur.library.util.NavBackStack+import com.vayunmathur.web.R+import com.vayunmathur.web.Route+import com.vayunmathur.web.data.Bookmark+import com.vayunmathur.web.data.BookmarkFolder+import com.vayunmathur.web.platform.CacheMode+import com.vayunmathur.web.platform.SearchEngine+import com.vayunmathur.web.platform.WebViewModel+import com.vayunmathur.web.platform.clearAllDownloads+import com.vayunmathur.web.platform.clearAllSiteData+import com.vayunmathur.web.platform.clearHistory+import com.vayunmathur.web.platform.createFolder+import com.vayunmathur.web.platform.deleteFolder+import com.vayunmathur.web.platform.removeBookmark+import com.vayunmathur.web.platform.updateCacheMode+import com.vayunmathur.web.platform.updateSearchEngine++/**+ * Dialog destinations for web: every dialog is a [Route] with `DialogPage()`+ * metadata, rendered unconditionally by its entry. The library dialogs call+ * dismiss before confirm, so confirms here only perform the action.+ */+internal fun EntryProviderScope<Route>.webDialogEntries(+    viewModel: WebViewModel,+    backStack: NavBackStack<Route>,+) {+    entry<Route.NewFolderDialog>(metadata = DialogPage()) {+        TextInputDialog(+            title = stringResource(R.string.new_folder),+            placeholder = stringResource(R.string.folder_name),+            confirmLabel = stringResource(UiR.string.create),+            dismissLabel = stringResource(UiR.string.cancel),+            confirmEnabled = { it.isNotBlank() },+            onConfirm = { viewModel.createFolder(it.trim()) },+            onDismiss = { backStack.pop() },+        )+    }+    entry<Route.DeleteBookmarkDialog>(metadata = DialogPage()) { route ->+        ConfirmDialog(+            title = stringResource(R.string.delete_bookmark),+            message = route.title.ifBlank { route.url },+            confirmLabel = stringResource(UiR.string.delete),+            dismissLabel = stringResource(UiR.string.cancel),+            destructive = true,+            onConfirm = {+                viewModel.removeBookmark(+                    Bookmark(id = route.bookmarkId, url = route.url, title = route.title, createdAt = 0L),+                )+            },+            onDismiss = { backStack.pop() },+        )+    }+    entry<Route.DeleteFolderDialog>(metadata = DialogPage()) { route ->+        ConfirmDialog(+            title = stringResource(R.string.delete_folder_2),+            message = stringResource(R.string.bookmarks_inside_will_also_be_deleted, route.folderName),+            confirmLabel = stringResource(UiR.string.delete),+            dismissLabel = stringResource(UiR.string.cancel),+            destructive = true,+            onConfirm = {+                viewModel.deleteFolder(BookmarkFolder(id = route.folderId, name = route.folderName, createdAt = 0L))+            },+            onDismiss = { backStack.pop() },+        )+    }+    entry<Route.ClearHistoryDialog>(metadata = DialogPage()) {+        ConfirmDialog(+            title = stringResource(R.string.clear_history),+            message = stringResource(R.string.this_will_permanently_delete_your_browsi),+            confirmLabel = stringResource(UiR.string.clear),+            dismissLabel = stringResource(UiR.string.cancel),+            destructive = true,+            onConfirm = { viewModel.clearHistory() },+            onDismiss = { backStack.pop() },+        )+    }+    entry<Route.CacheModeDialog>(metadata = DialogPage()) {+        SingleChoiceDialog(+            title = stringResource(R.string.cache_mode),+            options = CacheMode.entries,+            selected = viewModel.cacheMode,+            label = { it.title },+            supportingLabel = { it.description },+            onSelect = { viewModel.updateCacheMode(it) },+            onDismiss = { backStack.pop() },+        )+    }+    entry<Route.SearchEngineDialog>(metadata = DialogPage()) {+        SingleChoiceDialog(+            title = stringResource(R.string.search_engine),+            options = SearchEngine.PICKABLE,+            selected = viewModel.searchEngine,+            label = { it.displayName },+            supportingLabel = { it.homepage },+            onSelect = { viewModel.updateSearchEngine(it) },+            onDismiss = { backStack.pop() },+        )+    }+    entry<Route.ClearBrowsingDataDialog>(metadata = DialogPage()) {+        ClearBrowsingDataDialogHost(viewModel, backStack)+    }+}++@Composable+private fun ClearBrowsingDataDialogHost(+    viewModel: WebViewModel,+    backStack: NavBackStack<Route>,+) {+    val context = LocalContext.current+    ConfirmDialog(+        title = stringResource(R.string.clear_browsing_data_2),+        message = stringResource(R.string.clears_cookies_cache_storage_history_dow),+        confirmLabel = stringResource(UiR.string.clear),+        dismissLabel = stringResource(UiR.string.cancel),+        destructive = true,+        onConfirm = {+            try { CookieManager.getInstance().removeAllCookies(null); CookieManager.getInstance().flush() } catch (_: Exception) {}+            try { WebStorage.getInstance().deleteAllData() } catch (_: Exception) {}+            try { WebView(context).clearCache(true) } catch (_: Exception) {}+            viewModel.clearHistory()+            viewModel.clearAllDownloads()+            viewModel.clearAllSiteData()+        },+        onDismiss = { backStack.pop() },+    )+}+
web/src/screenshotTest/kotlin/com/vayunmathur/web/ui/MetadataPreviews.kt
diff --git a/web/src/screenshotTest/kotlin/com/vayunmathur/web/ui/MetadataPreviews.kt b/web/src/screenshotTest/kotlin/com/vayunmathur/web/ui/MetadataPreviews.ktindex 559bec7c8d..eae4d57765 100644--- a/web/src/screenshotTest/kotlin/com/vayunmathur/web/ui/MetadataPreviews.kt+++ b/web/src/screenshotTest/kotlin/com/vayunmathur/web/ui/MetadataPreviews.kt@@ -10,11 +10,22 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.tooling.preview.Preview import com.android.tools.screenshot.PreviewTest+import com.vayunmathur.library.ui.ConfirmDialog import com.vayunmathur.library.ui.DynamicTheme+import com.vayunmathur.library.ui.SingleChoiceDialog+import com.vayunmathur.library.ui.TextInputDialog import com.vayunmathur.web.data.Bookmark import com.vayunmathur.web.data.BookmarkFolder+import com.vayunmathur.web.data.DownloadEntry import com.vayunmathur.web.data.HistoryEntry+import com.vayunmathur.web.data.InstalledSite+import com.vayunmathur.web.data.SitePermission+import com.vayunmathur.web.data.StorageInfo+import com.vayunmathur.web.domain.ShieldLevel+import com.vayunmathur.web.domain.ShieldsSettings import com.vayunmathur.web.platform.BrowserTab+import com.vayunmathur.web.platform.CacheMode+import com.vayunmathur.web.platform.SearchEngine  /** Phone-shaped, roughly 1080x2340 at xxhdpi — comfortably above the F-Droid minimum. */ private const val PHONE = "spec:width=411dp,height=891dp,dpi=420"@@ -31,7 +42,11 @@ private const val JUL_2026 = 1_753_900_000_000L  * A browser is mostly a WebView, which cannot render here, so these show the chrome around  * it: the new-tab landing page, the tab switcher and bookmarks. [BrowserChrome] was split out  * of [BrowserPage] and [BookmarksScreen] out of [BookmarksPage] to make that possible;- * [TabSwitcher] and [QuickAccess] were already stateless.+ * [TabSwitcher] and [QuickAccess] were already stateless. Every `Route` leaf has a+ * capture named `<n>-<route-kebab>`; the remaining routes render their stateless+ * slices ([HistoryContent], [SettingsContent], [DownloadsContent], [SiteDataContent],+ * [InstalledSitesContent], [ShieldsContent]) and the dialog routes render the+ * library dialog primitives their entries host.  *  * Each preview needs @PreviewTest as well as @Preview: @Preview alone renders in Studio but  * is not collected as a screenshot test. Previews must also be class members, not top-level@@ -71,7 +86,7 @@ class MetadataPreviews {     )      @PreviewTest-    @Preview(name = "1-new-tab", device = PHONE, group = "phone", showSystemUi = true)+    @Preview(name = "1-browser", device = PHONE, group = "phone", showSystemUi = true)     @Composable     fun Preview1NewTab() {         DynamicTheme(darkTheme = true) {@@ -90,7 +105,7 @@ class MetadataPreviews {     }      @PreviewTest-    @Preview(name = "2-tabs", device = PHONE, group = "phone", showSystemUi = true)+    @Preview(name = "2-browser-tabs", device = PHONE, group = "phone", showSystemUi = true)     @Composable     fun Preview2Tabs() {         DynamicTheme(darkTheme = true) {@@ -119,7 +134,7 @@ class MetadataPreviews {     }      @PreviewTest-    @Preview(name = "4-expanded", device = EXPANDED, group = "large-tablet", showSystemUi = true)+    @Preview(name = "4-browser-expanded", device = EXPANDED, group = "large-tablet", showSystemUi = true)     @Composable     fun Preview4Expanded() {         DynamicTheme(darkTheme = true) {@@ -144,4 +159,226 @@ class MetadataPreviews {             }         }     }++    @PreviewTest+    @Preview(name = "5-history", device = PHONE, group = "phone", showSystemUi = true)+    @Composable+    fun Preview5History() {+        DynamicTheme(darkTheme = true) {+            HistoryContent(+                grouped = listOf("Today" to history),+                historyEmpty = false,+                hasLoaded = true,+                onNavigateBack = {},+            )+        }+    }++    @PreviewTest+    @Preview(name = "6-settings", device = PHONE, group = "phone", showSystemUi = true)+    @Composable+    fun Preview6Settings() {+        DynamicTheme(darkTheme = true) {+            SettingsContent(+                searchEngineLabel = "DuckDuckGo",+                cacheModeLabel = "Default — Use HTTP cache as needed",+                shieldsLevel = ShieldLevel.STANDARD,+                searchBarAtBottom = true,+                jsEnabled = true,+                blockThirdPartyCookies = false,+                desktopMode = false,+                historyCount = history.size,+                downloadCount = 2,+                storageCount = 1,+                permissionCount = 1,+                installedCount = 1,+                onNavigateBack = {},+            )+        }+    }++    @PreviewTest+    @Preview(name = "7-downloads", device = PHONE, group = "phone", showSystemUi = true)+    @Composable+    fun Preview7Downloads() {+        DynamicTheme(darkTheme = true) {+            DownloadsContent(+                downloads = listOf(+                    DownloadEntry(id = 1, url = "https://example.com/report.pdf", fileName = "report.pdf", mimeType = "application/pdf", startedAt = JUL_2026),+                    DownloadEntry(id = 2, url = "https://example.com/photo.jpg", fileName = "photo.jpg", mimeType = "image/jpeg", startedAt = JUL_2026),+                ),+                hasLoaded = true,+                onNavigateBack = {},+            )+        }+    }++    @PreviewTest+    @Preview(name = "8-site-data", device = PHONE, group = "phone", showSystemUi = true)+    @Composable+    fun Preview8SiteData() {+        DynamicTheme(darkTheme = true) {+            SiteDataContent(+                storages = listOf(+                    StorageInfo(id = 1, origin = "https://example.com", host = "example.com", cookieCount = 3, hasLocalStorage = true, estimatedBytes = 2048L, lastSeen = JUL_2026),+                ),+                permissions = listOf(+                    SitePermission(id = 1, origin = "https://example.com", cameraAllowed = false, updatedAt = JUL_2026),+                ),+                onNavigateBack = {},+            )+        }+    }++    @PreviewTest+    @Preview(name = "9-installed-sites", device = PHONE, group = "phone", showSystemUi = true)+    @Composable+    fun Preview9InstalledSites() {+        DynamicTheme(darkTheme = true) {+            InstalledSitesContent(+                installed = listOf(+                    InstalledSite(id = "s1", url = "https://example.com", title = "Example", origin = "https://example.com", installedAt = JUL_2026),+                ),+                onNavigateBack = {},+            )+        }+    }++    @PreviewTest+    @Preview(name = "10-shields", device = PHONE, group = "phone", showSystemUi = true)+    @Composable+    fun Preview10Shields() {+        DynamicTheme(darkTheme = true) {+            ShieldsContent(+                global = ShieldsSettings(+                    level = ShieldLevel.STANDARD,+                    blockTrackers = true,+                    cosmeticFiltering = true,+                    fingerprintProtection = true,+                    httpsUpgrade = true,+                ),+                overrides = emptyList(),+                onNavigateBack = {},+            )+        }+    }++    @PreviewTest+    @Preview(name = "11-new-folder-dialog", device = PHONE, group = "phone", showSystemUi = true)+    @Composable+    fun Preview11NewFolderDialog() {+        DynamicTheme(darkTheme = true) {+            TextInputDialog(+                title = "New folder",+                placeholder = "Folder name",+                confirmLabel = "Create",+                dismissLabel = "Cancel",+                confirmEnabled = { it.isNotBlank() },+                onConfirm = {},+                onDismiss = {},+            )+        }+    }++    @PreviewTest+    @Preview(name = "12-delete-bookmark-dialog", device = PHONE, group = "phone", showSystemUi = true)+    @Composable+    fun Preview12DeleteBookmarkDialog() {+        DynamicTheme(darkTheme = true) {+            ConfirmDialog(+                title = "Delete bookmark?",+                message = "F-Droid",+                confirmLabel = "Delete",+                dismissLabel = "Cancel",+                destructive = true,+                onConfirm = {},+                onDismiss = {},+            )+        }+    }++    @PreviewTest+    @Preview(name = "13-delete-folder-dialog", device = PHONE, group = "phone", showSystemUi = true)+    @Composable+    fun Preview13DeleteFolderDialog() {+        DynamicTheme(darkTheme = true) {+            ConfirmDialog(+                title = "Delete folder?",+                message = "Bookmarks inside Reading will also be deleted.",+                confirmLabel = "Delete",+                dismissLabel = "Cancel",+                destructive = true,+                onConfirm = {},+                onDismiss = {},+            )+        }+    }++    @PreviewTest+    @Preview(name = "14-clear-history-dialog", device = PHONE, group = "phone", showSystemUi = true)+    @Composable+    fun Preview14ClearHistoryDialog() {+        DynamicTheme(darkTheme = true) {+            ConfirmDialog(+                title = "Clear history?",+                message = "This will permanently delete your browsing history.",+                confirmLabel = "Clear",+                dismissLabel = "Cancel",+                destructive = true,+                onConfirm = {},+                onDismiss = {},+            )+        }+    }++    @PreviewTest+    @Preview(name = "15-cache-mode-dialog", device = PHONE, group = "phone", showSystemUi = true)+    @Composable+    fun Preview15CacheModeDialog() {+        DynamicTheme(darkTheme = true) {+            SingleChoiceDialog(+                title = "Cache mode",+                options = CacheMode.entries,+                selected = CacheMode.DEFAULT,+                label = { it.title },+                supportingLabel = { it.description },+                onSelect = {},+                onDismiss = {},+            )+        }+    }++    @PreviewTest+    @Preview(name = "16-search-engine-dialog", device = PHONE, group = "phone", showSystemUi = true)+    @Composable+    fun Preview16SearchEngineDialog() {+        DynamicTheme(darkTheme = true) {+            SingleChoiceDialog(+                title = "Search engine",+                options = SearchEngine.PICKABLE,+                selected = SearchEngine.DUCKDUCKGO,+                label = { it.displayName },+                supportingLabel = { it.homepage },+                onSelect = {},+                onDismiss = {},+            )+        }+    }++    @PreviewTest+    @Preview(name = "17-clear-browsing-data-dialog", device = PHONE, group = "phone", showSystemUi = true)+    @Composable+    fun Preview17ClearBrowsingDataDialog() {+        DynamicTheme(darkTheme = true) {+            ConfirmDialog(+                title = "Clear browsing data?",+                message = "This clears cookies, cache, storage, history and downloads.",+                confirmLabel = "Clear",+                dismissLabel = "Cancel",+                destructive = true,+                onConfirm = {},+                onDismiss = {},+            )+        }+    } }
web/src/test/java/com/vayunmathur/web/ui/BookmarksScreenTest.kt
diff --git a/web/src/test/java/com/vayunmathur/web/ui/BookmarksScreenTest.kt b/web/src/test/java/com/vayunmathur/web/ui/BookmarksScreenTest.ktindex 1b5a03d7c4..24b046d0c2 100644--- a/web/src/test/java/com/vayunmathur/web/ui/BookmarksScreenTest.kt+++ b/web/src/test/java/com/vayunmathur/web/ui/BookmarksScreenTest.kt@@ -1,11 +1,17 @@ package com.vayunmathur.web.ui +import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableStateOf+import androidx.compose.runtime.remember+import androidx.compose.runtime.setValue import androidx.compose.ui.test.assertIsDisplayed import androidx.compose.ui.test.junit4.createComposeRule import androidx.compose.ui.test.onNodeWithContentDescription import androidx.compose.ui.test.onNodeWithText import androidx.compose.ui.test.performClick import androidx.compose.ui.test.performTextInput+import com.vayunmathur.library.ui.ConfirmDialog+import com.vayunmathur.library.ui.TextInputDialog import com.vayunmathur.web.data.Bookmark import com.vayunmathur.web.data.BookmarkFolder import kotlin.test.Test@@ -32,14 +38,38 @@ class BookmarksScreenTest {         onCreateFolder: (String) -> Unit = {},     ) {         rule.setContent {+            var showNewFolder by remember { mutableStateOf(false) }+            var pendingDelete by remember { mutableStateOf<Bookmark?>(null) }             BookmarksScreen(                 bookmarks = bookmarks,                 folders = folders,                 onOpen = onOpen,-                onDelete = onDelete,-                onCreateFolder = onCreateFolder,-                onDeleteFolder = {},+                onRequestNewFolder = { showNewFolder = true },+                onRequestDeleteBookmark = { pendingDelete = it },+                onRequestDeleteFolder = {},             )+            if (showNewFolder) {+                TextInputDialog(+                    title = "New folder",+                    placeholder = "Folder name",+                    confirmLabel = "Create",+                    dismissLabel = "Cancel",+                    confirmEnabled = { it.isNotBlank() },+                    onConfirm = { onCreateFolder(it.trim()) },+                    onDismiss = { showNewFolder = false },+                )+            }+            pendingDelete?.let { bm ->+                ConfirmDialog(+                    title = "Delete bookmark?",+                    message = bm.title.ifBlank { bm.url },+                    confirmLabel = "Delete",+                    dismissLabel = "Cancel",+                    destructive = true,+                    onConfirm = { onDelete(bm) },+                    onDismiss = { pendingDelete = null },+                )+            }         }         rule.waitForIdle()     }
web/src/test/java/com/vayunmathur/web/ui/MiscDeepTest.kt
diff --git a/web/src/test/java/com/vayunmathur/web/ui/MiscDeepTest.kt b/web/src/test/java/com/vayunmathur/web/ui/MiscDeepTest.ktindex 62162fd578..c76a6b49eb 100644--- a/web/src/test/java/com/vayunmathur/web/ui/MiscDeepTest.kt+++ b/web/src/test/java/com/vayunmathur/web/ui/MiscDeepTest.kt@@ -1,11 +1,15 @@ package com.vayunmathur.web.ui -// FIXTURE RELATIVE-TIME EXCEPTION: timestamps are seeded relative to the wall clock the code under test reads internally, so the fresh/expired/relative-time branch under test keeps its meaning; a fixed past instant would silently change that branch.+// FIXTURE RELATIVE-TIME EXCEPTION: history fixtures seed visitedAt relative to the real clock because HistoryPage groups entries by today/yesterday against now.  import android.graphics.Bitmap import android.net.Uri import android.os.Looper import android.webkit.WebView+import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableStateOf+import androidx.compose.runtime.remember+import androidx.compose.runtime.setValue import androidx.compose.ui.test.hasScrollAction import androidx.compose.ui.test.hasText import androidx.compose.ui.test.junit4.createComposeRule@@ -14,6 +18,7 @@ import androidx.compose.ui.test.performClick import androidx.compose.ui.test.performScrollToNode import androidx.room3.Room import androidx.test.core.app.ApplicationProvider+import com.vayunmathur.library.ui.ConfirmDialog import com.vayunmathur.library.util.NavBackStack import com.vayunmathur.web.Route import com.vayunmathur.web.data.FaviconStore@@ -25,6 +30,7 @@ import com.vayunmathur.web.data.TabThumbnailStore import com.vayunmathur.web.data.WebDatabase import com.vayunmathur.web.platform.TestStores import com.vayunmathur.web.platform.WebViewModel+import com.vayunmathur.web.platform.clearHistory import com.vayunmathur.web.platform.shields.ShieldsEngine import kotlin.test.AfterTest import kotlin.test.Test@@ -171,7 +177,21 @@ class MiscDeepTest {         val v = vm()         runBlocking { stores.history.upsert(HistoryEntry(url = "https://clear.example", title = "ClearMe", visitedAt = System.currentTimeMillis())) }         await("history seeded") { v.history.value.isNotEmpty() }-        rule.setContent { SettingsPage(v, NavBackStack(arrayOf<Route>(Route.Browser))) }+        rule.setContent {+            var showClear by remember { mutableStateOf(false) }+            SettingsPage(v, NavBackStack(arrayOf<Route>(Route.Browser)), onRequestClearBrowsingData = { showClear = true })+            if (showClear) {+                ConfirmDialog(+                    title = "Clear browsing data?",+                    message = "This clears cookies, cache, storage, history and downloads.",+                    confirmLabel = "Clear",+                    dismissLabel = "Cancel",+                    destructive = true,+                    onConfirm = { v.clearHistory() },+                    onDismiss = { showClear = false },+                )+            }+        }         rule.waitForIdle()         rule.onNode(hasScrollAction()).performScrollToNode(hasText("Clear browsing data"))         rule.onNodeWithText("Clear browsing data").performClick()
web/src/test/java/com/vayunmathur/web/ui/QuickAddTest.kt
diff --git a/web/src/test/java/com/vayunmathur/web/ui/QuickAddTest.kt b/web/src/test/java/com/vayunmathur/web/ui/QuickAddTest.ktindex 32ceae467f..2f107144ae 100644--- a/web/src/test/java/com/vayunmathur/web/ui/QuickAddTest.kt+++ b/web/src/test/java/com/vayunmathur/web/ui/QuickAddTest.kt@@ -1,6 +1,6 @@ package com.vayunmathur.web.ui -// FIXTURE RELATIVE-TIME EXCEPTION: timestamps are seeded relative to the wall clock the code under test reads internally, so the fresh/expired/relative-time branch under test keeps its meaning; a fixed past instant would silently change that branch.+// FIXTURE RELATIVE-TIME EXCEPTION: history/tab fixtures seed timestamps relative to the real clock because the browser pages group and order them against now.  import android.os.Looper import androidx.compose.ui.test.assertIsDisplayed
web/src/test/java/com/vayunmathur/web/ui/WebPagesDeepTest.kt
diff --git a/web/src/test/java/com/vayunmathur/web/ui/WebPagesDeepTest.kt b/web/src/test/java/com/vayunmathur/web/ui/WebPagesDeepTest.ktindex 314870ad6c..3f4dd64339 100644--- a/web/src/test/java/com/vayunmathur/web/ui/WebPagesDeepTest.kt+++ b/web/src/test/java/com/vayunmathur/web/ui/WebPagesDeepTest.kt@@ -1,8 +1,12 @@ package com.vayunmathur.web.ui -// FIXTURE RELATIVE-TIME EXCEPTION: timestamps are seeded relative to the wall clock the code under test reads internally, so the fresh/expired/relative-time branch under test keeps its meaning; a fixed past instant would silently change that branch.+// FIXTURE RELATIVE-TIME EXCEPTION: history/download fixtures seed visitedAt/startedAt relative to the real clock because the pages group and label them by today/now.  import android.os.Looper+import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableStateOf+import androidx.compose.runtime.remember+import androidx.compose.runtime.setValue import androidx.compose.ui.test.assertIsDisplayed import androidx.compose.ui.test.hasText import androidx.compose.ui.test.isToggleable@@ -20,6 +24,7 @@ import androidx.compose.ui.test.swipeUp import androidx.compose.ui.test.performTextInput import androidx.room3.Room import androidx.test.core.app.ApplicationProvider+import com.vayunmathur.library.ui.ConfirmDialog import com.vayunmathur.library.util.NavBackStack import com.vayunmathur.web.Route import com.vayunmathur.web.data.Bookmark@@ -28,6 +33,7 @@ import com.vayunmathur.web.data.WebDatabase import com.vayunmathur.web.platform.TestStores import com.vayunmathur.web.platform.WebViewModel import com.vayunmathur.web.platform.newTab+import com.vayunmathur.web.platform.clearHistory import com.vayunmathur.web.platform.shieldsFor import kotlin.test.AfterTest import kotlin.test.Test@@ -135,7 +141,21 @@ class WebPagesDeepTest {      @Test fun settingsClearDataDialogCancels() {         val v = vm()-        rule.setContent { SettingsPage(v, backStack()) }+        rule.setContent {+            var showClear by remember { mutableStateOf(false) }+            SettingsPage(v, backStack(), onRequestClearBrowsingData = { showClear = true })+            if (showClear) {+                ConfirmDialog(+                    title = "Clear browsing data?",+                    message = "This clears cookies, cache, storage, history and downloads.",+                    confirmLabel = "Clear",+                    dismissLabel = "Cancel",+                    destructive = true,+                    onConfirm = {},+                    onDismiss = { showClear = false },+                )+            }+        }         rule.waitForIdle()         scrollToText("Clear browsing data")         rule.onNodeWithText("Clear browsing data").performClick()@@ -162,11 +182,23 @@ class WebPagesDeepTest {     @Test fun bookmarksCreateFolderWithName() {         var created: String? = null         rule.setContent {+            var showNewFolder by remember { mutableStateOf(false) }             BookmarksScreen(                 bookmarks = emptyList(),                 folders = emptyList(),-                onCreateFolder = { created = it },+                onRequestNewFolder = { showNewFolder = true },             )+            if (showNewFolder) {+                com.vayunmathur.library.ui.TextInputDialog(+                    title = "New folder",+                    placeholder = "Folder name",+                    confirmLabel = "Create",+                    dismissLabel = "Cancel",+                    confirmEnabled = { it.isNotBlank() },+                    onConfirm = { created = it.trim() },+                    onDismiss = { showNewFolder = false },+                )+            }         }         rule.waitForIdle()         rule.onNodeWithText("No bookmarks yet", substring = true).assertIsDisplayed()@@ -195,11 +227,23 @@ class WebPagesDeepTest {     @Test fun bookmarksLongPressDeletes() {         var deleted: Bookmark? = null         rule.setContent {+            var pendingDelete by remember { mutableStateOf<Bookmark?>(null) }             BookmarksScreen(                 bookmarks = listOf(Bookmark(id = 1, url = "https://a.example", title = "Delete Me")),                 folders = emptyList(),-                onDelete = { deleted = it },+                onRequestDeleteBookmark = { pendingDelete = it },             )+            pendingDelete?.let { bm ->+                ConfirmDialog(+                    title = "Delete bookmark?",+                    message = bm.title.ifBlank { bm.url },+                    confirmLabel = "Delete",+                    dismissLabel = "Cancel",+                    destructive = true,+                    onConfirm = { deleted = bm },+                    onDismiss = { pendingDelete = null },+                )+            }         }         rule.waitForIdle()         rule.onNodeWithText("Delete Me").performTouchInput { longClick() }@@ -382,7 +426,21 @@ class WebPagesDeepTest {         val v = vm()         runBlocking { stores.history.upsert(com.vayunmathur.web.data.HistoryEntry(url = "https://h.example", title = "Hist", visitedAt = System.currentTimeMillis())) }         await("history") { v.history.value.isNotEmpty() }-        rule.setContent { HistoryPage(v, backStack()) }+        rule.setContent {+            var showClear by remember { mutableStateOf(false) }+            HistoryPage(v, backStack(), onRequestClearHistory = { showClear = true })+            if (showClear) {+                ConfirmDialog(+                    title = "Clear history?",+                    message = "This will permanently delete your browsing history.",+                    confirmLabel = "Clear",+                    dismissLabel = "Cancel",+                    destructive = true,+                    onConfirm = { v.clearHistory() },+                    onDismiss = { showClear = false },+                )+            }+        }         rule.waitForIdle()         rule.onNode(androidx.compose.ui.test.hasContentDescription("Delete")).performClick()         rule.waitForIdle()
web/src/test/java/com/vayunmathur/web/ui/WebPagesTest.kt
diff --git a/web/src/test/java/com/vayunmathur/web/ui/WebPagesTest.kt b/web/src/test/java/com/vayunmathur/web/ui/WebPagesTest.ktindex a49513d95b..f8639aaa09 100644--- a/web/src/test/java/com/vayunmathur/web/ui/WebPagesTest.kt+++ b/web/src/test/java/com/vayunmathur/web/ui/WebPagesTest.kt@@ -1,11 +1,15 @@ package com.vayunmathur.web.ui -// FIXTURE RELATIVE-TIME EXCEPTION: timestamps are seeded relative to the wall clock the code under test reads internally, so the fresh/expired/relative-time branch under test keeps its meaning; a fixed past instant would silently change that branch.+// FIXTURE RELATIVE-TIME EXCEPTION: history/download fixtures seed visitedAt/startedAt relative to the real clock because the pages group and label them by today/now, so a fixed past timestamp would change the asserted grouping.  import android.os.Looper import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.runtime.remember+import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableStateOf+import androidx.compose.runtime.remember+import androidx.compose.runtime.setValue import androidx.compose.ui.test.assertIsDisplayed impo

Diff truncated.