Modern Apps git

← Modern-Apps.git

appstore: show installed and new version in updates list (#630)

Commit
b2882a648b095e8431c6c480dfc094e72cd9773d
Author
vayun-mathur <[email protected]>
When
2026-08-31 17:00 UTC (3 months ago)
Parents
fe4267f

Diff

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 db04181872..93cf40d8ee 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/ui/AppComponents.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/ui/AppComponents.kt@@ -150,6 +150,7 @@ fun AppRow(     isInstalled: Boolean = false,     stage: InstallStage? = null,     installedIcon: Drawable? = null,+    versionLabel: String? = null,     onClick: () -> Unit = {},     trailing: @Composable (() -> Unit)? = null, ) {@@ -191,6 +192,16 @@ fun AppRow(                         IconCheck(Modifier.size(12.dp), tint = MaterialTheme.colorScheme.primary)                     }                 }+                if (versionLabel != null) {+                    Text(+                        versionLabel,+                        style = MaterialTheme.typography.labelSmall,+                        color = MaterialTheme.colorScheme.onSurfaceVariant,+                        maxLines = 1,+                        overflow = TextOverflow.Ellipsis,+                        modifier = Modifier.padding(top = 2.dp),+                    )+                }             }             if (trailing != null) {                 Spacer(Modifier.width(8.dp))
appstore/src/main/java/com/vayunmathur/appstore/ui/UpdatesPage.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/ui/UpdatesPage.kt b/appstore/src/main/java/com/vayunmathur/appstore/ui/UpdatesPage.ktindex 3cec42fece..6818431e30 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/ui/UpdatesPage.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/ui/UpdatesPage.kt@@ -138,11 +138,20 @@ fun UpdatesScreen(                     }                     items(state.updates, key = { it.packageName }) { app ->                         val stage = state.stages[app.packageName]+                        val installed = state.installedInfos[app.packageName]+                        val versionLabel = installed?.let { info ->+                            val old = info.versionName?.let { "$it (${info.versionCode})" }+                                ?: info.versionCode.toString()+                            val new = app.versionName?.let { "$it (${app.versionCode})" }+                                ?: app.versionCode.toString()+                            stringResource(R.string.version_update, old, new)+                        }                         AppRow(                             app = app,                             isInstalled = true,                             stage = stage,                             installedIcon = state.installedIcons[app.packageName],+                            versionLabel = versionLabel,                             onClick = { onAppClick(app) },                             trailing = {                                 Button(
appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreUiContract.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreUiContract.kt b/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreUiContract.ktindex 9d6c025a00..c9aed53c46 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreUiContract.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreUiContract.kt@@ -99,6 +99,8 @@ data class AppDetailUiState( data class UpdatesUiState(     val updates: List<UnifiedApp> = emptyList(),     val installedIcons: Map<String, Drawable> = emptyMap(),+    /** Currently-installed info per package, so the row can show old โ†’ new versions. */+    val installedInfos: Map<String, InstalledInfo> = emptyMap(),     val stages: Map<String, InstallStage> = emptyMap(),     val isChecking: Boolean = false,     /** ms since epoch of the last completed check, 0 if never. */
appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreViewModel.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreViewModel.kt b/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreViewModel.ktindex 224259fa28..12defcbdad 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreViewModel.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreViewModel.kt@@ -253,6 +253,7 @@ class AppStoreViewModel(         UpdatesUiState(             updates = list,             installedIcons = rows.icons,+            installedInfos = rows.installed.associateBy { it.packageName },             stages = rows.stages,             isChecking = checking,             lastCheckedAt = checkedAt,
appstore/src/main/res/values/strings.xml
diff --git a/appstore/src/main/res/values/strings.xml b/appstore/src/main/res/values/strings.xmlindex 72d3b78f1f..b25519e2a4 100644--- a/appstore/src/main/res/values/strings.xml+++ b/appstore/src/main/res/values/strings.xml@@ -122,6 +122,8 @@     <string name="fact_size">Size</string>     <string name="fact_rated">Rated</string>     <string name="fact_version">Version</string>+    <!-- Updates list: shows the currently-installed version and the new one, e.g. "1.2 (3) โ†’ 1.3 (4)" -->+    <string name="version_update">%1$s โ†’ %2$s</string>     <string name="detail_whats_new">What\'s new</string>     <string name="detail_package">Package</string>     <string name="detail_license">License</string>