From 6d9813b3b326d23e55bef0c5720408275c9d546f Mon Sep 17 00:00:00 2001 From: Terry Wang Date: Tue, 17 Nov 2026 07:51:33 +0800 Subject: [PATCH 1/2] feat: show the changelog in Settings The build copies release-notes/ into the app's assets, so Settings > What's new lists every release's notes, newest first, in the app's language with English as the fallback, and marks the installed version. It links to bellterm.app's changelog. GlassUiTest.t9 opens it on the CI emulator and keeps a screenshot. --- .github/workflows/ci.yml | 2 +- README.md | 6 ++- app/build.gradle.kts | 9 +++- .../java/app/bellterm/e2e/GlassUiTest.kt | 23 +++++++++ .../java/app/bellterm/data/ReleaseNotes.kt | 49 +++++++++++++++++++ .../bellterm/ui/settings/SettingsScreen.kt | 48 ++++++++++++++++++ app/src/main/res/values-zh/strings.xml | 3 ++ app/src/main/res/values/strings.xml | 3 ++ .../app/bellterm/data/ReleaseNotesTest.kt | 31 ++++++++++++ 9 files changed, 170 insertions(+), 4 deletions(-) create mode 100644 app/src/main/java/app/bellterm/data/ReleaseNotes.kt create mode 100644 app/src/test/java/app/bellterm/data/ReleaseNotesTest.kt diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c358771..708855e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -170,7 +170,7 @@ jobs: instrument -e publish_key 1 -e class "$test#t0_publishesDeviceKey" || exit 1 adb shell cat /sdcard/Android/data/app.bellterm/files/e2e/device.pub >> ~/.ssh/authorized_keys instrument -e host 10.0.2.2 -e port 2222 -e user "$(id -un)" -e fingerprint "$FINGERPRINT" \ - -e machine b-machine -e machine_workspace on-b -e class "$test#t8_switchesToSavedMachine" + -e machine b-machine -e machine_workspace on-b -e class "$test#t8_switchesToSavedMachine,$test#t9_changelogListsReleases" SCRIPT - uses: reactivecircus/android-emulator-runner@a421e43855164a8197daf9d8d40fe71c6996bb0d # v2.38.0 diff --git a/README.md b/README.md index b632fbb..5352c8f 100644 --- a/README.md +++ b/README.md @@ -240,8 +240,10 @@ whenever *Check for updates* is tapped in Settings. When it lists a higher the browser. To publish one: 1. Optionally write release notes to `release-notes/.en.txt` and - `.zh.txt` on `main`, and add the release to bellterm.app's changelog, - `site/changelog/` and `site/zh/changelog/`. + `.zh.txt` on `main`, one line per change: they become the update banner, + the GitHub release, and the app's **What's new** in Settings. Add the + release to bellterm.app's changelog too, `site/changelog/` and + `site/zh/changelog/`. 2. Run the Release workflow from the Actions tab with the version, such as `1.2.0`. It sets `versionName` and `versionCode` (`10200`) in `app/build.gradle.kts`, builds the APK with the release key (from the diff --git a/app/build.gradle.kts b/app/build.gradle.kts index feb63bb..75df775 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -64,6 +64,7 @@ android { } sourceSets["main"].jniLibs.directories.add(layout.buildDirectory.dir("rustJniLibs").get().asFile.path) sourceSets["main"].assets.directories.add(layout.buildDirectory.dir("legalAssets").get().asFile.path) + sourceSets["main"].assets.directories.add(layout.buildDirectory.dir("releaseNotesAssets").get().asFile.path) packaging { jniLibs.useLegacyPackaging = false } @@ -108,7 +109,13 @@ val legalAssets = tasks.register("legalAssets") { from(root.file("crates/herdr-protocol/NOTICE.md")) { rename { "herdr-protocol-NOTICE.md" } } into(layout.buildDirectory.dir("legalAssets/licenses")) } -tasks.named("preBuild") { dependsOn(buildRust, legalAssets) } +// release-notes/ feeds the update manifest, GitHub releases, and the in-app +// changelog alike, so the app ships the same files. +val releaseNotesAssets = tasks.register("releaseNotesAssets") { + from(rootProject.layout.projectDirectory.dir("release-notes")) { include("*.txt") } + into(layout.buildDirectory.dir("releaseNotesAssets/release-notes")) +} +tasks.named("preBuild") { dependsOn(buildRust, legalAssets, releaseNotesAssets) } kotlin { compilerOptions { diff --git a/app/src/androidTest/java/app/bellterm/e2e/GlassUiTest.kt b/app/src/androidTest/java/app/bellterm/e2e/GlassUiTest.kt index 2219e8b..14e3cfc 100644 --- a/app/src/androidTest/java/app/bellterm/e2e/GlassUiTest.kt +++ b/app/src/androidTest/java/app/bellterm/e2e/GlassUiTest.kt @@ -6,12 +6,14 @@ import android.content.Intent import android.os.Build import androidx.test.platform.app.InstrumentationRegistry import androidx.test.uiautomator.By +import androidx.test.uiautomator.Direction import androidx.test.uiautomator.BySelector import androidx.test.uiautomator.UiDevice import androidx.test.uiautomator.UiObject2 import androidx.test.uiautomator.Until import app.bellterm.BelltermApp import app.bellterm.R +import app.bellterm.data.ReleaseNotes import app.bellterm.data.ThemeMode import app.bellterm.ui.MainActivity import java.io.File @@ -282,6 +284,27 @@ class GlassUiTest { assertTrue("the host's machines go with it", device.wait(Until.gone(By.res("node:$machine")), TIMEOUT)) } + @Test + fun t9_changelogListsReleases() { + openMenu(R.string.settings) + val settings = need(By.res("settings")) + val entry = By.text(string(R.string.changelog)) + repeat(6) { if (!device.hasObject(entry)) settings.scroll(Direction.DOWN, 1f) } + need(entry).click() + need(By.res("changelog")) + need(By.textStartsWith("• ")) + // The installed version is marked when it has notes of its own. + val installed = context.packageManager.getPackageInfo(context.packageName, 0).versionName + if (ReleaseNotes.load(context, "en").any { it.version == installed }) { + need(By.text(string(R.string.changelog_installed, installed!!))) + } + shot("22_changelog") + need(By.text(string(android.R.string.ok))).click() + assertTrue(device.wait(Until.gone(By.res("changelog")), TIMEOUT)) + need(By.res("back")).click() + need(By.res("action:keys")) + } + /** Adds [host] from the instrumentation arguments as a node, opens it, and trusts its key when vouched for. */ private fun connectHost(host: String) { val args = InstrumentationRegistry.getArguments() diff --git a/app/src/main/java/app/bellterm/data/ReleaseNotes.kt b/app/src/main/java/app/bellterm/data/ReleaseNotes.kt new file mode 100644 index 0000000..a67c2b2 --- /dev/null +++ b/app/src/main/java/app/bellterm/data/ReleaseNotes.kt @@ -0,0 +1,49 @@ +package app.bellterm.data + +import android.content.Context + +/** One release's notes, a line each. */ +data class Release(val version: String, val notes: List) + +/** + * The changelog from `release-notes/..txt`, which the + * build copies into the app's assets: newest release first, in [language] + * where a release has it, else English. + */ +object ReleaseNotes { + private const val DIR = "release-notes" + + fun load(context: Context, language: String): List { + val names = context.assets.list(DIR).orEmpty() + return parse(names.associateWith { name -> context.assets.open("$DIR/$name").bufferedReader().use { it.readText() } }, language) + } + + /** [files] maps file names to their text. */ + fun parse(files: Map, language: String): List = + files.entries + .mapNotNull { (name, text) -> + val stem = name.removeSuffix(".txt").takeIf { it != name } ?: return@mapNotNull null + val version = stem.substringBeforeLast('.', "").takeIf { it.isNotEmpty() } ?: return@mapNotNull null + Triple(version, stem.substringAfterLast('.'), text) + } + .groupBy({ it.first }, { it.second to it.third }) + .map { (version, texts) -> + val text = texts.firstOrNull { it.first == language }?.second + ?: texts.firstOrNull { it.first == "en" }?.second + ?: texts.first().second + Release(version, text.lines().map(String::trim).filter(String::isNotEmpty)) + } + .filter { it.notes.isNotEmpty() } + .sortedWith(compareByDescending>(VersionOrder) { it.version.split('.').map { part -> part.toIntOrNull() ?: 0 } }) + + /** Compares dotted versions part by part, so 1.10.0 follows 1.9.0. */ + private object VersionOrder : Comparator> { + override fun compare(a: List, b: List): Int { + for (i in 0 until maxOf(a.size, b.size)) { + val diff = a.getOrElse(i) { 0 } - b.getOrElse(i) { 0 } + if (diff != 0) return diff + } + return 0 + } + } +} diff --git a/app/src/main/java/app/bellterm/ui/settings/SettingsScreen.kt b/app/src/main/java/app/bellterm/ui/settings/SettingsScreen.kt index 3b6515f..18c872b 100644 --- a/app/src/main/java/app/bellterm/ui/settings/SettingsScreen.kt +++ b/app/src/main/java/app/bellterm/ui/settings/SettingsScreen.kt @@ -20,6 +20,7 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.foundation.lazy.items import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.shape.RoundedCornerShape @@ -32,6 +33,7 @@ import androidx.compose.material.icons.filled.Face import androidx.compose.material.icons.filled.Info import androidx.compose.material.icons.filled.Notifications import androidx.compose.material.icons.filled.Refresh +import androidx.compose.material.icons.filled.Star import androidx.compose.material3.CircularProgressIndicator import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Icon @@ -59,6 +61,7 @@ import androidx.compose.ui.draw.dropShadow import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.shadow.Shadow import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.platform.LocalUriHandler import androidx.compose.ui.platform.testTag import androidx.compose.ui.res.stringResource import androidx.compose.ui.semantics.Role @@ -71,6 +74,7 @@ import app.bellterm.BelltermApp import app.bellterm.R import app.bellterm.data.AppLanguage import app.bellterm.data.AppLanguages +import app.bellterm.data.ReleaseNotes import app.bellterm.data.ThemeMode import app.bellterm.data.UpdateState import app.bellterm.ui.components.Group @@ -103,6 +107,7 @@ fun SettingsScreen(app: BelltermApp, onBack: () -> Unit) { val snackbar = remember { SnackbarHostState() } val progress = remember { mutableStateMapOf() } var licenses by remember { mutableStateOf(false) } + var changelog by remember { mutableStateOf(false) } val update by app.updates.state.collectAsState() val download = rememberOpenDownload() val fontPicker = rememberLauncherForActivityResult(ActivityResultContracts.OpenDocument()) { uri -> @@ -263,6 +268,13 @@ fun SettingsScreen(app: BelltermApp, onBack: () -> Unit) { ) } GlassDivider() + ItemRow( + title = stringResource(R.string.changelog), + leading = { IconBadge(Icons.Default.Star, Color(0xFFE0A030)) }, + onClick = { changelog = true }, + chevron = true, + ) + GlassDivider() ItemRow( title = stringResource(R.string.licenses), leading = { IconBadge(Icons.AutoMirrored.Filled.List, Color(0xFF8A8F98)) }, @@ -274,6 +286,39 @@ fun SettingsScreen(app: BelltermApp, onBack: () -> Unit) { } } + if (changelog) { + val chinese = context.resources.configuration.locales[0].language == "zh" + val releases = remember(chinese) { ReleaseNotes.load(context, if (chinese) "zh" else "en") } + val installed = remember { context.packageManager.getPackageInfo(context.packageName, 0).versionName } + val uris = LocalUriHandler.current + GlassAlertDialog( + onDismissRequest = { changelog = false }, + title = { Text(stringResource(R.string.changelog)) }, + text = { + LazyColumn(Modifier.testTag("changelog"), verticalArrangement = Arrangement.spacedBy(16.dp)) { + items(releases, key = { it.version }) { release -> + Column(verticalArrangement = Arrangement.spacedBy(6.dp)) { + Text( + if (release.version == installed) stringResource(R.string.changelog_installed, release.version) else release.version, + style = MaterialTheme.typography.titleSmall, + fontWeight = FontWeight.SemiBold, + ) + release.notes.forEach { note -> + Text("• $note", style = MaterialTheme.typography.bodyMedium) + } + } + } + } + }, + confirmButton = { TextButton(onClick = { changelog = false }) { Text(stringResource(android.R.string.ok)) } }, + dismissButton = { + TextButton(onClick = { uris.openUri(if (chinese) CHANGELOG_ZH else CHANGELOG_EN) }) { + Text(stringResource(R.string.changelog_website)) + } + }, + ) + } + if (licenses) { val text = remember { listOf( @@ -426,3 +471,6 @@ private fun LanguagePicker() { ) } } + +private const val CHANGELOG_EN = "https://bellterm.app/changelog/" +private const val CHANGELOG_ZH = "https://bellterm.app/zh/changelog/" diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index 4ed71cf..0119a87 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -213,6 +213,9 @@ 关于 版本 %1$s 开源许可 + 更新日志 + %1$s · 当前版本 + 在网站上查看 检查更新 正在检查… 已是最新版本 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0f2b185..242c864 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -219,6 +219,9 @@ About Version %1$s Open source licences + What’s new + %1$s · installed + On the website Check for updates Checking… You’re up to date diff --git a/app/src/test/java/app/bellterm/data/ReleaseNotesTest.kt b/app/src/test/java/app/bellterm/data/ReleaseNotesTest.kt new file mode 100644 index 0000000..64bb5d6 --- /dev/null +++ b/app/src/test/java/app/bellterm/data/ReleaseNotesTest.kt @@ -0,0 +1,31 @@ +package app.bellterm.data + +import org.junit.Assert.assertEquals +import org.junit.Test + +class ReleaseNotesTest { + private val files = mapOf( + "1.1.1.en.txt" to "Saved machines.\n", + "1.1.1.zh.txt" to "保存的机器。\n", + "1.9.0.en.txt" to "Nine.\n", + "1.10.0.en.txt" to "First line.\n\n Second line. \n", + "1.0.1.en.txt" to "Glass.\n", + "2.0.0.en.txt" to "\n", + "README.md" to "not notes", + ) + + @Test + fun newestFirstInTheAskedLanguageElseEnglish() { + assertEquals( + listOf( + Release("1.10.0", listOf("First line.", "Second line.")), + Release("1.9.0", listOf("Nine.")), + Release("1.1.1", listOf("保存的机器。")), + Release("1.0.1", listOf("Glass.")), + ), + ReleaseNotes.parse(files, "zh"), + ) + assertEquals(listOf("Saved machines."), ReleaseNotes.parse(files, "en").first { it.version == "1.1.1" }.notes) + assertEquals(listOf("Saved machines."), ReleaseNotes.parse(files, "fr").first { it.version == "1.1.1" }.notes) + } +} From cef2d15039f38092812eb3b3526da0fd607e2080 Mon Sep 17 00:00:00 2001 From: Terry Wang Date: Tue, 17 Nov 2026 08:02:12 +0800 Subject: [PATCH 2/2] docs: release notes and site changelog for 1.1.2 --- release-notes/1.1.2.en.txt | 1 + release-notes/1.1.2.zh.txt | 1 + site/changelog/index.html | 6 ++++++ site/zh/changelog/index.html | 6 ++++++ 4 files changed, 14 insertions(+) create mode 100644 release-notes/1.1.2.en.txt create mode 100644 release-notes/1.1.2.zh.txt diff --git a/release-notes/1.1.2.en.txt b/release-notes/1.1.2.en.txt new file mode 100644 index 0000000..a4b1556 --- /dev/null +++ b/release-notes/1.1.2.en.txt @@ -0,0 +1 @@ +Settings has a What's new page listing each release's changes, with the installed version marked. diff --git a/release-notes/1.1.2.zh.txt b/release-notes/1.1.2.zh.txt new file mode 100644 index 0000000..499de54 --- /dev/null +++ b/release-notes/1.1.2.zh.txt @@ -0,0 +1 @@ +设置里新增“更新日志”页面,列出每个版本的改动,并标出当前安装的版本。 diff --git a/site/changelog/index.html b/site/changelog/index.html index 7b08ea7..d620b28 100644 --- a/site/changelog/index.html +++ b/site/changelog/index.html @@ -35,6 +35,12 @@

Changelog

Android releases, newest first. The Android app offers each one on its own; the iOS beta on TestFlight picks up the same changes in a later build.

+

1.1.2

+

· Android · Release on GitHub

+
    +
  • What's new in the app. Settings has a What's new page listing each release's changes, newest first, with the installed version marked and a link to this page.
  • +
+

1.1.1

· Android · Release on GitHub

    diff --git a/site/zh/changelog/index.html b/site/zh/changelog/index.html index 52aa717..c979722 100644 --- a/site/zh/changelog/index.html +++ b/site/zh/changelog/index.html @@ -35,6 +35,12 @@

    更新日志

    Android 版本,最新的在前。Android 应用会自动提示新版本;TestFlight 上的 iOS 测试版会在之后的构建中带上同样的改动。

    +

    1.1.2

    +

    · Android · GitHub 上的发布

    +
      +
    • 应用内的更新日志。设置里新增“更新日志”页面,按版本从新到旧列出改动,标出当前安装的版本,并可跳转到本页。
    • +
    +

    1.1.1

    · Android · GitHub 上的发布