From 8b975c77ce441e498270263f19429e2997406371 Mon Sep 17 00:00:00 2001 From: kalarina Date: Sun, 25 Oct 2026 12:28:15 +0200 Subject: [PATCH] Show the last app list at once when the Apps tab opens again The list is still reloaded in the background on every visit; it no longer starts from the loading placeholder each time. --- app/src/main/java/cc/skysparkle/sparkledns/AppsScreen.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/cc/skysparkle/sparkledns/AppsScreen.kt b/app/src/main/java/cc/skysparkle/sparkledns/AppsScreen.kt index 9356a6d..9a080cf 100644 --- a/app/src/main/java/cc/skysparkle/sparkledns/AppsScreen.kt +++ b/app/src/main/java/cc/skysparkle/sparkledns/AppsScreen.kt @@ -80,6 +80,10 @@ private class AppItem(val label: String, val packageName: String, val group: App // Decoded icons survive scrolling and tab switches instead of being rendered again every time private val IconCache = LruCache(256) +// Shown right away when the tab opens again, while the list is read anew in the background. +// Only touched on the main thread. +private var lastAppList: List? = null + @Composable fun AppsScreen(modifier: Modifier = Modifier) { val context = LocalContext.current @@ -87,7 +91,7 @@ fun AppsScreen(modifier: Modifier = Modifier) { val active by DohVpnService.active.collectAsStateWithLifecycle() val activeExcluded by DohVpnService.activeExcluded.collectAsStateWithLifecycle() - var apps by remember { mutableStateOf?>(null) } + var apps by remember { mutableStateOf(lastAppList) } var excluded by remember { mutableStateOf(prefs.excludedApps) } var search by rememberSaveable { mutableStateOf("") } var collapsed by remember { mutableStateOf(setOf(AppGroup.SYSTEM)) } @@ -100,7 +104,7 @@ fun AppsScreen(modifier: Modifier = Modifier) { val searching = search.isNotBlank() LaunchedEffect(Unit) { - apps = withContext(Dispatchers.IO) { loadApps(context) } + apps = withContext(Dispatchers.IO) { loadApps(context) }.also { lastAppList = it } } val groups = remember(apps, search) {