StreamVault is a TV-first free IPTV player for Android TV built with Kotlin, Jetpack Compose, Room, Hilt, and Media3.
Kotlin iptv-player
fix(downloads): keep focus on Clear cache while it clears
Rickc5c71d6950dc
diff --git a/feature/system/src/androidTest/java/com/streamvault/feature/system/DownloadsRemoteNavigationTest.kt b/feature/system/src/androidTest/java/com/streamvault/feature/system/DownloadsRemoteNavigationTest.ktindex eefc14d8..96fb6738 100644--- a/feature/system/src/androidTest/java/com/streamvault/feature/system/DownloadsRemoteNavigationTest.kt+++ b/feature/system/src/androidTest/java/com/streamvault/feature/system/DownloadsRemoteNavigationTest.kt@@ -155,6 +155,43 @@ class DownloadsRemoteNavigationTest {composeRule.onNode(hasText("Delete") and hasClickAction() and isFocused()).assertExists()}+ @Test+ fun clearCacheKeepsFocusWhileClearing() {+ var clearing by mutableStateOf(false)+ var clears = 0+ composeRule.setContent {+ StreamVaultTheme {+ MaterialTheme {+ DownloadsContent(+ uiState = DownloadsUiState(+ isLoading = false,+ torrentCacheStatus = TorrentCacheStatus(0, 8_000_000_000, 20_000_000_000, 0),+ isClearingTorrentCache = clearing+ ),+ scaffold = scaffoldWithMenu,+ onChangeFolder = {},+ onOpen = {},+ onResume = {},+ onDelete = {},+ onConfirmDelete = {},+ onDismissDelete = {},+ onClearTorrentCache = { clears++ },+ )+ }+ }+ }+ focus("Clear cache")++ clearing = true+ composeRule.waitForIdle()+ press(Key.Enter) // ignored while clearing+ clearing = false+ composeRule.waitForIdle()++ composeRule.onNode(hasText("Clear cache") and hasClickAction()).assertIsFocused()+ assertThat(clears).isEqualTo(0)+ }+private var downloads by mutableStateOf(emptyList<DownloadItem>())private var confirmItem by mutableStateOf<DownloadItem?>(null)diff --git a/feature/system/src/main/java/com/streamvault/feature/system/presentation/downloads/DownloadsScreen.kt b/feature/system/src/main/java/com/streamvault/feature/system/presentation/downloads/DownloadsScreen.ktindex 16334d77..ba27583f 100644--- a/feature/system/src/main/java/com/streamvault/feature/system/presentation/downloads/DownloadsScreen.kt+++ b/feature/system/src/main/java/com/streamvault/feature/system/presentation/downloads/DownloadsScreen.kt@@ -299,9 +299,11 @@ private fun TorrentCacheCard()}}+ // Stays enabled while clearing (presses are ignored): a disabled button loses the remote's focus, which+ // would jump to the top menu.Button(- onClick = onClear,- enabled = status != null && status.activeSessionCount == 0 && !isClearing,+ onClick = { if (!isClearing) onClear() },+ enabled = status != null && status.activeSessionCount == 0,modifier = Modifier.align(Alignment.End)) {if (isClearing) {