diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts index 0df2f680..c23d0070 100644 --- a/android/app/build.gradle.kts +++ b/android/app/build.gradle.kts @@ -9,8 +9,8 @@ android { applicationId = "tv.orbit.classic" minSdk = 26 targetSdk = 36 - versionCode = 250 - versionName = "0.108.90-director-plan" + versionCode = 251 + versionName = "0.108.91-planning-shown" } buildFeatures { compose = true } // The finished build for the TVs (Paul, 6 November 2026: the test build stuttered on the box). Not debuggable, so diff --git a/android/app/src/main/assets/phone/companion.html b/android/app/src/main/assets/phone/companion.html index 55707bf1..415bc4a7 100644 --- a/android/app/src/main/assets/phone/companion.html +++ b/android/app/src/main/assets/phone/companion.html @@ -82,6 +82,7 @@ body:has(main.kpad) .toast{bottom:calc(250px + env(safe-area-inset-bottom))} /* While typing, the keyboard pushes fixed bars up over the search results (Paul, 7 November 2026): hide them until it's down. */ body.typing .kbar,body.typing nav{display:none} .toast button{margin-left:10px;font-weight:800;text-decoration:underline;color:inherit} +@keyframes kplan{0%{margin-left:-35%}100%{margin-left:100%}}.kplan{animation:kplan 1.6s ease-in-out infinite} .toast{position:fixed;left:50%;bottom:90px;transform:translateX(-50%);background:var(--accent);color:var(--on-accent);padding:9px 16px;border-radius:999px;font-weight:700;font-size:13px;z-index:9;display:none;max-width:90vw;text-align:center} .empty{color:var(--muted);text-align:center;padding:30px 10px} @@ -261,8 +262,8 @@ function more() {
${(yours?.channels || []).map(c => `
- + ${c.planning ? `Planning…` : ``}
`).join('')} ${!yours || yours.next ? `` : ''}
`; const line = (label, value, attr, first) => ``; @@ -443,8 +444,11 @@ const brandOf = d => d.brand !== undefined ? d.brand : ((state.brands || []).fin function doneView() { const c = state.create, k = c.done; return `
✓
-
${esc(k.name)} is ready on ${k.number}
-
${esc(k.message || '')}
+
${esc(k.name)} is on ${k.number}
+ ${k.minutes ? `
Planning its first week +
+
About ${k.minutes === 1 ? 'a minute' : k.minutes + ' minutes'}. Orbit reads every title's episodes, then lays out the week. It comes on by itself, and Your channels shows when it's done. Watch anything else meanwhile.
` + : `
${esc(k.message || '')}
`} ${c.watching ? `
${esc(c.watching)}
` : ''} ${k.queued ? '' : ``}
`; @@ -596,7 +600,7 @@ async function makeChannel(ending) { try { const r = await api('/api/channels', {number: d.number, name: d.name, description: d.description, style: d.style, hours: d.hours, shows: d.shows.map(x => ({id: x.id, title: x.title, year: x.year ?? null, type: x.type})), slots: d.style === 'Shaped' ? d.slots : undefined, core: d.style === 'Shaped' ? d.core : undefined, season: d.season || null, brand: d.brand !== undefined ? d.brand : undefined, collection: d.collection || undefined}); - c.done = {number: r.number, name: d.name, message: r.message, edit: !!d.number}; c.busy = false; render(); load('more'); + c.done = {number: r.number, name: d.name, message: r.message, minutes: d.number ? 0 : r.minutes, edit: !!d.number}; c.busy = false; render(); load('more'); // Create & watch next: queued for after the programme on now, never interrupting it (Paul, 7 November 2026). if (ending === 'next') { await watchNew('next'); } } catch (e) { c.note = e.message; c.busy = false; render(); } diff --git a/android/app/src/main/java/tv/orbit/classic/CustomChannels.kt b/android/app/src/main/java/tv/orbit/classic/CustomChannels.kt index 8f86993d..bb558a3e 100644 --- a/android/app/src/main/java/tv/orbit/classic/CustomChannels.kt +++ b/android/app/src/main/java/tv/orbit/classic/CustomChannels.kt @@ -99,6 +99,11 @@ internal object CustomChannels { fun clear() { list = emptyList() } fun nextNumber(): Int? = (YOURS_FIRST..YOURS_LAST).firstOrNull { n -> list.none { it.number == n } } fun of(number: Int) = list.firstOrNull { it.number == number } + /** The channel of your own whose first week is being planned right now, if any, for the phone to show. */ + @Volatile var planning: Int? = null + + /** Roughly how long a first plan takes, from what it has to read: each series' episodes, a quick look for each film. */ + fun planMinutes(series: Int, films: Int) = ((series * 9 + films) / 60.0).let { kotlin.math.ceil(it).toInt() }.coerceAtLeast(1) @Volatile private var cached: Pair, List> = emptyList() to emptyList() /** Every channel of your own as the planner sees it. */ @@ -117,6 +122,9 @@ internal fun programmingOf(channel: CustomChannel): ChannelProgramming = Channel channel.number, channel.name, emptyList(), seriesCount = 60, finishTogether = channel.style == PlayStyle.Standard || channel.style == PlayStyle.Blocks || channel.style == PlayStyle.Shaped, exactTitles = true, shuffleEpisodes = channel.style == PlayStyle.Shuffled, mixedTurns = true, + // You chose these titles yourself, so they play in the sound they have: Sakura's anime is mostly Japanese with subtitles, + // and asking for English sound left nearly all of it out (7 November 2026). + englishAudio = false, dayParts = when (channel.style) { PlayStyle.Blocks -> timetableParts(channel.shows); PlayStyle.Shaped -> shapedParts(channel.slots); else -> emptyList() }, storyGrouping = channel.style == PlayStyle.Standard || channel.style == PlayStyle.Shaped, shorts = if (channel.style == PlayStyle.Standard || channel.style == PlayStyle.Shaped) YoursShorts else null, diff --git a/android/app/src/main/java/tv/orbit/classic/EmbyClient.kt b/android/app/src/main/java/tv/orbit/classic/EmbyClient.kt index ccc08e21..f7b4f1e1 100644 --- a/android/app/src/main/java/tv/orbit/classic/EmbyClient.kt +++ b/android/app/src/main/java/tv/orbit/classic/EmbyClient.kt @@ -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 = when (kind) { - ServerKind.Emby -> mapOf("X-Emby-Authorization" to "Emby Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.108.90\"") + + ServerKind.Emby -> mapOf("X-Emby-Authorization" to "Emby Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.108.91\"") + (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.90\"" + + ServerKind.Jellyfin -> mapOf("Authorization" to "MediaBrowser Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.108.91\"" + (token?.let { ", Token=\"$it\"" } ?: "")) } /** One picture from the provider, or nothing. Same fixed origin and no redirects, and failures are never shown or logged. */ diff --git a/android/app/src/main/java/tv/orbit/classic/EmbyConnectionScreen.kt b/android/app/src/main/java/tv/orbit/classic/EmbyConnectionScreen.kt index 47e33210..e4f94532 100644 --- a/android/app/src/main/java/tv/orbit/classic/EmbyConnectionScreen.kt +++ b/android/app/src/main/java/tv/orbit/classic/EmbyConnectionScreen.kt @@ -504,10 +504,13 @@ internal fun EmbyConnectionScreen(modifier: Modifier = Modifier, visible: Boolea fun setSmartSchedule(programming: ChannelProgramming, turnOn: Boolean) { val active = session ?: return val existing = smartLoop(programming) + // Planning another channel: say so, rather than the switch seeming to do nothing (Paul, 7 November 2026). + if (busy) { message = "Orbit is still planning ${CustomChannels.planning?.let { CustomChannels.of(it)?.name } ?: "another channel"}. Try again when it's finished."; return } // A second press straight after the first is taken as a slip. - if (busy || now - lastSmartPress < 5_000) return + if (now - lastSmartPress < 5_000) return lastSmartPress = now busy = true; busyLabel = "Reading ${programming.name}'s whole series and planning seven days…"; message = null + if (turnOn && CustomChannels.of(programming.number) != null) CustomChannels.planning = programming.number job = scope.launch { try { if (turnOn) { @@ -529,7 +532,7 @@ internal fun EmbyConnectionScreen(modifier: Modifier = Modifier, visible: Boolea } catch (cancelled: CancellationException) { throw cancelled } catch (failure: EmbyCheckException) { withContext(Dispatchers.IO) { scheduler.setEnabled(active.accountId, programming.number, false) }; message = failure.message } catch (_: Exception) { withContext(Dispatchers.IO) { scheduler.setEnabled(active.accountId, programming.number, false) }; message = "${programming.name} could not be scheduled, so it stays off." } - finally { busy = false } + finally { busy = false; CustomChannels.planning = null } } } // Create your own from a phone and the Companion: kept here, before any screen returns early, so the phone can make @@ -570,7 +573,9 @@ internal fun EmbyConnectionScreen(modifier: Modifier = Modifier, visible: Boolea } android.util.Log.i("OrbitSchedule", "yours channel=${channel.number} style=${channel.style} titles=${shows.size}") SmartChannels.firstOrNull { it.number == channel.number }?.let { setSmartSchedule(it, true) } - "${channel.name} is ready on ${channel.number}. Its first programmes are being planned now." + val minutes = CustomChannels.planMinutes(shows.count { it.type == "Series" }, shows.count { it.type != "Series" }) + "${channel.name} is on ${channel.number}. Orbit is reading its titles and planning the week, which takes about " + + (if (minutes == 1) "a minute" else "$minutes minutes") + ". It comes on by itself, and you can watch anything else meanwhile." }, remove = { number -> val gone = CustomChannels.of(number) ?: return@ChannelMaker "That channel has already gone." diff --git a/android/app/src/main/java/tv/orbit/classic/PhoneLink.kt b/android/app/src/main/java/tv/orbit/classic/PhoneLink.kt index 237b260c..9215a919 100644 --- a/android/app/src/main/java/tv/orbit/classic/PhoneLink.kt +++ b/android/app/src/main/java/tv/orbit/classic/PhoneLink.kt @@ -294,7 +294,8 @@ internal object PhoneLink { val h = standIn ?: handler ?: return json(out, 403, JSONObject().put("error", "The TV isn't signed in to a library right now.")) when ("${r.method} ${r.path}") { "GET /api/channels" -> json(out, 200, JSONObject().put("next", CustomChannels.nextNumber() ?: JSONObject.NULL).put("channels", JSONArray(CustomChannels.list.map { c -> - c.toJson().put("on", h.isOn(c.number)).put("styleTitle", c.style.title).put("hoursLabel", c.hours?.label ?: "All day") }))) + c.toJson().apply { remove("seen") }.put("on", h.isOn(c.number)).put("planning", CustomChannels.planning == c.number) + .put("styleTitle", c.style.title).put("hoursLabel", c.hours?.label ?: "All day") }))) "GET /api/shows" -> { val number = r.query["number"]?.toIntOrNull() ?: return json(out, 400, JSONObject()) json(out, 200, JSONArray(runBlocking { h.maker.showsOf(number) }.map(::suggestionJson))) @@ -389,7 +390,8 @@ internal object PhoneLink { slots = o.optJSONObject("slots")?.let { m -> m.keys().asSequence().mapNotNull { id -> titleOf[id]?.let { t -> runCatching { t to Slot.valueOf(m.getString(id)) }.getOrNull() } }.toMap() }.orEmpty(), core = o.optJSONArray("core")?.let { a -> (0 until minOf(a.length(), 20)).mapNotNull { titleOf[a.getString(it)] }.toSet() }.orEmpty()) val said = runBlocking { withContext(mainDispatcher) { h.maker.create(laidOut, shows) } } - json(out, 200, JSONObject().put("message", said).put("number", number)) + json(out, 200, JSONObject().put("message", said).put("number", number) + .put("minutes", CustomChannels.planMinutes(shows.count { it.type == "Series" }, shows.count { it.type != "Series" }))) } // Off keeps a channel and its place; on plans it again (Paul, 7 November 2026: an Off switch beside Remove). "POST /api/channels/power" -> { diff --git a/android/app/src/main/java/tv/orbit/classic/SecureMediaDataSource.kt b/android/app/src/main/java/tv/orbit/classic/SecureMediaDataSource.kt index c347a7c6..cf73dd04 100644 --- a/android/app/src/main/java/tv/orbit/classic/SecureMediaDataSource.kt +++ b/android/app/src/main/java/tv/orbit/classic/SecureMediaDataSource.kt @@ -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.90") + next.setRequestProperty("User-Agent", "OrbitTV/0.108.91") 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()) {