Modern Apps git

← Modern-Apps.git

networklocation: add setup and status screenshot captures

Commit
a7053e1f332923f8cbe984f584e22ab00af5e148
Author
Vayun Mathur <[email protected]>
When
2026-12-04 23:44 UTC (1 day ago)
Parents
48fae36
Route.Setup and Route.Status had no screenshot capture, so
RouteScreenshotCoverage failed :networklocation:lintVitalRelease
on a clean checkout of main (verified before this change: two
errors, at Route.kt lines 9 and 13) and blocked assembleRelease
and install for the module.

Add a MetadataPreviews class under src/screenshotTest, following
the backup reference module: the common-conventions-preview-
metadata plugin in build.gradle.kts, a PHONE device spec, the
repo-standard phone form-factor bucket (networklocation had no
previews of its own to take a bucket from), @PreviewTest plus
@Preview on class members, and DynamicTheme. The captures are
named 1-setup and 2-status, numbered in route order, and render
the real SetupScreen and StatusScreen with no arguments beyond
the screens' own fixed copy, so they are reproducible from a
clean checkout.

The real screens could not render in Layoutlib at all:
OfflineDatabaseSection reads the offline databases from
device-protected storage and their progress from DataStore,
and both fail there (createDeviceProtectedStorageContext
returns null) instead of reporting the databases absent. Add a
LocalInspectionMode branch to that section, the short-circuit
pattern already used for previews elsewhere in the repo, which
renders the fixed no-databases-installed state (blurb, three
zero-progress rows, disabled download button); production
behaviour is unchanged. AGENTS.md now records screenshotTest:
yes for the module.

Verified fresh with rm -rf networklocation/build and
./gradlew :networklocation:lint :networklocation:lintVitalRelease
:networklocation:testDevUnitTest --rerun-tasks (BUILD SUCCESSFUL;
in that combined invocation AGP skips the vital task, so
:networklocation:lintVitalRelease --rerun-tasks was also run
standalone and executed green). Additionally
:networklocation:updateDevScreenshotTest renders both previews
and the PNGs were inspected: setup shows the provider blurb and
download rows, status shows the live-check cards above the same
section. :networklocation:ktlintCheck still fails on pre-existing
style violations in untouched src/test files; the main source
set, including this change, is clean.

Diff

