Release 0.1.5 with a reliable Settings update flow

The update button no longer disappears while downloading, so focus can't
be lost and the remote no longer jumps to Home from Settings. It shows
download progress, offers Install again after a cancelled installer, and
restores focus on return. Settings scrolls only as far as needed, shows
just the new version's notes above the buttons, and focused primary
buttons now stand apart from unfocused ones. Release bodies and the
manifest carry only that version's changelog section.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Elijah 2026-10-24 14:00:32 -07:00
parent 4ac18c8a45
commit 5442a41aed
14 changed files with 140 additions and 24 deletions

View file

@ -1,5 +1,12 @@
# Kaleido releases
## 0.1.5
- Show update download progress on the update button and with a progress bar under it.
- Keep focus on the update button while it downloads and after the installer closes, so the remote no longer jumps to Home from Settings.
- Offer Install again after the installer is cancelled, without downloading the update again.
- Stop Settings from scrolling when moving between buttons, show only the new version's notes above the update buttons, and make focused primary buttons clearly stand out.
## 0.1.4
- Halve the pause when switching between Home, Movies and TV Shows: cards fill in over a few frames under the page fade, and the tab highlights before the section changes.

View file

@ -14,6 +14,12 @@ import java.security.MessageDigest
import java.util.concurrent.TimeUnit
data class Release(val version: String,val url: String,val checksumUrl: String?,val notes: String)
/** Release bodies may hold the whole changelog; keep only [version]'s section. */
fun releaseNotes(body: String,version: String): String {
val heading=Regex("^## v?"+Regex.escape(version)+"[ \t]*$",RegexOption.MULTILINE).find(body) ?: return body.trim()
val end=Regex("^## ",RegexOption.MULTILINE).find(body,heading.range.last+1)?.range?.first ?: body.length
return body.substring(heading.range.last+1,end).trim()
}
object Versions {
fun newer(candidate: String,current: String): Boolean {
fun parts(v:String)=v.removePrefix("v").split('.').map {it.toIntOrNull() ?: return emptyList<Int>()}
@ -35,12 +41,12 @@ class AppUpdater(private val context: Context) {
if(manifest.isBlank())return@withContext null
val m=JSONObject(manifest)
if(!Versions.newer(m.getString("version"),BuildConfig.VERSION_NAME))return@withContext null
return@withContext Release(m.getString("version"),checkedUrl(m.getString("url")),checkedUrl(m.getString("checksumUrl")),m.optString("notes"))
return@withContext Release(m.getString("version"),checkedUrl(m.getString("url")),checkedUrl(m.getString("checksumUrl")),releaseNotes(m.optString("notes"),m.getString("version")))
}
val j=JSONObject(raw);if(j.optBoolean("draft")||j.optBoolean("prerelease")||!Versions.newer(j.optString("tag_name"),BuildConfig.VERSION_NAME))return@withContext null
val assets=j.optJSONArray("assets").objects();val apk=assets.firstOrNull{it.optString("name")=="Kaleido.apk"} ?: assets.firstOrNull{it.optString("name").endsWith(".apk")} ?: error("This release has no Android APK.")
val sha=assets.firstOrNull{it.optString("name")==apk.optString("name")+".sha256"}
Release(j.getString("tag_name").removePrefix("v"),checkedUrl(apk.getString("browser_download_url")),sha?.getString("browser_download_url")?.let(::checkedUrl),j.optString("body"))
Release(j.getString("tag_name").removePrefix("v"),checkedUrl(apk.getString("browser_download_url")),sha?.getString("browser_download_url")?.let(::checkedUrl),releaseNotes(j.optString("body"),j.getString("tag_name").removePrefix("v")))
}
suspend fun download(release: Release,onProgress: (Int)->Unit): File = withContext(Dispatchers.IO) {
val dir=File(context.cacheDir,"updates").apply{mkdirs()};val part=File(dir,"Kaleido.apk.part");val file=File(dir,"Kaleido.apk");part.delete();file.delete()

View file

@ -6,6 +6,7 @@ import androidx.lifecycle.viewModelScope
import androidx.compose.runtime.getValue
import androidx.compose.runtime.setValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.mutableFloatStateOf
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.Job
import kotlinx.coroutines.async
@ -59,6 +60,9 @@ class KaleidoViewModel(app: Application): AndroidViewModel(app) {
var updateStatus by mutableStateOf(""); private set
var downloadedApk by mutableStateOf<File?>(null); private set
var downloading by mutableStateOf(false); private set
var downloadProgress by mutableFloatStateOf(0f); private set
/** A verified APK for [update], kept so a cancelled installer can be reopened without downloading again. */
var readyApk by mutableStateOf<File?>(null); private set
var playbackMode by mutableStateOf(preferences.getInt("playbackModeV2",1)); private set
var watchedPercent by mutableStateOf(preferences.getInt("watchedPercent",80).coerceIn(50,100)); private set
var navigationSounds by mutableStateOf(preferences.getBoolean("navigationSounds",true)); private set
@ -264,11 +268,24 @@ class KaleidoViewModel(app: Application): AndroidViewModel(app) {
fun chooseNavigationSounds(value:Boolean){navigationSounds=value;preferences.edit().putBoolean("navigationSounds",value).apply()}
fun chooseQuality(value: Int){quality=value;preferences.edit().putInt("quality",value).apply()}
fun checkUpdate(manual: Boolean=true){viewModelScope.launch {
if(!manual&&System.currentTimeMillis()-preferences.getLong("lastUpdateCheck",0)<6*3600_000L)return@launch
if(downloading||!manual&&System.currentTimeMillis()-preferences.getLong("lastUpdateCheck",0)<6*3600_000L)return@launch
updateStatus="Checking for updates…"
try{update=updater.latest();preferences.edit().putLong("lastUpdateCheck",System.currentTimeMillis()).apply();updateStatus=if(update==null)"Kaleido is up to date." else "Version ${update!!.version} is available."}catch(e:Exception){updateStatus="Update check failed. ${e.message}"}
try{val previous=update?.version;update=updater.latest();if(update?.version!=previous)readyApk=null;preferences.edit().putLong("lastUpdateCheck",System.currentTimeMillis()).apply();updateStatus=if(update==null)"Kaleido is up to date." else "Version ${update!!.version} is available."}catch(e:Exception){updateStatus="Update check failed. ${e.message}"}
}}
fun downloadUpdate(){val release=update ?: return; if(downloading)return;viewModelScope.launch {downloading=true;try {downloadedApk=updater.download(release){progress -> updateStatus="Downloading update · $progress%"};updateStatus="Update verified. Ready to install."}catch(e:Exception){updateStatus=e.message ?: "Download failed."}finally{downloading=false}}}
fun downloadUpdate() {
val release=update ?: return
if(downloading)return
readyApk?.takeIf{it.exists()}?.let{downloadedApk=it;updateStatus="Opening the installer…";return}
viewModelScope.launch {
downloading=true;downloadProgress=0f
try {
val apk=updater.download(release){progress->downloadProgress=progress/100f;updateStatus="Downloading update · $progress%"}
readyApk=apk;downloadedApk=apk;updateStatus="Update verified. Opening the installer…"
}catch(e:Exception){updateStatus=e.message ?: "Download failed."}finally{downloading=false}
}
}
fun clearDownload(){downloadedApk=null}
/** Back from the system installer without updating: the verified APK can be installed again. */
fun installerReturned(){if(readyApk!=null&&!downloading)updateStatus="Update downloaded. Select Install ${update?.version.orEmpty()} to finish."}
fun debugPlay(id: String,offset: Long,mode: Int){if(!BuildConfig.DEBUG)return;launchLoad {playing=null;delay(150);playbackMode=mode;playing=api.details(id).copy(offset=offset);startFromZero=false}}
}

View file

@ -21,14 +21,16 @@ class MainActivity: ComponentActivity() {
if(packageManager.canRequestPackageInstalls()) pendingApk?.let(::installApk)
}
fun installApk(file: File) {
pendingApk=file
// Consume the request first: a denied permission or cancelled installer must not
// reopen on the next visit to Settings. Settings offers Install again instead.
model.clearDownload();pendingApk=file
if(!packageManager.canRequestPackageInstalls()) {
unknownSources.launch(Intent(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES,Uri.parse("package:$packageName")));return
}
val uri=FileProvider.getUriForFile(this,"$packageName.files",file)
@Suppress("DEPRECATION")
startActivity(Intent(Intent.ACTION_INSTALL_PACKAGE).setDataAndType(uri,"application/vnd.android.package-archive").addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION))
pendingApk=null;model.clearDownload()
pendingApk=null
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

View file

@ -36,6 +36,9 @@ import androidx.compose.ui.window.Dialog
import coil.compose.AsyncImage
import coil.request.ImageRequest
import coil.size.Precision
import androidx.compose.foundation.gestures.BringIntoViewSpec
import androidx.compose.foundation.gestures.LocalBringIntoViewSpec
import androidx.lifecycle.compose.LifecycleResumeEffect
import kotlinx.coroutines.delay
import kotlinx.coroutines.withTimeoutOrNull
import kotlinx.coroutines.flow.first
@ -140,7 +143,21 @@ val sortLabels=listOf("titleSort:asc" to "Title: A–Z","titleSort:desc" to "Tit
@Composable fun SettingsScreen(vm: KaleidoViewModel,install: (File)->Unit) {
var confirmSignOut by remember{mutableStateOf(false)};var modeDialog by remember{mutableStateOf(false)};var qualityDialog by remember{mutableStateOf(false)};var watchedDialog by remember{mutableStateOf(false)}
LaunchedEffect(vm.downloadedApk){vm.downloadedApk?.let(install)}
LazyColumn(contentPadding=PaddingValues(horizontal=Cinema.gutter,vertical=17.dp),verticalArrangement=Arrangement.spacedBy(16.dp)) {
// Returning from the package installer can leave nothing focused; the next D-pad press
// would then search from the top bar and open Home. Put focus back on the update actions.
var settingsFocused by remember{mutableStateOf(false)}
val updateFocus=remember{FocusRequester()}
val paused=remember{booleanArrayOf(false)}
LifecycleResumeEffect(Unit){
if(paused[0]){vm.installerReturned();if(!settingsFocused)runCatching{updateFocus.requestFocus()}}
onPauseOrDispose{paused[0]=true}
}
// TV's default scrolling pins focus a third of the way down, so even sideways moves
// shifted this page. Scroll only as far as needed to keep the focused control visible.
val density=LocalDensity.current
val scroll=remember(density){MinimalScroll(with(density){56.dp.toPx()})}
CompositionLocalProvider(LocalBringIntoViewSpec provides scroll) {
LazyColumn(Modifier.onFocusChanged{settingsFocused=it.hasFocus},contentPadding=PaddingValues(horizontal=Cinema.gutter,vertical=17.dp),verticalArrangement=Arrangement.spacedBy(16.dp)) {
item {Text("Settings",color=Accent,fontSize=29.sp,lineHeight=34.sp,fontWeight=FontWeight.SemiBold,letterSpacing=(-.8).sp)}
item{SettingsPanel("Plex connection") {Text(vm.session?.serverName.orEmpty(),color=Color.White,fontSize=20.sp,fontWeight=FontWeight.Bold);Text(if(vm.accountToken.isBlank())"Server connection · Link your Plex account to discover your servers"else "Plex account linked · Session encrypted with Android Keystore",color=Muted,fontSize=12.sp);Spacer(Modifier.height(14.dp));Row(horizontalArrangement=Arrangement.spacedBy(10.dp)){TvButton("Sign in with Plex",initialFocus=true,onClick={vm.beginAccountLink()});if(vm.accountToken.isNotBlank())TvButton("Choose server",onClick={vm.switchServer()});TvButton("Sign out",onClick={confirmSignOut=true})}}}
item{SettingsPanel("Playback") {Row(horizontalArrangement=Arrangement.spacedBy(12.dp)){TvButton("Mode: "+listOf("Original","Direct stream","Transcode")[vm.playbackMode],onClick={modeDialog=true});TvButton("Transcode quality: "+if(vm.quality>20000)"4K · 80 Mbps"else "1080p · 20 Mbps",onClick={qualityDialog=true})};Text("Direct stream is the default. Playback mode, audio, subtitles, speed, and quality can also be changed in the player.",color=Muted,fontSize=12.sp,modifier=Modifier.padding(top=12.dp))}}
@ -152,7 +169,28 @@ val sortLabels=listOf("titleSort:asc" to "Title: A–Z","titleSort:desc" to "Tit
TvButton("Navigation sounds: "+if(vm.navigationSounds)"On"else "Off",onClick={vm.chooseNavigationSounds(!vm.navigationSounds)})
Text("Play the TV's system tap when focus moves. Follows your TV's sound-effects setting.",color=Muted,fontSize=12.sp,lineHeight=18.sp,modifier=Modifier.padding(top=10.dp))
}}
item{SettingsPanel("Software updates") {Text("Kaleido ${BuildConfig.VERSION_NAME}",color=Color.White,fontSize=20.sp,fontWeight=FontWeight.Bold);Text(vm.updateStatus,color=Muted,fontSize=12.sp,modifier=Modifier.padding(vertical=8.dp));Text("Updates are checked automatically every six hours while Kaleido is in use.",color=Muted,fontSize=12.sp);Spacer(Modifier.height(14.dp));Row(horizontalArrangement=Arrangement.spacedBy(10.dp)){TvButton("Check for updates",onClick={vm.checkUpdate()});if(vm.update!=null&&!vm.downloading)TvButton("Download & install ${vm.update!!.version}",primary=true,onClick={vm.downloadUpdate()})};vm.update?.let{if(it.notes.isNotBlank())Text(it.notes.take(1800),color=Muted,fontSize=11.sp,modifier=Modifier.padding(top=12.dp))};Text("git.elijahkuntz.com/Elijah/Kaleido",color=Accent,fontSize=10.sp,modifier=Modifier.padding(top=14.dp))}}
item{SettingsPanel("Software updates") {
Text("Kaleido ${BuildConfig.VERSION_NAME}",color=Color.White,fontSize=20.sp,fontWeight=FontWeight.Bold)
Text(vm.updateStatus,color=Muted,fontSize=12.sp,modifier=Modifier.padding(vertical=8.dp))
Text("Updates are checked automatically every six hours while Kaleido is in use.",color=Muted,fontSize=12.sp)
// Notes sit above the actions, so scrolling to the buttons always reveals them.
vm.update?.let{if(it.notes.isNotBlank()){
Spacer(Modifier.height(16.dp));Eyebrow("What's new in ${it.version}")
Text(it.notes.take(1800),color=Cinema.secondary,fontSize=11.sp,lineHeight=17.sp,modifier=Modifier.padding(top=7.dp))
}}
Spacer(Modifier.height(16.dp))
Row(Modifier.focusRequester(updateFocus).focusRestorer(),horizontalArrangement=Arrangement.spacedBy(10.dp)) {
TvButton("Check for updates",onClick={vm.checkUpdate()})
// The update action never leaves while focused; it reports progress in place.
vm.update?.let{release->
val label=when{vm.downloading->"Downloading… ${(vm.downloadProgress*100).toInt()}%";vm.readyApk!=null->"Install ${release.version}";else->"Download & install ${release.version}"}
TvButton(label,primary=true,onClick={vm.downloadUpdate()})
}
}
if(vm.downloading)LinearProgressIndicator(progress={vm.downloadProgress},modifier=Modifier.padding(top=14.dp).width(340.dp).height(3.dp),color=Accent,trackColor=Color.White.copy(alpha=.14f),gapSize=0.dp,drawStopIndicator={})
Text("git.elijahkuntz.com/Elijah/Kaleido",color=Accent,fontSize=10.sp,modifier=Modifier.padding(top=14.dp))
}}
}
}
if(confirmSignOut)ChoiceDialog("Sign out of Plex?",listOf("Keep watching","Sign out"),0,{confirmSignOut=false}){if(it==1)vm.signOut();confirmSignOut=false}
if(watchedDialog) {
@ -162,6 +200,18 @@ val sortLabels=listOf("titleSort:asc" to "Title: A–Z","titleSort:desc" to "Tit
if(modeDialog)ChoiceDialog("Playback mode",listOf("Automatic · Original quality","Direct stream · Remux when possible","Transcode · Compatibility mode"),vm.playbackMode,{modeDialog=false}){vm.choosePlaybackMode(it);modeDialog=false}
if(qualityDialog)ChoiceDialog("Transcode quality",listOf("1080p · 20 Mbps","4K · 80 Mbps"),if(vm.quality>20000)1 else 0,{qualityDialog=false}){vm.chooseQuality(if(it==0)20000 else 80000);qualityDialog=false}
}
/** Scroll only as far as needed to reveal the focused control, keeping [margin] px clear of the edges. */
private class MinimalScroll(private val margin:Float):BringIntoViewSpec {
override fun calculateScrollDistance(offset:Float,size:Float,containerSize:Float):Float {
val leading=offset-margin;val trailing=offset+size+margin
return when {
leading>=0f&&trailing<=containerSize->0f
leading<0f&&trailing>containerSize->0f
kotlin.math.abs(leading)<kotlin.math.abs(trailing-containerSize)->leading
else->trailing-containerSize
}
}
}
@Composable fun SettingsPanel(title: String,content: @Composable ColumnScope.()->Unit) {Column(Modifier.fillMaxWidth().clip(RoundedCornerShape(9.dp)).background(Panel.copy(alpha=.65f)).padding(18.dp)){Eyebrow(title);Spacer(Modifier.height(11.dp));content()}}
@Composable fun EmptyState(title: String,message: String){Column(Modifier.padding(52.dp),verticalArrangement=Arrangement.spacedBy(12.dp)){Text(title,color=Color.White,fontSize=26.sp,fontWeight=FontWeight.Bold);Text(message,color=Muted,fontSize=14.sp)}}
@Composable fun ErrorDialog(message: String,dismiss: ()->Unit,retry: ()->Unit) {Dialog(onDismissRequest=dismiss){Column(Modifier.width(390.dp).clip(RoundedCornerShape(12.dp)).background(Panel).padding(23.dp)){Text("Something needs attention",color=Accent,fontSize=20.sp,lineHeight=26.sp,fontWeight=FontWeight.SemiBold);Text(message,color=Muted,fontSize=12.sp,lineHeight=19.sp,modifier=Modifier.padding(vertical=17.dp));Row(horizontalArrangement=Arrangement.spacedBy(9.dp)){TvButton("Try again",primary=true,initialFocus=true,onClick={dismiss();retry()});TvButton("Dismiss",onClick=dismiss)}}}}

View file

@ -54,12 +54,13 @@ object Cinema {
}
@Composable fun TvButton(label: String,modifier: Modifier=Modifier,selected: Boolean=false,primary: Boolean=false,initialFocus: Boolean=false,onClick: ()->Unit) {
var focused by remember { mutableStateOf(false) };val requester=remember {FocusRequester()}
val bg by animateColorAsState(if(focused) Accent else if(primary)Color(0xFFDEDEDE) else if(selected)Color.White.copy(alpha=.16f)else Color.White.copy(alpha=.08f),tween(150),label="buttonBackground")
val fg=if(focused||primary) Ink else Accent
// Only focus is solid white; a primary action is a brighter tint, so focus stays obvious.
val bg by animateColorAsState(if(focused) Accent else if(primary)Color.White.copy(alpha=.24f) else if(selected)Color.White.copy(alpha=.16f)else Color.White.copy(alpha=.08f),tween(150),label="buttonBackground")
val fg=if(focused) Ink else Accent
val scale by animateFloatAsState(if(focused)1.025f else 1f,tween(160),label="buttonScale")
LaunchedEffect(initialFocus){if(initialFocus){withFrameNanos{};runCatching{requester.requestFocus()}}}
Box(modifier.graphicsLayer{scaleX=scale;scaleY=scale}.focusRequester(requester).navigationSound().onFocusChanged{focused=it.isFocused}.clip(RoundedCornerShape(Cinema.radius)).background(bg).clickable(onClick=onClick).padding(horizontal=13.dp,vertical=8.dp)) {
Text(label,color=fg,fontSize=12.sp,lineHeight=16.sp,fontWeight=FontWeight.Medium,maxLines=1)
Text(label,color=fg,fontSize=12.sp,lineHeight=16.sp,fontWeight=if(primary)FontWeight.SemiBold else FontWeight.Medium,maxLines=1)
}
}
@Composable fun SectionHeading(title: String, subtitle: String?=null) {

View file

@ -0,0 +1,17 @@
package tv.kaleido.app
import org.junit.Assert.assertEquals
import org.junit.Test
class ReleaseNotesTest {
private val changelog="# Kaleido releases\n\n## 0.1.4\n\n- Smoother browsing.\n- Library focus.\n\n## 0.1.3\n\n- Aperture splash.\n"
@Test fun keepsOnlyTheReleasedVersionsSection() {
assertEquals("- Smoother browsing.\n- Library focus.",releaseNotes(changelog,"0.1.4"))
assertEquals("- Aperture splash.",releaseNotes(changelog,"0.1.3"))
}
@Test fun leavesNotesWithoutAMatchingHeadingIntact() {
assertEquals("- Only this release.",releaseNotes("\n- Only this release.\n","0.1.5"))
assertEquals(changelog.trim(),releaseNotes(changelog,"0.1.40"))
}
}

Binary file not shown.

View file

@ -1 +1 @@
859db6187e2f92410019606864957d2c8271162ef826ea4ddb23332c0f475681 Kaleido.apk
4831f17cb8e6c08254707bd66c1e210bc8e6d46fe112436bd8cfe7d2f629086c Kaleido.apk

View file

@ -1,7 +1,7 @@
{
"version": "0.1.4",
"versionCode": 5,
"url": "https://git.elijahkuntz.com/Elijah/Kaleido/raw/tag/v0.1.4/distribution/Kaleido.apk",
"checksumUrl": "https://git.elijahkuntz.com/Elijah/Kaleido/raw/tag/v0.1.4/distribution/Kaleido.apk.sha256",
"notes": "0.1.4\n\n- Halve the pause when switching between Home, Movies and TV Shows: cards fill in over a few frames under the page fade, and the tab highlights before the section changes.\n- Remove the freeze on the first move from the Home hero to the rows below, and the skipped frames when moving between Movies/TV rows.\n- The Library tab is now labelled \"Library\", and pressing Right from it moves to the genre, watch and sort controls instead of opening Home.\n- Reduce background image decoding and overdraw for smoother browsing on Fire TV Stick and other lower-powered TVs.\n"
"version": "0.1.5",
"versionCode": 6,
"url": "https://git.elijahkuntz.com/Elijah/Kaleido/raw/tag/v0.1.5/distribution/Kaleido.apk",
"checksumUrl": "https://git.elijahkuntz.com/Elijah/Kaleido/raw/tag/v0.1.5/distribution/Kaleido.apk.sha256",
"notes": "- Show update download progress on the update button and with a progress bar under it.\n- Keep focus on the update button while it downloads and after the installer closes, so the remote no longer jumps to Home from Settings.\n- Offer Install again after the installer is cancelled, without downloading the update again.\n- Stop Settings from scrolling when moving between buttons, show only the new version's notes above the update buttons, and make focused primary buttons clearly stand out."
}

View file

@ -104,3 +104,11 @@ Results (skipped frames per cycle; UI-thread maximum):
On the TCL, Home → Movies measured 196 ms of UI time before and 88 ms in the one completed final sample. Its final full run was skipped at the user's request because its ADB link kept dropping; the partial final run and the A/B runs showed no regressions. Movies row ← row still skips two frames on the onn. Returning from Movies still disposes and composes whole sections. Retaining sections across tabs would remove that cost but needs per-section navigation state.
`Build.ps1 -Release -Test` passed. On the onn, all six `verify_ui.py browse` checks and `repro_runtime.py sections` passed. A recording confirmed the staged cards fill in under the fade without bound changes. The final release was left installed on all three devices. Private evidence: `transitions-*.json`, `transitions-*-frames.txt`, `trace-*.txt` and the `onn-*` recordings in `evidence/private/`.
## Settings update flow on the Fire Stick - 2026-10-24
The user found that pressing "Download & install" on the Fire Stick appeared to do nothing, and after cancelling the package installer every D-pad press in Settings opened Home. Cause: the button was removed while downloading, so focus was lost with it; with nothing focused, the next press searched from the top bar and focused (which opens) Home. On TV, Compose's default bring-into-view pinned focused controls near a third of the screen height, so sideways moves scrolled Settings, and focused/unfocused primary buttons were nearly the same white. Release bodies carried the whole changelog.
The update action now stays in place and reports progress ("Downloading… n%" plus a progress bar), then offers "Install" for the verified APK, which reopens the installer without downloading again. Returning from the installer refreshes the status and restores focus to the update actions if nothing is focused. Settings scrolls only far enough to keep the focused control 56 dp from the edges, and shows only the new version's notes above the buttons. `publish_release.py` and `package_release.py` publish just the version's changelog section; `releaseNotes()` trims older full-changelog bodies, with unit coverage.
Verified on the Fire Stick with a build labelled 0.1.3 against published 0.1.4: check, download, installer, Back, then Left/Up/Down/Right all stayed within Settings with focus on "Install 0.1.4". The LAN download takes under a second, so a throwaway build that slowed the download loop (not committed) was used to capture "Downloading… 8%" with the progress bar. Completing the in-app update itself was left to the user.

View file

@ -1,5 +1,5 @@
"""Stage a locally signed APK for Git distribution and tag-triggered Forgejo releases."""
import hashlib, json, pathlib, shutil, subprocess
import hashlib, json, pathlib, re, shutil, subprocess
ROOT=pathlib.Path(__file__).resolve().parents[1]
version=dict(l.split('=',1) for l in (ROOT/'version.properties').read_text().splitlines() if '=' in l)
apk=ROOT/'app/build/outputs/apk/release/app-release.apk'
@ -10,6 +10,9 @@ digest=hashlib.sha256(apk.read_bytes()).hexdigest()
(out/'Kaleido.apk.sha256').write_text(digest+' Kaleido.apk\n')
repo='https://git.elijahkuntz.com/Elijah/Kaleido'
tag='v'+version['versionName']
manifest={'version':version['versionName'],'versionCode':int(version['versionCode']),'url':repo+'/raw/tag/'+tag+'/distribution/Kaleido.apk','checksumUrl':repo+'/raw/tag/'+tag+'/distribution/Kaleido.apk.sha256','notes':(ROOT/'CHANGELOG.md').read_text().split('\n## ')[1].split('\n## ')[0] if (ROOT/'CHANGELOG.md').exists() else ''}
# Only this version's section, matching the release body the app shows as notes.
changelog=(ROOT/'CHANGELOG.md').read_text() if (ROOT/'CHANGELOG.md').exists() else ''
section=re.search(r'^## v?'+re.escape(version['versionName'])+r'[ \t]*$(.*?)(?=^## |\Z)',changelog,re.M|re.S)
manifest={'version':version['versionName'],'versionCode':int(version['versionCode']),'url':repo+'/raw/tag/'+tag+'/distribution/Kaleido.apk','checksumUrl':repo+'/raw/tag/'+tag+'/distribution/Kaleido.apk.sha256','notes':section.group(1).strip() if section else ''}
(out/'latest.json').write_text(json.dumps(manifest,indent=2)+'\n')
print('Packaged',tag,'SHA-256',digest)

View file

@ -1,5 +1,5 @@
"""Publish the checked-in, signed APK using Forgejo's repository-scoped CI token."""
import hashlib, json, os, pathlib, urllib.request, uuid
import hashlib, json, os, pathlib, re, urllib.request, uuid
ROOT=pathlib.Path(__file__).resolve().parents[1]
API='https://git.elijahkuntz.com/api/v1/repos/Elijah/Kaleido'
token=os.environ['KALEIDO_RELEASE_TOKEN']
@ -8,6 +8,11 @@ tag='v'+version['versionName']
ref=os.environ.get('RELEASE_REF','')
assert ref=='refs/tags/'+tag,'Tag must match version.properties exactly'
out=ROOT/'distribution'
def notes():
"""Only this version's changelog section; the app shows the body as release notes."""
text=(ROOT/'CHANGELOG.md').read_text()
m=re.search(r'^## v?'+re.escape(version['versionName'])+r'[ \t]*$(.*?)(?=^## |\Z)',text,re.M|re.S)
return m.group(1).strip() if m else ''
assert hashlib.sha256((out/'Kaleido.apk').read_bytes()).hexdigest()==(out/'Kaleido.apk.sha256').read_text().split()[0]
def call(path,data=None,method=None,content='application/json'):
req=urllib.request.Request(API+path,data=data,method=method,headers={'Authorization':'token '+token,'Content-Type':content})
@ -15,7 +20,7 @@ def call(path,data=None,method=None,content='application/json'):
try:release=call('/releases/tags/'+tag)
except urllib.error.HTTPError as e:
if e.code!=404:raise
release=call('/releases',json.dumps({'tag_name':tag,'name':'Kaleido '+version['versionName'],'body':(ROOT/'CHANGELOG.md').read_text(),'draft':True,'prerelease':False}).encode(),'POST')
release=call('/releases',json.dumps({'tag_name':tag,'name':'Kaleido '+version['versionName'],'body':notes(),'draft':True,'prerelease':False}).encode(),'POST')
existing={a['name']:a for a in release.get('assets',[])}
for name in ['Kaleido.apk','Kaleido.apk.sha256']:
if name in existing:continue

View file

@ -1,2 +1,2 @@
versionName=0.1.4
versionCode=5
versionName=0.1.5
versionCode=6