diff --git a/android/app/src/household/java/tv/orbit/classic/Edition.kt b/android/app/src/household/java/tv/orbit/classic/Edition.kt index 91138a83..fa825ab4 100644 --- a/android/app/src/household/java/tv/orbit/classic/Edition.kt +++ b/android/app/src/household/java/tv/orbit/classic/Edition.kt @@ -30,6 +30,9 @@ internal object Edition { if (intent?.getBooleanExtra("orbit_shadow_catalogue_stop", false) == true) CatalogueShadow.cancel = true // Timings (0.129 stage 0): on, off or clear; local only. intent?.getStringExtra("orbit_timing")?.let { OrbitTiming.set(activity, it) } + // Layouts and looks by name, for checking all 70 pairs on the emulator (12 November 2026). + intent?.getStringExtra("orbit_layout")?.let { n -> OrbitLayout.entries.firstOrNull { it.name == n }?.let { OrbitLayouts.choose(activity, it) } } + intent?.getStringExtra("orbit_look")?.let { n -> OrbitLook.entries.firstOrNull { it.name == n }?.let { OrbitTheme.choose(activity, it) } } // Requests to the server, by kind and hour (0.129): written to Orbit's own folder for adb to pull. Counts only. if (intent?.getStringExtra("orbit_requests") == "dump") runCatching { val out = java.io.File(activity.getExternalFilesDir(null), "server-requests.json") 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 6eb55643..ac6c96e4 100644 --- a/android/app/src/main/java/tv/orbit/classic/EmbyConnectionScreen.kt +++ b/android/app/src/main/java/tv/orbit/classic/EmbyConnectionScreen.kt @@ -115,7 +115,9 @@ internal fun EmbyConnectionScreen(modifier: Modifier = Modifier, visible: Boolea /** The first-launch flow is showing: it draws everything once signed in, so this screen draws nothing. */ onboarding: Boolean = false, onSignedIn: () -> Unit = {}, mainGuide: Boolean, mainHome: Boolean = false, mainDriveIn: Boolean = false, mainWhatsOn: Boolean = false, mainCatchUp: Boolean = false, onChannelAvailable: (Boolean) -> Unit, onRestoreChecked: () -> Unit = {}, onGuide: () -> Unit, - onHome: () -> Unit = {}, onDriveIn: () -> Unit = {}) { + onHome: () -> Unit = {}, onDriveIn: () -> Unit = {}, + /** Another part of Orbit by its name in the top bar ("TV Guide", "Catch Up", "Drive-In", "Connect Emby"), for the layouts' Home. */ + onSection: (String) -> Unit = {}) { val appContext = androidx.compose.ui.platform.LocalContext.current.applicationContext // Everything below belongs to the server signed in to ([ServerWorkspace]): another server's sign-in, catalogue and // schedules are never open at the same time, and work begun for one keeps writing only to its own. @@ -742,6 +744,17 @@ internal fun EmbyConnectionScreen(modifier: Modifier = Modifier, visible: Boolea } // Orbit Companion: the channels this TV shows right now, and tuning as the guide does. Set here, before any screen // returns early, so the phone works from every section (the Drive-In and the Arcade go to the guide to tune). + // Just Watch (12 November 2026): as Orbit opens or comes back, it goes straight to the channel, full screen, once someone + // has been chosen. Back from there is Just Watch's menu over the picture. + var justWatchArmed by remember { mutableStateOf(true) } + DisposableEffect(lifecycle) { + val observer = LifecycleEventObserver { _, event -> if (event == Lifecycle.Event.ON_START) justWatchArmed = true } + lifecycle.addObserver(observer); onDispose { lifecycle.removeObserver(observer) } + } + // Never behind Who's watching: it waits until someone has been chosen, so nothing plays under the last person's profile. + LaunchedEffect(mainHome, justWatchArmed, liveChannel != null, OrbitLayouts.current, WatchCheck.pending) { + if (justWatchArmed && mainHome && !WatchCheck.pending && liveChannel != null && OrbitLayouts.current == OrbitLayout.JustWatch && !watchingChannel) { justWatchArmed = false; tune(selectedNumber, 0) } + } val shownChannels by rememberUpdatedState(availableChannels.filter { !lockedOut(it.number) && !profileHides(it.number) }) val companionTune by rememberUpdatedState<(Int, Long) -> Unit> { n, offset -> if (shownChannels.any { it.number == n }) { tune(n, offset); if (!mainGuide && !mainHome && !mainWhatsOn && !mainCatchUp) onGuide() } @@ -844,6 +857,14 @@ internal fun EmbyConnectionScreen(modifier: Modifier = Modifier, visible: Boolea } val picture = @Composable { GuidePicture(liveSession, liveChannel, live = !watchingChannel, handoff = liveHandoff, onUnplayable = ::rememberUnplayable) } when { + mainHome && OrbitLayouts.current == OrbitLayout.Teletext -> OrbiFaxScreen({ shows, pause -> orbiFaxData(availableChannels, scheduledChannels.mapValues { it.value.plan }, driveInPlan, + { session?.let { scheduleStore.loadArrivals(it.accountId).first }.orEmpty() }, orbiFaxRecords(OrbitSettings(appContext)), Profiles.current, System.currentTimeMillis(), shows = shows, pause = pause) }, + onClose = onGuide) + mainHome && OrbitLayouts.current != OrbitLayout.Original -> LayoutHomeScreen(OrbitLayouts.current, LayoutHome(liveSession, + availableChannels.filter { !lockedOut(it.number) && !profileHides(it.number) }, liveChannel, + picture = { m -> Box(m) { GuidePicture(liveSession, liveChannel, live = !watchingChannel, handoff = liveHandoff, onUnplayable = ::rememberUnplayable) } }, + onSelect = { n -> if (n != selectedNumber && availableChannels.any { it.number == n }) { lastNumber = selectedNumber; selectedNumber = n } }, + onWatch = { n -> tune(n, 0) }, onSection = onSection, kids = Profiles.kids), modifier) mainHome -> HomeScreen(availableChannels, modifier, onCategory = { guideCategory = it; onGuide() }, carryOn = continueEntries(availableChannels.filter { !lockedOut(it.number) && !profileHides(it.number) }, ContinueWatching.marks, System.currentTimeMillis()), onResume = ::resumeContinue) mainCatchUp -> CatchUpScreen(availableChannels, liveSession, modifier, onOpen = { catchUpOpen = it }, diff --git a/android/app/src/main/java/tv/orbit/classic/Layouts.kt b/android/app/src/main/java/tv/orbit/classic/Layouts.kt new file mode 100644 index 00000000..b3fadd36 --- /dev/null +++ b/android/app/src/main/java/tv/orbit/classic/Layouts.kt @@ -0,0 +1,313 @@ +package tv.orbit.classic + +import android.content.Context +import androidx.compose.foundation.Image +import androidx.compose.foundation.background +import androidx.compose.foundation.border +import androidx.compose.foundation.clickable +import androidx.compose.foundation.focusable +import androidx.compose.foundation.layout.* +import androidx.compose.foundation.lazy.LazyRow +import androidx.compose.foundation.lazy.grid.GridCells +import androidx.compose.foundation.lazy.grid.LazyVerticalGrid +import androidx.compose.foundation.lazy.grid.itemsIndexed +import androidx.compose.foundation.lazy.itemsIndexed +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.runtime.* +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.focus.FocusRequester +import androidx.compose.ui.focus.focusProperties +import androidx.compose.ui.focus.focusRequester +import androidx.compose.ui.focus.onFocusChanged +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.text.style.TextOverflow +import androidx.compose.ui.unit.Dp +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import androidx.tv.material3.Text +import kotlinx.coroutines.delay + +/** + * Orbit's layouts (Paul, 11 and 12 November 2026, from design/layouts): how Home is laid out, separately from the look's + * colours, so any layout wears any of the ten looks. Orbit Original stays exactly as it was. Each layout only changes Home; + * the guide, Catch Up, the Drive-In and watching full screen are shared, and every layout plays at most one stream, as + * before (the guide picture's rules, including its 10-minute rest, apply wherever a picture shows). + */ +internal enum class OrbitLayout(val title: String, val line: String) { + Original("Orbit Original", "The category menu, as it has always been"), + JustWatch("Just Watch", "Opens on the last channel; OK for the menu"), + Simple("Orbit Simple", "Big type and four big choices"), + RetroCable("Retro Cable", "The picture is home; surf with Up and Down"), + Mosaic("Mosaic", "Nine channels at a glance; one plays"), + Teletext("Teletext", "Orbit as OrbiFax pages"), + Kids("Kids", "Big picture cards for the kids' channels") +} + +internal object OrbitLayouts { + var current by mutableStateOf(OrbitLayout.Original) + private set + private fun prefs(context: Context) = context.getSharedPreferences("orbit_settings", Context.MODE_PRIVATE) + fun load(context: Context) { current = prefs(context).getString("layout", null)?.let { n -> OrbitLayout.entries.firstOrNull { it.name == n } } ?: OrbitLayout.Original } + fun choose(context: Context, chosen: OrbitLayout) { prefs(context).edit().putString("layout", chosen.name).apply(); current = chosen } + /** For tests and previews. */ + internal fun use(chosen: OrbitLayout) { current = chosen } +} + +internal val Comfortaa = androidx.compose.ui.text.font.FontFamily(androidx.compose.ui.text.font.Font(R.font.comfortaa)) + +/** Kids' channels for the Kids layout: Kids and Cartoons, or every channel if there are none. */ +internal fun kidsChannels(channels: List): List = kidsNumbers(channels.map { it.number }).let { keep -> channels.filter { it.number in keep } } +internal fun kidsNumbers(numbers: List): List = + numbers.filter { ChannelBrands.forNumber(it)?.category.let { c -> c == ChannelCategory.Kids || c == ChannelCategory.Cartoons } }.ifEmpty { numbers } + +/** Everything the layouts need from the main screen. */ +internal class LayoutHome( + val session: EmbySampleSession, val channels: List, val selected: SampleChannel, + val picture: @Composable (Modifier) -> Unit, + val onSelect: (Int) -> Unit, val onWatch: (Int) -> Unit, val onSection: (String) -> Unit, val kids: Boolean) + +@Composable +internal fun LayoutHomeScreen(layout: OrbitLayout, home: LayoutHome, modifier: Modifier) { + when (layout) { + OrbitLayout.JustWatch -> JustWatchHome(home, modifier) + OrbitLayout.Simple -> SimpleHome(home, modifier) + OrbitLayout.RetroCable -> CableHome(home, modifier) + OrbitLayout.Mosaic -> MosaicHome(home, modifier) + OrbitLayout.Kids -> KidsHome(home, modifier) + else -> Unit // Original and Teletext are drawn by the main screen. + } +} + +private val Round = RoundedCornerShape(10.dp) + +/** A focusable card: gold fill and a ring when focused, never colour alone. */ +@Composable +private fun LayoutCard(modifier: Modifier, focus: FocusRequester? = null, onFocused: () -> Unit = {}, onClick: () -> Unit, shape: RoundedCornerShape = Round, + content: @Composable BoxScope.(Boolean) -> Unit) { + var focused by remember { mutableStateOf(false) } + Box(modifier.then(if (focus != null) Modifier.focusRequester(focus) else Modifier) + .onFocusChanged { focused = it.isFocused; if (it.isFocused) onFocused() } + .border(if (focused) 3.dp else 0.dp, if (focused) Yellow else Color.Transparent, shape).padding(if (focused) 4.dp else 0.dp) + .clip(shape).background(focusColor(if (focused) Yellow else Panel)).clickable(onClick = onClick)) { content(focused) } +} + +@Composable +private fun firstFocus(): FocusRequester { + val f = remember { FocusRequester() } + LaunchedEffect(Unit) { repeat(20) { if (runCatching { f.requestFocus() }.isSuccess) return@LaunchedEffect; delay(50) } } + return f +} + +private fun nowAt(channel: SampleChannel) = runCatching { channel.at(System.currentTimeMillis()) }.getOrNull() + +@Composable +private fun ChannelLogo(number: Int, modifier: Modifier) { + ChannelBrands.forNumber(number)?.let { Image(cachedPainter(it.logo), it.displayName, modifier.logoPlate()) } +} + +@Composable +private fun NowLines(channel: SampleChannel, onAccent: Boolean, titleSize: Int = 16, lineSize: Int = 12) { + val show = nowAt(channel) ?: return + val now = System.currentTimeMillis() + Text("${channel.number} ${guideTitle(channel.number, show).first}", color = if (onAccent) OnAccent else Ink, fontSize = titleSize.sp, fontWeight = FontWeight.Bold, + maxLines = 1, overflow = TextOverflow.Ellipsis) + Text(leftLabel(show.endMs - now), color = if (onAccent) OnAccent else Muted, fontSize = lineSize.sp, maxLines = 1) + Box(Modifier.padding(top = 4.dp).fillMaxWidth().height(4.dp).clip(RoundedCornerShape(2.dp)).background(if (onAccent) OnAccent.copy(alpha = .25f) else Blue)) { + Box(Modifier.fillMaxWidth(programmeProgress(show.startMs, show.endMs, now)).fillMaxHeight().background(if (onAccent) OnAccent else Yellow)) + } +} + +// ---------- Just Watch ---------- + +/** + * Just Watch: Orbit opens playing (the main screen tunes the last channel as Orbit opens), and Back from full screen comes + * here: the picture fills the screen behind one row of choices, or a strip of channels. + */ +@Composable +private fun JustWatchHome(h: LayoutHome, modifier: Modifier) { + var channels by remember { mutableStateOf(false) } + Box(modifier.fillMaxSize()) { + h.picture(Modifier.fillMaxSize()) + Column(Modifier.align(Alignment.BottomStart).fillMaxWidth().background(Navy.copy(alpha = .88f), RoundedCornerShape(12.dp)).padding(16.dp), + verticalArrangement = Arrangement.spacedBy(10.dp)) { + nowAt(h.selected)?.let { show -> Text("${h.selected.number} ${guideTitle(h.selected.number, show).first}", color = Ink, fontSize = 18.sp, fontWeight = FontWeight.Bold) } + if (!channels) { + val first = firstFocus() + Row(horizontalArrangement = Arrangement.spacedBy(12.dp)) { + listOf("Watch" to { h.onWatch(h.selected.number) }, "Channels" to { channels = true }, "TV Guide" to { h.onSection("TV Guide") }, + "Catch Up" to { h.onSection("Catch Up") }, "Drive-In" to { h.onSection("Drive-In") }).forEachIndexed { i, (label, go) -> + LayoutCard(Modifier.width(140.dp).height(48.dp), if (i == 0) first else null, onClick = go) { f -> + Text(label, Modifier.align(Alignment.Center), color = if (f) OnAccent else Ink, fontSize = 16.sp, fontWeight = FontWeight.Bold) + } + } + } + } else { + androidx.activity.compose.BackHandler { channels = false } + val first = firstFocus() + LazyRow(horizontalArrangement = Arrangement.spacedBy(12.dp)) { + itemsIndexed(h.channels, key = { _, c -> c.number }) { i, c -> + LayoutCard(Modifier.width(170.dp).height(116.dp), if (c.number == h.selected.number || (i == 0 && h.channels.none { it.number == h.selected.number })) first else null, + onClick = { h.onWatch(c.number) }) { f -> + Column(Modifier.padding(10.dp), verticalArrangement = Arrangement.spacedBy(2.dp)) { + ChannelLogo(c.number, Modifier.height(32.dp)) + NowLines(c, f, 13, 11) + } + } + } + } + } + } + } +} + +// ---------- Orbit Simple ---------- + +/** Orbit Simple: what's on now, then four big choices in one row. Left and Right only. */ +@Composable +private fun SimpleHome(h: LayoutHome, modifier: Modifier) { + val first = firstFocus() + Column(modifier.fillMaxSize(), verticalArrangement = Arrangement.spacedBy(16.dp)) { + Row(Modifier.fillMaxWidth().height(150.dp).clip(RoundedCornerShape(12.dp)).background(Panel).padding(12.dp), horizontalArrangement = Arrangement.spacedBy(16.dp)) { + h.picture(Modifier.width(226.dp).fillMaxHeight().clip(RoundedCornerShape(8.dp))) + Column(Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(4.dp)) { + Text("On now", color = Muted, fontSize = 16.sp) + NowLines(h.selected, false, 26, 16) + } + } + Row(horizontalArrangement = Arrangement.spacedBy(16.dp)) { + val choices = listOfNotNull("Watch TV" to { h.onWatch(h.selected.number) }, "TV Guide" to { h.onSection("TV Guide") }, "Catch Up" to { h.onSection("Catch Up") }, + if (h.kids) null else "Settings" to { h.onSection("Connect Emby") }) + choices.forEachIndexed { i, (label, go) -> + LayoutCard(Modifier.weight(1f).height(150.dp), if (i == 0) first else null, onClick = go, shape = RoundedCornerShape(14.dp)) { f -> + Text(label, Modifier.align(Alignment.BottomStart).padding(18.dp), color = if (f) OnAccent else Ink, fontSize = 26.sp, fontWeight = FontWeight.Bold) + } + } + } + Text("◀ ▶ Choose OK Open Back Leave Orbit", color = Muted, fontSize = 15.sp) + } +} + +// ---------- Retro Cable ---------- + +/** Retro Cable: the picture is home. A surf list of every channel on the left (Up and Down, the picture follows after 600 ms), Now and Next below. */ +@Composable +private fun CableHome(h: LayoutHome, modifier: Modifier) { + val numbers = h.channels.map { it.number } + Box(modifier.fillMaxSize()) { + h.picture(Modifier.fillMaxSize()) + Box(Modifier.align(Alignment.TopEnd).background(Color.Black.copy(alpha = .75f), RoundedCornerShape(6.dp)).padding(horizontal = 14.dp, vertical = 4.dp)) { + Text("%03d".format(h.selected.number), color = Mint, fontFamily = BarlowCondensed, fontSize = 40.sp) + } + val first = firstFocus() + // Every channel in a list that scrolls; the focused one becomes the channel after 600 ms, so surfing past opens nothing. + var focusedNumber by remember { mutableStateOf(null) } + LaunchedEffect(focusedNumber) { val n = focusedNumber ?: return@LaunchedEffect; delay(600); h.onSelect(n) } + androidx.compose.foundation.lazy.LazyColumn(Modifier.align(Alignment.CenterStart).width(280.dp).height(240.dp), verticalArrangement = Arrangement.spacedBy(6.dp)) { + itemsIndexed(h.channels, key = { _, c -> c.number }) { i, c -> + val n = c.number + LayoutCard(Modifier.fillMaxWidth().height(40.dp), if (n == h.selected.number || (i == 0 && numbers.none { it == h.selected.number })) first else null, + onFocused = { focusedNumber = n }, onClick = { h.onWatch(n) }, shape = RoundedCornerShape(6.dp)) { f -> + Row(Modifier.fillMaxSize().padding(horizontal = 10.dp), verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(10.dp)) { + Text("$n", color = if (f) OnAccent else Mint, fontFamily = BarlowCondensed, fontSize = 18.sp) + Text(nowAt(c)?.let { guideTitle(n, it).first }.orEmpty(), color = if (f) OnAccent else Ink, fontSize = 14.sp, maxLines = 1, overflow = TextOverflow.Ellipsis) + } + } + } + } + val show = nowAt(h.selected) + if (show != null) Column(Modifier.align(Alignment.BottomCenter).fillMaxWidth().background(Panel.copy(alpha = .94f), RoundedCornerShape(6.dp)).padding(14.dp)) { + Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(12.dp)) { + ChannelLogo(h.selected.number, Modifier.height(36.dp)) + Text("NOW", color = Yellow, fontFamily = Anton, fontSize = 14.sp) + Text(guideTitle(h.selected.number, show).first, color = Ink, fontSize = 18.sp, fontWeight = FontWeight.Bold, maxLines = 1) + Spacer(Modifier.weight(1f)) + Text("▲▼ surf · OK watch", color = Muted, fontSize = 13.sp) + } + runCatching { h.selected.at(show.endMs + 1) }.getOrNull()?.let { next -> + Row(horizontalArrangement = Arrangement.spacedBy(12.dp)) { + Text("NEXT", color = Muted, fontFamily = Anton, fontSize = 14.sp) + Text(guideTitle(h.selected.number, next).first, color = Ink, fontSize = 15.sp, maxLines = 1) + } + } + } + } +} + +// ---------- Mosaic ---------- + +/** Mosaic: a wall of channels with their programmes' artwork. The focused tile becomes the channel after 600 ms, and only it plays. */ +@Composable +private fun MosaicHome(h: LayoutHome, modifier: Modifier) { + val first = firstFocus() + var focusedNumber by remember { mutableStateOf(null) } + LaunchedEffect(focusedNumber) { val n = focusedNumber ?: return@LaunchedEffect; delay(600); h.onSelect(n) } + LazyVerticalGrid(GridCells.Fixed(3), modifier.fillMaxSize(), horizontalArrangement = Arrangement.spacedBy(10.dp), verticalArrangement = Arrangement.spacedBy(10.dp)) { + itemsIndexed(h.channels, key = { _, c -> c.number }) { i, c -> + LayoutCard(Modifier.fillMaxWidth().aspectRatio(16f / 10f), if (c.number == h.selected.number || (i == 0 && h.channels.none { it.number == h.selected.number })) first else null, + onFocused = { focusedNumber = c.number }, onClick = { h.onWatch(c.number) }) { f -> + Column(Modifier.fillMaxSize()) { + Box(Modifier.weight(1f).fillMaxWidth()) { + val show = nowAt(c) + if (f && c.number == h.selected.number) h.picture(Modifier.fillMaxSize()) + else if (show != null) ProgrammeArtwork(h.session, c, show, Modifier.fillMaxSize()) + ChannelLogo(c.number, Modifier.padding(6.dp).height(22.dp)) + } + Column(Modifier.padding(horizontal = 8.dp, vertical = 4.dp)) { NowLines(c, f, 13, 10) } + } + } + } + } +} + +// ---------- Kids ---------- + +/** Kids: big picture cards, one row, a word each. Only the kids' channels; no guide grid and no settings. */ +@Composable +private fun KidsHome(h: LayoutHome, modifier: Modifier) { + val first = firstFocus() + val kids = kidsChannels(h.channels) + Column(modifier.fillMaxSize(), verticalArrangement = Arrangement.spacedBy(16.dp)) { + Text("What shall we watch?", color = Ink, fontFamily = Comfortaa, fontSize = 30.sp, fontWeight = FontWeight.Bold) + LazyRow(horizontalArrangement = Arrangement.spacedBy(18.dp)) { + itemsIndexed(kids, key = { _, c -> c.number }) { i, c -> + LayoutCard(Modifier.width(200.dp).height(300.dp), if (i == 0) first else null, onClick = { h.onWatch(c.number) }, shape = RoundedCornerShape(20.dp)) { f -> + Column(Modifier.fillMaxSize()) { + Box(Modifier.weight(1f).fillMaxWidth()) { + nowAt(c)?.let { ProgrammeArtwork(h.session, c, it, Modifier.fillMaxSize()) } + ChannelLogo(c.number, Modifier.padding(10.dp).height(36.dp)) + } + Column(Modifier.padding(14.dp), verticalArrangement = Arrangement.spacedBy(2.dp)) { + Text(ChannelBrands.forNumber(c.number)?.displayName?.removePrefix("Orbit ") ?: c.name, color = if (f) OnAccent else Ink, fontFamily = Comfortaa, + fontSize = 24.sp, fontWeight = FontWeight.Bold, maxLines = 1) + nowAt(c)?.let { Text(guideTitle(c.number, it).first, color = if (f) OnAccent else Muted, fontFamily = Comfortaa, fontSize = 14.sp, maxLines = 1, overflow = TextOverflow.Ellipsis) } + } + } + } + } + } + Text("◀ ▶ pick · OK watch", color = Muted, fontFamily = Comfortaa, fontSize = 18.sp, fontWeight = FontWeight.Bold) + } +} + +/** The layouts as a list, for Settings › On screen. */ +@Composable +internal fun LayoutPicker(context: Context = androidx.compose.ui.platform.LocalContext.current) { + Column(verticalArrangement = Arrangement.spacedBy(6.dp)) { + OrbitLayout.entries.chunked(4).forEach { row -> + Row(horizontalArrangement = Arrangement.spacedBy(10.dp)) { + row.forEach { layout -> + val inUse = OrbitLayouts.current == layout + LayoutCard(Modifier.width(150.dp).height(56.dp), onClick = { OrbitLayouts.choose(context, layout) }, shape = RoundedCornerShape(8.dp)) { f -> + Column(Modifier.padding(horizontal = 10.dp, vertical = 6.dp)) { + Text(layout.title + if (inUse) " ✓" else "", color = if (f) OnAccent else if (inUse) Yellow else Ink, fontSize = 13.sp, fontWeight = FontWeight.SemiBold, maxLines = 1) + Text(layout.line, color = if (f) OnAccent else Muted, fontSize = 10.sp, maxLines = 2, overflow = TextOverflow.Ellipsis) + } + } + } + } + } + } +} diff --git a/android/app/src/main/java/tv/orbit/classic/MainActivity.kt b/android/app/src/main/java/tv/orbit/classic/MainActivity.kt index f4068de2..478c4839 100644 --- a/android/app/src/main/java/tv/orbit/classic/MainActivity.kt +++ b/android/app/src/main/java/tv/orbit/classic/MainActivity.kt @@ -99,6 +99,7 @@ class MainActivity : ComponentActivity() { RoomLinks.load(this) // The chosen look, before the first frame, so a light look never flashes navy. OrbitTheme.load(this) + OrbitLayouts.load(this) Subtitles.load(OrbitSettings(this)) window.setBackgroundDrawable(android.graphics.drawable.ColorDrawable(Navy.toArgb())) // One typeface everywhere, matching the channel logos. @@ -217,12 +218,13 @@ private fun OrbitApp() { EmbyConnectionScreen(if (section == "Arcade") Modifier else Modifier.weight(1f), visible = section == "Connect Emby", onboarding = onboarding, onSignedIn = { if (Onboarding.step == OnboardStep.SignIn) Onboarding.go(OnboardStep.Channels) }, mainGuide = section == "TV Guide" && realChannelAvailable && chosen, - mainHome = section == "Home" && realChannelAvailable && chosen, + // Not while Who's watching is asked: a layout's Home can hold a picture, and nothing plays before someone is chosen. + mainHome = section == "Home" && realChannelAvailable && chosen && !picking, mainDriveIn = section == "Drive-In" && realChannelAvailable && chosen, mainWhatsOn = section == "What's On" && realChannelAvailable && chosen, mainCatchUp = section == "Catch Up" && realChannelAvailable && chosen, onChannelAvailable = { realChannelAvailable = it }, onRestoreChecked = { restoreChecked = true }, - onGuide = { section = "TV Guide" }, onHome = { section = "Home" }, onDriveIn = { section = "Drive-In" }) + onGuide = { section = "TV Guide" }, onHome = { section = "Home" }, onDriveIn = { section = "Drive-In" }, onSection = { section = it }) } // Tuning in (design/motion): the channels circle the dial while Orbit reads its sign-in and schedules. // It waits a moment first, so a quick start never pays for it. diff --git a/android/app/src/main/java/tv/orbit/classic/Settings.kt b/android/app/src/main/java/tv/orbit/classic/Settings.kt index 253caf03..e15c50a4 100644 --- a/android/app/src/main/java/tv/orbit/classic/Settings.kt +++ b/android/app/src/main/java/tv/orbit/classic/Settings.kt @@ -612,6 +612,9 @@ internal fun SettingsScreen(section: SettingsSection, onSection: (SettingsSectio } } SettingsSection.OnScreen -> ViewingDetail(firstSwitch, detail) { + Heading("Layout") + Text("How Home is laid out. Any layout works with any look below.", color = Muted, fontSize = 12.sp) + LayoutPicker() Heading("Look") Text("Every screen takes the look you pick, straight away. The cast, the channels' idents and the games keep their own colours.", color = Muted, fontSize = 12.sp) LookPicker(firstSwitch, cardWidth = 128.dp) diff --git a/android/app/src/main/res/font/comfortaa.ttf b/android/app/src/main/res/font/comfortaa.ttf new file mode 100644 index 00000000..e64de93f Binary files /dev/null and b/android/app/src/main/res/font/comfortaa.ttf differ diff --git a/android/app/src/test/java/tv/orbit/classic/LayoutsTest.kt b/android/app/src/test/java/tv/orbit/classic/LayoutsTest.kt new file mode 100644 index 00000000..fb63ae8c --- /dev/null +++ b/android/app/src/test/java/tv/orbit/classic/LayoutsTest.kt @@ -0,0 +1,29 @@ +package tv.orbit.classic + +import org.junit.After +import org.junit.Assert.* +import org.junit.Test + +/** The seven layouts (12 November 2026): Original stays the default, and any layout wears any look. */ +class LayoutsTest { + @After fun reset() { OrbitLayouts.use(OrbitLayout.Original); OrbitTheme.use(OrbitLook.Night) } + + @Test fun sevenLayoutsAndOriginalFirst() { + assertEquals(7, OrbitLayout.entries.size) + assertEquals(OrbitLayout.Original, OrbitLayout.entries.first()) + assertEquals(OrbitLayout.Original, OrbitLayouts.current) + } + + @Test fun seventyCombinations() { + assertEquals(10, OrbitLook.entries.size) + var combos = 0 + for (layout in OrbitLayout.entries) for (look in OrbitLook.entries) { OrbitLayouts.use(layout); OrbitTheme.use(look); combos++ + assertEquals(layout, OrbitLayouts.current); assertEquals(look.palette.accent, Yellow) } + assertEquals(70, combos) + } + + @Test fun kidsShowsOnlyKidsChannelsWhenThereAreAny() { + assertEquals(listOf(TOTS_NUMBER, VORTEX_NUMBER), kidsNumbers(listOf(101, TOTS_NUMBER, VORTEX_NUMBER, 201))) + assertEquals(listOf(101, 201), kidsNumbers(listOf(101, 201))) + } +}