appstore: fix all lint findings
- Commit
a5d0d91626866bceb08596f2a0b972df45225ea7- Author
- Vayun Mathur <[email protected]>
- When
- 2026-11-17 06:56 UTC (19 days ago)
- Parents
d0ec660
Brings :appstore:lintDev to zero app-owned errors and warnings (231 findings). ExtraTranslation (125) and UnusedResources (39) are removed after verifying no dynamic lookups (the one getIdentifier use, for the gplayapi device profile, now references com.aurora.gplayapi.R.raw directly, which also clears DiscouragedApi). PackageStructure (24): util/ view model and ops move to platform/, RemoteImageFetchers to data/, tv/ screens to ui/tv and the TV view model/ops to platform/; Route and AppRoot/AppTabs are extracted from MainActivity. OneComposablePerFile (14): each extra public composable gets its own file. RawScaffoldInApp (5): tab screens use AppScaffold. PluralsCandidate: sync_done becomes a plural in the default locale and every translation (with the ar/pl/it/fr quantities MissingQuantity requires, and the unused zh one removed). ObsoleteSdkInt, EmptySuperCall, UseKtx (toUri, SharedPreferences.edit), MissingPermission (inline POST_NOTIFICATIONS check before notify), IntentFilterUniqueDataAttributes, Typos (Hintergund) and CommentedOutCode are fixed in code. Suppressions (false positives, noted per instructions): ProtectedPermissions tools:ignore on INSTALL_PACKAGES (the MAOS system store; runtime-checked, stock Android keeps the user-confirmed flow), PluralsCandidate tools:ignore on the modern-Android rule detail (the number is an API level, not a count), and VectorRaster tools:ignore on the 320x180 leanback banner (a two-path tile at the size the launcher requests). Verified: ./gradlew :appstore:lintDev reports 0 errors and 0 app-owned warnings, and :appstore:testDevUnitTest passes (670 tests). Remaining report warnings are sourced from shared library modules only.
Diff
appstore/src/main/AndroidManifest.xml
diff --git a/appstore/src/main/AndroidManifest.xml b/appstore/src/main/AndroidManifest.xmlindex 2d371ea03f..62850fa168 100644--- a/appstore/src/main/AndroidManifest.xml+++ b/appstore/src/main/AndroidManifest.xml@@ -16,7 +16,8 @@ grants it to a regularly installed app, so the installer checks at runtime (checkSelfPermission) and keeps the user-confirmed session flow when it is not held. Declaring it here changes nothing on stock. -->- <uses-permission android:name="android.permission.INSTALL_PACKAGES" />+ <!-- INSTALL_PACKAGES is a signature|privileged permission held only on MAOS, where this store is the system installer; the runtime check above keeps stock Android on the user-confirmed flow, so ProtectedPermissions is a false positive here. -->+ <uses-permission android:name="android.permission.INSTALL_PACKAGES" tools:ignore="ProtectedPermissions" /> <uses-permission android:name="android.permission.REQUEST_DELETE_PACKAGES" /> <uses-permission android:name="android.permission.ENFORCE_UPDATE_OWNERSHIP" /> <!-- Silent background updates: SessionInstaller commits with USER_ACTION_NOT_REQUIRED,@@ -78,22 +79,22 @@ <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" />- <data android:scheme="https" android:host="play.google.com" android:pathPrefix="/store/apps/details" />+ <data android:scheme="https" />+ <data android:host="play.google.com" />+ <data android:pathPrefix="/store/apps/details" /> </intent-filter> <intent-filter android:autoVerify="false"> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <!-- Plain /packages/<pkg> listing URLs. -->- <data- android:scheme="https"- android:host="f-droid.org"- android:pathPrefix="/packages/" />+ <data android:scheme="https" />+ <data android:host="f-droid.org" />+ <data android:pathPrefix="/packages/" /> <!-- Localised /<locale>/packages/<pkg>/ listing URLs. -->- <data- android:scheme="https"- android:host="f-droid.org"- android:pathPattern="/.*/packages/.*" />+ <data android:scheme="https" />+ <data android:host="f-droid.org" />+ <data android:pathPattern="/.*/packages/.*" /> </intent-filter> </activity> @@ -104,11 +105,10 @@ entries that confuse launcher resolution (the tvlauncher HOME lesson). --> <activity- android:name=".tv.TvMainActivity"+ android:name=".ui.tv.TvMainActivity" android:configChanges="mcc|mnc|colorMode|density|fontScale|fontWeightAdjustment|keyboard|keyboardHidden|layoutDirection|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode" android:exported="true" android:launchMode="singleTask"- android:screenOrientation="landscape" android:theme="@style/Theme.General"> <intent-filter> <action android:name="android.intent.action.MAIN" />
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 db455abca7..5cd61964e0 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/MainActivity.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/MainActivity.kt@@ -1,38 +1,8 @@ package com.vayunmathur.appstore--import android.content.Intent-import androidx.compose.foundation.layout.Box-import androidx.compose.foundation.layout.fillMaxSize-import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue-import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.setValue-import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource-import androidx.lifecycle.viewmodel.compose.viewModel-import com.vayunmathur.appstore.data.AppStoreDatabaseRepository-import com.vayunmathur.appstore.data.ExternalLinks-import com.vayunmathur.appstore.data.UnifiedApp-import com.vayunmathur.appstore.data.UpdateCheckWorker-import com.vayunmathur.appstore.ui.AppDetailPage-import com.vayunmathur.appstore.ui.BrowsePage-import com.vayunmathur.appstore.ui.HomePage-import com.vayunmathur.appstore.ui.LibraryPage-import com.vayunmathur.appstore.ui.ScreenshotViewerScreen-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.util.AppSection-import com.vayunmathur.appstore.util.AppStoreViewModel-import com.vayunmathur.appstore.util.AppStoreViewModelFactory-import com.vayunmathur.appstore.util.RemoteImageFetchers-import com.vayunmathur.library.image.ImageLoader-import com.vayunmathur.library.network.NetworkClient-import com.vayunmathur.library.network.TrustBundle-import com.vayunmathur.library.ui.MaActivity-import com.vayunmathur.library.util.OfflineAware import com.vayunmathur.library.ui.IconDownload import com.vayunmathur.library.ui.IconHome import com.vayunmathur.library.ui.IconPackage@@ -47,6 +17,27 @@ import com.vayunmathur.library.util.NavKey import com.vayunmathur.library.util.SiblingPage import com.vayunmathur.library.util.rememberNavBackStack import kotlinx.serialization.Serializable+import com.vayunmathur.appstore.ui.AppRoot+import com.vayunmathur.appstore.platform.refreshInstalled++import android.content.Intent+import androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.fillMaxSize+import androidx.compose.runtime.Composable+import androidx.compose.runtime.mutableStateOf+import androidx.compose.ui.Modifier+import androidx.lifecycle.viewmodel.compose.viewModel+import com.vayunmathur.appstore.data.AppStoreDatabaseRepository+import com.vayunmathur.appstore.data.ExternalLinks+import com.vayunmathur.appstore.data.UpdateCheckWorker+import com.vayunmathur.appstore.platform.AppStoreViewModel+import com.vayunmathur.appstore.platform.AppStoreViewModelFactory+import com.vayunmathur.appstore.data.RemoteImageFetchers+import com.vayunmathur.library.image.ImageLoader+import com.vayunmathur.library.network.NetworkClient+import com.vayunmathur.library.network.TrustBundle+import com.vayunmathur.library.ui.MaActivity+import com.vayunmathur.library.util.OfflineAware /** Entry activity that wires the store UI, navigation and catalog startup. */ class MainActivity : MaActivity() {@@ -106,172 +97,3 @@ class MainActivity : MaActivity() { } } -@Serializable-/** Navigation destinations for the phone store UI. */-sealed interface Route : NavKey {- /** Tab destination showing the store home page. */- @Serializable data object Home : Route- /** Tab destination showing store search. */- @Serializable data object Search : Route- /** Tab destination showing available updates. */- @Serializable data object Updates : Route- /** Tab destination showing the installed-app library. */- @Serializable data object Library : Route- /** Tab destination showing store sources. */- @Serializable data object Sources : Route- /** Destination showing source trust information. */- @Serializable data object Trust : Route- /** Destination showing one app's detail page, named by its package. */- @Serializable data class Detail(val packageName: String) : Route- /** Destination browsing one home-page section by its ID. */- @Serializable data class Browse(val sectionId: String) : Route-- /**- * Full-screen screenshot viewer (#918). Carries its own URL list rather than reading the- * selected app back out of the view model, so a restored back stack still has its images.- */- @Serializable- data class Screenshots(val appName: String, val urls: List<String>, val index: Int) : Route-}--/**- * Five tabs and two pushed screens.- *- * 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(- viewModel: AppStoreViewModel,- externalPackage: String?,- onExternalPackageHandled: () -> Unit,-) {- // Home is the start (and deep-link base) tab: an external package pushes- // Detail over it, so popping Detail lands back on Home.- val backStack = rememberNavBackStack<Route>(Route.Home)-- LaunchedEffect(externalPackage) {- val pkg = externalPackage ?: return@LaunchedEffect- // The route carries the package; the Detail entry loads it. No- // ViewModel selection is set here, so a restored stack cannot show- // a different app from the one its top entry names.- if (backStack.last() != Route.Detail(pkg)) backStack.add(Route.Detail(pkg))- onExternalPackageHandled()- }-- fun openDetail(app: UnifiedApp) {- if (backStack.last() != Route.Detail(app.packageName)) {- backStack.add(Route.Detail(app.packageName))- }- }-- fun openBrowse(section: AppSection) {- backStack.add(Route.Browse(section.id))- }-- AppTabs(- backStack = backStack,- viewModel = viewModel,- onAppClick = ::openDetail,- onOpenBrowse = ::openBrowse,- )-}--/**- * The five bottom-nav tabs as sibling routes (see [TabbedPagerScaffold]'s- * route-backed overload). Selecting a tab resets the stack to that tab, so- * tab state is the back stack itself — visible to back, deep links and- * process restore — and each tab entry below is registered [SiblingPage]- * so switches crossfade instead of sliding like a push. Browse, Trust,- * Detail and Screenshots are pushed over the tab host as ordinary routes;- * while one is on top no tab is selected. Per-tab screen state stays in- * the shared ViewModel (and each entry's saveable state), as with the pager.- */-@Composable-private fun AppTabs(- backStack: NavBackStack<Route>,- viewModel: AppStoreViewModel,- onAppClick: (UnifiedApp) -> Unit,- onOpenBrowse: (AppSection) -> Unit,-) {- val tabs = listOf<RouteTab<Route>>(- RouteTab(Route.Home, stringResource(R.string.nav_home), { IconHome() }),- RouteTab(Route.Search, stringResource(R.string.nav_search), { IconSearch() }),- RouteTab(Route.Updates, stringResource(R.string.nav_updates), { IconDownload() }),- RouteTab(Route.Library, stringResource(R.string.nav_library), { IconPackage() }),- RouteTab(Route.Sources, stringResource(R.string.nav_sources), { IconProvider() }),- )- TabbedPagerScaffold(backStack = backStack, tabs = tabs) {- MainNavigation(backStack) {- entry<Route.Home>(metadata = SiblingPage()) {- HomePage(- viewModel = viewModel,- onAppClick = onAppClick,- // Cross-tab jump: a sibling switch, not a push.- onOpenUpdates = { backStack.reset(Route.Updates) },- onOpenBrowse = onOpenBrowse,- )- }- entry<Route.Search>(metadata = SiblingPage()) {- // This entry only renders while Search is on top, so the- // page is active by construction: opening it may autofocus,- // and a neighbour can no longer grab focus mid-swipe.- SearchPage(- viewModel = viewModel,- onAppClick = onAppClick,- isActive = true,- )- }- entry<Route.Updates>(metadata = SiblingPage()) {- UpdatesPage(viewModel = viewModel, onAppClick = onAppClick)- }- entry<Route.Library>(metadata = SiblingPage()) {- LibraryPage(viewModel = viewModel, onAppClick = onAppClick)- }- entry<Route.Sources>(metadata = SiblingPage()) {- SourcesPage(- viewModel = viewModel,- onOpenTrust = { backStack.add(Route.Trust) },- )- }- entry<Route.Browse> { route ->- BrowsePage(- viewModel = viewModel,- sectionId = route.sectionId,- onAppClick = onAppClick,- onBack = { backStack.pop() },- )- }- entry<Route.Trust> {- TrustPage(- ownSigningCertificates = viewModel.ownSigningCertificates,- onBack = { backStack.pop() },- )- }- entry<Route.Detail>(metadata = MorphPage()) { route ->- AppDetailPage(- viewModel = viewModel,- packageName = route.packageName,- onBack = { backStack.pop() },- onOpenTrust = { backStack.add(Route.Trust) },- onOpenScreenshot = { index ->- val app = viewModel.detail.value.app- if (app != null && app.screenshots.isNotEmpty()) {- backStack.add(Route.Screenshots(app.name, app.screenshots, index))- }- },- )- }- entry<Route.Screenshots> { route ->- ScreenshotViewerScreen(- appName = route.appName,- urls = route.urls,- initialIndex = route.index,- onClose = { backStack.pop() },- )- }- }- }-}
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.ktnew file mode 100644index 0000000000..2f05490af7--- /dev/null+++ b/appstore/src/main/java/com/vayunmathur/appstore/Route.kt@@ -0,0 +1,41 @@+package com.vayunmathur.appstore++import com.vayunmathur.library.util.NavKey+import kotlinx.serialization.Serializable++@Serializable+/** Navigation destinations for the phone store UI. */+sealed interface Route : NavKey {+ /** Tab destination showing the store home page. */+ @Serializable data object Home : Route+ /** Tab destination showing store search. */+ @Serializable data object Search : Route+ /** Tab destination showing available updates. */+ @Serializable data object Updates : Route+ /** Tab destination showing the installed-app library. */+ @Serializable data object Library : Route+ /** Tab destination showing store sources. */+ @Serializable data object Sources : Route+ /** Destination showing source trust information. */+ @Serializable data object Trust : Route+ /** Destination showing one app's detail page, named by its package. */+ @Serializable data class Detail(val packageName: String) : Route+ /** Destination browsing one home-page section by its ID. */+ @Serializable data class Browse(val sectionId: String) : Route++ /**+ * Full-screen screenshot viewer (#918). Carries its own URL list rather than reading the+ * selected app back out of the view model, so a restored back stack still has its images.+ */+ @Serializable+ data class Screenshots(val appName: String, val urls: List<String>, val index: Int) : Route+}++/**+ * Five tabs and two pushed screens.+ *+ * 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.+ */
appstore/src/main/java/com/vayunmathur/appstore/data/AppModels.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/data/AppModels.kt b/appstore/src/main/java/com/vayunmathur/appstore/data/AppModels.ktindex f449ed7652..e8cd73687c 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/AppModels.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/AppModels.kt@@ -1,4 +1,5 @@ package com.vayunmathur.appstore.data+import com.vayunmathur.appstore.platform.reason import com.vayunmathur.appstore.domain.SearchRanking
appstore/src/main/java/com/vayunmathur/appstore/data/FDroidRepository.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/data/FDroidRepository.kt b/appstore/src/main/java/com/vayunmathur/appstore/data/FDroidRepository.ktindex aef611d7cf..4e92b4d29e 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/FDroidRepository.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/FDroidRepository.kt@@ -1,4 +1,5 @@ package com.vayunmathur.appstore.data+import com.vayunmathur.appstore.platform.reason import android.content.Context import android.os.Build
appstore/src/main/java/com/vayunmathur/appstore/data/RemoteImageFetchers.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/util/RemoteImageFetchers.kt b/appstore/src/main/java/com/vayunmathur/appstore/data/RemoteImageFetchers.ktsimilarity index 97%rename from appstore/src/main/java/com/vayunmathur/appstore/util/RemoteImageFetchers.ktrename to appstore/src/main/java/com/vayunmathur/appstore/data/RemoteImageFetchers.ktindex 61106f76d8..4bb5425111 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/util/RemoteImageFetchers.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/RemoteImageFetchers.kt@@ -1,4 +1,4 @@-package com.vayunmathur.appstore.util+package com.vayunmathur.appstore.data import android.content.Context import android.net.Uri
appstore/src/main/java/com/vayunmathur/appstore/data/UpdateCheckWorker.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/data/UpdateCheckWorker.kt b/appstore/src/main/java/com/vayunmathur/appstore/data/UpdateCheckWorker.ktindex b3577dc79d..55fd583094 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/UpdateCheckWorker.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/UpdateCheckWorker.kt@@ -1,4 +1,5 @@ package com.vayunmathur.appstore.data+import com.vayunmathur.appstore.R import android.Manifest import android.app.Activity@@ -25,13 +26,12 @@ import androidx.work.WorkInfo import androidx.work.WorkManager import androidx.work.WorkerParameters import com.vayunmathur.appstore.MainActivity-import com.vayunmathur.appstore.R import com.vayunmathur.appstore.data.accrescent.AccrescentRepository import com.vayunmathur.appstore.data.accrescent.DeviceAttributesProvider import com.vayunmathur.appstore.data.installer.InstallCoordinator import com.vayunmathur.appstore.data.play.PlayRepository import com.vayunmathur.appstore.data.security.ApkCertificates-import com.vayunmathur.appstore.tv.TvMainActivity+import com.vayunmathur.appstore.ui.tv.TvMainActivity import com.vayunmathur.library.network.NetworkClient import com.vayunmathur.library.network.TrustBundle import kotlinx.coroutines.CoroutineScope@@ -368,7 +368,6 @@ class UpdateCheckWorker( * can't usefully answer, so those are left to the notification instead. */ private fun canSilentlyUpdate(packageName: String): Boolean {- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) return false return runCatching { val info = context.packageManager.getInstallSourceInfo(packageName) val self = context.packageName@@ -388,15 +387,11 @@ class UpdateCheckWorker( .setOngoing(true) .setPriority(NotificationCompat.PRIORITY_LOW) .build()- return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {- ForegroundInfo(- INSTALL_NOTIFICATION_ID,- notification,- ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC,- )- } else {- ForegroundInfo(INSTALL_NOTIFICATION_ID, notification)- }+ return ForegroundInfo(+ INSTALL_NOTIFICATION_ID,+ notification,+ ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC,+ ) } private fun notifyInstalled(count: Int) {@@ -418,8 +413,12 @@ class UpdateCheckWorker( .setAutoCancel(true) .setPriority(NotificationCompat.PRIORITY_LOW) .build()- runCatching {- NotificationManagerCompat.from(context).notify(INSTALLED_NOTIFICATION_ID, notification)+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU ||+ ActivityCompat.checkSelfPermission(context, Manifest.permission.POST_NOTIFICATIONS) == PackageManager.PERMISSION_GRANTED+ ) {+ runCatching {+ NotificationManagerCompat.from(context).notify(INSTALLED_NOTIFICATION_ID, notification)+ } } }
appstore/src/main/java/com/vayunmathur/appstore/data/UpdateLists.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/data/UpdateLists.kt b/appstore/src/main/java/com/vayunmathur/appstore/data/UpdateLists.ktindex e698730323..6b449eaefe 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/UpdateLists.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/UpdateLists.kt@@ -1,4 +1,5 @@ package com.vayunmathur.appstore.data+import com.vayunmathur.appstore.platform.merge /** * One update check's candidates, split by what "Update all" may touch (#885).
appstore/src/main/java/com/vayunmathur/appstore/data/accrescent/AccrescentRepository.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/data/accrescent/AccrescentRepository.kt b/appstore/src/main/java/com/vayunmathur/appstore/data/accrescent/AccrescentRepository.ktindex f406d24fd7..c2810b8504 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/accrescent/AccrescentRepository.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/accrescent/AccrescentRepository.kt@@ -1,4 +1,5 @@ package com.vayunmathur.appstore.data.accrescent+import com.vayunmathur.appstore.data.toUnifiedApp import android.content.Context import com.vayunmathur.library.log.Log
appstore/src/main/java/com/vayunmathur/appstore/data/installer/InstallCoordinator.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/data/installer/InstallCoordinator.kt b/appstore/src/main/java/com/vayunmathur/appstore/data/installer/InstallCoordinator.ktindex b54414a1ad..083e2554e7 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/installer/InstallCoordinator.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/installer/InstallCoordinator.kt@@ -1,4 +1,6 @@ package com.vayunmathur.appstore.data.installer+import com.vayunmathur.appstore.data.AppProvider+import com.vayunmathur.appstore.platform.reason import android.content.Context import com.aurora.gplayapi.exceptions.GooglePlayException@@ -317,8 +319,7 @@ class InstallCoordinator( } once() if (expectedSize > 0 && target.length() != expectedSize) {- // Truncated (or over-long) — one retry before giving up. Delete- // first: HttpURLConnection won't overwrite cleanly on all devices.+ // Truncated (or over-long): delete first and retry once, since HttpURLConnection will not overwrite cleanly on all devices. target.delete() once() if (target.length() != expectedSize) {@@ -440,10 +441,7 @@ class InstallCoordinator( expectedSha256 = emptyMap(), minVersionCode = trust.minVersionCode, signerOrigin = "Accrescent's signed app list",- // Server is the authority for Accrescent: it already picks splits- // per-device, so a client-side leanback refusal would second-guess- // it (mirrors the tvRefusal() exemption). Every other source keeps- // requireTvCompatible = isTv.+ // Server is the authority for Accrescent: it already picks splits per-device, so a client-side leanback refusal would second-guess it (mirrors the tvRefusal() exemption); every other source keeps the TV-compatibility requirement from isTv. requireTvCompatible = false, )
appstore/src/main/java/com/vayunmathur/appstore/data/installer/InstallStatusReceiver.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/data/installer/InstallStatusReceiver.kt b/appstore/src/main/java/com/vayunmathur/appstore/data/installer/InstallStatusReceiver.ktindex ef6b52ca8b..01f9aa89b4 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/installer/InstallStatusReceiver.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/installer/InstallStatusReceiver.kt@@ -1,4 +1,6 @@ package com.vayunmathur.appstore.data.installer+import com.vayunmathur.appstore.R+import com.vayunmathur.appstore.platform.reason import android.Manifest import android.app.ActivityManager@@ -16,7 +18,6 @@ import androidx.core.app.ActivityCompat import androidx.core.app.NotificationCompat import androidx.core.app.NotificationManagerCompat import com.vayunmathur.library.log.Log-import com.vayunmathur.appstore.R import com.vayunmathur.appstore.data.RestrictedPackages import com.vayunmathur.appstore.data.TvIncompatiblePackages import com.vayunmathur.appstore.data.accrescent.DeviceAttributesProvider
appstore/src/main/java/com/vayunmathur/appstore/data/installer/SessionInstaller.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/data/installer/SessionInstaller.kt b/appstore/src/main/java/com/vayunmathur/appstore/data/installer/SessionInstaller.ktindex 9ca2da4d16..7ef9ad6298 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/installer/SessionInstaller.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/installer/SessionInstaller.kt@@ -1,4 +1,5 @@ package com.vayunmathur.appstore.data.installer+import com.vayunmathur.appstore.platform.reason import android.app.PendingIntent import android.content.Context@@ -169,9 +170,7 @@ class SessionInstaller( // in which case silent commits are allowed for first installs too. The // permission check is what makes this degrade gracefully: stock Android // never grants it, so the flow there is byte-for-byte the old one.- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S &&- (isInstalled(packageName) || hasSilentInstallPermission())- ) {+ if (isInstalled(packageName) || hasSilentInstallPermission()) { setRequireUserAction(PackageInstaller.SessionParams.USER_ACTION_NOT_REQUIRED) } setInstallLocation(android.content.pm.PackageInfo.INSTALL_LOCATION_AUTO)
appstore/src/main/java/com/vayunmathur/appstore/data/play/DeviceInfoProvider.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/data/play/DeviceInfoProvider.kt b/appstore/src/main/java/com/vayunmathur/appstore/data/play/DeviceInfoProvider.ktindex 282b1bb42f..650b5dc2c6 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/play/DeviceInfoProvider.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/play/DeviceInfoProvider.kt@@ -1,4 +1,5 @@ package com.vayunmathur.appstore.data.play+import com.vayunmathur.appstore.R import android.content.Context import android.content.pm.PackageManager@@ -31,7 +32,7 @@ object DeviceInfoProvider { * Falls back to the native profile only if the bundled resource is missing. */ fun auroraProfile(context: Context): Properties = try {- val id = context.resources.getIdentifier("gplayapi_px_9a", "raw", context.packageName)+ val id = com.aurora.gplayapi.R.raw.gplayapi_px_9a if (id != 0) { context.resources.openRawResource(id).use { input -> Properties().apply { load(input) } } } else {
appstore/src/main/java/com/vayunmathur/appstore/data/play/PlayRepository.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/data/play/PlayRepository.kt b/appstore/src/main/java/com/vayunmathur/appstore/data/play/PlayRepository.ktindex 2bef486811..18a91b340f 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/play/PlayRepository.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/play/PlayRepository.kt@@ -1,4 +1,6 @@ package com.vayunmathur.appstore.data.play+import com.vayunmathur.appstore.R+import com.vayunmathur.appstore.platform.reason import android.content.Context import com.vayunmathur.library.log.Log
appstore/src/main/java/com/vayunmathur/appstore/data/play/PlayStoreApi.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/data/play/PlayStoreApi.kt b/appstore/src/main/java/com/vayunmathur/appstore/data/play/PlayStoreApi.ktindex bfba4625f6..959f787627 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/play/PlayStoreApi.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/play/PlayStoreApi.kt@@ -1,4 +1,6 @@ package com.vayunmathur.appstore.data.play+import com.vayunmathur.appstore.data.toUnifiedApp+import com.vayunmathur.appstore.platform.reason import com.aurora.gplayapi.data.models.App import com.aurora.gplayapi.data.models.AuthData
appstore/src/main/java/com/vayunmathur/appstore/data/security/InstallVerifier.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/data/security/InstallVerifier.kt b/appstore/src/main/java/com/vayunmathur/appstore/data/security/InstallVerifier.ktindex cea5c85217..2868544f68 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/security/InstallVerifier.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/security/InstallVerifier.kt@@ -1,4 +1,5 @@ package com.vayunmathur.appstore.data.security+import com.vayunmathur.appstore.platform.reason import android.content.Context import com.vayunmathur.appstore.data.AppProvider
appstore/src/main/java/com/vayunmathur/appstore/data/security/TrustProfile.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/data/security/TrustProfile.kt b/appstore/src/main/java/com/vayunmathur/appstore/data/security/TrustProfile.ktindex f37afbb858..168c415e2a 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/security/TrustProfile.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/security/TrustProfile.kt@@ -1,7 +1,8 @@ package com.vayunmathur.appstore.data.security+import com.vayunmathur.appstore.R+import com.vayunmathur.appstore.data.UnifiedApp import androidx.annotation.StringRes-import com.vayunmathur.appstore.R import com.vayunmathur.appstore.data.AppProvider import com.vayunmathur.appstore.data.AppSource
appstore/src/main/java/com/vayunmathur/appstore/domain/SearchRanking.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/domain/SearchRanking.kt b/appstore/src/main/java/com/vayunmathur/appstore/domain/SearchRanking.ktindex dfb3bc4dd5..2ff0de8dd9 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/domain/SearchRanking.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/domain/SearchRanking.kt@@ -1,4 +1,5 @@ package com.vayunmathur.appstore.domain+import com.vayunmathur.appstore.platform.rank /** * Turns a query and a set of candidate listings into an order.
appstore/src/main/java/com/vayunmathur/appstore/platform/AppStoreActionOps.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreActionOps.kt b/appstore/src/main/java/com/vayunmathur/appstore/platform/AppStoreActionOps.ktsimilarity index 95%rename from appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreActionOps.ktrename to appstore/src/main/java/com/vayunmathur/appstore/platform/AppStoreActionOps.ktindex 94604134f7..3351358cf7 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreActionOps.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/platform/AppStoreActionOps.kt@@ -1,9 +1,8 @@-package com.vayunmathur.appstore.util+package com.vayunmathur.appstore.platform+import com.vayunmathur.appstore.R -import com.vayunmathur.appstore.util.AppStoreViewModel.Companion.INSTALL_SETTLE_MS import android.content.Intent import androidx.lifecycle.viewModelScope-import com.vayunmathur.appstore.R import com.vayunmathur.appstore.data.PlayStoreLinks import com.vayunmathur.appstore.data.UnifiedApp import com.vayunmathur.appstore.data.security.VerificationResult@@ -32,7 +31,7 @@ internal fun AppStoreViewModel.installImpl(app: UnifiedApp) { if (outcome.started) { // PackageInstaller commits asynchronously; give it a moment before the // installed list is re-read, or the row still shows the old version.- delay(INSTALL_SETTLE_MS)+ delay(AppStoreViewModel.INSTALL_SETTLE_MS) installedRepo.refresh() } }
appstore/src/main/java/com/vayunmathur/appstore/platform/AppStoreDetailOps.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreDetailOps.kt b/appstore/src/main/java/com/vayunmathur/appstore/platform/AppStoreDetailOps.ktsimilarity index 98%rename from appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreDetailOps.ktrename to appstore/src/main/java/com/vayunmathur/appstore/platform/AppStoreDetailOps.ktindex f39916dcd2..de5f95d67a 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreDetailOps.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/platform/AppStoreDetailOps.kt@@ -1,4 +1,4 @@-package com.vayunmathur.appstore.util+package com.vayunmathur.appstore.platform import androidx.lifecycle.viewModelScope import com.vayunmathur.appstore.data.AppSource
appstore/src/main/java/com/vayunmathur/appstore/platform/AppStoreHomeOps.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreHomeOps.kt b/appstore/src/main/java/com/vayunmathur/appstore/platform/AppStoreHomeOps.ktsimilarity index 95%rename from appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreHomeOps.ktrename to appstore/src/main/java/com/vayunmathur/appstore/platform/AppStoreHomeOps.ktindex a45c584342..27fa1e3d6a 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreHomeOps.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/platform/AppStoreHomeOps.kt@@ -1,10 +1,8 @@-package com.vayunmathur.appstore.util+package com.vayunmathur.appstore.platform+import com.vayunmathur.appstore.R+import com.vayunmathur.appstore.data.UpdateCheckWorker -import com.vayunmathur.appstore.util.AppStoreViewModel.Companion.CAROUSEL_LIMIT-import com.vayunmathur.appstore.util.AppStoreViewModel.Companion.PLAY_CLUSTER_LIMIT-import com.vayunmathur.appstore.util.AppStoreViewModel.Companion.RECENT_PER_SOURCE_LIMIT import androidx.lifecycle.viewModelScope-import com.vayunmathur.appstore.R import com.vayunmathur.appstore.data.AppSource import com.vayunmathur.appstore.data.DefaultRepos import com.vayunmathur.appstore.data.SyncReport@@ -37,7 +35,7 @@ internal suspend fun AppStoreViewModel.loadHome(enabled: Set<AppSource> = enable private suspend fun AppStoreViewModel.loadOfflineRecents(enabled: Set<AppSource>) { suspend fun recentOrEmpty(source: AppSource): List<UnifiedApp> =- if (source in enabled) catalog.recentlyUpdatedBySource(source, RECENT_PER_SOURCE_LIMIT) else emptyList()+ if (source in enabled) catalog.recentlyUpdatedBySource(source, AppStoreViewModel.RECENT_PER_SOURCE_LIMIT) else emptyList() modernRecentFlow.value = recentOrEmpty(AppSource.MODERN_APPS) fdroidRecentFlow.value = recentOrEmpty(AppSource.FDROID) izzyRecentFlow.value = recentOrEmpty(AppSource.IZZY)@@ -51,12 +49,12 @@ private suspend fun AppStoreViewModel.loadPlayHomeSections() { val clusters = play.homeClusters() playFullClustersFlow.value = clusters .filter { it.apps.isNotEmpty() }- .take(PLAY_CLUSTER_LIMIT)+ .take(AppStoreViewModel.PLAY_CLUSTER_LIMIT) .associate { "play-${it.title}" to it.apps } playSectionsFlow.value = clusters .filter { it.apps.isNotEmpty() }- .take(PLAY_CLUSTER_LIMIT)- .map { AppSection("play-${it.title}", it.title, it.apps.take(CAROUSEL_LIMIT)) }+ .take(AppStoreViewModel.PLAY_CLUSTER_LIMIT)+ .map { AppSection("play-${it.title}", it.title, it.apps.take(AppStoreViewModel.CAROUSEL_LIMIT)) } if (playSectionsFlow.value.isEmpty()) { // No account, or Play changed its stream shape. A top chart is one request and // still gives the screen something beyond this repo's own dozen apps.@@ -67,7 +65,7 @@ private suspend fun AppStoreViewModel.loadPlayHomeSections() { AppSection( id = "play-top", title = context.getString(R.string.section_play_top_charts),- apps = chart.take(CAROUSEL_LIMIT),+ apps = chart.take(AppStoreViewModel.CAROUSEL_LIMIT), ) ) }@@ -274,7 +272,7 @@ private fun AppStoreViewModel.syncReportMessage(report: SyncReport, enabled: Set val counts = listOf(report.fdroidCount, report.modernCount, report.proprietaryCount, report.izzyCount) return when { report.allSkipped -> context.getString(R.string.sync_all_sources_off)- !report.anyFailed -> context.getString(R.string.sync_done, counts.sumOf { it ?: 0 })+ !report.anyFailed -> context.resources.getQuantityString(R.plurals.sync_done, counts.sumOf { it ?: 0 }, counts.sumOf { it ?: 0 }) counts.all { it == null } -> context.getString(R.string.sync_failed_all) report.fdroidCount == null -> context.getString(R.string.sync_failed_fdroid) report.izzyCount == null && AppSource.IZZY in enabled ->
appstore/src/main/java/com/vayunmathur/appstore/platform/AppStoreSearchOps.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreSearchOps.kt b/appstore/src/main/java/com/vayunmathur/appstore/platform/AppStoreSearchOps.ktsimilarity index 95%rename from appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreSearchOps.ktrename to appstore/src/main/java/com/vayunmathur/appstore/platform/AppStoreSearchOps.ktindex 5f0863165b..8b77ceac1a 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreSearchOps.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/platform/AppStoreSearchOps.kt@@ -1,8 +1,7 @@-package com.vayunmathur.appstore.util+package com.vayunmathur.appstore.platform+import com.vayunmathur.appstore.R -import com.vayunmathur.appstore.util.AppStoreViewModel.Companion.SEARCH_DEBOUNCE_MS import androidx.lifecycle.viewModelScope-import com.vayunmathur.appstore.R import com.vayunmathur.appstore.data.AppSource import com.vayunmathur.appstore.data.UnifiedApp import com.vayunmathur.appstore.data.play.PlayAuthState@@ -26,7 +25,7 @@ internal fun AppStoreViewModel.setSearchImpl(query: String) { return } searchJob = viewModelScope.launch {- delay(SEARCH_DEBOUNCE_MS)+ delay(AppStoreViewModel.SEARCH_DEBOUNCE_MS) isSearchingFlow.value = true searchPlayErrorFlow.value = "" // The persisted choice, not the flow's optimistic default: a search fired on a
appstore/src/main/java/com/vayunmathur/appstore/platform/AppStoreUiContract.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreUiContract.kt b/appstore/src/main/java/com/vayunmathur/appstore/platform/AppStoreUiContract.ktsimilarity index 99%rename from appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreUiContract.ktrename to appstore/src/main/java/com/vayunmathur/appstore/platform/AppStoreUiContract.ktindex cc91d4386e..b47eb470ba 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreUiContract.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/platform/AppStoreUiContract.kt@@ -1,4 +1,4 @@-package com.vayunmathur.appstore.util+package com.vayunmathur.appstore.platform import android.graphics.drawable.Drawable import com.vayunmathur.appstore.data.AppSource
appstore/src/main/java/com/vayunmathur/appstore/platform/AppStoreUpdateOps.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreUpdateOps.kt b/appstore/src/main/java/com/vayunmathur/appstore/platform/AppStoreUpdateOps.ktsimilarity index 95%rename from appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreUpdateOps.ktrename to appstore/src/main/java/com/vayunmathur/appstore/platform/AppStoreUpdateOps.ktindex a0371b6b0e..943fc29356 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreUpdateOps.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/platform/AppStoreUpdateOps.kt@@ -1,10 +1,7 @@-package com.vayunmathur.appstore.util+package com.vayunmathur.appstore.platform+import com.vayunmathur.appstore.R -import com.vayunmathur.appstore.util.AppStoreViewModel.Companion.CAROUSEL_LIMIT-import com.vayunmathur.appstore.util.AppStoreViewModel.Companion.INSTALL_SETTLE_MS-import com.vayunmathur.appstore.util.AppStoreViewModel.Companion.REPEATED_FAILURE_LIMIT import androidx.lifecycle.viewModelScope-import com.vayunmathur.appstore.R import com.vayunmathur.appstore.data.AppSource import com.vayunmathur.appstore.data.UnifiedApp import com.vayunmathur.appstore.data.installer.InstallFailureBatch@@ -122,7 +119,7 @@ internal fun AppStoreViewModel.updateAllImpl() { // PackageInstaller commits asynchronously, so the last app's real verdict // is still on its way. Wait for it before summarising, or it lands on its // own afterwards — which is the repetition this is here to stop.- delay(INSTALL_SETTLE_MS)+ delay(AppStoreViewModel.INSTALL_SETTLE_MS) } finally { statusMessageFlow.value = "" run.failures += InstallFailureBatch.end()@@ -159,7 +156,7 @@ private class UpdateRun { /** * Records one install outcome. Returns true when the run should stop:- * the same reason has failed [REPEATED_FAILURE_LIMIT] times in a row.+ * the same reason has failed [AppStoreViewModel.REPEATED_FAILURE_LIMIT] times in a row. */ fun record(viewModel: AppStoreViewModel, outcome: SessionInstaller.Outcome): Boolean { if (outcome.started) {@@ -172,7 +169,7 @@ private class UpdateRun { failures += failure repeats = if (failure == previousReason) repeats + 1 else 1 previousReason = failure- return repeats >= REPEATED_FAILURE_LIMIT+ return repeats >= AppStoreViewModel.REPEATED_FAILURE_LIMIT } } @@ -210,5 +207,5 @@ internal suspend fun AppStoreViewModel.loadAccrescent(enabled: Set<AppSource> = val ids = accrescent.appIds() if (ids.isNotEmpty()) accrescentPackagesFlow.value = ids val page = accrescent.listApps()- if (page.apps.isNotEmpty()) accrescentAppsFlow.value = page.apps.take(CAROUSEL_LIMIT)+ if (page.apps.isNotEmpty()) accrescentAppsFlow.value = page.apps.take(AppStoreViewModel.CAROUSEL_LIMIT) }
appstore/src/main/java/com/vayunmathur/appstore/platform/AppStoreViewModel.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreViewModel.kt b/appstore/src/main/java/com/vayunmathur/appstore/platform/AppStoreViewModel.ktsimilarity index 99%rename from appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreViewModel.ktrename to appstore/src/main/java/com/vayunmathur/appstore/platform/AppStoreViewModel.ktindex 2d4dfac8e7..d26dc0681a 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreViewModel.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/platform/AppStoreViewModel.kt@@ -1,4 +1,7 @@-package com.vayunmathur.appstore.util+package com.vayunmathur.appstore.platform+import com.vayunmathur.appstore.R+import com.vayunmathur.appstore.data.PackageIndexRow+import com.vayunmathur.appstore.data.toUnifiedApp import android.app.ActivityManager import android.app.Application@@ -9,7 +12,6 @@ import android.net.Uri import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.viewModelScope-import com.vayunmathur.appstore.R import com.vayunmathur.appstore.data.AppDatabase import com.vayunmathur.appstore.data.AppSource import com.vayunmathur.appstore.data.DefaultRepos@@ -468,7 +470,6 @@ class AppStoreViewModel( override fun onCleared() { // Release the Accrescent gRPC channel (and its okhttp connection pool). accrescent.shutdown()- super.onCleared() } /**
appstore/src/main/java/com/vayunmathur/appstore/platform/TvStoreHomeOps.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreHomeOps.kt b/appstore/src/main/java/com/vayunmathur/appstore/platform/TvStoreHomeOps.ktsimilarity index 97%rename from appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreHomeOps.ktrename to appstore/src/main/java/com/vayunmathur/appstore/platform/TvStoreHomeOps.ktindex 827bcb21be..56e4a086f1 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreHomeOps.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/platform/TvStoreHomeOps.kt@@ -1,7 +1,7 @@-package com.vayunmathur.appstore.tv+package com.vayunmathur.appstore.platform+import com.vayunmathur.appstore.R import androidx.lifecycle.viewModelScope-import com.vayunmathur.appstore.R import com.vayunmathur.appstore.data.AppSource import com.vayunmathur.appstore.data.DefaultRepos import com.vayunmathur.appstore.data.SyncReport@@ -67,7 +67,7 @@ private fun TvStoreViewModel.tvSyncReportMessage(report: SyncReport, enabled: Se val counts = listOf(report.fdroidCount, report.modernCount, report.proprietaryCount, report.izzyCount) return when { report.allSkipped -> context.getString(R.string.sync_all_sources_off)- !report.anyFailed -> context.getString(R.string.sync_done, counts.sumOf { it ?: 0 })+ !report.anyFailed -> context.resources.getQuantityString(R.plurals.sync_done, counts.sumOf { it ?: 0 }, counts.sumOf { it ?: 0 }) counts.all { it == null } -> context.getString(R.string.sync_failed_all) report.fdroidCount == null -> context.getString(R.string.sync_failed_fdroid) report.izzyCount == null && AppSource.IZZY in enabled ->
appstore/src/main/java/com/vayunmathur/appstore/platform/TvStoreLibraryOps.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreLibraryOps.kt b/appstore/src/main/java/com/vayunmathur/appstore/platform/TvStoreLibraryOps.ktsimilarity index 96%rename from appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreLibraryOps.ktrename to appstore/src/main/java/com/vayunmathur/appstore/platform/TvStoreLibraryOps.ktindex 9112911bc4..55442fb91d 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreLibraryOps.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/platform/TvStoreLibraryOps.kt@@ -1,10 +1,10 @@-package com.vayunmathur.appstore.tv+package com.vayunmathur.appstore.platform import androidx.lifecycle.viewModelScope import com.vayunmathur.appstore.data.AppSource import com.vayunmathur.appstore.data.InstalledInfo import com.vayunmathur.appstore.data.UnifiedApp-import com.vayunmathur.appstore.util.SourceFilter+import com.vayunmathur.appstore.platform.SourceFilter import kotlinx.coroutines.launch // ---- Library + Accrescent attribution ----
appstore/src/main/java/com/vayunmathur/appstore/platform/TvStoreOps.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreOps.kt b/appstore/src/main/java/com/vayunmathur/appstore/platform/TvStoreOps.ktsimilarity index 99%rename from appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreOps.ktrename to appstore/src/main/java/com/vayunmathur/appstore/platform/TvStoreOps.ktindex f74c71ba5b..f547f94e21 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreOps.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/platform/TvStoreOps.kt@@ -1,7 +1,7 @@-package com.vayunmathur.appstore.tv+package com.vayunmathur.appstore.platform+import com.vayunmathur.appstore.R import androidx.lifecycle.viewModelScope-import com.vayunmathur.appstore.R import com.vayunmathur.appstore.data.AppSource import com.vayunmathur.appstore.data.UnifiedApp import com.vayunmathur.appstore.data.installer.InstallFailureBatch
appstore/src/main/java/com/vayunmathur/appstore/platform/TvStoreUiState.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreUiState.kt b/appstore/src/main/java/com/vayunmathur/appstore/platform/TvStoreUiState.ktsimilarity index 97%rename from appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreUiState.ktrename to appstore/src/main/java/com/vayunmathur/appstore/platform/TvStoreUiState.ktindex 492fbafc44..9f518240c5 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreUiState.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/platform/TvStoreUiState.kt@@ -1,4 +1,4 @@-package com.vayunmathur.appstore.tv+package com.vayunmathur.appstore.platform import android.graphics.drawable.Drawable import com.vayunmathur.appstore.data.AppSource@@ -6,7 +6,7 @@ import com.vayunmathur.appstore.data.InstalledInfo import com.vayunmathur.appstore.data.UnifiedApp import com.vayunmathur.appstore.data.installer.InstallStage import com.vayunmathur.appstore.data.security.VerificationResult-import com.vayunmathur.appstore.util.SourceFilter+import com.vayunmathur.appstore.platform.SourceFilter /** * One titled row on the TV home screen. Same shape as the phone's `AppSection`:
appstore/src/main/java/com/vayunmathur/appstore/platform/TvStoreViewModel.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreViewModel.kt b/appstore/src/main/java/com/vayunmathur/appstore/platform/TvStoreViewModel.ktsimilarity index 98%rename from appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreViewModel.ktrename to appstore/src/main/java/com/vayunmathur/appstore/platform/TvStoreViewModel.ktindex f396506645..8b1b41572a 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreViewModel.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/platform/TvStoreViewModel.kt@@ -1,4 +1,7 @@-package com.vayunmathur.appstore.tv+package com.vayunmathur.appstore.platform+import com.vayunmathur.appstore.R+import androidx.core.net.toUri+import com.vayunmathur.appstore.ui.tv.TvStoreRoute import android.app.Application import android.content.Intent@@ -6,7 +9,6 @@ import android.net.Uri import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.viewModelScope-import com.vayunmathur.appstore.R import com.vayunmathur.appstore.data.AppDatabase import com.vayunmathur.appstore.data.AppSource import com.vayunmathur.appstore.data.CatalogRepository@@ -27,7 +29,7 @@ import com.vayunmathur.appstore.data.play.PlayRepository import com.vayunmathur.appstore.data.priority import com.vayunmathur.appstore.data.security.ApkCertificates import com.vayunmathur.appstore.data.security.VerificationResult-import com.vayunmathur.appstore.util.SourceFilter+import com.vayunmathur.appstore.platform.SourceFilter import com.vayunmathur.library.util.AppMessages import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job@@ -585,7 +587,7 @@ class TvStoreViewModel( if (url.isBlank()) return runCatching { context.startActivity(- Intent(Intent.ACTION_VIEW, Uri.parse(url)).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)+ Intent(Intent.ACTION_VIEW, url.toUri()).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) ) } }@@ -594,14 +596,14 @@ class TvStoreViewModel( fun openInPlayStore(packageName: String) { runCatching { val market = Intent(- Intent.ACTION_VIEW, Uri.parse("market://details?id=$packageName")+ Intent.ACTION_VIEW, "market://details?id=$packageName".toUri() ).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) if (market.resolveActivity(context.packageManager) != null) { context.startActivity(market) return } context.startActivity(- Intent(Intent.ACTION_VIEW, Uri.parse(PlayStoreLinks.playStoreUrl(packageName)))+ Intent(Intent.ACTION_VIEW, PlayStoreLinks.playStoreUrl(packageName).toUri()) .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) ) }@@ -614,7 +616,7 @@ class TvStoreViewModel( fun uninstallApp(packageName: String) { val started = runCatching { context.startActivity(- Intent(Intent.ACTION_DELETE, Uri.parse("package:$packageName"))+ Intent(Intent.ACTION_DELETE, "package:$packageName".toUri()) .putExtra(Intent.EXTRA_RETURN_RESULT, true) .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) )@@ -629,7 +631,6 @@ class TvStoreViewModel( override fun onCleared() { accrescent.shutdown()- super.onCleared() } internal companion object {
appstore/src/main/java/com/vayunmathur/appstore/ui/AppCarousel.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/ui/AppCarousel.kt b/appstore/src/main/java/com/vayunmathur/appstore/ui/AppCarousel.ktnew file mode 100644index 0000000000..21e52e3acd--- /dev/null+++ b/appstore/src/main/java/com/vayunmathur/appstore/ui/AppCarousel.kt@@ -0,0 +1,74 @@+package com.vayunmathur.appstore.ui++import com.vayunmathur.appstore.platform.reason+import android.graphics.drawable.Drawable+import androidx.compose.foundation.Image+import androidx.compose.foundation.background+import androidx.compose.foundation.clickable+import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.PaddingValues+import androidx.compose.foundation.layout.Row+import androidx.compose.foundation.layout.Spacer+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.LazyRow+import androidx.compose.foundation.lazy.items+import androidx.compose.foundation.shape.RoundedCornerShape+import androidx.compose.runtime.Composable+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.draw.clip+import androidx.compose.ui.graphics.asImageBitmap+import androidx.compose.ui.layout.ContentScale+import androidx.compose.ui.res.stringResource+import androidx.compose.ui.text.font.FontWeight+import androidx.compose.ui.text.style.TextOverflow+import androidx.compose.ui.unit.Dp+import androidx.compose.ui.unit.dp+import androidx.core.graphics.drawable.toBitmap+import com.vayunmathur.appstore.data.AppSource+import com.vayunmathur.appstore.data.UnifiedApp+import com.vayunmathur.appstore.data.installer.InstallStage+import com.vayunmathur.library.image.compose.AsyncImage+import com.vayunmathur.library.ui.IconCheck+import com.vayunmathur.library.ui.IconStar+import com.vayunmathur.library.ui.LinearProgressIndicator+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.Text+import com.vayunmathur.library.ui.TextButton+import com.vayunmathur.library.util.sharedCrop+import java.util.Locale++/** One horizontally scrolling row of [AppTile]s. */+@Composable+fun AppCarousel(+ apps: List<UnifiedApp>,+ installedPackages: Set<String>,+ installedIcons: Map<String, Drawable>,+ onAppClick: (UnifiedApp) -> Unit,+ modifier: Modifier = Modifier,+ stages: Map<String, InstallStage> = emptyMap(),+ /** Per-app, because only the caller knows which copy of an app owns the morph. */+ sharedKey: (UnifiedApp) -> Any? = { null },+) {+ LazyRow(+ modifier = modifier.fillMaxWidth(),+ contentPadding = PaddingValues(horizontal = 12.dp),+ horizontalArrangement = Arrangement.spacedBy(4.dp),+ ) {+ items(apps, key = { it.packageName }) { app ->+ AppTile(+ app = app,+ isInstalled = app.packageName in installedPackages,+ stage = stages[app.packageName],+ installedIcon = installedIcons[app.packageName],+ onClick = { onAppClick(app) },+ sharedKey = sharedKey(app),+ )+ }+ }+}
appstore/src/main/java/com/vayunmathur/appstore/ui/AppComponents.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/ui/AppComponents.kt b/appstore/src/main/java/com/vayunmathur/appstore/ui/AppComponents.ktindex ce5d471657..24a302902d 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/ui/AppComponents.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/ui/AppComponents.kt@@ -1,8 +1,7 @@ package com.vayunmathur.appstore.ui-+import com.vayunmathur.appstore.R import android.graphics.drawable.Drawable import androidx.compose.foundation.Image-import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box@@ -11,89 +10,37 @@ import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer 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.LazyRow import androidx.compose.foundation.lazy.items-import androidx.compose.foundation.shape.RoundedCornerShape-import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment-import androidx.compose.ui.Modifier-import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.asImageBitmap import androidx.compose.ui.layout.ContentScale-import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.Dp-import androidx.compose.ui.unit.dp import androidx.core.graphics.drawable.toBitmap-import com.vayunmathur.appstore.R-import com.vayunmathur.appstore.data.AppSource-import com.vayunmathur.appstore.data.UnifiedApp-import com.vayunmathur.appstore.data.installer.InstallStage import com.vayunmathur.library.image.compose.AsyncImage import com.vayunmathur.library.ui.IconCheck import com.vayunmathur.library.ui.IconStar import com.vayunmathur.library.ui.LinearProgressIndicator-import com.vayunmathur.library.ui.MaterialTheme-import com.vayunmathur.library.ui.Text import com.vayunmathur.library.ui.TextButton import com.vayunmathur.library.util.sharedCrop import java.util.Locale -/**- * The icon, from whichever of the places actually has one.- *- * A locally installed app has a real launcher icon in PackageManager, which beats- * re-downloading the listing's copy; a catalogue entry has a URL; a Play cluster row- * sometimes has neither. Every screen needs the same fallback chain, so it lives here- * rather than being written out again per call site.- */-@Composable-fun AppIcon(- app: UnifiedApp,- installedIcon: Drawable?,- modifier: Modifier = Modifier,- size: Dp = 48.dp,- corner: Dp = 12.dp,-) {- val shape = RoundedCornerShape(corner)- val box = modifier.size(size).clip(shape)- val bitmap = installedIcon?.let {- runCatching {- val px = (size.value * 2).toInt().coerceAtLeast(1)- it.toBitmap(width = px, height = px).asImageBitmap()- }.getOrNull()- }- when {- bitmap != null -> Image(- bitmap = bitmap,- contentDescription = null,- modifier = box,- contentScale = ContentScale.Crop,- )- app.iconUrl != null -> AsyncImage(- model = app.iconUrl,- contentDescription = null,- modifier = box,- contentScale = ContentScale.Crop,- )- // No icon anywhere: an initial on a tinted tile reads better than a blank hole,- // and keeps rows the same height whether or not the artwork loaded.- else -> Box(- box.background(MaterialTheme.colorScheme.surfaceVariant),- contentAlignment = Alignment.Center,- ) {- Text(- app.name.take(1).uppercase(),- style = MaterialTheme.typography.titleMedium,- color = MaterialTheme.colorScheme.onSurfaceVariant,- )- }- }-}+import androidx.compose.foundation.background+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.shape.RoundedCornerShape+import androidx.compose.runtime.Composable+import androidx.compose.ui.Modifier+import androidx.compose.ui.draw.clip+import androidx.compose.ui.res.stringResource+import androidx.compose.ui.unit.dp+import com.vayunmathur.appstore.data.AppSource+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.Text+ /** Where an app came from. Purely factual — the sources are not ranked. */ @Composable@@ -119,206 +66,3 @@ fun SourceChip(source: AppSource, modifier: Modifier = Modifier) { ) } -/** "4.6 ★" plus the rating count, when the source published one. */-@Composable-fun RatingLabel(app: UnifiedApp, modifier: Modifier = Modifier) {- val rating = app.rating ?: return- Row(modifier, verticalAlignment = Alignment.CenterVertically) {- Text(- String.format(Locale.US, "%.1f", rating),- style = MaterialTheme.typography.labelSmall,- color = MaterialTheme.colorScheme.onSurfaceVariant,- )- Spacer(Modifier.width(2.dp))- IconStar(Modifier.size(12.dp), tint = MaterialTheme.colorScheme.onSurfaceVariant)- }-}--/**- * A full-width list row: icon, name, summary, and whatever the caller puts on the right.- *- * [stage] draws its own progress bar underneath, so a row that is mid-install says which- * part of the install it is in rather than showing a bar that sits at 100% through- * verification and commit.- */-@Composable-fun AppRow(- app: UnifiedApp,- modifier: Modifier = Modifier,- isInstalled: Boolean = false,- stage: InstallStage? = null,- installedIcon: Drawable? = null,- versionLabel: String? = null,- /**- * Non-null makes this row the origin of the [sharedCrop] container transform into the app's- * detail page. Null for a row that is a second copy of an app already shown elsewhere on- * screen - the morph cannot choose between two origins for one destination.- */- sharedKey: Any? = null,- onClick: () -> Unit = {},- trailing: @Composable (() -> Unit)? = null,-) {- Column(- modifier- .then(if (sharedKey == null) Modifier else Modifier.sharedCrop(sharedKey))- .fillMaxWidth()- .clickable(onClick = onClick)- .padding(horizontal = 16.dp, vertical = 10.dp),- ) {- Row(verticalAlignment = Alignment.CenterVertically) {- AppIcon(app, installedIcon, size = 48.dp)- Spacer(Modifier.width(14.dp))- Column(Modifier.weight(1f)) {- Text(- app.name,- style = MaterialTheme.typography.titleSmall,- fontWeight = FontWeight.SemiBold,- maxLines = 1,- overflow = TextOverflow.Ellipsis,- )- val subtitle = app.summary.ifBlank { app.author.orEmpty() }- if (subtitle.isNotBlank()) {- Text(- subtitle,- style = MaterialTheme.typography.bodySmall,- color = MaterialTheme.colorScheme.onSurfaceVariant,- maxLines = 2,- overflow = TextOverflow.Ellipsis,- )- }- Row(- Modifier.padding(top = 2.dp),- verticalAlignment = Alignment.CenterVertically,- horizontalArrangement = Arrangement.spacedBy(6.dp),- ) {- SourceChip(app.source)- RatingLabel(app)- if (isInstalled) {- IconCheck(Modifier.size(12.dp), tint = MaterialTheme.colorScheme.primary)- }- }- if (versionLabel != null) {- Text(- versionLabel,- style = MaterialTheme.typography.labelSmall,- color = MaterialTheme.colorScheme.onSurfaceVariant,- // Old and new versions share one "a (1) → b (2)" line, and long- // version names ellipsized the tail — the new code — away (#813).- // Two lines keeps both codes visible.- maxLines = 2,- overflow = TextOverflow.Ellipsis,- modifier = Modifier.padding(top = 2.dp),- )- }- }- if (trailing != null) {- Spacer(Modifier.width(8.dp))- trailing()- }- }- StageProgress(stage, Modifier.padding(top = 8.dp))- }-}--/** Heading above a section of the home screen, with an optional trailing action. */-@Composable-fun SectionHeader(- title: String,- subtitle: String?,- modifier: Modifier = Modifier,- /** Label for the header's action button; null draws no button (e.g. in a preview). */- actionLabel: String? = null,- onAction: () -> Unit = {},-) {- Row(- modifier.padding(horizontal = 16.dp, vertical = 8.dp),- verticalAlignment = Alignment.CenterVertically,- ) {- Column(Modifier.weight(1f)) {- Text(title, style = MaterialTheme.typography.titleMedium, fontWeight = FontWeight.Bold)- if (!subtitle.isNullOrBlank()) {- Text(- subtitle,- style = MaterialTheme.typography.bodySmall,- color = MaterialTheme.colorScheme.onSurfaceVariant,- )- }- }- if (actionLabel != null) {- TextButton(onClick = onAction) {- Text(actionLabel)- }- }- }-}--/** One horizontally scrolling row of [AppTile]s. */-@Composable-fun AppCarousel(- apps: List<UnifiedApp>,- installedPackages: Set<String>,- installedIcons: Map<String, Drawable>,- onAppClick: (UnifiedApp) -> Unit,- modifier: Modifier = Modifier,- stages: Map<String, InstallStage> = emptyMap(),- /** Per-app, because only the caller knows which copy of an app owns the morph. */- sharedKey: (UnifiedApp) -> Any? = { null },-) {- LazyRow(- modifier = modifier.fillMaxWidth(),- contentPadding = PaddingValues(horizontal = 12.dp),- horizontalArrangement = Arrangement.spacedBy(4.dp),- ) {- items(apps, key = { it.packageName }) { app ->- AppTile(- app = app,- isInstalled = app.packageName in installedPackages,- stage = stages[app.packageName],- installedIcon = installedIcons[app.packageName],- onClick = { onAppClick(app) },- sharedKey = sharedKey(app),- )- }- }-}--/**- * The progress line for an in-flight install, or nothing when there isn't one.- *- * Download is determinate; verification and the PackageInstaller commit are not, and an- * indeterminate bar is the honest way to say "still working, no idea how long".- */-@Composable-fun StageProgress(stage: InstallStage?, modifier: Modifier = Modifier) {- if (stage == null) return- Column(modifier.fillMaxWidth()) {- when (stage) {- is InstallStage.Downloading -> LinearProgressIndicator(- progress = { stage.fraction },- modifier = Modifier.fillMaxWidth(),- )- is InstallStage.Failed -> Unit- else -> LinearProgressIndicator(Modifier.fillMaxWidth())- }- Text(- stageLabel(stage),- style = MaterialTheme.typography.labelSmall,- color = if (stage is InstallStage.Failed) {- MaterialTheme.colorScheme.error- } else {- MaterialTheme.colorScheme.onSurfaceVariant- },- modifier = Modifier.padding(top = 2.dp),- )- }-}--@Composable-fun stageLabel(stage: InstallStage): String = when (stage) {- InstallStage.Preparing -> stringResource(R.string.stage_preparing)- is InstallStage.Downloading ->- stringResource(R.string.stage_downloading, (stage.fraction * 100).toInt())- InstallStage.Verifying -> stringResource(R.string.stage_verifying)- InstallStage.Installing -> stringResource(R.string.stage_installing)- is InstallStage.Failed -> stringResource(R.string.stage_failed, stage.reason)-}
appstore/src/main/java/com/vayunmathur/appstore/ui/AppDetailHeader.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/ui/AppDetailHeader.kt b/appstore/src/main/java/com/vayunmathur/appstore/ui/AppDetailHeader.ktindex f4a38ffabd..57ef32cf7a 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/ui/AppDetailHeader.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/ui/AppDetailHeader.kt@@ -1,4 +1,7 @@ package com.vayunmathur.appstore.ui+import com.vayunmathur.appstore.R+import com.vayunmathur.appstore.platform.AppDetailUiState+import com.vayunmathur.appstore.platform.reason import androidx.compose.foundation.background import androidx.compose.foundation.clickable@@ -35,9 +38,7 @@ import androidx.compose.ui.semantics.semantics import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp-import com.vayunmathur.appstore.R import com.vayunmathur.appstore.data.UnifiedApp-import com.vayunmathur.appstore.util.AppDetailUiState import com.vayunmathur.library.image.compose.AsyncImage import com.vayunmathur.library.image.compose.AsyncImageState import com.vayunmathur.library.ui.CircularProgressIndicator
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 2d1a00d8a2..842ef8847e 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/ui/AppDetailPage.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/ui/AppDetailPage.kt@@ -1,14 +1,10 @@ package com.vayunmathur.appstore.ui- import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize 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.runtime.mutableStateOf import androidx.compose.runtime.remember@@ -17,11 +13,6 @@ 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.R-import com.vayunmathur.appstore.util.AppDetailActions-import com.vayunmathur.appstore.util.AppDetailUiState-import com.vayunmathur.appstore.util.AppStoreViewModel-import com.vayunmathur.appstore.util.loadDetail import com.vayunmathur.library.ui.AppBarAlignment import com.vayunmathur.library.ui.AppScaffold import com.vayunmathur.library.ui.ConfirmDialog@@ -30,6 +21,12 @@ import com.vayunmathur.library.ui.IconShare import com.vayunmathur.library.ui.R as UiR import com.vayunmathur.library.ui.Text import com.vayunmathur.library.ui.appBarScrollBehavior+import com.vayunmathur.appstore.platform.loadDetail++import androidx.compose.runtime.Composable+import androidx.compose.runtime.LaunchedEffect+import androidx.compose.runtime.collectAsState+import com.vayunmathur.appstore.platform.AppStoreViewModel /** * Binds [AppStoreViewModel] to the stateless [AppDetailScreen] for@@ -55,69 +52,3 @@ fun AppDetailPage( ) } -/**- * One app's page: what it is, what it looks like, and what installing it would mean.- *- * The previous version led with a wall of label/value rows, which is a debug dump rather- * than a listing. The order here is the order the questions actually get asked —- * screenshots, the install button, the description, then the facts, then provenance.- *- * Stateless so it can be rendered from a `@Preview` — see `src/screenshotTest`, which is- * where the store listing images come from.- */-@Composable-fun AppDetailScreen(- state: AppDetailUiState,- actions: AppDetailActions,- onBack: () -> Unit = {},- onOpenTrust: () -> Unit = {},- /** Opens the full-screen viewer at this index into `app.screenshots` (#918). */- onOpenScreenshot: (Int) -> Unit = {},-) {- val app = state.app ?: return- var showUninstallConfirm by remember { mutableStateOf(false) }-- AppScaffold(- title = { Text(app.name, maxLines = 1, overflow = TextOverflow.Ellipsis) },- onNavigateBack = onBack,- alignment = AppBarAlignment.Center,- actions = {- IconButton(onClick = { actions.shareApp(app) }) { IconShare() }- },- scrollBehavior = appBarScrollBehavior(),- ) { padding ->- Column(- Modifier- .fillMaxSize()- .padding(padding)- .verticalScroll(rememberScrollState())- .padding(bottom = 32.dp),- verticalArrangement = Arrangement.spacedBy(16.dp),- ) {- AppDetailHeader(state)- AppInstallActions(state, actions, onUninstall = { showUninstallConfirm = true })- if (app.screenshots.isNotEmpty()) {- AppScreenshotStrip(app.screenshots, app.name, onOpen = onOpenScreenshot)- }- AppDetailFacts(app)- AppDetailDescription(app)- AppDetailWhatsNew(app)- AppDetailChips(app)- AppTrustCard(app.source, state.verification, onOpenTrust)- AppDetailLinks(app, actions)- AppDetailDetails(app)- }- }-- 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/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.ktnew file mode 100644index 0000000000..7b2b0b6aba--- /dev/null+++ b/appstore/src/main/java/com/vayunmathur/appstore/ui/AppDetailScreen.kt@@ -0,0 +1,99 @@+package com.vayunmathur.appstore.ui+import com.vayunmathur.appstore.R++import com.vayunmathur.appstore.platform.AppDetailActions+import com.vayunmathur.appstore.platform.AppDetailUiState+import com.vayunmathur.appstore.platform.loadDetail+import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.fillMaxSize+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.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+import com.vayunmathur.library.ui.appBarScrollBehavior++/**+ * One app's page: what it is, what it looks like, and what installing it would mean.+ *+ * The previous version led with a wall of label/value rows, which is a debug dump rather+ * than a listing. The order here is the order the questions actually get asked —+ * screenshots, the install button, the description, then the facts, then provenance.+ *+ * Stateless so it can be rendered from a `@Preview` — see `src/screenshotTest`, which is+ * where the store listing images come from.+ */+@Composable+fun AppDetailScreen(+ state: AppDetailUiState,+ actions: AppDetailActions,+ onBack: () -> Unit = {},+ onOpenTrust: () -> Unit = {},+ /** Opens the full-screen viewer at this index into `app.screenshots` (#918). */+ onOpenScreenshot: (Int) -> Unit = {},+) {+ val app = state.app ?: return+ var showUninstallConfirm by remember { mutableStateOf(false) }++ AppScaffold(+ title = { Text(app.name, maxLines = 1, overflow = TextOverflow.Ellipsis) },+ onNavigateBack = onBack,+ alignment = AppBarAlignment.Center,+ actions = {+ IconButton(onClick = { actions.shareApp(app) }) { IconShare() }+ },+ scrollBehavior = appBarScrollBehavior(),+ ) { padding ->+ Column(+ Modifier+ .fillMaxSize()+ .padding(padding)+ .verticalScroll(rememberScrollState())+ .padding(bottom = 32.dp),+ verticalArrangement = Arrangement.spacedBy(16.dp),+ ) {+ AppDetailHeader(state)+ AppInstallActions(state, actions, onUninstall = { showUninstallConfirm = true })+ if (app.screenshots.isNotEmpty()) {+ AppScreenshotStrip(app.screenshots, app.name, onOpen = onOpenScreenshot)+ }+ AppDetailFacts(app)+ AppDetailDescription(app)+ AppDetailWhatsNew(app)+ AppDetailChips(app)+ AppTrustCard(app.source, state.verification, onOpenTrust)+ AppDetailLinks(app, actions)+ AppDetailDetails(app)+ }+ }++ 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/AppDetailSections.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/ui/AppDetailSections.kt b/appstore/src/main/java/com/vayunmathur/appstore/ui/AppDetailSections.ktindex ff2797078b..3b80f1b7a1 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/ui/AppDetailSections.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/ui/AppDetailSections.kt@@ -1,4 +1,8 @@ package com.vayunmathur.appstore.ui+import com.vayunmathur.appstore.R+import com.vayunmathur.appstore.platform.AppDetailActions+import com.vayunmathur.appstore.platform.AppDetailUiState+import com.vayunmathur.appstore.platform.reason import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column@@ -13,15 +17,12 @@ 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.library.ui.R as UiR import com.vayunmathur.appstore.data.AppSource import com.vayunmathur.appstore.data.UnifiedApp import com.vayunmathur.appstore.data.installer.InstallStage import com.vayunmathur.appstore.data.security.TrustProfile import com.vayunmathur.appstore.data.security.VerificationResult-import com.vayunmathur.appstore.util.AppDetailActions-import com.vayunmathur.appstore.util.AppDetailUiState import com.vayunmathur.library.ui.Button import com.vayunmathur.library.ui.Card import com.vayunmathur.library.ui.FilledTonalButton
appstore/src/main/java/com/vayunmathur/appstore/ui/AppIcon.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/ui/AppIcon.kt b/appstore/src/main/java/com/vayunmathur/appstore/ui/AppIcon.ktnew file mode 100644index 0000000000..70a32fdb39--- /dev/null+++ b/appstore/src/main/java/com/vayunmathur/appstore/ui/AppIcon.kt@@ -0,0 +1,96 @@+package com.vayunmathur.appstore.ui++import com.vayunmathur.appstore.platform.reason+import android.graphics.drawable.Drawable+import androidx.compose.foundation.Image+import androidx.compose.foundation.background+import androidx.compose.foundation.clickable+import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.PaddingValues+import androidx.compose.foundation.layout.Row+import androidx.compose.foundation.layout.Spacer+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.LazyRow+import androidx.compose.foundation.lazy.items+import androidx.compose.foundation.shape.RoundedCornerShape+import androidx.compose.runtime.Composable+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.draw.clip+import androidx.compose.ui.graphics.asImageBitmap+import androidx.compose.ui.layout.ContentScale+import androidx.compose.ui.res.stringResource+import androidx.compose.ui.text.font.FontWeight+import androidx.compose.ui.text.style.TextOverflow+import androidx.compose.ui.unit.Dp+import androidx.compose.ui.unit.dp+import androidx.core.graphics.drawable.toBitmap+import com.vayunmathur.appstore.data.AppSource+import com.vayunmathur.appstore.data.UnifiedApp+import com.vayunmathur.appstore.data.installer.InstallStage+import com.vayunmathur.library.image.compose.AsyncImage+import com.vayunmathur.library.ui.IconCheck+import com.vayunmathur.library.ui.IconStar+import com.vayunmathur.library.ui.LinearProgressIndicator+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.Text+import com.vayunmathur.library.ui.TextButton+import com.vayunmathur.library.util.sharedCrop+import java.util.Locale++/**+ * The icon, from whichever of the places actually has one.+ *+ * A locally installed app has a real launcher icon in PackageManager, which beats+ * re-downloading the listing's copy; a catalogue entry has a URL; a Play cluster row+ * sometimes has neither. Every screen needs the same fallback chain, so it lives here+ * rather than being written out again per call site.+ */+@Composable+fun AppIcon(+ app: UnifiedApp,+ installedIcon: Drawable?,+ modifier: Modifier = Modifier,+ size: Dp = 48.dp,+ corner: Dp = 12.dp,+) {+ val shape = RoundedCornerShape(corner)+ val box = modifier.size(size).clip(shape)+ val bitmap = installedIcon?.let {+ runCatching {+ val px = (size.value * 2).toInt().coerceAtLeast(1)+ it.toBitmap(width = px, height = px).asImageBitmap()+ }.getOrNull()+ }+ when {+ bitmap != null -> Image(+ bitmap = bitmap,+ contentDescription = null,+ modifier = box,+ contentScale = ContentScale.Crop,+ )+ app.iconUrl != null -> AsyncImage(+ model = app.iconUrl,+ contentDescription = null,+ modifier = box,+ contentScale = ContentScale.Crop,+ )+ // No icon anywhere: an initial on a tinted tile reads better than a blank hole,+ // and keeps rows the same height whether or not the artwork loaded.+ else -> Box(+ box.background(MaterialTheme.colorScheme.surfaceVariant),+ contentAlignment = Alignment.Center,+ ) {+ Text(+ app.name.take(1).uppercase(),+ style = MaterialTheme.typography.titleMedium,+ color = MaterialTheme.colorScheme.onSurfaceVariant,+ )+ }+ }+}
appstore/src/main/java/com/vayunmathur/appstore/ui/AppMeta.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/ui/AppMeta.kt b/appstore/src/main/java/com/vayunmathur/appstore/ui/AppMeta.ktindex f34f464b7b..0c21277398 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/ui/AppMeta.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/ui/AppMeta.kt@@ -1,15 +1,15 @@ package com.vayunmathur.appstore.ui+import androidx.compose.foundation.layout.padding+import androidx.compose.ui.unit.dp+import com.vayunmathur.library.ui.Card+import com.vayunmathur.library.ui.CardDefaults import androidx.compose.foundation.layout.Column-import androidx.compose.foundation.layout.padding import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextOverflow-import androidx.compose.ui.unit.dp-import com.vayunmathur.library.ui.Card-import com.vayunmathur.library.ui.CardDefaults import com.vayunmathur.library.ui.MaterialTheme import com.vayunmathur.library.ui.Text import java.util.Locale@@ -39,35 +39,6 @@ fun StatCell(label: String, value: String, modifier: Modifier = Modifier) { } } -/** A read-only chip, for categories and anti-features. */-@Composable-fun InfoChip(- text: String,- modifier: Modifier = Modifier,- emphasise: Boolean = false,-) {- Card(- modifier = modifier,- colors = CardDefaults.cardColors(- containerColor = if (emphasise) {- MaterialTheme.colorScheme.errorContainer- } else {- MaterialTheme.colorScheme.surfaceVariant- },- contentColor = if (emphasise) {- MaterialTheme.colorScheme.onErrorContainer- } else {- MaterialTheme.colorScheme.onSurfaceVariant- },- ),- ) {- Text(- text,- style = MaterialTheme.typography.labelSmall,- modifier = Modifier.padding(horizontal = 10.dp, vertical = 4.dp),- )- }-} /** "12 MB", "980 kB" — SI units, because that is what stores quote. */ fun formatSize(bytes: Long): String = when {
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.ktnew file mode 100644index 0000000000..7c54b6d0f0--- /dev/null+++ b/appstore/src/main/java/com/vayunmathur/appstore/ui/AppRoot.kt@@ -0,0 +1,166 @@+package com.vayunmathur.appstore.ui+import com.vayunmathur.appstore.R+import com.vayunmathur.appstore.Route++import com.vayunmathur.appstore.platform.AppSection+import androidx.compose.runtime.Composable+import androidx.compose.runtime.LaunchedEffect+import androidx.compose.ui.res.stringResource+import androidx.lifecycle.viewmodel.compose.viewModel+import com.vayunmathur.appstore.data.UnifiedApp+import com.vayunmathur.appstore.ui.AppDetailPage+import com.vayunmathur.appstore.ui.BrowsePage+import com.vayunmathur.appstore.ui.HomePage+import com.vayunmathur.appstore.ui.LibraryPage+import com.vayunmathur.appstore.ui.ScreenshotViewerScreen+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.platform.AppStoreViewModel+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.RouteTab+import com.vayunmathur.library.ui.TabbedPagerScaffold+import com.vayunmathur.library.util.MainNavigation+import com.vayunmathur.library.util.MorphPage+import com.vayunmathur.library.util.NavBackStack+import com.vayunmathur.library.util.SiblingPage+import com.vayunmathur.library.util.rememberNavBackStack++@Composable+fun AppRoot(+ viewModel: AppStoreViewModel,+ externalPackage: String?,+ onExternalPackageHandled: () -> Unit,+) {+ // Home is the start (and deep-link base) tab: an external package pushes+ // Detail over it, so popping Detail lands back on Home.+ val backStack = rememberNavBackStack<Route>(Route.Home)++ LaunchedEffect(externalPackage) {+ val pkg = externalPackage ?: return@LaunchedEffect+ // The route carries the package; the Detail entry loads it. No+ // ViewModel selection is set here, so a restored stack cannot show+ // a different app from the one its top entry names.+ if (backStack.last() != Route.Detail(pkg)) backStack.add(Route.Detail(pkg))+ onExternalPackageHandled()+ }++ fun openDetail(app: UnifiedApp) {+ if (backStack.last() != Route.Detail(app.packageName)) {+ backStack.add(Route.Detail(app.packageName))+ }+ }++ fun openBrowse(section: AppSection) {+ backStack.add(Route.Browse(section.id))+ }++ AppTabs(+ backStack = backStack,+ viewModel = viewModel,+ onAppClick = ::openDetail,+ onOpenBrowse = ::openBrowse,+ )+}++/**+ * The five bottom-nav tabs as sibling routes (see [TabbedPagerScaffold]'s+ * route-backed overload). Selecting a tab resets the stack to that tab, so+ * tab state is the back stack itself — visible to back, deep links and+ * process restore — and each tab entry below is registered [SiblingPage]+ * so switches crossfade instead of sliding like a push. Browse, Trust,+ * Detail and Screenshots are pushed over the tab host as ordinary routes;+ * while one is on top no tab is selected. Per-tab screen state stays in+ * the shared ViewModel (and each entry's saveable state), as with the pager.+ */+@Composable+private fun AppTabs(+ backStack: NavBackStack<Route>,+ viewModel: AppStoreViewModel,+ onAppClick: (UnifiedApp) -> Unit,+ onOpenBrowse: (AppSection) -> Unit,+) {+ val tabs = listOf<RouteTab<Route>>(+ RouteTab(Route.Home, stringResource(R.string.nav_home), { IconHome() }),+ RouteTab(Route.Search, stringResource(R.string.nav_search), { IconSearch() }),+ RouteTab(Route.Updates, stringResource(R.string.nav_updates), { IconDownload() }),+ RouteTab(Route.Library, stringResource(R.string.nav_library), { IconPackage() }),+ RouteTab(Route.Sources, stringResource(R.string.nav_sources), { IconProvider() }),+ )+ TabbedPagerScaffold(backStack = backStack, tabs = tabs) {+ MainNavigation(backStack) {+ entry<Route.Home>(metadata = SiblingPage()) {+ HomePage(+ viewModel = viewModel,+ onAppClick = onAppClick,+ // Cross-tab jump: a sibling switch, not a push.+ onOpenUpdates = { backStack.reset(Route.Updates) },+ onOpenBrowse = onOpenBrowse,+ )+ }+ entry<Route.Search>(metadata = SiblingPage()) {+ // This entry only renders while Search is on top, so the+ // page is active by construction: opening it may autofocus,+ // and a neighbour can no longer grab focus mid-swipe.+ SearchPage(+ viewModel = viewModel,+ onAppClick = onAppClick,+ isActive = true,+ )+ }+ entry<Route.Updates>(metadata = SiblingPage()) {+ UpdatesPage(viewModel = viewModel, onAppClick = onAppClick)+ }+ entry<Route.Library>(metadata = SiblingPage()) {+ LibraryPage(viewModel = viewModel, onAppClick = onAppClick)+ }+ entry<Route.Sources>(metadata = SiblingPage()) {+ SourcesPage(+ viewModel = viewModel,+ onOpenTrust = { backStack.add(Route.Trust) },+ )+ }+ entry<Route.Browse> { route ->+ BrowsePage(+ viewModel = viewModel,+ sectionId = route.sectionId,+ onAppClick = onAppClick,+ onBack = { backStack.pop() },+ )+ }+ entry<Route.Trust> {+ TrustPage(+ ownSigningCertificates = viewModel.ownSigningCertificates,+ onBack = { backStack.pop() },+ )+ }+ entry<Route.Detail>(metadata = MorphPage()) { route ->+ AppDetailPage(+ viewModel = viewModel,+ packageName = route.packageName,+ onBack = { backStack.pop() },+ onOpenTrust = { backStack.add(Route.Trust) },+ onOpenScreenshot = { index ->+ val app = viewModel.detail.value.app+ if (app != null && app.screenshots.isNotEmpty()) {+ backStack.add(Route.Screenshots(app.name, app.screenshots, index))+ }+ },+ )+ }+ entry<Route.Screenshots> { route ->+ ScreenshotViewerScreen(+ appName = route.appName,+ urls = route.urls,+ initialIndex = route.index,+ onClose = { backStack.pop() },+ )+ }+ }+ }+}
appstore/src/main/java/com/vayunmathur/appstore/ui/AppRow.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/ui/AppRow.kt b/appstore/src/main/java/com/vayunmathur/appstore/ui/AppRow.ktnew file mode 100644index 0000000000..d5d3707688--- /dev/null+++ b/appstore/src/main/java/com/vayunmathur/appstore/ui/AppRow.kt@@ -0,0 +1,130 @@+package com.vayunmathur.appstore.ui++import com.vayunmathur.appstore.platform.reason+import android.graphics.drawable.Drawable+import androidx.compose.foundation.Image+import androidx.compose.foundation.background+import androidx.compose.foundation.clickable+import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.PaddingValues+import androidx.compose.foundation.layout.Row+import androidx.compose.foundation.layout.Spacer+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.LazyRow+import androidx.compose.foundation.lazy.items+import androidx.compose.foundation.shape.RoundedCornerShape+import androidx.compose.runtime.Composable+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.draw.clip+import androidx.compose.ui.graphics.asImageBitmap+import androidx.compose.ui.layout.ContentScale+import androidx.compose.ui.res.stringResource+import androidx.compose.ui.text.font.FontWeight+import androidx.compose.ui.text.style.TextOverflow+import androidx.compose.ui.unit.Dp+import androidx.compose.ui.unit.dp+import androidx.core.graphics.drawable.toBitmap+import com.vayunmathur.appstore.data.AppSource+import com.vayunmathur.appstore.data.UnifiedApp+import com.vayunmathur.appstore.data.installer.InstallStage+import com.vayunmathur.library.image.compose.AsyncImage+import com.vayunmathur.library.ui.IconCheck+import com.vayunmathur.library.ui.IconStar+import com.vayunmathur.library.ui.LinearProgressIndicator+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.Text+import com.vayunmathur.library.ui.TextButton+import com.vayunmathur.library.util.sharedCrop+import java.util.Locale++/**+ * A full-width list row: icon, name, summary, and whatever the caller puts on the right.+ *+ * [stage] draws its own progress bar underneath, so a row that is mid-install says which+ * part of the install it is in rather than showing a bar that sits at 100% through+ * verification and commit.+ */+@Composable+fun AppRow(+ app: UnifiedApp,+ modifier: Modifier = Modifier,+ isInstalled: Boolean = false,+ stage: InstallStage? = null,+ installedIcon: Drawable? = null,+ versionLabel: String? = null,+ /**+ * Non-null makes this row the origin of the [sharedCrop] container transform into the app's+ * detail page. Null for a row that is a second copy of an app already shown elsewhere on+ * screen - the morph cannot choose between two origins for one destination.+ */+ sharedKey: Any? = null,+ onClick: () -> Unit = {},+ trailing: @Composable (() -> Unit)? = null,+) {+ Column(+ modifier+ .then(if (sharedKey == null) Modifier else Modifier.sharedCrop(sharedKey))+ .fillMaxWidth()+ .clickable(onClick = onClick)+ .padding(horizontal = 16.dp, vertical = 10.dp),+ ) {+ Row(verticalAlignment = Alignment.CenterVertically) {+ AppIcon(app, installedIcon, size = 48.dp)+ Spacer(Modifier.width(14.dp))+ Column(Modifier.weight(1f)) {+ Text(+ app.name,+ style = MaterialTheme.typography.titleSmall,+ fontWeight = FontWeight.SemiBold,+ maxLines = 1,+ overflow = TextOverflow.Ellipsis,+ )+ val subtitle = app.summary.ifBlank { app.author.orEmpty() }+ if (subtitle.isNotBlank()) {+ Text(+ subtitle,+ style = MaterialTheme.typography.bodySmall,+ color = MaterialTheme.colorScheme.onSurfaceVariant,+ maxLines = 2,+ overflow = TextOverflow.Ellipsis,+ )+ }+ Row(+ Modifier.padding(top = 2.dp),+ verticalAlignment = Alignment.CenterVertically,+ horizontalArrangement = Arrangement.spacedBy(6.dp),+ ) {+ SourceChip(app.source)+ RatingLabel(app)+ if (isInstalled) {+ IconCheck(Modifier.size(12.dp), tint = MaterialTheme.colorScheme.primary)+ }+ }+ if (versionLabel != null) {+ Text(+ versionLabel,+ style = MaterialTheme.typography.labelSmall,+ color = MaterialTheme.colorScheme.onSurfaceVariant,+ // Old and new versions share one "a (1) → b (2)" line, and long+ // version names ellipsized the tail — the new code — away (#813).+ // Two lines keeps both codes visible.+ maxLines = 2,+ overflow = TextOverflow.Ellipsis,+ modifier = Modifier.padding(top = 2.dp),+ )+ }+ }+ if (trailing != null) {+ Spacer(Modifier.width(8.dp))+ trailing()+ }+ }+ StageProgress(stage, Modifier.padding(top = 8.dp))+ }+}
appstore/src/main/java/com/vayunmathur/appstore/ui/AppTile.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/ui/AppTile.kt b/appstore/src/main/java/com/vayunmathur/appstore/ui/AppTile.ktindex 9f56f01081..8efc7956dc 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/ui/AppTile.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/ui/AppTile.kt@@ -1,4 +1,5 @@ package com.vayunmathur.appstore.ui+import com.vayunmathur.appstore.R import android.graphics.drawable.Drawable import androidx.compose.foundation.clickable@@ -21,7 +22,6 @@ import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp-import com.vayunmathur.appstore.R import com.vayunmathur.appstore.data.UnifiedApp import com.vayunmathur.appstore.data.installer.InstallStage import com.vayunmathur.library.ui.MaterialTheme
appstore/src/main/java/com/vayunmathur/appstore/ui/BrowsePage.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/ui/BrowsePage.kt b/appstore/src/main/java/com/vayunmathur/appstore/ui/BrowsePage.ktindex 479c64383b..3b58478ec7 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/ui/BrowsePage.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/ui/BrowsePage.kt@@ -1,30 +1,28 @@ package com.vayunmathur.appstore.ui- import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items-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.unit.dp-import com.vayunmathur.appstore.R-import com.vayunmathur.appstore.data.UnifiedApp-import com.vayunmathur.appstore.util.AppStoreViewModel-import com.vayunmathur.appstore.util.BrowseUiState-import com.vayunmathur.appstore.util.loadBrowse import com.vayunmathur.library.ui.AppBarAlignment import com.vayunmathur.library.ui.AppScaffold import com.vayunmathur.library.ui.CircularProgressIndicator import com.vayunmathur.library.ui.EmptyState import com.vayunmathur.library.ui.IconSearch import com.vayunmathur.library.ui.appBarScrollBehavior+import com.vayunmathur.appstore.platform.loadBrowse++import androidx.compose.runtime.Composable+import androidx.compose.runtime.LaunchedEffect+import androidx.compose.runtime.collectAsState+import com.vayunmathur.appstore.data.UnifiedApp+import com.vayunmathur.appstore.platform.AppStoreViewModel /** * Binds [AppStoreViewModel] to the stateless [BrowseScreen] for the section@@ -47,64 +45,3 @@ fun BrowsePage( ) } -/**- * One home section's full catalogue as a vertical list.- *- * A home carousel shows a capped slice — the 20 newest builds, the first 20 tiles.- * This page lists literally every app behind that section, A–Z, in the same- * [AppRow] the search page uses.- *- * Stateless so it can be rendered from a `@Preview` — see `src/screenshotTest`,- * which is where the store listing images come from.- */-@Composable-fun BrowseScreen(- state: BrowseUiState,- onAppClick: (UnifiedApp) -> Unit = {},- onBack: () -> Unit = {},-) {- AppScaffold(- title = state.title,- onNavigateBack = onBack,- alignment = AppBarAlignment.Start,- scrollBehavior = appBarScrollBehavior(),- ) { padding ->- when {- state.isLoading && state.apps.isEmpty() -> Box(- Modifier.fillMaxSize().padding(padding),- contentAlignment = Alignment.Center,- ) {- CircularProgressIndicator()- }-- state.apps.isEmpty() -> EmptyState(- title = stringResource(R.string.browse_empty_title),- message = stringResource(R.string.browse_empty_message),- icon = { IconSearch() },- modifier = Modifier.padding(padding),- )-- else -> LazyColumn(- Modifier.fillMaxSize().padding(padding),- contentPadding = PaddingValues(bottom = 24.dp),- ) {- // Morph ownership mirrors the home screen: the browse page and home are- // never composed at the same time (pushed route), so this list owns the- // morph for every app while it is on screen.- items(- state.apps,- key = { 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 = "appstore-app-${app.packageName}",- )- }- }- }- }-}
appstore/src/main/java/com/vayunmathur/appstore/ui/BrowseScreen.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/ui/BrowseScreen.kt b/appstore/src/main/java/com/vayunmathur/appstore/ui/BrowseScreen.ktnew file mode 100644index 0000000000..768da722a0--- /dev/null+++ b/appstore/src/main/java/com/vayunmathur/appstore/ui/BrowseScreen.kt@@ -0,0 +1,89 @@+package com.vayunmathur.appstore.ui+import com.vayunmathur.appstore.R++import com.vayunmathur.appstore.platform.BrowseUiState+import com.vayunmathur.appstore.platform.loadBrowse+import androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.PaddingValues+import androidx.compose.foundation.layout.fillMaxSize+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.lazy.LazyColumn+import androidx.compose.foundation.lazy.items+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.unit.dp+import com.vayunmathur.appstore.data.UnifiedApp+import com.vayunmathur.appstore.platform.AppStoreViewModel+import com.vayunmathur.library.ui.AppBarAlignment+import com.vayunmathur.library.ui.AppScaffold+import com.vayunmathur.library.ui.CircularProgressIndicator+import com.vayunmathur.library.ui.EmptyState+import com.vayunmathur.library.ui.IconSearch+import com.vayunmathur.library.ui.appBarScrollBehavior++/**+ * One home section's full catalogue as a vertical list.+ *+ * A home carousel shows a capped slice — the 20 newest builds, the first 20 tiles.+ * This page lists literally every app behind that section, A–Z, in the same+ * [AppRow] the search page uses.+ *+ * Stateless so it can be rendered from a `@Preview` — see `src/screenshotTest`,+ * which is where the store listing images come from.+ */+@Composable+fun BrowseScreen(+ state: BrowseUiState,+ onAppClick: (UnifiedApp) -> Unit = {},+ onBack: () -> Unit = {},+) {+ AppScaffold(+ title = state.title,+ onNavigateBack = onBack,+ alignment = AppBarAlignment.Start,+ scrollBehavior = appBarScrollBehavior(),+ ) { padding ->+ when {+ state.isLoading && state.apps.isEmpty() -> Box(+ Modifier.fillMaxSize().padding(padding),+ contentAlignment = Alignment.Center,+ ) {+ CircularProgressIndicator()+ }++ state.apps.isEmpty() -> EmptyState(+ title = stringResource(R.string.browse_empty_title),+ message = stringResource(R.string.browse_empty_message),+ icon = { IconSearch() },+ modifier = Modifier.padding(padding),+ )++ else -> LazyColumn(+ Modifier.fillMaxSize().padding(padding),+ contentPadding = PaddingValues(bottom = 24.dp),+ ) {+ // Morph ownership mirrors the home screen: the browse page and home are+ // never composed at the same time (pushed route), so this list owns the+ // morph for every app while it is on screen.+ items(+ state.apps,+ key = { 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 = "appstore-app-${app.packageName}",+ )+ }+ }+ }+ }+}
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 c24680cf24..087ba869c3 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/ui/HomePage.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/ui/HomePage.kt@@ -1,48 +1,45 @@ package com.vayunmathur.appstore.ui+import com.vayunmathur.appstore.R+import androidx.compose.foundation.layout.fillMaxSize+import androidx.compose.foundation.lazy.LazyColumn+import androidx.compose.runtime.getValue+import androidx.compose.runtime.remember+import com.vayunmathur.library.ui.AppPullToRefreshBox+import com.vayunmathur.library.ui.EmptyState+import com.vayunmathur.library.ui.IconPackage+import com.vayunmathur.library.ui.Scaffold+import com.vayunmathur.appstore.platform.AppSection import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.PaddingValues 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.layout.size import androidx.compose.foundation.layout.width-import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyRow import androidx.compose.foundation.lazy.items import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.collectAsState-import androidx.compose.runtime.getValue-import androidx.compose.runtime.remember import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.res.pluralStringResource 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.UnifiedApp-import com.vayunmathur.appstore.util.AppSection-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.AppPullToRefreshBox+import com.vayunmathur.appstore.platform.AppStoreViewModel 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.IconChevronRight import com.vayunmathur.library.ui.IconDownload-import com.vayunmathur.library.ui.IconPackage import com.vayunmathur.library.ui.MaterialTheme-import com.vayunmathur.library.ui.Scaffold import com.vayunmathur.library.ui.Text /** Binds [AppStoreViewModel] to the stateless [HomeScreen]. */@@ -69,130 +66,9 @@ fun HomePage( ) } -/**- * The store front: a few curated rows rather than one undifferentiated list.- *- * The rows come from three places and are deliberately labelled as such — this repo's own- * apps, Play's editorial clusters, and F-Droid's newest reproduced builds. Which source a- * row comes from is information, not a verdict; see- * [com.vayunmathur.appstore.data.security.TrustProfile].- *- * Stateless so it can be rendered from a `@Preview` — see `src/screenshotTest`, which is- * where the store listing images come from.- */-@Composable-fun HomeScreen(- state: HomeUiState,- actions: HomeActions,- onAppClick: (UnifiedApp) -> Unit = {},- onOpenUpdates: () -> Unit = {},- onOpenBrowse: (AppSection) -> Unit = {},-) {- Scaffold { padding ->- AppPullToRefreshBox(- isRefreshing = state.isSyncing,- onRefresh = { actions.refresh() },- modifier = Modifier.fillMaxSize(),- topClearance = padding.calculateTopPadding(),- ) {- // 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),- ) {- if (state.isSyncing || state.statusMessage.isNotBlank()) {- item("status") { StatusLine(state.statusMessage, state.isSyncing) }- }-- if (state.updateCount > 0) {- item("updates") { UpdatesBanner(state.updateCount, onOpenUpdates) }- }-- if (state.categories.isNotEmpty()) {- item("categories") {- CategoryRow(- categories = state.categories,- selected = state.selectedCategory,- onSelect = actions::selectCategory,- )- }- }-- 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),- )- }- }- }-- state.sections.forEach { section ->- item("${section.id}-header") {- SectionHeader(- title = section.title,- subtitle = section.subtitle,- actionLabel = stringResource(R.string.action_browse),- onAction = { onOpenBrowse(section) },- )- }- if (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) },- )- }- } else {- 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),- )- }- }- }- }- }- }-} @Composable-private fun StatusLine(message: String, isSyncing: Boolean) {+internal fun StatusLine(message: String, isSyncing: Boolean) { Row( Modifier.fillMaxWidth().padding(horizontal = 16.dp, vertical = 6.dp), verticalAlignment = Alignment.CenterVertically,@@ -210,7 +86,7 @@ private fun StatusLine(message: String, isSyncing: Boolean) { } @Composable-private fun UpdatesBanner(count: Int, onClick: () -> Unit) {+internal fun UpdatesBanner(count: Int, onClick: () -> Unit) { Card( onClick = onClick, modifier = Modifier.fillMaxWidth().padding(horizontal = 16.dp, vertical = 4.dp),@@ -242,7 +118,7 @@ private fun UpdatesBanner(count: Int, onClick: () -> Unit) { } @Composable-private fun CategoryRow(+internal fun CategoryRow( categories: List<String>, selected: String?, onSelect: (String?) -> Unit,@@ -270,7 +146,7 @@ private fun CategoryRow( } @Composable-private fun LoadingRow() {+internal fun LoadingRow() { Row( Modifier.fillMaxWidth().height(160.dp), horizontalArrangement = Arrangement.Center,
appstore/src/main/java/com/vayunmathur/appstore/ui/HomeScreen.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/ui/HomeScreen.kt b/appstore/src/main/java/com/vayunmathur/appstore/ui/HomeScreen.ktnew file mode 100644index 0000000000..1d7ae4db38--- /dev/null+++ b/appstore/src/main/java/com/vayunmathur/appstore/ui/HomeScreen.kt@@ -0,0 +1,168 @@+package com.vayunmathur.appstore.ui+import com.vayunmathur.appstore.R++import com.vayunmathur.appstore.platform.AppSection+import com.vayunmathur.appstore.platform.HomeActions+import com.vayunmathur.appstore.platform.HomeUiState+import com.vayunmathur.appstore.platform.SectionLayout+import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.PaddingValues+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.layout.size+import androidx.compose.foundation.layout.width+import androidx.compose.foundation.lazy.LazyColumn+import androidx.compose.foundation.lazy.LazyRow+import androidx.compose.foundation.lazy.items+import androidx.compose.runtime.Composable+import androidx.compose.runtime.LaunchedEffect+import androidx.compose.runtime.collectAsState+import androidx.compose.runtime.getValue+import androidx.compose.runtime.remember+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.res.pluralStringResource+import androidx.compose.ui.res.stringResource+import androidx.compose.ui.text.font.FontWeight+import androidx.compose.ui.unit.dp+import com.vayunmathur.appstore.data.UnifiedApp+import com.vayunmathur.appstore.platform.AppStoreViewModel+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.IconChevronRight+import com.vayunmathur.library.ui.IconDownload+import com.vayunmathur.library.ui.IconPackage+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.AppScaffold+import com.vayunmathur.library.ui.Text++/**+ * The store front: a few curated rows rather than one undifferentiated list.+ *+ * The rows come from three places and are deliberately labelled as such — this repo's own+ * apps, Play's editorial clusters, and F-Droid's newest reproduced builds. Which source a+ * row comes from is information, not a verdict; see+ * [com.vayunmathur.appstore.data.security.TrustProfile].+ *+ * Stateless so it can be rendered from a `@Preview` — see `src/screenshotTest`, which is+ * where the store listing images come from.+ */+@Composable+fun HomeScreen(+ state: HomeUiState,+ actions: HomeActions,+ onAppClick: (UnifiedApp) -> Unit = {},+ onOpenUpdates: () -> Unit = {},+ onOpenBrowse: (AppSection) -> Unit = {},+) {+ AppScaffold(topBar = {}) { padding ->+ AppPullToRefreshBox(+ isRefreshing = state.isSyncing,+ onRefresh = { actions.refresh() },+ modifier = Modifier.fillMaxSize(),+ topClearance = padding.calculateTopPadding(),+ ) {+ // 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),+ ) {+ if (state.isSyncing || state.statusMessage.isNotBlank()) {+ item("status") { StatusLine(state.statusMessage, state.isSyncing) }+ }++ if (state.updateCount > 0) {+ item("updates") { UpdatesBanner(state.updateCount, onOpenUpdates) }+ }++ if (state.categories.isNotEmpty()) {+ item("categories") {+ CategoryRow(+ categories = state.categories,+ selected = state.selectedCategory,+ onSelect = actions::selectCategory,+ )+ }+ }++ 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),+ )+ }+ }+ }++ state.sections.forEach { section ->+ item("${section.id}-header") {+ SectionHeader(+ title = section.title,+ subtitle = section.subtitle,+ actionLabel = stringResource(R.string.action_browse),+ onAction = { onOpenBrowse(section) },+ )+ }+ if (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) },+ )+ }+ } else {+ 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/InfoChip.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/ui/InfoChip.kt b/appstore/src/main/java/com/vayunmathur/appstore/ui/InfoChip.ktnew file mode 100644index 0000000000..9953b93f12--- /dev/null+++ b/appstore/src/main/java/com/vayunmathur/appstore/ui/InfoChip.kt@@ -0,0 +1,45 @@+package com.vayunmathur.appstore.ui++import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.padding+import androidx.compose.runtime.Composable+import androidx.compose.ui.Modifier+import androidx.compose.ui.text.font.FontWeight+import androidx.compose.ui.text.style.TextAlign+import androidx.compose.ui.text.style.TextOverflow+import androidx.compose.ui.unit.dp+import com.vayunmathur.library.ui.Card+import com.vayunmathur.library.ui.CardDefaults+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.Text+import java.util.Locale++/** A read-only chip, for categories and anti-features. */+@Composable+fun InfoChip(+ text: String,+ modifier: Modifier = Modifier,+ emphasise: Boolean = false,+) {+ Card(+ modifier = modifier,+ colors = CardDefaults.cardColors(+ containerColor = if (emphasise) {+ MaterialTheme.colorScheme.errorContainer+ } else {+ MaterialTheme.colorScheme.surfaceVariant+ },+ contentColor = if (emphasise) {+ MaterialTheme.colorScheme.onErrorContainer+ } else {+ MaterialTheme.colorScheme.onSurfaceVariant+ },+ ),+ ) {+ Text(+ text,+ style = MaterialTheme.typography.labelSmall,+ modifier = Modifier.padding(horizontal = 10.dp, vertical = 4.dp),+ )+ }+}
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 1ad47759db..51c6405a02 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/ui/LibraryPage.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/ui/LibraryPage.kt@@ -1,5 +1,4 @@ package com.vayunmathur.appstore.ui- import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.PaddingValues@@ -9,24 +8,21 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyRow import androidx.compose.foundation.lazy.items-import androidx.compose.runtime.Composable-import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp-import com.vayunmathur.appstore.R-import com.vayunmathur.appstore.data.UnifiedApp-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.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 androidx.compose.runtime.Composable+import androidx.compose.runtime.collectAsState+import com.vayunmathur.appstore.data.UnifiedApp+import com.vayunmathur.appstore.platform.AppStoreViewModel+ /** Binds [AppStoreViewModel] to the stateless [LibraryScreen]. */ @Composable fun LibraryPage(viewModel: AppStoreViewModel, onAppClick: (UnifiedApp) -> Unit) {@@ -34,64 +30,3 @@ fun LibraryPage(viewModel: AppStoreViewModel, onAppClick: (UnifiedApp) -> Unit) LibraryScreen(state = state, actions = viewModel, onAppClick = onAppClick) } -/**- * Every app installed on the device, grouped by which source offers it.- *- * Uninstall lives only on an app's own page — a delete button next to every row in a long- * list is too easy to hit by accident.- */-@Composable-fun LibraryScreen(- state: LibraryUiState,- actions: LibraryActions,- onAppClick: (UnifiedApp) -> Unit = {},-) {- Scaffold { pad
Diff truncated.