networklocation/AGENTS.md
diff --git a/networklocation/AGENTS.md b/networklocation/AGENTS.mdindex e6e4120749..931c5e33b1 100644--- a/networklocation/AGENTS.md+++ b/networklocation/AGENTS.md@@ -8,7 +8,7 @@ _Install: ./install networklocation (dev by default)._ - Entry files: MainActivity.kt (database-setup UI) + provider/LocationProviderImpl.kt (system provider entry) - Deps: :library:locationprovider, :library:downloadservice - Metadata: metadata_data/networklocation.md (present)-- Rust: yes / screenshotTest: no+- Rust: yes / screenshotTest: yes  ## Overview **Purpose:** Privileged system network-location + geocoder provider — Wi-Fi/cell fixes without GPS and offline geocoding, solved on-device in Rust. Beacons never leave the phone; internet only for one-time offline-DB downloads.
networklocation/build.gradle.kts
diff --git a/networklocation/build.gradle.kts b/networklocation/build.gradle.ktsindex 058f9ec144..24abc048b6 100644--- a/networklocation/build.gradle.kts+++ b/networklocation/build.gradle.kts@@ -1,5 +1,8 @@ plugins {     id("common-conventions-app")+    // Listing screenshots come from Compose previews (src/screenshotTest), not from an+    // instrumented test on a device. Same `:networklocation:metadata` task name either way.+    id("common-conventions-preview-metadata") }  launcherIcon {
networklocation/src/main/java/com/vayunmathur/networklocation/ui/OfflineDatabaseSection.kt
diff --git a/networklocation/src/main/java/com/vayunmathur/networklocation/ui/OfflineDatabaseSection.kt b/networklocation/src/main/java/com/vayunmathur/networklocation/ui/OfflineDatabaseSection.ktindex 9912a541db..99cbf34702 100644--- a/networklocation/src/main/java/com/vayunmathur/networklocation/ui/OfflineDatabaseSection.kt+++ b/networklocation/src/main/java/com/vayunmathur/networklocation/ui/OfflineDatabaseSection.kt@@ -13,6 +13,7 @@ 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.platform.LocalInspectionMode import androidx.compose.ui.unit.dp import com.vayunmathur.library.downloadservice.FileProgressItem import com.vayunmathur.library.downloadservice.ModelDownloadItem@@ -35,6 +36,27 @@ import com.vayunmathur.networklocation.platform.OfflineDatabases  */ @Composable fun OfflineDatabaseSection(modifier: Modifier = Modifier, onReady: () -> Unit = {}) {+    // Screenshot previews render this section with no databases installed. Layoutlib has+    // no device-protected storage or DataStore to read that state from (both fail there+    // rather than reporting "absent"), so previews short-circuit to that fixed state.+    if (LocalInspectionMode.current) {+        Column(modifier) {+            Text("Offline databases", style = MaterialTheme.typography.titleMedium)+            OfflineDatabaseBlurb()+            for ((_, label, _) in offlineDatabaseEntries()) {+                FileProgressItem(label = label, progress = 0.0, speedMbps = 0.0, isDone = false)+            }+            Button(+                onClick = {},+                enabled = false,+                modifier = Modifier.fillMaxWidth().padding(top = 16.dp),+            ) {+                Text("Download offline databases")+            }+        }+        return+    }+     val context = LocalContext.current     val ds = remember { DataStoreUtils.getInstance(context) } 
networklocation/src/screenshotTest/kotlin/com/vayunmathur/networklocation/ui/MetadataPreviews.kt
diff --git a/networklocation/src/screenshotTest/kotlin/com/vayunmathur/networklocation/ui/MetadataPreviews.kt b/networklocation/src/screenshotTest/kotlin/com/vayunmathur/networklocation/ui/MetadataPreviews.ktnew file mode 100644index 0000000000..04ccdec931--- /dev/null+++ b/networklocation/src/screenshotTest/kotlin/com/vayunmathur/networklocation/ui/MetadataPreviews.kt@@ -0,0 +1,44 @@+package com.vayunmathur.networklocation.ui++import androidx.compose.runtime.Composable+import androidx.compose.ui.tooling.preview.Preview+import com.android.tools.screenshot.PreviewTest+import com.vayunmathur.library.ui.DynamicTheme++/** Phone-shaped, roughly 1080x2340 at xxhdpi — comfortably above the F-Droid minimum. */+private const val PHONE = "spec:width=411dp,height=891dp,dpi=420"++/**+ * Store-listing images for `:networklocation`, rendered from Compose previews instead+ * of an instrumented test on a device (the privileged provider needs a platform-signed+ * install and cannot run here).+ *+ * `./gradlew :networklocation:metadata` renders these and copies the PNGs into+ * `metadata_data/photos/networklocation/`, where `release.sh` picks them up.+ *+ * Each preview must carry @PreviewTest as well as @Preview and be a member of a class+ * (not a top-level function) or the screenshot engine silently skips it. Both captures+ * render the deterministic first state of their route on a clean install — no offline+ * databases on disk and no location permission granted — so the output is reproducible+ * from a clean checkout with no literals beyond the screens' own fixed copy.+ */+class MetadataPreviews {++    @PreviewTest+    @Preview(name = "1-setup", device = PHONE, group = "phone", showSystemUi = true)+    @Composable+    fun Preview1Setup() {+        DynamicTheme(darkTheme = true) {+            SetupScreen(onReady = {})+        }+    }++    @PreviewTest+    @Preview(name = "2-status", device = PHONE, group = "phone", showSystemUi = true)+    @Composable+    fun Preview2Status() {+        DynamicTheme(darkTheme = true) {+            StatusScreen()+        }+    }+}