Modern Apps git

← Modern-Apps.git

euicc: add store metadata and screenshot previews

Commit
940538a772d46b8d284c8fa70c8f120af2162d0a
Author
Vayun Mathur <[email protected]>
When
2026-08-12 16:53 UTC (3 months ago)
Parents
5cc368a

Diff

euicc/src/main/java/com/vayunmathur/euicc/ui/EuiccApp.kt
diff --git a/euicc/src/main/java/com/vayunmathur/euicc/ui/EuiccApp.kt b/euicc/src/main/java/com/vayunmathur/euicc/ui/EuiccApp.ktindex 0c8b6b7e4e..78f1ca6474 100644--- a/euicc/src/main/java/com/vayunmathur/euicc/ui/EuiccApp.kt+++ b/euicc/src/main/java/com/vayunmathur/euicc/ui/EuiccApp.kt@@ -36,7 +36,30 @@ import com.vayunmathur.library.ui.TextButton  @Composable fun EuiccApp(viewModel: EuiccViewModel) {-    val state = viewModel.state+    EuiccScreen(+        state = viewModel.state,+        onReload = viewModel::reload,+        onDownload = viewModel::downloadProfile,+        onEnable = { viewModel.enable(it.iccid) },+        onDisable = { viewModel.disable(it.iccid) },+        onRename = { profile, name -> viewModel.rename(profile.iccid, name) },+        onDelete = { viewModel.delete(it.iccid) },+        onRemoveNotification = { viewModel.removeNotification(it.seqNumber) },+    )+}++/** Stateless LPA screen; all inputs are the [state] and the action callbacks. */+@Composable+fun EuiccScreen(+    state: EuiccScreenState,+    onReload: () -> Unit,+    onDownload: (String) -> Unit,+    onEnable: (Profile) -> Unit,+    onDisable: (Profile) -> Unit,+    onRename: (Profile, String) -> Unit,+    onDelete: (Profile) -> Unit,+    onRemoveNotification: (Notification) -> Unit,+) {     var renameTarget by remember { mutableStateOf<Profile?>(null) }     var deleteTarget by remember { mutableStateOf<Profile?>(null) }     var showDownload by remember { mutableStateOf(false) }@@ -45,7 +68,7 @@ fun EuiccApp(viewModel: EuiccViewModel) {         title = "EUICC",         actions = {             IconButton(onClick = { showDownload = true }, enabled = !state.loading) { IconAdd() }-            IconButton(onClick = viewModel::reload, enabled = !state.loading) { IconRefresh() }+            IconButton(onClick = onReload, enabled = !state.loading) { IconRefresh() }         },     ) { padding ->         Column(@@ -62,14 +85,14 @@ fun EuiccApp(viewModel: EuiccViewModel) {              ProfilesSection(                 profiles = state.profiles,-                onEnable = { viewModel.enable(it.iccid) },-                onDisable = { viewModel.disable(it.iccid) },+                onEnable = onEnable,+                onDisable = onDisable,                 onRename = { renameTarget = it },                 onDelete = { deleteTarget = it },             )             NotificationsSection(                 notifications = state.notifications,-                onRemove = { viewModel.removeNotification(it.seqNumber) },+                onRemove = onRemoveNotification,             )             EuiccSection(eid = state.eid, info = state.info)         }@@ -79,7 +102,7 @@ fun EuiccApp(viewModel: EuiccViewModel) {         RenameDialog(             profile = profile,             onConfirm = { name ->-                viewModel.rename(profile.iccid, name)+                onRename(profile, name)                 renameTarget = null             },             onDismiss = { renameTarget = null },@@ -93,7 +116,7 @@ fun EuiccApp(viewModel: EuiccViewModel) {             confirmLabel = "Delete",             destructive = true,             onConfirm = {-                viewModel.delete(profile.iccid)+                onDelete(profile)                 deleteTarget = null             },             onDismiss = { deleteTarget = null },@@ -103,7 +126,7 @@ fun EuiccApp(viewModel: EuiccViewModel) {     if (showDownload) {         DownloadDialog(             onDownload = {-                viewModel.downloadProfile(it)+                onDownload(it)                 showDownload = false             },             onDismiss = { showDownload = false },@@ -111,42 +134,6 @@ fun EuiccApp(viewModel: EuiccViewModel) {     } } -@Composable-private fun DownloadDialog(onDownload: (String) -> Unit, onDismiss: () -> Unit) {-    var code by remember { mutableStateOf("") }-    var scanning by remember { mutableStateOf(false) }--    if (scanning) {-        QrScannerScreen(-            onResult = { code = it; scanning = false },-            onCancel = { scanning = false },-        )-        return-    }--    AlertDialog(-        onDismissRequest = onDismiss,-        title = { Text("Download profile") },-        text = {-            Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {-                OutlinedTextField(-                    value = code,-                    onValueChange = { code = it },-                    label = { Text("Activation code") },-                )-                TextButton(onClick = { scanning = true }) { Text("Scan QR code") }-            }-        },-        confirmButton = {-            TextButton(-                onClick = { if (code.isNotBlank()) onDownload(code.trim()) },-                enabled = code.isNotBlank(),-            ) { Text("Download") }-        },-        dismissButton = { TextButton(onClick = onDismiss) { Text("Cancel") } },-    )-}- @Composable private fun ProfilesSection(     profiles: List<Profile>,@@ -222,6 +209,42 @@ private fun EuiccSection(eid: String?, info: EuiccInfo?) {     } } +@Composable+private fun DownloadDialog(onDownload: (String) -> Unit, onDismiss: () -> Unit) {+    var code by remember { mutableStateOf("") }+    var scanning by remember { mutableStateOf(false) }++    if (scanning) {+        QrScannerScreen(+            onResult = { code = it; scanning = false },+            onCancel = { scanning = false },+        )+        return+    }++    AlertDialog(+        onDismissRequest = onDismiss,+        title = { Text("Download profile") },+        text = {+            Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {+                OutlinedTextField(+                    value = code,+                    onValueChange = { code = it },+                    label = { Text("Activation code") },+                )+                TextButton(onClick = { scanning = true }) { Text("Scan QR code") }+            }+        },+        confirmButton = {+            TextButton(+                onClick = { if (code.isNotBlank()) onDownload(code.trim()) },+                enabled = code.isNotBlank(),+            ) { Text("Download") }+        },+        dismissButton = { TextButton(onClick = onDismiss) { Text("Cancel") } },+    )+}+ @Composable private fun RenameDialog(profile: Profile, onConfirm: (String) -> Unit, onDismiss: () -> Unit) {     var name by remember { mutableStateOf(profile.nickname) }
euicc/src/screenshotTest/kotlin/com/vayunmathur/euicc/ui/MetadataPreviews.kt
diff --git a/euicc/src/screenshotTest/kotlin/com/vayunmathur/euicc/ui/MetadataPreviews.kt b/euicc/src/screenshotTest/kotlin/com/vayunmathur/euicc/ui/MetadataPreviews.ktnew file mode 100644index 0000000000..d2b0412c2f--- /dev/null+++ b/euicc/src/screenshotTest/kotlin/com/vayunmathur/euicc/ui/MetadataPreviews.kt@@ -0,0 +1,102 @@+package com.vayunmathur.euicc.ui++import androidx.compose.runtime.Composable+import androidx.compose.ui.tooling.preview.Preview+import com.android.tools.screenshot.PreviewTest+import com.vayunmathur.euicc.data.EuiccInfo+import com.vayunmathur.euicc.data.Notification+import com.vayunmathur.euicc.data.Profile+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 `:euicc`, rendered from Compose previews instead of an+ * instrumented test on a device (which is impossible here — the LPA needs a+ * platform-signed install and a real eUICC).+ *+ * `./gradlew :euicc:metadata` renders these and copies the PNGs into+ * `metadata_data/photos/euicc/`, 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 sampleProfiles = listOf(+        Profile(+            iccid = "9810320000000000001",+            iccidDisplay = "8901234567890000001",+            state = "enabled",+            profileClass = "operational",+            nickname = "Work",+            serviceProvider = "Example Mobile",+            name = "Example Prepaid",+        ),+        Profile(+            iccid = "9810320000000000002",+            iccidDisplay = "8901234567890000002",+            state = "disabled",+            profileClass = "operational",+            serviceProvider = "Travel eSIM",+            name = "Global Data 5GB",+        ),+    )++    private val sampleNotifications = listOf(+        Notification(seqNumber = 3, operation = "enable", address = "smdp.example.com"),+        Notification(seqNumber = 4, operation = "install", address = "rsp.travelesim.com"),+    )++    private val sampleInfo = EuiccInfo(svn = "2.2.0")++    @PreviewTest+    @Preview(name = "1-profiles", device = PHONE, showSystemUi = true)+    @Composable+    fun Preview1Profiles() {+        DynamicTheme(darkTheme = true) {+            EuiccScreen(+                state = EuiccScreenState(+                    loading = false,+                    eid = "89044000001234567890123456789012",+                    info = sampleInfo,+                    profiles = sampleProfiles,+                    notifications = sampleNotifications,+                ),+                onReload = {},+                onDownload = {},+                onEnable = {},+                onDisable = {},+                onRename = { _, _ -> },+                onDelete = {},+                onRemoveNotification = {},+            )+        }+    }++    @PreviewTest+    @Preview(name = "2-empty", device = PHONE, showSystemUi = true)+    @Composable+    fun Preview2Empty() {+        DynamicTheme(darkTheme = true) {+            EuiccScreen(+                state = EuiccScreenState(+                    loading = false,+                    eid = "89044000001234567890123456789012",+                    info = sampleInfo,+                    profiles = emptyList(),+                    notifications = emptyList(),+                ),+                onReload = {},+                onDownload = {},+                onEnable = {},+                onDisable = {},+                onRename = { _, _ -> },+                onDelete = {},+                onRemoveNotification = {},+            )+        }+    }+}
metadata_data/euicc.md
diff --git a/metadata_data/euicc.md b/metadata_data/euicc.mdnew file mode 100644index 0000000000..adf3108b68--- /dev/null+++ b/metadata_data/euicc.md@@ -0,0 +1,8 @@+A privileged eSIM manager (LPA) for the phone's built-in eUICC++Features:+- List installed eSIM profiles with enable, disable, delete, and rename+- Download new profiles by QR code or activation code (SGP.22 / ES9+)+- View the EID and eUICC information+- Manage pending eUICC notifications+- SGP.22 protocol core implemented natively in Rust
metadata_data/photos/euicc/1.png
diff --git a/metadata_data/photos/euicc/1.png b/metadata_data/photos/euicc/1.pngnew file mode 100644index 0000000000..3072953362Binary files /dev/null and b/metadata_data/photos/euicc/1.png differ
metadata_data/photos/euicc/2.png
diff --git a/metadata_data/photos/euicc/2.png b/metadata_data/photos/euicc/2.pngnew file mode 100644index 0000000000..1573a29464Binary files /dev/null and b/metadata_data/photos/euicc/2.png differ