Skip to content

Debloat your Android TV, install apps, browse and transfer files on it, all from your phone. Just 3 MB, no tracking, no root, no PC.

Grey out app rows and show the Files-style empty state while the TV is away

jesse-agent-23256a8776b2840
diff --git a/app/src/main/java/app/tellyscope/ui/DeviceScreen.kt b/app/src/main/java/app/tellyscope/ui/DeviceScreen.kt
index 5a73e43..422ac95 100644
--- a/app/src/main/java/app/tellyscope/ui/DeviceScreen.kt
+++ b/app/src/main/java/app/tellyscope/ui/DeviceScreen.kt
@@ -410,11 +410,13 @@ internal fun AppRow(
locked: Boolean = false,
/** Opens the Home screen card in Tweaks, where launchers are switched. */
toHomeScreen: () -> Unit = {},
+ /** The TV is away: what the row last heard is stale, so it greys out, says nothing and won't open. */
+ offline: Boolean = false,
) {
var open by rememberSaveable(app.packageName) { mutableStateOf(false) }
// A launcher can be protected and still open, for the way to the Home screen card.
val launcher = app.answersHome || app.builtInLauncher
- val changeable = app.protectedReason == null || launcher
+ val changeable = (app.protectedReason == null || launcher) && !offline
val ram = procs.filter { it.packageName == app.packageName }.sumOf { it.ramMb }
val status = stringResource(
when {
@@ -423,20 +425,22 @@ internal fun AppRow(
else -> R.string.device_app_not_running
},
)
- Column(Modifier.fillMaxWidth().clip(MaterialTheme.shapes.large).clickable(enabled = changeable) { open = !open }.padding(vertical = 8.dp)) {
+ Column(Modifier.fillMaxWidth().clip(MaterialTheme.shapes.large).clickable(enabled = changeable) { open = !open }.padding(vertical = 8.dp).alpha(if (offline) 0.38f else 1f)) {
Row(verticalAlignment = Alignment.CenterVertically) {
- AppIcon(app, Modifier.alpha(if (app.enabled) 1f else 0.4f))
+ AppIcon(app, Modifier.alpha(if (app.enabled || offline) 1f else 0.4f))
Spacer(Modifier.width(12.dp))
Column(Modifier.weight(1f)) {
Text(app.label, style = MaterialTheme.typography.bodyLarge, maxLines = 1, overflow = TextOverflow.Ellipsis)
- Text(
- app.protectedReason?.let { stringResource(R.string.device_app_protected, it.resolve()) } ?: status,
- style = MaterialTheme.typography.bodySmall,
- color = MaterialTheme.colorScheme.onSurfaceVariant,
- )
- if (app.homeServiceOff) Text(Copy.SERVICE_OFF.resolve(), style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant)
+ if (!offline) {
+ Text(
+ app.protectedReason?.let { stringResource(R.string.device_app_protected, it.resolve()) } ?: status,
+ style = MaterialTheme.typography.bodySmall,
+ color = MaterialTheme.colorScheme.onSurfaceVariant,
+ )
+ if (app.homeServiceOff) Text(Copy.SERVICE_OFF.resolve(), style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant)
+ }
}
- if (busy) androidx.compose.material3.LoadingIndicator(Modifier.size(32.dp))
+ if (busy && !offline) androidx.compose.material3.LoadingIndicator(Modifier.size(32.dp))
}
// Home switches are asked for in the Home screen card, not here.
val proposed = pending?.takeIf { it.first == app.packageName }?.second?.takeUnless { it == Action.Home || it == Action.HomeBack }
diff --git a/app/src/main/java/app/tellyscope/ui/DeviceTabs.kt b/app/src/main/java/app/tellyscope/ui/DeviceTabs.kt
index 2556170..dd647ca 100644
--- a/app/src/main/java/app/tellyscope/ui/DeviceTabs.kt
+++ b/app/src/main/java/app/tellyscope/ui/DeviceTabs.kt
@@ -349,7 +349,7 @@ fun DeviceTabsScreen(
}
TvTab.Apps -> {
fun rows(apps: List<AppInfo>) = items(apps, key = { it.packageName }) { app ->
- AppRow(app, procs, ui.pending, ui.busy == app.packageName, actions, locked = ui.busy != null, toHomeScreen = { if (searching) closeSearch(); tab = TvTab.Tweaks })
+ AppRow(app, procs, ui.pending, ui.busy == app.packageName, actions, locked = ui.busy != null, toHomeScreen = { if (searching) closeSearch(); tab = TvTab.Tweaks }, offline = offline)
}
// Until the first read lands, an empty list means "not yet", not "none".
val loading = ui.appsLoading && !offline
@@ -408,7 +408,7 @@ fun DeviceTabsScreen(
}
}
TvTab.Tweaks -> {
- if (offline) item { Muted(stringResource(R.string.tabs_tweaks_offline)) }
+ if (offline) item { EmptyState(DeviceIcons.Tv, Copy.TV_OFFLINE.resolve(), stringResource(R.string.tabs_tweaks_offline)) }
else {
if (homeLaunchers(ui.apps).isNotEmpty()) item { Panel(Copy.HOME_SCREEN.resolve()) { HomeScreenBlock(ui, actions, fire) } }
item { Panel(Copy.TWEAKS.resolve()) { TweaksBlock(ui, actions) } }
diff --git a/app/src/test/java/app/tellyscope/BusyGatingTest.kt b/app/src/test/java/app/tellyscope/BusyGatingTest.kt
index ffec6e0..dff55e0 100644
--- a/app/src/test/java/app/tellyscope/BusyGatingTest.kt
+++ b/app/src/test/java/app/tellyscope/BusyGatingTest.kt
@@ -2,9 +2,11 @@
package app.tellyscope
+import androidx.compose.ui.test.assertCountEquals
import androidx.compose.ui.test.assertIsEnabled
import androidx.compose.ui.test.assertIsNotEnabled
import androidx.compose.ui.test.junit4.v2.createComposeRule
+import androidx.compose.ui.test.onAllNodesWithText
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
import app.tellyscope.data.Action
@@ -42,6 +44,14 @@ class BusyGatingTest {
compose.onNodeWithText(Copy.button(Action.Uninstall).text()).assertIsNotEnabled()
}
+ @Test fun offlineRowSaysNothingAndWontOpen() {
+ // Away, what the row last heard is stale: no status line, and a tap opens nothing.
+ compose.setContent { AppRow(app, emptyList(), null, busy = false, actions = DeviceActions(), offline = true) }
+ compose.onNodeWithText("Example").performClick()
+ compose.onAllNodesWithText(Copy.button(Action.Disable).text()).assertCountEquals(0)
+ compose.onAllNodesWithText("Not running").assertCountEquals(0)
+ }
+
@Test fun confirmWaitsWhileTheTvIsBusy() {
// Proposed before a restore started: the explanation stays, its button waits.
compose.setContent { AppRow(app, emptyList(), pkg to Action.Disable, busy = false, actions = DeviceActions(), locked = true) }