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.

Start the end space again from none when the list changes

jesse-agent-232d18725382cca
diff --git a/app/src/main/java/app/tellyscope/ui/DeviceTabs.kt b/app/src/main/java/app/tellyscope/ui/DeviceTabs.kt
index 72eafd7..3697cf5 100644
--- a/app/src/main/java/app/tellyscope/ui/DeviceTabs.kt
+++ b/app/src/main/java/app/tellyscope/ui/DeviceTabs.kt
@@ -65,6 +65,7 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
+import androidx.compose.runtime.rememberUpdatedState
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.runtime.snapshotFlow
@@ -78,6 +79,7 @@ import androidx.compose.ui.graphics.lerp
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.graphics.vector.PathParser
import androidx.compose.ui.platform.LocalDensity
+import androidx.compose.ui.platform.testTag
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.font.FontWeight
@@ -142,10 +144,15 @@ fun DeviceTabsScreen(
val collapse by remember { derivedStateOf { collapsedFraction(list.firstVisibleItemIndex, list.firstVisibleItemScrollOffset, heroHeight) } }
val barTitle by remember { derivedStateOf { titleAlpha(collapse) > 0f } }
// A tab shorter than the screen gets blank space at its end, so its hero can still fold fully into the bar.
- // Measured only while the hero and the space are both in view; kept as it was while scrolled.
+ // Measured only while the hero and the space are both in view, and kept while scrolled; a different list
+ // (another tab, sub-tab or folder, or items coming and going) starts again from none.
var tail by remember { mutableIntStateOf(0) }
+ var measuredFor by remember { mutableStateOf<List<Any>>(emptyList()) }
+ val folder by rememberUpdatedState(ui.files.folder)
LaunchedEffect(list) {
snapshotFlow { list.layoutInfo }.collect { info ->
+ val content = listOf(tab, appsTab, folder, info.totalItemsCount)
+ if (content != measuredFor) { measuredFor = content; tail = 0 }
val items = info.visibleItemsInfo
val hero = items.firstOrNull { it.key == "hero" } ?: return@collect
val end = items.firstOrNull { it.key == "tail" } ?: return@collect
@@ -331,7 +338,7 @@ fun DeviceTabsScreen(
}
}
}
- item(key = "tail") { Spacer(Modifier.height(with(LocalDensity.current) { tail.toDp() })) }
+ item(key = "tail") { Spacer(Modifier.height(with(LocalDensity.current) { tail.toDp() }).testTag("tail")) }
}
if (!offline) ui.request?.let { RequestDialog(it, ui.busy == ANSWERING, actions.answerRequest, actions.dismissRequest) }
ui.sideload?.let { SideloadDialog(it, actions) }
diff --git a/app/src/test/java/app/tellyscope/ScreenshotTest.kt b/app/src/test/java/app/tellyscope/ScreenshotTest.kt
index 18ed86e..222c01b 100644
--- a/app/src/test/java/app/tellyscope/ScreenshotTest.kt
+++ b/app/src/test/java/app/tellyscope/ScreenshotTest.kt
@@ -27,6 +27,8 @@ import androidx.compose.ui.test.performScrollToNode
import androidx.compose.ui.test.performScrollToIndex
import androidx.compose.ui.test.hasScrollAction
import androidx.compose.ui.test.hasText
+import androidx.compose.ui.test.hasTestTag
+import androidx.compose.ui.test.onNodeWithTag
import app.tellyscope.adb.ApkInfo
import app.tellyscope.adb.ConnectionRequest
import app.tellyscope.adb.InstallRefusal
@@ -92,6 +94,7 @@ import java.nio.file.Files
import kotlin.random.Random
import kotlinx.coroutines.runBlocking
import org.junit.Assert.assertEquals
+import org.junit.Assert.assertTrue
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
@@ -290,6 +293,18 @@ class ScreenshotTest {
TvFile("holiday-2025.mp4", 812_000_000, now - 3 * 86_400_000L),
TvFile("family-trip-2025.mp4", 486_000_000, now - 9 * 86_400_000L),
)))) }
+ // The end space is Files' own: Apps, long after it, ends with none.
+ @Test fun longTabAfterShortOneHasNoEndSpace() {
+ compose.mainClock.autoAdvance = false
+ compose.setContent { TellyscopeTheme(dynamic = false) { DeviceTabsScreen(md3State(), DeviceActions(), startTab = TvTab.Files) } }
+ compose.mainClock.advanceTimeBy(1_000)
+ assertTrue(compose.onNodeWithTag("tail").fetchSemanticsNode().size.height > 0)
+ compose.onNodeWithText("Apps").performClick()
+ compose.mainClock.advanceTimeBy(1_000)
+ compose.onNode(hasScrollAction()).performScrollToNode(hasTestTag("tail"))
+ compose.mainClock.advanceTimeBy(1_000)
+ assertEquals(0, compose.onNodeWithTag("tail").fetchSemanticsNode().size.height)
+ }
@Test fun md3_files_movies() { shot("73_md3_files_movies") { DeviceTabsScreen(moviesState(), DeviceActions(), startTab = TvTab.Files) } }
@Test fun md3_files_movies_dark() { shot("73_md3_files_movies", dark = true) { DeviceTabsScreen(moviesState(), DeviceActions(), startTab = TvTab.Files) } }
@Test fun md3_files_offline() {