appstore: drop tab top bars, add Sources tab with pull to refresh
- Commit
9b04c09bdb80547d6545dbf3d2c618e9c3b0d377- Author
- vayun-mathur <[email protected]>
- When
- 2026-10-09 20:42 UTC (1 month ago)
- Parents
205241c
Diff
appstore/src/main/java/com/vayunmathur/appstore/MainActivity.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/MainActivity.kt b/appstore/src/main/java/com/vayunmathur/appstore/MainActivity.ktindex 085000503f..2c0af5010a 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/MainActivity.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/MainActivity.kt@@ -39,6 +39,7 @@ import com.vayunmathur.library.util.OfflineAware import com.vayunmathur.library.ui.IconDownload import com.vayunmathur.library.ui.IconHome import com.vayunmathur.library.ui.IconPackage+import com.vayunmathur.library.ui.IconProvider import com.vayunmathur.library.ui.IconSearch import com.vayunmathur.library.ui.PagerTab import com.vayunmathur.library.ui.TabStyle@@ -117,18 +118,17 @@ class MainActivity : ComponentActivity() { @Serializable sealed interface Route : NavKey { @Serializable data object Main : Route- @Serializable data object Sources : Route @Serializable data object Trust : Route @Serializable data object Detail : Route } /**- * Four tabs and three pushed screens.+ * Five tabs and two pushed screens. *- * Sources and the trust explainer used to be a tab each, which spent a quarter of the- * bottom bar on screens opened perhaps once. They are now behind the gear on the home- * bar, and the freed slot went to search — which was previously a text field wedged above- * the browse list, so browsing and searching fought over the same screen.+ * Sources used to be behind the gear on the home bar, which spent a settings icon on a+ * screen opened perhaps once. It is now a tab of its own, and search — previously a text+ * field wedged above the browse list — has its own tab so browsing and searching no+ * longer fight over the same screen. */ @Composable private fun AppRoot(@@ -155,13 +155,6 @@ private fun AppRoot( AppTabs( viewModel = viewModel, onAppClick = ::openDetail,- onOpenSources = { backStack.add(Route.Sources) },- )- }- entry<Route.Sources> {- SourcesPage(- viewModel = viewModel,- onBack = { backStack.pop() }, onOpenTrust = { backStack.add(Route.Trust) }, ) }@@ -185,16 +178,16 @@ private fun AppRoot( } /**- * The four bottom-nav tabs, hosted in a swipeable pager (see [TabbedPagerScaffold]).- * Sources, Trust and Detail are pushed on top of this host as ordinary routes.+ * The five bottom-nav tabs, hosted in a swipeable pager (see [TabbedPagerScaffold]).+ * Trust and Detail are pushed on top of this host as ordinary routes. */ @Composable private fun AppTabs( viewModel: AppStoreViewModel, onAppClick: (UnifiedApp) -> Unit,- onOpenSources: () -> Unit,+ onOpenTrust: () -> Unit, ) {- val pagerState = rememberPagerState(pageCount = { 4 })+ val pagerState = rememberPagerState(pageCount = { 5 }) val scope = rememberCoroutineScope() val tabs = listOf( PagerTab(stringResource(R.string.nav_home), { IconHome() }) {@@ -202,7 +195,6 @@ private fun AppTabs( viewModel = viewModel, onAppClick = onAppClick, onOpenUpdates = { scope.launch { pagerState.animateScrollToPage(PAGE_UPDATES) } },- onOpenSources = onOpenSources, ) }, PagerTab(stringResource(R.string.nav_search), { IconSearch() }) {@@ -222,6 +214,9 @@ private fun AppTabs( PagerTab(stringResource(R.string.nav_library), { IconPackage() }) { LibraryPage(viewModel = viewModel, onAppClick = onAppClick) },+ PagerTab(stringResource(R.string.nav_sources), { IconProvider() }) {+ SourcesPage(viewModel = viewModel, onOpenTrust = onOpenTrust)+ }, ) TabbedPagerScaffold(tabs = tabs, pagerState = pagerState, tabStyle = TabStyle.BottomNav) }
appstore/src/main/java/com/vayunmathur/appstore/ui/HomePage.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/ui/HomePage.kt b/appstore/src/main/java/com/vayunmathur/appstore/ui/HomePage.ktindex 52fa69a75f..4d19fa633e 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/ui/HomePage.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/ui/HomePage.kt@@ -31,21 +31,18 @@ import com.vayunmathur.appstore.util.AppStoreViewModel import com.vayunmathur.appstore.util.HomeActions import com.vayunmathur.appstore.util.HomeUiState import com.vayunmathur.appstore.util.SectionLayout-import com.vayunmathur.library.ui.AppScaffold+import com.vayunmathur.library.ui.AppPullToRefreshBox import com.vayunmathur.library.ui.Card import com.vayunmathur.library.ui.CardDefaults import com.vayunmathur.library.ui.CircularProgressIndicator import com.vayunmathur.library.ui.EmptyState import com.vayunmathur.library.ui.FilterChip-import com.vayunmathur.library.ui.IconButton import com.vayunmathur.library.ui.IconChevronRight import com.vayunmathur.library.ui.IconDownload import com.vayunmathur.library.ui.IconPackage-import com.vayunmathur.library.ui.IconRefresh-import com.vayunmathur.library.ui.IconSettings import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.Scaffold import com.vayunmathur.library.ui.Text-import com.vayunmathur.library.ui.appBarScrollBehavior /** Binds [AppStoreViewModel] to the stateless [HomeScreen]. */ @Composable@@ -53,7 +50,6 @@ fun HomePage( viewModel: AppStoreViewModel, onAppClick: (UnifiedApp) -> Unit, onOpenUpdates: () -> Unit,- onOpenSources: () -> Unit, ) { val state by viewModel.home.collectAsState() HomeScreen(@@ -61,7 +57,6 @@ fun HomePage( actions = viewModel, onAppClick = onAppClick, onOpenUpdates = onOpenUpdates,- onOpenSources = onOpenSources, ) } @@ -82,100 +77,97 @@ fun HomeScreen( actions: HomeActions, onAppClick: (UnifiedApp) -> Unit = {}, onOpenUpdates: () -> Unit = {},- onOpenSources: () -> Unit = {}, ) {- AppScaffold(- title = stringResource(R.string.app_name),- actions = {- IconButton(onClick = { actions.refresh() }, enabled = !state.isSyncing) {- IconRefresh()- }- IconButton(onClick = onOpenSources) { IconSettings() }- },- scrollBehavior = appBarScrollBehavior(),- ) { padding ->- // A package can legitimately sit in several sections at once - a new release is also a- // top download - but one detail page cannot morph from two origins. The first section- // listing a package owns the morph; later copies of it open without one.- val morphOwner = remember(state.sections) {- buildMap<String, String> {- state.sections.forEach { section ->- section.apps.forEach { putIfAbsent(it.packageName, section.id) }- }- }- }- fun sharedKeyFor(section: AppSection, app: UnifiedApp): Any? =- if (morphOwner[app.packageName] == section.id) {- "appstore-app-${app.packageName}"- } else {- null- }-- LazyColumn(- Modifier.fillMaxSize().padding(padding),- contentPadding = PaddingValues(bottom = 24.dp),- verticalArrangement = Arrangement.spacedBy(4.dp),+ Scaffold { padding ->+ AppPullToRefreshBox(+ isRefreshing = state.isSyncing,+ onRefresh = { actions.refresh() },+ modifier = Modifier.fillMaxSize(),+ topClearance = padding.calculateTopPadding(), ) {- if (state.isSyncing || state.statusMessage.isNotBlank()) {- item("status") { StatusLine(state.statusMessage, state.isSyncing) }+ // A package can legitimately sit in several sections at once - a new release is also a+ // top download - but one detail page cannot morph from two origins. The first section+ // listing a package owns the morph; later copies of it open without one.+ val morphOwner = remember(state.sections) {+ buildMap<String, String> {+ state.sections.forEach { section ->+ section.apps.forEach { putIfAbsent(it.packageName, section.id) }+ }+ } }+ fun sharedKeyFor(section: AppSection, app: UnifiedApp): Any? =+ if (morphOwner[app.packageName] == section.id) {+ "appstore-app-${app.packageName}"+ } else {+ null+ } - if (state.updateCount > 0) {- item("updates") { UpdatesBanner(state.updateCount, onOpenUpdates) }- }+ LazyColumn(+ Modifier.fillMaxSize().padding(padding),+ contentPadding = PaddingValues(bottom = 24.dp),+ verticalArrangement = Arrangement.spacedBy(4.dp),+ ) {+ if (state.isSyncing || state.statusMessage.isNotBlank()) {+ item("status") { StatusLine(state.statusMessage, state.isSyncing) }+ } - if (state.categories.isNotEmpty()) {- item("categories") {- CategoryRow(- categories = state.categories,- selected = state.selectedCategory,- onSelect = actions::selectCategory,- )+ if (state.updateCount > 0) {+ item("updates") { UpdatesBanner(state.updateCount, onOpenUpdates) } }- } - if (state.sections.isEmpty()) {- item("empty") {- if (state.isLoading) {- LoadingRow()- } else {- EmptyState(- title = stringResource(R.string.home_empty_title),- message = stringResource(R.string.home_empty_message),- icon = { IconPackage() },- modifier = Modifier.height(320.dp),+ if (state.categories.isNotEmpty()) {+ item("categories") {+ CategoryRow(+ categories = state.categories,+ selected = state.selectedCategory,+ onSelect = actions::selectCategory, ) } }- } - state.sections.forEach { section ->- item("${section.id}-header") {- SectionHeader(section.title, section.subtitle)+ if (state.sections.isEmpty()) {+ item("empty") {+ if (state.isLoading) {+ LoadingRow()+ } else {+ EmptyState(+ title = stringResource(R.string.home_empty_title),+ message = stringResource(R.string.home_empty_message),+ icon = { IconPackage() },+ modifier = Modifier.height(320.dp),+ )+ }+ } }- when (section.layout) {- SectionLayout.CAROUSEL -> item("${section.id}-body") {- AppCarousel(- apps = section.apps,- installedPackages = state.installedPackages,- installedIcons = state.installedIcons,- onAppClick = onAppClick,- stages = state.stages,- sharedKey = { sharedKeyFor(section, it) },- )++ state.sections.forEach { section ->+ item("${section.id}-header") {+ SectionHeader(section.title, section.subtitle) }- SectionLayout.LIST -> items(- section.apps,- key = { "${section.id}-${it.packageName}" },- ) { app ->- AppRow(- app = app,- isInstalled = app.packageName in state.installedPackages,- stage = state.stages[app.packageName],- installedIcon = state.installedIcons[app.packageName],- onClick = { onAppClick(app) },- sharedKey = sharedKeyFor(section, app),- )+ when (section.layout) {+ SectionLayout.CAROUSEL -> item("${section.id}-body") {+ AppCarousel(+ apps = section.apps,+ installedPackages = state.installedPackages,+ installedIcons = state.installedIcons,+ onAppClick = onAppClick,+ stages = state.stages,+ sharedKey = { sharedKeyFor(section, it) },+ )+ }+ SectionLayout.LIST -> items(+ section.apps,+ key = { "${section.id}-${it.packageName}" },+ ) { app ->+ AppRow(+ app = app,+ isInstalled = app.packageName in state.installedPackages,+ stage = state.stages[app.packageName],+ installedIcon = state.installedIcons[app.packageName],+ onClick = { onAppClick(app) },+ sharedKey = sharedKeyFor(section, app),+ )+ } } } }
appstore/src/main/java/com/vayunmathur/appstore/ui/LibraryPage.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/ui/LibraryPage.kt b/appstore/src/main/java/com/vayunmathur/appstore/ui/LibraryPage.ktindex 5193d731c6..1ad47759db 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/ui/LibraryPage.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/ui/LibraryPage.kt@@ -21,12 +21,11 @@ import com.vayunmathur.appstore.util.AppStoreViewModel import com.vayunmathur.appstore.util.LibraryActions import com.vayunmathur.appstore.util.LibraryUiState import com.vayunmathur.appstore.util.SourceFilter-import com.vayunmathur.library.ui.AppScaffold import com.vayunmathur.library.ui.EmptyState import com.vayunmathur.library.ui.FilterChip import com.vayunmathur.library.ui.IconPackage+import com.vayunmathur.library.ui.Scaffold import com.vayunmathur.library.ui.Text-import com.vayunmathur.library.ui.appBarScrollBehavior /** Binds [AppStoreViewModel] to the stateless [LibraryScreen]. */ @Composable@@ -47,14 +46,8 @@ fun LibraryScreen( actions: LibraryActions, onAppClick: (UnifiedApp) -> Unit = {}, ) {- AppScaffold(- title = stringResource(- R.string.library_title,- state.counts[SourceFilter.ALL] ?: state.apps.size,- ),- scrollBehavior = appBarScrollBehavior(),- ) { padding ->- Column(Modifier.fillMaxSize().padding(padding)) {+ Scaffold { padding ->+ Column(Modifier.fillMaxSize().padding(top = padding.calculateTopPadding())) { LazyRow( Modifier.fillMaxWidth(), contentPadding = PaddingValues(horizontal = 16.dp, vertical = 8.dp),@@ -84,7 +77,10 @@ fun LibraryScreen( icon = { IconPackage() }, ) } else {- LazyColumn(Modifier.fillMaxSize(), contentPadding = PaddingValues(bottom = 24.dp)) {+ LazyColumn(+ Modifier.fillMaxSize(),+ contentPadding = PaddingValues(bottom = padding.calculateBottomPadding() + 24.dp),+ ) { items(state.apps, key = { it.packageName }) { app -> AppRow( app = app,
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 b647ceda16..f979cbcf0c 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/ui/SourcesPage.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/ui/SourcesPage.kt@@ -3,16 +3,16 @@ 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.Spacer+import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth-import androidx.compose.foundation.layout.height 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.collectAsState import androidx.compose.runtime.getValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier-import androidx.compose.ui.platform.LocalConfiguration import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp@@ -21,145 +21,98 @@ 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.data.security.ApkCertificates import com.vayunmathur.appstore.util.AppStoreViewModel-import com.vayunmathur.appstore.util.syncSources-import com.vayunmathur.library.ui.AppBarAlignment-import com.vayunmathur.library.ui.Button import com.vayunmathur.library.ui.Card-import com.vayunmathur.library.ui.DetailScaffold import com.vayunmathur.library.ui.MaterialTheme import com.vayunmathur.library.ui.OutlinedButton+import com.vayunmathur.library.ui.Scaffold import com.vayunmathur.library.ui.SettingsSwitchRow import com.vayunmathur.library.ui.Switch import com.vayunmathur.library.ui.Text-import com.vayunmathur.library.ui.appBarScrollBehavior-import java.text.SimpleDateFormat-import java.util.Date /**- * The source list is fixed — see [DefaultRepos] for why nothing can be added to it. What the- * user does control is which of them the store talks to at all, and this page is where that- * choice is made. It also shows what each source is pinned to, so the pins can be compared- * against their published values rather than taken on faith.+ * 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 SourcesPage( viewModel: AppStoreViewModel,- onBack: () -> Unit, onOpenTrust: () -> Unit = {}, ) {- val repos by viewModel.repos.collectAsState() val home by viewModel.home.collectAsState() val autoInstallUpdates by viewModel.autoInstallUpdates.collectAsState() val enabledSources by viewModel.enabledSources.collectAsState()- val fdroid = repos.find { it.url == DefaultRepos.FDROID.url }- val proprietary = repos.find { it.url == DefaultRepos.PROPRIETARY.url } val noneEnabled = AppSource.TOGGLEABLE.none { it in enabledSources }- // Sync only refreshes the two offline indexes; with both off it has nothing to fetch.- val nothingToSync = DefaultRepos.ALL.none { it.source in enabledSources } - DetailScaffold(- title = stringResource(R.string.repositories),- onNavigateBack = onBack,- alignment = AppBarAlignment.Center,- scrollBehavior = appBarScrollBehavior(),- ) {- Text(- stringResource(R.string.sources_are_fixed),- style = MaterialTheme.typography.bodySmall,- )- Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(8.dp)) {- Button(- onClick = { viewModel.syncSources() },- enabled = !home.isSyncing && !nothingToSync,- modifier = Modifier.weight(1f),- ) {+ Scaffold { 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(- if (home.isSyncing) R.string.sync_in_progress- else R.string.repos_sync_sources- )+ stringResource(R.string.sources_all_disabled),+ style = MaterialTheme.typography.labelSmall,+ color = MaterialTheme.colorScheme.error, ) }- OutlinedButton(onClick = onOpenTrust, modifier = Modifier.weight(1f)) {- Text(stringResource(R.string.trust_page_title))+ if (home.statusMessage.isNotBlank()) {+ Text(+ home.statusMessage,+ style = MaterialTheme.typography.labelSmall,+ color = MaterialTheme.colorScheme.secondary,+ ) }- }- if (noneEnabled) {- Text(- stringResource(R.string.sources_all_disabled),- style = MaterialTheme.typography.labelSmall,- color = MaterialTheme.colorScheme.error,++ 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) },+ )+ }++ 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) }, )- }- if (home.statusMessage.isNotBlank()) {- Text(- home.statusMessage,- style = MaterialTheme.typography.labelSmall,- color = MaterialTheme.colorScheme.secondary,+ SourceCard(+ title = stringResource(R.string.source_chip_fdroid),+ subtitle = DefaultRepos.FDROID.url,+ enabled = AppSource.FDROID in enabledSources,+ onEnabledChange = { viewModel.setSourceEnabled(AppSource.FDROID, it) }, )- }-- 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) },+ 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) }, ) }-- SourceCard(- title = stringResource(R.string.source_modern_apps),- subtitle = ModernAppsRepo.PROJECT_URL,- pinLabel = stringResource(R.string.source_modern_apps_pin),- pins = viewModel.ownSigningCertificates,- lastSync = 0L,- 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,- pinLabel = stringResource(R.string.source_fdroid_pin),- pins = setOfNotNull(- fdroid?.fingerprint ?: DefaultRepos.FDROID.pinnedFingerprint- ),- lastSync = fdroid?.lastSync ?: 0L,- enabled = AppSource.FDROID in enabledSources,- onEnabledChange = { viewModel.setSourceEnabled(AppSource.FDROID, it) },- )- SourceCard(- title = stringResource(R.string.source_chip_proprietary),- subtitle = DefaultRepos.PROPRIETARY.url,- pinLabel = stringResource(R.string.source_proprietary_pin),- pins = setOfNotNull(- proprietary?.fingerprint ?: DefaultRepos.PROPRIETARY.pinnedFingerprint- ),- lastSync = proprietary?.lastSync ?: 0L,- enabled = AppSource.PROPRIETARY in enabledSources,- onEnabledChange = { viewModel.setSourceEnabled(AppSource.PROPRIETARY, it) },- )- SourceCard(- title = stringResource(R.string.source_play),- subtitle = "play.google.com",- pinLabel = stringResource(R.string.source_play_pin),- pins = emptySet(),- lastSync = 0L,- enabled = AppSource.PLAYSTORE in enabledSources,- onEnabledChange = { viewModel.setSourceEnabled(AppSource.PLAYSTORE, it) },- )- SourceCard(- title = stringResource(R.string.source_chip_accrescent),- subtitle = AccrescentRepo.REPOSITORY_URL,- pinLabel = stringResource(R.string.source_accrescent_pin),- pins = setOf(AccrescentRepo.REPODATA_PUBKEY),- lastSync = 0L,- enabled = AppSource.ACCRESCENT in enabledSources,- onEnabledChange = { viewModel.setSourceEnabled(AppSource.ACCRESCENT, it) },- abbreviatePins = false,- ) } } @@ -167,58 +120,27 @@ fun SourcesPage( private fun SourceCard( title: String, subtitle: String,- pinLabel: String,- pins: Set<String>,- lastSync: Long, enabled: Boolean, onEnabledChange: (Boolean) -> Unit,- /**- * Whether [pins] are hex certificate fingerprints to abbreviate for display. Accrescent's- * pin is a base64 signify ed25519 key, not a hex fingerprint, so it is shown verbatim.- */- abbreviatePins: Boolean = true, ) {- val locale = LocalConfiguration.current.locales[0] Card(Modifier.fillMaxWidth()) {- Column(Modifier.padding(16.dp), verticalArrangement = Arrangement.spacedBy(4.dp)) {- Row(Modifier.fillMaxWidth(), verticalAlignment = Alignment.CenterVertically) {- Column(Modifier.weight(1f)) {- Text(- title,- style = MaterialTheme.typography.titleSmall,- fontWeight = FontWeight.SemiBold,- )- Text(- subtitle,- style = MaterialTheme.typography.labelSmall,- color = MaterialTheme.colorScheme.onSurfaceVariant,- )- }- Switch(checked = enabled, onCheckedChange = onEnabledChange)- }- Spacer(Modifier.height(4.dp))- Text(- pinLabel,- style = MaterialTheme.typography.labelSmall,- color = MaterialTheme.colorScheme.onSurfaceVariant,- )- pins.forEach {+ Row(+ Modifier.fillMaxWidth().padding(16.dp),+ verticalAlignment = Alignment.CenterVertically,+ ) {+ Column(Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(2.dp)) { Text(- if (abbreviatePins) ApkCertificates.abbreviate(it) else it,- style = MaterialTheme.typography.labelMedium,- color = MaterialTheme.colorScheme.primary,+ title,+ style = MaterialTheme.typography.titleSmall,+ fontWeight = FontWeight.SemiBold, )- }- if (lastSync > 0) { Text(- stringResource(- R.string.last_sync,- SimpleDateFormat("yyyy-MM-dd HH:mm", locale)- .format(Date(lastSync)),- ),+ subtitle, style = MaterialTheme.typography.labelSmall,+ color = MaterialTheme.colorScheme.onSurfaceVariant, ) }+ Switch(checked = enabled, onCheckedChange = onEnabledChange) } } }
appstore/src/main/java/com/vayunmathur/appstore/ui/UpdatesPage.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/ui/UpdatesPage.kt b/appstore/src/main/java/com/vayunmathur/appstore/ui/UpdatesPage.ktindex 7d6a36b747..414415820c 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/ui/UpdatesPage.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/ui/UpdatesPage.kt@@ -9,7 +9,6 @@ import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding-import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items@@ -28,17 +27,14 @@ import com.vayunmathur.appstore.data.installer.InstallStage import com.vayunmathur.appstore.util.AppStoreViewModel import com.vayunmathur.appstore.util.UpdatesActions import com.vayunmathur.appstore.util.UpdatesUiState-import com.vayunmathur.library.ui.AppScaffold+import com.vayunmathur.library.ui.AppPullToRefreshBox import com.vayunmathur.library.ui.Button-import com.vayunmathur.library.ui.CircularProgressIndicator import com.vayunmathur.library.ui.EmptyState import com.vayunmathur.library.ui.IconCheck import com.vayunmathur.library.ui.IconDownload import com.vayunmathur.library.ui.MaterialTheme-import com.vayunmathur.library.ui.OutlinedButton-import com.vayunmathur.library.ui.AppPullToRefreshBox+import com.vayunmathur.library.ui.Scaffold import com.vayunmathur.library.ui.Text-import com.vayunmathur.library.ui.appBarScrollBehavior /** Binds [AppStoreViewModel] to the stateless [UpdatesScreen]. */ @Composable@@ -60,29 +56,21 @@ fun UpdatesScreen( ) { val anyInstalling = state.stages.values.any { it !is InstallStage.Failed } - AppScaffold(- title = {},- actions = {- if (state.isChecking) {- CircularProgressIndicator(Modifier.size(18.dp).padding(end = 4.dp))- }- },- scrollBehavior = appBarScrollBehavior(),- ) { padding ->+ Scaffold { padding -> AppPullToRefreshBox( isRefreshing = state.isChecking, onRefresh = { actions.checkForUpdates() }, modifier = Modifier.fillMaxSize(),- // Below the top app bar: the scaffold's top inset is the exact clearance.+ // Below the status bar: the scaffold's top inset is the exact clearance. topClearance = padding.calculateTopPadding(), ) { Column(Modifier.fillMaxSize().padding(padding)) {- Row(- Modifier.fillMaxWidth().padding(horizontal = 16.dp, vertical = 8.dp),- horizontalArrangement = Arrangement.spacedBy(8.dp),- verticalAlignment = Alignment.CenterVertically,- ) {- if (state.updates.isNotEmpty()) {+ if (state.updates.isNotEmpty()) {+ Row(+ Modifier.fillMaxWidth().padding(horizontal = 16.dp, vertical = 8.dp),+ horizontalArrangement = Arrangement.spacedBy(8.dp),+ verticalAlignment = Alignment.CenterVertically,+ ) { Button( onClick = { actions.updateAll() }, enabled = !anyInstalling,@@ -93,13 +81,6 @@ fun UpdatesScreen( Text(stringResource(R.string.update_all, state.updates.size)) } }- OutlinedButton(- onClick = { actions.checkForUpdates() },- enabled = !state.isChecking,- modifier = if (state.updates.isEmpty()) Modifier.weight(1f) else Modifier,- ) {- Text(stringResource(R.string.action_check_again))- } } val status = state.statusMessage.takeIf { it.isNotBlank() }
appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreViewModel.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreViewModel.kt b/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreViewModel.ktindex f674a56c22..fccb976607 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreViewModel.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreViewModel.kt@@ -423,7 +423,7 @@ class AppStoreViewModel( override fun refresh() = syncSources() /** Re-download both offline catalogues, then reload the home rows from them. */- // Implemented in AppStoreHomeOps.kt as a public extension (called from SourcesPage).+ // Implemented in AppStoreHomeOps.kt as a public extension (called from refresh()). /** * Turn a source on or off, and make the rest of the store agree immediately.
appstore/src/main/res/values/strings.xml
diff --git a/appstore/src/main/res/values/strings.xml b/appstore/src/main/res/values/strings.xmlindex 0f9747d0af..c07f36c139 100644--- a/appstore/src/main/res/values/strings.xml+++ b/appstore/src/main/res/values/strings.xml@@ -19,6 +19,7 @@ <string name="nav_search">Search</string> <string name="nav_updates">Updates</string> <string name="nav_library">Library</string>+ <string name="nav_sources">Sources</string> <!-- Source chips. Factual labels; the sources are not ranked. --> <string name="source_chip_modern_apps" translatable="false">Modern Apps</string>