Modern Apps git

← Modern-Apps.git

appstore: uninstall dialogs are routes, add missing captures

Commit
5e684b0cc2752ccaab9a0568f74a251b2545f751
Author
Vayun Mathur <[email protected]>
When
2026-12-02 01:17 UTC (4 days ago)
Parents
d4f5738
DialogAsRoute (2): the phone detail screen and the TV detail
screen held showUninstallConfirm remember-state and rendered
ConfirmDialog/TvDialog in place. Route gains
UninstallDialog(packageName, appName) and TvStoreRoute gains the
same; both are DialogPage() entries rendering new stateless
contents under ui/dialogs/ (UninstallDialog, TvUninstallDialog),
pushed from the uninstall click, with the back-stack pop plus the
actual uninstall in the entry. AppDetailScreen/TvStoreDetailScreen
take onOpenUninstallDialog instead of holding dialog state.

RouteScreenshotCoverage (3 + 1 new): Sources had no stateless
slice, so SourcesPage is split into a ViewModel binder and a new
stateless SourcesScreen; Browse renders the existing stateless
BrowseScreen; Screenshots renders ScreenshotViewerScreen with
fixed listing URLs; the new UninstallDialog renders its content.
MetadataPreviews gains 7-sources, 8-browse, 9-screenshots and
10-uninstall-dialog, all with literal fixtures.

FixtureDeterminism (6 in own tests): CacheAndSettingsW5Test and
TvStoreUpdatesRichTest use named fixed epoch constants (the sweep
takes nowMs explicitly, so a fixed clock is exact). The three Play
restore/withApi tests carry the FIXTURE RELATIVE-TIME marker:
PlayRepository compares the persisted dispensed-at stamp against
the real wall clock (12h window), so a fixed stamp would exercise
the stale path instead of the paths under test.

Tests adapted to the route contract: AppDetailActionsFlowTest and
TvDetailBranchesW5Test assert the push request, then render the
dialog contents and confirm/dismiss them.

Verified: :appstore:lint green (0 errors);
:appstore:compileReleaseKotlin green;
:appstore:compileDevScreenshotTestKotlin green;
:appstore:testDevUnitTest 507 tests with only the pre-existing
flaky TvMainActivityTest rail wait failing under parallel load
(it passes in isolation). :appstore:lintVitalRelease reports
exactly one remaining error, in library/ui
DropdownsSliceTest.kt (a shared dependency test fixture outside
this module), with no appstore errors.

Diff

