Stage 1 (0.129): the password field, Who's watching, Settings pages, Quiz Night, High Scores, subtitles
- Password: Android's own password field, so accessibility gets dots, not the password (TalkBack no longer reads it). - Who's watching and every PIN: a full-screen window over everything; the five-second carry-on is gone; at launch Back leaves Orbit, from inside Orbit it goes back keeping the profile. - Pages that open in Settings (Director's Chair, New arrivals, Create your own, Add a room, Connect a phone): focus goes in and stays in; Back returns to the card that opened them. - Quiz Night redraws on OK. High Scores: one table with shared columns. - Subtitles: Off / On / Automatic, enforced in the player (forced tracks only under Off), the same from the phone. - Up and Down leave text fields. 0.129.0 (build 42). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,7 +3,7 @@ plugins {
|
||||
id("org.jetbrains.kotlin.plugin.compose")
|
||||
}
|
||||
/** The release's build number: versionCode is this x 10 plus the edition's channel. */
|
||||
val ORBIT_BUILD = 41
|
||||
val ORBIT_BUILD = 42
|
||||
android {
|
||||
namespace = "tv.orbit.classic"
|
||||
compileSdk = 36
|
||||
@@ -11,7 +11,7 @@ android {
|
||||
applicationId = "tv.orbit.classic"
|
||||
minSdk = 26
|
||||
targetSdk = 36
|
||||
versionName = "0.128.0"
|
||||
versionName = "0.129.0"
|
||||
}
|
||||
// Two editions of the same app (Paul, 10 November 2026): the household build, which updates itself between rooms, and the
|
||||
// Play build, which only Google Play updates. Both are tv.orbit.classic, so a TV can move between them keeping its data.
|
||||
|
||||
@@ -75,7 +75,7 @@ private fun PlaybackTest(itemId: String, done: () -> Unit) {
|
||||
var problem by remember { mutableStateOf<String?>(null) }
|
||||
val record = remember { PlaybackTestRecord() }
|
||||
// Starts from the subtitles setting exactly as a channel visit does, so the test shows what a viewer would get.
|
||||
val subtitles = remember { mutableStateOf(if (OrbitSettings(context).subtitlesOn) SUBTITLES_BY_DEFAULT else null) }
|
||||
val subtitles = remember { mutableStateOf<String?>(OrbitSettings(context).subtitleMode.preference) }
|
||||
val startedAt = remember { android.os.SystemClock.elapsedRealtime() }
|
||||
var ended by remember { mutableStateOf(false) }
|
||||
fun finish(reason: String) {
|
||||
@@ -125,7 +125,10 @@ private fun PlaybackTest(itemId: String, done: () -> Unit) {
|
||||
selected(C.TRACK_TYPE_VIDEO)?.let { record.video = "${playTestLabel(it.sampleMimeType)} ${it.width}x${it.height}" }
|
||||
selected(C.TRACK_TYPE_AUDIO)?.let { record.audio = "${playTestLabel(it.sampleMimeType)} ${playTestLabel(it.language)} ${it.channelCount}ch" }
|
||||
val text = tracks.groups.filter { it.type == C.TRACK_TYPE_TEXT }
|
||||
record.subtitles = text.map { g -> g.getTrackFormat(0).let { "${playTestLabel(it.sampleMimeType ?: it.codecs)} ${playTestLabel(it.language)}" + (if (g.isSupported) "" else " unsupported") + (if (g.isSelected) " selected" else "") } }
|
||||
record.subtitles = text.map { g -> g.getTrackFormat(0).let { "${playTestLabel(it.sampleMimeType ?: it.codecs)} ${playTestLabel(it.language)}" + (if (g.isSupported) "" else " unsupported") +
|
||||
// Whether the file marks it default or forced (0.129: Off shows forced tracks only).
|
||||
(if (it.selectionFlags and C.SELECTION_FLAG_FORCED != 0) " forced" else "") + (if (it.selectionFlags and C.SELECTION_FLAG_DEFAULT != 0) " default" else "") +
|
||||
(if (g.isSelected) " selected" else "") } }
|
||||
record.subtitleSelected = selected(C.TRACK_TYPE_TEXT)?.let { playTestLabel(it.language) } ?: "none"
|
||||
Log.i("OrbitPlayTest", "playtest tracks video=${record.video} audio=${record.audio} subtitles=${record.subtitles.joinToString(", ")}")
|
||||
}
|
||||
|
||||
@@ -329,6 +329,7 @@ function more() {
|
||||
h += `<div class="label">Settings</div><div style="background:var(--surface);border-radius:16px;overflow:hidden">
|
||||
${line('Look', keptLook() ? esc(keptLook()) : 'Follows the TV', 'data-klook="1"', true)}
|
||||
${standalone() ? '' : line('Add to home screen', '', 'data-home="1"')}
|
||||
${line('Subtitles', esc(state.now?.subtitles?.mode || ''), 'data-ksubs="1"')}
|
||||
${line('Back up and restore', '', 'data-kbackup="1"')}
|
||||
${line('About Orbit Companion', '', 'data-kabout="1"')}</div>`;
|
||||
return h;
|
||||
@@ -805,6 +806,12 @@ document.addEventListener('click', e => {
|
||||
if (d.klook) { openSheet(`<div class="title">Look</div><div class="small" style="margin:6px 0 12px">Following the TV, each room's remote wears that room's look. Pick one to keep it on this phone instead.</div>
|
||||
<div class="chips" style="flex-wrap:wrap"><button class="${keptLook() ? '' : 'on'}" data-look="">Follow this TV${state.now?.look ? ' (' + esc(state.now.look.name) + ')' : ''}</button>
|
||||
${(state.looks || []).map(l => `<button class="${keptLook() === l.name ? 'on' : ''}" data-look="${esc(l.name)}">${esc(l.name)}</button>`).join('')}</div>`); return; }
|
||||
// Subtitles, the same setting as the TV's (0.129): Off, On or Automatic, each saying what it does.
|
||||
if (d.ksubs) { const cur = state.now?.subtitles?.mode;
|
||||
const opts = [['Off', 'No subtitles. Short translations a programme marks as needed still show.'], ['On', 'Subtitles in your language whenever a programme has them.'], ['Automatic', 'Subtitles in your language when the sound is in another language.']];
|
||||
openSheet(`<div class="title">Subtitles</div><div class="small" style="margin:6px 0 12px">The TV's setting, the same as in Settings on the TV. It applies straight away; press right on the TV to change them for one programme.</div>` +
|
||||
opts.map(([m, l]) => `<button class="btn${cur === m ? ' gold' : ''}" data-subs="${m}" style="margin-top:8px;text-align:left"><b>${m}</b><div class="small">${l}</div></button>`).join('')); return; }
|
||||
if (d.subs) { api('/api/subtitles', {mode: d.subs}).then(j => { if (state.now) state.now.subtitles = j; closeSheet(); toast('Subtitles: ' + j.mode); render(); }).catch(e => toast(e.message)); return; }
|
||||
if (d.kbackup) { state.bnote = ''; openSheet(backupSheet()); api('/api/backup').then(j => { state.backup = j; if ($('#bsheet')) openSheet(backupSheet()); }).catch(() => {}); return; }
|
||||
if (d.bmake) { makeBackup(); return; }
|
||||
if (d.kabout) { openSheet(`<div class="title">Orbit Companion</div><div class="small" style="margin-top:8px">It runs on the TV itself, over your home Wi-Fi: nothing to install, no account. It works while Orbit is open on the TV. To stop this phone, remove it in Settings › Rooms and phones on the TV.</div>`); return; }
|
||||
|
||||
@@ -149,6 +149,8 @@ internal fun PinEntry(title: String, problem: String?, onDone: (String) -> Unit,
|
||||
BackHandler(onBack = onCancel)
|
||||
fun submit(e: ChannelEntry) = onDone(e.digits.joinToString(""))
|
||||
val corner = RoundedCornerShape(8.dp)
|
||||
// Its own window (0.129): nothing behind a PIN can take the remote, and the PIN stays out of screenshots.
|
||||
OrbitModal(onBack = onCancel, scrim = Navy.copy(alpha = .85f), secure = true) {
|
||||
Column(Modifier.background(Navy, corner).border(2.dp, Yellow, corner).padding(horizontal = 22.dp, vertical = 14.dp).focusRequester(focus).focusable().onPreviewKeyEvent { event ->
|
||||
val native = event.nativeKeyEvent
|
||||
val typed = if (native.keyCode in KeyEvent.KEYCODE_0..KeyEvent.KEYCODE_9) native.keyCode - KeyEvent.KEYCODE_0 else null
|
||||
@@ -178,6 +180,7 @@ internal fun PinEntry(title: String, problem: String?, onDone: (String) -> Unit,
|
||||
}
|
||||
Text(problem ?: "▲▼ Change OK Next Back Cancel", color = if (problem != null) Yellow else Muted, fontSize = 11.sp)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private enum class LockStep { None, Unlock, NewPin, ConfirmPin, CheckForChange, CheckForOff }
|
||||
|
||||
@@ -1034,12 +1034,7 @@ private fun SignInForm(modifier: Modifier, serverText: String, onServer: (String
|
||||
keyboardOptions = KeyboardOptions(autoCorrectEnabled = false, keyboardType = KeyboardType.Uri, imeAction = ImeAction.Next),
|
||||
modifier = Modifier.fillMaxWidth().onFocusChanged { serverFocused = it.isFocused }
|
||||
.background(Panel).border(2.dp, if (serverFocused) Yellow else Blue)
|
||||
.onPreviewKeyEvent { event ->
|
||||
if (event.nativeKeyEvent.keyCode == KeyEvent.KEYCODE_DPAD_CENTER) {
|
||||
if (event.nativeKeyEvent.action == KeyEvent.ACTION_UP) keyboard?.show()
|
||||
true
|
||||
} else false
|
||||
}.padding(12.dp))
|
||||
.onPreviewKeyEvent { event -> textFieldKeys(event.nativeKeyEvent, keyboard, focus) }.padding(12.dp))
|
||||
Text("For example https://emby.example.com, or a server at home: http://192.168.1.20:8096", color = Muted, fontSize = 11.sp)
|
||||
// A home server over plain HTTP: say plainly what that means before the password goes.
|
||||
if (serverText.trim().startsWith("http://", ignoreCase = true)) Text(
|
||||
@@ -1055,29 +1050,11 @@ private fun SignInForm(modifier: Modifier, serverText: String, onServer: (String
|
||||
keyboardActions = KeyboardActions(onNext = { passwordFocus.requestFocus(); keyboard?.show() }),
|
||||
modifier = Modifier.fillMaxWidth().onFocusChanged { userFocused = it.isFocused }
|
||||
.background(Panel).border(2.dp, if (userFocused) Yellow else Blue)
|
||||
.onPreviewKeyEvent { event ->
|
||||
if (event.nativeKeyEvent.keyCode == KeyEvent.KEYCODE_DPAD_CENTER) {
|
||||
if (event.nativeKeyEvent.action == KeyEvent.ACTION_UP) keyboard?.show()
|
||||
true
|
||||
} else false
|
||||
}.padding(12.dp))
|
||||
.onPreviewKeyEvent { event -> textFieldKeys(event.nativeKeyEvent, keyboard, focus, below = passwordFocus) }.padding(12.dp))
|
||||
Text("Password", color = Muted, fontSize = 14.sp)
|
||||
var passwordFocused by remember { mutableStateOf(false) }
|
||||
BasicSecureTextField(state = password, enabled = !busy && !restoring,
|
||||
textObfuscationMode = TextObfuscationMode.Hidden,
|
||||
inputTransformation = InputTransformation.maxLength(1024),
|
||||
textStyle = TextStyle(color = Ink, fontSize = 18.sp), cursorBrush = SolidColor(Yellow),
|
||||
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Password, imeAction = ImeAction.Done),
|
||||
onKeyboardAction = { keyboard?.hide(); if (ready) submitFocus.requestFocus() else focus.clearFocus() },
|
||||
modifier = Modifier.fillMaxWidth().focusRequester(passwordFocus)
|
||||
.onFocusChanged { passwordFocused = it.isFocused }
|
||||
.background(Panel).border(2.dp, if (passwordFocused) Yellow else Blue)
|
||||
.onPreviewKeyEvent { event ->
|
||||
if (event.nativeKeyEvent.keyCode == KeyEvent.KEYCODE_DPAD_CENTER) {
|
||||
if (event.nativeKeyEvent.action == KeyEvent.ACTION_UP) keyboard?.show()
|
||||
true
|
||||
} else false
|
||||
}.padding(12.dp))
|
||||
// Android's own password box (0.129): Compose's gave accessibility the password itself. See PasswordField.
|
||||
PasswordField(password, enabled = !busy && !restoring, focusRequester = passwordFocus,
|
||||
onDone = { keyboard?.hide(); if (ready) submitFocus.requestFocus() else focus.clearFocus() }, modifier = Modifier.fillMaxWidth())
|
||||
OrbitButton(if (busy) "Signing in…" else if (waiting) "Wait before trying again" else "Sign in",
|
||||
Modifier.fillMaxWidth().focusRequester(submitFocus), enabled = ready, onClick = onSignIn)
|
||||
message?.let { Text(it, color = Yellow, fontSize = 14.sp, maxLines = 4) }
|
||||
@@ -1090,3 +1067,16 @@ private fun SignInForm(modifier: Modifier, serverText: String, onServer: (String
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The remote in a text box (0.129): OK opens the keyboard; Up and Down move to the box or button above or below, as they do
|
||||
* everywhere else (a text box kept them for itself, so an empty address box couldn't be left with Down).
|
||||
*/
|
||||
internal fun textFieldKeys(e: KeyEvent, keyboard: androidx.compose.ui.platform.SoftwareKeyboardController?, focus: androidx.compose.ui.focus.FocusManager,
|
||||
/** The box below, when it's Android's own (the password): moving by direction doesn't reach into one. */
|
||||
below: FocusRequester? = null): Boolean = when (e.keyCode) {
|
||||
KeyEvent.KEYCODE_DPAD_CENTER -> { if (e.action == KeyEvent.ACTION_UP) keyboard?.show(); true }
|
||||
KeyEvent.KEYCODE_DPAD_DOWN -> { if (e.action == KeyEvent.ACTION_DOWN) { if (below == null || !runCatching { below.requestFocus() }.getOrDefault(false)) focus.moveFocus(androidx.compose.ui.focus.FocusDirection.Down) }; true }
|
||||
KeyEvent.KEYCODE_DPAD_UP -> { if (e.action == KeyEvent.ACTION_DOWN) focus.moveFocus(androidx.compose.ui.focus.FocusDirection.Up); true }
|
||||
else -> false
|
||||
}
|
||||
|
||||
@@ -120,7 +120,9 @@ 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(audioPreference?.value ?: "en").build()
|
||||
// Until Orbit has chosen (below), only a track the programme marks as forced may show: never one the file merely
|
||||
// marks as default, which is how subtitles appeared with the setting off (0.129).
|
||||
trackSelectionParameters = forcedSubtitlesOnly(trackSelectionParameters.buildUpon().setPreferredAudioLanguage(audioPreference?.value ?: "en")).build()
|
||||
OrbitTiming.tune(scheduled?.channel?.number)
|
||||
if (OrbitTiming.on) addAnalyticsListener(object : androidx.media3.exoplayer.analytics.AnalyticsListener {
|
||||
@androidx.annotation.OptIn(androidx.media3.common.util.UnstableApi::class)
|
||||
@@ -137,10 +139,19 @@ internal fun EmbyPlaybackDialog(session: EmbySampleSession, plan: EmbyPlaybackPl
|
||||
fun audioLanguages() = player.currentTracks.groups.filter { it.type == C.TRACK_TYPE_AUDIO }.map { it.getTrackFormat(0).language.orEmpty() }
|
||||
fun chooseSubtitle(index: Int?, tracks: List<Tracks.Group>) {
|
||||
subtitleIndex = index
|
||||
val builder = player.trackSelectionParameters.buildUpon().clearOverridesOfType(C.TRACK_TYPE_TEXT).setTrackTypeDisabled(C.TRACK_TYPE_TEXT, index == null)
|
||||
if (index != null) builder.addOverride(TrackSelectionOverride(tracks[index].mediaTrackGroup, 0))
|
||||
// None chosen is Off's rule, not "no subtitles at all": a forced track (foreign dialogue, signs) still shows.
|
||||
val builder = player.trackSelectionParameters.buildUpon().clearOverridesOfType(C.TRACK_TYPE_TEXT).setTrackTypeDisabled(C.TRACK_TYPE_TEXT, false)
|
||||
if (index != null) builder.addOverride(TrackSelectionOverride(tracks[index].mediaTrackGroup, 0)) else forcedSubtitlesOnly(builder)
|
||||
player.trackSelectionParameters = builder.build()
|
||||
}
|
||||
// The listeners below are made once per player: they read the setting as it is now, not as it was when they were made
|
||||
// (a change from Off to On, then a new set of tracks, put the old choice back).
|
||||
val latestSubtitles by rememberUpdatedState(subtitlePreference)
|
||||
// The setting changed while this programme plays (on the TV or from the phone): it applies straight away (0.129).
|
||||
LaunchedEffect(subtitlePreference) {
|
||||
val available = textTracks()
|
||||
if (available.isNotEmpty()) chooseSubtitle(subtitleChoice(subtitlePreference?.value, audioLanguages(), available.map { it.getTrackFormat(0).language.orEmpty() }), available)
|
||||
}
|
||||
fun chooseAudio(group: Tracks.Group) {
|
||||
player.trackSelectionParameters = player.trackSelectionParameters.buildUpon().clearOverridesOfType(C.TRACK_TYPE_AUDIO)
|
||||
.addOverride(TrackSelectionOverride(group.mediaTrackGroup, 0)).build()
|
||||
@@ -208,7 +219,7 @@ internal fun EmbyPlaybackDialog(session: EmbySampleSession, plan: EmbyPlaybackPl
|
||||
// Its tracks were found before this listener arrived, so the subtitle choice is made here.
|
||||
if (runningPlayer != null && subtitleIndex == null) {
|
||||
val available = textTracks()
|
||||
subtitleChoice(subtitlePreference?.value, audioLanguages(), available.map { it.getTrackFormat(0).language.orEmpty() })?.let { chooseSubtitle(it, available) }
|
||||
subtitleChoice(latestSubtitles?.value, audioLanguages(), available.map { it.getTrackFormat(0).language.orEmpty() }).let { chooseSubtitle(it, available) }
|
||||
}
|
||||
playing = player.isPlaying
|
||||
val listener = object : Player.Listener {
|
||||
@@ -283,7 +294,7 @@ internal fun EmbyPlaybackDialog(session: EmbySampleSession, plan: EmbyPlaybackPl
|
||||
}
|
||||
if (subtitleIndex == null) {
|
||||
val available = textTracks()
|
||||
subtitleChoice(subtitlePreference?.value, audioLanguages(), available.map { it.getTrackFormat(0).language.orEmpty() })?.let { chooseSubtitle(it, available) }
|
||||
subtitleChoice(latestSubtitles?.value, audioLanguages(), available.map { it.getTrackFormat(0).language.orEmpty() }).let { chooseSubtitle(it, available) }
|
||||
}
|
||||
}
|
||||
override fun onPositionDiscontinuity(oldPosition: Player.PositionInfo, newPosition: Player.PositionInfo, reason: Int) {
|
||||
@@ -611,3 +622,12 @@ internal fun EmbyPlaybackDialog(session: EmbySampleSession, plan: EmbyPlaybackPl
|
||||
if (window != null) content() else Dialog(onDismissRequest = dismiss, properties = DialogProperties(usePlatformDefaultWidth = false,
|
||||
decorFitsSystemWindows = false, securePolicy = SecureFlagPolicy.SecureOn)) { content() }
|
||||
}
|
||||
|
||||
/**
|
||||
* Off's rule for the player (0.129): no ordinary subtitle track, only one the programme marks as forced. Media3 would otherwise
|
||||
* pick a track the file marks as default, or follow the TV's own caption setting; neither is asked for here.
|
||||
*/
|
||||
@androidx.annotation.OptIn(androidx.media3.common.util.UnstableApi::class)
|
||||
internal fun forcedSubtitlesOnly(builder: androidx.media3.common.TrackSelectionParameters.Builder): androidx.media3.common.TrackSelectionParameters.Builder =
|
||||
builder.setPreferredTextLanguages().setPreferredTextRoleFlags(0).setSelectUndeterminedTextLanguage(false)
|
||||
.setIgnoredTextSelectionFlags(C.SELECTION_FLAG_DEFAULT)
|
||||
|
||||
@@ -100,6 +100,7 @@ class MainActivity : ComponentActivity() {
|
||||
RoomLinks.load(this)
|
||||
// The chosen look, before the first frame, so a light look never flashes navy.
|
||||
OrbitTheme.load(this)
|
||||
Subtitles.load(OrbitSettings(this))
|
||||
window.setBackgroundDrawable(android.graphics.drawable.ColorDrawable(Navy.toArgb()))
|
||||
// One typeface everywhere, matching the channel logos.
|
||||
setContent { MaterialTheme { CompositionLocalProvider(androidx.tv.material3.LocalTextStyle provides androidx.compose.ui.text.TextStyle(fontFamily = Barlow)) { OrbitApp() } } }
|
||||
@@ -229,7 +230,10 @@ private fun OrbitApp() {
|
||||
if (!restoreChecked && slowStart) MomentClip(Moment.Tuning, loop = true)
|
||||
// The sections sit centred on the screen, over the centred page below; the logo keeps the left, the clock the right.
|
||||
if (picking && !chosen) WhosWatching(onClose = { activity?.finish() })
|
||||
else if (picking) WhosWatching(onClose = { WatchCheck.pending = false }, initial = profile, onChosen = { WatchCheck.pending = false })
|
||||
// Back (0.129, Paul): as Orbit opens, it leaves to the TV's home screen and nobody is chosen; from inside Orbit it goes
|
||||
// back and keeps who's watching.
|
||||
else if (picking) WhosWatching(onClose = { if (WatchCheck.atStart) activity?.finish() else WatchCheck.pending = false }, initial = profile,
|
||||
onChosen = { WatchCheck.pending = false; WatchCheck.atStart = false })
|
||||
// At the end of the flow the one who set Orbit up starts watching as Adult; the tour goes back to Settings.
|
||||
if (onboarding) OnboardingScreen(signedIn = realChannelAvailable) { tour ->
|
||||
if (!tour) { section = if (realChannelAvailable) "Home" else "Connect Emby"; Profiles.current = Profiles.all.first { it.kind == ProfileKind.Grown } }
|
||||
@@ -251,7 +255,7 @@ private fun OrbitApp() {
|
||||
Spacer(Modifier.weight(1f))
|
||||
TopBarClock()
|
||||
// Who's watching, as a little picture: OK goes back to Who's watching? to switch.
|
||||
if (realChannelAvailable && profile != null) HomeCard(Modifier.size(38.dp, 32.dp).focusProperties { if (section == "Drive-In") down = driveInFocus }, onClick = { section = "Home"; Profiles.current = null }) { focused ->
|
||||
if (realChannelAvailable && profile != null) HomeCard(Modifier.size(38.dp, 32.dp).focusProperties { if (section == "Drive-In") down = driveInFocus }, onClick = { WatchCheck.askFromInside() }) { focused ->
|
||||
Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) { ProfileAvatar(profile.picture, 28.dp, ringed = false) }
|
||||
}
|
||||
if (realChannelAvailable && !Profiles.kids) HomeCard(Modifier.size(38.dp, 32.dp).focusProperties { if (section == "Drive-In") down = driveInFocus }, onClick = { section = "Connect Emby" }) { focused ->
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package tv.orbit.classic
|
||||
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.BoxScope
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.window.Dialog
|
||||
import androidx.compose.ui.window.DialogProperties
|
||||
import androidx.compose.ui.window.SecureFlagPolicy
|
||||
|
||||
/**
|
||||
* A screen that must be answered before anything else (0.129, Paul, 10 November 2026): Who's watching, the PIN, the restore
|
||||
* preview. It is its own window over everything, the programme playing full screen included, so:
|
||||
* - nothing behind it can take the remote, a click or TalkBack's focus, because Android gives keys and accessibility to the top
|
||||
* window only;
|
||||
* - what's behind is covered by [scrim] (fully, by default), so it can't be mistaken for part of the question;
|
||||
* - Back does [onBack] and nothing else: the screen decides what Back means (cancel, go back, or leave Orbit at start-up);
|
||||
* - the screen inside sets where focus starts, as each already does with its own FocusRequester.
|
||||
* [secure] keeps it out of screenshots and screen recording, for a code or a PIN.
|
||||
*/
|
||||
@Composable
|
||||
internal fun OrbitModal(onBack: () -> Unit, scrim: Color = Navy, secure: Boolean = false, content: @Composable BoxScope.() -> Unit) {
|
||||
Dialog(onDismissRequest = onBack, properties = DialogProperties(usePlatformDefaultWidth = false, dismissOnClickOutside = false,
|
||||
decorFitsSystemWindows = false, securePolicy = if (secure) SecureFlagPolicy.SecureOn else SecureFlagPolicy.Inherit)) {
|
||||
BackHandler(onBack = onBack)
|
||||
Box(Modifier.fillMaxSize().background(scrim), contentAlignment = Alignment.Center, content = content)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package tv.orbit.classic
|
||||
|
||||
import android.text.InputFilter
|
||||
import android.text.InputType
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import android.widget.EditText
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.text.input.TextFieldState
|
||||
import androidx.compose.foundation.text.input.setTextAndPlaceCursorAtEnd
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.focus.FocusRequester
|
||||
import androidx.compose.ui.focus.focusRequester
|
||||
import androidx.compose.ui.focus.onFocusChanged
|
||||
import androidx.compose.ui.graphics.toArgb
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.viewinterop.AndroidView
|
||||
import androidx.core.widget.doAfterTextChanged
|
||||
|
||||
/**
|
||||
* The sign-in password, typed into Android's own password field (0.129, Paul's release blocker of 10 November 2026). Compose's
|
||||
* secure field showed dots on screen but handed accessibility services the password itself, so TalkBack read it aloud each time
|
||||
* the field was focused (with its "Speak passwords" setting on, the default on Android TV) and any accessibility app could read
|
||||
* it. Android's own field gives them dots, exactly as every other password box on the TV does, and still says "password" and
|
||||
* how many characters. The typed text is kept in [state] as before, so signing in is unchanged; clearing [state] clears the box.
|
||||
*/
|
||||
@Composable
|
||||
internal fun PasswordField(state: TextFieldState, enabled: Boolean, focusRequester: FocusRequester, onDone: () -> Unit, modifier: Modifier = Modifier) {
|
||||
var focused by remember { mutableStateOf(false) }
|
||||
// The box is made once, so it reads the latest action when Done is pressed.
|
||||
val done by androidx.compose.runtime.rememberUpdatedState(onDone)
|
||||
val focusManager = androidx.compose.ui.platform.LocalFocusManager.current
|
||||
val ink = Ink.toArgb(); val muted = Muted.toArgb()
|
||||
AndroidView(
|
||||
factory = { context ->
|
||||
EditText(context).apply {
|
||||
// Single line first: setting it afterwards swaps the password's dots for plain text (found on the emulator).
|
||||
isSingleLine = true
|
||||
inputType = InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_VARIATION_PASSWORD
|
||||
transformationMethod = android.text.method.PasswordTransformationMethod.getInstance()
|
||||
// A password box switches to a typewriter font; Orbit's own reads better on a TV.
|
||||
typeface = android.graphics.Typeface.DEFAULT
|
||||
imeOptions = EditorInfo.IME_ACTION_DONE or EditorInfo.IME_FLAG_NO_EXTRACT_UI
|
||||
filters = arrayOf(InputFilter.LengthFilter(1024))
|
||||
background = null
|
||||
textSize = 18f
|
||||
// What TalkBack calls the box while it's empty; once typed in, it says "password" and the count, never the words.
|
||||
hint = "Password"
|
||||
doAfterTextChanged { typed -> val now = typed?.toString().orEmpty(); if (now != state.text.toString()) state.setTextAndPlaceCursorAtEnd(now) }
|
||||
setOnEditorActionListener { _, action, _ -> if (action == EditorInfo.IME_ACTION_DONE) { done(); true } else false }
|
||||
// Up leaves the box for the username above, as Down already leaves it for Sign in.
|
||||
setOnKeyListener { _, code, event ->
|
||||
if (code == android.view.KeyEvent.KEYCODE_DPAD_UP && event.action == android.view.KeyEvent.ACTION_DOWN) focusManager.moveFocus(androidx.compose.ui.focus.FocusDirection.Up)
|
||||
else false
|
||||
}
|
||||
}
|
||||
},
|
||||
update = { box ->
|
||||
box.isEnabled = enabled
|
||||
box.setTextColor(ink); box.setHintTextColor(muted)
|
||||
// Cleared by Orbit (signed in, or left): the box empties too.
|
||||
if (state.text.isEmpty() && box.text.isNotEmpty()) box.setText("")
|
||||
},
|
||||
modifier = modifier.focusRequester(focusRequester).onFocusChanged { focused = it.hasFocus }
|
||||
.background(Panel).border(2.dp, if (focused) Yellow else Blue).padding(horizontal = 6.dp, vertical = 2.dp))
|
||||
}
|
||||
@@ -517,7 +517,7 @@ internal object PhoneLink {
|
||||
"POST /api/channel", "POST /api/tune", "POST /api/remind", "POST /api/follow", "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")
|
||||
"POST /api/profile/add", "POST /api/profile/rename", "POST /api/profile/remove", "POST /api/subtitles")
|
||||
/** The Companion's remote, guide, Catch Up and rooms (see [OrbitCompanion]); false when [r] is for Create your own. */
|
||||
private fun companion(r: Request, out: OutputStream): Boolean {
|
||||
if ("${r.method} ${r.path}" !in companionRoutes) return false
|
||||
@@ -529,7 +529,15 @@ 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).put("reminder", OrbitCompanion.reminderNow ?: org.json.JSONObject.NULL))
|
||||
"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)
|
||||
// The same subtitles setting the TV shows (0.129): Off, On or Automatic, with what it means.
|
||||
.put("subtitles", JSONObject().put("mode", Subtitles.mode.name).put("line", Subtitles.mode.line)))
|
||||
"POST /api/subtitles" -> {
|
||||
val to = SubtitleMode.entries.firstOrNull { it.name == body().optString("mode") } ?: return json(out, 400, JSONObject().put("error", "Off, On or Automatic"))
|
||||
val ctx = appContext ?: return json(out, 409, JSONObject().put("error", "Orbit is starting up on the TV."))
|
||||
onScreen { Subtitles.set(OrbitSettings(ctx), to) }
|
||||
json(out, 200, JSONObject().put("mode", to.name).put("line", to.line))
|
||||
}
|
||||
"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))
|
||||
|
||||
@@ -17,6 +17,8 @@ import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.semantics.heading
|
||||
import androidx.compose.ui.semantics.semantics
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.focus.FocusRequester
|
||||
import androidx.compose.ui.focus.focusRequester
|
||||
@@ -227,24 +229,32 @@ internal fun StarrySky(modifier: Modifier = Modifier) {
|
||||
/**
|
||||
* Asking again (Paul, 9 November 2026), so Taste learns from the right person: when Orbit comes back after 10 minutes or
|
||||
* more away, and on the first button press after 2 hours without one (whoever picks up the remote). Whoever was watching
|
||||
* is already highlighted: OK, Back, or 5 seconds with no button carries on as them. Only while Orbit asks at all
|
||||
* is already highlighted: OK or Back carries on as them. Nobody is chosen by waiting (0.129, Paul: no silent carry-on; an
|
||||
* automatic choice would be its own, explained opt-in that respects the PIN). Only while Orbit asks at all
|
||||
* ([Profiles.asks]). A full-screen programme isn't interrupted: the press is seen when the guide or Home has it.
|
||||
*/
|
||||
internal object WatchCheck {
|
||||
var pending by mutableStateOf(false)
|
||||
/**
|
||||
* Asked as Orbit opens (or comes back after a while away), rather than from inside it (0.129, Paul): Back then leaves to
|
||||
* the TV's home screen instead of carrying on as anyone. From inside Orbit (the profile picture, or after two idle hours)
|
||||
* Back goes back and keeps who's watching.
|
||||
*/
|
||||
var atStart = false
|
||||
/** The release of the press that only asked, so it does nothing either. */
|
||||
var swallowUp = false
|
||||
private var lastKeyMs = android.os.SystemClock.elapsedRealtime()
|
||||
private var stoppedMs: Long? = null
|
||||
const val IDLE_MS = 2 * 60 * 60_000L
|
||||
const val AWAY_MS = 10 * 60_000L
|
||||
const val CARRY_ON_MS = 5_000L
|
||||
fun started(nowMs: Long = android.os.SystemClock.elapsedRealtime()) { if (stoppedMs.let { it == null || nowMs - it >= AWAY_MS }) pending = true; lastKeyMs = nowMs }
|
||||
fun started(nowMs: Long = android.os.SystemClock.elapsedRealtime()) { if (stoppedMs.let { it == null || nowMs - it >= AWAY_MS }) { pending = true; atStart = true }; lastKeyMs = nowMs }
|
||||
/** Who's watching? asked from inside Orbit (the profile picture): the current profile stays until someone is chosen. */
|
||||
fun askFromInside() { pending = true; atStart = false }
|
||||
fun stopped(nowMs: Long = android.os.SystemClock.elapsedRealtime()) { stoppedMs = nowMs }
|
||||
/** A button press; true when it comes after the idle gap, so it only brings up the question. */
|
||||
fun key(nowMs: Long = android.os.SystemClock.elapsedRealtime()): Boolean {
|
||||
val idle = nowMs - lastKeyMs >= IDLE_MS; lastKeyMs = nowMs
|
||||
if (idle && Profiles.asks && Profiles.current != null) { pending = true; return true }
|
||||
if (idle && Profiles.asks && Profiles.current != null) { pending = true; atStart = false; return true }
|
||||
return false
|
||||
}
|
||||
}
|
||||
@@ -258,19 +268,22 @@ internal fun WhosWatching(onClose: () -> Unit, initial: Profile? = null, onChose
|
||||
val first = remember { FocusRequester() }
|
||||
val ordered = Profiles.all.sortedBy { if (it.kind == ProfileKind.Kids) 0 else 1 }
|
||||
val firstIndex = ordered.indexOfFirst { it.id == initial?.id }.coerceAtLeast(0)
|
||||
var touched by remember { mutableStateOf(false) }
|
||||
LaunchedEffect(asking) { if (asking == null) runCatching { first.requestFocus() } }
|
||||
// Asking again carries on as whoever was watching when nobody answers.
|
||||
LaunchedEffect(touched, asking) { if (initial != null && !touched && asking == null) { kotlinx.coroutines.delay(WatchCheck.CARRY_ON_MS); onClose() } }
|
||||
BackHandler(asking == null, onBack = onClose)
|
||||
// Its window may still be opening: keep asking until the starting profile has the remote.
|
||||
LaunchedEffect(asking) { if (asking == null) repeat(40) { if (runCatching { first.requestFocus() }.getOrDefault(false)) return@LaunchedEffect; kotlinx.coroutines.delay(50) } }
|
||||
// Nobody is chosen without being asked (Paul, 10 November 2026): the five-second carry-on is gone. Back is the screen's
|
||||
// own: [onClose] leaves Orbit at start-up, or goes back keeping who's watching when asked from inside Orbit.
|
||||
fun choose(p: Profile) {
|
||||
if (p.kind == ProfileKind.Grown && p.id != initial?.id && AfterDarkLock.pinSet && !AfterDarkLock.unlocked) { asking = p; problem = null }
|
||||
else { if (p.kind == ProfileKind.Kids) AfterDarkLock.lock(); Profiles.current = p; onChosen() }
|
||||
}
|
||||
Box(Modifier.fillMaxSize().onPreviewKeyEvent { touched = true; false }) {
|
||||
// Its own window over everything, the screen behind fully covered (0.129): nothing behind can take the remote.
|
||||
OrbitModal(onBack = { if (asking != null) asking = null else onClose() }) {
|
||||
StarrySky()
|
||||
Box(Modifier.fillMaxSize()) {
|
||||
Column(Modifier.align(Alignment.Center), horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.spacedBy(28.dp)) {
|
||||
Image(cachedPainter(R.drawable.orbit_logo), "Orbit", Modifier.logoPlate().width(150.dp).height(38.dp))
|
||||
Text("Who's watching?", color = Ink, fontFamily = Anton, fontSize = 40.sp)
|
||||
// The logo is decoration here (0.129): TalkBack starts on the question and the profiles, not on a picture.
|
||||
Image(cachedPainter(R.drawable.orbit_logo), null, Modifier.logoPlate().width(150.dp).height(38.dp))
|
||||
Text("Who's watching?", Modifier.semantics { heading() }, color = Ink, fontFamily = Anton, fontSize = 40.sp)
|
||||
// Room for the whole family (Family v2): smaller and closer as more join.
|
||||
val many = Profiles.all.size > 4
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(if (many) 28.dp else 56.dp)) {
|
||||
@@ -294,7 +307,8 @@ internal fun WhosWatching(onClose: () -> Unit, initial: Profile? = null, onChose
|
||||
}
|
||||
}
|
||||
}
|
||||
if (initial != null && !touched) Text("Carrying on as ${initial.name} in a moment. OK to confirm, or choose someone else.", color = Muted, fontSize = 15.sp)
|
||||
if (initial != null && !WatchCheck.atStart) Text("Watching as ${initial.name}. OK on someone to switch, or Back to carry on.", color = Muted, fontSize = 15.sp)
|
||||
else if (initial != null) Text("Last watching: ${initial.name}. OK to carry on as them or choose someone else. Back leaves Orbit.", color = Muted, fontSize = 15.sp)
|
||||
else Text("Kids sees only the channels and games chosen for it." + if (AfterDarkLock.pinSet) " Adult needs the PIN." else " Set a PIN in Settings › Family to keep Adult for grown-ups.",
|
||||
color = Muted, fontSize = 15.sp)
|
||||
}
|
||||
@@ -310,5 +324,6 @@ internal fun WhosWatching(onClose: () -> Unit, initial: Profile? = null, onChose
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,9 @@ internal fun ScheduledChannelPlayer(session: EmbySampleSession, channel: SampleC
|
||||
onShift: (Long) -> Unit = {}, onLive: () -> Unit = {}) {
|
||||
// Outlives each programme and channel, and ends when the viewer leaves full screen.
|
||||
val settingsContext = androidx.compose.ui.platform.LocalContext.current
|
||||
val subtitlePreference = remember { mutableStateOf(if (OrbitSettings(settingsContext).subtitlesOn) SUBTITLES_BY_DEFAULT else null) }
|
||||
// From the setting (Off, On or Automatic); a change in Settings or from the phone applies straight away (the player
|
||||
// chooses again when this changes).
|
||||
val subtitlePreference = remember(Subtitles.mode) { mutableStateOf<String?>(Subtitles.mode.preference) }
|
||||
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) } }
|
||||
|
||||
@@ -19,6 +19,10 @@ import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.semantics.contentDescription
|
||||
import androidx.compose.ui.focus.focusProperties
|
||||
import androidx.compose.foundation.focusable
|
||||
import androidx.compose.foundation.focusGroup
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.focus.FocusRequester
|
||||
import androidx.compose.ui.focus.focusRequester
|
||||
@@ -82,9 +86,10 @@ internal class OrbitSettings(context: Context) {
|
||||
var recentGames: List<String>
|
||||
get() = saved.getString("recent_games", "").orEmpty().split(',').filter { it.isNotBlank() }
|
||||
set(value) { saved.edit().putString("recent_games", value.joinToString(",")).apply() }
|
||||
var subtitlesOn: Boolean
|
||||
get() = saved.getBoolean("subtitles_on", false)
|
||||
set(value) { saved.edit().putBoolean("subtitles_on", value).apply() }
|
||||
/** Off, On or Automatic (0.129); from the old on/off switch until first chosen. See [SubtitleMode]. */
|
||||
var subtitleMode: SubtitleMode
|
||||
get() = SubtitleMode.from(saved.getString("subtitle_mode", null), saved.getBoolean("subtitles_on", false))
|
||||
set(value) { saved.edit().putString("subtitle_mode", value.name).apply() }
|
||||
var channelLogo: Boolean
|
||||
get() = saved.getBoolean("channel_logo", true)
|
||||
set(value) { saved.edit().putBoolean("channel_logo", value).apply() }
|
||||
@@ -268,7 +273,6 @@ private fun ChannelsDetail(busy: Boolean, message: String?, isOn: (Int) -> Boole
|
||||
private fun ViewingDetail(firstSwitch: FocusRequester, modifier: Modifier, top: @Composable () -> Unit = {}) {
|
||||
val context = LocalContext.current
|
||||
val settings = remember { OrbitSettings(context) }
|
||||
var subtitlesOn by remember { mutableStateOf(settings.subtitlesOn) }
|
||||
var channelLogo by remember { mutableStateOf(settings.channelLogo) }
|
||||
var idents by remember { mutableStateOf(settings.idents) }
|
||||
var identSound by remember { mutableStateOf(settings.identSound) }
|
||||
@@ -286,8 +290,11 @@ private fun ViewingDetail(firstSwitch: FocusRequester, modifier: Modifier, top:
|
||||
Column(modifier.verticalScroll(rememberScrollState()), verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
top()
|
||||
Heading("Watching")
|
||||
SettingLine("Subtitles", "Turn on English subtitles whenever you tune in, if the programme has them. You can still change them while watching, by pressing right.") {
|
||||
OnOff(subtitlesOn, Modifier, onClick = { subtitlesOn = !subtitlesOn; settings.subtitlesOn = subtitlesOn })
|
||||
// Off, On or Automatic (0.129): each says what it does; the choice applies from the next programme.
|
||||
SettingLine("Subtitles: ${Subtitles.mode.title}", Subtitles.mode.line + " Press right while watching to change them for one programme.") {
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(6.dp)) {
|
||||
SubtitleMode.entries.forEach { m -> OrbitButton(m.title, selected = Subtitles.mode == m, onClick = { Subtitles.set(settings, m) }) }
|
||||
}
|
||||
}
|
||||
SettingLine("Channel logo", "Show the channel's small logo in the corner during programmes.") {
|
||||
OnOff(channelLogo, Modifier, onClick = { channelLogo = !channelLogo; settings.channelLogo = channelLogo })
|
||||
@@ -396,7 +403,11 @@ private fun RoomsDetail(firstSwitch: FocusRequester, modifier: Modifier,
|
||||
if (AfterDarkLock.check(context, pin)) { undoPin = false; undoScope.launch { (context as? android.app.Activity)?.let { PhoneBackups.undo(it) } } } else undoProblem = AfterDarkLock.refusal(context, "That PIN didn't match.")
|
||||
}, onCancel = { undoPin = false }); return }
|
||||
var brought by remember { mutableStateOf<String?>(null) }
|
||||
if (adding) { AddRoomPanel(onClose = { adding = false }, modifier = modifier); return }
|
||||
// The button that opened a page here gets the remote back when it closes (0.129).
|
||||
val addButton = remember { FocusRequester() }; val connectButton = remember { FocusRequester() }
|
||||
var returnTo by remember { mutableStateOf<FocusRequester?>(null) }
|
||||
LaunchedEffect(adding, connecting, bringing) { if (!adding && !connecting && !bringing) returnTo?.let { r -> repeat(20) { if (runCatching { r.requestFocus() }.getOrDefault(false)) { returnTo = null; return@LaunchedEffect }; kotlinx.coroutines.delay(50) } } }
|
||||
if (adding) { SettingsSubPage(null, null, modifier) { AddRoomPanel(onClose = { park(); adding = false }, modifier = Modifier.fillMaxSize()) }; return }
|
||||
// Rooms sync (Paul, 7 November 2026): a TV already set up can bring in another room's family, Taste and Continue watching.
|
||||
// What's ticked is merged: people join, events join by id, nothing here is overwritten, and no schedule or channel changes.
|
||||
if (bringing) {
|
||||
@@ -415,14 +426,15 @@ private fun RoomsDetail(firstSwitch: FocusRequester, modifier: Modifier,
|
||||
}
|
||||
if (connecting) {
|
||||
// Orbit Companion (Paul, 6 November 2026): the same one-time code as Create your own's, from where phones are listed.
|
||||
BackHandler { connecting = false }
|
||||
Column(modifier, verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
SettingsSubPage(null, { park(); connecting = false }, modifier) {
|
||||
Column(Modifier.fillMaxSize(), verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
PhoneCard(Modifier.width(460.dp), "Connect a phone")
|
||||
Text("Your phone becomes a remote for this TV: what's on, the guide, Catch Up and your rooms, in this TV's colours.", color = Muted, fontSize = 13.sp)
|
||||
val done = remember { FocusRequester() }
|
||||
LaunchedEffect(Unit) { runCatching { done.requestFocus() } }
|
||||
OrbitButton("Done", Modifier.focusRequester(done), onClick = { connecting = false })
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
Column(modifier.verticalScroll(rememberScrollState()), verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
@@ -438,7 +450,7 @@ private fun RoomsDetail(firstSwitch: FocusRequester, modifier: Modifier,
|
||||
OrbitButton("Bring in", onClick = { park(); bringing = true })
|
||||
}
|
||||
SettingLine("Add a room", "Set up Orbit on another TV in your home by copying this one: channels, profiles, look and more. Your password never travels.") {
|
||||
OrbitButton("Add a room", onClick = { park(); adding = true })
|
||||
OrbitButton("Add a room", Modifier.focusRequester(addButton), onClick = { park(); returnTo = addButton; adding = true })
|
||||
}
|
||||
// Rooms sync (7 November 2026): each paired room, when it last synced, and a switch to stop.
|
||||
RoomLinks.links.forEach { link ->
|
||||
@@ -453,7 +465,7 @@ private fun RoomsDetail(firstSwitch: FocusRequester, modifier: Modifier,
|
||||
}
|
||||
Heading("Phones")
|
||||
SettingLine("Connect a phone", "Orbit Companion: your phone as a remote, with the guide, Catch Up and rooms. No app to install, just scan a code.") {
|
||||
OrbitButton("Connect", onClick = { park(); connecting = true })
|
||||
OrbitButton("Connect", Modifier.focusRequester(connectButton), onClick = { park(); returnTo = connectButton; connecting = true })
|
||||
}
|
||||
PhoneLink.phones.forEachIndexed { i, (id, name) -> SettingLine(name, "A remote for this TV, and can make and edit your channels.") {
|
||||
OrbitButton("Remove", if (i == 0) Modifier.focusRequester(firstSwitch) else Modifier, onClick = { PhoneLink.forget(id) }) } }
|
||||
@@ -541,6 +553,10 @@ internal fun SettingsScreen(section: SettingsSection, onSection: (SettingsSectio
|
||||
val channelList = rememberLazyListState()
|
||||
val scope = rememberCoroutineScope()
|
||||
LaunchedEffect(Unit) { firstFocus.requestFocus() }
|
||||
// The card that opened a page in place of the list gets the remote back when the page closes (0.129).
|
||||
val createCard = remember { FocusRequester() }; val chairCard = remember { FocusRequester() }; val arrivalsCard = remember { FocusRequester() }
|
||||
var returnTo by remember { mutableStateOf<FocusRequester?>(null) }
|
||||
LaunchedEffect(opened, making) { if (opened == null && making == null) returnTo?.let { r -> repeat(20) { if (runCatching { r.requestFocus() }.getOrDefault(false)) { returnTo = null; return@LaunchedEffect }; kotlinx.coroutines.delay(50) } } }
|
||||
Column(modifier.fillMaxWidth(), verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
Text("Settings", color = Ink, fontSize = 22.sp, fontWeight = FontWeight.SemiBold)
|
||||
Row(Modifier.fillMaxWidth().weight(1f), horizontalArrangement = Arrangement.spacedBy(14.dp)) {
|
||||
@@ -555,16 +571,19 @@ internal fun SettingsScreen(section: SettingsSection, onSection: (SettingsSectio
|
||||
val detail = Modifier.weight(1f).fillMaxHeight()
|
||||
when (section) {
|
||||
SettingsSection.Channels -> when {
|
||||
making != null && maker != null -> making?.let { (_, editing) -> CreateChannelFlow(maker, editing, { result -> made = result; making = null }, detail) }
|
||||
// Director's Chair and New arrivals open in place of the list; Back returns to it.
|
||||
opened == ChannelPage.Director -> { BackHandler { opened = null }; director(detail, firstSwitch) }
|
||||
opened == ChannelPage.Arrivals -> { BackHandler { opened = null }; arrivals(detail, firstSwitch) }
|
||||
making != null && maker != null -> making?.let { (_, editing) -> SettingsSubPage(null, null, detail) {
|
||||
CreateChannelFlow(maker, editing, { result -> made = result; making = null }, Modifier.fillMaxSize()) } }
|
||||
// Director's Chair and New arrivals open in place of the list; Back returns to it, onto the card that opened it.
|
||||
// Back parks the remote on this section's own item in the list before the page goes (with TalkBack on, the
|
||||
// page vanishing under the remote let Android hand it to Home in the top bar); then the card gets it back.
|
||||
opened == ChannelPage.Director -> SettingsSubPage(firstSwitch, { runCatching { firstFocus.requestFocus() }; opened = null }, detail) { director(Modifier.fillMaxSize(), firstSwitch) }
|
||||
opened == ChannelPage.Arrivals -> SettingsSubPage(firstSwitch, { runCatching { firstFocus.requestFocus() }; opened = null }, detail) { arrivals(Modifier.fillMaxSize(), firstSwitch) }
|
||||
else -> Column(detail, verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
val card = Modifier.weight(1f).height(72.dp)
|
||||
if (maker != null) ChannelCard("Create your own", "Your own channel, on this TV or your phone", "ollie", card.focusRequester(firstSwitch)) { made = null; making = true to null }
|
||||
ChannelCard("Director's Chair", "Suggestions for your channels, and events", "luna", if (maker == null) card.focusRequester(firstSwitch) else card) { opened = ChannelPage.Director }
|
||||
ChannelCard("New in your library", "What's arrived, and where it went", "drift", card) { opened = ChannelPage.Arrivals }
|
||||
if (maker != null) ChannelCard("Create your own", "Your own channel, on this TV or your phone", "ollie", card.focusRequester(firstSwitch).focusRequester(createCard)) { made = null; returnTo = createCard; making = true to null }
|
||||
ChannelCard("Director's Chair", "Suggestions for your channels, and events", "luna", (if (maker == null) card.focusRequester(firstSwitch) else card).focusRequester(chairCard)) { returnTo = chairCard; opened = ChannelPage.Director }
|
||||
ChannelCard("New in your library", "What's arrived, and where it went", "drift", card.focusRequester(arrivalsCard)) { returnTo = arrivalsCard; opened = ChannelPage.Arrivals }
|
||||
}
|
||||
ChannelsDetail(busy, made ?: message, isOn, onSwitch, onSuggestions, listFirst, channelList, Modifier.weight(1f), onEdit = { c -> made = null; making = true to c })
|
||||
}
|
||||
@@ -582,3 +601,37 @@ internal fun SettingsScreen(section: SettingsSection, onSection: (SettingsSectio
|
||||
Text("▲▼ Move ► Into this section OK Select Back Main menu", color = Muted, fontSize = 11.sp)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A page that opens in place of a Settings section's list (0.129, Paul, 10 November 2026: Director's Chair opened with the
|
||||
* remote left on Home in the top bar, and one stray Left lost the Chair). The rules, the same for every such page:
|
||||
* - **Focus goes into it.** While its content loads, an invisible holder inside the page keeps the remote (TalkBack hears
|
||||
* "Loading"), so Android never hands focus to the top bar or the list. As soon as [first] is on screen, focus moves there.
|
||||
* - **The remote stays inside.** At the page's edges the arrows do nothing (Left or Down could reach the Settings list, which
|
||||
* opens whatever section it lands on); leaving is Back, which does [onBack] (none: the page handles Back itself, as
|
||||
* Create your own's steps do).
|
||||
* - **Back returns** to the list, and the caller puts focus back on the card or button that opened the page.
|
||||
*/
|
||||
@Composable
|
||||
internal fun SettingsSubPage(first: FocusRequester?, onBack: (() -> Unit)?, modifier: Modifier, content: @Composable () -> Unit) {
|
||||
val holder = remember { FocusRequester() }
|
||||
var holding by remember { mutableStateOf(true) }
|
||||
var held by remember { mutableStateOf(false) }
|
||||
// Closing: the remote may leave now (the caller parks it before the page goes, so Android never chooses for it).
|
||||
var closing by remember { mutableStateOf(false) }
|
||||
LaunchedEffect(Unit) {
|
||||
runCatching { holder.requestFocus() }
|
||||
// Into the page's first item once it's there (a page that loads first draws it later).
|
||||
if (first != null) repeat(300) { if (!holding || runCatching { first.requestFocus() }.getOrDefault(false)) return@LaunchedEffect; kotlinx.coroutines.delay(100) }
|
||||
}
|
||||
if (onBack != null) BackHandler { closing = true; onBack() }
|
||||
Box(modifier.focusProperties {
|
||||
// No direction leaves it: Down at its foot reached the Settings list and switched section just as Left did.
|
||||
onExit = { if (!closing) cancelFocusChange() }
|
||||
}.focusGroup()) {
|
||||
Box(Modifier.size(1.dp).focusRequester(holder).focusProperties { canFocus = holding }
|
||||
.onFocusChanged { if (it.isFocused) held = true else if (held) holding = false }
|
||||
.semantics { contentDescription = "Loading" }.focusable())
|
||||
content()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
package tv.orbit.classic
|
||||
|
||||
import androidx.compose.runtime.setValue
|
||||
|
||||
import androidx.compose.runtime.getValue
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.layout.*
|
||||
@@ -27,6 +31,38 @@ internal data class ChannelEntry(val digits: List<Int>, val slot: Int = 0) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Subtitles, as the viewer sets them (0.129, Paul's rules of 10 November 2026). The same everywhere: Settings on the TV, the
|
||||
* Companion, and what each programme opens with.
|
||||
* - [Off]: no ordinary subtitles. A track the programme itself marks as forced (translations of foreign dialogue, essential
|
||||
* signs) still shows. A programme with no separate forced track never has a whole subtitle track turned on.
|
||||
* - [On]: subtitles in the viewer's language whenever the programme has them.
|
||||
* - [Automatic]: the viewer's language when the programme's sound is all in another language (an anime in Japanese opens
|
||||
* with English subtitles), otherwise as Off.
|
||||
* The viewer's own choice while watching (press right) wins for the rest of that viewing, as before.
|
||||
*/
|
||||
internal enum class SubtitleMode(val title: String, val line: String) {
|
||||
Off("Off", "No subtitles. Short translations a programme marks as needed, such as foreign dialogue or signs, still show."),
|
||||
On("On", "Subtitles in your language whenever a programme has them."),
|
||||
Automatic("Automatic", "Subtitles in your language when a programme's sound is in another language.");
|
||||
/** What a viewing opens with: [subtitleChoice]'s preference. */
|
||||
val preference: String? get() = when (this) { Off -> SUBTITLES_OFF; On -> SUBTITLES_BY_DEFAULT; Automatic -> null }
|
||||
companion object {
|
||||
/** The saved mode; before there was one, the old switch: on is On, off is Off (what the switch said). */
|
||||
fun from(saved: String?, legacyOn: Boolean): SubtitleMode = entries.firstOrNull { it.name == saved } ?: if (legacyOn) On else Off
|
||||
}
|
||||
}
|
||||
|
||||
/** The setting as it is now, for every screen and the Companion to read, and each viewing to start from. */
|
||||
internal object Subtitles {
|
||||
var mode by androidx.compose.runtime.mutableStateOf(SubtitleMode.Off)
|
||||
fun load(settings: OrbitSettings) { mode = settings.subtitleMode }
|
||||
fun set(settings: OrbitSettings, to: SubtitleMode) { settings.subtitleMode = to; mode = to }
|
||||
}
|
||||
|
||||
/** The viewer's languages for subtitles: the TV's own language, then English. */
|
||||
internal fun preferredSubtitleLanguages(): List<String> = listOf(java.util.Locale.getDefault().language.lowercase(java.util.Locale.ROOT), "en").filter { it.isNotBlank() }.distinct()
|
||||
|
||||
/** The setting's choice: English where a programme has it, and otherwise none, so a foreign track never appears unasked. */
|
||||
internal const val SUBTITLES_BY_DEFAULT = "default-english"
|
||||
|
||||
@@ -36,7 +72,9 @@ internal const val SUBTITLES_OFF = "off"
|
||||
/** 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 || wanted == SUBTITLES_OFF || languages.isEmpty()) return null
|
||||
if (wanted == SUBTITLES_BY_DEFAULT) return languages.indexOfFirst { it.lowercase(java.util.Locale.ROOT).startsWith("en") }.takeIf { it >= 0 }
|
||||
// The viewer's languages in order (the TV's, then English), each matched by its code's start (en, eng, en-GB).
|
||||
if (wanted == SUBTITLES_BY_DEFAULT) return preferredSubtitleLanguages().firstNotNullOfOrNull { want ->
|
||||
languages.indexOfFirst { it.lowercase(java.util.Locale.ROOT).startsWith(want) }.takeIf { it >= 0 } }
|
||||
return languages.indexOf(wanted).takeIf { it >= 0 } ?: 0
|
||||
}
|
||||
|
||||
|
||||
@@ -46,24 +46,22 @@ internal fun HighScoresPage(profile: Profile, visible: List<ArcadeGame>, data: A
|
||||
val now = remember { System.currentTimeMillis() }
|
||||
// The house board (Paul, 9 November 2026): everyone's scores, from every room, each kept on their own profile.
|
||||
PageTitle("HIGH SCORES", "${profile.name} · the whole house, every room")
|
||||
Row(Modifier.fillMaxSize(), horizontalArrangement = Arrangement.spacedBy(10.dp)) {
|
||||
Column(Modifier.weight(1f).fillMaxHeight().background(ArcadeColours.PanelDeep.copy(alpha = .85f), RoundedCornerShape(10.dp)).border(1.dp, ArcadeColours.Line, RoundedCornerShape(10.dp)).padding(8.dp)) {
|
||||
Row(Modifier.fillMaxWidth().padding(horizontal = 8.dp, vertical = 2.dp)) {
|
||||
Text("Game", Modifier.weight(1f), color = ArcadeColours.Muted, fontSize = 12.sp)
|
||||
listOf("Your best" to 90, "House best" to 128, "Played" to 64).forEach { (t, w) -> Text(t, Modifier.width(w.dp), color = ArcadeColours.Muted, fontSize = 12.sp, maxLines = 1) }
|
||||
}
|
||||
visible.forEach { g ->
|
||||
val defs = scoreTableDefs(g.id, g.scoreKind)
|
||||
val ix = tableIx[g.id] ?: 0
|
||||
ScoreRow(g, defs[ix], data.game(defs[ix].id), now, houseTop(house, profile.id, defs[ix]).firstOrNull(), tableLabel = scoreTableLabel(g, ix), highlighted = ix > 0,
|
||||
onSide = if (defs.size > 1) { side -> tableIx = tableIx + (g.id to Math.floorMod(ix + side, defs.size)) } else null) { topTen = g }
|
||||
}
|
||||
// One table (0.129): the household records were a second column beside it, with a taller heading, so its lines sat out of
|
||||
// step with the games. Now every row, the heading included, uses the same columns ([ScoreColumns]), and numbers line up on
|
||||
// the right in figures of equal width.
|
||||
Column(Modifier.fillMaxSize().background(ArcadeColours.PanelDeep.copy(alpha = .85f), RoundedCornerShape(10.dp)).border(1.dp, ArcadeColours.Line, RoundedCornerShape(10.dp)).padding(8.dp)) {
|
||||
Row(Modifier.fillMaxWidth().height(rowHeight).padding(horizontal = 8.dp), verticalAlignment = Alignment.CenterVertically) {
|
||||
Spacer(Modifier.width(ScoreColumns.icon))
|
||||
Text("Game", Modifier.weight(1f), color = ArcadeColours.Muted, fontSize = 12.sp)
|
||||
ScoreColumns.headings.forEach { (t, w) -> Text(t, Modifier.width(w), color = if (t == ScoreColumns.HOUSEHOLD) ArcadeColours.Cyan else ArcadeColours.Muted, fontSize = 12.sp, maxLines = 1, textAlign = androidx.compose.ui.text.style.TextAlign.End) }
|
||||
}
|
||||
Column(Modifier.width(150.dp).fillMaxHeight().background(ArcadeColours.PanelDeep.copy(alpha = .85f), RoundedCornerShape(10.dp)).border(1.dp, ArcadeColours.Line, RoundedCornerShape(10.dp)).padding(8.dp)) {
|
||||
Text("🔒 Household Records", color = ArcadeColours.Cyan, fontSize = 13.sp, fontWeight = FontWeight.SemiBold)
|
||||
Text("From before profiles · read-only", color = ArcadeColours.Muted, fontSize = 11.sp)
|
||||
visible.forEach { g -> Text(householdLine(g, household) ?: "—", Modifier.fillMaxWidth().height(rowHeight).padding(top = 3.dp), color = ArcadeColours.Ink, fontSize = 13.sp, fontWeight = FontWeight.SemiBold, textAlign = androidx.compose.ui.text.style.TextAlign.End) }
|
||||
visible.forEach { g ->
|
||||
val defs = scoreTableDefs(g.id, g.scoreKind)
|
||||
val ix = tableIx[g.id] ?: 0
|
||||
ScoreRow(g, defs[ix], data.game(defs[ix].id), now, houseTop(house, profile.id, defs[ix]).firstOrNull(), householdLine(g, household), tableLabel = scoreTableLabel(g, ix), highlighted = ix > 0,
|
||||
onSide = if (defs.size > 1) { side -> tableIx = tableIx + (g.id to Math.floorMod(ix + side, defs.size)) } else null) { topTen = g }
|
||||
}
|
||||
Text("🔒 Household records are from before profiles, and read-only.", Modifier.padding(start = 8.dp, top = 6.dp), color = ArcadeColours.Muted, fontSize = 11.sp)
|
||||
}
|
||||
topTen?.let { g -> val ix = tableIx[g.id] ?: 0; val def = scoreTableDefs(g.id, g.scoreKind)[ix]; TopTen(g, def, houseTop(house, profile.id, def), now, title = scoreTableTitle(g, ix), onClose = { topTen = null }) }
|
||||
}
|
||||
@@ -90,8 +88,18 @@ internal fun scoreTableTitle(game: ArcadeGame, hard: Boolean): String = scoreTab
|
||||
|
||||
private val rowHeight = 22.dp
|
||||
|
||||
/** The High Scores table's columns, shared by its heading and every row, so nothing can drift out of line. */
|
||||
internal object ScoreColumns {
|
||||
const val HOUSEHOLD = "Household"
|
||||
val icon = 22.dp
|
||||
val best = 90.dp; val house = 150.dp; val played = 72.dp; val household = 110.dp
|
||||
val headings = listOf("Your best" to best, "House best" to house, "Played" to played, HOUSEHOLD to household)
|
||||
}
|
||||
/** Figures all the same width, so 980 and 12,480 line up on the right. */
|
||||
private val Figures = androidx.compose.ui.text.TextStyle(fontFeatureSettings = "tnum")
|
||||
|
||||
@Composable
|
||||
private fun ScoreRow(game: ArcadeGame, table: ScoreTable, record: GameRecord, now: Long, houseBest: HouseRun?, tableLabel: String? = null, highlighted: Boolean = false, onSide: ((Int) -> Unit)? = null, onOpen: () -> Unit) {
|
||||
private fun ScoreRow(game: ArcadeGame, table: ScoreTable, record: GameRecord, now: Long, houseBest: HouseRun?, householdRecord: String?, tableLabel: String? = null, highlighted: Boolean = false, onSide: ((Int) -> Unit)? = null, onOpen: () -> Unit) {
|
||||
var focused by remember { mutableStateOf(false) }
|
||||
val corner = RoundedCornerShape(6.dp)
|
||||
val runs = rankRuns(record.runs, table.kind)
|
||||
@@ -103,22 +111,26 @@ private fun ScoreRow(game: ArcadeGame, table: ScoreTable, record: GameRecord, no
|
||||
side != 0
|
||||
} else Modifier)
|
||||
.clickable(onClick = onOpen).padding(horizontal = 8.dp), verticalAlignment = Alignment.CenterVertically) {
|
||||
Canvas(Modifier.size(16.dp)) { drawMascot(game.mascot, center, size.minDimension * .4f) }
|
||||
Spacer(Modifier.width(6.dp))
|
||||
Text(game.title, Modifier.weight(1f, fill = tableLabel == null), color = ArcadeColours.Ink, fontSize = 13.sp, maxLines = 1, overflow = TextOverflow.Ellipsis)
|
||||
if (tableLabel != null) {
|
||||
Text(tableLabel, Modifier.padding(start = 6.dp).background(if (highlighted) ArcadeColours.Pink else ArcadeColours.Panel, RoundedCornerShape(8.dp)).padding(horizontal = 6.dp),
|
||||
Box(Modifier.width(ScoreColumns.icon)) { Canvas(Modifier.size(16.dp)) { drawMascot(game.mascot, center, size.minDimension * .4f) } }
|
||||
// The game and its table switch share one cell that takes the spare width, so the columns after it never move (two
|
||||
// weighted parts, one not filling, left a gap that pushed the numbers left on rows with a switch).
|
||||
Row(Modifier.weight(1f), verticalAlignment = Alignment.CenterVertically) {
|
||||
Text(game.title, Modifier.weight(1f, fill = false), color = ArcadeColours.Ink, fontSize = 13.sp, maxLines = 1, overflow = TextOverflow.Ellipsis)
|
||||
if (tableLabel != null) Text(tableLabel, Modifier.padding(start = 6.dp).background(if (highlighted) ArcadeColours.Pink else ArcadeColours.Panel, RoundedCornerShape(8.dp)).padding(horizontal = 6.dp),
|
||||
color = ArcadeColours.Ink, fontSize = 11.sp, fontWeight = FontWeight.Bold, maxLines = 1)
|
||||
Spacer(Modifier.weight(1f))
|
||||
}
|
||||
val best = bestOf(record, table.kind).takeIf { it > 0 }?.let(table.format)
|
||||
val house = houseBest?.let { "${houseScore(table, it)} · ${if (it.mine) "You" else it.who}" }
|
||||
if (best == null && house == null) Text(if (game.launchable) "Not played yet" else "Coming soon", Modifier.width(282.dp), color = ArcadeColours.Muted, fontSize = 12.sp)
|
||||
val end = androidx.compose.ui.text.style.TextAlign.End
|
||||
if (best == null && house == null) Text(if (game.launchable) "Not played yet" else "Coming soon", Modifier.width(ScoreColumns.best + ScoreColumns.house + ScoreColumns.played),
|
||||
color = ArcadeColours.Muted, fontSize = 12.sp, maxLines = 1, textAlign = end)
|
||||
else {
|
||||
Text(best ?: "—", Modifier.width(90.dp), color = if (best == null) ArcadeColours.Muted else ArcadeColours.Ink, fontSize = 13.sp, fontWeight = FontWeight.Bold, maxLines = 1)
|
||||
Text(house.orEmpty(), Modifier.width(128.dp), color = if (houseBest?.mine == true) ArcadeColours.Yellow else ArcadeColours.Muted, fontSize = 12.sp, maxLines = 1, overflow = TextOverflow.Ellipsis)
|
||||
Text(playedLabel(record.lastPlayedMs, now), Modifier.width(64.dp), color = ArcadeColours.Muted, fontSize = 12.sp, maxLines = 1)
|
||||
Text(best ?: "—", Modifier.width(ScoreColumns.best), color = if (best == null) ArcadeColours.Muted else ArcadeColours.Ink, fontSize = 13.sp, fontWeight = FontWeight.Bold, maxLines = 1, textAlign = end, style = Figures)
|
||||
Text(house.orEmpty(), Modifier.width(ScoreColumns.house), color = if (houseBest?.mine == true) ArcadeColours.Yellow else ArcadeColours.Muted, fontSize = 12.sp, maxLines = 1, overflow = TextOverflow.Ellipsis, textAlign = end, style = Figures)
|
||||
Text(playedLabel(record.lastPlayedMs, now), Modifier.width(ScoreColumns.played), color = ArcadeColours.Muted, fontSize = 12.sp, maxLines = 1, textAlign = end)
|
||||
}
|
||||
Text(householdRecord ?: "—", Modifier.width(ScoreColumns.household), color = if (householdRecord == null) ArcadeColours.Muted else ArcadeColours.Ink, fontSize = 13.sp,
|
||||
fontWeight = FontWeight.SemiBold, maxLines = 1, overflow = TextOverflow.Ellipsis, textAlign = end, style = Figures)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,9 +148,12 @@ private fun TopTen(game: ArcadeGame, table: ScoreTable, entries: List<HouseRun>,
|
||||
entries.forEachIndexed { i, e ->
|
||||
Row(Modifier.fillMaxWidth(), verticalAlignment = Alignment.CenterVertically) {
|
||||
Text("${i + 1}.", Modifier.width(26.dp), color = ArcadeColours.Muted, fontSize = 13.sp)
|
||||
Text(if (e.mine) "You" else e.who, Modifier.width(84.dp), color = if (e.mine) ArcadeColours.Yellow else ArcadeColours.Ink, fontSize = 13.sp, fontWeight = FontWeight.SemiBold, maxLines = 1, overflow = TextOverflow.Ellipsis)
|
||||
Text(houseScore(table, e, long = true), Modifier.weight(1f), color = ArcadeColours.Ink, fontSize = 13.sp, fontWeight = FontWeight.SemiBold, maxLines = 1)
|
||||
Text(listOfNotNull(e.run.detail.takeIf { !e.counted }, playedLabel(e.run.atMs, now)).joinToString(" · "), color = ArcadeColours.Muted, fontSize = 12.sp, maxLines = 1)
|
||||
// Fixed columns, numbers on the right in equal-width figures: long names and 1 to 7 digit scores keep in line.
|
||||
Text(if (e.mine) "You" else e.who, Modifier.weight(1f), color = if (e.mine) ArcadeColours.Yellow else ArcadeColours.Ink, fontSize = 13.sp, fontWeight = FontWeight.SemiBold, maxLines = 1, overflow = TextOverflow.Ellipsis)
|
||||
Text(houseScore(table, e, long = true), Modifier.width(96.dp), color = ArcadeColours.Ink, fontSize = 13.sp, fontWeight = FontWeight.SemiBold, maxLines = 1,
|
||||
textAlign = androidx.compose.ui.text.style.TextAlign.End, style = Figures)
|
||||
Text(listOfNotNull(e.run.detail.takeIf { !e.counted }, playedLabel(e.run.atMs, now)).joinToString(" · "), Modifier.width(130.dp).padding(start = 10.dp), color = ArcadeColours.Muted, fontSize = 12.sp, maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis, textAlign = androidx.compose.ui.text.style.TextAlign.End)
|
||||
}
|
||||
}
|
||||
ArcadeButton("Close", Modifier.fillMaxWidth().padding(top = 6.dp).focusRequester(close), icon = "←", onClick = onClose)
|
||||
|
||||
@@ -94,8 +94,11 @@ internal fun QuizNightScreen(play: ArcadePlay) {
|
||||
}
|
||||
QuizStage.Players -> QuizPlayers(levels, quizLevels(play.kids), backdrop, onChange = { levels = it }, onStart = ::start, onBack = { stage = QuizStage.Title })
|
||||
QuizStage.Question -> game?.let { g ->
|
||||
tick // read, so each answer and each next question redraw
|
||||
QuizAskScreen(g, backdrop, paused, onAnswer = { latestPlay.audio.sfx(if (g.answer(it)) Sfx.MATCH else Sfx.NOPE, soundsOn); tick++ }, onNext = { g.next(); tick++; if (g.over) finish(g) }, onPause = { paused = true })
|
||||
// The game is a plain object that changes in place, so each answer and question draws the screen afresh (keyed on
|
||||
// [tick]): Compose skipped redrawing it, and an answer (registered, with its score) never showed, nor did Next (0.129).
|
||||
key(tick) {
|
||||
QuizAskScreen(g, tick, backdrop, paused, onAnswer = { latestPlay.audio.sfx(if (g.answer(it)) Sfx.MATCH else Sfx.NOPE, soundsOn); tick++ }, onNext = { g.next(); tick++; if (g.over) finish(g) }, onPause = { paused = true })
|
||||
}
|
||||
if (paused) ArcadePauseMenu(gameDef, "Quiz Night · Round ${g.round} of ${g.rounds}", onResume = { paused = false }, onRestart = ::start, onExit = { latestPlay.onLeave() })
|
||||
}
|
||||
QuizStage.Result -> game?.let { g ->
|
||||
@@ -166,7 +169,7 @@ private fun QuizPlayers(levels: List<QuizLevel>, allowed: List<QuizLevel>, backd
|
||||
// ---------- A question ----------
|
||||
|
||||
@Composable
|
||||
private fun QuizAskScreen(g: QuizGame, backdrop: ArcadeBackdrop, paused: Boolean, onAnswer: (Int) -> Unit, onNext: () -> Unit, onPause: () -> Unit) {
|
||||
private fun QuizAskScreen(g: QuizGame, @Suppress("UNUSED_PARAMETER") version: Int, backdrop: ArcadeBackdrop, paused: Boolean, onAnswer: (Int) -> Unit, onNext: () -> Unit, onPause: () -> Unit) {
|
||||
val ask = g.ask
|
||||
val answered = g.answered
|
||||
val firstAnswer = remember { FocusRequester() }
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
package tv.orbit.classic
|
||||
|
||||
import androidx.media3.common.C
|
||||
import androidx.media3.common.TrackSelectionParameters
|
||||
import org.junit.After
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Test
|
||||
import java.util.Locale
|
||||
|
||||
/** Subtitles Off / On / Automatic (0.129, Paul's rules of 10 November 2026). */
|
||||
class SubtitleModesTest {
|
||||
private val saved = Locale.getDefault()
|
||||
@After fun down() = Locale.setDefault(saved)
|
||||
|
||||
private val japaneseSound = listOf("ja"); private val englishSound = listOf("en")
|
||||
private val subs = listOf("pt", "en", "es")
|
||||
|
||||
@Test fun theOldSwitchBecomesWhatItSaid() {
|
||||
assertEquals(SubtitleMode.Off, SubtitleMode.from(null, legacyOn = false))
|
||||
assertEquals(SubtitleMode.On, SubtitleMode.from(null, legacyOn = true))
|
||||
assertEquals(SubtitleMode.Automatic, SubtitleMode.from("Automatic", legacyOn = false))
|
||||
assertEquals(SubtitleMode.Off, SubtitleMode.from("nonsense", legacyOn = false))
|
||||
}
|
||||
|
||||
@Test fun offNeverTurnsAWholeTrackOnEvenForForeignSound() {
|
||||
assertNull(subtitleChoice(SubtitleMode.Off.preference, japaneseSound, subs))
|
||||
assertNull(subtitleChoice(SubtitleMode.Off.preference, englishSound, subs))
|
||||
}
|
||||
|
||||
@Test fun onShowsTheViewersLanguageWhereverThereIsOne() {
|
||||
Locale.setDefault(Locale.UK)
|
||||
assertEquals(1, subtitleChoice(SubtitleMode.On.preference, englishSound, subs))
|
||||
assertNull(subtitleChoice(SubtitleMode.On.preference, englishSound, listOf("pt", "es")))
|
||||
// A French TV prefers French, then English.
|
||||
Locale.setDefault(Locale.FRANCE)
|
||||
assertEquals(1, subtitleChoice(SubtitleMode.On.preference, englishSound, listOf("en", "fr")))
|
||||
assertEquals(0, subtitleChoice(SubtitleMode.On.preference, englishSound, listOf("en", "de")))
|
||||
}
|
||||
|
||||
@Test fun automaticAddsTheViewersLanguageOnlyForForeignSound() {
|
||||
Locale.setDefault(Locale.UK)
|
||||
assertEquals(1, subtitleChoice(SubtitleMode.Automatic.preference, japaneseSound, subs))
|
||||
assertNull(subtitleChoice(SubtitleMode.Automatic.preference, englishSound, subs))
|
||||
}
|
||||
|
||||
@Test fun offsRuleForThePlayerAllowsOnlyForcedTracks() {
|
||||
val p = forcedSubtitlesOnly(TrackSelectionParameters.DEFAULT_WITHOUT_CONTEXT.buildUpon().setPreferredTextLanguage("en")).build()
|
||||
assertTrue(p.preferredTextLanguages.isEmpty())
|
||||
assertEquals(0, p.preferredTextRoleFlags)
|
||||
assertFalse(p.selectUndeterminedTextLanguage)
|
||||
assertEquals(C.SELECTION_FLAG_DEFAULT, p.ignoredTextSelectionFlags and C.SELECTION_FLAG_DEFAULT)
|
||||
// Forced stays allowed: the text type isn't disabled.
|
||||
assertFalse(p.disabledTrackTypes.contains(C.TRACK_TYPE_TEXT))
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 825 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 826 KiB |
Reference in New Issue
Block a user