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.
Bundle CHANGELOG.md as an asset and parse its released sections
jesse-agent-232e3fe63d455df
diff --git a/app/build.gradle.kts b/app/build.gradle.ktsindex 0849455..1a12c2d 100644--- a/app/build.gradle.kts+++ b/app/build.gradle.kts@@ -127,6 +127,22 @@ val dexLabelHelper by tasks.registering(DexLabelHelper::class) {outputDir = layout.buildDirectory.dir("generated/labelHelper/assets")}+/** The repo's CHANGELOG.md, shipped as an asset so What's new matches the installed version, offline. */+abstract class BundleChangelog : DefaultTask() {+ @get:InputFile abstract val changelog: RegularFileProperty+ @get:OutputDirectory abstract val outputDir: DirectoryProperty++ @TaskAction fun copy() {+ val out = outputDir.get().asFile.also { it.deleteRecursively(); it.mkdirs() }+ changelog.get().asFile.copyTo(out.resolve("CHANGELOG.md"))+ }+}++val bundleChangelog by tasks.registering(BundleChangelog::class) {+ changelog = rootProject.layout.projectDirectory.file("CHANGELOG.md")+ outputDir = layout.buildDirectory.dir("generated/changelog/assets")+}+/** Fails the build when a release APK grows past the 3.5 MB budget. CI's `build` and release.yml both assemble release. */abstract class CheckApkSize : DefaultTask() {@get:InputFiles abstract val apkDir: DirectoryProperty@@ -147,6 +163,7 @@ abstract class CheckApkSize : DefaultTask() {androidComponents {onVariants { variant ->variant.sources.assets?.addGeneratedSourceDirectory(dexLabelHelper, DexLabelHelper::outputDir)+ variant.sources.assets?.addGeneratedSourceDirectory(bundleChangelog, BundleChangelog::outputDir)}onVariants(selector().withBuildType("release")) { variant ->val name = variant.name.replaceFirstChar { it.uppercase() }diff --git a/app/src/main/java/app/tellyscope/data/Changelog.kt b/app/src/main/java/app/tellyscope/data/Changelog.ktnew file mode 100644index 0000000..116d3dc--- /dev/null+++ b/app/src/main/java/app/tellyscope/data/Changelog.kt@@ -0,0 +1,47 @@+// SPDX-License-Identifier: GPL-3.0-only++package app.tellyscope.data++/**+ * CHANGELOG.md, bundled as an asset at build time, read for What's new. Only the released sections+ * count: the header paragraph and `## Unreleased` are left out. Everything stays in the file's order.+ */+object Changelog {+ const val ASSET = "CHANGELOG.md"++ enum class Kind(val label: String) { New("New"), Improved("Improved"), Fixed("Fixed") }++ /** One change. [pr] is the pull request it links to, if any; [details] are its indented points. */+ data class Change(val kind: Kind?, val text: String, val pr: Int?, val details: List<String> = emptyList())++ data class Release(val version: String, val date: String?, val changes: List<Change>)++ private val HEADING = Regex("""^## (.+?)(?: — (.+))?$""")+ private val ITEM = Regex("""^- (?:\*\*(\w+):\*\* )?(.*?)(?: \[#(\d+)]\([^)]*\))?$""")+ private val DETAIL = Regex("""^\s+- (.*)$""")++ fun parse(markdown: String): List<Release> {+ val releases = mutableListOf<Release>()+ var heading: Pair<String, String?>? = null+ val changes = mutableListOf<Change>()+ fun close() {+ heading?.let { (v, d) -> if (!v.equals("Unreleased", ignoreCase = true)) releases += Release(v, d, changes.toList()) }+ changes.clear()+ }+ for (line in markdown.lineSequence().map(String::trimEnd)) {+ val h = HEADING.matchEntire(line)+ val d = DETAIL.matchEntire(line)+ val i = ITEM.matchEntire(line)+ when {+ h != null -> { close(); heading = h.groupValues[1].trim() to h.groupValues[2].ifBlank { null } }+ heading == null -> {}+ d != null -> changes.removeLastOrNull()?.let { changes += it.copy(details = it.details + d.groupValues[1]) }+ i != null -> changes += Change(+ Kind.entries.firstOrNull { it.name == i.groupValues[1] }, i.groupValues[2], i.groupValues[3].toIntOrNull(),+ )+ }+ }+ close()+ return releases+ }+}diff --git a/app/src/test/java/app/tellyscope/ChangelogTest.kt b/app/src/test/java/app/tellyscope/ChangelogTest.ktnew file mode 100644index 0000000..4299a12--- /dev/null+++ b/app/src/test/java/app/tellyscope/ChangelogTest.kt@@ -0,0 +1,66 @@+// SPDX-License-Identifier: GPL-3.0-only++package app.tellyscope++import app.tellyscope.data.Changelog+import app.tellyscope.data.Changelog.Change+import app.tellyscope.data.Changelog.Kind+import org.junit.Assert.assertEquals+import org.junit.Assert.assertTrue+import org.junit.Test+import java.io.File++class ChangelogTest {++ private val sample = """+ # Changelog++ What changed in each Tellyscope release. Headings are `## <version> — <date>`.+ - not a change: before any heading++ ## Unreleased++ - **Fixed:** Not released yet. [#9](../../pull/9)++ ## 0.13.0 — 2026-10-29++ - **New:** Remote buttons open Netflix and more. [#224](../../pull/224)+ - Hold a button to pick up to three.+ - Screen off moved into ⋮.+ - **Fixed:** On Fire TV, Open opens the app. [#248](../../pull/248)++ ## 0.12.0 — 2026-10-28++ - **Improved:** The Remote opens as a sheet. [#198](../../pull/198)+ """.trimIndent()++ @Test fun readsReleasedSectionsInTheFilesOrder() {+ val releases = Changelog.parse(sample)+ assertEquals(listOf("0.13.0", "0.12.0"), releases.map { it.version })+ assertEquals(listOf("2026-10-29", "2026-10-28"), releases.map { it.date })+ assertEquals(+ listOf(+ Change(Kind.New, "Remote buttons open Netflix and more.", 224, listOf("Hold a button to pick up to three.", "Screen off moved into ⋮.")),+ Change(Kind.Fixed, "On Fire TV, Open opens the app.", 248),+ ),+ releases[0].changes,+ )+ assertEquals(listOf(Change(Kind.Improved, "The Remote opens as a sheet.", 198)), releases[1].changes)+ }++ @Test fun aHeadingWithoutADateStillCounts() {+ val r = Changelog.parse("## 1.0.0\n\n- A line with no tag or link\n").single()+ assertEquals(null, r.date)+ assertEquals(Change(null, "A line with no tag or link", null), r.changes.single())+ }++ /** The bundled file itself: every released line has a tag and a PR, so the page never shows a bare line. */+ @Test fun theRepoChangelogParsesCleanly() {+ val file = generateSequence(File("").absoluteFile) { it.parentFile }.map { File(it, Changelog.ASSET) }.first { it.exists() }+ val releases = Changelog.parse(file.readText())+ assertTrue(releases.isNotEmpty())+ assertTrue(releases.none { it.version.equals("Unreleased", ignoreCase = true) })+ val bare = releases.flatMap { r -> r.changes.filter { it.kind == null || it.pr == null }.map { "${r.version}: ${it.text}" } }+ assertEquals(emptyList<String>(), bare)+ }+}