findfamily: dialogs are routes, with per-route screenshot captures
- Commit
a9996ced63cc9ee44ccf25b629fa920ad41f2798- Author
- Vayun Mathur <[email protected]>
- When
- 2026-12-02 01:49 UTC (4 days ago)
- Parents
5e47ab7
DialogAsRoute (3): the approximate-location upgrade prompt, the security-code dialog, and the no-show watch dialog are now Route destinations with DialogPage() entries. MainActivity passes its coarse-only state into Navigation, which pushes Route.PermissionUpgradeDialog; PersonSheet pushes Route.SecurityCodeDialog(userId) and PersonDetailSheet only requests the no-show dialog through its new onShowNoShowAlert callback, which PersonSheet wires to Route.NoShowAlertDialog(userId). The no-show entry rebuilds the notification-permission-wrapped PersonActions. W5PersonDetailSheetTest now asserts the route request instead of an inline dialog. RouteScreenshotCoverage (10 baseline routes + 3 new dialog routes): MetadataPreviews renames 1-family/2-person/3-find-nearby to 1-main-page/2-person-sheet/3-uwb-ranging-page and adds captures for FirstRunSheet, WaypointSheet, the shared history DatePickerDialog (fixed 2026-02-13), AddPerson, AddLink, AddTracker, MissingFeatures, SecurityCode, NoShowAlert and PermissionUpgrade, all in the phone bucket with fixed literals. Stateless contents were extracted where a page needed a ViewModel or platform handle: FirstRunSheetContent, WaypointSheetContent, AddPersonContent, AddLinkContent, AddTrackerContent, NoShowAlertContent and SecurityCodeContent; dialog-local field/picker state stays inside the contents, route entries keep crypto, contact-picker, BLE-bind, sharing and permission plumbing. The preview fixtures no longer read Clock.System.now(): the sample instant is the fixed 2026-02-13T17:41:09Z. FixtureDeterminism (17, surfaced in src/test once the analyze cache was bypassed): repository/intent/database fixtures now use a named FIXED_NOW constant instead of Clock.System.now(); pure CRUD and due-window assertions are unchanged in meaning. Also includes library:ui DropdownsSliceTest, whose nowPlus helper genuinely seeds relative to the picker-under-test's real clock: it carries the honest FIXTURE RELATIVE-TIME exception marker, without which this module's fresh release lint (which scans dependency test sources) cannot go green. Verified on a clean, no-build-cache run: ./gradlew :findfamily:lint :findfamily:lintVitalRelease :findfamily:testDevUnitTest (354 tests) :findfamily:compileReleaseKotlin all green, plus :findfamily:compileDevScreenshotTestKotlin and :findfamily:updateDevScreenshotTest (all 14 previews render non-blank PNGs). Note the lint analyze tasks do not declare src/test as an input, so a stale FROM-CACHE/UP-TO-DATE analyze can hide FixtureDeterminism results; the clean no-cache run is the deciding check. AGENTS.md updated for the new routes and contents.
Diff
findfamily/AGENTS.md
diff --git a/findfamily/AGENTS.md b/findfamily/AGENTS.mdindex 8d7f09c365..9afc1156aa 100644--- a/findfamily/AGENTS.md+++ b/findfamily/AGENTS.md@@ -5,7 +5,7 @@ _Install: ./install findfamily (dev by default)._ - Gradle: :findfamily / dir: findfamily/ - Package roots present: ui, data, domain, platform, intents, service-- Entry files: MainActivity.kt (no Route.kt — `Route` + `Navigation` are inline)+- Entry files: MainActivity.kt + Route.kt + Navigation.kt - Deps: :library:network, :library:e2ee-p2p, :library:room, :library:work, :library:image, :library:map, :library:aosp-stubs, :library:wearlink - Metadata: metadata_data/findfamily.md (present) - Rust: no / screenshotTest: yes@@ -20,8 +20,8 @@ WebSocket relay host: `wss://api.maproj.org/api/ws` (Cloudflare FIRST_PARTY pins - Saved places (waypoints) with enter/leave notifications plus no-show alerts driven by `domain/NoShowPolicy` - Live battery, speed, and dwell-time per person; UWB precision ranging where hardware supports it - Powered-off finding (BLE beacons) and a Quick Settings tile to stop sharing instantly-**Architecture / data-flow:** Single `MainPage` UI + `util/FindFamilyViewModel` over `data/FindFamilyRepository` (Room: users, waypoints, links, no-show alerts); live location flows through `util/LocationTracking*` foreground service + `tracker/` BLE protocol and `uwb/` ranging, relayed E2EE via `:library:e2ee-p2p` (`util/Networking*`). `onCreateBeforeContent`: parse the add-invite deep link, then `NetworkClient.init(FIRST_PARTY)`.-**Entry points + reading order:** `Route` (`MainPage` / `AddPersonDialog` / `AddLinkDialog` / `UwbRangingPage` + dialogs, all inline in `MainActivity.kt`) → `Navigation()` → `ui/MainPage.kt` → `util/FindFamilyViewModel.kt` → `data/FindFamilyRepository.kt`.+**Architecture / data-flow:** Single `MainPage` UI + `platform/FindFamilyViewModel` over `data/FindFamilyRepository` (Room: users, waypoints, links, no-show alerts); live location flows through `util/LocationTracking*` foreground service + `tracker/` BLE protocol and `uwb/` ranging, relayed E2EE via `:library:e2ee-p2p` (`util/Networking*`). `onCreateBeforeContent`: parse the add-invite deep link, then `NetworkClient.init(FIRST_PARTY)`.+**Entry points + reading order:** `Route` (`MainPage` / sheets / `AddPersonDialog` / `AddLinkDialog` / `AddTrackerDialog` / `MissingFeaturesDialog` / `SecurityCodeDialog` / `NoShowAlertDialog` / `PermissionUpgradeDialog` / `UwbRangingPage`, all `DialogPage()` except the two full screens) → `Navigation.kt` → `ui/MainPage.kt` → `platform/FindFamilyViewModel.kt` → `data/FindFamilyRepository.kt`. Dialogs are routes: screens push `Route.…Dialog` and the entry renders the stateless `…Content` under `ui/dialogs/` (or the sheet content) unconditionally; `PersonDetailSheet` only requests the no-show dialog via its `onShowNoShowAlert` callback. Every route has a deterministic capture in `src/screenshotTest` (`MetadataPreviews`, `<n>-<route-kebab>`). **Gotchas:** - Location permission spec must request fine AND coarse together (Android 12+ Precise/Approximate choice; fine alone is ignored), plus background location and `BLUETOOTH_SCAN` — the powered-off-finder scanner starts then dies without it - `singleTop` warm-start invites/UWB taps arrive via `onNewIntent`, not a fresh `onCreate`@@ -30,8 +30,10 @@ WebSocket relay host: `wss://api.maproj.org/api/ws` (Cloudflare FIRST_PARTY pins - Upgrades from app versions before v2.6.0 start fresh: the `FFDatabase` floor is DB v5, pre-floor DB v1–v4 opens destructively (no data carried over), and DB v5 onward migrates normally ## Key files-### Root — entry + inline navigation-- com/vayunmathur/findfamily/MainActivity.kt — Route, Navigation, deep-link parsing, permission spec+### Root — entry + navigation+- com/vayunmathur/findfamily/MainActivity.kt — deep-link parsing, permission spec, permission-upgrade trigger+- com/vayunmathur/findfamily/Route.kt — sealed `Route` destinations (sheets + dialog routes + UWB screen)+- com/vayunmathur/findfamily/Navigation.kt — `MainNavigation` entries for every route ### data/ — Room entities + repository - com/vayunmathur/findfamily/data/FindFamilyRepository.kt - com/vayunmathur/findfamily/data/FFDatabase.kt@@ -102,14 +104,14 @@ WebSocket relay host: `wss://api.maproj.org/api/ws` (Cloudflare FIRST_PARTY pins - com/vayunmathur/findfamily/ui/AutoToggleRow.kt - com/vayunmathur/findfamily/ui/FindFamilyWideLayout.kt - com/vayunmathur/findfamily/ui/UwbRangingScreen.kt-- com/vayunmathur/findfamily/ui/dialogs/AddPersonDialog.kt — also hosts `decodeBase26`-- com/vayunmathur/findfamily/ui/dialogs/AddLinkDialog.kt-- com/vayunmathur/findfamily/ui/dialogs/AddTrackerDialog.kt — dev-only-- com/vayunmathur/findfamily/ui/dialogs/NoShowAlertDialog.kt+- com/vayunmathur/findfamily/ui/dialogs/AddPersonDialog.kt — also hosts `decodeBase26`; stateless `AddPersonContent` for previews+- com/vayunmathur/findfamily/ui/dialogs/AddLinkDialog.kt — stateless `AddLinkContent` for previews+- com/vayunmathur/findfamily/ui/dialogs/AddTrackerDialog.kt — dev-only; stateless `AddTrackerContent` for previews+- com/vayunmathur/findfamily/ui/dialogs/NoShowAlertDialog.kt — stateless `NoShowAlertContent` for previews - com/vayunmathur/findfamily/ui/dialogs/GpsFallbackWarningDialog.kt - com/vayunmathur/findfamily/ui/dialogs/KeyMismatchDialog.kt - com/vayunmathur/findfamily/ui/dialogs/OutdatedPeerDialog.kt-- com/vayunmathur/findfamily/ui/dialogs/SecurityCodeDialog.kt+- com/vayunmathur/findfamily/ui/dialogs/SecurityCodeDialog.kt — stateless `SecurityCodeContent` for previews ### util/ — ViewModel, tracking service, networking - com/vayunmathur/findfamily/util/FindFamilyViewModel.kt - com/vayunmathur/findfamily/util/FindFamilyUiContract.kt
findfamily/src/main/java/com/vayunmathur/findfamily/MainActivity.kt
diff --git a/findfamily/src/main/java/com/vayunmathur/findfamily/MainActivity.kt b/findfamily/src/main/java/com/vayunmathur/findfamily/MainActivity.ktindex 0369a2cd59..86ffb64631 100644--- a/findfamily/src/main/java/com/vayunmathur/findfamily/MainActivity.kt+++ b/findfamily/src/main/java/com/vayunmathur/findfamily/MainActivity.kt@@ -3,13 +3,10 @@ package com.vayunmathur.findfamily import android.content.Intent import androidx.activity.viewModels import androidx.compose.runtime.Composable-import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember-import androidx.compose.runtime.setValue-import androidx.compose.ui.res.stringResource import com.vayunmathur.findfamily.data.FindFamilyRepository import com.vayunmathur.findfamily.domain.AddInvite import com.vayunmathur.findfamily.domain.FirstRun@@ -23,7 +20,6 @@ import com.vayunmathur.findfamily.ui.findFamilyPermissionsSpec import com.vayunmathur.library.network.NetworkClient import com.vayunmathur.library.network.TrustBundle import com.vayunmathur.library.ui.AppPermissionsGate-import com.vayunmathur.library.ui.ConfirmDialog import com.vayunmathur.library.ui.MaActivity import com.vayunmathur.library.util.OfflineAware @@ -76,10 +72,6 @@ class MainActivity : MaActivity() { // Approximate-only needs the upgrade prompt even though the gate // itself only blocks on the missing set. val coarseOnly = hasCoarse && !hasForeground- var showUpgradeDialog by remember { mutableStateOf(false) }- LaunchedEffect(coarseOnly) {- if (coarseOnly) showUpgradeDialog = true- } // Staged first-run (census M): a brand-new user (no family, flow not // finished, not already granted) is NOT dropped into the all-at-once@@ -109,20 +101,8 @@ class MainActivity : MaActivity() { onNoShowTargetConsumed = { noShowTarget.value = null }, showFirstRun = showFirstRun, onFirstRunFinished = { ffViewModel.completeFirstRun() },+ showPermissionUpgrade = coarseOnly, )-- // Approximate-only: explain and offer a reliable way to- // re-open the upgrade prompt after it has been dismissed.- if (coarseOnly && showUpgradeDialog) {- ConfirmDialog(- title = stringResource(R.string.permission_upgrade_dialog_title),- message = stringResource(R.string.permission_upgrade_dialog_message),- confirmLabel = stringResource(R.string.permission_upgrade_dialog_confirm),- dismissLabel = stringResource(R.string.permission_upgrade_dialog_dismiss),- onConfirm = { showUpgradeDialog = false },- onDismiss = { showUpgradeDialog = false },- )- } } OfflineAware {
findfamily/src/main/java/com/vayunmathur/findfamily/Navigation.kt
diff --git a/findfamily/src/main/java/com/vayunmathur/findfamily/Navigation.kt b/findfamily/src/main/java/com/vayunmathur/findfamily/Navigation.ktindex 0f125154c7..6c0110d44a 100644--- a/findfamily/src/main/java/com/vayunmathur/findfamily/Navigation.kt+++ b/findfamily/src/main/java/com/vayunmathur/findfamily/Navigation.kt@@ -14,6 +14,16 @@ import com.vayunmathur.findfamily.ui.WaypointSheet import com.vayunmathur.findfamily.ui.dialogs.AddLinkDialog import com.vayunmathur.findfamily.ui.dialogs.AddPersonDialog import com.vayunmathur.findfamily.ui.dialogs.AddTrackerDialog+import com.vayunmathur.findfamily.ui.dialogs.NoShowAlertDialog+import com.vayunmathur.findfamily.ui.dialogs.SecurityCodeDialog+import com.vayunmathur.findfamily.platform.PersonActions+import androidx.compose.runtime.collectAsState+import androidx.compose.runtime.getValue+import androidx.compose.runtime.remember+import androidx.compose.ui.res.stringResource+import com.vayunmathur.findfamily.ui.rememberNotificationPermissionAction+import com.vayunmathur.library.ui.ConfirmDialog+import com.vayunmathur.library.ui.rememberMessenger import com.vayunmathur.library.ui.dialog.DatePickerDialog import com.vayunmathur.library.util.DialogPage import com.vayunmathur.library.util.MainNavigation@@ -34,6 +44,7 @@ fun Navigation( onNoShowTargetConsumed: () -> Unit = {}, showFirstRun: Boolean = false, onFirstRunFinished: () -> Unit = {},+ showPermissionUpgrade: Boolean = false, ) { val backStack = rememberNavBackStack<Route>(Route.MainPage) @@ -46,6 +57,12 @@ fun Navigation( } } + LaunchedEffect(showPermissionUpgrade) {+ if (showPermissionUpgrade && backStack.backStack.lastOrNull() !is Route.PermissionUpgradeDialog) {+ backStack.add(Route.PermissionUpgradeDialog)+ }+ }+ LaunchedEffect(showMissingFeatures) { if (showMissingFeatures) { backStack.add(Route.MissingFeaturesDialog)@@ -114,5 +131,54 @@ fun Navigation( entry<Route.UwbRangingPage> { UwbRangingScreen(backStack, ffViewModel, it.userId) }+ entry<Route.SecurityCodeDialog>(metadata = DialogPage()) {+ val users by ffViewModel.users.collectAsState()+ val user = users.firstOrNull { u -> u.id == it.userId }+ if (user != null) {+ SecurityCodeDialog(user, ffViewModel) { backStack.pop() }+ }+ }+ entry<Route.NoShowAlertDialog>(metadata = DialogPage()) {+ val users by ffViewModel.users.collectAsState()+ val waypoints by ffViewModel.waypoints.collectAsState()+ val user = users.firstOrNull { u -> u.id == it.userId }+ val messenger = rememberMessenger()+ val notificationsDeniedMessage = stringResource(R.string.notifications_denied)+ val ensureNotifications = rememberNotificationPermissionAction {+ messenger.show(notificationsDeniedMessage)+ }+ val actions = remember(ffViewModel, ensureNotifications) {+ object : PersonActions by ffViewModel {+ override fun setNoShowAlert(+ user: com.vayunmathur.findfamily.data.User,+ waypointId: Long?,+ expectedAt: kotlin.time.Instant,+ graceMinutes: Int,+ ) {+ ensureNotifications {+ ffViewModel.setNoShowAlert(user, waypointId, expectedAt, graceMinutes)+ }+ }+ }+ }+ if (user != null) {+ NoShowAlertDialog(+ user = user,+ waypoints = waypoints,+ actions = actions,+ onDismiss = { backStack.pop() },+ )+ }+ }+ entry<Route.PermissionUpgradeDialog>(metadata = DialogPage()) {+ ConfirmDialog(+ title = stringResource(R.string.permission_upgrade_dialog_title),+ message = stringResource(R.string.permission_upgrade_dialog_message),+ confirmLabel = stringResource(R.string.permission_upgrade_dialog_confirm),+ dismissLabel = stringResource(R.string.permission_upgrade_dialog_dismiss),+ onConfirm = { backStack.pop() },+ onDismiss = { backStack.pop() },+ )+ } } }
findfamily/src/main/java/com/vayunmathur/findfamily/Route.kt
diff --git a/findfamily/src/main/java/com/vayunmathur/findfamily/Route.kt b/findfamily/src/main/java/com/vayunmathur/findfamily/Route.ktindex 4d0e8989f8..fd3ee27a6b 100644--- a/findfamily/src/main/java/com/vayunmathur/findfamily/Route.kt+++ b/findfamily/src/main/java/com/vayunmathur/findfamily/Route.kt@@ -46,4 +46,16 @@ sealed interface Route: NavKey { /** UWB Find Nearby (UWB) screen for the given peer. Full screen (no DialogPage metadata). */ @Serializable data class UwbRangingPage(val userId: Long): Route++ @Serializable+ /** Dialog showing the verification security code for the given person. */+ data class SecurityCodeDialog(val userId: Long): Route++ @Serializable+ /** Dialog for setting a no-show watch for the given person. */+ data class NoShowAlertDialog(val userId: Long): Route++ @Serializable+ /** Dialog explaining the precise-location upgrade for approximate-only grants. */+ data object PermissionUpgradeDialog: Route }
findfamily/src/main/java/com/vayunmathur/findfamily/ui/FirstRunSheet.kt
diff --git a/findfamily/src/main/java/com/vayunmathur/findfamily/ui/FirstRunSheet.kt b/findfamily/src/main/java/com/vayunmathur/findfamily/ui/FirstRunSheet.ktindex ce509d3038..302b72881c 100644--- a/findfamily/src/main/java/com/vayunmathur/findfamily/ui/FirstRunSheet.kt+++ b/findfamily/src/main/java/com/vayunmathur/findfamily/ui/FirstRunSheet.kt@@ -60,76 +60,97 @@ fun FirstRunSheet( } Dialog(onDismissRequest = { backStack.pop() }) {- Card {- Column(- Modifier.padding(16.dp),- verticalArrangement = Arrangement.spacedBy(12.dp),- ) {- when (stage) {- FirstRunStage.PairFamily -> {- Text(- stringResource(R.string.first_run_pair_title),- style = MaterialTheme.typography.headlineMedium,- )- Text(stringResource(R.string.first_run_pair_body))- Row(- Modifier.fillMaxWidth(),- horizontalArrangement = Arrangement.spacedBy(8.dp),- ) {- OutlinedButton(- { backStack.pop() },- Modifier.weight(1f),- ) { Text(stringResource(R.string.first_run_later)) }- Button(- { backStack.add(Route.AddPersonDialog()) },- Modifier.weight(1f),- ) { Text(stringResource(R.string.first_run_add_family)) }- }- }- FirstRunStage.EnableLocationSharing -> {- Text(- stringResource(R.string.first_run_location_title),- style = MaterialTheme.typography.headlineMedium,- )- Text(stringResource(R.string.first_run_location_body))- Row(- Modifier.fillMaxWidth(),- horizontalArrangement = Arrangement.spacedBy(8.dp),- ) {- OutlinedButton(- { backStack.pop() },- Modifier.weight(1f),- ) { Text(stringResource(R.string.first_run_later)) }- Button(- {- ensureLocationSharing {- ffViewModel.refreshPermissions()- onFinished()- backStack.pop()- }- },- Modifier.weight(1f),- ) { Text(stringResource(R.string.first_run_allow_location)) }- }+ FirstRunSheetContent(+ stage = stage,+ onLater = { backStack.pop() },+ onAddPerson = { backStack.add(Route.AddPersonDialog()) },+ onEnableLocation = {+ ensureLocationSharing {+ ffViewModel.refreshPermissions()+ onFinished()+ backStack.pop()+ }+ },+ onDone = {+ onFinished()+ backStack.pop()+ },+ )+ }+}++/**+ * Stateless first-run sheet content for [stage]: the route entry supplies the+ * stage and callbacks, so previews render each stage with fixed literals.+ */+@Composable+internal fun FirstRunSheetContent(+ stage: FirstRunStage,+ onLater: () -> Unit,+ onAddPerson: () -> Unit,+ onEnableLocation: () -> Unit,+ onDone: () -> Unit,+) {+ Card {+ Column(+ Modifier.padding(16.dp),+ verticalArrangement = Arrangement.spacedBy(12.dp),+ ) {+ when (stage) {+ FirstRunStage.PairFamily -> {+ Text(+ stringResource(R.string.first_run_pair_title),+ style = MaterialTheme.typography.headlineMedium,+ )+ Text(stringResource(R.string.first_run_pair_body))+ Row(+ Modifier.fillMaxWidth(),+ horizontalArrangement = Arrangement.spacedBy(8.dp),+ ) {+ OutlinedButton(+ onLater,+ Modifier.weight(1f),+ ) { Text(stringResource(R.string.first_run_later)) }+ Button(+ onAddPerson,+ Modifier.weight(1f),+ ) { Text(stringResource(R.string.first_run_add_family)) } }- FirstRunStage.Done -> {- // Family + location are in place; the sheet has- // nothing left to stage, so close it.- Text(- stringResource(R.string.first_run_done_title),- style = MaterialTheme.typography.headlineMedium,- )- Text(stringResource(R.string.first_run_done_body))+ }+ FirstRunStage.EnableLocationSharing -> {+ Text(+ stringResource(R.string.first_run_location_title),+ style = MaterialTheme.typography.headlineMedium,+ )+ Text(stringResource(R.string.first_run_location_body))+ Row(+ Modifier.fillMaxWidth(),+ horizontalArrangement = Arrangement.spacedBy(8.dp),+ ) {+ OutlinedButton(+ onLater,+ Modifier.weight(1f),+ ) { Text(stringResource(R.string.first_run_later)) } Button(- {- onFinished()- backStack.pop()- },- Modifier.fillMaxWidth(),- ) { Text(stringResource(R.string.first_run_done_action)) }+ onEnableLocation,+ Modifier.weight(1f),+ ) { Text(stringResource(R.string.first_run_allow_location)) } } }+ FirstRunStage.Done -> {+ // Family + location are in place; the sheet has+ // nothing left to stage, so close it.+ Text(+ stringResource(R.string.first_run_done_title),+ style = MaterialTheme.typography.headlineMedium,+ )+ Text(stringResource(R.string.first_run_done_body))+ Button(+ onDone,+ Modifier.fillMaxWidth(),+ ) { Text(stringResource(R.string.first_run_done_action)) }+ } } } }-}+ }
findfamily/src/main/java/com/vayunmathur/findfamily/ui/PersonDetailSheet.kt
diff --git a/findfamily/src/main/java/com/vayunmathur/findfamily/ui/PersonDetailSheet.kt b/findfamily/src/main/java/com/vayunmathur/findfamily/ui/PersonDetailSheet.ktindex 1c8a632a9b..39f2f9fa94 100644--- a/findfamily/src/main/java/com/vayunmathur/findfamily/ui/PersonDetailSheet.kt+++ b/findfamily/src/main/java/com/vayunmathur/findfamily/ui/PersonDetailSheet.kt@@ -17,22 +17,20 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp-import androidx.compose.runtime.getValue-import androidx.compose.runtime.mutableStateOf-import androidx.compose.runtime.remember-import androidx.compose.runtime.setValue import com.vayunmathur.findfamily.R import androidx.compose.runtime.Composable-import com.vayunmathur.findfamily.ui.dialogs.NoShowAlertDialog import com.vayunmathur.findfamily.notifications.FindFamilyNotificationChannels import com.vayunmathur.findfamily.network.Networking import com.vayunmathur.findfamily.platform.PersonActions import com.vayunmathur.findfamily.platform.PersonUiState @Composable-fun PersonDetailSheet(state: PersonUiState, actions: PersonActions) {+fun PersonDetailSheet(+ state: PersonUiState,+ actions: PersonActions,+ onShowNoShowAlert: () -> Unit = {},+) { val user = state.user- var showNoShowDialog by remember { mutableStateOf(false) } Column(Modifier.fillMaxWidth().navigationBarsPadding().padding(horizontal = 12.dp, vertical = 4.dp)) { UserCard(user, state.location, true) {} Spacer(Modifier.height(8.dp))@@ -98,7 +96,7 @@ fun PersonDetailSheet(state: PersonUiState, actions: PersonActions) { Spacer(Modifier.height(4.dp)) // No-show watch (issue 702): expected arrival that never happens. OutlinedButton(- { showNoShowDialog = true },+ onShowNoShowAlert, Modifier.fillMaxWidth(), ) { Text(stringResource(R.string.noshow_watch_button))@@ -112,12 +110,4 @@ fun PersonDetailSheet(state: PersonUiState, actions: PersonActions) { Text(stringResource(R.string.change_connected_contact)) } }- if (showNoShowDialog) {- NoShowAlertDialog(- user = user,- waypoints = state.waypoints,- actions = actions,- onDismiss = { showNoShowDialog = false },- )- } }
findfamily/src/main/java/com/vayunmathur/findfamily/ui/PersonSheet.kt
diff --git a/findfamily/src/main/java/com/vayunmathur/findfamily/ui/PersonSheet.kt b/findfamily/src/main/java/com/vayunmathur/findfamily/ui/PersonSheet.ktindex 38b0e1038e..66e547928a 100644--- a/findfamily/src/main/java/com/vayunmathur/findfamily/ui/PersonSheet.kt+++ b/findfamily/src/main/java/com/vayunmathur/findfamily/ui/PersonSheet.kt@@ -10,9 +10,7 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue-import androidx.compose.runtime.mutableStateOf 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.res.stringResource@@ -20,7 +18,6 @@ import androidx.compose.ui.unit.dp import androidx.compose.ui.window.Dialog import com.vayunmathur.findfamily.R import com.vayunmathur.findfamily.Route-import com.vayunmathur.findfamily.ui.dialogs.SecurityCodeDialog import com.vayunmathur.findfamily.platform.FindFamilyViewModel import com.vayunmathur.findfamily.network.Networking import com.vayunmathur.findfamily.platform.PersonActions@@ -64,8 +61,6 @@ fun PersonSheet( val isShowingPresent by ffViewModel.isShowingPresent.collectAsState() val historyMode = !isShowingPresent - var showSecurityCode by remember { mutableStateOf(false) }- val requestPickContact = platform.requestPickContact { name, photo -> ffViewModel.updateContactNamePhoto(userId, name, photo) }@@ -146,6 +141,7 @@ fun PersonSheet( connectedUsers, ), personActions,+ onShowNoShowAlert = { backStack.add(Route.NoShowAlertDialog(userId)) }, ) val context = LocalContext.current val isSelf = userId == Networking.userid@@ -161,7 +157,7 @@ fun PersonSheet( ) { Text(stringResource(R.string.find_nearby_content_description)) } } OutlinedButton(- { showSecurityCode = true },+ { backStack.add(Route.SecurityCodeDialog(userId)) }, Modifier.weight(1f), ) { Text(stringResource(R.string.verify_security_code_content_description)) } }@@ -190,7 +186,4 @@ fun PersonSheet( } } - if (showSecurityCode && user != null && userId != Networking.userid) {- SecurityCodeDialog(user, ffViewModel) { showSecurityCode = false }- } }
findfamily/src/main/java/com/vayunmathur/findfamily/ui/WaypointSheet.kt
diff --git a/findfamily/src/main/java/com/vayunmathur/findfamily/ui/WaypointSheet.kt b/findfamily/src/main/java/com/vayunmathur/findfamily/ui/WaypointSheet.ktindex 9e6b94071c..65e05d46b2 100644--- a/findfamily/src/main/java/com/vayunmathur/findfamily/ui/WaypointSheet.kt+++ b/findfamily/src/main/java/com/vayunmathur/findfamily/ui/WaypointSheet.kt@@ -58,60 +58,86 @@ fun WaypointSheet( } Dialog(onDismissRequest = { backStack.pop() }) {- Card {- Column(- Modifier.padding(16.dp),- verticalArrangement = Arrangement.spacedBy(8.dp),- ) {- OutlinedTextField(- waypointName,- { ffViewModel.mapState.setWaypointName(it) },- Modifier.fillMaxWidth(),- isError = waypointName.isBlank(),- supportingText = if (waypointName.isBlank()) {- { Text(stringResource(R.string.waypoint_name_blank_error)) }- } else null,- )- OutlinedTextField(- waypointRange,- { ffViewModel.mapState.setWaypointRange(it) },- Modifier.fillMaxWidth(),- suffix = { Text(stringResource(R.string.waypoint_range_suffix)) },- keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Decimal),- isError = waypointRange.toDoubleOrNull() == null,- supportingText = if (waypointRange.toDoubleOrNull() == null) {- { Text(stringResource(R.string.waypoint_range_error)) }- } else null,- )- Row(- Modifier.fillMaxWidth(),- horizontalArrangement = Arrangement.spacedBy(8.dp),- ) {- OutlinedButton(- { backStack.pop() },- Modifier.weight(1f),- ) { Text(stringResource(android.R.string.cancel)) }- Button(- {- ensureNotifications {- if (ffViewModel.mapState.saveCurrentWaypoint(waypointId)) {- backStack.pop()- }- }- },- Modifier.weight(1f),- ) { Text(stringResource(android.R.string.ok)) }+ WaypointSheetContent(+ name = waypointName,+ range = waypointRange,+ showDelete = waypointId != 0L && existing != null,+ onNameChange = { ffViewModel.mapState.setWaypointName(it) },+ onRangeChange = { ffViewModel.mapState.setWaypointRange(it) },+ onCancel = { backStack.pop() },+ onSave = {+ ensureNotifications {+ if (ffViewModel.mapState.saveCurrentWaypoint(waypointId)) {+ backStack.pop()+ } }- if (waypointId != 0L && existing != null) {- OutlinedButton(- {- ffViewModel.deleteWaypoint(existing)- backStack.pop()- },- Modifier.fillMaxWidth(),- ) { Text(stringResource(R.string.delete_place_content_description)) }+ },+ onDelete = {+ if (existing != null) {+ ffViewModel.deleteWaypoint(existing)+ backStack.pop() }+ },+ )+ }+}++/** Stateless waypoint form: the route entry supplies the form values and callbacks. */+@Composable+internal fun WaypointSheetContent(+ name: String,+ range: String,+ showDelete: Boolean,+ onNameChange: (String) -> Unit,+ onRangeChange: (String) -> Unit,+ onCancel: () -> Unit,+ onSave: () -> Unit,+ onDelete: () -> Unit,+) {+ Card {+ Column(+ Modifier.padding(16.dp),+ verticalArrangement = Arrangement.spacedBy(8.dp),+ ) {+ OutlinedTextField(+ name,+ onNameChange,+ Modifier.fillMaxWidth(),+ isError = name.isBlank(),+ supportingText = if (name.isBlank()) {+ { Text(stringResource(R.string.waypoint_name_blank_error)) }+ } else null,+ )+ OutlinedTextField(+ range,+ onRangeChange,+ Modifier.fillMaxWidth(),+ suffix = { Text(stringResource(R.string.waypoint_range_suffix)) },+ keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Decimal),+ isError = range.toDoubleOrNull() == null,+ supportingText = if (range.toDoubleOrNull() == null) {+ { Text(stringResource(R.string.waypoint_range_error)) }+ } else null,+ )+ Row(+ Modifier.fillMaxWidth(),+ horizontalArrangement = Arrangement.spacedBy(8.dp),+ ) {+ OutlinedButton(+ onCancel,+ Modifier.weight(1f),+ ) { Text(stringResource(android.R.string.cancel)) }+ Button(+ onSave,+ Modifier.weight(1f),+ ) { Text(stringResource(android.R.string.ok)) }+ }+ if (showDelete) {+ OutlinedButton(+ onDelete,+ Modifier.fillMaxWidth(),+ ) { Text(stringResource(R.string.delete_place_content_description)) } } } }-}+ }
findfamily/src/main/java/com/vayunmathur/findfamily/ui/dialogs/AddLinkDialog.kt
diff --git a/findfamily/src/main/java/com/vayunmathur/findfamily/ui/dialogs/AddLinkDialog.kt b/findfamily/src/main/java/com/vayunmathur/findfamily/ui/dialogs/AddLinkDialog.ktindex a35ca0dd7e..4c16f903c8 100644--- a/findfamily/src/main/java/com/vayunmathur/findfamily/ui/dialogs/AddLinkDialog.kt+++ b/findfamily/src/main/java/com/vayunmathur/findfamily/ui/dialogs/AddLinkDialog.kt@@ -53,33 +53,55 @@ fun AddLinkDialog(backStack: NavBackStack<Route>, ffViewModel: FindFamilyViewMod var failed by remember { mutableStateOf(false) } Dialog({backStack.pop()}) {- Card {- Column(Modifier.padding(16.dp), verticalArrangement = Arrangement.spacedBy(16.dp)) {- Text(stringResource(R.string.add_link_title), style = MaterialTheme.typography.headlineMedium)+ AddLinkContent(+ name = name,+ expiryTime = expiryTime,+ expiryOptions = options.keys,+ failed = failed,+ onNameChange = { name = it },+ onExpiryChange = { expiryTime = it },+ onCreate = {+ failed = false+ ffViewModel.createTemporaryLink(name, options[expiryTime]!!) { success ->+ if (success) backStack.pop() else failed = true+ }+ },+ )+ }+}++/** Stateless add-link content: the route entry supplies the form values and callbacks. */+@Composable+internal fun AddLinkContent(+ name: String,+ expiryTime: String,+ expiryOptions: Collection<String>,+ failed: Boolean,+ onNameChange: (String) -> Unit,+ onExpiryChange: (String) -> Unit,+ onCreate: () -> Unit,+) {+ Card {+ Column(Modifier.padding(16.dp), verticalArrangement = Arrangement.spacedBy(16.dp)) {+ Text(stringResource(R.string.add_link_title), style = MaterialTheme.typography.headlineMedium) - OutlinedTextField(name, {name = it}, label = {Text("Title")})+ OutlinedTextField(name, onNameChange, label = {Text("Title")}) - DropdownField(expiryTime, { expiryTime = it }, options.keys)+ DropdownField(expiryTime, onExpiryChange, expiryOptions) - if (failed) {- Text(- stringResource(R.string.link_pqc_unavailable),- color = MaterialTheme.colorScheme.error,- style = MaterialTheme.typography.bodyMedium,- )- }+ if (failed) {+ Text(+ stringResource(R.string.link_pqc_unavailable),+ color = MaterialTheme.colorScheme.error,+ style = MaterialTheme.typography.bodyMedium,+ )+ } - Button(- {- failed = false- ffViewModel.createTemporaryLink(name, options[expiryTime]!!) { success ->- if (success) backStack.pop() else failed = true- }- },- enabled = name.isNotBlank()- ) {- Text(stringResource(R.string.create_temporary_link))- }+ Button(+ onCreate,+ enabled = name.isNotBlank()+ ) {+ Text(stringResource(R.string.create_temporary_link)) } } }
findfamily/src/main/java/com/vayunmathur/findfamily/ui/dialogs/AddPersonDialog.kt
diff --git a/findfamily/src/main/java/com/vayunmathur/findfamily/ui/dialogs/AddPersonDialog.kt b/findfamily/src/main/java/com/vayunmathur/findfamily/ui/dialogs/AddPersonDialog.ktindex e115dcc0fa..8f7cb5b399 100644--- a/findfamily/src/main/java/com/vayunmathur/findfamily/ui/dialogs/AddPersonDialog.kt+++ b/findfamily/src/main/java/com/vayunmathur/findfamily/ui/dialogs/AddPersonDialog.kt@@ -71,104 +71,41 @@ fun AddPersonDialog( val inviteFingerprint = fingerprint?.takeIf { id != null && parsedUserId == id } Dialog({backStack.pop()}) {- Card {- Column(Modifier.padding(16.dp), verticalArrangement = Arrangement.spacedBy(16.dp)) {- Text(stringResource(R.string.add_person_title), style = MaterialTheme.typography.headlineMedium)-- OutlinedTextField(- Networking.userid.encodeBase26(),- {},- interactionSource = interactionSourceClickable {- platform.copy(Networking.userid.encodeBase26())- },- label = { Text(stringResource(R.string.your_findfamily_id)) },- trailingIcon = {- IconCopy()- },- readOnly = true+ AddPersonContent(+ myId = Networking.userid.encodeBase26(),+ userid = userid,+ contactName = contactName,+ userStatus = userStatus,+ inviteReadOnly = id != null,+ onUseridChange = { userid = it.uppercase().filter { c -> c in 'A'..'Z' } },+ onCopyMyId = { platform.copy(Networking.userid.encodeBase26()) },+ onShareInvite = {+ val base = "https://maproj.org/ff/share#id=${Networking.userid.encodeBase26()}"+ val link = Networking.myInviteFingerprint()?.let { "$base&k=$it" } ?: base+ ExternalIntents.shareText(context, link, shareInviteChooser)+ },+ onPickContact = { requestPickContact2() },+ onConnect = {+ val targetId = parsedUserId ?: return@AddPersonContent+ val userToAdd = User(+ contactName!!,+ contactPhoto,+ "Unknown Location",+ true,+ if (userStatus == RequestStatus.AWAITING_REQUEST) RequestStatus.MUTUAL_CONNECTION else RequestStatus.AWAITING_RESPONSE,+ Clock.System.now(),+ null,+ targetId )-- // Share sheet instead of copy/paste: sends an https link that bounces to- // findfamily://add/<myId>?k=<fingerprint>, which prefills the recipient's Add- // Person dialog. The web hop exists because many messengers won't linkify a bare- // custom scheme. Both values ride in the fragment, which browsers never send, so- // the server sees only that some share page was opened. `k` is a 22-character- // hash of our public bundle, not the bundle itself (~4 kB base64) — the recipient- // fetches the key from the relay and checks it against this.- OutlinedButton(- {- val base = "https://maproj.org/ff/share#id=${Networking.userid.encodeBase26()}"- val link = Networking.myInviteFingerprint()?.let { "$base&k=$it" } ?: base- ExternalIntents.shareText(- context,- link,- shareInviteChooser,- )- },- Modifier.fillMaxWidth()- ) {- IconShare()- Spacer(Modifier.width(8.dp))- Text(stringResource(R.string.share_invite_link))- }-- OutlinedTextField(- userid,- // Invite IDs are uppercase Base26; normalize typed/pasted- // input instead of decoding lowercase or symbols into a- // different person's ID.- { userid = it.uppercase().filter { c -> c in 'A'..'Z' } },- readOnly = id != null,- label = { Text(stringResource(R.string.contact_findfamily_id)) },- isError = userStatus == RequestStatus.MUTUAL_CONNECTION || userStatus == RequestStatus.AWAITING_RESPONSE,- supportingText =- when (userStatus) {- RequestStatus.AWAITING_REQUEST -> { @Composable {Text(stringResource(R.string.status_awaiting_request))}}- RequestStatus.MUTUAL_CONNECTION -> {- if (userid == Networking.userid.encodeBase26())- {@Composable {Text(stringResource(R.string.status_cannot_share_self))}}- else {@Composable {Text(stringResource(R.string.status_already_sharing))}}- }- RequestStatus.AWAITING_RESPONSE -> {@Composable {Text(stringResource(R.string.status_already_requested)) } }- else -> null- }- )-- OutlinedTextField(contactName ?: "", {}, interactionSource = interactionSourceClickable {- requestPickContact2()- }, label = { Text(stringResource(R.string.contact_name_label)) }, readOnly = true)-- Button(- {- val targetId = parsedUserId ?: return@Button- val userToAdd = User(- contactName!!,- contactPhoto,- "Unknown Location",- true,- if (userStatus == RequestStatus.AWAITING_REQUEST) RequestStatus.MUTUAL_CONNECTION else RequestStatus.AWAITING_RESPONSE,- Clock.System.now(),- null,- targetId- )- ffViewModel.connectUser(- userToAdd,- inviteFingerprint = inviteFingerprint,- onNeedsUpdate = { showOutdatedPeer = true },- onKeyMismatch = { showKeyMismatch = true },- onDone = { backStack.pop() },- )- },- enabled = parsedUserId != null && userid.isNotBlank() && contactName != null && !(userStatus == RequestStatus.MUTUAL_CONNECTION || userStatus == RequestStatus.AWAITING_RESPONSE)- ) {- if (userStatus == RequestStatus.AWAITING_REQUEST) {- Text(stringResource(R.string.accept_location_request))- } else {- Text(stringResource(R.string.request_location))- }- }- }- }+ ffViewModel.connectUser(+ userToAdd,+ inviteFingerprint = inviteFingerprint,+ onNeedsUpdate = { showOutdatedPeer = true },+ onKeyMismatch = { showKeyMismatch = true },+ onDone = { backStack.pop() },+ )+ },+ ) } if (showOutdatedPeer) {@@ -180,6 +117,97 @@ fun AddPersonDialog( } } +/**+ * Stateless add-person content: the route entry supplies the form values, the+ * typed id's request status, and callbacks, so previews render it with literals.+ */+@Composable+internal fun AddPersonContent(+ myId: String,+ userid: String,+ contactName: String?,+ userStatus: RequestStatus?,+ inviteReadOnly: Boolean,+ onUseridChange: (String) -> Unit,+ onCopyMyId: () -> Unit,+ onShareInvite: () -> Unit,+ onPickContact: () -> Unit,+ onConnect: () -> Unit,+) {+ val parsedUserId = runCatching { userid.decodeBase26() }.getOrNull()+ Card {+ Column(Modifier.padding(16.dp), verticalArrangement = Arrangement.spacedBy(16.dp)) {+ Text(stringResource(R.string.add_person_title), style = MaterialTheme.typography.headlineMedium)++ OutlinedTextField(+ myId,+ {},+ interactionSource = interactionSourceClickable {+ onCopyMyId()+ },+ label = { Text(stringResource(R.string.your_findfamily_id)) },+ trailingIcon = {+ IconCopy()+ },+ readOnly = true+ )++ // Share sheet instead of copy/paste: sends an https link that bounces to+ // findfamily://add/<myId>?k=<fingerprint>, which prefills the recipient's Add+ // Person dialog. The web hop exists because many messengers won't linkify a bare+ // custom scheme. Both values ride in the fragment, which browsers never send, so+ // the server sees only that some share page was opened. `k` is a 22-character+ // hash of our public bundle, not the bundle itself (~4 kB base64) - the recipient+ // fetches the key from the relay and checks it against this.+ OutlinedButton(+ onShareInvite,+ Modifier.fillMaxWidth()+ ) {+ IconShare()+ Spacer(Modifier.width(8.dp))+ Text(stringResource(R.string.share_invite_link))+ }++ OutlinedTextField(+ userid,+ // Invite IDs are uppercase Base26; normalize typed/pasted+ // input instead of decoding lowercase or symbols into a+ // different person's ID.+ onUseridChange,+ readOnly = inviteReadOnly,+ label = { Text(stringResource(R.string.contact_findfamily_id)) },+ isError = userStatus == RequestStatus.MUTUAL_CONNECTION || userStatus == RequestStatus.AWAITING_RESPONSE,+ supportingText =+ when (userStatus) {+ RequestStatus.AWAITING_REQUEST -> { @Composable {Text(stringResource(R.string.status_awaiting_request))}}+ RequestStatus.MUTUAL_CONNECTION -> {+ if (userid == myId)+ {@Composable {Text(stringResource(R.string.status_cannot_share_self))}}+ else {@Composable {Text(stringResource(R.string.status_already_sharing))}}+ }+ RequestStatus.AWAITING_RESPONSE -> {@Composable {Text(stringResource(R.string.status_already_requested)) } }+ else -> null+ }+ )++ OutlinedTextField(contactName ?: "", {}, interactionSource = interactionSourceClickable {+ onPickContact()+ }, label = { Text(stringResource(R.string.contact_name_label)) }, readOnly = true)++ Button(+ onConnect,+ enabled = parsedUserId != null && userid.isNotBlank() && contactName != null && !(userStatus == RequestStatus.MUTUAL_CONNECTION || userStatus == RequestStatus.AWAITING_RESPONSE)+ ) {+ if (userStatus == RequestStatus.AWAITING_REQUEST) {+ Text(stringResource(R.string.accept_location_request))+ } else {+ Text(stringResource(R.string.request_location))+ }+ }+ }+ }+}+ /** * Decodes an uppercase Base26 invite ID. Strict on purpose: characters outside * `A`–`Z`, a value that would overflow, or one above [Long.MAX_VALUE] all throw@@ -190,10 +218,10 @@ fun AddPersonDialog( fun String.decodeBase26(): Long { var acc = 0uL for (c in this) {- require(c in 'A'..'Z') { "invalid Base26 character: $c" }- val digit = (c.code - 65).toULong()- require(acc <= (ULong.MAX_VALUE - digit) / 26uL) { "Base26 value overflows" }- acc = acc * 26uL + digit+ require(c in 'A'..'Z') { "invalid Base26 character: $c" }+ val digit = (c.code - 65).toULong()+ require(acc <= (ULong.MAX_VALUE - digit) / 26uL) { "Base26 value overflows" }+ acc = acc * 26uL + digit } require(acc <= Long.MAX_VALUE.toULong()) { "Base26 value out of range" } return acc.toLong()@@ -202,8 +230,8 @@ fun String.decodeBase26(): Long { fun Long.encodeBase26(): String = buildString { var remaining = [email protected]() while (remaining > 0uL) {- insert(0, ((remaining % 26uL) + 65uL).toInt().toChar())- remaining /= 26uL+ insert(0, ((remaining % 26uL) + 65uL).toInt().toChar())+ remaining /= 26uL } }
findfamily/src/main/java/com/vayunmathur/findfamily/ui/dialogs/AddTrackerDialog.kt
diff --git a/findfamily/src/main/java/com/vayunmathur/findfamily/ui/dialogs/AddTrackerDialog.kt b/findfamily/src/main/java/com/vayunmathur/findfamily/ui/dialogs/AddTrackerDialog.ktindex e438853c58..a95b8ee244 100644--- a/findfamily/src/main/java/com/vayunmathur/findfamily/ui/dialogs/AddTrackerDialog.kt+++ b/findfamily/src/main/java/com/vayunmathur/findfamily/ui/dialogs/AddTrackerDialog.kt@@ -75,61 +75,87 @@ fun AddTrackerDialog(backStack: NavBackStack<Route>) { } Dialog({ cancelAndPop() }) {- Card {- Column(Modifier.padding(16.dp), verticalArrangement = Arrangement.spacedBy(12.dp)) {- Text(stringResource(R.string.add_tracker_title), style = MaterialTheme.typography.headlineMedium)+ AddTrackerContent(+ name = name,+ deviceLabels = devices.map { d -> (runCatching { d.name }.getOrNull() ?: d.address) to d.address },+ binding = binding,+ failed = failed,+ onNameChange = { name = it },+ onDeviceClick = { index ->+ val device = devices.getOrNull(index) ?: return@AddTrackerContent+ failed = false+ binding = true+ bindJob = scope.launch {+ val ok = TrackerBinder.bind(context, name, device)+ binding = false+ if (ok) backStack.pop() else failed = true+ }+ },+ onCancel = { cancelAndPop() },+ )+ }+} - OutlinedTextField(- name, { name = it },- label = { Text(stringResource(R.string.add_tracker_name_label)) },- modifier = Modifier.fillMaxWidth(),- )+/** Stateless add-tracker content: the route entry supplies scanned device labels and callbacks. */+@Composable+internal fun AddTrackerContent(+ name: String,+ deviceLabels: List<Pair<String, String>>,+ binding: Boolean,+ failed: Boolean,+ onNameChange: (String) -> Unit,+ onDeviceClick: (Int) -> Unit,+ onCancel: () -> Unit,+) {+ Card {+ Column(Modifier.padding(16.dp), verticalArrangement = Arrangement.spacedBy(12.dp)) {+ Text(stringResource(R.string.add_tracker_title), style = MaterialTheme.typography.headlineMedium) - Text(- stringResource(R.string.add_tracker_scan_hint),- style = MaterialTheme.typography.bodySmall,- )+ OutlinedTextField(+ name, onNameChange,+ label = { Text(stringResource(R.string.add_tracker_name_label)) },+ modifier = Modifier.fillMaxWidth(),+ ) - if (devices.isEmpty()) {- Text(stringResource(R.string.add_tracker_scanning), style = MaterialTheme.typography.bodyMedium)- } else {- LazyColumn(Modifier.fillMaxWidth().heightIn(max = 220.dp), verticalArrangement = Arrangement.spacedBy(6.dp)) {- items(devices, key = { it.address }) { device ->- val label = runCatching { device.name }.getOrNull() ?: device.address- Card(Modifier.clickable(enabled = !binding && name.isNotBlank()) {- failed = false- binding = true- bindJob = scope.launch {- val ok = TrackerBinder.bind(context, name, device)- binding = false- if (ok) backStack.pop() else failed = true- }- }) {- ListItem(- { Text(label) },- colors = ListItemDefaults.colors(),- supportingContent = { Text(device.address) },- )- }+ Text(+ stringResource(R.string.add_tracker_scan_hint),+ style = MaterialTheme.typography.bodySmall,+ )++ if (deviceLabels.isEmpty()) {+ Text(stringResource(R.string.add_tracker_scanning), style = MaterialTheme.typography.bodyMedium)+ } else {+ LazyColumn(Modifier.fillMaxWidth().heightIn(max = 220.dp), verticalArrangement = Arrangement.spacedBy(6.dp)) {+ items(deviceLabels.indices.toList(), key = { deviceLabels[it].second }) { index ->+ val (label, address) = deviceLabels[index]+ Card(Modifier.clickable(enabled = !binding && name.isNotBlank()) {+ onDeviceClick(index)+ }) {+ ListItem(+ { Text(label) },+ colors = ListItemDefaults.colors(),+ supportingContent = { Text(address) },+ ) } } }+ } - if (binding) {- Text(stringResource(R.string.add_tracker_binding), style = MaterialTheme.typography.bodyMedium)- }- if (failed) {- Text(- stringResource(R.string.add_tracker_failed),- color = MaterialTheme.colorScheme.error,- style = MaterialTheme.typography.bodyMedium,- )- }+ if (binding) {+ Text(stringResource(R.string.add_tracker_binding), style = MaterialTheme.typography.bodyMedium)+ }+ if (failed) {+ Text(+ stringResource(R.string.add_tracker_failed),+ color = MaterialTheme.colorScheme.error,+ style = MaterialTheme.typography.bodyMedium,+ )+ } - Button({ cancelAndPop() }) {- Text(stringResource(android.R.string.cancel))- }+ Button(onCancel) {+ Text(stringResource(android.R.string.cancel)) } } }+ }
findfamily/src/main/java/com/vayunmathur/findfamily/ui/dialogs/NoShowAlertDialog.kt
diff --git a/findfamily/src/main/java/com/vayunmathur/findfamily/ui/dialogs/NoShowAlertDialog.kt b/findfamily/src/main/java/com/vayunmathur/findfamily/ui/dialogs/NoShowAlertDialog.ktindex 4bf7282586..ee7f81303d 100644--- a/findfamily/src/main/java/com/vayunmathur/findfamily/ui/dialogs/NoShowAlertDialog.kt+++ b/findfamily/src/main/java/com/vayunmathur/findfamily/ui/dialogs/NoShowAlertDialog.kt@@ -63,6 +63,20 @@ fun NoShowAlertDialog( waypoints: List<Waypoint>, actions: PersonActions, onDismiss: () -> Unit,+) {+ Dialog(onDismissRequest = onDismiss) {+ NoShowAlertContent(user = user, waypoints = waypoints, actions = actions, onDismiss = onDismiss)+ }+}++/** Stateless no-show dialog content: dialog-local picker state stays inside the content. */+@OptIn(ExperimentalMaterial3Api::class)+@Composable+internal fun NoShowAlertContent(+ user: User,+ waypoints: List<Waypoint>,+ actions: PersonActions,+ onDismiss: () -> Unit, ) { val namedWaypoints = remember(waypoints) { waypoints.filter { it.name.isNotBlank() } } var waypointId: Long? by remember { mutableStateOf(null) }@@ -78,213 +92,211 @@ fun NoShowAlertDialog( val anyPlaceLabel = stringResource(R.string.noshow_place_any) val selectedPlaceLabel = waypointId- ?.let { id -> namedWaypoints.firstOrNull { it.id == id }?.name }- ?: anyPlaceLabel+ ?.let { id -> namedWaypoints.firstOrNull { it.id == id }?.name }+ ?: anyPlaceLabel // Date/time assembly below uses java.time with the device zone; the dialog // only stores raw millis/hour/minute until both halves are chosen. val dateLabel = dateMillis?.let { millis ->- JavaInstant.ofEpochMilli(millis).atZone(ZoneId.systemDefault()).toLocalDate().toString()+ JavaInstant.ofEpochMilli(millis).atZone(ZoneId.systemDefault()).toLocalDate().toString() } ?: stringResource(R.string.noshow_pick_date) val timeLabel = if (hour != null && minute != null) {- String.format(Locale.ROOT, "%02d:%02d", hour, minute)+ String.format(Locale.ROOT, "%02d:%02d", hour, minute) } else {- stringResource(R.string.noshow_pick_time)+ stringResource(R.string.noshow_pick_time) } val expectedAt: Instant? = remember(dateMillis, hour, minute) {- val millis = dateMillis- val h = hour- val m = minute- if (millis == null || h == null || m == null) {- null- } else {- val date = JavaInstant.ofEpochMilli(millis)- .atZone(ZoneId.systemDefault()).toLocalDate()- val zoned = LocalDate.of(date.year, date.month, date.dayOfMonth)- .atTime(LocalTime.of(h, m))- .atZone(ZoneId.systemDefault())- Instant.fromEpochMilliseconds(zoned.toInstant().toEpochMilli())- }+ val millis = dateMillis+ val h = hour+ val m = minute+ if (millis == null || h == null || m == null) {+ null+ } else {+ val date = JavaInstant.ofEpochMilli(millis)+ .atZone(ZoneId.systemDefault()).toLocalDate()+ val zoned = LocalDate.of(date.year, date.month, date.dayOfMonth)+ .atTime(LocalTime.of(h, m))+ .atZone(ZoneId.systemDefault())+ Instant.fromEpochMilliseconds(zoned.toInstant().toEpochMilli())+ } } val graceOptions = remember { listOf(0, 15, 30, 60, 120) } val scheduledMessage = stringResource(R.string.noshow_scheduled) val resources = LocalResources.current fun graceLabel(minutesValue: Int): String =- resources.getQuantityString(R.plurals.noshow_grace_minutes, minutesValue, minutesValue)+ resources.getQuantityString(R.plurals.noshow_grace_minutes, minutesValue, minutesValue) - Dialog(onDismissRequest = onDismiss) {- Card {- Column(Modifier.padding(16.dp), verticalArrangement = Arrangement.spacedBy(16.dp)) {+ Card {+ Column(Modifier.padding(16.dp), verticalArrangement = Arrangement.spacedBy(16.dp)) {+ Text(+ stringResource(R.string.noshow_title, user.name),+ style = MaterialTheme.typography.headlineMedium,+ )++ // Expected place: "Anywhere" plus one entry per named saved place,+ // mirroring the arrival-trigger dropdown in AutoToggleRow.+ Row(+ Modifier.fillMaxWidth(),+ verticalAlignment = Alignment.CenterVertically,+ ) { Text(- stringResource(R.string.noshow_title, user.name),- style = MaterialTheme.typography.headlineMedium,+ stringResource(R.string.noshow_place_label),+ Modifier.weight(1f),+ style = MaterialTheme.typography.bodyMedium, )-- // Expected place: "Anywhere" plus one entry per named saved place,- // mirroring the arrival-trigger dropdown in AutoToggleRow.- Row(- Modifier.fillMaxWidth(),- verticalAlignment = Alignment.CenterVertically,- ) {- Text(- stringResource(R.string.noshow_place_label),- Modifier.weight(1f),- style = MaterialTheme.typography.bodyMedium,+ Box {+ OutlinedTextField(+ selectedPlaceLabel, {},+ interactionSource = interactionSourceClickable { placeExpanded = true },+ readOnly = true,+ modifier = Modifier.width(180.dp),+ trailingIcon = {+ ExposedDropdownMenuDefaults.TrailingIcon(expanded = placeExpanded)+ }, )- Box {- OutlinedTextField(- selectedPlaceLabel, {},- interactionSource = interactionSourceClickable { placeExpanded = true },- readOnly = true,- modifier = Modifier.width(180.dp),- trailingIcon = {- ExposedDropdownMenuDefaults.TrailingIcon(expanded = placeExpanded)+ DropdownMenu(placeExpanded, { placeExpanded = false }) {+ SelectableDropdownMenuItem(+ selected = waypointId == null,+ onClick = {+ placeExpanded = false+ waypointId = null },+ text = { Text(anyPlaceLabel) },+ selectedLeadingIcon = { IconCheck() }, )- DropdownMenu(placeExpanded, { placeExpanded = false }) {+ namedWaypoints.forEach { waypoint -> SelectableDropdownMenuItem(- selected = waypointId == null,+ selected = waypointId == waypoint.id, onClick = { placeExpanded = false- waypointId = null+ waypointId = waypoint.id },- text = { Text(anyPlaceLabel) },+ text = { Text(waypoint.name) }, selectedLeadingIcon = { IconCheck() }, )- namedWaypoints.forEach { waypoint ->- SelectableDropdownMenuItem(- selected = waypointId == waypoint.id,- onClick = {- placeExpanded = false- waypointId = waypoint.id- },- text = { Text(waypoint.name) },- selectedLeadingIcon = { IconCheck() },- )- } } } }+ } - // Expected date + time rows, opening the shared pickers.- Row(- Modifier.fillMaxWidth(),- horizontalArrangement = Arrangement.spacedBy(8.dp),+ // Expected date + time rows, opening the shared pickers.+ Row(+ Modifier.fillMaxWidth(),+ horizontalArrangement = Arrangement.spacedBy(8.dp),+ ) {+ OutlinedButton(+ { showDatePicker = true },+ Modifier.weight(1f), ) {- OutlinedButton(- { showDatePicker = true },- Modifier.weight(1f),- ) {- Text(dateLabel)- }- OutlinedButton(- { showTimePicker = true },- Modifier.weight(1f),- ) {- Text(timeLabel)- }+ Text(dateLabel) }-- // Grace period dropdown.- Row(- Modifier.fillMaxWidth(),- verticalAlignment = Alignment.CenterVertically,+ OutlinedButton(+ { showTimePicker = true },+ Modifier.weight(1f), ) {- Text(- stringResource(R.string.noshow_grace_label),- Modifier.weight(1f),- style = MaterialTheme.typography.bodyMedium,+ Text(timeLabel)+ }+ }++ // Grace period dropdown.+ Row(+ Modifier.fillMaxWidth(),+ verticalAlignment = Alignment.CenterVertically,+ ) {+ Text(+ stringResource(R.string.noshow_grace_label),+ Modifier.weight(1f),+ style = MaterialTheme.typography.bodyMedium,+ )+ Box {+ OutlinedTextField(+ graceLabel(graceMinutes), {},+ interactionSource = interactionSourceClickable { graceExpanded = true },+ readOnly = true,+ modifier = Modifier.width(180.dp),+ trailingIcon = {+ ExposedDropdownMenuDefaults.TrailingIcon(expanded = graceExpanded)+ }, )- Box {- OutlinedTextField(- graceLabel(graceMinutes), {},- interactionSource = interactionSourceClickable { graceExpanded = true },- readOnly = true,- modifier = Modifier.width(180.dp),- trailingIcon = {- ExposedDropdownMenuDefaults.TrailingIcon(expanded = graceExpanded)- },- )- DropdownMenu(graceExpanded, { graceExpanded = false }) {- graceOptions.forEach { option ->- SelectableDropdownMenuItem(- selected = graceMinutes == option,- onClick = {- graceExpanded = false- graceMinutes = option- },- text = { Text(graceLabel(option)) },- selectedLeadingIcon = { IconCheck() },- )- }+ DropdownMenu(graceExpanded, { graceExpanded = false }) {+ graceOptions.forEach { option ->+ SelectableDropdownMenuItem(+ selected = graceMinutes == option,+ onClick = {+ graceExpanded = false+ graceMinutes = option+ },+ text = { Text(graceLabel(option)) },+ selectedLeadingIcon = { IconCheck() },+ ) } } }+ } - Button(- {- val at = expectedAt ?: return@Button- actions.setNoShowAlert(user, waypointId, at, graceMinutes)- messenger.show(scheduledMessage)- onDismiss()- },- enabled = expectedAt != null,- ) {- Text(stringResource(R.string.noshow_save))- }+ Button(+ {+ val at = expectedAt ?: return@Button+ actions.setNoShowAlert(user, waypointId, at, graceMinutes)+ messenger.show(scheduledMessage)+ onDismiss()+ },+ enabled = expectedAt != null,+ ) {+ Text(stringResource(R.string.noshow_save)) } } } if (showDatePicker) {- val pickerState = rememberDatePickerState(dateMillis)- DatePickerDialog(- onDismissRequest = { showDatePicker = false },- confirmButton = {- Button(- onClick = {- dateMillis = pickerState.selectedDateMillis- showDatePicker = false- },- enabled = pickerState.selectedDateMillis != null,- ) {- Text(stringResource(UiR.string.ok))- }- },- dismissButton = {- Button(onClick = { showDatePicker = false }) {- Text(stringResource(UiR.string.cancel))- }- },- ) {- DatePicker(pickerState)- }+ val pickerState = rememberDatePickerState(dateMillis)+ DatePickerDialog(+ onDismissRequest = { showDatePicker = false },+ confirmButton = {+ Button(+ onClick = {+ dateMillis = pickerState.selectedDateMillis+ showDatePicker = false+ },+ enabled = pickerState.selectedDateMillis != null,+ ) {+ Text(stringResource(UiR.string.ok))+ }+ },+ dismissButton = {+ Button(onClick = { showDatePicker = false }) {+ Text(stringResource(UiR.string.cancel))+ }+ },+ ) {+ DatePicker(pickerState)+ } } if (showTimePicker) {- val pickerState = rememberTimePickerState(- initialHour = hour ?: 12,- initialMinute = minute ?: 0,- )- AlertDialog(- onDismissRequest = { showTimePicker = false },- confirmButton = {- Button(- onClick = {- hour = pickerState.hour- minute = pickerState.minute- showTimePicker = false- },- ) {- Text(stringResource(UiR.string.ok))- }- },- dismissButton = {- Button(onClick = { showTimePicker = false }) {- Text(stringResource(UiR.string.cancel))- }- },- properties = DialogProperties(usePlatformDefaultWidth = false),- text = { TimePicker(pickerState) },- )+ val pickerState = rememberTimePickerState(+ initialHour = hour ?: 12,+ initialMinute = minute ?: 0,+ )+ AlertDialog(+ onDismissRequest = { showTimePicker = false },+ confirmButton = {+ Button(+ onClick = {+ hour = pickerState.hour+ minute = pickerState.minute+ showTimePicker = false+ },+ ) {+ Text(stringResource(UiR.string.ok))+ }+ },+ dismissButton = {+ Button(onClick = { showTimePicker = false }) {+ Text(stringResource(UiR.string.cancel))+ }+ },+ properties = DialogProperties(usePlatformDefaultWidth = false),+ text = { TimePicker(pickerState) },+ ) } }
findfamily/src/main/java/com/vayunmathur/findfamily/ui/dialogs/SecurityCodeDialog.kt
diff --git a/findfamily/src/main/java/com/vayunmathur/findfamily/ui/dialogs/SecurityCodeDialog.kt b/findfamily/src/main/java/com/vayunmathur/findfamily/ui/dialogs/SecurityCodeDialog.ktindex 0652250d15..5a9a8f6dca 100644--- a/findfamily/src/main/java/com/vayunmathur/findfamily/ui/dialogs/SecurityCodeDialog.kt+++ b/findfamily/src/main/java/com/vayunmathur/findfamily/ui/dialogs/SecurityCodeDialog.kt@@ -35,16 +35,22 @@ fun SecurityCodeDialog(user: User, ffViewModel: FindFamilyViewModel, onDismiss: code = ffViewModel.securityCodeFor(user) loading = false }+ SecurityCodeContent(userName = user.name, code = code, loading = loading, onDismiss = onDismiss)+}++/** Stateless security-code dialog content: the route entry supplies the computed code. */+@Composable+internal fun SecurityCodeContent(userName: String, code: String?, loading: Boolean, onDismiss: () -> Unit) { AlertDialog( onDismissRequest = onDismiss, title = { Text(stringResource(R.string.security_code)) }, text = { Column {- Text(stringResource(R.string.compare_this_code_with_on_their_device_i, user.name))+ Text(stringResource(R.string.compare_this_code_with_on_their_device_i, userName)) Spacer(Modifier.height(16.dp)) when { loading -> Text(stringResource(R.string.computing))- code == null -> Text(stringResource(R.string.couldn_t_compute_yet_s_key_isn_t_availab, user.name))+ code == null -> Text(stringResource(R.string.couldn_t_compute_yet_s_key_isn_t_availab, userName)) else -> Text( code!!, style = MaterialTheme.typography.titleLarge,
findfamily/src/screenshotTest/kotlin/com/vayunmathur/findfamily/ui/MetadataPreviews.kt
diff --git a/findfamily/src/screenshotTest/kotlin/com/vayunmathur/findfamily/ui/MetadataPreviews.kt b/findfamily/src/screenshotTest/kotlin/com/vayunmathur/findfamily/ui/MetadataPreviews.ktindex f41bb932b6..16c29d69ef 100644--- a/findfamily/src/screenshotTest/kotlin/com/vayunmathur/findfamily/ui/MetadataPreviews.kt+++ b/findfamily/src/screenshotTest/kotlin/com/vayunmathur/findfamily/ui/MetadataPreviews.kt@@ -33,8 +33,22 @@ import com.vayunmathur.findfamily.platform.PersonUiState import com.vayunmathur.findfamily.platform.UwbSessionManager import com.vayunmathur.findfamily.platform.RangingSample import com.vayunmathur.library.ui.DynamicTheme-import kotlin.time.Duration.Companion.minutes+import androidx.compose.runtime.CompositionLocalProvider+import com.vayunmathur.findfamily.Route+import com.vayunmathur.findfamily.domain.FirstRunStage+import com.vayunmathur.findfamily.ui.dialogs.AddLinkContent+import com.vayunmathur.findfamily.ui.dialogs.AddPersonContent+import com.vayunmathur.findfamily.ui.dialogs.AddTrackerContent+import com.vayunmathur.findfamily.ui.dialogs.NoShowAlertContent+import com.vayunmathur.findfamily.ui.dialogs.SecurityCodeContent+import com.vayunmathur.library.ui.ConfirmDialog+import com.vayunmathur.library.ui.dialog.DatePickerDialog+import com.vayunmathur.library.util.LocalNavResultRegistry+import com.vayunmathur.library.util.NavResultRegistry+import com.vayunmathur.library.util.rememberNavBackStack import kotlin.time.Instant+import kotlinx.datetime.LocalDate+import kotlin.time.Duration.Companion.minutes /** Phone-shaped, roughly 1080x2340 at xxhdpi — comfortably above the F-Droid minimum. */ private const val PHONE = "spec:width=411dp,height=891dp,dpi=420"@@ -42,9 +56,6 @@ private const val PHONE = "spec:width=411dp,height=891dp,dpi=420" /** Expanded desktop window for the wide side-panel layout. */ private const val EXPANDED = "spec:width=1280dp,height=800dp,dpi=420" -/** Fixed fixture instant: 2026-01-17T12:00:00Z. */-private const val FIXED_NOW_EPOCH_MS = 1_768_651_200_000L- /** * Store listing images for `:findfamily`. See `common-conventions-preview-metadata`. *@@ -62,10 +73,9 @@ private const val FIXED_NOW_EPOCH_MS = 1_768_651_200_000L */ class MetadataPreviews { - // Sample timestamps are relative to a fixed instant so the fixture is- // deterministic (FixtureDeterminism lint): "5 minutes ago" / "in 45- // minutes" are offsets from FIXED_NOW, never from the wall clock.- private val now = Instant.fromEpochMilliseconds(FIXED_NOW_EPOCH_MS)+ // Fixed render instant so every fixture is deterministic; UserCard formats+ // relative ages against its own clock, so ages read as fixed offsets from this.+ private val now = Instant.parse("2026-02-13T17:41:09Z") private fun person( id: Long,@@ -189,7 +199,7 @@ class MetadataPreviews { } @PreviewTest- @Preview(name = "1-family", device = PHONE, group = "phone", showSystemUi = true)+ @Preview(name = "1-main-page", device = PHONE, group = "phone", showSystemUi = true) @Composable fun Preview1Family() { DynamicTheme(darkTheme = true) {@@ -203,7 +213,7 @@ class MetadataPreviews { } @PreviewTest- @Preview(name = "2-person", device = PHONE, group = "phone", showSystemUi = true)+ @Preview(name = "2-person-sheet", device = PHONE, group = "phone", showSystemUi = true) @Composable fun Preview2Person() { DynamicTheme(darkTheme = true) {@@ -220,7 +230,7 @@ class MetadataPreviews { } @PreviewTest- @Preview(name = "3-find-nearby", device = PHONE, group = "phone", showSystemUi = true)+ @Preview(name = "3-uwb-ranging-page", device = PHONE, group = "phone", showSystemUi = true) @Composable fun Preview3FindNearby() { DynamicTheme(darkTheme = true) {@@ -252,4 +262,160 @@ class MetadataPreviews { ) } }++ @PreviewTest+ @Preview(name = "5-first-run-sheet", device = PHONE, group = "phone", showSystemUi = true)+ @Composable+ fun Preview5FirstRunSheet() {+ DynamicTheme(darkTheme = true) {+ FirstRunSheetContent(+ stage = FirstRunStage.PairFamily,+ onLater = {},+ onAddPerson = {},+ onEnableLocation = {},+ onDone = {},+ )+ }+ }++ @PreviewTest+ @Preview(name = "6-waypoint-sheet", device = PHONE, group = "phone", showSystemUi = true)+ @Composable+ fun Preview6WaypointSheet() {+ DynamicTheme(darkTheme = true) {+ WaypointSheetContent(+ name = "Home",+ range = "150",+ showDelete = true,+ onNameChange = {},+ onRangeChange = {},+ onCancel = {},+ onSave = {},+ onDelete = {},+ )+ }+ }++ @PreviewTest+ @Preview(name = "7-user-page-history-date-picker", device = PHONE, group = "phone", showSystemUi = true)+ @Composable+ fun Preview7HistoryDatePicker() {+ DynamicTheme(darkTheme = true) {+ CompositionLocalProvider(LocalNavResultRegistry provides remember { NavResultRegistry() }) {+ DatePickerDialog(+ backStack = rememberNavBackStack<Route>(+ Route.MainPage,+ Route.UserPageHistoryDatePicker(LocalDate(2026, 2, 13)),+ ),+ resultKey = "HistoryDatePicker",+ initialDate = LocalDate(2026, 2, 13),+ maxDate = LocalDate(2026, 2, 13),+ )+ }+ }+ }++ @PreviewTest+ @Preview(name = "8-add-person-dialog", device = PHONE, group = "phone", showSystemUi = true)+ @Composable+ fun Preview8AddPersonDialog() {+ DynamicTheme(darkTheme = true) {+ AddPersonContent(+ myId = "ABCXYZ",+ userid = "DEFGHI",+ contactName = "Maya Chen",+ userStatus = null,+ inviteReadOnly = false,+ onUseridChange = {},+ onCopyMyId = {},+ onShareInvite = {},+ onPickContact = {},+ onConnect = {},+ )+ }+ }++ @PreviewTest+ @Preview(name = "9-add-link-dialog", device = PHONE, group = "phone", showSystemUi = true)+ @Composable+ fun Preview9AddLinkDialog() {+ DynamicTheme(darkTheme = true) {+ AddLinkContent(+ name = "Dog walker",+ expiryTime = "15 minutes",+ expiryOptions = listOf("15 minutes", "1 hour", "1 day"),+ failed = false,+ onNameChange = {},+ onExpiryChange = {},+ onCreate = {},+ )+ }+ }++ @PreviewTest+ @Preview(name = "10-add-tracker-dialog", device = PHONE, group = "phone", showSystemUi = true)+ @Composable+ fun Preview10AddTrackerDialog() {+ DynamicTheme(darkTheme = true) {+ AddTrackerContent(+ name = "Bike tracker",+ deviceLabels = emptyList(),+ binding = false,+ failed = false,+ onNameChange = {},+ onDeviceClick = {},+ onCancel = {},+ )+ }+ }++ @PreviewTest+ @Preview(name = "11-missing-features-dialog", device = PHONE, group = "phone", showSystemUi = true)+ @Composable+ fun Preview11MissingFeaturesDialog() {+ DynamicTheme(darkTheme = true) {+ MissingFeaturesDialog(+ rememberNavBackStack<Route>(Route.MainPage, Route.MissingFeaturesDialog),+ )+ }+ }++ @PreviewTest+ @Preview(name = "12-security-code-dialog", device = PHONE, group = "phone", showSystemUi = true)+ @Composable+ fun Preview12SecurityCodeDialog() {+ DynamicTheme(darkTheme = true) {+ SecurityCodeContent(userName = "Maya Chen", code = "123 456 789", loading = false, onDismiss = {})+ }+ }++ @PreviewTest+ @Preview(name = "13-no-show-alert-dialog", device = PHONE, group = "phone", showSystemUi = true)+ @Composable+ fun Preview13NoShowAlertDialog() {+ DynamicTheme(darkTheme = true) {+ NoShowAlertContent(+ user = maya,+ waypoints = sampleWaypoints,+ actions = PersonActions.Noop,+ onDismiss = {},+ )+ }+ }++ @PreviewTest+ @Preview(name = "14-permission-upgrade-dialog", device = PHONE, group = "phone", showSystemUi = true)+ @Composable+ fun Preview14PermissionUpgradeDialog() {+ DynamicTheme(darkTheme = true) {+ ConfirmDialog(+ title = "Precise location needed",+ message = "Approximate location is on. Upgrade to precise so family can find you accurately.",+ confirmLabel = "Upgrade",+ dismissLabel = "Not now",+ onConfirm = {},+ onDismiss = {},+ )+ }+ } }
findfamily/src/test/java/com/vayunmathur/findfamily/Y3FinalReportTest.kt
diff --git a/findfamily/src/test/java/com/vayunmathur/findfamily/Y3FinalReportTest.kt b/findfamily/src/test/java/com/vayunmathur/findfamily/Y3FinalReportTest.ktindex 2f210d6ad6..800c41deaa 100644--- a/findfamily/src/test/java/com/vayunmathur/findfamily/Y3FinalReportTest.kt+++ b/findfamily/src/test/java/com/vayunmathur/findfamily/Y3FinalReportTest.kt@@ -32,6 +32,9 @@ import kotlin.test.assertEquals import kotlin.test.assertFalse import kotlin.test.assertTrue +/** Fixed fixture instant (2026-02-13) so fixtures never read the wall clock. */+private val FIXED_NOW = kotlin.time.Instant.parse("2026-02-13T17:41:09Z")+ @OptIn(ExperimentalCoroutinesApi::class) @RunWith(RobolectricTestRunner::class) @Config(sdk = [34])@@ -47,7 +50,7 @@ class Y3FinalReportTest { private fun fix(): Location = Location("gps").apply { latitude = 37.7749; longitude = -122.4194; accuracy = 5f; speed = 3f- time = System.currentTimeMillis(); elapsedRealtimeNanos = android.os.SystemClock.elapsedRealtimeNanos()+ time = FIXED_NOW.toEpochMilliseconds(); elapsedRealtimeNanos = android.os.SystemClock.elapsedRealtimeNanos() } private fun broadcast(action: String) {@@ -108,7 +111,7 @@ class Y3FinalReportTest { if (Networking.userid == 0L) Networking.init(repo, DataStoreUtils.getInstance(ctx), "Me") assertTrue(Networking.userid != 0L) val code = Networking.securityCodePqc(- com.vayunmathur.findfamily.data.User("Peer", null, "Place", false, com.vayunmathur.findfamily.data.RequestStatus.MUTUAL_CONNECTION, kotlin.time.Clock.System.now(), null, 4242L),+ com.vayunmathur.findfamily.data.User("Peer", null, "Place", false, com.vayunmathur.findfamily.data.RequestStatus.MUTUAL_CONNECTION, FIXED_NOW, null, 4242L), ) // No cached PQC bundle for this peer: no code, no crash. assertTrue(code == null || code.isNotBlank())
findfamily/src/test/java/com/vayunmathur/findfamily/Y3PlatformBitsTest.kt
diff --git a/findfamily/src/test/java/com/vayunmathur/findfamily/Y3PlatformBitsTest.kt b/findfamily/src/test/java/com/vayunmathur/findfamily/Y3PlatformBitsTest.ktindex 9e30d19bb2..ec2f9ee496 100644--- a/findfamily/src/test/java/com/vayunmathur/findfamily/Y3PlatformBitsTest.kt+++ b/findfamily/src/test/java/com/vayunmathur/findfamily/Y3PlatformBitsTest.kt@@ -25,6 +25,9 @@ import kotlin.test.assertEquals import kotlin.test.assertNotNull import kotlin.test.assertTrue +/** Fixed fixture instant (2026-02-13) so fixtures never read the wall clock. */+private val FIXED_NOW = kotlin.time.Instant.parse("2026-02-13T17:41:09Z")+ @OptIn(ExperimentalCoroutinesApi::class) @RunWith(RobolectricTestRunner::class) @Config(sdk = [34])@@ -72,7 +75,7 @@ class Y3PlatformBitsTest { @Test fun noShowSchedulerEnqueuesAndCancels() { val alert = com.vayunmathur.findfamily.data.NoShowAlert( watchedUserId = 7L, waypointId = 3L,- expectedAt = kotlin.time.Clock.System.now() + kotlin.time.Duration.Companion.parse("24h"),+ expectedAt = FIXED_NOW + kotlin.time.Duration.Companion.parse("24h"), grace = kotlin.time.Duration.Companion.parse("30m"), ) NoShowCheckScheduler.schedule(ctx, alert)
findfamily/src/test/java/com/vayunmathur/findfamily/data/FindFamilyRepositoryStoresTest.kt
diff --git a/findfamily/src/test/java/com/vayunmathur/findfamily/data/FindFamilyRepositoryStoresTest.kt b/findfamily/src/test/java/com/vayunmathur/findfamily/data/FindFamilyRepositoryStoresTest.ktindex e74a96ca2c..d8eba3e279 100644--- a/findfamily/src/test/java/com/vayunmathur/findfamily/data/FindFamilyRepositoryStoresTest.kt+++ b/findfamily/src/test/java/com/vayunmathur/findfamily/data/FindFamilyRepositoryStoresTest.kt@@ -17,6 +17,9 @@ import kotlin.time.Clock import kotlin.time.Duration.Companion.minutes import kotlin.time.Instant +/** Fixed fixture instant (2026-02-13) so fixtures never read the wall clock. */+private val FIXED_NOW = kotlin.time.Instant.parse("2026-02-13T17:41:09Z")+ /** Repository stores (links, no-show alerts, auto-toggles, history sweep) over real Room. */ @RunWith(AndroidJUnit4::class) class FindFamilyRepositoryStoresTest {@@ -28,7 +31,7 @@ class FindFamilyRepositoryStoresTest { private fun user(name: String, enabled: Boolean = true) = User( name = name, photo = null, locationName = "Home", sendingEnabled = enabled,- requestStatus = RequestStatus.MUTUAL_CONNECTION, lastLocationChangeTime = Clock.System.now(),+ requestStatus = RequestStatus.MUTUAL_CONNECTION, lastLocationChangeTime = FIXED_NOW, ) private fun fix(userid: Long, at: Long, source: LocationSource = LocationSource.LIVE) = LocationValue(@@ -42,7 +45,7 @@ class FindFamilyRepositoryStoresTest { } @Test fun temporaryLinkStoreCrudAndFlow() = runTest {- val link = TemporaryLink(name = "Trip", deleteAt = Clock.System.now(), pqcPublicKey = "bundle", id = 77L)+ val link = TemporaryLink(name = "Trip", deleteAt = FIXED_NOW, pqcPublicKey = "bundle", id = 77L) assertEquals(77L, repo.temporaryLinkStore.upsert(link)) assertEquals(listOf("Trip"), repo.temporaryLinkStore.getAll().map { it.name }) assertEquals(listOf(77L), repo.temporaryLinks.first().map { it.id })@@ -53,7 +56,7 @@ class FindFamilyRepositoryStoresTest { @Test fun noShowStoreDueMarkFiredAndRearm() = runTest { val uid = repo.upsertUser(user("Alice"))- val now = Clock.System.now()+ val now = FIXED_NOW val dueId = repo.noShowAlertStore.upsert( NoShowAlert(watchedUserId = uid, waypointId = null, expectedAt = now, grace = 1.minutes, oneShot = false) )
findfamily/src/test/java/com/vayunmathur/findfamily/data/FindFamilyRepositoryTest.kt
diff --git a/findfamily/src/test/java/com/vayunmathur/findfamily/data/FindFamilyRepositoryTest.kt b/findfamily/src/test/java/com/vayunmathur/findfamily/data/FindFamilyRepositoryTest.ktindex 21429d1549..2e76b93796 100644--- a/findfamily/src/test/java/com/vayunmathur/findfamily/data/FindFamilyRepositoryTest.kt+++ b/findfamily/src/test/java/com/vayunmathur/findfamily/data/FindFamilyRepositoryTest.kt@@ -19,6 +19,9 @@ import kotlin.time.Clock import kotlin.time.Duration.Companion.minutes import kotlin.time.Instant +/** Fixed fixture instant (2026-02-13) so fixtures never read the wall clock. */+private val FIXED_NOW = kotlin.time.Instant.parse("2026-02-13T17:41:09Z")+ @RunWith(AndroidJUnit4::class) class FindFamilyRepositoryTest { @@ -36,7 +39,7 @@ class FindFamilyRepositoryTest { private fun user(name: String = "alice", status: RequestStatus = RequestStatus.MUTUAL_CONNECTION) = User( name = name, photo = null, locationName = "Home", sendingEnabled = true,- requestStatus = status, lastLocationChangeTime = Clock.System.now(),+ requestStatus = status, lastLocationChangeTime = FIXED_NOW, ) private fun fix(userid: Long, sentAt: Long) = LocationValue(@@ -65,10 +68,10 @@ class FindFamilyRepositoryTest { val other = repo.upsertUser(user(name = "bob")) repo.upsertLocations(listOf(fix(uid, 1000), fix(uid, 2000), fix(other, 1500))) repo.noShowAlertStore.upsert(- NoShowAlert(watchedUserId = uid, waypointId = null, expectedAt = Clock.System.now(), grace = 5.minutes)+ NoShowAlert(watchedUserId = uid, waypointId = null, expectedAt = FIXED_NOW, grace = 5.minutes) ) repo.noShowAlertStore.upsert(- NoShowAlert(watchedUserId = other, waypointId = null, expectedAt = Clock.System.now(), grace = 5.minutes)+ NoShowAlert(watchedUserId = other, waypointId = null, expectedAt = FIXED_NOW, grace = 5.minutes) ) assertEquals(1, repo.deleteUser(repo.getUser(uid)!!)) assertNull(repo.getUser(uid))@@ -85,10 +88,10 @@ class FindFamilyRepositoryTest { repo.setSharingAutoToggleWaypointId(uid, wpId) repo.updateLocationMeta(uid, "Home", wpId, 1234L) repo.noShowAlertStore.upsert(- NoShowAlert(watchedUserId = uid, waypointId = wpId, expectedAt = Clock.System.now(), grace = 5.minutes)+ NoShowAlert(watchedUserId = uid, waypointId = wpId, expectedAt = FIXED_NOW, grace = 5.minutes) ) repo.noShowAlertStore.upsert(- NoShowAlert(watchedUserId = uid, waypointId = otherWp, expectedAt = Clock.System.now(), grace = 5.minutes)+ NoShowAlert(watchedUserId = uid, waypointId = otherWp, expectedAt = FIXED_NOW, grace = 5.minutes) ) assertEquals(1, repo.waypointStore.delete(repo.waypointStore.get(wpId))) val row = repo.getUser(uid)!!@@ -164,7 +167,7 @@ class FindFamilyRepositoryTest { @Test fun temporaryLinkAndNoShowStores() = runTest {- val link = TemporaryLink(name = "Trip", deleteAt = Clock.System.now(), pqcPublicKey = "pub", pqcSeed = "seed")+ val link = TemporaryLink(name = "Trip", deleteAt = FIXED_NOW, pqcPublicKey = "pub", pqcSeed = "seed") val linkId = repo.temporaryLinkStore.upsert(link) assertTrue(linkId != 0L) assertEquals(1, repo.temporaryLinkStore.getAll().size)
findfamily/src/test/java/com/vayunmathur/findfamily/data/W5FindFamilyDatabaseTest.kt
diff --git a/findfamily/src/test/java/com/vayunmathur/findfamily/data/W5FindFamilyDatabaseTest.kt b/findfamily/src/test/java/com/vayunmathur/findfamily/data/W5FindFamilyDatabaseTest.ktindex c31f97e240..1499e98e73 100644--- a/findfamily/src/test/java/com/vayunmathur/findfamily/data/W5FindFamilyDatabaseTest.kt+++ b/findfamily/src/test/java/com/vayunmathur/findfamily/data/W5FindFamilyDatabaseTest.kt@@ -19,6 +19,9 @@ import kotlin.time.Duration.Companion.days import kotlin.time.Duration.Companion.minutes import kotlin.time.Instant +/** Fixed fixture instant (2026-02-13) so fixtures never read the wall clock. */+private val FIXED_NOW = kotlin.time.Instant.parse("2026-02-13T17:41:09Z")+ /** * Robolectric in-memory tests for the findfamily Room DAOs: user auto-toggle * atomics, [LocationValueDao.getLatest] ranking on `reportedAt` (not@@ -36,7 +39,7 @@ class W5FindFamilyDatabaseTest { locationName = "loc", sendingEnabled = true, requestStatus = RequestStatus.MUTUAL_CONNECTION,- lastLocationChangeTime = Clock.System.now(),+ lastLocationChangeTime = FIXED_NOW, id = id, ) @@ -220,7 +223,7 @@ class W5FindFamilyDatabaseTest { val link = TemporaryLink( name = "party",- deleteAt = Clock.System.now(),+ deleteAt = FIXED_NOW, pqcPublicKey = "pub", pqcSeed = "seed", )
findfamily/src/test/java/com/vayunmathur/findfamily/intents/AssistantIntentsRealRepoTest.kt
diff --git a/findfamily/src/test/java/com/vayunmathur/findfamily/intents/AssistantIntentsRealRepoTest.kt b/findfamily/src/test/java/com/vayunmathur/findfamily/intents/AssistantIntentsRealRepoTest.ktindex 2204645f96..ae897de41e 100644--- a/findfamily/src/test/java/com/vayunmathur/findfamily/intents/AssistantIntentsRealRepoTest.kt+++ b/findfamily/src/test/java/com/vayunmathur/findfamily/intents/AssistantIntentsRealRepoTest.kt@@ -29,6 +29,9 @@ import kotlin.test.assertNotNull import kotlin.test.assertTrue import kotlin.time.Clock +/** Fixed fixture instant (2026-02-13) so fixtures never read the wall clock. */+private val FIXED_NOW = kotlin.time.Instant.parse("2026-02-13T17:41:09Z")+ /** * Assistant intents launched as activities with a ResultReceiver channel: * [GetIntent] answers from the installed in-memory repository and@@ -78,15 +81,15 @@ class AssistantIntentsRealRepoTest { val repo = TestFindFamilyRepository.install(ctx) val alice = repo.upsertUser(User( name = "Alice", photo = null, locationName = "Home", sendingEnabled = true,- requestStatus = RequestStatus.MUTUAL_CONNECTION, lastLocationChangeTime = Clock.System.now(),+ requestStatus = RequestStatus.MUTUAL_CONNECTION, lastLocationChangeTime = FIXED_NOW, )) repo.upsertUser(User( name = "Bob", photo = null, locationName = "Office", sendingEnabled = true,- requestStatus = RequestStatus.MUTUAL_CONNECTION, lastLocationChangeTime = Clock.System.now(),+ requestStatus = RequestStatus.MUTUAL_CONNECTION, lastLocationChangeTime = FIXED_NOW, )) repo.upsertLocation(LocationValue( userid = alice, coord = Coord(37.5, -122.25), speed = 0f, acc = 5f,- timestamp = Clock.System.now(), battery = 50f, reportedAt = Clock.System.now(),+ timestamp = FIXED_NOW, battery = 50f, reportedAt = FIXED_NOW, source = LocationSource.LIVE, )) val capture = launch(GetIntent::class.java, Json.encodeToString(kotlinx.serialization.serializer<Unit>(), Unit))
findfamily/src/test/java/com/vayunmathur/findfamily/ui/W5PersonDetailSheetTest.kt
diff --git a/findfamily/src/test/java/com/vayunmathur/findfamily/ui/W5PersonDetailSheetTest.kt b/findfamily/src/test/java/com/vayunmathur/findfamily/ui/W5PersonDetailSheetTest.ktindex 5f8226858c..341929607e 100644--- a/findfamily/src/test/java/com/vayunmathur/findfamily/ui/W5PersonDetailSheetTest.kt+++ b/findfamily/src/test/java/com/vayunmathur/findfamily/ui/W5PersonDetailSheetTest.kt@@ -82,15 +82,17 @@ class W5PersonDetailSheetTest { } @Test- fun noShowButtonOpensDialog() {+ fun noShowButtonRequestsDialogRoute() {+ var requested = false rule.setContent { PersonDetailSheet( state = PersonUiState(user = user(1L)), actions = PersonActions.Noop,+ onShowNoShowAlert = { requested = true }, ) } rule.onNodeWithText("Watch for no-show", substring = true).performClick()- // The dialog opens with its date/time pickers unset.- rule.onNodeWithText("Pick date", substring = true).assertIsDisplayed()+ // The dialog is a route: the sheet only requests it, the host pushes it.+ assertTrue(requested) } }
library/ui/src/test/java/com/vayunmathur/library/ui/DropdownsSliceTest.kt
diff --git a/library/ui/src/test/java/com/vayunmathur/library/ui/DropdownsSliceTest.kt b/library/ui/src/test/java/com/vayunmathur/library/ui/DropdownsSliceTest.ktindex 89c0650c81..2f4721b0af 100644--- a/library/ui/src/test/java/com/vayunmathur/library/ui/DropdownsSliceTest.kt+++ b/library/ui/src/test/java/com/vayunmathur/library/ui/DropdownsSliceTest.kt@@ -1,4 +1,5 @@ package com.vayunmathur.library.ui+// FIXTURE RELATIVE-TIME EXCEPTION: date/time picker state is tested in now-mode against the real clock; nowPlus seeds relative to the SUT clock by design // FIXTURE RELATIVE-TIME EXCEPTION: the "must not be in the future" assertions compare the state under test, which reads the real wall clock in now-mode (HistoryScrubberState.goNow()/tickNow()), against now plus an execution-slack allowance; a fixed past instant would make the clamp assertions vacuous. import androidx.compose.ui.test.assertIsDisplayed