Modern Apps git

← Modern-Apps.git

vpn: delete-all-logs dialog is a route, cover all routes

Commit
c4676c8c5edeb5490800ce1136b176a579b9d5ba
Author
Vayun Mathur <[email protected]>
When
2026-12-02 00:57 UTC (4 days ago)
Parents
fd97a6c
Route gains DeleteAllLogsDialog with a DialogPage entry in VpnTabs
and a stateless DeleteAllLogsDialog content under ui/dialogs/;
LoggingContent now only requests the dialog route from its trash
action (LoggingPage forwards the request from VpnTabs), so no dialog
is gated by remember-state in the screen. Tests adapted to the
route-request contract: LoggingContent asserts the request fires
and renders no dialog itself.

RouteScreenshotCoverage: Logging, Settings, Detail, BypassList,
GeoPicker, GeoCountry and GeoCity had no capture whose preview name
names the route. MetadataPreviews gains 5-logging and 6-settings
through the real tab chrome, plus 7-detail, 8-bypass-list,
9-geo-picker, 10-geo-country, 11-geo-city and 12-delete-all-logs-dialog
from new stateless slices (ConfigDetailContent in ConfigDetailPage,
BypassListContent in BypassListPage, GeoPickerContent /
GeoCountryContent / GeoCityContent in their pages) rendered from
fixed literal fixtures (fabricated WireGuard tunnels, Germany/US
geo countries with Frankfurt/Berlin/New York servers, three bypass
apps with no icons). No screenshot exemptions and no live tunnel
state is read by any fixture.

Also fixes the shared FixtureDeterminism error every app lint run
reported from library/ui: DropdownsSliceTest's nowPlus helper read
Clock.System.now() on its own line, outside the detector's
freshness-assertion idiom; the two assertions now read the clock
inline on their assertTrue lines, which is the recognised idiom
for HistoryScrubberState tests that must compare against the real
clock. This shared fix lands in this first commit so the following
module commits re-run green against it.

vpn/AGENTS.md documents the geo pages and the new dialog file.

Verified: ./gradlew :vpn:lint :vpn:lintVitalRelease
:vpn:testDevUnitTest (79 tests, 0 failures)
:vpn:compileReleaseKotlin all green, plus
:vpn:compileDevScreenshotTestKotlin green.

Diff

