From 9c0f87a4c88f4d2f0d6274425c1142a6c981e2b8 Mon Sep 17 00:00:00 2001 From: The412Banner Date: Thu, 8 Oct 2026 17:12:40 -0400 Subject: [PATCH] Stores: a finished install rebuilds the Installed tab and the Games list --- app/src/main/java/com/droiddeck/launcher/MainActivity.kt | 6 +++++- .../java/com/droiddeck/launcher/stores/StoresState.kt | 9 +++++++++ .../droiddeck/launcher/stores/download/DownloadQueue.kt | 7 ++++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/droiddeck/launcher/MainActivity.kt b/app/src/main/java/com/droiddeck/launcher/MainActivity.kt index 7eac9cb1dd..3758034f79 100644 --- a/app/src/main/java/com/droiddeck/launcher/MainActivity.kt +++ b/app/src/main/java/com/droiddeck/launcher/MainActivity.kt @@ -922,8 +922,10 @@ class MainActivity : ComponentActivity() { override fun onResume() { super.onResume() refreshWifiDiscovery() - // Back from a store's sign-in page: the Stores chips show the account at once. + // Back from a store's sign-in page: the Stores chips show the account at once. A store + // install finishing while this screen is up rebuilds the Games list through the listener. if (gameStoresEnabled) com.droiddeck.launcher.stores.StoresState.refresh(this) + com.droiddeck.launcher.stores.StoresState.libraryListener = { refreshAddedGames(); refresh() } com.droiddeck.launcher.ui.Motion.refresh(this) // Back from a session stopped behind a flood: open on its blue, before the first frame. com.droiddeck.launcher.ui.QuitFlood.take()?.let { c -> @@ -981,6 +983,8 @@ class MainActivity : ComponentActivity() { unregisterReceiver(wifiLocationReceiver) unregisterReceiver(mediaReceiver) ui.removeCallbacks(mediaRefresh) + // An install finishing while this screen is away is picked up by onResume's refresh. + com.droiddeck.launcher.stores.StoresState.libraryListener = null displayManager.unregisterDisplayListener(secondScreenDisplayListener) // The session covers the page by now; coming back finds it as it was. flood = null diff --git a/app/src/main/java/com/droiddeck/launcher/stores/StoresState.kt b/app/src/main/java/com/droiddeck/launcher/stores/StoresState.kt index b8db7ea786..6be1397a72 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/StoresState.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/StoresState.kt @@ -129,6 +129,15 @@ object StoresState { }, "stores-uninstall").start() } + /** Told on the main thread when an install or removal changed what is on disk; the launcher rebuilds its Games list. */ + @Volatile var libraryListener: (() -> Unit)? = null + + /** A game landed or went: the installed set is re-read and the launcher told. Any thread. */ + fun notifyLibraryChanged(context: Context) { + refresh(context) + main.post { libraryListener?.invoke() } + } + /** Appends to the engine log with a clock, keeping the last 80 lines. Any thread. */ fun logLine(text: String) { val stamped = "${CLOCK.format(Date())} $text" diff --git a/app/src/main/java/com/droiddeck/launcher/stores/download/DownloadQueue.kt b/app/src/main/java/com/droiddeck/launcher/stores/download/DownloadQueue.kt index 93266dbcf8..dc5dc146c0 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/download/DownloadQueue.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/download/DownloadQueue.kt @@ -207,8 +207,13 @@ object DownloadQueue { publishLocked() } when (item.entry.state) { - DownloadState.INSTALLED -> StoresState.logLine("installed \"${item.entry.name}\" → ${result}") + DownloadState.INSTALLED -> { + StoresState.logLine("installed \"${item.entry.name}\" → ${result}") + // The folder is on disk and registered: the Installed tab and the Games list follow. + StoresState.notifyLibraryChanged(context) + } DownloadState.FAILED -> StoresState.logLine("${item.entry.store.label}: \"${item.entry.name}\" failed: $error") + DownloadState.CANCELLED -> StoresState.notifyLibraryChanged(context) else -> {} } StoreDownloadService.finish(context, item.entry.key)