securemail: delete and message-details dialogs are routes
- Commit
c36a383005d8ed0e784dad2430bf6ea84afa5500- Author
- Vayun Mathur <[email protected]>
- When
- 2026-12-02 01:34 UTC (4 days ago)
- Parents
f844989
DialogAsRoute: Route gains DeleteForeverDialog(messageIds, emptyTrash) and MessageDetailsDialog(messageId), both DialogPage entries in NavigationEntries with stateless content under ui/dialogs/ (DeleteForeverDialog, MessageDetailsDialog). InboxScreen no longer gates an AlertDialog on confirmDelete state: its trash/swipe/selection paths call the new FolderActions.onRequestDeleteForever, which Navigation wires to push the route; the entry performs emptyTrash or deleteForever and pops. The swipe-row snap-back that cancelling used to do by bumping swipeGeneration now runs on ON_RESUME (cancelling the dialog route pops back to the folder destination), reusing the clock FullscreenRevokedBanner lifecycle pattern. ReaderScreen no longer gates a ModalBottomSheet on showDetails: tapping the sender row calls onShowDetails, readerEntry pushes MessageDetailsDialog, and that entry loads the message and renders the same From/To/date/fingerprint sheet body. Tests adapted to the route-request contract (inbox asserts the request ids and empty-trash flag; the reader test asserts the shown id, and the sheet body is asserted in a separate dialog-content test). RouteScreenshotCoverage: Lock, Composer, Reader and Settings had no capture naming the route (the existing 3-compose preview does not name composer). MetadataPreviews gains 5-lock, 6-composer, 7-reader and 8-settings from the real screens with fixed literal fixtures ([email protected], a signed [email protected] message dated 1_792_772_800_000L), plus 9-delete-forever-dialog and 10-message-details-dialog from the new dialog contents. No route is exempted; the shared FixtureDeterminism fix that every app lint run also needed landed in the preceding vpn commit, so this commit needs no exceptions regen (structure_check exceptions regen is byte-identical). securemail/AGENTS.md documents the two new dialog routes and files. Verified: ./gradlew :securemail:lint :securemail:lintVitalRelease :securemail:testDevUnitTest (198 tests, 0 failures) :securemail:compileReleaseKotlin all green, run individually after the first combined run lost its daemon to host memory pressure (other agents' daemons on the box; the same combined-run daemon loss is recorded in the existing clock commit). Also :securemail:compileDevScreenshotTestKotlin green. Local note: one lintVitalRelease rerun initially surfaced a stale cached library/ui lint partial result for the already-fixed shared fixture; deleting the stale lint partial-results directories and re-running gave the green result above.
Diff
securemail/AGENTS.md
diff --git a/securemail/AGENTS.md b/securemail/AGENTS.mdindex 68891d319f..3a2f39b56c 100644--- a/securemail/AGENTS.md+++ b/securemail/AGENTS.md@@ -17,7 +17,7 @@ _Install: ./install securemail (dev by default)._ - Biometric-gated unlock: the Keystore-wrapped private key is unwrapped before any mail composes - Aliases, drafts, outbox retry, and WKD/VKS key lookup for external recipients **Architecture / data-flow:** `ui/` Compose screens → `platform/MailViewModel` (+ `AliasController`, `DraftsController`) → `data/` Room stores (`MailRepository`, `MailStore`, `InboundStore`) fed by `service/MailSocketService` over `network/MailSocket` (REST + WebSocket) and `platform/MailSyncWorker`; crypto in `domain/pgp/PgpCrypto` + `platform/crypto/KeyManager`. Unlike `email/`, there is no raw IMAP/SMTP and no `network.Networking` object — `network/MailSocket` is the sole network entry point.-**Entry points + reading order:** `Route` (`Onboarding` / `Lock` / `Inbox(folder)` / `Composer` / `Reader(messageId)` / `Out` / `Settings`) → `MainActivity.kt` → `Navigation.kt` → `platform/MailViewModel.kt` → `data/MailRepository.kt` → `network/MailSocket.kt`.+**Entry points + reading order:** `Route` (`Onboarding` / `Lock` / `Inbox(folder)` / `Composer` / `Reader(messageId)` / `Out` / `Settings` / `DeleteForeverDialog(messageIds, emptyTrash)` / `MessageDetailsDialog(messageId)`) → `MainActivity.kt` → `Navigation.kt` → `platform/MailViewModel.kt` → `data/MailRepository.kt` → `network/MailSocket.kt`. **Gotchas:** - `NetworkClient.init(this, TrustBundle.FIRST_PARTY)` must stay first in `onCreateBeforeContent` — `mail.maemail.org` is a pinned first-party host; WKD/VKS lookups for arbitrary external domains ride the platform trust store instead. - `MainActivity` is a `MaFragmentActivity` with `autoSetContent = false`: composition is deferred until `unlockIfReady` succeeds — don't set content before the key gate.@@ -66,6 +66,8 @@ _Install: ./install securemail (dev by default)._ - com/vayunmathur/securemail/ui/OutScreen.kt - com/vayunmathur/securemail/ui/SettingsScreen.kt - com/vayunmathur/securemail/ui/NavigationEntries.kt+- com/vayunmathur/securemail/ui/dialogs/DeleteForeverDialog.kt+- com/vayunmathur/securemail/ui/dialogs/MessageDetailsDialog.kt ## Verify (this module only) ```
securemail/src/main/java/com/vayunmathur/securemail/Navigation.kt
diff --git a/securemail/src/main/java/com/vayunmathur/securemail/Navigation.kt b/securemail/src/main/java/com/vayunmathur/securemail/Navigation.ktindex 4c3afaa49b..a041045c91 100644--- a/securemail/src/main/java/com/vayunmathur/securemail/Navigation.kt+++ b/securemail/src/main/java/com/vayunmathur/securemail/Navigation.kt@@ -71,6 +71,9 @@ fun Navigation(viewModel: MailViewModel, initialRoute: Route? = null) { onEmptyTrash = viewModel::emptyTrash, onConsumeMessage = viewModel::dismissMessages, onRetry = viewModel::refresh,+ onRequestDeleteForever = { ids, emptyTrash ->+ backStack.add(Route.DeleteForeverDialog(ids, emptyTrash))+ }, ) }
securemail/src/main/java/com/vayunmathur/securemail/Route.kt
diff --git a/securemail/src/main/java/com/vayunmathur/securemail/Route.kt b/securemail/src/main/java/com/vayunmathur/securemail/Route.ktindex 2fd58e3a3b..d133d2f1fe 100644--- a/securemail/src/main/java/com/vayunmathur/securemail/Route.kt+++ b/securemail/src/main/java/com/vayunmathur/securemail/Route.kt@@ -45,4 +45,16 @@ sealed interface Route : NavKey { /** Singleton holding settings state and operations. */ @Serializable data object Settings : Route++ /**+ * Permanent-delete confirmation pushed from the Trash folder; carries the+ * affected message ids, and whether the request was Empty trash (delete+ * everything) rather than a subset.+ */+ @Serializable+ data class DeleteForeverDialog(val messageIds: List<String>, val emptyTrash: Boolean) : Route++ /** Message-details sheet pushed from the reader; carries the message id. */+ @Serializable+ data class MessageDetailsDialog(val messageId: String) : Route }
securemail/src/main/java/com/vayunmathur/securemail/ui/InboxScreen.kt
diff --git a/securemail/src/main/java/com/vayunmathur/securemail/ui/InboxScreen.kt b/securemail/src/main/java/com/vayunmathur/securemail/ui/InboxScreen.ktindex 46634ee629..eda188f663 100644--- a/securemail/src/main/java/com/vayunmathur/securemail/ui/InboxScreen.kt+++ b/securemail/src/main/java/com/vayunmathur/securemail/ui/InboxScreen.kt@@ -14,13 +14,15 @@ import androidx.compose.runtime.mutableIntStateOf import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue+import androidx.compose.runtime.DisposableEffect+import androidx.lifecycle.Lifecycle+import androidx.lifecycle.LifecycleEventObserver+import androidx.lifecycle.compose.LocalLifecycleOwner import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext-import androidx.compose.ui.res.pluralStringResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp-import com.vayunmathur.library.ui.AlertDialog import com.vayunmathur.library.ui.AppScaffold import com.vayunmathur.library.ui.ExperimentalMaterial3Api import com.vayunmathur.library.ui.FloatingActionButton@@ -57,6 +59,13 @@ class FolderActions( val onEmptyTrash: () -> Unit, val onConsumeMessage: () -> Unit, val onRetry: () -> Unit = {},+ /**+ * Pushes the permanent-delete confirmation route for [ids];+ * [emptyTrash] is true when the request came from Empty trash (the whole+ * folder) rather than a swipe or selection. Defaults to no-op so previews+ * and tests that never leave the folder keep working.+ */+ val onRequestDeleteForever: (ids: List<String>, emptyTrash: Boolean) -> Unit = { _, _ -> }, ) /**@@ -78,16 +87,26 @@ fun InboxScreen( val undoLabel = stringResource(UiR.string.undo) ConsumeMessage(state.message, messenger, actions.onConsumeMessage) var selected by remember(folder) { mutableStateOf(emptySet<String>()) }- var confirmDelete by remember { mutableStateOf<List<String>?>(null) } // Bumped when a delete is cancelled so the swiped-away row snaps back.+ // Cancelling now happens in the DeleteForeverDialog route, so the reset+ // runs when this destination resumes (the dialog pops back to it); a+ // resume with no swipe in flight just recreates the rows in place. var swipeGeneration by remember { mutableIntStateOf(0) }+ val lifecycleOwner = LocalLifecycleOwner.current+ DisposableEffect(lifecycleOwner) {+ val observer = LifecycleEventObserver { _, event ->+ if (event == Lifecycle.Event.ON_RESUME) swipeGeneration+++ }+ lifecycleOwner.lifecycle.addObserver(observer)+ onDispose { lifecycleOwner.lifecycle.removeObserver(observer) }+ } val inTrash = folder == MailFolder.TRASH BackHandler(enabled = selected.isNotEmpty()) { selected = emptySet() } fun trashOrDelete(ids: List<String>) { if (inTrash) {- confirmDelete = ids+ actions.onRequestDeleteForever(ids, ids.size == messages.size) } else { actions.onTrash(ids) messenger.show(@@ -131,7 +150,7 @@ fun InboxScreen( } if (inTrash && messages.isNotEmpty() && selected.isEmpty()) { TextButton(- onClick = { confirmDelete = messages.map { it.id } },+ onClick = { actions.onRequestDeleteForever(messages.map { it.id }, true) }, modifier = Modifier.padding(horizontal = 8.dp), ) { Text(stringResource(R.string.inbox_empty_trash)) } }@@ -167,25 +186,6 @@ fun InboxScreen( } } - confirmDelete?.let { ids ->- val everything = ids.size == messages.size- AlertDialog(- onDismissRequest = { confirmDelete = null; swipeGeneration++ },- title = { Text(if (everything) stringResource(R.string.inbox_empty_trash_title) else stringResource(R.string.inbox_delete_forever_title)) },- text = {- Text(pluralStringResource(R.plurals.inbox_permanent_delete_message, ids.size, ids.size))- },- confirmButton = {- TextButton(onClick = {- if (everything) actions.onEmptyTrash() else actions.onDeleteForever(ids)- confirmDelete = null- }) { Text(stringResource(UiR.string.delete)) }- },- dismissButton = {- TextButton(onClick = { confirmDelete = null; swipeGeneration++ }) { Text(stringResource(UiR.string.cancel)) }- },- )- } } @OptIn(ExperimentalMaterial3Api::class)
securemail/src/main/java/com/vayunmathur/securemail/ui/NavigationEntries.kt
diff --git a/securemail/src/main/java/com/vayunmathur/securemail/ui/NavigationEntries.kt b/securemail/src/main/java/com/vayunmathur/securemail/ui/NavigationEntries.ktindex 6d6d2b3d87..2578396207 100644--- a/securemail/src/main/java/com/vayunmathur/securemail/ui/NavigationEntries.kt+++ b/securemail/src/main/java/com/vayunmathur/securemail/ui/NavigationEntries.kt@@ -11,6 +11,7 @@ import com.vayunmathur.library.util.AppMessages import com.vayunmathur.library.util.EntryProviderScope import com.vayunmathur.library.util.MainNavigation import com.vayunmathur.library.util.NavBackStack+import com.vayunmathur.library.util.DialogPage import com.vayunmathur.library.util.ListDetailPage import com.vayunmathur.library.util.ListPage import com.vayunmathur.library.util.SiblingPage@@ -28,6 +29,8 @@ import com.vayunmathur.securemail.platform.restoreFromTrash import com.vayunmathur.securemail.platform.setRead import com.vayunmathur.securemail.R import com.vayunmathur.securemail.Route+import com.vayunmathur.securemail.ui.dialogs.DeleteForeverDialog+import com.vayunmathur.securemail.ui.dialogs.MessageDetailsDialog /** Onboarding, lock, inbox, reader and settings destinations. */ internal fun EntryProviderScope<Route>.mainEntries(@@ -70,6 +73,28 @@ internal fun EntryProviderScope<Route>.mainEntries( ) } readerEntry(viewModel, backStack, state)+ entry<Route.DeleteForeverDialog>(metadata = DialogPage()) { route ->+ DeleteForeverDialog(+ messageCount = route.messageIds.size,+ emptyTrash = route.emptyTrash,+ onDismiss = { backStack.pop() },+ onConfirm = {+ if (route.emptyTrash) viewModel.emptyTrash() else viewModel.deleteForever(route.messageIds)+ backStack.pop()+ },+ )+ }+ entry<Route.MessageDetailsDialog>(metadata = DialogPage()) { route ->+ val msgFlow = remember(route.messageId) { viewModel.messageFlow(route.messageId) }+ val msg by msgFlow.collectAsState(null)+ msg?.let { message ->+ MessageDetailsDialog(+ message = message,+ ownAddress = state.address,+ onDismiss = { backStack.pop() },+ )+ }+ } entry<Route.Settings>(metadata = SiblingPage()) { val identities by viewModel.identities.collectAsState(emptyList()) SettingsScreen(@@ -113,6 +138,7 @@ entry<Route.Reader>(metadata = ListDetailPage()) { route -> }, onBack = { backStack.pop() }, message = msg,+ onShowDetails = { backStack.add(Route.MessageDetailsDialog(it.id)) }, ) } }
securemail/src/main/java/com/vayunmathur/securemail/ui/ReaderScreen.kt
diff --git a/securemail/src/main/java/com/vayunmathur/securemail/ui/ReaderScreen.kt b/securemail/src/main/java/com/vayunmathur/securemail/ui/ReaderScreen.ktindex 8edad229a0..2020c90322 100644--- a/securemail/src/main/java/com/vayunmathur/securemail/ui/ReaderScreen.kt+++ b/securemail/src/main/java/com/vayunmathur/securemail/ui/ReaderScreen.kt@@ -14,10 +14,7 @@ import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.verticalScroll 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.res.stringResource@@ -34,11 +31,9 @@ import com.vayunmathur.library.ui.IconShield import com.vayunmathur.library.ui.IconUndo import com.vayunmathur.library.ui.IconWarning import com.vayunmathur.library.ui.MaterialTheme-import com.vayunmathur.library.ui.ModalBottomSheet import com.vayunmathur.library.ui.OutlinedButton import com.vayunmathur.library.ui.Surface import com.vayunmathur.library.ui.Text-import com.vayunmathur.library.ui.rememberModalBottomSheetState import com.vayunmathur.securemail.R import com.vayunmathur.securemail.data.MailFolder import com.vayunmathur.securemail.data.StoredMessage@@ -58,6 +53,7 @@ fun ReaderScreen( onReply: (StoredMessage) -> Unit, onBack: () -> Unit, message: StoredMessage? = null,+ onShowDetails: (StoredMessage) -> Unit = {}, ) { val msg = message AppScaffold(@@ -78,7 +74,7 @@ fun ReaderScreen( modifier = Modifier.padding(16.dp), ) } else {- MessageBody(msg, ownAddress = state.address, onReply = { onReply(msg) })+ MessageBody(msg, onReply = { onReply(msg) }, onShowDetails = { onShowDetails(msg) }) } } }@@ -87,8 +83,11 @@ fun ReaderScreen( @OptIn(ExperimentalMaterial3Api::class) @Composable-private fun MessageBody(msg: StoredMessage, ownAddress: String, onReply: () -> Unit) {- var showDetails by remember { mutableStateOf(false) }+private fun MessageBody(+ msg: StoredMessage,+ onReply: () -> Unit,+ onShowDetails: () -> Unit = {},+) { val sent = msg.folder == MailFolder.SENT val counterpart = if (sent) msg.toJson.ifBlank { stringResource(R.string.unknown_parenthesized) } else msg.from.ifBlank { stringResource(R.string.encrypted_sender_parenthesized) } val date = remember(msg.dateMillis) {@@ -97,7 +96,7 @@ private fun MessageBody(msg: StoredMessage, ownAddress: String, onReply: () -> U val avatarColor = MaterialTheme.colorScheme.primaryContainer Row(- modifier = Modifier.fillMaxWidth().clickable { showDetails = true }.padding(16.dp),+ modifier = Modifier.fillMaxWidth().clickable { onShowDetails() }.padding(16.dp), verticalAlignment = Alignment.CenterVertically, ) { Avatar(counterpart, avatarColor, MaterialTheme.colorScheme.onPrimaryContainer, 40)@@ -138,28 +137,6 @@ private fun MessageBody(msg: StoredMessage, ownAddress: String, onReply: () -> U } HorizontalDivider() - if (showDetails) {- ModalBottomSheet(- onDismissRequest = { showDetails = false },- sheetState = rememberModalBottomSheetState(),- ) {- Column(modifier = Modifier.padding(16.dp).fillMaxWidth()) {- Text(date, style = MaterialTheme.typography.labelSmall, modifier = Modifier.align(Alignment.End))- DetailRow(stringResource(R.string.from_label), if (sent) ownAddress else msg.from.ifBlank { stringResource(R.string.encrypted_sender_parenthesized) }, avatarColor)- DetailRow(stringResource(R.string.to_label), if (sent) msg.toJson.ifBlank { stringResource(R.string.unknown_parenthesized) } else ownAddress, MaterialTheme.colorScheme.surfaceVariant)- if (msg.verifiedSigner != null) {- Spacer(Modifier.height(8.dp))- Text(stringResource(R.string.reader_signer_fingerprint), style = MaterialTheme.typography.labelLarge, color = MaterialTheme.colorScheme.primary)- Text(- msg.verifiedSigner.chunked(4).joinToString(" "),- style = MaterialTheme.typography.bodySmall,- modifier = Modifier.padding(vertical = 8.dp),- )- }- Spacer(Modifier.height(24.dp))- }- }- } } @Composable@@ -186,17 +163,6 @@ private fun TrustLine(msg: StoredMessage) { } } -@Composable-private fun DetailRow(label: String, address: String, avatarColor: Color) {- Column(modifier = Modifier.padding(vertical = 8.dp)) {- Text(label, style = MaterialTheme.typography.labelLarge, color = MaterialTheme.colorScheme.primary)- Row(modifier = Modifier.padding(vertical = 8.dp), verticalAlignment = Alignment.CenterVertically) {- Avatar(address, avatarColor, MaterialTheme.colorScheme.onSurface, 32)- Text(address, style = MaterialTheme.typography.bodyLarge, modifier = Modifier.padding(start = 12.dp))- }- }-}- @Composable private fun Avatar(address: String, color: Color, contentColor: Color, sizeDp: Int) { Surface(shape = CircleShape, color = color, modifier = Modifier.size(sizeDp.dp)) {
securemail/src/main/java/com/vayunmathur/securemail/ui/dialogs/DeleteForeverDialog.kt
diff --git a/securemail/src/main/java/com/vayunmathur/securemail/ui/dialogs/DeleteForeverDialog.kt b/securemail/src/main/java/com/vayunmathur/securemail/ui/dialogs/DeleteForeverDialog.ktnew file mode 100644index 0000000000..d38473d09c--- /dev/null+++ b/securemail/src/main/java/com/vayunmathur/securemail/ui/dialogs/DeleteForeverDialog.kt@@ -0,0 +1,45 @@+package com.vayunmathur.securemail.ui.dialogs++import androidx.compose.runtime.Composable+import androidx.compose.ui.res.pluralStringResource+import androidx.compose.ui.res.stringResource+import com.vayunmathur.library.ui.AlertDialog+import com.vayunmathur.library.ui.R as UiR+import com.vayunmathur.library.ui.Text+import com.vayunmathur.library.ui.TextButton+import com.vayunmathur.securemail.R++/**+ * The permanent-delete confirmation for `Route.DeleteForeverDialog`,+ * stateless: the count and the empty-trash shape are passed in and the route+ * entry owns deleting and popping the dialog.+ */+@Composable+fun DeleteForeverDialog(+ messageCount: Int,+ emptyTrash: Boolean,+ onDismiss: () -> Unit,+ onConfirm: () -> Unit,+) {+ AlertDialog(+ onDismissRequest = onDismiss,+ title = {+ Text(+ if (emptyTrash) {+ stringResource(R.string.inbox_empty_trash_title)+ } else {+ stringResource(R.string.inbox_delete_forever_title)+ },+ )+ },+ text = {+ Text(pluralStringResource(R.plurals.inbox_permanent_delete_message, messageCount, messageCount))+ },+ confirmButton = {+ TextButton(onClick = onConfirm) { Text(stringResource(UiR.string.delete)) }+ },+ dismissButton = {+ TextButton(onClick = onDismiss) { Text(stringResource(UiR.string.cancel)) }+ },+ )+}
securemail/src/main/java/com/vayunmathur/securemail/ui/dialogs/MessageDetailsDialog.kt
diff --git a/securemail/src/main/java/com/vayunmathur/securemail/ui/dialogs/MessageDetailsDialog.kt b/securemail/src/main/java/com/vayunmathur/securemail/ui/dialogs/MessageDetailsDialog.ktnew file mode 100644index 0000000000..e3afc33193--- /dev/null+++ b/securemail/src/main/java/com/vayunmathur/securemail/ui/dialogs/MessageDetailsDialog.kt@@ -0,0 +1,98 @@+package com.vayunmathur.securemail.ui.dialogs++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.fillMaxWidth+import androidx.compose.foundation.layout.height+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.layout.size+import androidx.compose.foundation.shape.CircleShape+import androidx.compose.runtime.Composable+import androidx.compose.runtime.remember+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.graphics.Color+import androidx.compose.ui.res.stringResource+import androidx.compose.ui.unit.dp+import com.vayunmathur.library.ui.ExperimentalMaterial3Api+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.ModalBottomSheet+import com.vayunmathur.library.ui.Surface+import com.vayunmathur.library.ui.Text+import com.vayunmathur.library.ui.rememberModalBottomSheetState+import com.vayunmathur.securemail.R+import com.vayunmathur.securemail.data.MailFolder+import com.vayunmathur.securemail.data.StoredMessage+import java.text.DateFormat+import java.util.Date++/**+ * The message-details sheet for `Route.MessageDetailsDialog`, stateless: the+ * message and the own address are passed in and the route entry owns popping+ * the sheet. The sheet body is the reader's From/To/date/fingerprint detail.+ */+@OptIn(ExperimentalMaterial3Api::class)+@Composable+fun MessageDetailsDialog(+ message: StoredMessage,+ ownAddress: String,+ onDismiss: () -> Unit,+) {+ val sent = message.folder == MailFolder.SENT+ val date = remember(message.dateMillis) {+ DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT).format(Date(message.dateMillis))+ }+ ModalBottomSheet(+ onDismissRequest = onDismiss,+ sheetState = rememberModalBottomSheetState(),+ ) {+ Column(modifier = Modifier.padding(16.dp).fillMaxWidth()) {+ Text(date, style = MaterialTheme.typography.labelSmall, modifier = Modifier.align(Alignment.End))+ MessageDetailRow(+ stringResource(R.string.from_label),+ if (sent) ownAddress else message.from.ifBlank { stringResource(R.string.encrypted_sender_parenthesized) },+ MaterialTheme.colorScheme.primaryContainer,+ )+ MessageDetailRow(+ stringResource(R.string.to_label),+ if (sent) message.toJson.ifBlank { stringResource(R.string.unknown_parenthesized) } else ownAddress,+ MaterialTheme.colorScheme.surfaceVariant,+ )+ if (message.verifiedSigner != null) {+ Spacer(Modifier.height(8.dp))+ Text(+ stringResource(R.string.reader_signer_fingerprint),+ style = MaterialTheme.typography.labelLarge,+ color = MaterialTheme.colorScheme.primary,+ )+ Text(+ message.verifiedSigner.chunked(4).joinToString(" "),+ style = MaterialTheme.typography.bodySmall,+ modifier = Modifier.padding(vertical = 8.dp),+ )+ }+ Spacer(Modifier.height(24.dp))+ }+ }+}++@Composable+private fun MessageDetailRow(label: String, address: String, avatarColor: Color) {+ Column(modifier = Modifier.padding(vertical = 8.dp)) {+ Text(label, style = MaterialTheme.typography.labelLarge, color = MaterialTheme.colorScheme.primary)+ Row(modifier = Modifier.padding(vertical = 8.dp), verticalAlignment = Alignment.CenterVertically) {+ Surface(shape = CircleShape, color = avatarColor, modifier = Modifier.size(32.dp)) {+ Box(contentAlignment = Alignment.Center) {+ Text(+ address.take(1).uppercase(),+ color = MaterialTheme.colorScheme.onSurface,+ style = MaterialTheme.typography.titleMedium,+ )+ }+ }+ Text(address, style = MaterialTheme.typography.bodyLarge, modifier = Modifier.padding(start = 12.dp))+ }+ }+}
securemail/src/screenshotTest/kotlin/com/vayunmathur/securemail/ui/MetadataPreviews.kt
diff --git a/securemail/src/screenshotTest/kotlin/com/vayunmathur/securemail/ui/MetadataPreviews.kt b/securemail/src/screenshotTest/kotlin/com/vayunmathur/securemail/ui/MetadataPreviews.ktindex e4f8965903..e13a1d8da6 100644--- a/securemail/src/screenshotTest/kotlin/com/vayunmathur/securemail/ui/MetadataPreviews.kt+++ b/securemail/src/screenshotTest/kotlin/com/vayunmathur/securemail/ui/MetadataPreviews.kt@@ -12,6 +12,8 @@ import com.vayunmathur.securemail.data.MailFolder import com.vayunmathur.securemail.data.StoredMessage import com.vayunmathur.securemail.data.StoredMessagePreview import com.vayunmathur.securemail.platform.MailUiState+import com.vayunmathur.securemail.ui.dialogs.DeleteForeverDialog+import com.vayunmathur.securemail.ui.dialogs.MessageDetailsDialog /** Phone-shaped, roughly 1080x2340 at xxhdpi — comfortably above the F-Droid minimum. */ private const val PHONE = "spec:width=411dp,height=891dp,dpi=420"@@ -174,4 +176,117 @@ class MetadataPreviews { } } }++ @PreviewTest+ @Preview(name = "5-lock", device = PHONE, group = "phone", showSystemUi = true)+ @Composable+ fun Preview5Lock() {+ DynamicTheme(darkTheme = true) {+ LockScreen(+ state = MailUiState(address = "[email protected]"),+ onUnlock = {},+ onDismissMessages = {},+ )+ }+ }++ @PreviewTest+ @Preview(name = "6-composer", device = PHONE, group = "phone", showSystemUi = true)+ @Composable+ fun Preview6Composer() {+ DynamicTheme(darkTheme = true) {+ ComposeScreen(+ state = MailUiState(address = "[email protected]"),+ identities = emptyList(),+ draftFrom = null,+ onSelectFrom = {},+ draftTo = listOf("[email protected]"),+ draftCc = emptyList(),+ draftBcc = emptyList(),+ initialSubject = "Hello from SecureMail",+ initialBody = "This message is end-to-end encrypted with PGP.",+ onAddRecipient = { _, _ -> true },+ onRemoveRecipient = { _, _ -> },+ onSend = { _, _, _, _, _, _ -> },+ onLeave = { _, _ -> },+ onDiscard = {},+ )+ }+ }++ private val readerMessage = StoredMessage(+ id = "m_1",+ from = "[email protected]",+ toJson = "[email protected]",+ dateMillis = 1_792_772_800_000L,+ messageId = "m_1",+ blobBase64 = "",+ decryptedSubject = "Hello from Proton",+ decryptedBody = "Lunch tomorrow?",+ verifiedSigner = "A1B2C3D4E5F60718",+ folder = MailFolder.INBOX,+ )++ @PreviewTest+ @Preview(name = "7-reader", device = PHONE, group = "phone", showSystemUi = true)+ @Composable+ fun Preview7Reader() {+ DynamicTheme(darkTheme = true) {+ ReaderScreen(+ state = MailUiState(address = "[email protected]"),+ onReply = {},+ onBack = {},+ message = readerMessage,+ )+ }+ }++ @PreviewTest+ @Preview(name = "8-settings", device = PHONE, group = "phone", showSystemUi = true)+ @Composable+ fun Preview8Settings() {+ DynamicTheme(darkTheme = true) {+ WithBottomBar(MailTab.SETTINGS) {+ SettingsScreen(+ state = MailUiState(+ address = "[email protected]",+ socketConnected = true,+ ),+ identities = emptyList(),+ onCreateAlias = {},+ onSetAliasDisabled = { _, _ -> },+ onExportPublicKey = {},+ onForget = {},+ onDismissMessages = {},+ )+ }+ }+ }++ @PreviewTest+ @Preview(name = "9-delete-forever-dialog", device = PHONE, group = "phone", showSystemUi = true)+ @Composable+ fun Preview9DeleteForeverDialog() {+ DynamicTheme(darkTheme = true) {+ DeleteForeverDialog(+ messageCount = 2,+ emptyTrash = true,+ onDismiss = {},+ onConfirm = {},+ )+ }+ }++ @PreviewTest+ @Preview(name = "10-message-details-dialog", device = PHONE, group = "phone", showSystemUi = true)+ @Composable+ fun Preview10MessageDetailsDialog() {+ DynamicTheme(darkTheme = true) {+ MessageDetailsDialog(+ message = readerMessage,+ ownAddress = "[email protected]",+ onDismiss = {},+ )+ }+ } }
securemail/src/test/java/com/vayunmathur/securemail/ui/MailScreensCoverageTest.kt
diff --git a/securemail/src/test/java/com/vayunmathur/securemail/ui/MailScreensCoverageTest.kt b/securemail/src/test/java/com/vayunmathur/securemail/ui/MailScreensCoverageTest.ktindex 266a7a0020..2dc95b4b8b 100644--- a/securemail/src/test/java/com/vayunmathur/securemail/ui/MailScreensCoverageTest.kt+++ b/securemail/src/test/java/com/vayunmathur/securemail/ui/MailScreensCoverageTest.kt@@ -324,28 +324,23 @@ class MailScreensCoverageTest { rule.onNodeWithText("Relay: offline", substring = true).assertExists() } - @Test fun `inbox trash empty dialog deletes everything or cancels`() {- var emptied = 0- val deleted = mutableListOf<List<String>>()+ @Test fun `inbox trash empty requests delete route`() {+ val requests = mutableListOf<Pair<List<String>, Boolean>>() val actions = FolderActions( onOpen = {}, onCompose = {}, onSetRead = { _, _ -> }, onTrash = {},- onMoveTo = { _, _ -> }, onRestore = {}, onDeleteForever = { deleted += it },- onEmptyTrash = { emptied++ }, onConsumeMessage = {},+ onMoveTo = { _, _ -> }, onRestore = {}, onDeleteForever = {},+ onEmptyTrash = {}, onConsumeMessage = {},+ onRequestDeleteForever = { ids, emptyTrash -> requests += ids to emptyTrash }, ) rule.setContent { InboxScreen(state = MailUiState(), folder = MailFolder.TRASH, actions = actions, messages = listOf(msg("t1", "Trash one").toPreview(), msg("t2", "Trash two").toPreview())) } rule.onNodeWithText("Empty trash").performClick()- rule.onNodeWithText("Empty trash?").assertExists()- rule.onNodeWithText("2 messages will be permanently deleted", substring = true).assertExists()- rule.onNodeWithText("Cancel").performClick()+ // The confirmation itself is the DeleteForeverDialog route entry, not+ // content rendered by InboxScreen.+ assertEquals(listOf(listOf("t1", "t2") to true), requests) rule.onAllNodes(hasText("Empty trash?")).assertCountEquals(0)- assertEquals(0, emptied)- rule.onNodeWithText("Empty trash").performClick()- rule.onNodeWithText("Delete").performClick()- assertEquals(1, emptied)- assertTrue(deleted.isEmpty()) } @Test fun `inbox long press opens selection bar`() {
securemail/src/test/java/com/vayunmathur/securemail/ui/MailScreensExtraTest.kt
diff --git a/securemail/src/test/java/com/vayunmathur/securemail/ui/MailScreensExtraTest.kt b/securemail/src/test/java/com/vayunmathur/securemail/ui/MailScreensExtraTest.ktindex 25b71d8632..ade764ba53 100644--- a/securemail/src/test/java/com/vayunmathur/securemail/ui/MailScreensExtraTest.kt+++ b/securemail/src/test/java/com/vayunmathur/securemail/ui/MailScreensExtraTest.kt@@ -54,13 +54,28 @@ class MailScreensExtraTest { MailIdentity(address, label, "pub", fp, "sec", isPrimary = primary, disabled = disabled, createdMillis = 1) @Test fun `reader details sheet shows from to and chunked signer fingerprint`() {+ val shown = mutableListOf<String>()+ val message = msg(verified = "AABBCCDD11223344") rule.setContent { ReaderScreen( state = MailUiState(address = "[email protected]"), onReply = {}, onBack = {},- message = msg(verified = "AABBCCDD11223344"),+ message = message,+ onShowDetails = { shown += it.id }, ) } rule.onNodeWithText("[email protected]", substring = true).performClick()+ // The details themselves are the MessageDetailsDialog route entry.+ assertEquals(listOf(message.id), shown)+ }++ @Test fun `message details dialog shows from to and chunked signer fingerprint`() {+ rule.setContent {+ com.vayunmathur.securemail.ui.dialogs.MessageDetailsDialog(+ message = msg(verified = "AABBCCDD11223344"),+ ownAddress = "[email protected]",+ onDismiss = {},+ )+ } rule.onNodeWithText("Signer fingerprint").assertExists() rule.onNodeWithText("AABB CCDD 1122 3344").assertExists() rule.onNodeWithText("From").assertExists()