Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/<version>.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
Expand Down
9 changes: 8 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -108,7 +109,13 @@ val legalAssets = tasks.register<Copy>("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<Copy>("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 {
Expand Down
23 changes: 23 additions & 0 deletions app/src/androidTest/java/app/bellterm/e2e/GlassUiTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
49 changes: 49 additions & 0 deletions app/src/main/java/app/bellterm/data/ReleaseNotes.kt
Original file line number Diff line number Diff line change
@@ -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<String>)

/**
* The changelog from `release-notes/<version>.<language>.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<Release> {
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<String, String>, language: String): List<Release> =
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<Release, List<Int>>(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<List<Int>> {
override fun compare(a: List<Int>, b: List<Int>): 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
}
}
}
48 changes: 48 additions & 0 deletions app/src/main/java/app/bellterm/ui/settings/SettingsScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -103,6 +107,7 @@ fun SettingsScreen(app: BelltermApp, onBack: () -> Unit) {
val snackbar = remember { SnackbarHostState() }
val progress = remember { mutableStateMapOf<String, Float>() }
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 ->
Expand Down Expand Up @@ -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)) },
Expand All @@ -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(
Expand Down Expand Up @@ -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/"
3 changes: 3 additions & 0 deletions app/src/main/res/values-zh/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@
<string name="section_about">关于</string>
<string name="about_text">版本 %1$s</string>
<string name="licenses">开源许可</string>
<string name="changelog">更新日志</string>
<string name="changelog_installed">%1$s · 当前版本</string>
<string name="changelog_website">在网站上查看</string>
<string name="check_updates">检查更新</string>
<string name="update_checking">正在检查…</string>
<string name="update_up_to_date">已是最新版本</string>
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@
<string name="section_about">About</string>
<string name="about_text">Version %1$s</string>
<string name="licenses">Open source licences</string>
<string name="changelog">What’s new</string>
<string name="changelog_installed">%1$s · installed</string>
<string name="changelog_website">On the website</string>
<string name="check_updates">Check for updates</string>
<string name="update_checking">Checking…</string>
<string name="update_up_to_date">You’re up to date</string>
Expand Down
31 changes: 31 additions & 0 deletions app/src/test/java/app/bellterm/data/ReleaseNotesTest.kt
Original file line number Diff line number Diff line change
@@ -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)
}
}
1 change: 1 addition & 0 deletions release-notes/1.1.2.en.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Settings has a What's new page listing each release's changes, with the installed version marked.
1 change: 1 addition & 0 deletions release-notes/1.1.2.zh.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
设置里新增“更新日志”页面,列出每个版本的改动,并标出当前安装的版本。
6 changes: 6 additions & 0 deletions site/changelog/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@
<h1>Changelog</h1>
<p class="meta">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.</p>

<h2 id="1.1.2">1.1.2</h2>
<p class="meta"><time datetime="2026-11-17">17 November 2026</time> · Android · <a href="https://github.com/nimrc/bellterm/releases/tag/v1.1.2">Release on GitHub</a></p>
<ul>
<li><strong>What's new in the app.</strong> 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.</li>
</ul>

<h2 id="1.1.1">1.1.1</h2>
<p class="meta"><time datetime="2026-11-16">16 November 2026</time> · Android · <a href="https://github.com/nimrc/bellterm/releases/tag/v1.1.1">Release on GitHub</a></p>
<ul>
Expand Down
6 changes: 6 additions & 0 deletions site/zh/changelog/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@
<h1>更新日志</h1>
<p class="meta">Android 版本,最新的在前。Android 应用会自动提示新版本;TestFlight 上的 iOS 测试版会在之后的构建中带上同样的改动。</p>

<h2 id="1.1.2">1.1.2</h2>
<p class="meta"><time datetime="2026-11-17">2026 年 11 月 17 日</time> · Android · <a href="https://github.com/nimrc/bellterm/releases/tag/v1.1.2">GitHub 上的发布</a></p>
<ul>
<li><strong>应用内的更新日志。</strong>设置里新增“更新日志”页面,按版本从新到旧列出改动,标出当前安装的版本,并可跳转到本页。</li>
</ul>

<h2 id="1.1.1">1.1.1</h2>
<p class="meta"><time datetime="2026-11-16">2026 年 11 月 16 日</time> · Android · <a href="https://github.com/nimrc/bellterm/releases/tag/v1.1.1">GitHub 上的发布</a></p>
<ul>
Expand Down
Loading