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.

What's new: show an update's versions above the installed one

jesse-agent-232dc736ebe02b2
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2c977b5..2deb4e7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,7 +13,7 @@ until this file has a section for its version.
## Unreleased
- **New:** Spanish, Chinese, Japanese and Russian translations, machine-made; corrections welcome. [#272](../../pull/272)
-- **New:** Settings › What's new shows what changed in each version, offline. [#271](../../pull/271)
+- **New:** Settings › What's new shows what changed in each version, and what an update brings. [#271](../../pull/271)
- **Improved:** Tweaks shows the same TV-offline screen as Files. [#273](../../pull/273)
- **Fixed:** With the TV away, app rows grey out and won't open. [#273](../../pull/273)
- **Fixed:** Connect says when the phone has dropped off Wi-Fi, and Try again waits for Wi-Fi instead of failing at once. [#274](../../pull/274)
diff --git a/NOTICE b/NOTICE
index 17f1803..bb7970b 100644
--- a/NOTICE
+++ b/NOTICE
@@ -27,7 +27,8 @@ The TV and HDMI (streaming stick) device icons use the path data of the
Apps, Files and Tweaks tabs those of "apps", "folder" and "tune", the
Upload files button that of "upload", the empty Movies folder that of
"movie", the links in Settings that of "open_in_new", Settings' What's new
-row that of the Material Symbols "new_releases", and the Remote's
+row that of the Material Symbols "new_releases", What's new's Update card
+and can't-load line those of "system_update" and "cloud_off", and the Remote's
restart, waiting and can't-reach icons and the Remote buttons sheet's drag
handle those of "restart_alt", "hourglass_top", "link_off" and
"drag_handle".
diff --git a/app/src/main/java/app/tellyscope/MainActivity.kt b/app/src/main/java/app/tellyscope/MainActivity.kt
index ab5c59c..79b8bfd 100644
--- a/app/src/main/java/app/tellyscope/MainActivity.kt
+++ b/app/src/main/java/app/tellyscope/MainActivity.kt
@@ -326,7 +326,8 @@ fun TellyscopeApp(vm: TellyscopeViewModel) {
AccessScreen(state, accessActions(vm) { access = false }, snackbar = snackbar)
} else if (whatsNew) {
BackHandler { whatsNew = false }
- WhatsNewScreen(rememberChangelog(), back = { whatsNew = false })
+ LaunchedEffect(state.available) { vm.loadNewer() }
+ WhatsNewScreen(rememberChangelog(), back = { whatsNew = false }, available = state.available, newer = state.newer, onUpdate = vm::reopenUpdate)
} else if (settings) {
BackHandler { settings = false }
SettingsScreen(
diff --git a/app/src/main/java/app/tellyscope/data/UpdateCheck.kt b/app/src/main/java/app/tellyscope/data/UpdateCheck.kt
index 1d77819..0878ef1 100644
--- a/app/src/main/java/app/tellyscope/data/UpdateCheck.kt
+++ b/app/src/main/java/app/tellyscope/data/UpdateCheck.kt
@@ -11,6 +11,7 @@ import java.util.Properties
/** Where releases are published: the app's own GitHub repo. */
const val RELEASES = "https://github.com/man15h/tellyscope/releases"
+private val REPO = RELEASES.removePrefix("https://github.com/").removeSuffix("/releases")
private const val RELEASES_API = "https://api.github.com/repos/man15h/tellyscope/releases?per_page=20"
/** How long a check counts for: release builds ask every 30 minutes, alpha builds every 5 minutes for testing. */
@@ -60,6 +61,23 @@ class UpdateCheck(
newest(text, alpha)?.takeIf { compareVersions(it.version, current) > 0 && it.version != p.getProperty("skip") }
}
+ /**
+ * The released CHANGELOG sections past [current], newest first, read from the branch this build
+ * updates from: `main`, or `dev` on alpha builds. Null on any failure. No interval: What's new
+ * asks only once the check has found an update.
+ */
+ suspend fun newer(): List<Changelog.Release>? = withContext(Dispatchers.IO) {
+ val text = try {
+ fetch("https://raw.githubusercontent.com/$REPO/${if (alpha) "dev" else "main"}/${Changelog.ASSET}").decodeToString()
+ } catch (e: CancellationException) {
+ throw e
+ } catch (_: Exception) {
+ return@withContext null
+ }
+ // An alpha's own section is its base version's, as for the Installed chip.
+ Changelog.parse(text).filter { compareVersions(it.version, current.substringBefore('-')) > 0 }
+ }
+
private fun props() = Properties().apply {
runCatching { file.takeIf { it.exists() }?.inputStream()?.use(::load) }
}
diff --git a/app/src/main/java/app/tellyscope/ui/TellyscopeViewModel.kt b/app/src/main/java/app/tellyscope/ui/TellyscopeViewModel.kt
index 1ca2a0b..64776cc 100644
--- a/app/src/main/java/app/tellyscope/ui/TellyscopeViewModel.kt
+++ b/app/src/main/java/app/tellyscope/ui/TellyscopeViewModel.kt
@@ -25,6 +25,7 @@ import app.tellyscope.adb.Tweak
import app.tellyscope.adb.installKind
import app.tellyscope.data.Action
import app.tellyscope.data.AppInfo
+import app.tellyscope.data.Changelog
import app.tellyscope.data.ConnectResult
import app.tellyscope.data.Device
import app.tellyscope.data.DeviceSource
@@ -298,6 +299,10 @@ data class UiState(
val alphaBuild: Boolean = false,
/** A newer release to offer; cleared once the user answers. */
val update: Update? = null,
+ /** The newest release the last check found; unlike [update] it stays after Later, for What's new. */
+ val available: Update? = null,
+ /** What's new's CHANGELOG sections past the installed version, once [available] is set: empty until read, null if they couldn't be. */
+ val newer: List<Changelog.Release>? = emptyList(),
/** A Remote key press vibrates. */
val keyHaptics: Boolean = true,
/** The TVs whose picture the Remote turned off. */
@@ -1782,7 +1787,7 @@ class TellyscopeViewModel(
if (updateJob?.isActive == true || _state.value.update != null) return
updateJob = viewModelScope.launch(Dispatchers.IO) {
// Null on any failure: no offer looks the same as no newer release.
- u.check()?.let { found -> _state.update { it.copy(update = found) } }
+ u.check()?.let { found -> _state.update { it.copy(update = found, available = found) } }
}
}
@@ -1794,10 +1799,25 @@ class TellyscopeViewModel(
/** "Skip this version": never offered again; a later release still is. */
fun skipUpdate() {
val version = _state.value.update?.version ?: return
- _state.update { it.copy(update = null) }
+ _state.update { it.copy(update = null, available = null) }
viewModelScope.launch(Dispatchers.IO) { updates?.skip(version) }
}
+ /** What's new's Update card: the update check's offer again. */
+ fun reopenUpdate() {
+ _state.update { it.copy(update = it.available) }
+ }
+
+ /** What's new is open and an update is known: read the versions in between from GitHub. */
+ fun loadNewer() {
+ val u = updates ?: return
+ if (_state.value.available == null) return
+ viewModelScope.launch(Dispatchers.IO) {
+ val newer = u.newer()
+ _state.update { it.copy(newer = newer) }
+ }
+ }
+
/** Folds or opens [tab]'s System section, and keeps it that way across restarts. */
fun foldSystem(tab: AppsTab, folded: Boolean) {
_state.update { it.copy(foldedSystem = if (folded) it.foldedSystem + tab else it.foldedSystem - tab) }
diff --git a/app/src/main/java/app/tellyscope/ui/WhatsNewScreen.kt b/app/src/main/java/app/tellyscope/ui/WhatsNewScreen.kt
index 3f876a0..64d5c03 100644
--- a/app/src/main/java/app/tellyscope/ui/WhatsNewScreen.kt
+++ b/app/src/main/java/app/tellyscope/ui/WhatsNewScreen.kt
@@ -1,8 +1,10 @@
// SPDX-License-Identifier: GPL-3.0-only
-// The What's new icon is the Material Symbols "new_releases" (Apache-2.0), see NOTICE.
+// The What's new, update and offline icons are the Material Symbols "new_releases", "system_update" and "cloud_off"
+// (Apache-2.0), see NOTICE.
package app.tellyscope.ui
+import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
@@ -21,6 +23,7 @@ import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
+import androidx.compose.material3.Button
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.ExperimentalMaterial3Api
@@ -61,6 +64,7 @@ import app.tellyscope.data.Changelog
import app.tellyscope.data.Changelog.Change
import app.tellyscope.data.Changelog.Kind
import app.tellyscope.data.Changelog.Release
+import app.tellyscope.data.Update
import java.time.LocalDate
import java.time.format.DateTimeFormatter
import java.util.Locale
@@ -78,10 +82,21 @@ fun rememberChangelog(): List<Release> {
* Inside a card the changes keep the file's order, which is New, then Improved, then Fixed, so a
* heading goes in wherever the kind changes. [installed] is the running versionName; its release
* gets an Installed chip whether or not this is an alpha.
+ *
+ * Once the update check has found [available], an Update card opens its offer again, and the
+ * [newer] sections from GitHub go on top with a Not installed chip. Null [newer] means they
+ * couldn't be read: one grey line says so instead.
*/
@OptIn(ExperimentalMaterial3Api::class)
@Composable
-fun WhatsNewScreen(releases: List<Release>, back: () -> Unit, installed: String = installedVersion()) {
+fun WhatsNewScreen(
+ releases: List<Release>,
+ back: () -> Unit,
+ installed: String = installedVersion(),
+ available: Update? = null,
+ newer: List<Release>? = emptyList(),
+ onUpdate: () -> Unit = {},
+) {
val browser = LocalUriHandler.current
val openPr = { pr: Int -> runCatching { browser.openUri(Changelog.pullUrl(pr)) }; Unit }
Scaffold(
@@ -99,9 +114,17 @@ fun WhatsNewScreen(releases: List<Release>, back: () -> Unit, installed: String
contentPadding = PaddingValues(start = 16.dp, end = 16.dp, bottom = 32.dp),
verticalArrangement = Arrangement.spacedBy(12.dp),
) {
- items(releases, key = { it.version }) { r ->
+ if (available != null) {
+ if (newer == null) {
+ item(key = "failed") { NewerFailed() }
+ } else {
+ item(key = "update") { UpdateCard(available, installed, onUpdate) }
+ }
+ }
+ val ahead = if (available == null) emptyList() else newer.orEmpty().filter { n -> releases.none { it.version == n.version } }
+ items(ahead + releases, key = { it.version }) { r ->
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
- VersionHeading(r, isInstalled = r.version == installed.substringBefore('-'))
+ VersionHeading(r, isInstalled = r.version == installed.substringBefore('-'), notInstalled = r in ahead)
Card(colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surfaceContainer)) {
r.changes.forEachIndexed { i, c ->
val kindChanged = i == 0 || r.changes[i - 1].kind != c.kind
@@ -117,7 +140,7 @@ fun WhatsNewScreen(releases: List<Release>, back: () -> Unit, installed: String
}
@Composable
-private fun VersionHeading(r: Release, isInstalled: Boolean) {
+private fun VersionHeading(r: Release, isInstalled: Boolean, notInstalled: Boolean = false) {
Row(Modifier.fillMaxWidth().padding(top = 8.dp, start = 4.dp), verticalAlignment = Alignment.CenterVertically) {
Text(r.version, style = MaterialTheme.typography.titleLarge)
r.date?.let {
@@ -133,6 +156,41 @@ private fun VersionHeading(r: Release, isInstalled: Boolean) {
color = MaterialTheme.colorScheme.onSecondaryContainer,
)
}
+ if (notInstalled) Surface(shape = RoundedCornerShape(8.dp), border = BorderStroke(1.dp, MaterialTheme.colorScheme.outline)) {
+ Text(
+ stringResource(R.string.whats_new_not_installed),
+ Modifier.padding(horizontal = 8.dp, vertical = 2.dp),
+ style = MaterialTheme.typography.labelMedium,
+ color = MaterialTheme.colorScheme.onSurfaceVariant,
+ )
+ }
+ }
+}
+
+/** "Tellyscope 0.14.0 is out · You have 0.13.0." Update opens the update check's dialog again. */
+@Composable
+private fun UpdateCard(available: Update, installed: String, onUpdate: () -> Unit) {
+ Card(Modifier.padding(top = 8.dp), colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.primaryContainer)) {
+ Row(Modifier.fillMaxWidth().padding(start = 16.dp, end = 16.dp, top = 12.dp, bottom = 12.dp), verticalAlignment = Alignment.CenterVertically) {
+ Icon(SystemUpdate, contentDescription = null, tint = MaterialTheme.colorScheme.onPrimaryContainer)
+ Spacer(Modifier.width(16.dp))
+ Column(Modifier.weight(1f)) {
+ Text(stringResource(R.string.whats_new_update_out, available.version), style = MaterialTheme.typography.titleSmall, color = MaterialTheme.colorScheme.onPrimaryContainer)
+ Text(stringResource(R.string.whats_new_you_have, installed), style = MaterialTheme.typography.bodyMedium, color = MaterialTheme.colorScheme.onPrimaryContainer)
+ }
+ Spacer(Modifier.width(12.dp))
+ Button(onClick = onUpdate) { Text(stringResource(R.string.whats_new_update)) }
+ }
+ }
+}
+
+/** An update is known, but its versions couldn't be read from GitHub. */
+@Composable
+private fun NewerFailed() {
+ Row(Modifier.fillMaxWidth().padding(top = 8.dp, start = 4.dp), verticalAlignment = Alignment.CenterVertically) {
+ Icon(CloudOff, contentDescription = null, Modifier.size(20.dp), tint = MaterialTheme.colorScheme.onSurfaceVariant)
+ Spacer(Modifier.width(12.dp))
+ Text(stringResource(R.string.whats_new_newer_failed), style = MaterialTheme.typography.bodyMedium, color = MaterialTheme.colorScheme.onSurfaceVariant)
}
}
@@ -205,13 +263,23 @@ private fun ChangeItem(c: Change, openPr: (Int) -> Unit, topPadding: Dp) {
}
}
-internal val NewReleases = ImageVector.Builder("NewReleases", 24.dp, 24.dp, 960f, 960f)
+internal val NewReleases = symbol(
+ "NewReleases",
+ "m344-60-76-128-144-32 14-148-98-112 98-112-14-148 144-32 76-128 136 58 136-58 76 128 144 32-14 148 98 112-98 112 14 148-144 32-76 128-136-58-136 58Zm34-102 102-44 104 44 56-96 110-26-10-112 74-84-74-86 10-112-110-24-58-96-102 44-104-44-56 96-110 24 10 112-74 86 74 84-10 114 110 24 58 96Zm102-318Zm-42 142 226-226-56-58-170 170-86-84-56 56 142 142Z",
+)
+
+private fun symbol(name: String, path: String) = ImageVector.Builder(name, 24.dp, 24.dp, 960f, 960f)
.addGroup(translationY = 960f)
- .addPath(
- PathParser().parsePathString(
- "m344-60-76-128-144-32 14-148-98-112 98-112-14-148 144-32 76-128 136 58 136-58 76 128 144 32-14 148 98 112-98 112 14 148-144 32-76 128-136-58-136 58Zm34-102 102-44 104 44 56-96 110-26-10-112 74-84-74-86 10-112-110-24-58-96-102 44-104-44-56 96-110 24 10 112-74 86 74 84-10 114 110 24 58 96Zm102-318Zm-42 142 226-226-56-58-170 170-86-84-56 56 142 142Z",
- ).toNodes(),
- pathFillType = PathFillType.NonZero, fill = SolidColor(Color.Black),
- )
+ .addPath(PathParser().parsePathString(path).toNodes(), pathFillType = PathFillType.NonZero, fill = SolidColor(Color.Black))
.clearGroup()
.build()
+
+private val SystemUpdate = symbol(
+ "SystemUpdate",
+ "M280-40q-33 0-56.5-23.5T200-120v-720q0-33 23.5-56.5T280-920h400q33 0 56.5 23.5T760-840v124q18 7 29 22t11 34v80q0 19-11 34t-29 22v404q0 33-23.5 56.5T680-40H280Zm0-80h400v-720H280v720Zm0 0v-720 720Zm200-200 160-160-56-56-64 62v-166h-80v166l-64-62-56 56 160 160Z",
+)
+
+private val CloudOff = symbol(
+ "CloudOff",
+ "M792-56 686-160H260q-92 0-156-64T40-380q0-77 47.5-137T210-594q3-8 6-15.5t6-16.5L56-792l56-56 736 736-56 56ZM260-240h346L284-562q-2 11-3 21t-1 21h-20q-58 0-99 41t-41 99q0 58 41 99t99 41Zm185-161Zm419 191-58-56q17-14 25.5-32.5T840-340q0-42-29-71t-71-29h-60v-80q0-83-58.5-141.5T480-720q-27 0-52 6.5T380-693l-58-58q35-24 74.5-36.5T480-800q117 0 198.5 81.5T760-520q69 8 114.5 59.5T920-340q0 39-15 72.5T864-210ZM593-479Z",
+)
diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml
index 31ef956..42c8228 100644
--- a/app/src/main/res/values-es/strings.xml
+++ b/app/src/main/res/values-es/strings.xml
@@ -995,6 +995,11 @@
<string name="whats_new_new">Nuevo</string>
<string name="whats_new_improved">Mejorado</string>
<string name="whats_new_fixed">Corregido</string>
+ <string name="whats_new_update_out">Tellyscope %1$s ya está disponible</string>
+ <string name="whats_new_you_have">Tienes la %1$s.</string>
+ <string name="whats_new_update">Actualizar</string>
+ <string name="whats_new_not_installed">No instalada</string>
+ <string name="whats_new_newer_failed">No se pudieron cargar las versiones nuevas.</string>
<string name="settings_advanced">Avanzado</string>
<string name="settings_change">Cambiar</string>
<string name="settings_change_text">Pega la carpeta raw HTTPS que contiene index.json, p. ej., raw.githubusercontent.com/&lt;tu-usuario&gt;/tellyscope-devices/main/</string>
diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml
index 14f4b9c..1ffb648 100644
--- a/app/src/main/res/values-ja/strings.xml
+++ b/app/src/main/res/values-ja/strings.xml
@@ -911,6 +911,11 @@
<string name="whats_new_new">新機能</string>
<string name="whats_new_improved">改善</string>
<string name="whats_new_fixed">修正</string>
+ <string name="whats_new_update_out">Tellyscope %1$s が公開されました</string>
+ <string name="whats_new_you_have">現在のバージョンは %1$s です。</string>
+ <string name="whats_new_update">アップデート</string>
+ <string name="whats_new_not_installed">未インストール</string>
+ <string name="whats_new_newer_failed">新しいバージョンを読み込めませんでした。</string>
<string name="settings_advanced">詳細設定</string>
<string name="settings_change">変更</string>
<string name="settings_change_text">index.json を含む HTTPS の raw フォルダを貼り付けてください。例: raw.githubusercontent.com/&lt;you&gt;/tellyscope-devices/main/</string>
diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml
index 6aad09d..893d3f0 100644
--- a/app/src/main/res/values-ru/strings.xml
+++ b/app/src/main/res/values-ru/strings.xml
@@ -1037,6 +1037,11 @@
<string name="whats_new_new">Новое</string>
<string name="whats_new_improved">Улучшено</string>
<string name="whats_new_fixed">Исправлено</string>
+ <string name="whats_new_update_out">Вышла версия Tellyscope %1$s</string>
+ <string name="whats_new_you_have">У вас версия %1$s.</string>
+ <string name="whats_new_update">Обновить</string>
+ <string name="whats_new_not_installed">Не установлена</string>
+ <string name="whats_new_newer_failed">Не удалось загрузить новые версии.</string>
<string name="settings_advanced">Дополнительно</string>
<string name="settings_change">Изменить</string>
<string name="settings_change_text">Вставьте адрес HTTPS-папки raw, в которой лежит index.json, например raw.githubusercontent.com/&lt;you&gt;/tellyscope-devices/main/</string>
diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml
index ec73893..3eead4a 100644
--- a/app/src/main/res/values-zh-rCN/strings.xml
+++ b/app/src/main/res/values-zh-rCN/strings.xml
@@ -911,6 +911,11 @@
<string name="whats_new_new">新增</string>
<string name="whats_new_improved">改进</string>
<string name="whats_new_fixed">修复</string>
+ <string name="whats_new_update_out">Tellyscope %1$s 已发布</string>
+ <string name="whats_new_you_have">你的版本是 %1$s。</string>
+ <string name="whats_new_update">更新</string>
+ <string name="whats_new_not_installed">未安装</string>
+ <string name="whats_new_newer_failed">无法加载更新的版本。</string>
<string name="settings_advanced">高级</string>
<string name="settings_change">更改</string>
<string name="settings_change_text">粘贴包含 index.json 的 HTTPS 原始文件夹地址,例如 raw.githubusercontent.com/&lt;you&gt;/tellyscope-devices/main/</string>
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index ba51418..4da14ef 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1186,6 +1186,11 @@
<string name="whats_new_new">New</string>
<string name="whats_new_improved">Improved</string>
<string name="whats_new_fixed">Fixed</string>
+ <string name="whats_new_update_out">Tellyscope %1$s is out</string>
+ <string name="whats_new_you_have">You have %1$s.</string>
+ <string name="whats_new_update">Update</string>
+ <string name="whats_new_not_installed">Not installed</string>
+ <string name="whats_new_newer_failed">Couldn’t load newer versions.</string>
<string name="settings_advanced">Advanced</string>
<!-- Heading: how to change where the debloat lists come from -->
<string name="settings_change">Change</string>
diff --git a/app/src/test/java/app/tellyscope/ScreenshotTest.kt b/app/src/test/java/app/tellyscope/ScreenshotTest.kt
index 020884c..56ea2e1 100644
--- a/app/src/test/java/app/tellyscope/ScreenshotTest.kt
+++ b/app/src/test/java/app/tellyscope/ScreenshotTest.kt
@@ -123,6 +123,7 @@ import app.tellyscope.ui.ReportUi
import app.tellyscope.ui.SettingsScreen
import app.tellyscope.ui.WhatsNewScreen
import app.tellyscope.data.Changelog
+import app.tellyscope.data.Update
import app.tellyscope.ui.SHARE_TEXT
import app.tellyscope.data.RELEASES
import androidx.compose.ui.platform.UriHandler
@@ -690,14 +691,42 @@ class ScreenshotTest {
/** The repo's own CHANGELOG.md, as bundled, with the newest release installed as an alpha. */
private fun whatsNew(opened: MutableList<String> = mutableListOf()) = @Composable {
- val file = generateSequence(File("").absoluteFile) { it.parentFile }.map { File(it, Changelog.ASSET) }.first { it.exists() }
- val releases = Changelog.parse(file.readText())
val links = object : UriHandler { override fun openUri(uri: String) { opened += uri } }
CompositionLocalProvider(LocalUriHandler provides links) {
- WhatsNewScreen(releases, back = {}, installed = releases.first().version + "-alpha.1")
+ WhatsNewScreen(changelog, back = {}, installed = changelog.first().version + "-alpha.1")
}
}
+ private val changelog by lazy {
+ Changelog.parse(generateSequence(File("").absoluteFile) { it.parentFile }.map { File(it, Changelog.ASSET) }.first { it.exists() }.readText())
+ }
+
+ /** An update is out: the newest release isn't installed, the one before it is. [newer] null = GitHub unreachable. */
+ private fun whatsNewUpdate(newer: Boolean, onUpdate: () -> Unit = {}) = @Composable {
+ val (latest, installed) = changelog
+ WhatsNewScreen(
+ changelog.drop(1), back = {}, installed = installed.version,
+ available = Update(latest.version, "", ""), newer = if (newer) listOf(latest) else null, onUpdate = onUpdate,
+ )
+ }
+
+ @Test fun whatsNew_updateWaiting() {
+ var updates = 0
+ shot("97_whats_new_update") { whatsNewUpdate(newer = true) { updates++ }() }
+ compose.onNodeWithText("Not installed").assertExists()
+ compose.onNodeWithText("Installed").assertExists()
+ compose.onNodeWithText("Update").performClick()
+ assertEquals(1, updates)
+ }
+
+ @Test fun whatsNew_updateWaiting_dark() = shot("97_whats_new_update", dark = true) { whatsNewUpdate(newer = true)() }
+
+ @Test fun whatsNew_newerFailed() {
+ shot("98_whats_new_newer_failed") { whatsNewUpdate(newer = false)() }
+ compose.onNodeWithText("Couldn’t load newer versions.").assertExists()
+ compose.onNodeWithText("Not installed").assertDoesNotExist()
+ }
+
@Test fun whatsNew_installedAndLinks() {
val opened = mutableListOf<String>()
shot("96_whats_new") { whatsNew(opened)() }
diff --git a/app/src/test/java/app/tellyscope/UpdateCheckTest.kt b/app/src/test/java/app/tellyscope/UpdateCheckTest.kt
index 3a6cfb9..7c28033 100644
--- a/app/src/test/java/app/tellyscope/UpdateCheckTest.kt
+++ b/app/src/test/java/app/tellyscope/UpdateCheckTest.kt
@@ -136,6 +136,19 @@ class UpdateCheckTest {
assertEquals(0, calls)
}
+ @Test fun `newer reads the branch's CHANGELOG and keeps only versions past the installed one`() = runTest {
+ val urls = mutableListOf<String>()
+ val md = "# Changelog\n\n## Unreleased\n\n- **New:** Later.\n\n## 0.3.0 — 2026-10-30\n\n- **New:** Three.\n\n## 0.2.0 — 2026-10-29\n\n- **New:** Two.\n"
+ val newer = UpdateCheck(tmp.newFile(), "0.2.0", alpha = false) { urls += it; md.toByteArray() }.newer()
+ assertEquals(listOf("0.3.0"), newer?.map { it.version })
+ assertTrue(urls.single().endsWith("/main/CHANGELOG.md"))
+ // An alpha reads dev, and its own section is its base version's.
+ val alpha = UpdateCheck(tmp.newFile(), "0.2.0-alpha.4", alpha = true) { urls += it; md.toByteArray() }.newer()
+ assertEquals(listOf("0.3.0"), alpha?.map { it.version })
+ assertTrue(urls.last().endsWith("/dev/CHANGELOG.md"))
+ assertNull(UpdateCheck(tmp.newFile(), "0.2.0", alpha = false) { throw IOException("offline") }.newer())
+ }
+
/** v0.1.0's body as release.yml wrote it, commit list cut short. */
private val prodBody = """