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.
Put the TV on top of every tab, folding into the bar on scroll
jesse-agent-2328d47fffae59a
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex adf648c..3f6386c 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -13,6 +13,7 @@ until this file has a section for its version.## Unreleased- **Improved:** Debloat finds your TV's list itself, or its maker's, or lets you pick. [#70](../../pull/70)+- **Improved:** The TV tops every tab and folds into the bar as you scroll. [#71](../../pull/71)## 0.5.0 — 2026-10-24diff --git a/README.md b/README.mdindex 98f5791..c9243a0 100644--- a/README.md+++ b/README.md@@ -81,7 +81,7 @@ Tellyscope is a phone app that talks to your Android TV, Google TV or Fire TV ov- **Find and connect.** It looks for TVs on your Wi-Fi, or you add one by IP address. Classic network debugging (port 5555) and Android 11+ wireless debugging with a 6-digit pairing code both work. **Add your TV** walks through turning debugging on one step at a time, with the menu names for Google TV, Android TV, Fire TV, Xiaomi or XGIMI, then lists the TVs it found. Each TV opens its own screen: the pairing code, or the Allow box with this phone's key to check against the one the TV shows. The first launch opens a short welcome with the three setup steps, and on Android 17 or newer asks for the local-network permission it needs to reach the TV.- **Remembers your TVs.** They reconnect on their own after a restart of the app or the TV. You can rename a TV (the name stays on your phone) or forget it.-- **How it's doing.** Each TV's Overview opens with the TV itself: its name, maker and model, and a one-line summary such as "Running fine" or "Storage almost full". Below that is a chip per TV to switch between them, then a **+ Device** chip. Then comes free space as a bar, with CPU, RAM, temperature and network speed. When a TV is offline, it shows the storage from the last time Tellyscope saw it. Its address and how long it's been on are under Advanced.+- **How it's doing.** Every tab of a TV's page opens with the TV itself: its name, maker and model, and a one-line summary such as "Running fine" or "Storage almost full". Scroll, and it folds into the top bar as a small icon, the name and a Connected or Offline badge. On Overview, below that is a chip per TV to switch between them, then a **+ Device** chip. Then comes free space as a bar, with CPU, RAM, temperature and network speed. When a TV is offline, it shows the storage from the last time Tellyscope saw it. Its address and how long it's been on are under Advanced.- **The main jobs up front.** Big **Install app**, **Debloat** and **Send file** tiles sit right under the vitals. Debloat shows a count while the TV's list still has apps on, or while apps Tellyscope turned off are back on, often after a TV update. When there's nothing left, it opens Apps instead. Under **Suggested for this TV**, one line says how many of the list's apps are off. If any came back on, a red line says so. Below that are the TV's Android version, when it last updated, and **Check for updates**, which opens the TV's own update screen. The Apps tab has an **Install app** button, and Files has **Upload files**.- **Advanced.** Every number in one place: memory, storage, CPU, temperature, uptime and screen state, CPU and RAM by app, processes, network and data used, and the TV's address.- **Apps.** Every app on the TV with its real name and icon. Stop, disable or turn back on any app that isn't protected; each button says what it will do and asks first. Apps you installed yourself also offer **Uninstall**, which asks in a dialog that names the app and says it can't be undone. Protected apps are folded into their own **Can't be changed** section below the list.diff --git a/app/src/main/java/app/tellyscope/ui/DeviceTabs.kt b/app/src/main/java/app/tellyscope/ui/DeviceTabs.ktindex e7dc603..8318b15 100644--- a/app/src/main/java/app/tellyscope/ui/DeviceTabs.kt+++ b/app/src/main/java/app/tellyscope/ui/DeviceTabs.kt@@ -4,28 +4,20 @@package app.tellyscope.ui-import androidx.compose.foundation.backgroundimport androidx.compose.foundation.layout.Arrangementimport androidx.compose.foundation.layout.Boximport androidx.compose.foundation.layout.Column-import androidx.compose.foundation.layout.FlowRowimport androidx.compose.foundation.layout.PaddingValuesimport androidx.compose.foundation.layout.Row-import androidx.compose.foundation.layout.Spacerimport androidx.compose.foundation.layout.fillMaxSizeimport androidx.compose.foundation.layout.fillMaxWidth-import androidx.compose.foundation.layout.offsetimport androidx.compose.foundation.layout.paddingimport androidx.compose.foundation.layout.size-import androidx.compose.foundation.layout.width-import androidx.compose.foundation.layout.widthInimport androidx.compose.foundation.lazy.LazyColumnimport androidx.compose.foundation.lazy.itemsimport androidx.compose.foundation.lazy.rememberLazyListState-import androidx.compose.foundation.shape.CircleShapeimport androidx.compose.material.icons.Iconsimport androidx.compose.material.icons.filled.Add-import androidx.compose.material.icons.filled.CheckCircleimport androidx.compose.material.icons.filled.Closeimport androidx.compose.material.icons.filled.Deleteimport androidx.compose.material.icons.filled.Edit@@ -35,7 +27,6 @@ import androidx.compose.material.icons.filled.Listimport androidx.compose.material.icons.filled.MoreVertimport androidx.compose.material.icons.filled.Searchimport androidx.compose.material.icons.filled.Settings-import androidx.compose.material.icons.filled.Warningimport androidx.compose.material3.AssistChipimport androidx.compose.material3.Cardimport androidx.compose.material3.CardDefaults@@ -60,27 +51,29 @@ import androidx.compose.material3.ShortNavigationBarItemimport androidx.compose.material3.SingleChoiceSegmentedButtonRowimport androidx.compose.material3.SnackbarHostimport androidx.compose.material3.SnackbarHostState-import androidx.compose.material3.Surfaceimport androidx.compose.material3.Textimport androidx.compose.material3.TextButtonimport androidx.compose.material3.TextFieldimport androidx.compose.material3.TextFieldDefaultsimport androidx.compose.material3.TopAppBar+import androidx.compose.material3.TopAppBarDefaultsimport androidx.compose.material3.toShapeimport androidx.compose.runtime.Composableimport androidx.compose.runtime.LaunchedEffect+import androidx.compose.runtime.derivedStateOfimport androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableIntStateOfimport androidx.compose.runtime.mutableStateOfimport androidx.compose.runtime.rememberimport androidx.compose.runtime.saveable.rememberSaveableimport androidx.compose.runtime.setValueimport androidx.compose.ui.Alignmentimport androidx.compose.ui.Modifier-import androidx.compose.ui.draw.alpha-import androidx.compose.ui.draw.clipimport androidx.compose.ui.graphics.Colorimport androidx.compose.ui.graphics.PathFillTypeimport androidx.compose.ui.graphics.SolidColor+import androidx.compose.ui.graphics.graphicsLayer+import androidx.compose.ui.graphics.lerpimport androidx.compose.ui.graphics.vector.ImageVectorimport androidx.compose.ui.graphics.vector.PathParserimport androidx.compose.ui.text.SpanStyle@@ -90,11 +83,9 @@ import androidx.compose.ui.text.style.TextOverflowimport androidx.compose.ui.text.withStyleimport androidx.compose.ui.unit.dpimport app.tellyscope.data.Action-import app.tellyscope.data.Deviceimport app.tellyscope.data.DeviceStateimport app.tellyscope.data.Snapshotimport app.tellyscope.data.Suggestions-import app.tellyscope.data.deviceKind/** The TV page's destinations, one job each, in the bottom bar. */enum class TvTab(val label: String) { Overview("Overview"), Apps("Apps"), Files("Files"), Tweaks("Tweaks") }@@ -124,8 +115,8 @@ private fun TvTab.icon() = when (this) {/*** The TV page as four tabs under a bottom bar, in place of one long scroll of folded sections.- * Overview leads with the TV itself, big and centred, and a chip per TV to switch; the other tabs- * name the TV in the app bar. Search (Apps only) and the overflow sit on the right.+ * Every tab leads with the TV itself, big and centred, Overview with a chip per TV to switch; scrolling+ * folds it into the app bar. Search (Apps only) and the overflow sit on the right.*/@OptIn(ExperimentalMaterial3Api::class, ExperimentalMaterial3ExpressiveApi::class)@Composable@@ -143,10 +134,14 @@ fun DeviceTabsScreen(val q = state.query.trim().lowercase()val offline = device.state != DeviceState.Onlineval list = rememberLazyListState()- // "See changes" lands on Tweaks scrolled to Recent changes, the list's second item.+ // The hero tops every tab and collapses into the bar as the tab scrolls.+ var heroHeight by remember { mutableIntStateOf(0) }+ val collapse by remember { derivedStateOf { collapsedFraction(list.firstVisibleItemIndex, list.firstVisibleItemScrollOffset, heroHeight) } }+ val barTitle by remember { derivedStateOf { titleAlpha(collapse) > 0f } }+ // "See changes" lands on Tweaks scrolled to Recent changes, the list's third item, after the hero.var toChanges by remember { mutableStateOf(false) }LaunchedEffect(tab, toChanges) {- if (tab == TvTab.Tweaks && toChanges) { list.scrollToItem(1); toChanges = false }+ if (tab == TvTab.Tweaks && toChanges) { list.scrollToItem(2); toChanges = false }}Scaffold(@@ -183,8 +178,11 @@ fun DeviceTabsScreen()} else {TopAppBar(- // Overview shows the TV big below; the bar says which TV only on the other tabs.- title = { if (tab != TvTab.Overview) BarName(state) },+ // Each tab shows the TV big below, and in the bar once it has scrolled under it.+ title = { if (barTitle) TvBarTitle(device, Modifier.graphicsLayer { alpha = titleAlpha(collapse) }) },+ colors = TopAppBarDefaults.topAppBarColors(+ containerColor = lerp(MaterialTheme.colorScheme.surface, MaterialTheme.colorScheme.surfaceContainer, collapse),+ ),actions = {if (REMOTE_ENABLED) TextButton(onClick = actions.remote, enabled = !offline) { Text("Remote") }// Search only looks through apps, so it only shows on the Apps tab.@@ -223,9 +221,9 @@ fun DeviceTabsScreen() {val snap = ui.snapshotval live = snap?.takeIf { !offline }+ item(key = "hero") { TvHero(state, live, actions, chips = tab == TvTab.Overview, collapse = { collapse }, onHeight = { heroHeight = it }) }when (tab) {TvTab.Overview -> {- item { Hero(state, live, actions) }val restart = state.restarting[device.id]if (restart != null) {item { RestartingCard(restart, state.now) }@@ -362,81 +360,6 @@ private fun AppMenu(state: UiState, actions: DeviceActions) {}}-/** The bar on every tab but Overview: which TV, nothing to open. Switching happens on Overview. */-@Composable-private fun BarName(state: UiState) {- val device = state.selected ?: return- val kind = deviceKind(device)- Row(verticalAlignment = Alignment.CenterVertically) {- Icon(DeviceIcons.of(kind), contentDescription = kind.word(), Modifier.padding(end = 12.dp))- Text(name(device), style = MaterialTheme.typography.titleLarge, maxLines = 1, overflow = TextOverflow.Ellipsis)- }-}-/** The TV as Overview's hero: an Expressive cookie-shaped tile, its name, how it's doing, and the switcher. */-@OptIn(ExperimentalMaterial3ExpressiveApi::class)-@Composable-private fun Hero(state: UiState, live: Snapshot?, actions: DeviceActions) {- val device = state.selected ?: return- val kind = deviceKind(device)- val c = MaterialTheme.colorScheme- // Offline: the tile greys out, so it agrees with the Offline pill.- val on = device.state == DeviceState.Online- Column(Modifier.fillMaxWidth(), horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.spacedBy(8.dp)) {- Box(- Modifier.size(80.dp).clip(MaterialShapes.Cookie9Sided.toShape()).background(if (on) c.primaryContainer else c.surfaceContainerHighest),- contentAlignment = Alignment.Center,- ) {- Icon(DeviceIcons.of(kind), contentDescription = kind.word(), Modifier.size(40.dp), tint = if (on) c.onPrimaryContainer else c.outline)- }- val title = name(device)- Column(horizontalAlignment = Alignment.CenterHorizontally) {- Text(title, style = MaterialTheme.typography.headlineMediumEmphasized, maxLines = 1, overflow = TextOverflow.Ellipsis, modifier = Modifier.padding(horizontal = 16.dp))- // Under a model-name title, the model would only say it twice.- val maker = device.manufacturer ?: device.hit.maker- val made = if (title == device.model) maker.orEmpty() else made(maker, device.model)- if (made.isNotEmpty()) Text(made, style = MaterialTheme.typography.bodyMedium, color = c.onSurfaceVariant)- }- val health = live?.let { Copy.health(it, heaviest(it, state.device.apps)) }- Surface(shape = CircleShape, color = if (health?.ok == false) c.errorContainer else c.secondaryContainer) {- Row(Modifier.padding(horizontal = 12.dp, vertical = 4.dp), verticalAlignment = Alignment.CenterVertically) {- if (health != null) {- Icon(if (health.ok) Icons.Default.CheckCircle else Icons.Default.Warning, null, Modifier.size(16.dp), tint = if (health.ok) c.primary else c.error)- } else StateDot(device.state)- Spacer(Modifier.width(8.dp))- Text(health?.text ?: Copy.state(device.state), style = MaterialTheme.typography.labelLarge)- }- }- TvChips(state, actions)- }-}--/** One chip per TV to switch, offline ones dimmed, then "+ Device" as the last chip. */-@Composable-private fun TvChips(state: UiState, actions: DeviceActions) {- FlowRow(- Modifier.fillMaxWidth(),- horizontalArrangement = Arrangement.spacedBy(8.dp, Alignment.CenterHorizontally),- itemVerticalAlignment = Alignment.CenterVertically,- ) {- if (state.devices.size > 1) state.devices.forEach { d ->- FilterChip(- selected = d.id == state.selectedId,- onClick = { actions.select(d.id) },- label = { Text(name(d), maxLines = 1, overflow = TextOverflow.Ellipsis, modifier = Modifier.widthIn(max = 104.dp)) },- leadingIcon = {- Box {- Icon(DeviceIcons.of(deviceKind(d)), contentDescription = deviceKind(d).word(), Modifier.size(18.dp))- Box(Modifier.align(Alignment.BottomEnd).offset(x = 3.dp, y = 3.dp)) { StateDot(d.state) }- }- },- modifier = if (d.state == DeviceState.Online) Modifier else Modifier.alpha(0.6f),- )- }- // Adding a TV sits with the TVs, as the last chip.- AssistChip(onClick = actions.addDevice, label = { Text("Device") }, leadingIcon = { Icon(Icons.Default.Add, contentDescription = "Add a", Modifier.size(18.dp)) })- }-}-/** Where the suggested list stands on this TV, worked out from the live app list. */internal data class DebloatState(/** Apps on the list that are installed here and Tellyscope may turn off, on or off. */diff --git a/app/src/main/java/app/tellyscope/ui/TvHeader.kt b/app/src/main/java/app/tellyscope/ui/TvHeader.ktnew file mode 100644index 0000000..ac20524--- /dev/null+++ b/app/src/main/java/app/tellyscope/ui/TvHeader.kt@@ -0,0 +1,182 @@+// SPDX-License-Identifier: GPL-3.0-only++package app.tellyscope.ui++import androidx.compose.foundation.background+import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.FlowRow+import androidx.compose.foundation.layout.Row+import androidx.compose.foundation.layout.Spacer+import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.offset+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.layout.size+import androidx.compose.foundation.layout.width+import androidx.compose.foundation.layout.widthIn+import androidx.compose.foundation.shape.CircleShape+import androidx.compose.material.icons.Icons+import androidx.compose.material.icons.filled.Add+import androidx.compose.material.icons.filled.CheckCircle+import androidx.compose.material.icons.filled.Warning+import androidx.compose.material3.AssistChip+import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi+import androidx.compose.material3.FilterChip+import androidx.compose.material3.Icon+import androidx.compose.material3.MaterialShapes+import androidx.compose.material3.MaterialTheme+import androidx.compose.material3.Surface+import androidx.compose.material3.Text+import androidx.compose.material3.toShape+import androidx.compose.runtime.Composable+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.draw.alpha+import androidx.compose.ui.draw.clip+import androidx.compose.ui.graphics.TransformOrigin+import androidx.compose.ui.graphics.graphicsLayer+import androidx.compose.ui.layout.onSizeChanged+import androidx.compose.ui.text.style.TextOverflow+import androidx.compose.ui.unit.Dp+import androidx.compose.ui.unit.dp+import app.tellyscope.data.Device+import app.tellyscope.data.DeviceState+import app.tellyscope.data.Snapshot+import app.tellyscope.data.deviceKind++/*+ * The TV's header, shared by the tabs that lead with the TV: the big hero, which collapses as the+ * page scrolls, and the bar title it collapses into. The TV chips, on Overview, scroll away with the page.+ */++/**+ * How far the hero has scrolled under the bar, 0 (all in view) to 1 (gone), from the list's+ * first visible item and its offset. The hero is item 0, [heroHeight] px tall; 0 before it's measured.+ */+internal fun collapsedFraction(firstIndex: Int, firstOffset: Int, heroHeight: Int): Float = when {+ firstIndex > 0 -> 1f+ heroHeight <= 0 -> 0f+ else -> (firstOffset.toFloat() / heroHeight).coerceIn(0f, 1f)+}++/** The maker line and health pill go first, over the first half of the collapse. */+internal fun detailAlpha(f: Float) = (1f - 2f * f).coerceIn(0f, 1f)++/** The bar title comes in over the last third, as the hero's name passes under the bar. */+internal fun titleAlpha(f: Float) = ((f - 0.67f) / 0.33f).coerceIn(0f, 1f)++/** The TV's cookie tile: primary while it's connected, grey when it isn't. */+@OptIn(ExperimentalMaterial3ExpressiveApi::class)+@Composable+private fun Cookie(device: Device, size: Dp) {+ val kind = deviceKind(device)+ val c = MaterialTheme.colorScheme+ val on = device.state == DeviceState.Online+ Box(+ Modifier.size(size).clip(MaterialShapes.Cookie9Sided.toShape()).background(if (on) c.primaryContainer else c.surfaceContainerHighest),+ contentAlignment = Alignment.Center,+ ) {+ Icon(DeviceIcons.of(kind), contentDescription = kind.word(), Modifier.size(size / 2), tint = if (on) c.onPrimaryContainer else c.outline)+ }+}++/**+ * The TV as the hero: an Expressive cookie-shaped tile, its name, how it's doing, and, on+ * Overview ([chips]), the TV chips. [collapse] is read while drawing only, so scrolling redraws+ * without recomposing: the cookie and name shrink and fade, the details faster. [onHeight] gets+ * the height of everything above the chips.+ */+@OptIn(ExperimentalMaterial3ExpressiveApi::class)+@Composable+fun TvHero(state: UiState, live: Snapshot?, actions: DeviceActions, chips: Boolean = true, collapse: () -> Float = { 0f }, onHeight: (Int) -> Unit = {}) {+ val device = state.selected ?: return+ val c = MaterialTheme.colorScheme+ Column(Modifier.fillMaxWidth(), horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.spacedBy(8.dp)) {+ Column(+ Modifier.fillMaxWidth().onSizeChanged { onHeight(it.height) },+ horizontalAlignment = Alignment.CenterHorizontally,+ verticalArrangement = Arrangement.spacedBy(8.dp),+ ) {+ // Toward the top left, where the bar's small cookie and name take over.+ Column(+ Modifier.graphicsLayer {+ val f = collapse()+ scaleX = 1f - 0.4f * f+ scaleY = scaleX+ alpha = 1f - f+ transformOrigin = TransformOrigin(0.5f, 0f)+ },+ horizontalAlignment = Alignment.CenterHorizontally,+ verticalArrangement = Arrangement.spacedBy(8.dp),+ ) {+ Cookie(device, 80.dp)+ Text(name(device), style = MaterialTheme.typography.headlineMediumEmphasized, maxLines = 1, overflow = TextOverflow.Ellipsis, modifier = Modifier.padding(horizontal = 16.dp))+ }+ Column(Modifier.graphicsLayer { alpha = detailAlpha(collapse()) }, horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.spacedBy(8.dp)) {+ // Under a model-name title, the model would only say it twice.+ val maker = device.manufacturer ?: device.hit.maker+ val made = if (name(device) == device.model) maker.orEmpty() else made(maker, device.model)+ if (made.isNotEmpty()) Text(made, style = MaterialTheme.typography.bodyMedium, color = c.onSurfaceVariant)+ val health = live?.let { Copy.health(it, heaviest(it, state.device.apps)) }+ Surface(shape = CircleShape, color = if (health?.ok == false) c.errorContainer else c.secondaryContainer) {+ Row(Modifier.padding(horizontal = 12.dp, vertical = 4.dp), verticalAlignment = Alignment.CenterVertically) {+ if (health != null) {+ Icon(if (health.ok) Icons.Default.CheckCircle else Icons.Default.Warning, null, Modifier.size(16.dp), tint = if (health.ok) c.primary else c.error)+ } else StateDot(device.state)+ Spacer(Modifier.width(8.dp))+ Text(health?.text ?: Copy.state(device.state), style = MaterialTheme.typography.labelLarge)+ }+ }+ }+ }+ if (chips) TvChips(state, actions)+ }+}++/** The collapsed hero, in the bar: small cookie, the TV's name, and whether it's connected. */+@Composable+fun TvBarTitle(device: Device, modifier: Modifier = Modifier) {+ val c = MaterialTheme.colorScheme+ val on = device.state == DeviceState.Online+ Row(modifier, verticalAlignment = Alignment.CenterVertically) {+ Cookie(device, 32.dp)+ Spacer(Modifier.width(12.dp))+ Text(name(device), style = MaterialTheme.typography.titleLarge, maxLines = 1, overflow = TextOverflow.Ellipsis, modifier = Modifier.weight(1f, fill = false))+ Spacer(Modifier.width(12.dp))+ Surface(shape = CircleShape, color = if (on) c.primaryContainer else c.surfaceContainerHighest, contentColor = if (on) c.onPrimaryContainer else c.onSurfaceVariant) {+ Row(Modifier.padding(horizontal = 8.dp, vertical = 2.dp), verticalAlignment = Alignment.CenterVertically) {+ StateDot(device.state)+ Spacer(Modifier.width(6.dp))+ Text(Copy.state(device.state), style = MaterialTheme.typography.labelMedium)+ }+ }+ }+}++/** One chip per TV to switch, offline ones dimmed, then "+ Device" as the last chip. */+@Composable+private fun TvChips(state: UiState, actions: DeviceActions) {+ FlowRow(+ Modifier.fillMaxWidth(),+ horizontalArrangement = Arrangement.spacedBy(8.dp, Alignment.CenterHorizontally),+ itemVerticalAlignment = Alignment.CenterVertically,+ ) {+ if (state.devices.size > 1) state.devices.forEach { d ->+ FilterChip(+ selected = d.id == state.selectedId,+ onClick = { actions.select(d.id) },+ label = { Text(name(d), maxLines = 1, overflow = TextOverflow.Ellipsis, modifier = Modifier.widthIn(max = 104.dp)) },+ leadingIcon = {+ Box {+ Icon(DeviceIcons.of(deviceKind(d)), contentDescription = deviceKind(d).word(), Modifier.size(18.dp))+ Box(Modifier.align(Alignment.BottomEnd).offset(x = 3.dp, y = 3.dp)) { StateDot(d.state) }+ }+ },+ modifier = if (d.state == DeviceState.Online) Modifier else Modifier.alpha(0.6f),+ )+ }+ // Adding a TV sits with the TVs, as the last chip.+ AssistChip(onClick = actions.addDevice, label = { Text("Device") }, leadingIcon = { Icon(Icons.Default.Add, contentDescription = "Add a", Modifier.size(18.dp)) })+ }+}diff --git a/app/src/test/java/app/tellyscope/ScreenshotTest.kt b/app/src/test/java/app/tellyscope/ScreenshotTest.ktindex ba3b9b3..284a4c8 100644--- a/app/src/test/java/app/tellyscope/ScreenshotTest.kt+++ b/app/src/test/java/app/tellyscope/ScreenshotTest.kt@@ -18,6 +18,7 @@ import androidx.compose.ui.test.assertIsSelectedimport androidx.compose.ui.test.onNodeWithContentDescriptionimport androidx.compose.ui.test.onNodeWithTextimport androidx.compose.ui.test.onAllNodesWithText+import androidx.compose.ui.test.onFirstimport androidx.compose.ui.test.assertCountEqualsimport androidx.compose.ui.test.onRootimport androidx.compose.ui.test.performClick@@ -245,6 +246,44 @@ class ScreenshotTest {@Test fun md3_overview_dark() = md3("60_md3_overview", true)@Test fun md3_offline() = md3("62_md3_offline", false) { md3State().let { it.copy(selectedId = it.devices[2].id, device = DeviceUi(history = it.device.history)) } }@Test fun md3_offline_dark() = md3("62_md3_offline", true) { md3State().let { it.copy(selectedId = it.devices[2].id, device = DeviceUi(history = it.device.history)) } }++ /**+ * Scrolled past the hero: it has collapsed into the bar, with the ⋮ menu still in place. On a+ * phone-height screen, so each tab has more than a screenful to scroll.+ */+ private fun collapsed(name: String, dark: Boolean, badge: String, tab: TvTab = TvTab.Overview, state: () -> UiState = ::md3State) {+ val scroll = { compose.onNode(hasScrollAction()).performScrollToIndex(1); Unit }+ shot(name, dark, before = scroll) { DeviceTabsScreen(state(), DeviceActions(), startTab = tab) }+ compose.onAllNodesWithText(badge).onFirst().assertExists()+ compose.onNodeWithContentDescription("More options").assertExists()+ compose.onNodeWithText("Device").assertDoesNotExist() // the chips scrolled away, or were never there+ }++ private fun offlineMd3() = md3State().let { it.copy(selectedId = it.devices[2].id, device = DeviceUi(history = it.device.history)) }++ @Config(qualifiers = "w411dp-h640dp-xxhdpi")+ @Test fun md3_collapsed() = collapsed("61_md3_collapsed", false, "Connected")+ @Config(qualifiers = "w411dp-h640dp-xxhdpi")+ @Test fun md3_collapsed_dark() = collapsed("61_md3_collapsed", true, "Connected")+ @Config(qualifiers = "w411dp-h640dp-xxhdpi")+ @Test fun md3_offline_collapsed() = collapsed("62_md3_offline_collapsed", false, "Offline", state = ::offlineMd3)+ @Config(qualifiers = "w411dp-h640dp-xxhdpi")+ @Test fun md3_offline_collapsed_dark() = collapsed("62_md3_offline_collapsed", true, "Offline", state = ::offlineMd3)+ @Config(qualifiers = "w411dp-h640dp-xxhdpi")+ @Test fun md3_apps_collapsed() = collapsed("64_md3_apps_collapsed", false, "Connected", TvTab.Apps)+ @Config(qualifiers = "w411dp-h640dp-xxhdpi")+ @Test fun md3_apps_collapsed_dark() = collapsed("64_md3_apps_collapsed", true, "Connected", TvTab.Apps)+ @Config(qualifiers = "w411dp-h640dp-xxhdpi")+ @Test fun md3_files_collapsed() = collapsed("65_md3_files_collapsed", false, "Connected", TvTab.Files)+ @Test fun md3_tweaks() { shot("66_md3_tweaks") { DeviceTabsScreen(md3State(), DeviceActions(), startTab = TvTab.Tweaks) } }+ @Config(qualifiers = "w411dp-h640dp-xxhdpi")+ @Test fun md3_tweaks_collapsed() = collapsed("66_md3_tweaks_collapsed", false, "Connected", TvTab.Tweaks)++ @Test fun md3_expandedHasNoBarTitle() {+ md3("60_md3_overview", false)+ // At rest the bar holds only ⋮; the hero's pill says how the TV is doing instead.+ compose.onNodeWithText("Connected").assertDoesNotExist()+ }@Test fun md3_apps() { shot("64_md3_apps") { DeviceTabsScreen(md3State(), DeviceActions(), startTab = TvTab.Apps) } }@Test fun md3_apps_dark() { shot("64_md3_apps", dark = true) { DeviceTabsScreen(md3State(), DeviceActions(), startTab = TvTab.Apps) } }@Test fun md3_files() { shot("65_md3_files") { DeviceTabsScreen(md3State(), DeviceActions(), startTab = TvTab.Files) } }diff --git a/app/src/test/java/app/tellyscope/TvHeaderTest.kt b/app/src/test/java/app/tellyscope/TvHeaderTest.ktnew file mode 100644index 0000000..f0312a4--- /dev/null+++ b/app/src/test/java/app/tellyscope/TvHeaderTest.kt@@ -0,0 +1,29 @@+// SPDX-License-Identifier: GPL-3.0-only++package app.tellyscope++import app.tellyscope.ui.collapsedFraction+import app.tellyscope.ui.detailAlpha+import app.tellyscope.ui.titleAlpha+import org.junit.Assert.assertEquals+import org.junit.Test++class TvHeaderTest {+ @Test fun theHeroCollapsesWithTheScrollAndStaysCollapsedPastIt() {+ assertEquals(0f, collapsedFraction(0, 0, 600))+ assertEquals(0.5f, collapsedFraction(0, 300, 600))+ assertEquals(1f, collapsedFraction(0, 900, 600)) // the chips are still in view+ assertEquals(1f, collapsedFraction(1, 0, 600)) // the hero is gone+ // Not measured yet: drawn expanded, never divided by zero.+ assertEquals(0f, collapsedFraction(0, 120, 0))+ }++ @Test fun theDetailsGoFirstAndTheBarTitleComesLast() {+ assertEquals(1f, detailAlpha(0f), 0.001f)+ assertEquals(0f, detailAlpha(0.5f), 0.001f)+ assertEquals(0f, titleAlpha(0.5f), 0.001f)+ assertEquals(1f, titleAlpha(1f), 0.001f)+ // Never both out of sight with nothing in the bar: the title starts once the details are gone.+ assertEquals(0f, detailAlpha(0.67f), 0.001f)+ }+}