Bring back the four features on top of fixes B and C (0.110.1)

Paul, 8 November 2026: continue with the approved features. Coming up next, phone reminders, Continue watching on
Home and Orbit TV Times, as built earlier (backlog/features-0.110), now over profiling fixes B and C.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-08 13:16:22 +00:00
co-authored by Claude Opus 5.5
parent 4300800cf6
commit fe7cc6c5b4
18 changed files with 323 additions and 19 deletions
+2 -2
View File
@@ -9,8 +9,8 @@ android {
applicationId = "tv.orbit.classic"
minSdk = 26
targetSdk = 36
versionCode = 275
versionName = "0.108.114-pick-card"
versionCode = 276
versionName = "0.110.1-features"
}
buildFeatures { compose = true }
// The finished build for the TVs (Paul, 6 November 2026: the test build stuttered on the box). Not debuggable, so
@@ -186,7 +186,8 @@ function guide() {
const f = cats.includes(state.filter) ? state.filter : 'all', list = g.channels.filter(c => f === 'all' || c.category === f);
const chips = `<div class="chips">${cats.map(k => `<button class="${k === f ? 'on' : ''}" data-filter="${esc(k)}">${k === 'all' ? 'All' : esc(k)}</button>`).join('')}</div>`;
if (f === 'Drive-In') return head('Guide') + chips + driveIn();
return head('Guide') + chips +
const times = `<a href="/times" class="card small" style="display:block;margin-bottom:10px;text-decoration:none;border:2px solid var(--accent)"><b style="color:var(--ink)">Orbit TV Times</b> · the week's listings, picks and films ›</a>`;
return head('Guide') + times + chips +
(list.map(c => `<button class="ch ${c.number === g.selected ? 'on' : ''}" data-pick="${c.number}"><div class="num"><b>${c.number}</b><small>${esc(c.name)}</small></div>
<div class="grow"><div class="what">${esc(c.now.title)}</div><div class="then">${hm(c.now.startMs)}–${hm(c.now.endMs)} · then ${esc(c.next.title)}</div></div>
${c.number === g.selected && state.now?.watching ? '<span class="pill mint">ON TV</span>' : '<span class="pill">LIVE</span>'}</button>`).join('') || '<div class="empty">No channels here.</div>');
@@ -196,7 +197,8 @@ function pickSheet(n) {
return `<div class="title">${esc(c.now.title)}</div><div class="small">${c.number} ${esc(c.name)} · Live now · ends ${hm(c.now.endMs)}${c.now.sub ? ' · ' + esc(c.now.sub) : ''}</div>
<div class="room" style="margin-top:12px"><span class="dot"></span>Watching on: <b>${esc(state.now?.room || 'this TV')}</b></div>
<div class="row" style="gap:8px"><button class="btn gold" data-tune="${c.number}">Watch on this TV</button><button class="btn" data-queue="${c.number}">Queue next</button></div>
<div class="small" style="margin-top:10px">Queue next switches to ${c.number} ${esc(c.name)} when the programme on the TV ends. Next on it at ${hm(c.next.startMs)}: ${esc(c.next.title)}</div>`;
<div class="small" style="margin-top:10px">Queue next switches to ${c.number} ${esc(c.name)} when the programme on the TV ends. Next on it at ${hm(c.next.startMs)}: ${esc(c.next.title)}</div>
<button class="btn${c.next.reminded ? '' : ' gold'}" style="margin-top:10px" data-remind="${c.number}:${c.next.startMs}:${c.next.reminded ? 0 : 1}">${c.next.reminded ? 'Reminder set · take it off' : 'Remind me about ' + esc(c.next.title)}</button>`;
}
// The Drive-In (phase 2): the coming bills, tickets, and out to the lot while one is showing.
function driveIn() {
@@ -852,6 +854,7 @@ document.addEventListener('click', e => {
if (d.filter) { state.filter = d.filter; render(); }
if (d.pick) openSheet(pickSheet(+d.pick));
if (d.tune) send('/api/tune', {number: +d.tune}, () => { closeSheet(); toast('Watching on the TV'); setTimeout(() => load('guide'), 700); });
if (d.remind) { const [number, startMs, on] = d.remind.split(':').map(Number); send('/api/remind', {number, startMs, on: !!on}, () => { closeSheet(); setTimeout(() => load('guide'), 400); toast(on ? 'The TV will remind you before it starts' : 'Reminder taken off'); }); return; }
if (d.queue) send('/api/queue', {number: +d.queue}, j => { state.now = {...state.now, queue: j.queue}; closeSheet(); toast('Queued: switches when this one ends'); });
if (d.cupick) { const [n, st] = d.cupick.split(':').map(Number); openSheet(cuSheet(n, st)); return; }
if (d.cuq) { const [number, startMs] = d.cuq.split(':').map(Number); send('/api/queue', {number, startMs}, j => { state.now = {...state.now, queue: j.queue}; closeSheet(); render(); toast('Queued for when this one ends'); }); return; }
@@ -0,0 +1,82 @@
<!doctype html>
<html lang="en-GB"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">
<title>Orbit TV Times</title>
<style>
:root{--red:#c8102e;--navy:#0b1630;--gold:#ffc72c;--paper:#f7f1e3;--ink:#1b1b1b;--muted:#5d564a;--rule:#cdbf9f}
*{box-sizing:border-box}
body{margin:0;background:var(--paper);color:var(--ink);font-family:Georgia,'Times New Roman',serif;line-height:1.35}
.mast svg{display:block;width:100%;height:auto}
.bar{display:flex;gap:8px;align-items:center;justify-content:space-between;padding:8px 14px;background:var(--navy);color:#fff;font:600 13px/1.2 system-ui,sans-serif}
.bar a{color:var(--gold);text-decoration:none}
.bar button{background:var(--gold);color:var(--navy);border:0;border-radius:6px;padding:7px 12px;font:700 13px system-ui,sans-serif}
.days{display:flex;gap:6px;overflow-x:auto;padding:10px 14px;border-bottom:3px double var(--rule)}
.days button{flex:none;border:2px solid var(--navy);background:#fff;border-radius:999px;padding:6px 12px;font:700 13px system-ui,sans-serif;color:var(--navy)}
.days button.on{background:var(--navy);color:var(--gold)}
main{max-width:980px;margin:0 auto;padding:12px 14px 40px}
.day h2{font-size:30px;margin:14px 0 4px;border-bottom:3px solid var(--red);padding-bottom:4px}
.day h2 small{font:600 14px system-ui,sans-serif;color:var(--muted);margin-left:8px}
.pick{display:grid;grid-template-columns:auto 1fr;gap:12px;background:var(--navy);color:#fff;border-radius:6px;padding:14px;margin:12px 0}
.pick .badge{background:var(--gold);color:var(--navy);font:900 13px/1 system-ui,sans-serif;padding:8px 10px;border-radius:4px;align-self:start;letter-spacing:1px}
.pick h3{margin:0;font-size:24px;color:var(--gold)}
.pick p{margin:4px 0 0}
.sec{font:900 14px system-ui,sans-serif;letter-spacing:2px;color:var(--red);margin:18px 0 6px;text-transform:uppercase}
.cols{columns:2 300px;column-gap:24px;column-rule:1px solid var(--rule)}
.row{break-inside:avoid;padding:6px 0;border-bottom:1px dotted var(--rule)}
.t{font:700 15px system-ui,sans-serif;color:var(--red);margin-right:6px}
.title{font-weight:700;font-size:17px}
.sub{font-style:italic;color:var(--muted)}
.meta{font:600 12px system-ui,sans-serif;color:var(--muted)}
.tag{display:inline-block;font:800 10px system-ui,sans-serif;letter-spacing:1px;background:var(--gold);color:var(--navy);padding:2px 5px;border-radius:3px;margin-left:4px;vertical-align:2px}
.drive{border:2px dashed var(--navy);border-radius:6px;padding:10px 12px;margin:8px 0;background:#fff}
.empty{padding:40px 0;text-align:center;color:var(--muted)}
footer{font:12px system-ui,sans-serif;color:var(--muted);text-align:center;margin-top:30px}
@media print{
@page{size:A4;margin:12mm}
body{background:#fff}
.bar,.days{display:none}
.day{display:block!important;break-before:page}
.day:first-of-type{break-before:auto}
.pick{-webkit-print-color-adjust:exact;print-color-adjust:exact}
.mast{-webkit-print-color-adjust:exact;print-color-adjust:exact}
}
</style></head>
<body>
<div class="mast"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 260" width="1200" height="260"> <rect width="1200" height="260" fill="#c8102e"/> <rect x="0" y="214" width="1200" height="46" fill="#0b1630"/> <g transform="translate(70 40)"> <circle cx="70" cy="70" r="66" fill="none" stroke="#ffc72c" stroke-width="10"/> <ellipse cx="70" cy="70" rx="104" ry="30" fill="none" stroke="#ffc72c" stroke-width="8" transform="rotate(-18 70 70)"/> <circle cx="70" cy="70" r="34" fill="#ffc72c"/> </g> <text x="250" y="150" font-family="Georgia, 'Times New Roman', serif" font-weight="700" font-size="136" fill="#ffffff" letter-spacing="2">ORBIT</text> <text x="742" y="150" font-family="Georgia, 'Times New Roman', serif" font-style="italic" font-weight="700" font-size="104" fill="#ffc72c">TV Times</text> <text x="252" y="196" font-family="Arial, Helvetica, sans-serif" font-weight="700" font-size="28" fill="#ffffff" letter-spacing="6">THE WEEK'S PROGRAMMES · EVERY CHANNEL</text> <text x="70" y="246" font-family="Arial, Helvetica, sans-serif" font-weight="700" font-size="24" fill="#ffc72c" letter-spacing="4">FREE WITH YOUR ORBIT</text> <text x="1130" y="246" text-anchor="end" font-family="Arial, Helvetica, sans-serif" font-weight="700" font-size="24" fill="#ffffff" letter-spacing="4">PICKS · FILMS · DRIVE-IN</text> </svg> </div>
<div class="bar"><a href="/">‹ Back to Orbit</a><span id="issue"></span><button id="print">Print or save PDF</button></div>
<div class="days" id="days"></div>
<main id="main"><div class="empty">Loading this week's listings…</div></main>
<script>
const $ = s => document.querySelector(s);
const esc = s => String(s ?? '').replace(/[&<>"']/g, c => ({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'}[c]));
const hm = ms => new Date(ms).toLocaleTimeString('en-GB', {hour: '2-digit', minute: '2-digit'});
const dayName = iso => new Date(iso + 'T12:00:00').toLocaleDateString('en-GB', {weekday: 'long', day: 'numeric', month: 'long'});
let data = null, shown = 0;
function row(i) {
return '<div class="row"><span class="t">' + hm(i.startMs) + '</span><span class="title">' + esc(i.title) + '</span>' + (i.tag ? '<span class="tag">' + esc(i.tag).toUpperCase() + '</span>' : '') +
(i.sub ? '<div class="sub">' + esc(i.sub) + '</div>' : '') + '<div class="meta">' + i.channel + ' ' + esc(i.name) + ' · until ' + hm(i.endMs) + (i.reason ? ' · ' + esc(i.reason) : '') + '</div></div>';
}
function day(d) {
let h = '<section class="day" data-day="' + esc(d.date) + '"><h2>' + esc(dayName(d.date)) + '</h2>';
if (d.pick) h += '<div class="pick"><div class="badge">PICK OF<br>THE DAY</div><div><h3>' + esc(d.pick.title) + '</h3><p>' + (d.pick.sub ? '<i>' + esc(d.pick.sub) + '</i><br>' : '') +
hm(d.pick.startMs) + ' on ' + d.pick.channel + ' ' + esc(d.pick.name) + (d.pick.reason ? ' · ' + esc(d.pick.reason) : '') + '</p></div></div>';
if (d.highlights.length) h += '<div class="sec">Tonight\'s highlights</div><div class="cols">' + d.highlights.map(row).join('') + '</div>';
if (d.films.length) h += '<div class="sec">Films this evening</div><div class="cols">' + d.films.map(row).join('') + '</div>';
if (d.drivein.length) h += '<div class="sec">At the Drive-In</div>' + d.drivein.map(b => '<div class="drive"><b>' + esc(b.event || b.kind) + '</b> · ' + hm(b.startMs) + '–' + hm(b.endMs) +
'<div>' + b.films.map(esc).join(' · ') + '</div></div>').join('');
return h + '</section>';
}
function render() {
if (!data.days.length) { $('#main').innerHTML = '<div class="empty">Nothing planned yet. Try again once Orbit has planned the week.</div>'; return; }
$('#days').innerHTML = data.days.map((d, i) => '<button class="' + (i === shown ? 'on' : '') + '" data-i="' + i + '">' + esc(new Date(d.date + 'T12:00:00').toLocaleDateString('en-GB', {weekday: 'short', day: 'numeric'})) + '</button>').join('');
$('#main').innerHTML = data.days.map(day).join('') + '<footer>Orbit TV Times · made from ' + esc(data.room || 'your Orbit') + '\'s schedules at ' + hm(data.generatedMs) + '. Programmes can change.</footer>';
document.querySelectorAll('.day').forEach((s, i) => s.style.display = i === shown ? '' : 'none');
}
$('#days').addEventListener('click', e => { const b = e.target.closest('button'); if (!b) return; shown = +b.dataset.i; render(); window.scrollTo(0, 0); });
$('#print').addEventListener('click', () => window.print());
fetch('/api/times', {credentials: 'same-origin'}).then(r => { if (!r.ok) throw new Error(r.status); return r.json(); }).then(j => {
data = j; const a = j.days[0], b = j.days[j.days.length - 1];
if (a) $('#issue').textContent = new Date(a.date + 'T12:00:00').toLocaleDateString('en-GB', {day: 'numeric', month: 'short'}) + ' – ' + new Date(b.date + 'T12:00:00').toLocaleDateString('en-GB', {day: 'numeric', month: 'short'});
render();
}).catch(() => { $('#main').innerHTML = '<div class="empty">Orbit isn\'t answering. Open Orbit on the TV and try again.</div>'; });
</script>
</body></html>
@@ -62,9 +62,9 @@ internal class HttpsEmbyTransport(internal val deviceId: String = UUID.randomUUI
}
/** The sign-in headers for this kind of server. */
internal fun authHeaders(token: String?): Map<String, String> = when (kind) {
ServerKind.Emby -> mapOf("X-Emby-Authorization" to "Emby Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.108.114\"") +
ServerKind.Emby -> mapOf("X-Emby-Authorization" to "Emby Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.110.1\"") +
(token?.let { mapOf("X-Emby-Token" to it) } ?: emptyMap())
ServerKind.Jellyfin -> mapOf("Authorization" to "MediaBrowser Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.108.114\"" +
ServerKind.Jellyfin -> mapOf("Authorization" to "MediaBrowser Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.110.1\"" +
(token?.let { ", Token=\"$it\"" } ?: ""))
}
/** One picture from the provider, or nothing. Same fixed origin and no redirects, and failures are never shown or logged. */
@@ -703,6 +703,12 @@ internal fun EmbyConnectionScreen(modifier: Modifier = Modifier, visible: Boolea
if (offset == 0L) liveHandoff.handOver(number)
channelClockOffset = offset; watchingChannel = true
}
/** Carries on a Continue watching programme from where it was left, from Catch Up or Home, while it's still in Catch Up. */
fun resumeContinue(c: ContinueEntry) {
if (c.entry.show.startMs < System.currentTimeMillis() - CATCH_UP_MS || lockedOut(c.entry.channel.number) || profileHides(c.entry.channel.number)) return
tune(c.entry.channel.number, c.entry.show.startMs + c.positionMs - System.currentTimeMillis())
Taste.record(TasteKind.Chose, c.entry.show.media.item.id, (c.entry.channel as? ScheduledChannel)?.seriesIdAt(c.entry.show.startMs), c.entry.show.media.item.title, c.entry.channel.number, "continue")
}
// Orbit Companion: the channels this TV shows right now, and tuning as the guide does. Set here, before any screen
// returns early, so the phone works from every section (the Drive-In and the Arcade go to the guide to tune).
val shownChannels by rememberUpdatedState(availableChannels.filter { !lockedOut(it.number) && !profileHides(it.number) })
@@ -716,6 +722,11 @@ internal fun EmbyConnectionScreen(modifier: Modifier = Modifier, visible: Boolea
val companionBills by rememberUpdatedState(driveInPlan.takeIf { Profiles.current?.let { it.kind != ProfileKind.Kids || it.driveIn } ?: true }
?.let { plan -> driveInLineup(driveInBills(plan), System.currentTimeMillis()).filter { !lockedOut(it) } }.orEmpty())
val companionDriveIn by rememberUpdatedState(mainDriveIn)
val companionReminders by rememberUpdatedState(reminders)
val companionRemind by rememberUpdatedState { number: Int, startMs: Long, title: String, on: Boolean ->
val kept = liveReminders(reminders, System.currentTimeMillis()).filterNot { it.channel == number && it.startMs == startMs }
saveReminders(if (on) kept + ProgrammeReminder(number, startMs, title) else kept)
}
val companionScreen = remember {
CompanionScreen(channels = { shownChannels }, selected = { selectedNumber }, watching = { watchingChannel }, offset = { channelClockOffset },
tune = { n, offset -> companionTune(n, offset) }, driveIn = { companionBills }, tickets = { companionTickets.keys },
@@ -736,7 +747,8 @@ internal fun EmbyConnectionScreen(modifier: Modifier = Modifier, visible: Boolea
decision == "approved" -> "${idea.theme} approved for ${idea.evening}. It books once the Drive-In plans that evening, after its films are checked again."
decision == "deferred" -> "${idea.theme} deferred: it can come back in four weeks."
else -> "${idea.theme} dismissed: it won't be proposed again unless its films change." }
})
},
reminders = { companionReminders }, remind = { number, startMs, title, on -> companionRemind(number, startMs, title, on) })
}
DisposableEffect(Unit) {
PhoneLink.screen = companionScreen
@@ -796,12 +808,10 @@ internal fun EmbyConnectionScreen(modifier: Modifier = Modifier, visible: Boolea
}
val picture = @Composable { GuidePicture(liveSession, liveChannel, live = !watchingChannel, handoff = liveHandoff, onUnplayable = ::rememberUnplayable) }
when {
mainHome -> HomeScreen(availableChannels, modifier, onCategory = { guideCategory = it; onGuide() })
mainHome -> HomeScreen(availableChannels, modifier, onCategory = { guideCategory = it; onGuide() },
carryOn = continueEntries(availableChannels.filter { !lockedOut(it.number) && !profileHides(it.number) }, ContinueWatching.marks, System.currentTimeMillis()), onResume = ::resumeContinue)
mainCatchUp -> CatchUpScreen(availableChannels, liveSession, modifier, onOpen = { catchUpOpen = it },
onResume = { c -> if (c.entry.show.startMs >= System.currentTimeMillis() - CATCH_UP_MS) {
tune(c.entry.channel.number, c.entry.show.startMs + c.positionMs - System.currentTimeMillis())
Taste.record(TasteKind.Chose, c.entry.show.media.item.id, (c.entry.channel as? ScheduledChannel)?.seriesIdAt(c.entry.show.startMs), c.entry.show.media.item.title, c.entry.channel.number, "continue")
} })
onResume = ::resumeContinue)
mainWhatsOn -> WhatsOnScreen(liveSession, scheduledChannels.filterKeys { !lockedOut(it) && !profileHides(it) }.mapValues { it.value.plan },
driveInPlan.takeIf { Profiles.current?.let { it.kind != ProfileKind.Kids || it.driveIn } ?: true }, modifier, reminders,
onWatch = { tune(it, 0) }, onDriveIn = onDriveIn, onBack = onHome,
@@ -32,6 +32,9 @@ internal enum class ChannelCategory(val label: String, val icon: Int) {
}
/** All Channels, then only the categories that have a channel in them. */
/** Continue watching rows on Home; the rest are in Catch Up. */
internal const val HOME_CONTINUE_MAX = 3
internal fun homeCategories(numbers: List<Int>): List<ChannelCategory> {
val used = numbers.mapNotNull { ChannelBrands.forNumber(it)?.category }.toSet()
return ChannelCategory.entries.filter { it == ChannelCategory.All || it in used }
@@ -68,7 +71,9 @@ internal fun HomeCard(modifier: Modifier = Modifier, focusRequester: FocusReques
* Guide on that category. What's On holds the evening's highlights.
*/
@Composable
internal fun HomeScreen(channels: List<SampleChannel>, modifier: Modifier = Modifier, onCategory: (ChannelCategory) -> Unit) {
internal fun HomeScreen(channels: List<SampleChannel>, modifier: Modifier = Modifier, onCategory: (ChannelCategory) -> Unit,
/** Continue watching, newest first (Paul, 8 November 2026): one press back into a half-watched programme. */
carryOn: List<ContinueEntry> = emptyList(), onResume: (ContinueEntry) -> Unit = {}) {
val firstFocus = remember { FocusRequester() }
val nav = LocalNavFocus.current
LaunchedEffect(Unit) { runCatching { firstFocus.requestFocus() } }
@@ -87,6 +92,23 @@ internal fun HomeScreen(channels: List<SampleChannel>, modifier: Modifier = Modi
}
}
} }
// Words only, no pictures, so Home stays as quick as it is.
if (carryOn.isNotEmpty()) {
Spacer(Modifier.height(14.dp))
Text("CONTINUE WATCHING", Modifier.width(400.dp), color = Yellow, fontFamily = Anton, fontSize = 13.sp)
Spacer(Modifier.height(4.dp))
CompositionLocalProvider(LocalGlide provides glide) { Column(Modifier.width(400.dp).glideArea(glide, Yellow, 6.dp), verticalArrangement = Arrangement.spacedBy(4.dp)) {
carryOn.take(HOME_CONTINUE_MAX).forEach { c ->
HomeCard(Modifier.fillMaxWidth().height(31.dp), onClick = { onResume(c) }) { focused ->
Row(Modifier.fillMaxSize().padding(horizontal = 16.dp), verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(10.dp)) {
Text(guideTitle(c.entry.channel.number, c.entry.show).first, Modifier.weight(1f), color = if (focused) OnAccent else Ink, fontSize = 14.sp,
fontWeight = FontWeight.SemiBold, maxLines = 1, overflow = androidx.compose.ui.text.style.TextOverflow.Ellipsis)
Text(leftLabel(c.leftMs), color = if (focused) OnAccent else Muted, fontSize = 12.sp, maxLines = 1)
}
}
}
} }
}
Spacer(Modifier.height(14.dp))
Text("Tonight's Pick and the evening's highlights are in What's On", color = Muted, fontSize = 11.sp)
Spacer(Modifier.weight(1f))
@@ -45,7 +45,10 @@ internal class CompanionScreen(
val director: () -> DeskReport? = { null },
val place: (ChairChoice, Int) -> Unit = { _, _ -> },
val drop: (ChairChoice) -> Unit = {},
val decideIdea: (DeskEventIdea, String) -> String = { _, _ -> "" })
val decideIdea: (DeskEventIdea, String) -> String = { _, _ -> "" },
/** Programme reminders, the same ones the TV guide and What's On set (8 November 2026). */
val reminders: () -> List<ProgrammeReminder> = { emptyList() },
val remind: (number: Int, startMs: Long, title: String, on: Boolean) -> Unit = { _, _, _, _ -> })
/**
* Phase 2's queue (Paul, 6 November 2026): what plays when the programme on now ends. A channel, live from then ("switch
@@ -138,18 +141,28 @@ internal object OrbitCompanion {
/** Every channel's now and next. */
fun guide(screen: CompanionScreen, nowMs: Long): JSONObject = JSONObject().put("selected", screen.selected()).put("serverMs", nowMs).put("channels",
JSONArray(screen.channels().map { c -> val on = c.at(nowMs)
channelJson(c).put("category", ChannelBrands.forNumber(c.number)?.category?.label ?: JSONObject.NULL).put("now", programme(on)).put("next", programme(c.at(on.endMs))) }))
channelJson(c).put("category", ChannelBrands.forNumber(c.number)?.category?.label ?: JSONObject.NULL).put("now", programme(on)).put("next", programme(c.at(on.endMs)).let { next ->
next.put("reminded", screen.reminders().any { it.channel == c.number && it.startMs == next.getLong("startMs") }) }) }))
fun catchUp(screen: CompanionScreen, nowMs: Long): JSONArray = JSONArray(catchUpShelves(screen.channels(), nowMs).map { shelf ->
JSONObject().put("title", shelf.title).put("entries", JSONArray(shelf.entries.map { e ->
programme(e.show).put("number", e.channel.number).put("channel", e.channel.name).put("continues", e.continues) }))
})
/** A reminder from the phone, for a programme still to come on a channel this TV shows; false when there's no such programme. */
fun remind(screen: CompanionScreen, number: Int, startMs: Long, on: Boolean, nowMs: Long): Boolean {
val c = screen.channels().firstOrNull { it.number == number } ?: return false
val show = runCatching { c.at(startMs) }.getOrNull()?.takeIf { it.startMs == startMs && it.startMs > nowMs } ?: return false
screen.remind(number, startMs, guideTitle(number, show).first, on); return true
}
/** The Catch Up programme the phone chose, only if it's still in Catch Up on a channel this TV shows. */
fun catchUpEntry(screen: CompanionScreen, number: Int, startMs: Long, nowMs: Long): CatchUpEntry? =
catchUpShelves(screen.channels(), nowMs).flatMap { it.entries }.firstOrNull { it.channel.number == number && it.show.startMs == startMs }
const val QUEUE_MAX = 5
const val TIMES_DAYS = 7
const val TIMES_FILMS = 12
/** How long before the programme's end the queue takes over. */
const val QUEUE_LEAD_MS = 2_500L
var queue by mutableStateOf<List<Queued>>(emptyList())
@@ -209,6 +222,42 @@ internal object OrbitCompanion {
})
}
/**
* Orbit TV Times (Paul, 8 November 2026): the week ahead as a listings magazine, from the real schedules. Each day is
* What's On's choice for that evening (its pick and highlights), the evening's films across the channels, and the
* Drive-In's bills, only for the channels this TV shows now (Kids' own, and After Dark only while unlocked).
*/
fun times(screen: CompanionScreen, nowMs: Long, zone: java.time.ZoneId = java.time.ZoneId.systemDefault()): JSONObject {
val channels = screen.channels()
val plans = channels.mapNotNull { c -> (c as? ScheduledChannel)?.let { c.number to it.plan } }.toMap()
val names = channels.associate { it.number to ChannelBrands.displayName(it) }
fun item(channel: Int, e: ScheduleEntry, tag: String?, reason: String?) = guideTitleParts(e.media.item.title).let { (title, sub) ->
JSONObject().put("channel", channel).put("name", names[channel] ?: channel.toString()).put("title", title).put("sub", sub ?: JSONObject.NULL)
.put("startMs", e.startMs).put("endMs", e.endMs).put("type", e.media.item.type)
.put("tag", tag ?: JSONObject.NULL).put("reason", reason ?: JSONObject.NULL)
}
val first = whatsOnEdition(nowMs, zone)
val days = JSONArray()
for (d in 0 until TIMES_DAYS) {
val date = first.plusDays(d.toLong())
val noon = maxOf(nowMs, date.atTime(12, 0).atZone(zone).toInstant().toEpochMilli())
val evening = date.atTime(18, 0).atZone(zone).toInstant().toEpochMilli(); val night = date.plusDays(1).atTime(0, 0).atZone(zone).toInstant().toEpochMilli()
val end = date.plusDays(1).atTime(6, 0).atZone(zone).toInstant().toEpochMilli()
val page = whatsOnPage(plans, null, noon, zone)
val films = plans.flatMap { (n, plan) -> plan.entries.filter { it.media.item.type == "Movie" && it.startMs in evening until night && !kidsAsleep(takeoverOf(n, it, zone)) }.map { n to it } }
.sortedBy { it.second.startMs }.distinctBy { it.second.media.item.id }.take(TIMES_FILMS)
val bills = screen.driveIn().filter { it.startMs in noon until end }
if (page.pick == null && page.tonight.isEmpty() && films.isEmpty() && bills.isEmpty()) continue
days.put(JSONObject().put("date", date.toString()).put("noonMs", noon)
.put("pick", page.pick?.let { item(it.channel, it.entry, it.tag, it.reason) } ?: JSONObject.NULL)
.put("highlights", JSONArray(page.tonight.map { item(it.channel, it.entry, it.tag, it.reason) }))
.put("films", JSONArray(films.map { (n, e) -> item(n, e, null, null) }))
.put("drivein", JSONArray(bills.map { b -> JSONObject().put("kind", b.kind.label).put("event", b.event ?: JSONObject.NULL).put("startMs", b.startMs).put("endMs", b.endMs)
.put("films", JSONArray(b.entries.map { guideTitleParts(it.media.item.title).first })) })))
}
return JSONObject().put("generatedMs", nowMs).put("room", Rooms.name).put("days", days)
}
// --- Phase 3: Director approvals and profiles. ---
private fun choiceJson(c: ChairChoice) = JSONObject().put("id", c.id).put("title", c.title).put("type", c.type).put("year", c.year ?: JSONObject.NULL)
.put("line", c.line).put("ask", c.ask).put("options", JSONArray(c.options.map { JSONObject().put("number", it.number).put("name", it.name).put("reason", it.reason) }))
@@ -241,6 +241,7 @@ internal object PhoneLink {
phone == null -> page(out, PhonePages.join(null))
r.path == "/" -> page(out, PhonePages.companion())
r.path == "/create" -> page(out, PhonePages.app())
r.path == "/times" -> page(out, PhonePages.times())
r.method == "POST" && r.headers["x-orbit"] != "1" -> json(out, 403, JSONObject().put("error", "Refused"))
else -> api(r, out, phone)
}
@@ -479,7 +480,7 @@ internal object PhoneLink {
}
private val companionRoutes = setOf("GET /api/now", "GET /api/guide", "GET /api/catchup", "GET /api/rooms", "GET /api/looks", "POST /api/key", "POST /api/volume",
"POST /api/channel", "POST /api/tune", "POST /api/section", "POST /api/catchup/watch",
"POST /api/channel", "POST /api/tune", "POST /api/remind", "GET /api/times", "POST /api/section", "POST /api/catchup/watch",
"GET /api/queue", "POST /api/queue", "POST /api/queue/remove", "GET /api/drivein", "POST /api/drivein/ticket", "POST /api/drivein/watch",
"GET /api/director", "POST /api/director/place", "POST /api/director/drop", "POST /api/director/idea", "GET /api/profiles", "POST /api/profile",
"POST /api/profile/add", "POST /api/profile/rename", "POST /api/profile/remove")
@@ -516,6 +517,13 @@ internal object PhoneLink {
val number = body().optInt("number").takeIf { n -> s.channels().any { it.number == n } } ?: return json(out, 404, JSONObject().put("error", "That channel isn't on this TV right now."))
onScreen { s.tune(number, 0) }; json(out, 200, JSONObject().put("number", number))
}
"GET /api/times" -> json(out, 200, OrbitCompanion.times(s, now))
"POST /api/remind" -> {
val o = body(); var done = false
onScreen { done = OrbitCompanion.remind(s, o.optInt("number"), o.optLong("startMs"), o.optBoolean("on", true), now) }
if (!done) return json(out, 404, JSONObject().put("error", "That programme isn't coming up on this TV."))
json(out, 200, JSONObject().put("ok", true))
}
"POST /api/section" -> {
val section = OrbitCompanion.sections[body().optString("section")] ?: return json(out, 400, JSONObject().put("error", "Unknown place"))
onScreen { OrbitCompanion.open(section) }; json(out, 200, JSONObject().put("ok", true))
@@ -21,6 +21,7 @@ background:#ffde59;color:#071632;font-size:18px;font-weight:700}.note{color:#ffd
fun app(): String = asset("app.html")
/** The Companion, at /: Remote, Guide, Catch Up, Rooms and More (which leads to Create your own). */
fun companion(): String = asset("companion.html")
fun times(): String = asset("times.html")
/** For "Add to home screen": Orbit's icon and name, opening on the remote. */
val icons = setOf("/icon-180.png", "/icon-192.png", "/icon-512.png")
fun icon(path: String): ByteArray? = runCatching { PhoneLink.context()?.assets?.open("phone" + path)?.use { it.readBytes() } }.getOrNull()
@@ -69,7 +69,7 @@ internal enum class RoomPart(val title: String, val line: String) {
}
/** On screen and Arcade settings that may travel; the sound output and anything about this box stay where they are. */
private val LookKeys = listOf("look", "subtitles_on", "channel_logo", "idents", "ident_sound", "special_idents", "block_ident_sound", "squeeze_back",
private val LookKeys = listOf("look", "subtitles_on", "channel_logo", "idents", "ident_sound", "special_idents", "block_ident_sound", "squeeze_back", "up_next",
"cast_on", "drive_in_intro", "reduce_motion")
private val ArcadeKeys = listOf("snake_best", "block_drop_best", "brick_break_best", "pairs_best", "patience_wins", "orb_man_best", "blast_best", "skydoku_solved", "snake_music")
private val DirectorFiles = listOf("director-decisions-0.json", "director-learning-0.json", "event-ideas-history-0.json")
@@ -71,6 +71,7 @@ internal fun ScheduledChannelPlayer(session: EmbySampleSession, channel: SampleC
val squeezeOn = remember { OrbitSettings(settingsContext).squeezeBack }
val cameosOn = remember { OrbitSettings(settingsContext).let { it.characterCameos && it.castOn } }
val calmMotion = remember { OrbitSettings(settingsContext).reduceMotion }
val upNextOn = remember { OrbitSettings(settingsContext).upNext }
val squeezing = squeezeOn && channel is ScheduledChannel && squeezeBackDue(channel.number, current.startMs, current.endMs, next.startMs, now, if (identsHere) identMs else 0L, clockOffsetMs, squeezeLength(current.media.item.type))
val squeeze by androidx.compose.animation.core.animateFloatAsState(if (squeezing) 1f else 0f,
if (calmMotion) androidx.compose.animation.core.snap() else androidx.compose.animation.core.tween(1_000), label = "squeeze")
@@ -218,6 +219,8 @@ internal fun ScheduledChannelPlayer(session: EmbySampleSession, channel: SampleC
}
}
if (plan != null && squeeze > 0f) SqueezePanel(session, channel, current, next, now, squeeze)
if (plan != null && upNextOn && squeeze == 0f && phase == IdentPhase.None && channel is ScheduledChannel && clockOffsetMs == 0L && next.startMs == current.endMs)
UpNextBanner(channel, current, next, now)
heldIdent?.let { held ->
key(held.startMs) {
val early = endedEarly == held.startMs
@@ -39,7 +39,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.108.114")
next.setRequestProperty("User-Agent", "OrbitTV/0.110.1")
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()) {
@@ -102,6 +102,10 @@ internal class OrbitSettings(context: Context) {
var identSoundNightQuiet: Boolean
get() = saved.getBoolean("ident_sound_night_quiet", true)
set(value) { saved.edit().putBoolean("ident_sound_night_quiet", value).apply() }
/** A small "Coming up next" card near the end of each programme (Paul, 8 November 2026). On by default. */
var upNext: Boolean
get() = saved.getBoolean("up_next", true)
set(value) { saved.edit().putBoolean("up_next", value).apply() }
var driveInIntro: Boolean
get() = saved.getBoolean("drive_in_intro", true)
set(value) { saved.edit().putBoolean("drive_in_intro", value).apply() }
@@ -270,6 +274,7 @@ private fun ViewingDetail(firstSwitch: FocusRequester, modifier: Modifier, top:
var identSound by remember { mutableStateOf(settings.identSound) }
var identSoundQuiet by remember { mutableStateOf(settings.identSoundQuiet) }
var identSoundNightQuiet by remember { mutableStateOf(settings.identSoundNightQuiet) }
var upNext by remember { mutableStateOf(settings.upNext) }
var driveInIntro by remember { mutableStateOf(settings.driveInIntro) }
var reduceMotion by remember { mutableStateOf(settings.reduceMotion) }
var squeezeBack by remember { mutableStateOf(settings.squeezeBack) }
@@ -300,6 +305,9 @@ private fun ViewingDetail(firstSwitch: FocusRequester, modifier: Modifier, top:
SettingLine("Quieter late at night", "From 11pm to 7am, ident sounds play softly on their own, so nobody's woken.") {
OnOff(identSoundNightQuiet, Modifier, enabled = identSound && !identSoundQuiet, onClick = { identSoundNightQuiet = !identSoundNightQuiet; settings.identSoundNightQuiet = identSoundNightQuiet })
}
SettingLine("Coming up next", "Near the end of a programme, a small card in the corner says what's on next.") {
OnOff(upNext, Modifier, onClick = { upNext = !upNext; settings.upNext = upNext })
}
SettingLine("Special idents", "Give named blocks and events their own ident as they begin, such as Riot Laughs or PPV Sunday. Off uses each channel's usual ident.") {
OnOff(specialIdents, Modifier, onClick = { specialIdents = !specialIdents; settings.specialIdents = specialIdents })
}
@@ -0,0 +1,54 @@
package tv.orbit.classic
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableLongStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.tv.material3.Text
/**
* Coming up next (Paul, 8 November 2026): near the end of a programme, a small card in the corner names what's on next, as
* a channel would, for [UP_NEXT_SHOW_MS] and once per programme. It comes in the last few minutes, before the squeeze-back
* and the ident, so they never overlap.
*/
internal const val UP_NEXT_FROM_MS = 3 * 60_000L
internal const val UP_NEXT_UNTIL_MS = 75_000L
internal const val UP_NEXT_SHOW_MS = 10_000L
/** Whether the card may start now, with [remainingMs] of the programme left. */
internal fun upNextMayStart(remainingMs: Long) = remainingMs in (UP_NEXT_UNTIL_MS + 1)..UP_NEXT_FROM_MS
/** The words on the card: "in 3 min", or "next" in the final minute or so. */
internal fun upNextWhen(remainingMs: Long): String = ((remainingMs + 59_999) / 60_000).let { m -> if (m <= 1) "in a minute" else "in $m min" }
@Composable
internal fun UpNextBanner(channel: SampleChannel, current: SampleBroadcast, next: SampleBroadcast, now: Long, modifier: Modifier = Modifier) {
// Kids never sees what a grown-up takeover will show, and nothing is named when the channel goes to sleep.
if (kidsAsleep(takeoverOf(channel.number, next))) return
var until by remember(current.startMs) { mutableLongStateOf(0L) }
val remaining = current.endMs - now
LaunchedEffect(current.startMs, upNextMayStart(remaining)) { if (until == 0L && upNextMayStart(remaining)) until = now + UP_NEXT_SHOW_MS }
if (until == 0L || now >= until) return
val (title, detail) = guideTitle(channel.number, next)
val corner = RoundedCornerShape(10.dp)
Box(Modifier.fillMaxSize().padding(36.dp), contentAlignment = Alignment.BottomEnd) {
Column(modifier.riseIn(0).widthIn(max = 460.dp).background(Navy.copy(alpha = .94f), corner).border(2.dp, Yellow, corner).padding(horizontal = 18.dp, vertical = 12.dp),
verticalArrangement = Arrangement.spacedBy(3.dp)) {
Text("COMING UP NEXT • ${upNextWhen(remaining).uppercase()}", color = Yellow, fontFamily = Anton, fontSize = 14.sp)
Text(title, color = Ink, fontSize = 20.sp, fontWeight = FontWeight.SemiBold, maxLines = 1, overflow = TextOverflow.Ellipsis)
Text(listOfNotNull(detail, "${channel.number} ${ChannelBrands.displayName(channel)}").joinToString(" • "), color = Muted, fontSize = 13.sp, maxLines = 1, overflow = TextOverflow.Ellipsis)
}
}
}
@@ -145,7 +145,9 @@ class PhoneLinkTest {
val pressed = mutableListOf<Int>(); val volume = mutableListOf<Int>()
OrbitCompanion.inject = { synchronized(pressed) { pressed += it } }; OrbitCompanion.volume = { volume += it }
PhoneLink.clock = { now }
PhoneLink.screen = CompanionScreen({ companionChannels }, { selected }, { true }, { 0 }, { n, o -> tuned += n to o; selected = n })
val reminders = mutableListOf<ProgrammeReminder>()
PhoneLink.screen = CompanionScreen({ companionChannels }, { selected }, { true }, { 0 }, { n, o -> tuned += n to o; selected = n },
reminders = { reminders.toList() }, remind = { n, start, title, on -> reminders.removeAll { it.channel == n && it.startMs == start }; if (on) reminders += ProgrammeReminder(n, start, title) })
try {
assertTrue(call("/api/now").body.contains("Enter the code")) // not joined: nothing
// The home-screen manifest needs no phone, and carries Orbit's name only.
@@ -191,6 +193,19 @@ class PhoneLinkTest {
assertEquals(0, JSONObject(call("/api/drivein", cookie = cookie).body).getJSONArray("bills").length())
assertEquals(404, call("/api/drivein/ticket", "POST", """{"startMs":1}""", cookie = cookie).status)
assertEquals(409, call("/api/drivein/watch", "POST", "{}", cookie = cookie).status)
// Reminders from the phone (8 November 2026): only for a programme still to come on a channel this TV shows.
val next = JSONObject(call("/api/guide", cookie = cookie).body).getJSONArray("channels").getJSONObject(0).getJSONObject("next")
assertFalse(next.getBoolean("reminded"))
assertEquals(200, call("/api/remind", "POST", """{"number":101,"startMs":${next.getLong("startMs")},"on":true}""", cookie = cookie).status)
assertEquals(listOf(101 to "Friends"), reminders.map { it.channel to it.title })
assertTrue(JSONObject(call("/api/guide", cookie = cookie).body).getJSONArray("channels").getJSONObject(0).getJSONObject("next").getBoolean("reminded"))
assertEquals(404, call("/api/remind", "POST", """{"number":999,"startMs":${next.getLong("startMs")}}""", cookie = cookie).status)
assertEquals(404, call("/api/remind", "POST", """{"number":101,"startMs":${next.getLong("startMs") + 1}}""", cookie = cookie).status)
assertEquals(200, call("/api/remind", "POST", """{"number":101,"startMs":${next.getLong("startMs")},"on":false}""", cookie = cookie).status)
assertTrue(reminders.isEmpty())
// Orbit TV Times: the page and its listings, for a joined phone.
assertTrue(call("/times", cookie = cookie).status == 200)
assertTrue(JSONObject(call("/api/times", cookie = cookie).body).has("days"))
// Titles and times only.
val everything = call("/api/now", cookie = cookie).body + call("/api/guide", cookie = cookie).body + call("/api/rooms", cookie = cookie).body
listOf("token", "api_key", "password", "X-Emby", "MediaBrowser", "s-a1", "a1").forEach { assertFalse(it, everything.contains("\"$it\"", ignoreCase = true)) }
@@ -0,0 +1,34 @@
package tv.orbit.classic
import org.junit.Assert.*
import org.junit.Test
import java.time.ZoneId
import java.time.ZonedDateTime
/** 8 November 2026: the Coming up next card's timing, and Orbit TV Times built from real plans. */
class UpNextAndTimesTest {
private val minute = 60_000L
@Test fun comingUpNextShowsBetweenThreeMinutesAndTheSqueeze() {
assertFalse(upNextMayStart(3 * minute + 1)); assertTrue(upNextMayStart(3 * minute)); assertTrue(upNextMayStart(76_000))
assertFalse(upNextMayStart(75_000)); assertFalse(upNextMayStart(10_000))
assertEquals("in 3 min", upNextWhen(3 * minute)); assertEquals("in 2 min", upNextWhen(90_000)); assertEquals("in a minute", upNextWhen(50_000))
}
@Test fun tvTimesListsEachEveningsFilmsAndPicksFromThePlans() {
val zone = ZoneId.of("Europe/London")
val day = ZonedDateTime.of(2026, 11, 9, 13, 0, 0, 0, zone).toInstant().toEpochMilli()
val eight = ZonedDateTime.of(2026, 11, 9, 20, 0, 0, 0, zone).toInstant().toEpochMilli()
fun film(id: String, title: String, at: Long) = ScheduleEntry("", EpisodeMark(0, 0), ScheduledMedia(SampleItem(title, "Movie", 100, "", id, 100 * minute), "s-$id", 100 * minute), at)
val plan = ChannelPlan(listOf(film("f1", "Hot Fuzz", eight), film("f2", "Paul", eight + 100 * minute)), ScheduleCursor())
val channel = ScheduledChannel(SampleChannel(plan.entries.map { it.media }, "BritX", 309), plan)
val screen = CompanionScreen({ listOf(channel) }, { 309 }, { false }, { 0 }, { _, _ -> })
val times = OrbitCompanion.times(screen, day, zone)
val first = times.getJSONArray("days").getJSONObject(0)
assertEquals("2026-11-09", first.getString("date"))
val films = first.getJSONArray("films")
assertEquals(listOf("Hot Fuzz", "Paul"), (0 until films.length()).map { films.getJSONObject(it).getString("title") })
assertEquals(309, films.getJSONObject(0).getInt("channel"))
// Ids and sources never go to the phone.
assertFalse(times.toString().contains("s-f1")); assertFalse(times.toString().contains("\"f1\""))
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

+15
View File
@@ -0,0 +1,15 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 260" width="1200" height="260">
<!-- Orbit TV Times masthead (8 November 2026): an old listings magazine's banner, in Orbit's gold and navy. -->
<rect width="1200" height="260" fill="#c8102e"/>
<rect x="0" y="214" width="1200" height="46" fill="#0b1630"/>
<g transform="translate(70 40)">
<circle cx="70" cy="70" r="66" fill="none" stroke="#ffc72c" stroke-width="10"/>
<ellipse cx="70" cy="70" rx="104" ry="30" fill="none" stroke="#ffc72c" stroke-width="8" transform="rotate(-18 70 70)"/>
<circle cx="70" cy="70" r="34" fill="#ffc72c"/>
</g>
<text x="250" y="150" font-family="Georgia, 'Times New Roman', serif" font-weight="700" font-size="136" fill="#ffffff" letter-spacing="2">ORBIT</text>
<text x="742" y="150" font-family="Georgia, 'Times New Roman', serif" font-style="italic" font-weight="700" font-size="104" fill="#ffc72c">TV Times</text>
<text x="252" y="196" font-family="Arial, Helvetica, sans-serif" font-weight="700" font-size="28" fill="#ffffff" letter-spacing="6">THE WEEK'S PROGRAMMES · EVERY CHANNEL</text>
<text x="70" y="246" font-family="Arial, Helvetica, sans-serif" font-weight="700" font-size="24" fill="#ffc72c" letter-spacing="4">FREE WITH YOUR ORBIT</text>
<text x="1130" y="246" text-anchor="end" font-family="Arial, Helvetica, sans-serif" font-weight="700" font-size="24" fill="#ffffff" letter-spacing="4">PICKS · FILMS · DRIVE-IN</text>
</svg>

After

Width:  |  Height:  |  Size: 1.4 KiB