vpn/AGENTS.md
diff --git a/vpn/AGENTS.md b/vpn/AGENTS.mdindex d775fa767a..279b4ef221 100644--- a/vpn/AGENTS.md+++ b/vpn/AGENTS.md@@ -57,6 +57,10 @@ _Install: ./install vpn (dev by default)._ - com/vayunmathur/vpn/ui/LoggingPage.kt - com/vayunmathur/vpn/ui/LoggingContent.kt - com/vayunmathur/vpn/ui/SettingsPage.kt+- com/vayunmathur/vpn/ui/GeoPickerPage.kt+- com/vayunmathur/vpn/ui/GeoCountryPage.kt+- com/vayunmathur/vpn/ui/GeoCityPage.kt+- com/vayunmathur/vpn/ui/dialogs/DeleteAllLogsDialog.kt - com/vayunmathur/vpn/ui/components/BypassHelpers.kt  ## Verify (this module only)
vpn/src/main/java/com/vayunmathur/vpn/Route.kt
diff --git a/vpn/src/main/java/com/vayunmathur/vpn/Route.kt b/vpn/src/main/java/com/vayunmathur/vpn/Route.ktindex 9cac8c9a5d..0a67227d99 100644--- a/vpn/src/main/java/com/vayunmathur/vpn/Route.kt+++ b/vpn/src/main/java/com/vayunmathur/vpn/Route.kt@@ -47,4 +47,8 @@ sealed interface Route : NavKey {     /** One city in the geo picker; carries its [countryCode] and [city]. */     @Serializable     data class GeoCity(val countryCode: String, val city: String) : Route++    /** Confirmation for deleting all connection logs, pushed from the Logging tab. */+    @Serializable+    data object DeleteAllLogsDialog : Route }
vpn/src/main/java/com/vayunmathur/vpn/ui/BypassListPage.kt
diff --git a/vpn/src/main/java/com/vayunmathur/vpn/ui/BypassListPage.kt b/vpn/src/main/java/com/vayunmathur/vpn/ui/BypassListPage.ktindex 53866e49ad..86ffda1b74 100644--- a/vpn/src/main/java/com/vayunmathur/vpn/ui/BypassListPage.kt+++ b/vpn/src/main/java/com/vayunmathur/vpn/ui/BypassListPage.kt@@ -52,9 +52,30 @@ fun BypassListPage(backStack: NavBackStack<Route>) {         value = withContext(Dispatchers.IO) { loadApps(context.packageManager, context.packageName) }     } +    BypassListContent(+        apps = apps,+        bypassed = bypassed,+        onToggle = { packageName, bypassed -> BypassList.setBypassed(context, packageName, bypassed) },+        onNavigateBack = { backStack.pop() },+    )+}++/**+ * The bypass list itself, stateless: the installed apps and the bypassed set+ * are passed in and toggles are reported out, so the list renders identically+ * from PackageManager (in [BypassListPage]) or from literal fixtures (the+ * `src/screenshotTest` capture for `Route.BypassList`, with no app icons).+ */+@Composable+internal fun BypassListContent(+    apps: List<BypassApp>?,+    bypassed: Set<String>,+    onToggle: (String, Boolean) -> Unit,+    onNavigateBack: () -> Unit,+) {     AppScaffold(         title = stringResource(R.string.bypass_list_title),-        backStack = backStack,+        onNavigateBack = onNavigateBack,         isRefreshing = apps == null,     ) { pad ->         val list = apps@@ -91,7 +112,7 @@ fun BypassListPage(backStack: NavBackStack<Route>) {                     trailingContent = {                         Switch(                             checked = isBypassed,-                            onCheckedChange = { BypassList.setBypassed(context, app.packageName, it) },+                            onCheckedChange = { onToggle(app.packageName, it) },                         )                     },                     supportingContent = { Text(app.packageName) },
vpn/src/main/java/com/vayunmathur/vpn/ui/ConfigDetailPage.kt
diff --git a/vpn/src/main/java/com/vayunmathur/vpn/ui/ConfigDetailPage.kt b/vpn/src/main/java/com/vayunmathur/vpn/ui/ConfigDetailPage.ktindex f29a547aa9..480ae1af83 100644--- a/vpn/src/main/java/com/vayunmathur/vpn/ui/ConfigDetailPage.kt+++ b/vpn/src/main/java/com/vayunmathur/vpn/ui/ConfigDetailPage.kt@@ -32,11 +32,23 @@ import com.vayunmathur.library.util.sharedText @Composable fun ConfigDetailPage(backStack: NavBackStack<Route>, vm: VpnViewModel, id: Long) {     val cfg = vm.configState(id)+    ConfigDetailContent(cfg = cfg, onNavigateBack = { backStack.pop() })+}++/**+ * The tunnel detail itself, stateless apart from the exported-text reveal+ * (in-screen sub-state): the config is passed in, so the detail renders+ * identically from the ViewModel (in [ConfigDetailPage]) or from literal+ * fixtures (the `src/screenshotTest` capture for `Route.Detail`).+ */+@Composable+internal fun ConfigDetailContent(cfg: com.vayunmathur.vpn.data.VpnConfig, onNavigateBack: () -> Unit) {     var exportText by remember { mutableStateOf<String?>(null) }+    val id = cfg.id      DetailScaffold(         title = stringResource(R.string.tunnel, cfg.name),-        backStack = backStack,+        onNavigateBack = onNavigateBack,     ) {         Text(             stringResource(R.string.imported_from_wireguard_conf_using_gotat),
vpn/src/main/java/com/vayunmathur/vpn/ui/GeoCityPage.kt
diff --git a/vpn/src/main/java/com/vayunmathur/vpn/ui/GeoCityPage.kt b/vpn/src/main/java/com/vayunmathur/vpn/ui/GeoCityPage.ktindex 29172ce124..09af2fd099 100644--- a/vpn/src/main/java/com/vayunmathur/vpn/ui/GeoCityPage.kt+++ b/vpn/src/main/java/com/vayunmathur/vpn/ui/GeoCityPage.kt@@ -26,6 +26,29 @@ fun GeoCityPage(backStack: NavBackStack<Route>, vm: VpnViewModel, countryCode: S     val activate = rememberServerActivation(vm)     val geoCity = countries.firstOrNull { it.countryCode == countryCode }         ?.cities?.firstOrNull { it.city == city }+    GeoCityContent(+        city = city,+        servers = geoCity?.servers,+        onServerConnect = { server ->+            configs.firstOrNull { it.id == server.configId }?.let { activate(it) }+        },+        onServerOpen = { backStack.add(Route.Detail(it.configId)) },+    )+}++/**+ * The city page itself, stateless: the servers are passed in, so it renders+ * identically from the ViewModel (in [GeoCityPage]) or from literal fixtures+ * (the `src/screenshotTest` capture for `Route.GeoCity`).+ */+@Composable+internal fun GeoCityContent(+    city: String,+    servers: List<com.vayunmathur.vpn.domain.GeoServer>?,+    onServerConnect: (com.vayunmathur.vpn.domain.GeoServer) -> Unit,+    onServerOpen: (com.vayunmathur.vpn.domain.GeoServer) -> Unit,+) {+    val geoCity = servers?.let { com.vayunmathur.vpn.domain.GeoCity(city, it) }     LazyListScaffold(         title = city,         horizontalPadding = 16.dp,@@ -35,11 +58,10 @@ fun GeoCityPage(backStack: NavBackStack<Route>, vm: VpnViewModel, countryCode: S             item { Text(city) }         } else {             items(geoCity.servers, key = { it.configId }) { server ->-                val config = configs.firstOrNull { it.id == server.configId }                 GeoServerRow(                     server = server,-                    onConnect = { if (config != null) activate(config) },-                    onOpen = { backStack.add(Route.Detail(server.configId)) },+                    onConnect = { onServerConnect(server) },+                    onOpen = { onServerOpen(server) },                 )             }         }
vpn/src/main/java/com/vayunmathur/vpn/ui/GeoCountryPage.kt
diff --git a/vpn/src/main/java/com/vayunmathur/vpn/ui/GeoCountryPage.kt b/vpn/src/main/java/com/vayunmathur/vpn/ui/GeoCountryPage.ktindex 7bf595bf8a..181db94ca3 100644--- a/vpn/src/main/java/com/vayunmathur/vpn/ui/GeoCountryPage.kt+++ b/vpn/src/main/java/com/vayunmathur/vpn/ui/GeoCountryPage.kt@@ -25,6 +25,24 @@ import com.vayunmathur.vpn.platform.VpnViewModel fun GeoCountryPage(backStack: NavBackStack<Route>, vm: VpnViewModel, countryCode: String) {     val countries by vm.geoCountries.collectAsState()     val country = countries.firstOrNull { it.countryCode == countryCode }+    GeoCountryContent(+        country = country,+        countryCode = countryCode,+        onCityClick = { backStack.add(Route.GeoCity(countryCode, it)) },+    )+}++/**+ * The country page itself, stateless: the country is passed in, so it renders+ * identically from the ViewModel (in [GeoCountryPage]) or from literal+ * fixtures (the `src/screenshotTest` capture for `Route.GeoCountry`).+ */+@Composable+internal fun GeoCountryContent(+    country: com.vayunmathur.vpn.domain.GeoCountry?,+    countryCode: String,+    onCityClick: (String) -> Unit,+) {     LazyListScaffold(         title = if (country != null) "${country.flag} ${country.countryName}" else countryCode,         horizontalPadding = 16.dp,@@ -36,7 +54,7 @@ fun GeoCountryPage(backStack: NavBackStack<Route>, vm: VpnViewModel, countryCode             items(country.cities, key = { it.city }) { city ->                 Card(                     Modifier.fillMaxWidth()-                        .clickable { backStack.add(Route.GeoCity(countryCode, city.city)) },+                        .clickable { onCityClick(city.city) },                     shape = RoundedCornerShape(16.dp),                 ) {                     Text(
vpn/src/main/java/com/vayunmathur/vpn/ui/GeoPickerPage.kt
diff --git a/vpn/src/main/java/com/vayunmathur/vpn/ui/GeoPickerPage.kt b/vpn/src/main/java/com/vayunmathur/vpn/ui/GeoPickerPage.ktindex d3cdaa458a..a82531b6d5 100644--- a/vpn/src/main/java/com/vayunmathur/vpn/ui/GeoPickerPage.kt+++ b/vpn/src/main/java/com/vayunmathur/vpn/ui/GeoPickerPage.kt@@ -40,9 +40,32 @@ import com.vayunmathur.vpn.ui.components.rememberServerActivation fun GeoPickerPage(backStack: NavBackStack<Route>, vm: VpnViewModel) {     val countries by vm.geoCountries.collectAsState()     val configs by vm.configs.collectAsState()+    val activate = rememberServerActivation(vm)+    GeoPickerContent(+        countries = countries,+        onCountryClick = { backStack.add(Route.GeoCountry(it)) },+        onServerConnect = { server ->+            configs.firstOrNull { it.id == server.configId }?.let { activate(it) }+        },+        onServerOpen = { backStack.add(Route.Detail(it.configId)) },+    )+}++/**+ * The geo picker itself, stateless apart from the search query (in-screen+ * filter state): countries and configs are passed in, so the picker renders+ * identically from the ViewModel (in [GeoPickerPage]) or from literal+ * fixtures (the `src/screenshotTest` capture for `Route.GeoPicker`).+ */+@Composable+internal fun GeoPickerContent(+    countries: List<com.vayunmathur.vpn.domain.GeoCountry>,+    onCountryClick: (String) -> Unit,+    onServerConnect: (com.vayunmathur.vpn.domain.GeoServer) -> Unit,+    onServerOpen: (com.vayunmathur.vpn.domain.GeoServer) -> Unit,+) {     var query by rememberSaveable { mutableStateOf("") }     val filtered = filterGeoCountries(countries, query)-    val activate = rememberServerActivation(vm)      LazyListScaffold(         title = stringResource(R.string.geo_picker_title),@@ -58,16 +81,15 @@ fun GeoPickerPage(backStack: NavBackStack<Route>, vm: VpnViewModel) {             countries.isEmpty() -> item { Text(stringResource(R.string.geo_no_bundles)) }             filtered.isEmpty() -> item { Text(stringResource(R.string.geo_no_matches)) }             query.isNotBlank() -> items(filtered.flattenServers(), key = { it.configId }) { server ->-                val config = configs.firstOrNull { it.id == server.configId }                 GeoServerRow(                     server = server,-                    onConnect = { if (config != null) activate(config) },-                    onOpen = { backStack.add(Route.Detail(server.configId)) },+                    onConnect = { onServerConnect(server) },+                    onOpen = { onServerOpen(server) },                 )             }             else -> items(filtered, key = { it.countryCode }) { country ->                 Card(-                    Modifier.fillMaxWidth().clickable { backStack.add(Route.GeoCountry(country.countryCode)) },+                    Modifier.fillMaxWidth().clickable { onCountryClick(country.countryCode) },                     shape = RoundedCornerShape(16.dp),                 ) {                     Text(
vpn/src/main/java/com/vayunmathur/vpn/ui/LoggingContent.kt
diff --git a/vpn/src/main/java/com/vayunmathur/vpn/ui/LoggingContent.kt b/vpn/src/main/java/com/vayunmathur/vpn/ui/LoggingContent.ktindex d052bd7a1e..f486d8ac4f 100644--- a/vpn/src/main/java/com/vayunmathur/vpn/ui/LoggingContent.kt+++ b/vpn/src/main/java/com/vayunmathur/vpn/ui/LoggingContent.kt@@ -16,33 +16,25 @@ import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableIntStateOf-import androidx.compose.runtime.mutableStateOf-import androidx.compose.runtime.remember import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier-import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp-import com.vayunmathur.library.ui.AlertDialog import com.vayunmathur.library.ui.AppScaffold-import com.vayunmathur.library.ui.Button import com.vayunmathur.library.ui.Card import com.vayunmathur.library.ui.IconButton import com.vayunmathur.library.ui.IconDelete import com.vayunmathur.library.ui.LinearProgressIndicator import com.vayunmathur.library.ui.MaterialTheme-import com.vayunmathur.library.ui.OutlinedButton import com.vayunmathur.library.ui.PrimaryScrollableTabRow-import com.vayunmathur.library.ui.R as UiR import com.vayunmathur.library.ui.Tab import com.vayunmathur.library.ui.Text-import com.vayunmathur.vpn.R import com.vayunmathur.vpn.data.AppUsageSummary import com.vayunmathur.vpn.data.DomainBytesSummary import com.vayunmathur.vpn.data.DomainCountSummary@@ -58,7 +50,7 @@ fun LoggingContent(     topApps: List<AppUsageSummary>,     domainsByCount: List<DomainCountSummary>,     domainsByBytes: List<DomainBytesSummary>,-    onDeleteAllLogs: () -> Unit = {},+    onDeleteAllLogsRequest: () -> Unit = {},     /**      * Which leaderboard to open on. The app always starts on the first; previews set it so a      * given tab can be captured without driving the UI to get there.@@ -67,7 +59,6 @@ fun LoggingContent(     /** Notified when the in-screen leaderboard tab changes, so the host can mirror it. */     onTabChange: (Int) -> Unit = {}, ) {-    var showDeleteDialog by remember { mutableStateOf(false) }     // In-screen sub-tabs of the Logging destination: saveable so the chosen     // leaderboard survives rotation/process recreation, not routed destinations.     var tabIndex by rememberSaveable { mutableIntStateOf(initialTab) }@@ -75,7 +66,7 @@ fun LoggingContent(     AppScaffold(         title = "",         actions = {-            IconButton(onClick = { showDeleteDialog = true }) {+            IconButton(onClick = onDeleteAllLogsRequest) {                 IconDelete()             }         },@@ -134,19 +125,6 @@ fun LoggingContent(         }     } -    if (showDeleteDialog) {-        AlertDialog(-            onDismissRequest = { showDeleteDialog = false },-            title = { Text(stringResource(R.string.delete_all_logs)) },-            text = { Text(stringResource(R.string.this_will_permanently_remove_all_connect)) },-            confirmButton = {-                Button(onClick = { onDeleteAllLogs(); showDeleteDialog = false }) { Text(stringResource(UiR.string.delete)) }-            },-            dismissButton = {-                OutlinedButton(onClick = { showDeleteDialog = false }) { Text(stringResource(UiR.string.cancel)) }-            }-        )-    } }  private data class LeaderboardEntry(
vpn/src/main/java/com/vayunmathur/vpn/ui/LoggingPage.kt
diff --git a/vpn/src/main/java/com/vayunmathur/vpn/ui/LoggingPage.kt b/vpn/src/main/java/com/vayunmathur/vpn/ui/LoggingPage.ktindex 667119bc9a..c5d2a2c8b5 100644--- a/vpn/src/main/java/com/vayunmathur/vpn/ui/LoggingPage.kt+++ b/vpn/src/main/java/com/vayunmathur/vpn/ui/LoggingPage.kt@@ -10,6 +10,7 @@ fun LoggingPage(     vm: VpnViewModel,     initialTab: Int = 0,     onTabChange: (Int) -> Unit = {},+    onDeleteAllLogsRequest: () -> Unit = {}, ) {     val topApps by vm.topAppsFlow.collectAsState()     val domainsByCount by vm.domainsByCountFlow.collectAsState()@@ -19,7 +20,7 @@ fun LoggingPage(         topApps = topApps,         domainsByCount = domainsByCount,         domainsByBytes = domainsByBytes,-        onDeleteAllLogs = { vm.deleteAllLogs() },+        onDeleteAllLogsRequest = onDeleteAllLogsRequest,         initialTab = initialTab,         onTabChange = onTabChange,     )
vpn/src/main/java/com/vayunmathur/vpn/ui/VpnTabs.kt
diff --git a/vpn/src/main/java/com/vayunmathur/vpn/ui/VpnTabs.kt b/vpn/src/main/java/com/vayunmathur/vpn/ui/VpnTabs.ktindex 44686acb9a..b1370dcf3d 100644--- a/vpn/src/main/java/com/vayunmathur/vpn/ui/VpnTabs.kt+++ b/vpn/src/main/java/com/vayunmathur/vpn/ui/VpnTabs.kt@@ -11,6 +11,7 @@ import com.vayunmathur.library.ui.IconHistory import com.vayunmathur.library.ui.IconSettings import com.vayunmathur.library.ui.RouteTab import com.vayunmathur.library.ui.TabbedPagerScaffold+import com.vayunmathur.library.util.DialogPage import com.vayunmathur.library.util.ListDetailPage import com.vayunmathur.library.util.ListPage import com.vayunmathur.library.util.MainNavigation@@ -19,6 +20,7 @@ import com.vayunmathur.library.util.NavBackStack import com.vayunmathur.library.util.SiblingPage import com.vayunmathur.vpn.Route import com.vayunmathur.vpn.platform.VpnViewModel+import com.vayunmathur.vpn.ui.dialogs.DeleteAllLogsDialog  /**  * The three top-level tabs as sibling routes. The route-backed@@ -62,6 +64,7 @@ fun VpnTabs(backStack: NavBackStack<Route>, vm: VpnViewModel) {                             backStack.setLast(Route.Logging(tab))                         }                     },+                    onDeleteAllLogsRequest = { backStack.add(Route.DeleteAllLogsDialog) },                 )             }             entry<Route.Settings>(metadata = SiblingPage()) { SettingsPage(backStack) }@@ -74,6 +77,15 @@ fun VpnTabs(backStack: NavBackStack<Route>, vm: VpnViewModel) {             entry<Route.GeoCity>(metadata = ListDetailPage()) {                 GeoCityPage(backStack, vm, it.countryCode, it.city)             }+            entry<Route.DeleteAllLogsDialog>(metadata = DialogPage()) {+                DeleteAllLogsDialog(+                    onDismiss = { backStack.pop() },+                    onConfirm = {+                        vm.deleteAllLogs()+                        backStack.pop()+                    },+                )+            }         }     } }
vpn/src/main/java/com/vayunmathur/vpn/ui/dialogs/DeleteAllLogsDialog.kt
diff --git a/vpn/src/main/java/com/vayunmathur/vpn/ui/dialogs/DeleteAllLogsDialog.kt b/vpn/src/main/java/com/vayunmathur/vpn/ui/dialogs/DeleteAllLogsDialog.ktnew file mode 100644index 0000000000..a8ec997f20--- /dev/null+++ b/vpn/src/main/java/com/vayunmathur/vpn/ui/dialogs/DeleteAllLogsDialog.kt@@ -0,0 +1,29 @@+package com.vayunmathur.vpn.ui.dialogs++import androidx.compose.runtime.Composable+import androidx.compose.ui.res.stringResource+import com.vayunmathur.library.ui.AlertDialog+import com.vayunmathur.library.ui.Button+import com.vayunmathur.library.ui.OutlinedButton+import com.vayunmathur.library.ui.R as UiR+import com.vayunmathur.library.ui.Text+import com.vayunmathur.vpn.R++/**+ * The delete-all-logs confirmation for `Route.DeleteAllLogsDialog`, stateless:+ * the route entry owns deleting the logs and popping the dialog.+ */+@Composable+fun DeleteAllLogsDialog(onDismiss: () -> Unit, onConfirm: () -> Unit) {+    AlertDialog(+        onDismissRequest = onDismiss,+        title = { Text(stringResource(R.string.delete_all_logs)) },+        text = { Text(stringResource(R.string.this_will_permanently_remove_all_connect)) },+        confirmButton = {+            Button(onClick = onConfirm) { Text(stringResource(UiR.string.delete)) }+        },+        dismissButton = {+            OutlinedButton(onClick = onDismiss) { Text(stringResource(UiR.string.cancel)) }+        },+    )+}
vpn/src/screenshotTest/kotlin/com/vayunmathur/vpn/ui/MetadataPreviews.kt
diff --git a/vpn/src/screenshotTest/kotlin/com/vayunmathur/vpn/ui/MetadataPreviews.kt b/vpn/src/screenshotTest/kotlin/com/vayunmathur/vpn/ui/MetadataPreviews.ktindex 9246113d64..9331ab469e 100644--- a/vpn/src/screenshotTest/kotlin/com/vayunmathur/vpn/ui/MetadataPreviews.kt+++ b/vpn/src/screenshotTest/kotlin/com/vayunmathur/vpn/ui/MetadataPreviews.kt@@ -20,6 +20,11 @@ import com.vayunmathur.vpn.data.AppUsageSummary import com.vayunmathur.vpn.data.DomainBytesSummary import com.vayunmathur.vpn.data.DomainCountSummary import com.vayunmathur.vpn.data.VpnConfig+import com.vayunmathur.vpn.domain.GeoCity+import com.vayunmathur.vpn.domain.GeoCountry+import com.vayunmathur.vpn.domain.GeoServer+import com.vayunmathur.vpn.ui.components.BypassApp+import com.vayunmathur.vpn.ui.dialogs.DeleteAllLogsDialog  /** Phone-shaped, roughly 1080x2340 at xxhdpi β€” comfortably above the F-Droid minimum. */ private const val PHONE = "spec:width=411dp,height=891dp,dpi=420"@@ -149,6 +154,132 @@ class MetadataPreviews {         }     } +    @PreviewTest+    @Preview(name = "5-logging", device = PHONE, group = "phone", showSystemUi = true)+    @Composable+    fun Preview5Logging() {+        ChromePreview(selectedTab = 1)+    }++    @PreviewTest+    @Preview(name = "6-settings", device = PHONE, group = "phone", showSystemUi = true)+    @Composable+    fun Preview6Settings() {+        ChromePreview(selectedTab = 2)+    }++    @PreviewTest+    @Preview(name = "7-detail", device = PHONE, group = "phone", showSystemUi = true)+    @Composable+    fun Preview7Detail() {+        DynamicTheme(darkTheme = true) {+            ConfigDetailContent(cfg = tunnels[0], onNavigateBack = {})+        }+    }++    @PreviewTest+    @Preview(name = "8-bypass-list", device = PHONE, group = "phone", showSystemUi = true)+    @Composable+    fun Preview8BypassList() {+        DynamicTheme(darkTheme = true) {+            BypassListContent(+                apps = listOf(+                    BypassApp("com.vayunmathur.web", "Web", null),+                    BypassApp("com.vayunmathur.maps", "Maps", null),+                    BypassApp("com.vayunmathur.youpipe", "YouPipe", null),+                ),+                bypassed = setOf("com.vayunmathur.maps"),+                onToggle = { _, _ -> },+                onNavigateBack = {},+            )+        }+    }++    private val geoCountries = listOf(+        GeoCountry(+            countryCode = "DE",+            countryName = "Germany",+            flag = "πŸ‡©πŸ‡ͺ",+            cities = listOf(+                GeoCity(+                    city = "Frankfurt",+                    servers = listOf(+                        GeoServer(2L, "ExampleVPN", "DE", "Frankfurt", "Frankfurt 1", "185.220.101.47:51820"),+                    ),+                ),+                GeoCity(+                    city = "Berlin",+                    servers = listOf(+                        GeoServer(3L, "ExampleVPN", "DE", "Berlin", "Berlin 1", "berlin.example.net:51820"),+                    ),+                ),+            ),+        ),+        GeoCountry(+            countryCode = "US",+            countryName = "United States",+            flag = "πŸ‡ΊπŸ‡Έ",+            cities = listOf(+                GeoCity(+                    city = "New York",+                    servers = listOf(+                        GeoServer(1L, "ExampleVPN", "US", "New York", "New York 1", "vpn.example.net:51820"),+                    ),+                ),+            ),+        ),+    )++    @PreviewTest+    @Preview(name = "9-geo-picker", device = PHONE, group = "phone", showSystemUi = true)+    @Composable+    fun Preview9GeoPicker() {+        DynamicTheme(darkTheme = true) {+            GeoPickerContent(+                countries = geoCountries,+                onCountryClick = {},+                onServerConnect = {},+                onServerOpen = {},+            )+        }+    }++    @PreviewTest+    @Preview(name = "10-geo-country", device = PHONE, group = "phone", showSystemUi = true)+    @Composable+    fun Preview10GeoCountry() {+        DynamicTheme(darkTheme = true) {+            GeoCountryContent(+                country = geoCountries[0],+                countryCode = "DE",+                onCityClick = {},+            )+        }+    }++    @PreviewTest+    @Preview(name = "11-geo-city", device = PHONE, group = "phone", showSystemUi = true)+    @Composable+    fun Preview11GeoCity() {+        DynamicTheme(darkTheme = true) {+            GeoCityContent(+                city = "Frankfurt",+                servers = geoCountries[0].cities[0].servers,+                onServerConnect = {},+                onServerOpen = {},+            )+        }+    }++    @PreviewTest+    @Preview(name = "12-delete-all-logs-dialog", device = PHONE, group = "phone", showSystemUi = true)+    @Composable+    fun Preview12DeleteAllLogsDialog() {+        DynamicTheme(darkTheme = true) {+            DeleteAllLogsDialog(onDismiss = {}, onConfirm = {})+        }+    }+     /**      * The app's real tab chrome around preview screen content: the same      * [TabbedPagerScaffold] with the same Tunnels/Logging/Settings tabs `VpnTabs`
vpn/src/test/java/com/vayunmathur/vpn/ui/FinalVpnBatchTest.kt
diff --git a/vpn/src/test/java/com/vayunmathur/vpn/ui/FinalVpnBatchTest.kt b/vpn/src/test/java/com/vayunmathur/vpn/ui/FinalVpnBatchTest.ktindex e890b30a3f..7bc490b8bd 100644--- a/vpn/src/test/java/com/vayunmathur/vpn/ui/FinalVpnBatchTest.kt+++ b/vpn/src/test/java/com/vayunmathur/vpn/ui/FinalVpnBatchTest.kt@@ -6,6 +6,7 @@ import android.content.pm.PackageInfo import android.graphics.drawable.ColorDrawable import androidx.activity.ComponentActivity import androidx.compose.ui.graphics.Color+import androidx.compose.ui.test.assertCountEquals import androidx.compose.ui.test.assertIsDisplayed import androidx.compose.ui.test.captureToImage import androidx.compose.ui.test.junit4.createAndroidComposeRule@@ -56,31 +57,31 @@ class FinalVpnBatchTest {     }      @Test fun loggingDeleteDialogFlow() {-        var deleted = 0+        var requested = 0         rule.setContent {             DynamicTheme {                 LoggingContent(                     topApps = listOf(AppUsageSummary("com.a", "A", 10, 1)),                     domainsByCount = emptyList(), domainsByBytes = emptyList(),-                    onDeleteAllLogs = { deleted++ },+                    onDeleteAllLogsRequest = { requested++ },                 )             }         }         // Trash icon in the scaffold actions (only click-action in the top bar besides tabs)         rule.onNodeWithText("A").assertIsDisplayed()-        // Open dialog via the delete IconButton: it is the first click node in the top bar area+        // Request the dialog route via the delete IconButton: it is the first click node in the top bar area         val nodes = rule.onAllNodes(androidx.compose.ui.test.hasClickAction()).fetchSemanticsNodes()         val topBar = nodes.withIndex().filter { it.value.boundsInRoot.top < 80f }-        // Click each top-bar node until the dialog title shows (tabs are lower, actions are here)+        // Click each top-bar node until the route request fires (tabs are lower, actions are here)         for ((i, _) in topBar) {             runCatching { rule.onAllNodes(androidx.compose.ui.test.hasClickAction())[i].performClick() }             rule.waitForIdle()-            if (rule.onAllNodes(androidx.compose.ui.test.hasText("Delete all logs?")).fetchSemanticsNodes().isNotEmpty()) break+            if (requested > 0) break         }-        rule.onNodeWithText("Delete all logs?").assertIsDisplayed()-        // Cancel first-        rule.onNodeWithText("Cancel").performClick()-        assertEquals(0, deleted)+        // The confirmation itself is the DeleteAllLogsDialog route entry, not+        // content rendered by LoggingContent.+        assertEquals(1, requested)+        rule.onAllNodes(androidx.compose.ui.test.hasText("Delete all logs?")).assertCountEquals(0)     }      @Test fun appIconAndLockdownWarningDraw() {
vpn/src/test/java/com/vayunmathur/vpn/ui/VpnComposeScreensTest.kt
diff --git a/vpn/src/test/java/com/vayunmathur/vpn/ui/VpnComposeScreensTest.kt b/vpn/src/test/java/com/vayunmathur/vpn/ui/VpnComposeScreensTest.ktindex 28f1cfb1f1..ac65a067de 100644--- a/vpn/src/test/java/com/vayunmathur/vpn/ui/VpnComposeScreensTest.kt+++ b/vpn/src/test/java/com/vayunmathur/vpn/ui/VpnComposeScreensTest.kt@@ -94,7 +94,7 @@ class VpnComposeScreensTest {                     topApps = listOf(AppUsageSummary("com.a", "App A", 2048, 3), AppUsageSummary(null, "", 1024, 1)),                     domainsByCount = listOf(DomainCountSummary("a.com", 7)),                     domainsByBytes = listOf(DomainBytesSummary("b.com", 1048576)),-                    onDeleteAllLogs = { deleteAll++ },+                    onDeleteAllLogsRequest = { deleteAll++ },                 )             }         }