Add Detour, BritX, Orbit Junior and Orbit Wild, and a subtitles and audio panel (0.63.0)
pauljd/davidson-ci: Davidson CI / quality (push) Failing after 1m53s
pauljd/davidson-ci: Davidson CI / ai-review (push) Failing after 1m22s

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-11-02 11:01:27 +00:00
co-authored by Claude Opus 5.5
parent a39f01a800
commit a534aed53c
31 changed files with 213 additions and 44 deletions
@@ -11,6 +11,10 @@ internal object ChannelBrands {
112 to ChannelBranding("orbit-three", "Orbit Three", R.drawable.orbit_three_epg, R.drawable.orbit_three_background, R.drawable.orbit_three_bug, ChannelCategory.Comedy),
113 to ChannelBranding("orbit-riot", "Orbit Riot", R.drawable.orbit_riot_epg, R.drawable.orbit_riot_background, R.drawable.orbit_riot_bug, ChannelCategory.Comedy),
142 to ChannelBranding("orbit-dark-files", "Orbit Dark Files", R.drawable.orbit_dark_files_epg, R.drawable.orbit_dark_files_background, R.drawable.orbit_dark_files_bug, ChannelCategory.Documentaries),
114 to ChannelBranding("orbit-detour", "Orbit Detour", R.drawable.orbit_detour_epg, R.drawable.orbit_one_background, R.drawable.orbit_detour_bug, ChannelCategory.Movies),
115 to ChannelBranding("orbit-britx", "Orbit BritX", R.drawable.orbit_britx_epg, R.drawable.orbit_one_background, R.drawable.orbit_britx_bug, ChannelCategory.Movies),
125 to ChannelBranding("orbit-junior", "Orbit Junior", R.drawable.orbit_junior_epg, R.drawable.orbit_one_background, R.drawable.orbit_junior_bug, ChannelCategory.Kids),
143 to ChannelBranding("orbit-wild", "Orbit Wild", R.drawable.orbit_wild_epg, R.drawable.orbit_one_background, R.drawable.orbit_wild_bug, ChannelCategory.Documentaries),
121 to ChannelBranding("heroes", "Orbit Heroes", R.drawable.heroes_epg, R.drawable.heroes_background, R.drawable.heroes_bug, ChannelCategory.Cartoons),
122 to ChannelBranding("toonz", "Orbit ToonZ", R.drawable.toonz_epg, R.drawable.toonz_background, R.drawable.toonz_bug, ChannelCategory.Cartoons),
123 to ChannelBranding("rewind", "Orbit Rewind", R.drawable.rewind_epg, R.drawable.rewind_background, R.drawable.rewind_bug, ChannelCategory.Cartoons),
@@ -3,7 +3,9 @@ package tv.orbit.classic
/** A channel the app can build from named shows. Numbers follow the design and may change with the generic channel list. */
internal data class ChannelPreset(val number: Int, val name: String, val searches: List<String>,
/** Started from its smart schedule alone, with no separate loop to build first. */
val smartOnly: Boolean = false)
val smartOnly: Boolean = false,
/** A film channel: curated titles, each resting a week between showings. */
val films: Boolean = false)
internal val DarkFilesCrime = listOf("Forensic Files", "Cold Case Files", "The First 48", "Making a Murderer", "The Staircase", "The Jinx", "I Am a Killer", "Evil Lives Here", "Conversations with a Killer: The Ted Bundy Tapes", "Crime Scene: The Vanishing at the Cecil Hotel",
"Snapped", "American Justice", "City Confidential", "Homicide Hunter", "The Keepers", "Don't F**k with Cats: Hunting an Internet Killer", "The Confession Tapes", "Night Stalker: The Hunt for a Serial Killer",
@@ -39,12 +41,25 @@ internal val ChannelPresets = listOf(
ChannelPreset(141, "Evidence", listOf("CSI: Crime Scene Investigation", "NCIS", "CSI: Miami", "CSI: NY", "Law & Order", "Law & Order: Special Victims Unit", "Criminal Minds", "Bones",
"Castle", "The Mentalist", "Monk", "Columbo", "Midsomer Murders", "Vera", "Luther", "Line of Duty", "Taggart", "Silent Witness", "Waking the Dead", "A Touch of Frost", "Dexter", "Sherlock", "Broadchurch", "Death in Paradise", "Lewis", "Inspector Morse",
"Dalziel and Pascoe", "Happy Valley", "The Wire", "Hawaii Five-0", "Blue Bloods"), smartOnly = true),
ChannelPreset(142, "Dark Files", DarkFilesCrime + DarkFilesMysteries + DarkFilesParanormal, smartOnly = true))
ChannelPreset(142, "Dark Files", DarkFilesCrime + DarkFilesMysteries + DarkFilesParanormal, smartOnly = true),
ChannelPreset(114, "Detour", listOf("American Pie", "American Pie 2", "American Wedding", "American Reunion", "Road Trip", "EuroTrip", "Harold & Kumar Go to White Castle", "Harold & Kumar Escape from Guantanamo Bay",
"A Very Harold & Kumar Christmas", "The Hangover", "The Hangover Part II", "The Hangover Part III", "Van Wilder", "Van Wilder: The Rise of Taj", "Old School", "Sex Drive", "Accepted", "Superbad", "Pineapple Express",
"Dude, Where's My Car?", "Without a Paddle", "The Girl Next Door", "Not Another Teen Movie", "Project X", "21 & Over", "Beerfest", "Grandma's Boy", "Waiting..."), smartOnly = true, films = true),
ChannelPreset(115, "BritX", listOf("Shaun of the Dead", "Hot Fuzz", "The World's End", "Lock, Stock and Two Smoking Barrels", "Snatch", "RocknRolla", "Layer Cake", "Trainspotting", "T2 Trainspotting", "Green Street",
"The Football Factory", "Dog Soldiers", "Dead Man's Shoes", "28 Days Later", "28 Weeks Later", "This Is England", "The Gentlemen", "The Business", "The Firm", "Rise of the Footsoldier", "The 51st State", "Sexy Beast",
"The Bank Job", "The Long Good Friday", "Human Traffic", "Twin Town", "Shallow Grave", "Four Lions", "Severance", "Attack the Block", "The Descent", "In Bruges", "Filth", "Calibre", "Sightseers", "Sweet Sixteen"), smartOnly = true, films = true),
ChannelPreset(125, "Orbit Junior", listOf("Thomas the Tank Engine & Friends", "Thomas & Friends", "Fireman Sam", "Postman Pat", "Brum", "Rosie and Jim", "Bob the Builder", "Pingu", "Noddy", "Teletubbies", "Tweenies", "Tots TV",
"Pingu in the City", "Peppa Pig", "Bluey", "Bagpuss", "The Clangers", "Camberwick Green", "Trumpton", "Button Moon", "Rainbow", "Balamory", "Fimbles"), smartOnly = true),
ChannelPreset(143, "Orbit Wild", listOf("The Crocodile Hunter", "Crocodile Hunter Diaries", "Deadliest Catch", "River Monsters", "Man vs. Wild", "Running Wild with Bear Grylls", "Survivorman", "Dual Survival", "Naked and Afraid", "Ice Road Truckers",
"Swamp People", "Wild Things with Dominic Monaghan", "Lone Star Law", "Alone", "Ax Men", "Monster Fish", "Dirty Jobs", "Shark Week", "Whale Wars", "Dangerous Encounters with Brady Barr"), smartOnly = true))
/** A fallback for a channel with no old loop: its first episodes, in turn. Used only outside its plan. */
internal fun loopFromPool(pool: List<PoolSeries>, programming: ChannelProgramming): SampleChannel? {
val turns = (0 until (pool.maxOfOrNull { it.episodes.size } ?: 0)).asSequence().flatMap { round -> pool.asSequence().mapNotNull { show -> show.episodes.getOrNull(round)?.let { show to it } } }
val media = turns.take(15).map { (show, episode) -> ScheduledMedia(scheduledItem(show.title, episode), episode.sourceId, episode.durationMs) }.toList()
val media = turns.take(15).map { (show, episode) ->
val item = if (show.isFilm) SampleItem(show.title, "Movie", episode.durationMs / 60_000, "", episode.id, episode.durationMs) else scheduledItem(show.title, episode)
ScheduledMedia(item, episode.sourceId, episode.durationMs)
}.toList()
return if (media.size < 2) null else SampleChannel(media, programming.name, programming.number)
}
@@ -59,7 +59,8 @@ internal val SmartChannels = listOf(
"Hostile Planet", "Africa", "Wild China", "South Pacific", "Great Barrier Reef", "The Hunt", "The Life of Mammals", "The Life of Birds", "Nature's Great Events", "Green Planet", "Prehistoric Planet"),
seriesCount = 20, finishTogether = true, exactTitles = true),
ChannelProgramming(152, "Paradox", ChannelPresets.first { it.number == 152 }.searches)) +
ChannelPresets.filter { it.smartOnly }.map { ChannelProgramming(it.number, it.name, it.searches, seriesCount = 60, finishTogether = true, exactTitles = true,
ChannelPresets.filter { it.smartOnly }.map { ChannelProgramming(it.number, it.name, it.searches, seriesCount = 60, finishTogether = !it.films, exactTitles = true,
filmRestMs = if (it.films) 7 * 24 * 60 * 60_000L else null,
suggestionRules = SmartChannelRules[it.number].orEmpty(), dayParts = SmartChannelParts[it.number].orEmpty()) }
/** Dark Files, from the programming bible: crime by day, mysteries early evening, the paranormal late. */
@@ -46,7 +46,7 @@ internal fun ClassicProgrammeStrip(item: SampleItem, playing: Boolean, modifier:
Legend("↶", "TV guide")
if (scheduled != null) {
Legend("◄", "Last channel")
Legend("►", "Subtitles")
Legend("►", "Subtitles and audio")
Legend("Hold OK", "Number")
}
}
@@ -66,7 +66,7 @@ internal class HttpsEmbyTransport(internal val deviceId: String = UUID.randomUUI
connection.connectTimeout = 10_000
connection.readTimeout = request.readTimeoutMs ?: if (request.path == "/Sessions/Logout") 5_000 else 15_000
connection.setRequestProperty("Accept", "application/json")
connection.setRequestProperty("X-Emby-Authorization", "Emby Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.62.0\"")
connection.setRequestProperty("X-Emby-Authorization", "Emby Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.63.0\"")
request.token?.let { connection.setRequestProperty("X-Emby-Token", it) }
if (request.method == "POST") {
val bytes = request.body.orEmpty().toByteArray(Charsets.UTF_8)
@@ -41,7 +41,7 @@ private const val MAX_PLAYER_RETRIES = 1
@androidx.annotation.OptIn(androidx.media3.common.util.UnstableApi::class)
@Composable
internal fun EmbyPlaybackDialog(session: EmbySampleSession, plan: EmbyPlaybackPlan, onClose: () -> Unit, scheduled: ScheduledPlayback? = null,
onStep: (Int) -> Unit = {}, onLast: () -> Unit = {}, onNumber: (Int) -> Boolean = { false }, subtitlePreference: MutableState<String?>? = null, runningPlayer: ExoPlayer? = null, announce: Boolean = true, onHandBack: ((ExoPlayer) -> Boolean)? = null, onUnplayable: ((String) -> Unit)? = null) {
onStep: (Int) -> Unit = {}, onLast: () -> Unit = {}, onNumber: (Int) -> Boolean = { false }, subtitlePreference: MutableState<String?>? = null, runningPlayer: ExoPlayer? = null, announce: Boolean = true, onHandBack: ((ExoPlayer) -> Boolean)? = null, onUnplayable: ((String) -> Unit)? = null, audioPreference: MutableState<String?>? = null) {
val context = LocalContext.current
var failure by remember { mutableStateOf<String?>(null) }
var tuningNumberVisible by remember { mutableStateOf(announce) }
@@ -57,7 +57,8 @@ internal fun EmbyPlaybackDialog(session: EmbySampleSession, plan: EmbyPlaybackPl
var numberProblem by remember { mutableStateOf<String?>(null) }
var okHeld by remember { mutableStateOf(false) }
var subtitleIndex by remember { mutableStateOf<Int?>(null) }
var subtitleNote by remember { mutableStateOf<String?>(null) }
var trackMenu by remember { mutableStateOf<List<TrackRow>?>(null) }
var trackCursor by remember { mutableIntStateOf(0) }
val player = remember(session, plan) {
if (runningPlayer != null) return@remember runningPlayer
val factory = DataSource.Factory { SecureMediaDataSource(session) }
@@ -65,7 +66,7 @@ internal fun EmbyPlaybackDialog(session: EmbySampleSession, plan: EmbyPlaybackPl
.setSeekBackIncrementMs(10_000).setSeekForwardIncrementMs(10_000).build().apply {
setMediaItem(channelMediaItem(plan))
if (scheduled != null) seekTo(scheduled.programme.offsetAt(scheduled.nowMs()))
trackSelectionParameters = trackSelectionParameters.buildUpon().setPreferredAudioLanguage("en").build()
trackSelectionParameters = trackSelectionParameters.buildUpon().setPreferredAudioLanguage(audioPreference?.value ?: "en").build()
prepare(); playWhenReady = true
}
}
@@ -76,17 +77,25 @@ internal fun EmbyPlaybackDialog(session: EmbySampleSession, plan: EmbyPlaybackPl
if (index != null) builder.addOverride(TrackSelectionOverride(tracks[index].mediaTrackGroup, 0))
player.trackSelectionParameters = builder.build()
}
fun cycleSubtitles() {
val tracks = textTracks()
val choice = nextSubtitle(subtitleIndex, tracks.size)
chooseSubtitle(choice, tracks)
val format = choice?.let { tracks[it].getTrackFormat(0) }
subtitlePreference?.value = format?.let { it.language.orEmpty() }
subtitleNote = when {
tracks.isEmpty() -> "No subtitles on this programme"
format == null -> "Subtitles off"
else -> "Subtitles: ${format.label ?: format.language ?: "Track ${choice + 1}"}"
fun chooseAudio(group: Tracks.Group) {
player.trackSelectionParameters = player.trackSelectionParameters.buildUpon().clearOverridesOfType(C.TRACK_TYPE_AUDIO)
.addOverride(TrackSelectionOverride(group.mediaTrackGroup, 0)).build()
audioPreference?.value = group.getTrackFormat(0).language
}
fun trackRows(): List<TrackRow> {
val subtitles = textTracks()
val audio = player.currentTracks.groups.filter { it.type == C.TRACK_TYPE_AUDIO && it.isSupported }
val subtitleRows = listOf(TrackRow("Subtitles", "Off", subtitles.none { it.isSelected }) { chooseSubtitle(null, subtitles); subtitlePreference?.value = null }) +
// Capped so the panel always fits the screen, even on a file with dozens of subtitles.
subtitles.take(8).mapIndexed { index, group ->
val format = group.getTrackFormat(0)
TrackRow("Subtitles", trackLabel(format.label, format.language, index), group.isSelected) { chooseSubtitle(index, subtitles); subtitlePreference?.value = format.language.orEmpty() }
}
val audioRows = audio.take(5).mapIndexed { index, group ->
val format = group.getTrackFormat(0)
TrackRow("Audio", trackLabel(format.label, format.language, index), group.isSelected) { chooseAudio(group) }
}
return subtitleRows + audioRows
}
fun submitNumber(entry: ChannelEntry) {
if (onNumber(entry.number)) { numberEntry = null; numberProblem = null }
@@ -100,7 +109,8 @@ internal fun EmbyPlaybackDialog(session: EmbySampleSession, plan: EmbyPlaybackPl
}
}
LaunchedEffect(numberEntry) { if (numberEntry != null) { delay(10_000); numberEntry = null; numberProblem = null } }
LaunchedEffect(subtitleNote) { if (subtitleNote != null) { delay(3_000); subtitleNote = null } }
// Closes by itself, so a stray press doesn't leave it over the programme.
LaunchedEffect(trackMenu, trackCursor) { if (trackMenu != null) { delay(10_000); trackMenu = null } }
val lifecycle = LocalLifecycleOwner.current.lifecycle
var foreground by remember { mutableStateOf(lifecycle.currentState.isAtLeast(Lifecycle.State.STARTED)) }
DisposableEffect(player, lifecycle) {
@@ -195,7 +205,7 @@ internal fun EmbyPlaybackDialog(session: EmbySampleSession, plan: EmbyPlaybackPl
LaunchedEffect(infoVisible, lastInteraction, playing, ready) {
if (infoVisible && playing && ready) { delay(5_000); infoVisible = false }
}
Dialog(onDismissRequest = { if (numberEntry != null) { numberEntry = null; numberProblem = null } else {
Dialog(onDismissRequest = { if (trackMenu != null) trackMenu = null else if (numberEntry != null) { numberEntry = null; numberProblem = null } else {
// Backing out keeps the stream running in the picture, without subtitles at that size.
if (ready && failure == null && foreground && onHandBack?.invoke(player) == true) {
handedBack = true
@@ -223,6 +233,17 @@ internal fun EmbyPlaybackDialog(session: EmbySampleSession, plan: EmbyPlaybackPl
if (event.action == KeyEvent.ACTION_UP) okHeld = false
return@setOnKeyListener true
}
trackMenu?.let { rows ->
if (event.action == KeyEvent.ACTION_DOWN) when (code) {
KeyEvent.KEYCODE_DPAD_UP -> trackCursor = (trackCursor - 1).coerceAtLeast(0)
KeyEvent.KEYCODE_DPAD_DOWN -> trackCursor = (trackCursor + 1).coerceAtMost(rows.lastIndex)
}
if (event.action == KeyEvent.ACTION_UP) {
if (isOk) { rows[trackCursor].choose(); trackMenu = null }
else if (code == KeyEvent.KEYCODE_DPAD_LEFT || code == KeyEvent.KEYCODE_DPAD_RIGHT) trackMenu = null
}
return@setOnKeyListener isOk || code in listOf(KeyEvent.KEYCODE_DPAD_UP, KeyEvent.KEYCODE_DPAD_DOWN, KeyEvent.KEYCODE_DPAD_LEFT, KeyEvent.KEYCODE_DPAD_RIGHT)
}
numberEntry?.let { entry ->
// On release, so the key that closes the box can't also act on the channel behind it.
val advance = (isOk || code == KeyEvent.KEYCODE_DPAD_RIGHT) && event.action == KeyEvent.ACTION_UP
@@ -254,7 +275,11 @@ internal fun EmbyPlaybackDialog(session: EmbySampleSession, plan: EmbyPlaybackPl
KeyEvent.KEYCODE_DPAD_DOWN, KeyEvent.KEYCODE_CHANNEL_DOWN -> if (scheduled != null) onStep(-1)
KeyEvent.KEYCODE_DPAD_LEFT -> if (scheduled != null) onLast() else player.seekBack()
KeyEvent.KEYCODE_MEDIA_REWIND -> if (scheduled == null) player.seekBack()
KeyEvent.KEYCODE_DPAD_RIGHT -> if (scheduled != null) cycleSubtitles() else player.seekForward()
KeyEvent.KEYCODE_DPAD_RIGHT -> if (scheduled != null) {
val rows = trackRows()
trackCursor = rows.indexOfFirst { it.selected }.coerceAtLeast(0)
trackMenu = rows
} else player.seekForward()
KeyEvent.KEYCODE_MEDIA_FAST_FORWARD -> if (scheduled == null) player.seekForward()
KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE -> if (scheduled == null) { if (player.isPlaying) player.pause() else player.play() }
KeyEvent.KEYCODE_MEDIA_PLAY -> player.play()
@@ -282,7 +307,7 @@ internal fun EmbyPlaybackDialog(session: EmbySampleSession, plan: EmbyPlaybackPl
Image(painterResource(bug), null, Modifier.align(Alignment.BottomStart).padding(start = 40.dp, bottom = 28.dp).width(108.dp).height(36.dp), alpha = .8f)
if (infoVisible && failure == null && ready) ClassicProgrammeStrip(plan.item, playing,
Modifier.align(Alignment.BottomCenter).fillMaxWidth(.86f).padding(bottom = 26.dp), scheduled = scheduled)
subtitleNote?.let { Text(it, Modifier.align(Alignment.TopCenter).padding(top = 28.dp).background(Navy).padding(horizontal = 14.dp, vertical = 6.dp), color = Color.White, fontSize = 15.sp) }
trackMenu?.let { TrackPanel(it, trackCursor, Modifier.align(Alignment.CenterEnd).padding(end = 28.dp)) }
numberEntry?.let { ChannelNumberBox(it, numberProblem, Modifier.align(Alignment.TopCenter).padding(top = 44.dp)) }
if (failure != null) Column(Modifier.align(Alignment.Center).widthIn(max = 620.dp).background(Navy).padding(24.dp)) {
Text(failure.orEmpty(), color = Color.White, fontSize = 20.sp)
@@ -93,6 +93,7 @@ internal fun ScheduledChannelPlayer(session: EmbySampleSession, channel: SampleC
onClose: () -> Unit, onStep: (Int) -> Unit = {}, onLast: () -> Unit = {}, onNumber: (Int) -> Boolean = { false }, handoff: LiveHandoff? = null, onUnplayable: ((String) -> Unit)? = null) {
// Outlives each programme and channel, and ends when the viewer leaves full screen.
val subtitlePreference = remember { mutableStateOf<String?>(null) }
val audioPreference = remember { mutableStateOf<String?>(null) }
var now by remember { mutableLongStateOf(System.currentTimeMillis() + clockOffsetMs) }
LaunchedEffect(channel, clockOffsetMs) { while (true) { now = System.currentTimeMillis() + clockOffsetMs; delay(250) } }
val shows = channel.guide(now, 2)
@@ -136,7 +137,7 @@ internal fun ScheduledChannelPlayer(session: EmbySampleSession, channel: SampleC
val announce = remember { announcedChannel[0] != channel.number }
SideEffect { announcedChannel[0] = channel.number }
EmbyPlaybackDialog(session, plan, onClose,
scheduled = ScheduledPlayback(channel, current, shows[1], clockOffsetMs), onStep = onStep, onLast = onLast, onNumber = onNumber, subtitlePreference = subtitlePreference, runningPlayer = handed?.takeIf { it.plan === plan }?.claim(), announce = announce, onUnplayable = onUnplayable,
scheduled = ScheduledPlayback(channel, current, shows[1], clockOffsetMs), onStep = onStep, onLast = onLast, onNumber = onNumber, subtitlePreference = subtitlePreference, runningPlayer = handed?.takeIf { it.plan === plan }?.claim(), announce = announce, onUnplayable = onUnplayable, audioPreference = audioPreference,
onHandBack = { running ->
if (handoff != null && clockOffsetMs == 0L) { handoff.returned = LiveStream(channel.number, current.startMs, plan, running); true } else false
})
@@ -33,7 +33,7 @@ internal class SecureMediaDataSource(private val session: EmbySampleSession) : B
next.instanceFollowRedirects = false
next.connectTimeout = 10_000
next.readTimeout = 20_000
next.setRequestProperty("User-Agent", "OrbitTV/0.62.0")
next.setRequestProperty("User-Agent", "OrbitTV/0.63.0")
next.setRequestProperty("Accept-Encoding", "identity")
session.mediaHeaders(address).forEach { (key, value) -> next.setRequestProperty(key, value) }
if (dataSpec.position != 0L || dataSpec.length != C.LENGTH_UNSET.toLong()) {
@@ -27,14 +27,6 @@ internal data class ChannelEntry(val digits: List<Int>, val slot: Int = 0) {
}
}
/** Right steps through the tracks and then off. */
internal fun nextSubtitle(current: Int?, count: Int): Int? = when {
count == 0 -> null
current == null -> 0
current + 1 < count -> current + 1
else -> null
}
/** Subtitles stay on across programmes: the same language if it's there, otherwise the first track. */
internal fun subtitleFor(wanted: String?, languages: List<String>): Int? {
if (wanted == null || languages.isEmpty()) return null
@@ -57,3 +49,32 @@ internal fun ChannelNumberBox(entry: ChannelEntry, problem: String?, modifier: M
Text(problem ?: "▲▼ Change OK Next Back Cancel", color = if (problem != null) Yellow else Muted, fontSize = 11.sp)
}
}
/** One choice in the subtitles and audio panel. */
internal class TrackRow(val section: String, val label: String, val selected: Boolean, val choose: () -> Unit)
/** A plain name for a track: its own label, else its language, else its position. */
internal fun trackLabel(label: String?, language: String?, position: Int): String {
label?.trim()?.takeIf { it.isNotEmpty() }?.let { return it }
val code = language?.trim().orEmpty()
if (code.isNotEmpty() && code != "und") {
val name = java.util.Locale(code).getDisplayLanguage(java.util.Locale.UK)
return if (name.isNullOrBlank() || name == code) code else name
}
return "Track ${position + 1}"
}
/** Sits to one side, so the programme keeps playing while you choose. */
@Composable
internal fun TrackPanel(rows: List<TrackRow>, cursor: Int, modifier: Modifier = Modifier) {
val corner = RoundedCornerShape(6.dp)
Column(modifier.width(280.dp).background(Navy.copy(alpha = .94f), corner).border(1.dp, Panel, corner).padding(12.dp), verticalArrangement = Arrangement.spacedBy(4.dp)) {
rows.forEachIndexed { index, row ->
if (index == 0 || rows[index - 1].section != row.section) Text(row.section, color = Muted, fontSize = 13.sp, fontWeight = FontWeight.SemiBold, modifier = Modifier.padding(top = if (index == 0) 0.dp else 6.dp))
val on = index == cursor
Text((if (row.selected) "✓ " else " ") + row.label, Modifier.fillMaxWidth().background(if (on) Yellow else Color.Transparent, RoundedCornerShape(4.dp)).padding(horizontal = 8.dp, vertical = 4.dp),
color = if (on) Navy else Color.White, fontSize = 15.sp, fontWeight = if (on || row.selected) FontWeight.SemiBold else FontWeight.Normal, maxLines = 1)
}
Text("▲▼ Move OK Choose Back Close", color = Muted, fontSize = 11.sp, modifier = Modifier.padding(top = 4.dp))
}
}