One Orbit at a time, quieter late idents, Back to now, guide reminders, sound credits. Ported from release-0.108 (0.108.104)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -5,7 +5,9 @@
|
||||
<uses-feature android:name="android.software.leanback" android:required="true" />
|
||||
<uses-feature android:name="android.hardware.touchscreen" android:required="false" />
|
||||
<application android:label="Orbit TV" android:theme="@style/OrbitTheme" android:icon="@drawable/orbit_app_icon" android:banner="@drawable/orbit_banner" android:allowBackup="false" android:networkSecurityConfig="@xml/network_security_config" android:supportsRtl="true">
|
||||
<activity android:name=".MainActivity" android:exported="true" android:screenOrientation="landscape">
|
||||
<!-- One Orbit at a time (8 November 2026): a second copy stacked on the first, and its idle half-minute note kept ending
|
||||
what the visible one was watching, so Taste never saw a long stay. -->
|
||||
<activity android:name=".MainActivity" android:exported="true" android:screenOrientation="landscape" android:launchMode="singleTask">
|
||||
<intent-filter><action android:name="android.intent.action.MAIN" /><category android:name="android.intent.category.LEANBACK_LAUNCHER" /></intent-filter>
|
||||
</activity>
|
||||
<!-- The install check (InstallSnapshot.kt): only adb can send it, as it needs the DUMP permission apps can't hold. -->
|
||||
|
||||
@@ -159,7 +159,10 @@ function remote() {
|
||||
const q = state.now?.queue || [];
|
||||
// Orbit in the background on the TV (another app on screen): connected, but say so rather than seem broken.
|
||||
const away = state.now && state.now.onTv === false ? `<div class="card small" style="margin-bottom:10px;border:2px solid var(--accent)"><b style="color:var(--ink)">Orbit isn't on screen on ${esc(room())}.</b> Another app is showing. Open Orbit on the TV and the remote works again.</div>` : '';
|
||||
return head('Remote') + away + nowCard() + (q.length ? `<div class="small" style="margin-top:8px;flex:none;text-align:center">Then from your queue: <b style="color:var(--ink)">${esc(q[0].title)}</b>${q.length > 1 ? ` +${q.length - 1} more` : ''}</div>` : '') + `
|
||||
// A programme reminder showing on the TV shows here too (8 November 2026).
|
||||
const r = state.now && state.now.reminder;
|
||||
const remind = r ? `<div class="card small" style="margin-bottom:10px;border:2px solid var(--accent)"><b style="color:var(--ink)">${r.started ? 'Starting now' : 'Starting soon'}: ${esc(r.title)}</b> on ${esc(String(r.channel))}. Press OK on the TV's reminder to watch.</div>` : '';
|
||||
return head('Remote') + away + remind + nowCard() + (q.length ? `<div class="small" style="margin-top:8px;flex:none;text-align:center">Then from your queue: <b style="color:var(--ink)">${esc(q[0].title)}</b>${q.length > 1 ? ` +${q.length - 1} more` : ''}</div>` : '') + `
|
||||
<div class="padwrap"><div class="pad"><button class="up" data-key="up" aria-label="Up">${I.chev('up')}</button><button class="left" data-key="left" aria-label="Left">${I.chev('left')}</button>
|
||||
<button class="ok" data-key="ok">OK</button><button class="right" data-key="right" aria-label="Right">${I.chev('right')}</button><button class="down" data-key="down" aria-label="Down">${I.chev('down')}</button></div></div>
|
||||
<div class="row"><button class="round" data-key="back" aria-label="Back">${I.back}</button>
|
||||
|
||||
@@ -507,6 +507,9 @@ internal fun EmbyConnectionScreen(modifier: Modifier = Modifier, visible: Boolea
|
||||
PromoOverlay(active, item)
|
||||
}
|
||||
}
|
||||
// The phone shows the reminder too, while the TV does (8 November 2026).
|
||||
LaunchedEffect(programmeReminder) { OrbitCompanion.reminderNow = programmeReminder?.let { r ->
|
||||
org.json.JSONObject().put("title", r.title).put("channel", r.channel).put("startMs", r.startMs).put("started", r.stage >= 2) } }
|
||||
programmeReminder?.let { due ->
|
||||
fun answered() { saveReminders(reminders.map { if (it.channel == due.channel && it.startMs == due.startMs) it.copy(stage = due.stage) else it }); programmeReminder = null }
|
||||
ProgrammeReminderCard(due, System.currentTimeMillis(), onDismiss = ::answered, onWatch = {
|
||||
@@ -806,7 +809,13 @@ internal fun EmbyConnectionScreen(modifier: Modifier = Modifier, visible: Boolea
|
||||
if (item.driveIn == null) Taste.record(TasteKind.Saved, item.entry.media.item.id, item.entry.seriesId, item.entry.media.item.title, item.channel, "reminder") })
|
||||
else -> GuideGrid(channelsIn(guideCategory, availableChannels).ifEmpty { availableChannels }, selectedNumber, modifier, guideCategory, homeCategories(availableChannels.map { it.number }), picture,
|
||||
onCategory = { guideCategory = it }, onWatch = ::tune, onBack = { guideCategory = ChannelCategory.All; onHome() }, onCatchUp = { catchUpOpen = it },
|
||||
onPicture = { tune(selectedNumber, 0) }, onRest = { rested -> scope.launch { TuneAhead.warm(liveSession, rested) } })
|
||||
onPicture = { tune(selectedNumber, 0) }, onRest = { rested -> scope.launch { TuneAhead.warm(liveSession, rested) } },
|
||||
reminders = reminders, onRemind = { number, startMs, title, on ->
|
||||
val kept = liveReminders(reminders, System.currentTimeMillis()).filterNot { it.channel == number && it.startMs == startMs }
|
||||
saveReminders(if (on) kept + ProgrammeReminder(number, startMs, title) else kept)
|
||||
if (on) scheduledChannels[number]?.let { c -> runCatching { c.at(startMs) }.getOrNull()?.let { show ->
|
||||
Taste.record(TasteKind.Saved, show.media.item.id, c.seriesIdAt(startMs), show.media.item.title, number, "reminder") } }
|
||||
})
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -125,7 +125,11 @@ internal fun GuideGrid(channels: List<SampleChannel>, selectedNumber: Int, modif
|
||||
/** The channel on the row the cursor has rested on for a moment, to get it ready ahead ([TuneAhead]). */
|
||||
onRest: (SampleChannel) -> Unit = {},
|
||||
/** OK on a finished programme that can be caught up. */
|
||||
onCatchUp: (CatchUpEntry) -> Unit = {}) {
|
||||
onCatchUp: (CatchUpEntry) -> Unit = {},
|
||||
/** Reminders set, so a later programme shows it has one. */
|
||||
reminders: List<ProgrammeReminder> = emptyList(),
|
||||
/** OK on a later programme: set its reminder, or take it off again (Paul, 8 November 2026). */
|
||||
onRemind: (channel: Int, startMs: Long, title: String, on: Boolean) -> Unit = { _, _, _, _ -> }) {
|
||||
val title = category.label
|
||||
// Moves on as the minute turns: nothing here shows seconds.
|
||||
val now by rememberMinuteClock()
|
||||
@@ -138,7 +142,6 @@ internal fun GuideGrid(channels: List<SampleChannel>, selectedNumber: Int, modif
|
||||
val pictureFocus = remember { FocusRequester() }
|
||||
var gridFocused by remember { mutableStateOf(true) }
|
||||
LaunchedEffect(Unit) { gridFocus.requestFocus() }
|
||||
BackHandler(onBack = onBack)
|
||||
val windowStart = guideWindowStart(now, slotsAhead)
|
||||
val windowEnd = windowStart + GUIDE_SLOTS * GUIDE_SLOT_MS
|
||||
val nowFraction = guideNowFraction(now, windowStart, windowEnd)
|
||||
@@ -152,6 +155,13 @@ internal fun GuideGrid(channels: List<SampleChannel>, selectedNumber: Int, modif
|
||||
openSlot?.let { (slotChannel, slot) -> ShortsSlotDetails(slotChannel, slot, now, onClose = { openSlot = null },
|
||||
onCatchUp = { show -> openSlot = null; onCatchUp(catchUpEntry(slotChannel, show)) }, onWatch = { openSlot = null; onWatch(slotChannel.number, 0) }) }
|
||||
val focusedPast = focused.endMs <= now && catchUpAvailable(channel, focused, now)
|
||||
// Back to now (Paul, 8 November 2026): after browsing later times or other channels, Back first returns to what's on now on
|
||||
// the tuned channel; Back again leaves the guide as before.
|
||||
val focusedLater = focused.startMs > now
|
||||
val reminded = focusedLater && reminders.any { it.channel == channel.number && it.startMs == focused.startMs }
|
||||
val tunedRow = channels.indexOfFirst { it.number == selectedNumber }.coerceAtLeast(0)
|
||||
val awayFromNow = slotsAhead != 0 || focused.startMs > now || row != tunedRow
|
||||
BackHandler { if (awayFromNow) { cursor = now; slotsAhead = 0; row = tunedRow } else onBack() }
|
||||
fun keepCursorInWindow(time: Long) {
|
||||
cursor = time
|
||||
val base = guideWindowStart(now, 0)
|
||||
@@ -179,6 +189,13 @@ internal fun GuideGrid(channels: List<SampleChannel>, selectedNumber: Int, modif
|
||||
if (focusedPast) Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(6.dp)) {
|
||||
CatchUpMark(); Text("CATCH UP • OK to watch from the start", color = CatchUpGreen, fontSize = 12.sp, fontWeight = FontWeight.SemiBold)
|
||||
}
|
||||
else if (focusedLater) Row(horizontalArrangement = Arrangement.spacedBy(6.dp)) {
|
||||
Text(if (reminded) "REMINDER SET • OK to take it off" else "OK Remind me", color = if (reminded) Yellow else Ink, fontSize = 12.sp, fontWeight = FontWeight.SemiBold)
|
||||
Text("BACK Back to now", Modifier.background(Yellow, androidx.compose.foundation.shape.RoundedCornerShape(3.dp)).padding(horizontal = 6.dp, vertical = 1.dp),
|
||||
color = OnAccent, fontSize = 12.sp, fontWeight = FontWeight.Bold)
|
||||
}
|
||||
else if (awayFromNow) Text("BACK Back to now", Modifier.background(Yellow, androidx.compose.foundation.shape.RoundedCornerShape(3.dp)).padding(horizontal = 6.dp, vertical = 1.dp),
|
||||
color = OnAccent, fontSize = 12.sp, fontWeight = FontWeight.Bold)
|
||||
}
|
||||
// The picture can be chosen: up from the top row reaches it, OK goes full screen on it, down comes back.
|
||||
var pictureFocused by remember { mutableStateOf(false) }
|
||||
@@ -225,6 +242,8 @@ internal fun GuideGrid(channels: List<SampleChannel>, selectedNumber: Int, modif
|
||||
if (native.repeatCount == 0 && slot != null) openSlot = slot
|
||||
else if (native.repeatCount == 0 && focusedPast) onCatchUp(catchUpEntry(channel, focused))
|
||||
else if (native.repeatCount == 0 && focused.startMs <= now) onWatch(channel.number, 0)
|
||||
else if (native.repeatCount == 0 && focusedLater && !kidsAsleep(takeoverOf(channel.number, focused)))
|
||||
onRemind(channel.number, focused.startMs, guideTitle(channel.number, focused).first, !reminded)
|
||||
true
|
||||
}
|
||||
else -> false
|
||||
|
||||
@@ -48,6 +48,14 @@ private val IdentVideos = mapOf(108 to R.raw.ident_108, 109 to R.raw.ident_109,
|
||||
*/
|
||||
internal fun identVolume(quiet: Boolean) = if (quiet) .4f else 1f
|
||||
|
||||
/** Late at night: 11pm until 7am by the box's clock (Paul, 8 November 2026: "so a thunderclap on After Dark doesn't wake anyone"). */
|
||||
internal fun identLateNight(nowMs: Long, zone: java.time.ZoneId = java.time.ZoneId.systemDefault()): Boolean =
|
||||
java.time.Instant.ofEpochMilli(nowMs).atZone(zone).hour.let { it >= 23 || it < 7 }
|
||||
|
||||
/** Whether ident sound plays softly now: always, when set; late at night, unless that's turned off. */
|
||||
internal fun identQuietNow(settings: OrbitSettings, nowMs: Long = System.currentTimeMillis()) =
|
||||
settings.identSoundQuiet || (settings.identSoundNightQuiet && identLateNight(nowMs))
|
||||
|
||||
internal object IdentStings {
|
||||
private val last = HashMap<Int, Long>()
|
||||
const val GAP_MS = 20 * 60_000L
|
||||
@@ -142,8 +150,8 @@ internal fun IdentOverlay(session: EmbySampleSession, channel: SampleChannel, ne
|
||||
}
|
||||
seekTo(startedLateMs.coerceIn(0, identMs))
|
||||
volume = if (block != null) (if (settings.blockIdentSound) 1f else 0f)
|
||||
else if (mood != null && settings.identSound && !settings.reduceMotion && TotsJingle.take(mood, System.currentTimeMillis())) identVolume(settings.identSoundQuiet)
|
||||
else if (mood == null && settings.identSound && IdentStings.take(channel.number, System.currentTimeMillis())) identVolume(settings.identSoundQuiet) else 0f
|
||||
else if (mood != null && settings.identSound && !settings.reduceMotion && TotsJingle.take(mood, System.currentTimeMillis())) identVolume(identQuietNow(settings))
|
||||
else if (mood == null && settings.identSound && IdentStings.take(channel.number, System.currentTimeMillis())) identVolume(identQuietNow(settings)) else 0f
|
||||
addListener(object : androidx.media3.common.Player.Listener {
|
||||
override fun onPlayerError(error: androidx.media3.common.PlaybackException) {
|
||||
android.util.Log.w("OrbitSchedule", "ident channel=${channel.number} failed=${error.errorCodeName}"); failed = true
|
||||
|
||||
@@ -124,6 +124,8 @@ internal object OrbitCompanion {
|
||||
/** What the TV is on: the chosen channel, what it's showing at the TV's clock, and what's next. */
|
||||
/** Orbit is on the TV's screen; false while the TV shows another app (phones and paired rooms still connect). */
|
||||
@Volatile var onTv = true
|
||||
/** The programme reminder showing on the TV now, for the phone. */
|
||||
@Volatile var reminderNow: org.json.JSONObject? = null
|
||||
fun now(screen: CompanionScreen, nowMs: Long): JSONObject {
|
||||
val reply = JSONObject().put("room", Rooms.name).put("look", look()).put("serverMs", nowMs)
|
||||
val channel = screen.channels().firstOrNull { it.number == screen.selected() } ?: return reply.put("channel", JSONObject.NULL)
|
||||
|
||||
@@ -491,7 +491,7 @@ internal object PhoneLink {
|
||||
fun body() = runCatching { JSONObject(r.body) }.getOrNull() ?: JSONObject()
|
||||
fun onScreen(block: () -> Unit) = runBlocking { withContext(mainDispatcher) { block() } }
|
||||
when ("${r.method} ${r.path}") {
|
||||
"GET /api/now" -> json(out, 200, OrbitCompanion.now(s, now).put("queue", OrbitCompanion.queueJson()).put("onTv", OrbitCompanion.onTv))
|
||||
"GET /api/now" -> json(out, 200, OrbitCompanion.now(s, now).put("queue", OrbitCompanion.queueJson()).put("onTv", OrbitCompanion.onTv).put("reminder", OrbitCompanion.reminderNow ?: org.json.JSONObject.NULL))
|
||||
"GET /api/guide" -> json(out, 200, OrbitCompanion.guide(s, now))
|
||||
"GET /api/catchup" -> json(out, 200, JSONObject().put("shelves", OrbitCompanion.catchUp(s, now)))
|
||||
"GET /api/rooms" -> json(out, 200, OrbitCompanion.rooms(appContext))
|
||||
|
||||
@@ -98,6 +98,10 @@ internal class OrbitSettings(context: Context) {
|
||||
var identSoundQuiet: Boolean
|
||||
get() = saved.getBoolean("ident_sound_quiet", false)
|
||||
set(value) { saved.edit().putBoolean("ident_sound_quiet", value).apply() }
|
||||
/** Quiet on its own late at night, 11pm to 7am (Paul, 8 November 2026). On by default. */
|
||||
var identSoundNightQuiet: Boolean
|
||||
get() = saved.getBoolean("ident_sound_night_quiet", true)
|
||||
set(value) { saved.edit().putBoolean("ident_sound_night_quiet", value).apply() }
|
||||
var driveInIntro: Boolean
|
||||
get() = saved.getBoolean("drive_in_intro", true)
|
||||
set(value) { saved.edit().putBoolean("drive_in_intro", value).apply() }
|
||||
@@ -265,6 +269,7 @@ private fun ViewingDetail(firstSwitch: FocusRequester, modifier: Modifier, top:
|
||||
var idents by remember { mutableStateOf(settings.idents) }
|
||||
var identSound by remember { mutableStateOf(settings.identSound) }
|
||||
var identSoundQuiet by remember { mutableStateOf(settings.identSoundQuiet) }
|
||||
var identSoundNightQuiet by remember { mutableStateOf(settings.identSoundNightQuiet) }
|
||||
var driveInIntro by remember { mutableStateOf(settings.driveInIntro) }
|
||||
var reduceMotion by remember { mutableStateOf(settings.reduceMotion) }
|
||||
var squeezeBack by remember { mutableStateOf(settings.squeezeBack) }
|
||||
@@ -292,12 +297,19 @@ private fun ViewingDetail(firstSwitch: FocusRequester, modifier: Modifier, top:
|
||||
SettingLine("Quiet ident sound", "Play the ident sounds softly, well under the programmes. Reduce motion shows idents as a still card, with no sound.") {
|
||||
OnOff(identSoundQuiet, Modifier, enabled = identSound, onClick = { identSoundQuiet = !identSoundQuiet; settings.identSoundQuiet = identSoundQuiet })
|
||||
}
|
||||
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("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 })
|
||||
}
|
||||
SettingLine("Special ident sound", "Play the short sound with each special ident. Off keeps them silent.") {
|
||||
OnOff(blockIdentSound, Modifier, onClick = { blockIdentSound = !blockIdentSound; settings.blockIdentSound = blockIdentSound })
|
||||
}
|
||||
// Credits for the sounds Paul chose (8 November 2026): royalty-free effects, named with thanks (design/channels/sound/samples).
|
||||
Text("Sound credits: VHS, Horror, After Dark, Vortex, Heroes, Riot, Paradox and Ring X use royalty-free effects from Pixabay by " +
|
||||
"freesound_community, jusatti890, tomas_herudek, audiopapkin, vishiv and other Pixabay creators, mastered for Orbit. Thank you.",
|
||||
Modifier.fillMaxWidth().clip(RailCorner).background(Panel).padding(horizontal = 12.dp, vertical = 8.dp), color = Muted, fontSize = 12.sp)
|
||||
SettingLine("Squeeze-back", "Over a programme's last minute, the credits shrink into a corner and what's next on the channel fills the screen beside them.") {
|
||||
OnOff(squeezeBack, Modifier, onClick = { squeezeBack = !squeezeBack; settings.squeezeBack = squeezeBack })
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package tv.orbit.classic
|
||||
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Test
|
||||
import java.time.ZoneId
|
||||
import java.time.ZonedDateTime
|
||||
|
||||
/** 8 November 2026: ident sounds play softly from 11pm to 7am. */
|
||||
class IdentLateNightTest {
|
||||
private val zone = ZoneId.of("Europe/London")
|
||||
private fun at(h: Int, m: Int = 0) = ZonedDateTime.of(2026, 11, 8, h, m, 0, 0, zone).toInstant().toEpochMilli()
|
||||
@Test fun lateNightIsElevenToSeven() {
|
||||
assertFalse(identLateNight(at(22, 59), zone)); assertTrue(identLateNight(at(23, 0), zone))
|
||||
assertTrue(identLateNight(at(3), zone)); assertTrue(identLateNight(at(6, 59), zone)); assertFalse(identLateNight(at(7), zone))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package tv.orbit.classic
|
||||
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.TemporaryFolder
|
||||
|
||||
/** 8 November 2026: a night's real data had no "stayed" and every signal at 0 ms watched. Half-minute notes must add up. */
|
||||
class TasteStayedTest {
|
||||
@get:Rule val tmp = TemporaryFolder()
|
||||
@Test fun halfMinuteNotesAddUpToStayed() {
|
||||
val minute = 60_000L; val start = 1_794_000_000_000L
|
||||
val adult = Profile("grown", "Adult", "sil-blue", ProfileKind.Grown)
|
||||
Taste.attach(tmp.root, start)
|
||||
val show = SampleBroadcast(ScheduledMedia(SampleItem("Terror Train", "Movie", 97, "", "6048906", 97 * minute), "src", 97 * minute), start)
|
||||
for (i in 0..60) { val now = start + i * 30_000L; Taste.watching(304, show, null, now - start, now, adult) }
|
||||
val kinds = Taste.store!!.events("grown").map { it.kind to it.watchedMs }
|
||||
println(kinds)
|
||||
assertTrue(kinds.toString(), kinds.any { it.first == TasteKind.Stayed && (it.second ?: 0) >= 20 * minute })
|
||||
assertTrue(kinds.none { it.first == TasteKind.Brief })
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user