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.
Banner-only TV apps get a letter tile in their banner's colours
jesse-agent-23227d4fcc8946f
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex e6f56a7..ec46c67 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -19,6 +19,7 @@ until this file has a section for its version.- **New:** Report a problem or help add your TV: GitHub opens with the report filled in. [#127](../../pull/127)- **New:** About shows the app's version and its GitHub page. [#125](../../pull/125)- **New:** Dock up to four apps on the Remote, one tap to open. [#120](../../pull/120)+- **Improved:** TV-only apps get a clear letter tile in their banner's colours. [#PR](../../pull/PR)- **Improved:** Restart TV sits in the Remote's top bar and waits with you. [#120](../../pull/120)- **Improved:** Sleep and Menu leave the Remote, making room for the dock. [#120](../../pull/120)- **Fixed:** Menus and the TV header no longer turn purple without dynamic colour. [#119](../../pull/119)diff --git a/adb/src/main/kotlin/app/tellyscope/adb/LabelHelper.kt b/adb/src/main/kotlin/app/tellyscope/adb/LabelHelper.ktindex 1e00d5e..1a4c596 100644--- a/adb/src/main/kotlin/app/tellyscope/adb/LabelHelper.kt+++ b/adb/src/main/kotlin/app/tellyscope/adb/LabelHelper.kt@@ -8,8 +8,18 @@ import kotlinx.coroutines.withTimeoutOrNullimport java.util.Base64import kotlin.time.Duration.Companion.seconds-/** One app as the TV's PackageManager describes it. */-class AppLabel(val packageName: String, val label: String, val versionCode: Long, val iconPng: ByteArray?)+/**+ * One app as the TV's PackageManager describes it. A banner-only app has no [iconPng] but a letter+ * tile: [tileColor] behind, [tileAccent] for the letter, both ARGB.+ */+class AppLabel(+ val packageName: String,+ val label: String,+ val versionCode: Long,+ val iconPng: ByteArray?,+ val tileColor: Long? = null,+ val tileAccent: Long? = null,+)/*** Real app names and icons, read on the TV by the helper dex (`app/src/helper`): push it, run it@@ -59,7 +69,9 @@ class LabelHelper(private val session: AdbSession, private val dex: ByteArray) {val label = (o["l"] as? String)?.trim()?.takeIf { it.isNotEmpty() } ?: return@mapNotNull nullval version = (o["v"] as? Long) ?: return@mapNotNull nullval icon = (o["i"] as? String)?.let { runCatching { Base64.getDecoder().decode(it) }.getOrNull() }- AppLabel(pkg, label, version, icon)+ // Both or neither: a tile needs its letter colour.+ val tile = (o["b"] as? Long)?.let { b -> (o["a"] as? Long)?.let { a -> b to a } }+ AppLabel(pkg, label, version, icon, tile?.first, tile?.second)}.toList()}}diff --git a/adb/src/test/kotlin/app/tellyscope/adb/LabelHelperTest.kt b/adb/src/test/kotlin/app/tellyscope/adb/LabelHelperTest.ktindex f441dc7..8560c61 100644--- a/adb/src/test/kotlin/app/tellyscope/adb/LabelHelperTest.kt+++ b/adb/src/test/kotlin/app/tellyscope/adb/LabelHelperTest.kt@@ -30,7 +30,21 @@ class LabelHelperTest {assertNull(apps[1].iconPng)}- @Test fun skipsLinesThatDontParse() {+ @Test fun aBannerAppSendsTileColoursInsteadOfAnIcon() {+ val out = """+ {"p":"com.spotify.tv.android","l":"Spotify","v":1,"b":4279308561,"a":4280211296}+ {"p":"com.example.half","l":"Half","v":1,"b":4279308561}+ """.trimIndent()+ val (spotify, half) = LabelHelper.parse(out)+ assertNull(spotify.iconPng)+ assertEquals(0xFF111111, spotify.tileColor)+ assertEquals(0xFF1ED760, spotify.tileAccent)+ // A colour without its letter colour isn't a tile.+ assertNull(half.tileColor)+ assertNull(half.tileAccent)+ }++ @Test fun skipsLinesThatDontParse() {val out = """Exception in thread "main" java.lang.SecurityException{"p":"com.a","l":"A","v":1}diff --git a/app/build.gradle.kts b/app/build.gradle.ktsindex 9da23ae..2303f79 100644--- a/app/build.gradle.kts+++ b/app/build.gradle.kts@@ -72,6 +72,9 @@ android {compose = true}+ // The helpers' pure parts (BannerColors) are unit-tested like app code.+ sourceSets["test"].java.srcDir("src/helper/java")+testOptions {// Robolectric renders the screenshot tests (see ScreenshotTest).unitTests.isIncludeAndroidResources = truediff --git a/app/src/helper/java/app/tellyscope/helper/BannerColors.java b/app/src/helper/java/app/tellyscope/helper/BannerColors.javanew file mode 100644index 0000000..8bc35c8--- /dev/null+++ b/app/src/helper/java/app/tellyscope/helper/BannerColors.java@@ -0,0 +1,94 @@+// SPDX-License-Identifier: GPL-3.0-only+package app.tellyscope.helper;++/**+ * The two colours of a letter tile for an app that only ships a TV banner: the banner's main+ * colour behind the letter, and its accent for the letter itself. Pure pixel arithmetic, so the+ * app's unit tests run it too.+ */+public final class BannerColors {+ /** WCAG's minimum for large text: below it the letter is swapped for white or black. */+ static final double MIN_CONTRAST = 3.0;++ private BannerColors() {}++ /**+ * {@code {background, accent}} as opaque ARGB, from a banner's ARGB pixels, or null when it has+ * none that aren't see-through.+ */+ public static int[] pick(int[] pixels) {+ // 4 bits a channel: close shades of one colour count together, and a bucket's colour is+ // the average of its pixels.+ int[] count = new int[4096];+ long[] r = new long[4096], g = new long[4096], b = new long[4096];+ int opaque = 0;+ for (int p : pixels) {+ if ((p >>> 24) < 128) continue;+ int pr = (p >> 16) & 0xff, pg = (p >> 8) & 0xff, pb = p & 0xff;+ int k = (pr >> 4) << 8 | (pg >> 4) << 4 | (pb >> 4);+ count[k]++;+ r[k] += pr;+ g[k] += pg;+ b[k] += pb;+ opaque++;+ }+ if (opaque == 0) return null;+ int main = 0;+ for (int k = 1; k < 4096; k++) if (count[k] > count[main]) main = k;+ int bg = average(count, r, g, b, main);++ // The accent: the most colourful shade that covers a real part of the banner and stands+ // apart from the background. Grey-only artwork falls back to its most common other shade.+ int min = Math.max(1, opaque / 200);+ int accent = 0, best = -1;+ double bestScore = 0;+ int common = -1;+ for (int k = 0; k < 4096; k++) {+ if (count[k] < min || k == main) continue;+ int c = average(count, r, g, b, k);+ if (contrast(c, bg) < 1.5) continue;+ if (common < 0 || count[k] > count[common]) common = k;+ double score = chroma(c);+ if (score > bestScore) {+ bestScore = score;+ best = k;+ accent = c;+ }+ }+ if (best < 0 || bestScore < 0.15) accent = common < 0 ? bg : average(count, r, g, b, common);+ return new int[] {bg, readable(accent, bg)};+ }++ /** [accent] when it reads on [bg], otherwise white or black, whichever reads better. */+ static int readable(int accent, int bg) {+ if (contrast(accent, bg) >= MIN_CONTRAST) return accent;+ return contrast(0xffffffff, bg) >= contrast(0xff000000, bg) ? 0xffffffff : 0xff000000;+ }++ /** WCAG contrast ratio, 1 to 21. */+ static double contrast(int a, int b) {+ double la = luminance(a), lb = luminance(b);+ return (Math.max(la, lb) + 0.05) / (Math.min(la, lb) + 0.05);+ }++ private static double luminance(int c) {+ return 0.2126 * linear((c >> 16) & 0xff) + 0.7152 * linear((c >> 8) & 0xff) + 0.0722 * linear(c & 0xff);+ }++ private static double linear(int v) {+ double s = v / 255.0;+ return s <= 0.04045 ? s / 12.92 : Math.pow((s + 0.055) / 1.055, 2.4);+ }++ /** How vivid, 0 for greys: unlike saturation, a near-black tint scores low. */+ private static double chroma(int c) {+ int max = Math.max((c >> 16) & 0xff, Math.max((c >> 8) & 0xff, c & 0xff));+ int min = Math.min((c >> 16) & 0xff, Math.min((c >> 8) & 0xff, c & 0xff));+ return (max - min) / 255.0;+ }++ private static int average(int[] count, long[] r, long[] g, long[] b, int k) {+ int n = count[k];+ return 0xff000000 | (int) (r[k] / n) << 16 | (int) (g[k] / n) << 8 | (int) (b[k] / n);+ }+}diff --git a/app/src/helper/java/app/tellyscope/helper/Labels.java b/app/src/helper/java/app/tellyscope/helper/Labels.javaindex b1cd458..9bafe33 100644--- a/app/src/helper/java/app/tellyscope/helper/Labels.java+++ b/app/src/helper/java/app/tellyscope/helper/Labels.java@@ -21,12 +21,15 @@ import java.util.List;/*** Runs on the TV as the shell user, through {@code app_process}, and prints one JSON object per- * app: {@code {"p":package,"l":label,"v":versionCode,"i":base64 PNG}}. Arguments are the packages- * to describe, or {@code --all}. It only reads through PackageManager: no writes, no permissions,- * no network. The app pushes it, runs it once and deletes it.+ * app: {@code {"p":package,"l":label,"v":versionCode,"i":base64 PNG}}. An app with only a TV+ * banner gets {@code "b"} and {@code "a"} in place of {@code "i"}: its letter tile's colours as+ * ARGB. Arguments are the packages to describe, or {@code --all}. It only reads through+ * PackageManager: no writes, no permissions, no network. The app pushes it, runs it once and deletes it.*/public final class Labels {- private static final int ICON_PX = 96;+ private static final int ICON_PX = 192;+ /** Enough of a banner to find its colours; a 16:9 banner is drawn at this width. */+ private static final int BANNER_PX = 160;public static void main(String[] args) throws Exception {Looper.prepareMainLooper();@@ -51,8 +54,13 @@ public final class Labels {line.append(",\"l\":");string(line, ai.loadLabel(pm).toString());line.append(",\"v\":").append(versionCode(p));- String icon = icon(pm, ai);- if (icon != null) line.append(",\"i\":\"").append(icon).append('"');+ int[] tile = ai.icon == 0 && ai.banner != 0 ? tile(pm, ai) : null;+ String icon = tile == null ? icon(pm, ai) : null;+ if (tile != null) {+ line.append(",\"b\":").append(tile[0] & 0xffffffffL).append(",\"a\":").append(tile[1] & 0xffffffffL);+ } else if (icon != null) {+ line.append(",\"i\":\"").append(icon).append('"');+ }line.append("}\n");out.print(line);} catch (Throwable t) {@@ -101,6 +109,31 @@ public final class Labels {private static final int ICON = 0, BANNER = 1, APPLICATION_ICON = 2;+ /**+ * A banner shrunk into a square icon is a thin strip of logo, so a banner-only app gets a letter+ * tile in the banner's colours instead. Null when the banner doesn't draw: then [icon] tries.+ */+ private static int[] tile(PackageManager pm, ApplicationInfo ai) {+ try {+ Drawable d = ai.loadBanner(pm);+ if (d == null) return null;+ int w = d.getIntrinsicWidth(), h = d.getIntrinsicHeight();+ int bh = w > 0 && h > 0 ? Math.max(1, BANNER_PX * h / w) : BANNER_PX * 9 / 16;+ Bitmap b = Bitmap.createBitmap(BANNER_PX, Math.min(bh, BANNER_PX), Bitmap.Config.ARGB_8888);+ try {+ d.setBounds(0, 0, b.getWidth(), b.getHeight());+ d.draw(new Canvas(b));+ int[] pixels = new int[b.getWidth() * b.getHeight()];+ b.getPixels(pixels, 0, b.getWidth(), 0, 0, b.getWidth(), b.getHeight());+ return BannerColors.pick(pixels);+ } finally {+ b.recycle();+ }+ } catch (Throwable t) {+ return null;+ }+ }+private static Drawable art(PackageManager pm, ApplicationInfo ai, int kind) {switch (kind) {case ICON: return ai.loadIcon(pm);diff --git a/app/src/main/java/app/tellyscope/data/AdbDeviceSource.kt b/app/src/main/java/app/tellyscope/data/AdbDeviceSource.ktindex 201db59..1ad02c2 100644--- a/app/src/main/java/app/tellyscope/data/AdbDeviceSource.kt+++ b/app/src/main/java/app/tellyscope/data/AdbDeviceSource.kt@@ -351,7 +351,8 @@ class AdbDeviceSource(context: Context) : DeviceSource {AppInfo(packageName = p.name,label = name.label,- iconColor = null,+ iconColor = name.tileColor,+ iconAccent = name.tileAccent,system = p.name in system,enabled = p.name !in disabled,// Same rule as Actions.run: no known launcher, nothing can be stopped or disabled.diff --git a/app/src/main/java/app/tellyscope/data/AppNames.kt b/app/src/main/java/app/tellyscope/data/AppNames.ktindex 0c6814a..787fcba 100644--- a/app/src/main/java/app/tellyscope/data/AppNames.kt+++ b/app/src/main/java/app/tellyscope/data/AppNames.kt@@ -9,8 +9,11 @@ import kotlinx.coroutines.sync.withLockimport java.io.Fileimport java.util.Base64-/** What the app list shows for one package. [icon] is a PNG; null means a letter avatar. */-class AppName(val label: String, val icon: ByteArray?)+/**+ * What the app list shows for one package. [icon] is a PNG; null means a letter avatar, in+ * [tileColor] and [tileAccent] for a banner-only app.+ */+class AppName(val label: String, val icon: ByteArray?, val tileColor: Long? = null, val tileAccent: Long? = null)/*** Real app names and icons per TV. The TV's own labels come from `describe` (the label helper) and@@ -43,7 +46,7 @@ class AppNames(private val dir: File) {// Without a versionCode (an older pm) a cached label is as good as it gets.val outdated = hit == null || (p.versionCode != null && p.versionCode != hit.versionCode)// A run where the icon failed once mustn't cost the app its icon until its next update.- (outdated || (hit?.iconPng == null && (tv to p.name) !in asked)) && (tv to p.name) !in unanswered+ (outdated || (hit?.iconPng == null && hit?.tileColor == null && (tv to p.name) !in asked)) && (tv to p.name) !in unanswered}if (stale.isNotEmpty() && tv !in refused) {val fresh = describe(stale.map { it.name })@@ -57,7 +60,7 @@ class AppNames(private val dir: File) {}}packages.associate { p ->- p.name to (cache[p.name]?.let { AppName(it.label, it.iconPng) } ?: AppName(fallback(p.name), null))+ p.name to (cache[p.name]?.let { AppName(it.label, it.iconPng, it.tileColor, it.tileAccent) } ?: AppName(fallback(p.name), null))}}@@ -86,16 +89,20 @@ class AppNames(private val dir: File) {private fun fileName(tv: String) = tv.replace(Regex("[^A-Za-z0-9._-]"), "_") + ".tsv"- /** `package \t versionCode \t label \t base64 PNG`. A damaged line costs that app, not the file. */+ /**+ * `package \t versionCode \t label \t base64 PNG \t tile colour \t tile accent`. A damaged+ * line costs that app, not the file. Lines from before the tile columns don't load, so+ * every TV is read again and its squashed banner icons are replaced.+ */private fun load(file: File): Map<String, AppLabel> {if (!file.exists()) return emptyMap()return runCatching { file.readLines() }.getOrDefault(emptyList()).mapNotNull { line ->val f = line.split('\t')- if (f.size != 4) return@mapNotNull null+ if (f.size != 6) return@mapNotNull nullval version = f[1].toLongOrNull() ?: return@mapNotNull nullif (f[0].isEmpty() || f[2].isEmpty()) return@mapNotNull nullval icon = f[3].takeIf { it.isNotEmpty() }?.let { runCatching { Base64.getDecoder().decode(it) }.getOrNull() }- AppLabel(f[0], f[2], version, icon)+ AppLabel(f[0], f[2], version, icon, f[4].toLongOrNull(), f[5].toLongOrNull())}.associateBy { it.packageName }}@@ -106,7 +113,7 @@ class AppNames(private val dir: File) {labels.joinToString("") { a ->val label = a.label.replace(Regex("[\t\r\n]"), " ")val icon = a.iconPng?.let { Base64.getEncoder().encodeToString(it) }.orEmpty()- "${a.packageName}\t${a.versionCode}\t$label\t$icon\n"+ "${a.packageName}\t${a.versionCode}\t$label\t$icon\t${a.tileColor ?: ""}\t${a.tileAccent ?: ""}\n"},)if (!tmp.renameTo(file)) tmp.delete()diff --git a/app/src/main/java/app/tellyscope/data/Model.kt b/app/src/main/java/app/tellyscope/data/Model.ktindex 9fc557a..4f2707f 100644--- a/app/src/main/java/app/tellyscope/data/Model.kt+++ b/app/src/main/java/app/tellyscope/data/Model.kt@@ -115,6 +115,8 @@ data class AppInfo(val version: String,/** The app's own icon as a PNG, from the TV; null shows the letter avatar. */val icon: ByteArray? = null,+ /** ARGB of the letter on an [iconColor] avatar; null = white. A banner-only app's accent colour. */+ val iconAccent: Long? = null,/** Installed by the user (`pm list packages -3`), so Uninstall is offered. Never for apps that came with the TV. */val removable: Boolean = false,/** Another launcher that can replace the current home screen, [homeInstead]: "Set as default launcher" is offered. */diff --git a/app/src/main/java/app/tellyscope/ui/DeviceScreen.kt b/app/src/main/java/app/tellyscope/ui/DeviceScreen.ktindex 7bbcd90..cb51397 100644--- a/app/src/main/java/app/tellyscope/ui/DeviceScreen.kt+++ b/app/src/main/java/app/tellyscope/ui/DeviceScreen.kt@@ -334,15 +334,15 @@ internal fun EmptyLine(q: String) {@Composablefun AppIcon(app: AppInfo, modifier: Modifier = Modifier) {val image = remember(app.icon) {- // A 96 px icon is a few KB; anything far bigger is a TV sending something odd.- app.icon?.takeIf { it.size <= 64 * 1024 }?.let { BitmapFactory.decodeByteArray(it, 0, it.size)?.asImageBitmap() }+ // A 192 px icon is tens of KB; anything far bigger is a TV sending something odd.+ app.icon?.takeIf { it.size <= 256 * 1024 }?.let { BitmapFactory.decodeByteArray(it, 0, it.size)?.asImageBitmap() }}if (image != null) {Image(image, contentDescription = null, modifier.size(40.dp).clip(MaterialTheme.shapes.medium))return}val bg = app.iconColor?.let { Color(it) } ?: MaterialTheme.colorScheme.secondaryContainer- val fg = if (app.iconColor != null) Color.White else MaterialTheme.colorScheme.onSecondaryContainer+ val fg = app.iconAccent?.let { Color(it) } ?: if (app.iconColor != null) Color.White else MaterialTheme.colorScheme.onSecondaryContainerBox(modifier.size(40.dp).clip(MaterialTheme.shapes.medium).background(bg), contentAlignment = Alignment.Center) {Text(app.label.take(1).uppercase(), color = fg, style = MaterialTheme.typography.titleMedium)}diff --git a/app/src/test/java/app/tellyscope/AppNamesTest.kt b/app/src/test/java/app/tellyscope/AppNamesTest.ktindex 90cb863..212c9cb 100644--- a/app/src/test/java/app/tellyscope/AppNamesTest.kt+++ b/app/src/test/java/app/tellyscope/AppNamesTest.kt@@ -102,10 +102,29 @@ class AppNamesTest {}@Test fun damagedCacheLinesCostOnlyThatApp() = runBlocking {- File(tmp.root, "SN1.tsv").writeText("com.netflix.ninja\t10\tNetflix\tAQID\ngarbage line\ncom.example.weatherbox\tx\tW\t\n")+ File(tmp.root, "SN1.tsv").writeText("com.netflix.ninja\t10\tNetflix\tAQID\t\t\ngarbage line\ncom.example.weatherbox\tx\tW\t\t\t\n")val helper = Helper()val names = AppNames(tmp.root).names("SN1", listOf(netflix, odd), helper::describe)assertEquals("Netflix", names.getValue("com.netflix.ninja").label)assertEquals(listOf("com.example.weatherbox"), helper.runs.single())}++ @Test fun aBannerAppsTileColoursAreCached() = runBlocking {+ val tile = AppLabel(odd.name, "Weather", 3, null, 0xFF101010, 0xFF1ED760)+ val helper = Helper()+ AppNames(tmp.root).names("SN1", listOf(odd), { listOf(tile) })+ // A new launch reads the cache, and a tile counts as having its icon: no second run.+ val names = AppNames(tmp.root).names("SN1", listOf(odd), helper::describe)+ assertEquals(0xFF101010, names.getValue(odd.name).tileColor)+ assertEquals(0xFF1ED760, names.getValue(odd.name).tileAccent)+ assertEquals(0, helper.runs.size)+ }++ @Test fun cacheFromBeforeTilesIsReadAgain() = runBlocking {+ // The old four-column line held a squashed banner; it must not survive the update.+ File(tmp.root, "SN1.tsv").writeText("com.example.weatherbox\t3\tWeather\tAQID\n")+ val helper = Helper()+ AppNames(tmp.root).names("SN1", listOf(odd), helper::describe)+ assertEquals(listOf("com.example.weatherbox"), helper.runs.single())+ }}diff --git a/app/src/test/java/app/tellyscope/BannerColorsTest.kt b/app/src/test/java/app/tellyscope/BannerColorsTest.ktnew file mode 100644index 0000000..757eb8b--- /dev/null+++ b/app/src/test/java/app/tellyscope/BannerColorsTest.kt@@ -0,0 +1,52 @@+// SPDX-License-Identifier: GPL-3.0-only++package app.tellyscope++import app.tellyscope.helper.BannerColors+import org.junit.Assert.assertArrayEquals+import org.junit.Assert.assertEquals+import org.junit.Assert.assertNull+import org.junit.Test++class BannerColorsTest {+ /** A banner of [n] pixels: mostly [bg], with a run of each of [marks]. */+ private fun banner(bg: Int, vararg marks: Pair<Int, Int>, n: Int = 1000): IntArray {+ val px = IntArray(n) { bg }+ var i = 0+ for ((color, count) in marks) repeat(count) { px[i++] = color }+ return px+ }++ @Test fun backgroundIsTheMainColourAndTheLetterTheVividOne() {+ // Spotify: near-black, a green logo, white wordmark.+ val (bg, accent) = BannerColors.pick(banner(0xFF121212.toInt(), 0xFFFFFFFF.toInt() to 80, 0xFF1ED760.toInt() to 40))!!+ assertEquals(0xFF121212.toInt(), bg)+ assertEquals(0xFF1ED760.toInt(), accent)+ }++ @Test fun aSpeckIsNotTheAccent() {+ // Two stray red pixels in a thousand don't make the letter red.+ val (_, accent) = BannerColors.pick(banner(0xFF202020.toInt(), 0xFFFF0000.toInt() to 2, 0xFFF0F0F0.toInt() to 100))!!+ assertEquals(0xFFF0F0F0.toInt(), accent)+ }++ @Test fun anAccentTooCloseToTheBackgroundBecomesWhiteOrBlack() {+ // Mid blue on a slightly darker blue: under 3:1, so white on dark.+ val (bg, accent) = BannerColors.pick(banner(0xFF1A237E.toInt(), 0xFF3949AB.toInt() to 100))!!+ assertEquals(0xFF1A237E.toInt(), bg)+ assertEquals(0xFFFFFFFF.toInt(), accent)+ // And black on a pale background.+ assertEquals(0xFF000000.toInt(), BannerColors.pick(banner(0xFFFFF59D.toInt(), 0xFFFFEE58.toInt() to 100))!![1])+ }++ @Test fun aSingleColourBannerStillGetsAReadableLetter() {+ assertArrayEquals(intArrayOf(0xFF000000.toInt(), 0xFFFFFFFF.toInt()), BannerColors.pick(banner(0xFF000000.toInt())))+ }++ @Test fun seeThroughPixelsDontCount() {+ // Transparent padding around an orange logo: the tile is orange, not see-through.+ val px = banner(0x00000000, 0xFFFF6D00.toInt() to 300, 0xFF000000.toInt() to 50)+ assertEquals(0xFFFF6D00.toInt(), BannerColors.pick(px)!![0])+ assertNull(BannerColors.pick(IntArray(10)))+ }+}diff --git a/app/src/test/java/app/tellyscope/ScreenshotTest.kt b/app/src/test/java/app/tellyscope/ScreenshotTest.ktindex bc08480..8ab58ee 100644--- a/app/src/test/java/app/tellyscope/ScreenshotTest.kt+++ b/app/src/test/java/app/tellyscope/ScreenshotTest.kt@@ -955,6 +955,34 @@ class ScreenshotTest {compose.onNodeWithText(Copy.ADD_TO_DOCK).assertDoesNotExist()}+ /**+ * Banner-only apps as letter tiles, in the colours the helper picks from their banners, beside+ * a real square icon and an app with no icon at all: the Apps list and the dock.+ */+ private fun tilesState(): UiState {+ val projectivy = "com.spocky.projengmenu"+ val spotify = AppInfo("com.spotify.tv.android", "Spotify", 0xFF121212, false, true, null, "", removable = true, launchable = true, iconAccent = 0xFF1ED760)+ val mine = AppInfo("com.example.myapp", "My App", null, false, true, null, "1.0", removable = true, launchable = true)+ val s = md3State()+ val apps = s.device.apps.map { a ->+ when (a.packageName) {+ projectivy -> a.copy(iconColor = 0xFF1C120D, iconAccent = 0xFFFF6A13)+ "com.google.android.youtube.tv" -> a.copy(icon = realIcon(a.packageName))+ else -> a+ }+ } + spotify + mine+ val dock = listOf(Docked(projectivy, "Projectivy"), Docked(spotify.packageName, "Spotify"), Docked("com.google.android.youtube.tv", "YouTube"), Docked(mine.packageName, "My App"))+ return s.copy(device = s.device.copy(apps = apps, dock = dock))+ }++ @Test fun tiles_apps() = shot("13_tiles_apps") { DeviceTabsScreen(tilesState(), DeviceActions(), startTab = TvTab.Apps) }++ @Test fun tiles_apps_dark() = shot("13_tiles_apps", dark = true) { DeviceTabsScreen(tilesState(), DeviceActions(), startTab = TvTab.Apps) }++ @Test fun tiles_dock() = shot("13_tiles_dock") { RemoteScreen(tilesState(), RemoteActions()) }++ @Test fun tiles_dock_dark() = shot("13_tiles_dock", dark = true) { RemoteScreen(tilesState(), RemoteActions()) }+@Test fun remote_dockPicker() = shot("12_remote_dock_picker", screen = true, before = { compose.onNodeWithText(Copy.ADD_TO_DOCK).performClick() }) {RemoteScreen(remoteState(), RemoteActions())}