Modern Apps git

← Modern-Apps.git

updater: screenshot previews from scratch; communicate: stateless thread list

Commit
f82781b0def118029ef83fbbcbd1bdc2b12fcdac
Author
vayun-mathur <[email protected]>
When
2026-10-25 22:43 UTC (1 month ago)
Parents
23bfadb

Diff

communicate/src/main/java/com/vayunmathur/communicate/ui/MessagesScreen.kt
diff --git a/communicate/src/main/java/com/vayunmathur/communicate/ui/MessagesScreen.kt b/communicate/src/main/java/com/vayunmathur/communicate/ui/MessagesScreen.ktindex 3a7576c102..28953bcbc9 100644--- a/communicate/src/main/java/com/vayunmathur/communicate/ui/MessagesScreen.kt+++ b/communicate/src/main/java/com/vayunmathur/communicate/ui/MessagesScreen.kt@@ -272,45 +272,66 @@ fun MessagesScreen(onOpenThread: (SmsThread) -> Unit, onOpenAccounts: () -> Unit                         modifier = Modifier.padding(padding),                     )                     else -> {-                        var pendingDelete by remember { mutableStateOf<SmsThread?>(null) }-                        LazyColumn(-                            modifier = Modifier-                                .padding(padding)-                                .fillMaxSize(),-                            contentPadding = PaddingValues(bottom = 88.dp),-                        ) {-                            items(rows, key = { it.threadId }) { thread ->-                                MessageThreadRow(-                                    thread = thread,-                                    onClick = { onOpenThread(thread) },-                                    onDelete = { pendingDelete = thread },-                                )-                                HorizontalDivider(Modifier.padding(horizontal = 16.dp))-                            }-                        }-                        val toDelete = pendingDelete-                        if (toDelete != null) {-                            com.vayunmathur.library.ui.ConfirmDialog(-                                title = stringResource(R.string.delete_conversation_title),-                                message = stringResource(R.string.delete_conversation_message),-                                confirmLabel = stringResource(com.vayunmathur.library.ui.R.string.delete),-                                dismissLabel = stringResource(com.vayunmathur.library.ui.R.string.cancel),-                                destructive = true,-                                onConfirm = {-                                    pendingDelete = null-                                    scope.launch {-                                        val ok = withContext(Dispatchers.IO) {-                                            CommunicateRepository.deleteConversation(context, toDelete)-                                        }-                                        if (ok) tick++ else AppMessages.show(context.getString(R.string.delete_failed))+                        MessagesListContent(+                            threads = rows,+                            modifier = Modifier.padding(padding),+                            onOpenThread = onOpenThread,+                            onDeleteThread = { toDelete ->+                                scope.launch {+                                    val ok = withContext(Dispatchers.IO) {+                                        CommunicateRepository.deleteConversation(context, toDelete)                                     }-                                },-                                onDismiss = { pendingDelete = null },-                            )-                        }+                                    if (ok) tick++ else AppMessages.show(context.getString(R.string.delete_failed))+                                }+                            },+                        )                     }                 }             }         }     } }++/**+ * The thread list, stateless: rows plus the delete-confirm dialog. Split out so+ * screenshot previews can render threads without the SMS provider, the polling+ * loop, or the permission gates above.+ */+@Composable+fun MessagesListContent(+    threads: List<SmsThread>,+    modifier: Modifier = Modifier,+    onOpenThread: (SmsThread) -> Unit,+    onDeleteThread: (SmsThread) -> Unit,+) {+    var pendingDelete by remember { mutableStateOf<SmsThread?>(null) }+    LazyColumn(+        modifier = modifier+            .fillMaxSize(),+        contentPadding = PaddingValues(bottom = 88.dp),+    ) {+        items(threads, key = { it.threadId }) { thread ->+            MessageThreadRow(+                thread = thread,+                onClick = { onOpenThread(thread) },+                onDelete = { pendingDelete = thread },+            )+            HorizontalDivider(Modifier.padding(horizontal = 16.dp))+        }+    }+    val toDelete = pendingDelete+    if (toDelete != null) {+        com.vayunmathur.library.ui.ConfirmDialog(+            title = stringResource(R.string.delete_conversation_title),+            message = stringResource(R.string.delete_conversation_message),+            confirmLabel = stringResource(com.vayunmathur.library.ui.R.string.delete),+            dismissLabel = stringResource(com.vayunmathur.library.ui.R.string.cancel),+            destructive = true,+            onConfirm = {+                pendingDelete = null+                onDeleteThread(toDelete)+            },+            onDismiss = { pendingDelete = null },+        )+    }+}
metadata_data/photos/updater/phone/1.png
diff --git a/metadata_data/photos/updater/phone/1.png b/metadata_data/photos/updater/phone/1.pngnew file mode 100644index 0000000000..9cbf8c525aBinary files /dev/null and b/metadata_data/photos/updater/phone/1.png differ
metadata_data/photos/updater/phone/2.png
diff --git a/metadata_data/photos/updater/phone/2.png b/metadata_data/photos/updater/phone/2.pngnew file mode 100644index 0000000000..f8c1b4622cBinary files /dev/null and b/metadata_data/photos/updater/phone/2.png differ
metadata_data/photos/updater/phone/3.png
diff --git a/metadata_data/photos/updater/phone/3.png b/metadata_data/photos/updater/phone/3.pngnew file mode 100644index 0000000000..67f373aef6Binary files /dev/null and b/metadata_data/photos/updater/phone/3.png differ
metadata_data/photos/updater/phone/4.png
diff --git a/metadata_data/photos/updater/phone/4.png b/metadata_data/photos/updater/phone/4.pngnew file mode 100644index 0000000000..47c0081d82Binary files /dev/null and b/metadata_data/photos/updater/phone/4.png differ
metadata_data/photos/updater/phone/5.png
diff --git a/metadata_data/photos/updater/phone/5.png b/metadata_data/photos/updater/phone/5.pngnew file mode 100644index 0000000000..28683cc21aBinary files /dev/null and b/metadata_data/photos/updater/phone/5.png differ
updater/src/screenshotTest/kotlin/com/vayunmathur/updater/ui/MetadataPreviews.kt
diff --git a/updater/src/screenshotTest/kotlin/com/vayunmathur/updater/ui/MetadataPreviews.kt b/updater/src/screenshotTest/kotlin/com/vayunmathur/updater/ui/MetadataPreviews.ktnew file mode 100644index 0000000000..930b5f70ed--- /dev/null+++ b/updater/src/screenshotTest/kotlin/com/vayunmathur/updater/ui/MetadataPreviews.kt@@ -0,0 +1,111 @@+package com.vayunmathur.updater.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+import com.vayunmathur.updater.domain.UpdateMetadata+import com.vayunmathur.updater.platform.UpdaterUiState++/** 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 `:updater`, rendered from Compose previews instead of an+ * instrumented test on a device (the install path needs a privileged, platform-signed+ * install and cannot run here).+ *+ * `./gradlew :updater:metadata` renders these and copies the PNGs into+ * `metadata_data/photos/updater/`, 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. Everything is+ * a literal so the output is reproducible from a clean checkout.+ */+class MetadataPreviews {++    private val current = UpdaterUiState(+        currentBuild = "v3.2.1-maos",+        autoInstall = true,+        meteredAllowed = false,+    )++    @PreviewTest+    @Preview(name = "1-never-checked", device = PHONE, group = "phone", showSystemUi = true)+    @Composable+    fun Preview1NeverChecked() {+        DynamicTheme(darkTheme = true) {+            UpdaterScreen(+                state = current,+                onCheckNow = {},+                onAutoInstallChanged = {},+                onMeteredAllowedChanged = {},+            )+        }+    }++    @PreviewTest+    @Preview(name = "2-checking", device = PHONE, group = "phone", showSystemUi = true)+    @Composable+    fun Preview2Checking() {+        DynamicTheme(darkTheme = true) {+            UpdaterScreen(+                state = current.copy(checking = true),+                onCheckNow = {},+                onAutoInstallChanged = {},+                onMeteredAllowedChanged = {},+            )+        }+    }++    @PreviewTest+    @Preview(name = "3-up-to-date", device = PHONE, group = "phone", showSystemUi = true)+    @Composable+    fun Preview3UpToDate() {+        DynamicTheme(darkTheme = true) {+            UpdaterScreen(+                state = current.copy(lastCheckedMillis = 1_786_500_000_000L),+                onCheckNow = {},+                onAutoInstallChanged = {},+                onMeteredAllowedChanged = {},+            )+        }+    }++    @PreviewTest+    @Preview(name = "4-available", device = PHONE, group = "phone", showSystemUi = true)+    @Composable+    fun Preview4Available() {+        DynamicTheme(darkTheme = true) {+            UpdaterScreen(+                state = current.copy(+                    lastCheckedMillis = 1_786_500_000_000L,+                    available = UpdateMetadata(+                        build = "v3.3.0-maos",+                        buildDateUtcSeconds = 1_786_585_200L,+                    ),+                ),+                onCheckNow = {},+                onAutoInstallChanged = {},+                onMeteredAllowedChanged = {},+            )+        }+    }++    @PreviewTest+    @Preview(name = "5-failed", device = PHONE, group = "phone", showSystemUi = true)+    @Composable+    fun Preview5Failed() {+        DynamicTheme(darkTheme = true) {+            UpdaterScreen(+                state = current.copy(+                    lastCheckedMillis = 1_786_500_000_000L,+                    lastFailure = "could not reach https://ota.example.com/shiba-stable",+                ),+                onCheckNow = {},+                onAutoInstallChanged = {},+                onMeteredAllowedChanged = {},+            )+        }+    }+}