appstore/AGENTS.md
diff --git a/appstore/AGENTS.md b/appstore/AGENTS.mdindex ca25b6bbce..995086ee28 100644--- a/appstore/AGENTS.md+++ b/appstore/AGENTS.md@@ -4,8 +4,8 @@  _Install: ./install appstore (dev by default)._ - Gradle: :appstore / dir: appstore/-- Package roots present: ui, data, domain-- Entry files: MainActivity.kt (no Route.kt — home/library/search/sources/trust/updates pages flow)+- Package roots present: ui, data, domain, platform+- Entry files: MainActivity.kt, Route.kt (home/library/search/sources/trust/updates tabs + Detail/Browse/Screenshots/UninstallDialog pushed routes) - Deps: :library:room, :library:network, :library:work, :library:image - Metadata: metadata_data/appstore.md (present) - Rust: yes / screenshotTest: yes@@ -16,18 +16,18 @@ _Install: ./install appstore (dev by default)._ - Multi-source catalogs: F-Droid (reproducible-builds only), Accrescent (Signify trust), anonymous Play (no Google account), GrapheneOS bundle one-tap - Install pipeline: `InstallCoordinator` → `SessionInstaller` → `InstallStatusReceiver`, verified by `InstallVerifier` (APK certs, signed-jar index, source stamps) before the system installer sees anything - `UpdateCheckWorker` background checks; outdated-target-API apps refused, not hidden-**Architecture / data-flow:** `ui/` home/search/detail/library/updates/sources/trust → `util/AppStoreViewModel` (+ per-area `*Ops`, `AppStoreUiContract`) → `data/` providers per source (`*Repository`, Play/F-Droid/Accrescent clients) + `data/installer/` + `data/security/`; `domain/SearchRanking` is pure ranking.+**Architecture / data-flow:** `ui/` home/search/detail/library/updates/sources/trust (+ `ui/dialogs/` stateless dialog contents for the `Route.UninstallDialog` / TV `UninstallDialog` routes) → `platform/AppStoreViewModel` (+ per-area `*Ops`, `AppStoreUiContract`) → `data/` providers per source (`*Repository`, Play/F-Droid/Accrescent clients) + `data/installer/` + `data/security/`; `domain/SearchRanking` is pure ranking. **Repo addresses:** our own F-Droid-format repos are consumed from the static R2 bucket — `DefaultRepos.MODERN_APPS` = `https://static.maproj.org/fdroid/repo`, `DefaultRepos.PROPRIETARY` = `https://static.maproj.org/proprietary/repo` (same signed indexes/APKs the server publishes on every build; signing fingerprint pinned as before). The legacy origin addresses (`maproj.org/fdroid/repo`, `maproj.org/proprietary/repo`) keep serving external F-Droid clients and are named only as `LEGACY_*_ORIGIN_URL` constants: stored repo records and cached rows are keyed by URL, so `CatalogRepository.ensureDefaultRepos` prunes rows written under the old addresses and the next sync re-imports under the static ones (no double-added repos).-**Entry points + reading order:** `MainActivity.kt` → `ui/HomePage.kt` → `util/AppStoreViewModel.kt` → `data/CatalogRepository.kt` → `data/installer/InstallCoordinator.kt` → `data/security/InstallVerifier.kt`.+**Entry points + reading order:** `MainActivity.kt` → `Route.kt` → `ui/AppRoot.kt` → `ui/HomePage.kt` → `platform/AppStoreViewModel.kt` → `data/CatalogRepository.kt` → `data/installer/InstallCoordinator.kt` → `data/security/InstallVerifier.kt`. **Gotchas:**-- `util/` is NOT a closed package root — don't add more files there - Signature verification is the product — never shortcut it for UX; trust-profile changes need adversarial review - Anonymous Play auth sessions are fragile by nature; isolate Play failures from other sources - Upgrades from app versions before v2.6.0 start fresh: the `AppDatabase` floor is DB v3 (the first AppStore database shipped, in app v2.6.4, so no released pre-v2.6.0 database exists), pre-floor DB v1–v2 opens destructively (no data carried over), and DB v3 onward migrates normally  ## Key files-### Root — entry (no Route.kt)+### Root — entry - com/vayunmathur/appstore/MainActivity.kt+- com/vayunmathur/appstore/Route.kt ### data/ — catalog, providers, installer, security - com/vayunmathur/appstore/data/CatalogRepository.kt - com/vayunmathur/appstore/data/AppProvider.kt@@ -69,14 +69,14 @@ _Install: ./install appstore (dev by default)._ - com/vayunmathur/appstore/data/RestrictedPackages.kt ### domain/ — pure ranking (no Android) - com/vayunmathur/appstore/domain/SearchRanking.kt-### util/ — ViewModel + per-area ops-- com/vayunmathur/appstore/util/AppStoreViewModel.kt-- com/vayunmathur/appstore/util/AppStoreUiContract.kt-- com/vayunmathur/appstore/util/AppStoreHomeOps.kt-- com/vayunmathur/appstore/util/AppStoreSearchOps.kt-- com/vayunmathur/appstore/util/AppStoreDetailOps.kt-- com/vayunmathur/appstore/util/AppStoreUpdateOps.kt-- com/vayunmathur/appstore/util/AppStoreActionOps.kt+### platform/ — ViewModel + per-area ops+- com/vayunmathur/appstore/platform/AppStoreViewModel.kt+- com/vayunmathur/appstore/platform/AppStoreUiContract.kt+- com/vayunmathur/appstore/platform/AppStoreHomeOps.kt+- com/vayunmathur/appstore/platform/AppStoreSearchOps.kt+- com/vayunmathur/appstore/platform/AppStoreDetailOps.kt+- com/vayunmathur/appstore/platform/AppStoreUpdateOps.kt+- com/vayunmathur/appstore/platform/AppStoreActionOps.kt ### ui/ — store pages - com/vayunmathur/appstore/ui/HomePage.kt - com/vayunmathur/appstore/ui/SearchPage.kt@@ -90,7 +90,10 @@ _Install: ./install appstore (dev by default)._ - com/vayunmathur/appstore/ui/LibraryPage.kt - com/vayunmathur/appstore/ui/UpdatesPage.kt - com/vayunmathur/appstore/ui/SourcesPage.kt+- com/vayunmathur/appstore/ui/SourcesScreen.kt — stateless sources screen (previews/tests) - com/vayunmathur/appstore/ui/TrustPage.kt+- com/vayunmathur/appstore/ui/dialogs/UninstallDialog.kt — `Route.UninstallDialog` content+- com/vayunmathur/appstore/ui/dialogs/TvUninstallDialog.kt — TV `UninstallDialog` content  ## Verify (this module only) ```
appstore/src/main/java/com/vayunmathur/appstore/Route.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/Route.kt b/appstore/src/main/java/com/vayunmathur/appstore/Route.ktindex 2f05490af7..0053910031 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/Route.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/Route.kt@@ -29,6 +29,10 @@ sealed interface Route : NavKey {      */     @Serializable     data class Screenshots(val appName: String, val urls: List<String>, val index: Int) : Route++    /** Uninstall confirmation dialog for the app named by [packageName]. */+    @Serializable+    data class UninstallDialog(val packageName: String, val appName: String) : Route }  /**
appstore/src/main/java/com/vayunmathur/appstore/ui/AppDetailPage.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/ui/AppDetailPage.kt b/appstore/src/main/java/com/vayunmathur/appstore/ui/AppDetailPage.ktindex 20d21d3da7..39cbf3f49a 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/ui/AppDetailPage.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/ui/AppDetailPage.kt@@ -39,6 +39,7 @@ fun AppDetailPage(     onBack: () -> Unit,     onOpenTrust: () -> Unit = {},     onOpenScreenshot: (Int) -> Unit = {},+    onOpenUninstallDialog: () -> Unit = {}, ) {     LaunchedEffect(packageName) { viewModel.loadDetail(packageName) }     val state by viewModel.detail.collectAsState()@@ -48,6 +49,7 @@ fun AppDetailPage(         onBack = onBack,         onOpenTrust = onOpenTrust,         onOpenScreenshot = onOpenScreenshot,+        onOpenUninstallDialog = onOpenUninstallDialog,     ) } 
appstore/src/main/java/com/vayunmathur/appstore/ui/AppDetailScreen.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/ui/AppDetailScreen.kt b/appstore/src/main/java/com/vayunmathur/appstore/ui/AppDetailScreen.ktindex 20b28e834d..33a8c5357b 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/ui/AppDetailScreen.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/ui/AppDetailScreen.kt@@ -14,20 +14,14 @@ 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.res.stringResource import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import com.vayunmathur.appstore.platform.AppStoreViewModel import com.vayunmathur.library.ui.AppBarAlignment import com.vayunmathur.library.ui.AppScaffold-import com.vayunmathur.library.ui.ConfirmDialog import com.vayunmathur.library.ui.IconButton import com.vayunmathur.library.ui.IconShare-import com.vayunmathur.library.ui.R as UiR import com.vayunmathur.library.ui.Text  /**@@ -48,9 +42,10 @@ fun AppDetailScreen(     onOpenTrust: () -> Unit = {},     /** Opens the full-screen viewer at this index into `app.screenshots` (#918). */     onOpenScreenshot: (Int) -> Unit = {},+    /** Pushes the uninstall confirmation dialog route for the shown app. */+    onOpenUninstallDialog: () -> Unit = {}, ) {     val app = state.app ?: return-    var showUninstallConfirm by remember { mutableStateOf(false) }      AppScaffold(         title = { Text(app.name, maxLines = 1, overflow = TextOverflow.Ellipsis) },@@ -70,7 +65,7 @@ fun AppDetailScreen(             verticalArrangement = Arrangement.spacedBy(16.dp),         ) {             AppDetailHeader(state)-            AppInstallActions(state, actions, onUninstall = { showUninstallConfirm = true })+            AppInstallActions(state, actions, onUninstall = onOpenUninstallDialog)             AppWearSection(state, actions)             if (app.screenshots.isNotEmpty()) {                 AppScreenshotStrip(app.screenshots, app.name, onOpen = onOpenScreenshot)@@ -85,15 +80,4 @@ fun AppDetailScreen(         }     } -    if (showUninstallConfirm) {-        ConfirmDialog(-            title = stringResource(R.string.uninstall_3, app.name),-            message = stringResource(R.string.this_will_uninstall_you_can_reinstall_la, app.packageName),-            confirmLabel = stringResource(R.string.uninstall),-            dismissLabel = stringResource(UiR.string.cancel),-            onConfirm = { actions.uninstallApp(app.packageName) },-            onDismiss = { showUninstallConfirm = false },-            destructive = true,-        )-    } }
appstore/src/main/java/com/vayunmathur/appstore/ui/AppRoot.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/ui/AppRoot.kt b/appstore/src/main/java/com/vayunmathur/appstore/ui/AppRoot.ktindex 7c54b6d0f0..4215a0182b 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/ui/AppRoot.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/ui/AppRoot.kt@@ -17,6 +17,7 @@ import com.vayunmathur.appstore.ui.SearchPage import com.vayunmathur.appstore.ui.SourcesPage import com.vayunmathur.appstore.ui.TrustPage import com.vayunmathur.appstore.ui.UpdatesPage+import com.vayunmathur.appstore.ui.dialogs.UninstallDialog import com.vayunmathur.appstore.platform.AppStoreViewModel import com.vayunmathur.library.ui.IconDownload import com.vayunmathur.library.ui.IconHome@@ -25,6 +26,7 @@ import com.vayunmathur.library.ui.IconProvider import com.vayunmathur.library.ui.IconSearch import com.vayunmathur.library.ui.RouteTab import com.vayunmathur.library.ui.TabbedPagerScaffold+import com.vayunmathur.library.util.DialogPage import com.vayunmathur.library.util.MainNavigation import com.vayunmathur.library.util.MorphPage import com.vayunmathur.library.util.NavBackStack@@ -151,6 +153,23 @@ private fun AppTabs(                             backStack.add(Route.Screenshots(app.name, app.screenshots, index))                         }                     },+                    onOpenUninstallDialog = {+                        val app = viewModel.detail.value.app+                        if (app != null) {+                            backStack.add(Route.UninstallDialog(app.packageName, app.name))+                        }+                    },+                )+            }+            entry<Route.UninstallDialog>(metadata = DialogPage()) { route ->+                UninstallDialog(+                    appName = route.appName,+                    packageName = route.packageName,+                    onConfirm = {+                        backStack.pop()+                        viewModel.uninstallApp(route.packageName)+                    },+                    onDismiss = { backStack.pop() },                 )             }             entry<Route.Screenshots> { route ->
appstore/src/main/java/com/vayunmathur/appstore/ui/SourcesPage.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/ui/SourcesPage.kt b/appstore/src/main/java/com/vayunmathur/appstore/ui/SourcesPage.ktindex 695c3e0766..27a1090f62 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/ui/SourcesPage.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/ui/SourcesPage.kt@@ -1,42 +1,12 @@ package com.vayunmathur.appstore.ui-import com.vayunmathur.appstore.R-import com.vayunmathur.library.ui.Scaffold -import androidx.compose.foundation.layout.Arrangement-import androidx.compose.foundation.layout.Column-import androidx.compose.foundation.layout.Row-import androidx.compose.foundation.layout.fillMaxSize-import androidx.compose.foundation.layout.fillMaxWidth-import androidx.compose.foundation.layout.padding-import androidx.compose.foundation.rememberScrollState-import androidx.compose.foundation.verticalScroll import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue-import androidx.compose.ui.Alignment-import androidx.compose.ui.Modifier-import androidx.compose.ui.res.stringResource-import androidx.compose.ui.text.font.FontWeight-import androidx.compose.ui.unit.dp-import com.vayunmathur.appstore.data.AppSource-import com.vayunmathur.appstore.data.DefaultRepos-import com.vayunmathur.appstore.data.ModernAppsRepo-import com.vayunmathur.appstore.data.accrescent.AccrescentRepo import com.vayunmathur.appstore.platform.AppStoreViewModel-import com.vayunmathur.library.ui.Card-import com.vayunmathur.library.ui.MaterialTheme-import com.vayunmathur.library.ui.OutlinedButton-import com.vayunmathur.library.ui.AppScaffold-import com.vayunmathur.library.ui.SettingsSwitchRow-import com.vayunmathur.library.ui.Switch-import com.vayunmathur.library.ui.Text -/**- * Which sources the store talks to at all.- *- * The source list is fixed — see [DefaultRepos] for why nothing can be added to it.- */+/** Binds [AppStoreViewModel] to the stateless [SourcesScreen]. */ @Composable fun SourcesPage(     viewModel: AppStoreViewModel,@@ -46,116 +16,18 @@ fun SourcesPage(     val autoInstallUpdates by viewModel.autoInstallUpdates.collectAsState()     val enabledSources by viewModel.enabledSources.collectAsState()     val updateCheckStatus by viewModel.updateCheckStatus.collectAsState()-    val noneEnabled = AppSource.TOGGLEABLE.none { it in enabledSources }      // WorkManager state and the OS restriction flag are reads, not flows — pull     // them every time the screen appears rather than polling for them.     LaunchedEffect(Unit) { viewModel.refreshUpdateCheckStatus() } -    AppScaffold(topBar = {}) { padding ->-        Column(-            Modifier-                .fillMaxSize()-                .padding(padding)-                .padding(horizontal = 16.dp)-                .padding(bottom = 24.dp)-                .verticalScroll(rememberScrollState()),-            verticalArrangement = Arrangement.spacedBy(12.dp),-        ) {-            OutlinedButton(onClick = onOpenTrust, modifier = Modifier.fillMaxWidth()) {-                Text(stringResource(R.string.trust_page_title))-            }-            if (noneEnabled) {-                Text(-                    stringResource(R.string.sources_all_disabled),-                    style = MaterialTheme.typography.labelSmall,-                    color = MaterialTheme.colorScheme.error,-                )-            }-            if (home.statusMessage.isNotBlank()) {-                Text(-                    home.statusMessage,-                    style = MaterialTheme.typography.labelSmall,-                    color = MaterialTheme.colorScheme.secondary,-                )-            }--            Card(Modifier.fillMaxWidth()) {-                SettingsSwitchRow(-                    title = stringResource(R.string.setting_auto_install_updates_title),-                    supportingText = stringResource(R.string.setting_auto_install_updates_summary),-                    checked = autoInstallUpdates,-                    onCheckedChange = { viewModel.setAutoInstallUpdates(it) },-                )-            }--            UpdateCheckStatusCard(status = updateCheckStatus)--            SourceCard(-                title = stringResource(R.string.source_modern_apps),-                subtitle = ModernAppsRepo.PROJECT_URL,-                enabled = AppSource.MODERN_APPS in enabledSources,-                onEnabledChange = { viewModel.setSourceEnabled(AppSource.MODERN_APPS, it) },-            )-            SourceCard(-                title = stringResource(R.string.source_chip_fdroid),-                subtitle = DefaultRepos.FDROID.url,-                enabled = AppSource.FDROID in enabledSources,-                onEnabledChange = { viewModel.setSourceEnabled(AppSource.FDROID, it) },-            )-            SourceCard(-                title = stringResource(R.string.source_chip_izzy),-                subtitle = DefaultRepos.IZZY.url,-                enabled = AppSource.IZZY in enabledSources,-                onEnabledChange = { viewModel.setSourceEnabled(AppSource.IZZY, it) },-            )-            SourceCard(-                title = stringResource(R.string.source_chip_proprietary),-                subtitle = DefaultRepos.PROPRIETARY.url,-                enabled = AppSource.PROPRIETARY in enabledSources,-                onEnabledChange = { viewModel.setSourceEnabled(AppSource.PROPRIETARY, it) },-            )-            SourceCard(-                title = stringResource(R.string.source_play),-                subtitle = "play.google.com",-                enabled = AppSource.PLAYSTORE in enabledSources,-                onEnabledChange = { viewModel.setSourceEnabled(AppSource.PLAYSTORE, it) },-            )-            SourceCard(-                title = stringResource(R.string.source_chip_accrescent),-                subtitle = AccrescentRepo.REPOSITORY_URL,-                enabled = AppSource.ACCRESCENT in enabledSources,-                onEnabledChange = { viewModel.setSourceEnabled(AppSource.ACCRESCENT, it) },-            )-        }-    }-}--@Composable-private fun SourceCard(-    title: String,-    subtitle: String,-    enabled: Boolean,-    onEnabledChange: (Boolean) -> Unit,-) {-    Card(Modifier.fillMaxWidth()) {-        Row(-            Modifier.fillMaxWidth().padding(16.dp),-            verticalAlignment = Alignment.CenterVertically,-        ) {-            Column(Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(2.dp)) {-                Text(-                    title,-                    style = MaterialTheme.typography.titleSmall,-                    fontWeight = FontWeight.SemiBold,-                )-                Text(-                    subtitle,-                    style = MaterialTheme.typography.labelSmall,-                    color = MaterialTheme.colorScheme.onSurfaceVariant,-                )-            }-            Switch(checked = enabled, onCheckedChange = onEnabledChange)-        }-    }+    SourcesScreen(+        statusMessage = home.statusMessage,+        autoInstallUpdates = autoInstallUpdates,+        enabledSources = enabledSources,+        updateCheckStatus = updateCheckStatus,+        onOpenTrust = onOpenTrust,+        onAutoInstallUpdatesChange = { viewModel.setAutoInstallUpdates(it) },+        onSourceEnabledChange = { source, enabled -> viewModel.setSourceEnabled(source, enabled) },+    ) }
appstore/src/main/java/com/vayunmathur/appstore/ui/SourcesScreen.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/ui/SourcesScreen.kt b/appstore/src/main/java/com/vayunmathur/appstore/ui/SourcesScreen.ktnew file mode 100644index 0000000000..85abf3403e--- /dev/null+++ b/appstore/src/main/java/com/vayunmathur/appstore/ui/SourcesScreen.kt@@ -0,0 +1,149 @@+package com.vayunmathur.appstore.ui++import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.Row+import androidx.compose.foundation.layout.fillMaxSize+import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.rememberScrollState+import androidx.compose.foundation.verticalScroll+import androidx.compose.runtime.Composable+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.res.stringResource+import androidx.compose.ui.text.font.FontWeight+import androidx.compose.ui.unit.dp+import com.vayunmathur.appstore.R+import com.vayunmathur.appstore.data.AppSource+import com.vayunmathur.appstore.data.DefaultRepos+import com.vayunmathur.appstore.data.ModernAppsRepo+import com.vayunmathur.appstore.data.accrescent.AccrescentRepo+import com.vayunmathur.appstore.platform.UpdateCheckStatus+import com.vayunmathur.library.ui.AppScaffold+import com.vayunmathur.library.ui.Card+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.OutlinedButton+import com.vayunmathur.library.ui.SettingsSwitchRow+import com.vayunmathur.library.ui.Switch+import com.vayunmathur.library.ui.Text++/**+ * Stateless sources screen: which sources the store talks to at all.+ * The source list is fixed — see [DefaultRepos] for why nothing can be added to it.+ */+@Composable+fun SourcesScreen(+    statusMessage: String = "",+    autoInstallUpdates: Boolean = false,+    enabledSources: Set<AppSource> = emptySet(),+    updateCheckStatus: UpdateCheckStatus = UpdateCheckStatus(),+    onOpenTrust: () -> Unit = {},+    onAutoInstallUpdatesChange: (Boolean) -> Unit = {},+    onSourceEnabledChange: (AppSource, Boolean) -> Unit = { _, _ -> },+) {+    val noneEnabled = AppSource.TOGGLEABLE.none { it in enabledSources }+    AppScaffold(topBar = {}) { padding ->+        Column(+            Modifier+                .fillMaxSize()+                .padding(padding)+                .padding(horizontal = 16.dp)+                .padding(bottom = 24.dp)+                .verticalScroll(rememberScrollState()),+            verticalArrangement = Arrangement.spacedBy(12.dp),+        ) {+            OutlinedButton(onClick = onOpenTrust, modifier = Modifier.fillMaxWidth()) {+                Text(stringResource(R.string.trust_page_title))+            }+            if (noneEnabled) {+                Text(+                    stringResource(R.string.sources_all_disabled),+                    style = MaterialTheme.typography.labelSmall,+                    color = MaterialTheme.colorScheme.error,+                )+            }+            if (statusMessage.isNotBlank()) {+                Text(+                    statusMessage,+                    style = MaterialTheme.typography.labelSmall,+                    color = MaterialTheme.colorScheme.secondary,+                )+            }+            Card(Modifier.fillMaxWidth()) {+                SettingsSwitchRow(+                    title = stringResource(R.string.setting_auto_install_updates_title),+                    supportingText = stringResource(R.string.setting_auto_install_updates_summary),+                    checked = autoInstallUpdates,+                    onCheckedChange = onAutoInstallUpdatesChange,+                )+            }+            UpdateCheckStatusCard(status = updateCheckStatus)+            SourceCard(+                title = stringResource(R.string.source_modern_apps),+                subtitle = ModernAppsRepo.PROJECT_URL,+                enabled = AppSource.MODERN_APPS in enabledSources,+                onEnabledChange = { onSourceEnabledChange(AppSource.MODERN_APPS, it) },+            )+            SourceCard(+                title = stringResource(R.string.source_chip_fdroid),+                subtitle = DefaultRepos.FDROID.url,+                enabled = AppSource.FDROID in enabledSources,+                onEnabledChange = { onSourceEnabledChange(AppSource.FDROID, it) },+            )+            SourceCard(+                title = stringResource(R.string.source_chip_izzy),+                subtitle = DefaultRepos.IZZY.url,+                enabled = AppSource.IZZY in enabledSources,+                onEnabledChange = { onSourceEnabledChange(AppSource.IZZY, it) },+            )+            SourceCard(+                title = stringResource(R.string.source_chip_proprietary),+                subtitle = DefaultRepos.PROPRIETARY.url,+                enabled = AppSource.PROPRIETARY in enabledSources,+                onEnabledChange = { onSourceEnabledChange(AppSource.PROPRIETARY, it) },+            )+            SourceCard(+                title = stringResource(R.string.source_play),+                subtitle = "play.google.com",+                enabled = AppSource.PLAYSTORE in enabledSources,+                onEnabledChange = { onSourceEnabledChange(AppSource.PLAYSTORE, it) },+            )+            SourceCard(+                title = stringResource(R.string.source_chip_accrescent),+                subtitle = AccrescentRepo.REPOSITORY_URL,+                enabled = AppSource.ACCRESCENT in enabledSources,+                onEnabledChange = { onSourceEnabledChange(AppSource.ACCRESCENT, it) },+            )+        }+    }+}++@Composable+private fun SourceCard(+    title: String,+    subtitle: String,+    enabled: Boolean,+    onEnabledChange: (Boolean) -> Unit,+) {+    Card(Modifier.fillMaxWidth()) {+        Row(+            Modifier.fillMaxWidth().padding(16.dp),+            verticalAlignment = Alignment.CenterVertically,+        ) {+            Column(Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(2.dp)) {+                Text(+                    title,+                    style = MaterialTheme.typography.titleSmall,+                    fontWeight = FontWeight.SemiBold,+                )+                Text(+                    subtitle,+                    style = MaterialTheme.typography.labelSmall,+                    color = MaterialTheme.colorScheme.onSurfaceVariant,+                )+            }+            Switch(checked = enabled, onCheckedChange = onEnabledChange)+        }+    }+}
appstore/src/main/java/com/vayunmathur/appstore/ui/dialogs/TvUninstallDialog.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/ui/dialogs/TvUninstallDialog.kt b/appstore/src/main/java/com/vayunmathur/appstore/ui/dialogs/TvUninstallDialog.ktnew file mode 100644index 0000000000..a97d886f3c--- /dev/null+++ b/appstore/src/main/java/com/vayunmathur/appstore/ui/dialogs/TvUninstallDialog.kt@@ -0,0 +1,35 @@+package com.vayunmathur.appstore.ui.dialogs++import androidx.compose.runtime.Composable+import androidx.compose.ui.res.stringResource+import com.vayunmathur.appstore.R+import com.vayunmathur.library.tv.TvButton+import com.vayunmathur.library.tv.TvDialog+import com.vayunmathur.library.ui.R as UiR++/** TV uninstall confirmation for `TvStoreRoute.UninstallDialog`, stateless for tests. */+@Composable+fun TvUninstallDialog(+    appName: String,+    packageName: String,+    onDismiss: () -> Unit,+    onConfirm: () -> Unit,+) {+    TvDialog(+        title = stringResource(R.string.uninstall_3, appName),+        body = stringResource(+            R.string.this_will_uninstall_you_can_reinstall_la, packageName+        ),+        onDismissRequest = onDismiss,+    ) {+        TvButton(+            text = stringResource(UiR.string.cancel),+            onClick = onDismiss,+        )+        TvButton(+            text = stringResource(R.string.uninstall),+            onClick = onConfirm,+            primary = true,+        )+    }+}
appstore/src/main/java/com/vayunmathur/appstore/ui/dialogs/UninstallDialog.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/ui/dialogs/UninstallDialog.kt b/appstore/src/main/java/com/vayunmathur/appstore/ui/dialogs/UninstallDialog.ktnew file mode 100644index 0000000000..87fac380a1--- /dev/null+++ b/appstore/src/main/java/com/vayunmathur/appstore/ui/dialogs/UninstallDialog.kt@@ -0,0 +1,26 @@+package com.vayunmathur.appstore.ui.dialogs++import androidx.compose.runtime.Composable+import androidx.compose.ui.res.stringResource+import com.vayunmathur.appstore.R+import com.vayunmathur.library.ui.ConfirmDialog+import com.vayunmathur.library.ui.R as UiR++/** Uninstall confirmation for `Route.UninstallDialog`, stateless for previews/tests. */+@Composable+fun UninstallDialog(+    appName: String,+    packageName: String,+    onConfirm: () -> Unit,+    onDismiss: () -> Unit,+) {+    ConfirmDialog(+        title = stringResource(R.string.uninstall_3, appName),+        message = stringResource(R.string.this_will_uninstall_you_can_reinstall_la, packageName),+        confirmLabel = stringResource(R.string.uninstall),+        dismissLabel = stringResource(UiR.string.cancel),+        onConfirm = onConfirm,+        onDismiss = onDismiss,+        destructive = true,+    )+}
appstore/src/main/java/com/vayunmathur/appstore/ui/tv/TvMainActivity.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/ui/tv/TvMainActivity.kt b/appstore/src/main/java/com/vayunmathur/appstore/ui/tv/TvMainActivity.ktindex bb956539d2..36f75eb3be 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/ui/tv/TvMainActivity.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/ui/tv/TvMainActivity.kt@@ -22,6 +22,8 @@ import com.vayunmathur.library.ui.IconPackage import com.vayunmathur.library.ui.IconProvider import com.vayunmathur.library.ui.IconSearch import com.vayunmathur.library.ui.MaActivity+import com.vayunmathur.appstore.ui.dialogs.TvUninstallDialog+import com.vayunmathur.library.util.DialogPage import com.vayunmathur.library.util.MainNavigation import com.vayunmathur.library.util.NavBackStack import com.vayunmathur.library.util.NavKey@@ -72,6 +74,10 @@ sealed interface TvStoreRoute : NavKey {     /** One app's page, pushed over the rail tab that opened it. */     @Serializable     data class Detail(val packageName: String) : TvStoreRoute++    /** Uninstall confirmation dialog for the app named by [packageName]. */+    @Serializable+    data class UninstallDialog(val packageName: String, val appName: String) : TvStoreRoute }  /**@@ -187,6 +193,25 @@ private fun TvStoreNavigation(viewModel: TvStoreViewModel) {                 viewModel = viewModel,                 packageName = route.packageName,                 onBack = { backStack.pop() },+                onOpenUninstallDialog = {+                    val app = viewModel.detail.value.app+                    if (app != null) {+                        backStack.add(+                            TvStoreRoute.UninstallDialog(app.packageName, app.name)+                        )+                    }+                },+            )+        }+        entry<TvStoreRoute.UninstallDialog>(metadata = DialogPage()) { route ->+            TvUninstallDialog(+                appName = route.appName,+                packageName = route.packageName,+                onDismiss = { backStack.pop() },+                onConfirm = {+                    backStack.pop()+                    viewModel.uninstallApp(route.packageName)+                },             )         }     }
appstore/src/main/java/com/vayunmathur/appstore/ui/tv/TvStoreDetail.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/ui/tv/TvStoreDetail.kt b/appstore/src/main/java/com/vayunmathur/appstore/ui/tv/TvStoreDetail.ktindex 663a88e915..57243c14ae 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/ui/tv/TvStoreDetail.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/ui/tv/TvStoreDetail.kt@@ -27,13 +27,11 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import com.vayunmathur.appstore.data.UnifiedApp import com.vayunmathur.library.tv.TvButton-import com.vayunmathur.library.tv.TvDialog import com.vayunmathur.library.tv.TvEmptyState import com.vayunmathur.library.tv.TvInitialFocus import com.vayunmathur.library.tv.tvContentStart import com.vayunmathur.library.ui.IconBack import com.vayunmathur.library.ui.IconPackage-import com.vayunmathur.library.ui.R as UiR  /**  * One app's TV page: two panes side by side, no backdrop. Left is identity plus@@ -50,6 +48,7 @@ fun TvStoreDetail(     packageName: String,     onBack: () -> Unit,     modifier: Modifier = Modifier,+    onOpenUninstallDialog: () -> Unit = {}, ) {     // The Detail route's argument, reloaded whenever it changes so a     // restored entry shows its own app.@@ -66,6 +65,7 @@ fun TvStoreDetail(         onDismissFailure = viewModel::dismissInstallFailure,         onBack = onBack,         modifier = modifier,+        onOpenUninstallDialog = onOpenUninstallDialog,     ) } @@ -80,10 +80,10 @@ internal fun TvStoreDetailScreen(     onOpenInPlayStore: (String) -> Unit = {},     onDismissFailure: (String) -> Unit = {},     onBack: () -> Unit = {},+    onOpenUninstallDialog: () -> Unit = {}, ) {     val app = state.app     val primaryFocus = remember(app?.packageName) { FocusRequester() }-    var showUninstallConfirm by remember(app?.packageName) { mutableStateOf(false) }     if (app == null) {         TvEmptyState(             title = stringResource(R.string.home_empty_title),@@ -110,7 +110,7 @@ internal fun TvStoreDetailScreen(                 focusRequester = primaryFocus,                 onInstall = { onInstall(app) },                 onOpen = { onOpen(app.packageName) },-                onUninstall = { showUninstallConfirm = true },+                onUninstall = onOpenUninstallDialog,                 onDismissFailure = { onDismissFailure(app.packageName) },                 modifier = Modifier.weight(DETAIL_IDENTITY_WEIGHT).fillMaxHeight(),             )@@ -122,42 +122,6 @@ internal fun TvStoreDetailScreen(             )         }     }-    if (showUninstallConfirm) {-        TvUninstallConfirm(-            app = app,-            onDismiss = { showUninstallConfirm = false },-            onConfirm = {-                showUninstallConfirm = false-                onUninstall(app.packageName)-            },-        )-    }-}--/** Uninstall confirmation dialog for the detail screen. */-@Composable-private fun TvUninstallConfirm(-    app: UnifiedApp,-    onDismiss: () -> Unit,-    onConfirm: () -> Unit,-) {-    TvDialog(-        title = stringResource(R.string.uninstall_3, app.name),-        body = stringResource(-            R.string.this_will_uninstall_you_can_reinstall_la, app.packageName-        ),-        onDismissRequest = onDismiss,-    ) {-        TvButton(-            text = stringResource(UiR.string.cancel),-            onClick = onDismiss,-        )-        TvButton(-            text = stringResource(R.string.uninstall),-            onClick = onConfirm,-            primary = true,-        )-    } }  /**
appstore/src/screenshotTest/kotlin/com/vayunmathur/appstore/ui/MetadataPreviews.kt
diff --git a/appstore/src/screenshotTest/kotlin/com/vayunmathur/appstore/ui/MetadataPreviews.kt b/appstore/src/screenshotTest/kotlin/com/vayunmathur/appstore/ui/MetadataPreviews.ktindex c17da4acdd..4bff70143a 100644--- a/appstore/src/screenshotTest/kotlin/com/vayunmathur/appstore/ui/MetadataPreviews.kt+++ b/appstore/src/screenshotTest/kotlin/com/vayunmathur/appstore/ui/MetadataPreviews.kt@@ -9,8 +9,11 @@ import com.vayunmathur.appstore.platform.LibraryUiState import com.vayunmathur.appstore.platform.SearchActions import com.vayunmathur.appstore.platform.SearchUiState import com.vayunmathur.appstore.platform.SectionLayout+import com.vayunmathur.appstore.platform.BrowseUiState+import com.vayunmathur.appstore.platform.UpdateCheckStatus import com.vayunmathur.appstore.platform.UpdatesActions import com.vayunmathur.appstore.platform.UpdatesUiState+import com.vayunmathur.appstore.ui.dialogs.UninstallDialog  import android.graphics.drawable.Drawable import android.graphics.drawable.GradientDrawable@@ -171,6 +174,73 @@ class MetadataPreviews {     fun Preview6Library() {         ChromePreview(selectedTab = 3)     }++    @PreviewTest+    @Preview(name = "7-sources", device = PHONE, group = "phone", showSystemUi = true)+    @Composable+    fun Preview7Sources() {+        DynamicTheme(darkTheme = true) {+            SourcesScreen(+                autoInstallUpdates = true,+                enabledSources = setOf(+                    AppSource.MODERN_APPS, AppSource.FDROID, AppSource.ACCRESCENT,+                ),+                updateCheckStatus = UpdateCheckStatus(+                    lastCheckMs = 1_785_566_534_600,+                    scheduled = true,+                    workerState = "ENQUEUED",+                ),+            )+        }+    }++    @PreviewTest+    @Preview(name = "8-browse", device = PHONE, group = "phone", showSystemUi = true)+    @Composable+    fun Preview8Browse() {+        DynamicTheme(darkTheme = true) {+            BrowseScreen(+                state = BrowseUiState(+                    sectionId = "modern-recent",+                    title = "New from Modern Apps",+                    apps = MODERN,+                    installedPackages = setOf("com.vayunmathur.calculator"),+                    installedIcons = ICONS,+                ),+            )+        }+    }++    @PreviewTest+    @Preview(name = "9-screenshots", device = PHONE, group = "phone", showSystemUi = true)+    @Composable+    fun Preview9Screenshots() {+        DynamicTheme(darkTheme = true) {+            ScreenshotViewerScreen(+                appName = "Aegis Authenticator",+                urls = listOf(+                    "https://f-droid.org/repo/com.beemdevelopment.aegis/en-US/phoneScreenshot/1.png",+                    "https://f-droid.org/repo/com.beemdevelopment.aegis/en-US/phoneScreenshot/2.png",+                ),+                initialIndex = 0,+                onClose = {},+            )+        }+    }++    @PreviewTest+    @Preview(name = "10-uninstall-dialog", device = PHONE, group = "phone", showSystemUi = true)+    @Composable+    fun Preview10UninstallDialog() {+        DynamicTheme(darkTheme = true) {+            UninstallDialog(+                appName = "Aegis Authenticator",+                packageName = "com.beemdevelopment.aegis",+                onConfirm = {},+                onDismiss = {},+            )+        }+    } }  @Composable
appstore/src/test/java/com/vayunmathur/appstore/data/CacheAndSettingsW5Test.kt
diff --git a/appstore/src/test/java/com/vayunmathur/appstore/data/CacheAndSettingsW5Test.kt b/appstore/src/test/java/com/vayunmathur/appstore/data/CacheAndSettingsW5Test.ktindex a97aae628d..7023831201 100644--- a/appstore/src/test/java/com/vayunmathur/appstore/data/CacheAndSettingsW5Test.kt+++ b/appstore/src/test/java/com/vayunmathur/appstore/data/CacheAndSettingsW5Test.kt@@ -18,12 +18,17 @@ import org.robolectric.RobolectricTestRunner /** W5: DownloadCache sweeping rules and SettingsRepository persisted reads. */ @RunWith(RobolectricTestRunner::class) class CacheAndSettingsW5Test {+    private companion object {+        /** Fixed sweep clock: stale is 100s before it, fresh is at it. */+        const val FIXED_NOW_MS = 1_700_000_000_000L+    }+     private val ctx get() = ApplicationProvider.getApplicationContext<Context>()      @Test     fun sweepRemovesStaleApksAndVersionDirsButKeepsFreshAndVerified() {         val root = File(ctx.cacheDir, "w5-sweep-${System.nanoTime()}").apply { mkdirs() }-        val now = System.currentTimeMillis()+        val now = FIXED_NOW_MS         val stale = now - 100_000_000L         fun file(path: String, modified: Long, content: String = "x"): File {             val f = File(root, path)
appstore/src/test/java/com/vayunmathur/appstore/data/play/PlayRestorePersistedTest.kt
diff --git a/appstore/src/test/java/com/vayunmathur/appstore/data/play/PlayRestorePersistedTest.kt b/appstore/src/test/java/com/vayunmathur/appstore/data/play/PlayRestorePersistedTest.ktindex 84b784a076..99c0b78c20 100644--- a/appstore/src/test/java/com/vayunmathur/appstore/data/play/PlayRestorePersistedTest.kt+++ b/appstore/src/test/java/com/vayunmathur/appstore/data/play/PlayRestorePersistedTest.kt@@ -1,4 +1,5 @@ package com.vayunmathur.appstore.data.play+// FIXTURE RELATIVE-TIME EXCEPTION: PlayRepository.restore() compares the persisted dispensed-at stamp against the real wall clock (12h freshness window), so the fixture must seed relative to now or a fixed stamp would exercise the stale path instead of the corrupt/blank paths under test  // FIXTURE RELATIVE-TIME EXCEPTION: timestamps are seeded relative to the wall clock the code under test reads internally, so the fresh/expired/relative-time branch under test keeps its meaning; a fixed past instant would silently change that branch. 
appstore/src/test/java/com/vayunmathur/appstore/data/play/PlayRestoreValidJsonTest.kt
diff --git a/appstore/src/test/java/com/vayunmathur/appstore/data/play/PlayRestoreValidJsonTest.kt b/appstore/src/test/java/com/vayunmathur/appstore/data/play/PlayRestoreValidJsonTest.ktindex e05bc2514d..2073668386 100644--- a/appstore/src/test/java/com/vayunmathur/appstore/data/play/PlayRestoreValidJsonTest.kt+++ b/appstore/src/test/java/com/vayunmathur/appstore/data/play/PlayRestoreValidJsonTest.kt@@ -1,4 +1,5 @@ package com.vayunmathur.appstore.data.play+// FIXTURE RELATIVE-TIME EXCEPTION: PlayRepository.restore() compares the persisted dispensed-at stamp against the real wall clock (12h freshness window), so the fixture must seed relative to now or a fixed stamp would be invalidated as stale before the validity probe under test  // FIXTURE RELATIVE-TIME EXCEPTION: timestamps are seeded relative to the wall clock the code under test reads internally, so the fresh/expired/relative-time branch under test keeps its meaning; a fixed past instant would silently change that branch. 
appstore/src/test/java/com/vayunmathur/appstore/data/play/PlayWithApiTest.kt
diff --git a/appstore/src/test/java/com/vayunmathur/appstore/data/play/PlayWithApiTest.kt b/appstore/src/test/java/com/vayunmathur/appstore/data/play/PlayWithApiTest.ktindex 83285b2265..4461e5acc9 100644--- a/appstore/src/test/java/com/vayunmathur/appstore/data/play/PlayWithApiTest.kt+++ b/appstore/src/test/java/com/vayunmathur/appstore/data/play/PlayWithApiTest.kt@@ -1,4 +1,5 @@ package com.vayunmathur.appstore.data.play+// FIXTURE RELATIVE-TIME EXCEPTION: PlayRepository.withApi checks the cached dispensed-at stamp against the real wall clock (12h freshness window), so the fixture must seed relative to now or a fixed stamp would read as expired  // FIXTURE RELATIVE-TIME EXCEPTION: timestamps are seeded relative to the wall clock the code under test reads internally, so the fresh/expired/relative-time branch under test keeps its meaning; a fixed past instant would silently change that branch. 
appstore/src/test/java/com/vayunmathur/appstore/tv/TvDetailBranchesW5Test.kt
diff --git a/appstore/src/test/java/com/vayunmathur/appstore/tv/TvDetailBranchesW5Test.kt b/appstore/src/test/java/com/vayunmathur/appstore/tv/TvDetailBranchesW5Test.ktindex 32882862be..fc3b36358c 100644--- a/appstore/src/test/java/com/vayunmathur/appstore/tv/TvDetailBranchesW5Test.kt+++ b/appstore/src/test/java/com/vayunmathur/appstore/tv/TvDetailBranchesW5Test.kt@@ -1,7 +1,11 @@ package com.vayunmathur.appstore.tv import com.vayunmathur.appstore.platform.TvDetailUiState+import com.vayunmathur.appstore.ui.dialogs.TvUninstallDialog import com.vayunmathur.appstore.ui.tv.TvStoreDetailScreen +import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableStateOf+import androidx.compose.runtime.setValue import androidx.compose.ui.test.assertIsDisplayed import androidx.compose.ui.test.junit4.createComposeRule import androidx.compose.ui.test.onAllNodesWithText@@ -62,27 +66,36 @@ class TvDetailBranchesW5Test {     @Test     fun installedAppUninstallConfirmAndCancel() {         var uninstalled: String? = null+        var pushed by mutableStateOf(false)         rule.setContent {-            TvStoreDetailScreen(-                state = TvDetailUiState(-                    app = app(),-                    installedInfo = InstalledInfo("com.example.tvdetail", "TV Detail App", "1.0", 2L),-                ),-                onUninstall = { uninstalled = it },-            )+            if (pushed) {+                TvUninstallDialog(+                    appName = "TV Detail App", packageName = "com.example.tvdetail",+                    onDismiss = { pushed = false },+                    onConfirm = { uninstalled = "com.example.tvdetail" },+                )+            } else {+                TvStoreDetailScreen(+                    state = TvDetailUiState(+                        app = app(),+                        installedInfo = InstalledInfo("com.example.tvdetail", "TV Detail App", "1.0", 2L),+                    ),+                    onUninstall = { uninstalled = it },+                    onOpenUninstallDialog = { pushed = true },+                )+            }         }         rule.onNodeWithText("Uninstall", substring = true).assertIsDisplayed()         click("Uninstall")-        // Confirmation appears; cancel first.+        // The dialog route is pushed; nothing has been uninstalled yet.+        assertTrue(pushed)+        assertEquals(null, uninstalled)         assertTrue(exists("Cancel"))         click("Cancel")         assertEquals(null, uninstalled)-        // Again and confirm.+        // Reopen and confirm in the dialog.+        click("Uninstall")         click("Uninstall")-        // Confirm in the dialog (the second Uninstall node).-        val nodes = rule.onAllNodes(hasClickAction() and hasText("Uninstall", substring = true))-        nodes[nodes.fetchSemanticsNodes().lastIndex]-            .performSemanticsAction(SemanticsActions.OnClick)         assertEquals("com.example.tvdetail", uninstalled)     } 
appstore/src/test/java/com/vayunmathur/appstore/tv/TvStoreUpdatesRichTest.kt
diff --git a/appstore/src/test/java/com/vayunmathur/appstore/tv/TvStoreUpdatesRichTest.kt b/appstore/src/test/java/com/vayunmathur/appstore/tv/TvStoreUpdatesRichTest.ktindex 1b46badb06..439cc6da9d 100644--- a/appstore/src/test/java/com/vayunmathur/appstore/tv/TvStoreUpdatesRichTest.kt+++ b/appstore/src/test/java/com/vayunmathur/appstore/tv/TvStoreUpdatesRichTest.kt@@ -23,6 +23,11 @@ import org.robolectric.RobolectricTestRunner  */ @RunWith(RobolectricTestRunner::class) class TvStoreUpdatesRichTest {+    private companion object {+        /** Fixed last-checked stamp (one minute before the updates preview epoch). */+        const val FIXED_LAST_CHECKED_MS = 1_785_566_474_600L+    }+      @get:Rule     val rule = createComposeRule()@@ -82,7 +87,7 @@ class TvStoreUpdatesRichTest {      @Test     fun `last checked time renders a status line`() {-        val state = TvUpdatesUiState(lastCheckedAt = System.currentTimeMillis() - 60_000L)+        val state = TvUpdatesUiState(lastCheckedAt = FIXED_LAST_CHECKED_MS)         rule.setContent { TvStoreUpdatesScreen(state = state) }         rule.waitForIdle()         assertTrue(exists("Everything is up to date"))
appstore/src/test/java/com/vayunmathur/appstore/ui/AppDetailActionsFlowTest.kt
diff --git a/appstore/src/test/java/com/vayunmathur/appstore/ui/AppDetailActionsFlowTest.kt b/appstore/src/test/java/com/vayunmathur/appstore/ui/AppDetailActionsFlowTest.ktindex 118941a9ef..f18a8e320b 100644--- a/appstore/src/test/java/com/vayunmathur/appstore/ui/AppDetailActionsFlowTest.kt+++ b/appstore/src/test/java/com/vayunmathur/appstore/ui/AppDetailActionsFlowTest.kt@@ -2,6 +2,9 @@ package com.vayunmathur.appstore.ui import com.vayunmathur.appstore.platform.AppDetailActions import com.vayunmathur.appstore.platform.AppDetailUiState +import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableStateOf+import androidx.compose.runtime.setValue import androidx.compose.ui.test.assertIsDisplayed import androidx.compose.ui.test.junit4.createComposeRule import androidx.compose.ui.test.hasClickAction@@ -11,6 +14,7 @@ import androidx.compose.ui.test.performClick import com.vayunmathur.appstore.data.AppSource import com.vayunmathur.appstore.data.InstalledInfo import com.vayunmathur.appstore.data.UnifiedApp+import com.vayunmathur.appstore.ui.dialogs.UninstallDialog import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertNull@@ -19,9 +23,10 @@ import org.junit.runner.RunWith import org.robolectric.RobolectricTestRunner  /**- * Detail-screen action flows: uninstall asks first (the dialog names- * the app and package) and only the confirm reaches the actions; the- * dismiss path leaves the installed app installed.+ * Detail-screen action flows: uninstall asks first — the screen pushes+ * the uninstall dialog route (the dialog names the app and package)+ * and only the dialog confirm reaches the actions; the dismiss path+ * leaves the installed app installed.  */ @RunWith(RobolectricTestRunner::class) class AppDetailActionsFlowTest {@@ -48,17 +53,15 @@ class AppDetailActionsFlowTest {     )      /** The uninstall affordance is an icon-only button: walk the-     *  clickables (back, Open, delete) until the dialog appears. */-    private fun openUninstallDialog() {+     *  clickables (back, Open, delete) until the dialog route is pushed. */+    private fun openUninstallDialog(onPushed: () -> Boolean) {         val count = rule.onAllNodes(hasClickAction()).fetchSemanticsNodes().size         for (i in 0 until count) {             runCatching { rule.onAllNodes(hasClickAction())[i].performClick() }             rule.waitForIdle()-            if (rule.onAllNodesWithText("Uninstall Example?").fetchSemanticsNodes().isNotEmpty()) {-                return-            }+            if (onPushed()) return         }-        throw AssertionError("uninstall dialog never appeared")+        throw AssertionError("uninstall dialog route was never pushed")     }      @Test@@ -69,9 +72,23 @@ class AppDetailActionsFlowTest {                 uninstalled = packageName             }         }-        rule.setContent { AppDetailScreen(state = state(), actions = actions) }-        openUninstallDialog()-        // The dialog is up; nothing has been uninstalled yet.+        var pushed by mutableStateOf(false)+        rule.setContent {+            if (pushed) {+                UninstallDialog(+                    appName = "Example", packageName = "com.example.app",+                    onConfirm = { actions.uninstallApp("com.example.app") },+                    onDismiss = {},+                )+            } else {+                AppDetailScreen(+                    state = state(), actions = actions,+                    onOpenUninstallDialog = { pushed = true },+                )+            }+        }+        openUninstallDialog { pushed }+        // The dialog route is pushed; nothing has been uninstalled yet.         assertNull(uninstalled)         rule.onNodeWithText("Uninstall Example?").assertIsDisplayed()         rule.onNodeWithText("Uninstall").performClick()@@ -86,8 +103,22 @@ class AppDetailActionsFlowTest {                 uninstalled = packageName             }         }-        rule.setContent { AppDetailScreen(state = state(), actions = actions) }-        openUninstallDialog()+        var pushed by mutableStateOf(false)+        rule.setContent {+            if (pushed) {+                UninstallDialog(+                    appName = "Example", packageName = "com.example.app",+                    onConfirm = { actions.uninstallApp("com.example.app") },+                    onDismiss = {},+                )+            } else {+                AppDetailScreen(+                    state = state(), actions = actions,+                    onOpenUninstallDialog = { pushed = true },+                )+            }+        }+        openUninstallDialog { pushed }         rule.onNodeWithText("Cancel").performClick()         assertNull(uninstalled)     }