Keep only what's needed: simple sign in and settings, demo and test tools removed (0.73.0)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,54 +0,0 @@
|
||||
package tv.orbit.classic
|
||||
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.layout.ContentScale
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.tv.material3.Text
|
||||
|
||||
@Composable
|
||||
internal fun AfterDarkReviewScreen(movies: List<AfterDarkMovie>, approved: Set<String>, busy: Boolean,
|
||||
message: String?, modifier: Modifier, onGenre: (String) -> Unit, onToggle: (String) -> Unit,
|
||||
onBuild: () -> Unit, onBack: () -> Unit) {
|
||||
BackHandler(onBack = onBack)
|
||||
Box(modifier.fillMaxWidth().background(Navy)) {
|
||||
Image(painterResource(R.drawable.orbit_after_dark_background), null, Modifier.matchParentSize(), contentScale = ContentScale.Crop, alpha = .45f)
|
||||
Column(Modifier.fillMaxSize().padding(18.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
Image(painterResource(R.drawable.orbit_after_dark_epg), "$AFTER_DARK_NUMBER Orbit After Dark", Modifier.width(230.dp).height(65.dp))
|
||||
Text("Late-night and cult cinema. Check a category, then choose two or three films.", color = Color.White, fontSize = 17.sp)
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
AfterDarkGenres.forEach { genre -> OrbitButton("Check $genre", enabled = !busy, onClick = { onGenre(genre) }) }
|
||||
}
|
||||
if (busy) Text("Checking your film sample…", color = Yellow, fontSize = 15.sp)
|
||||
message?.let { Text(it, color = Yellow, fontSize = 15.sp, maxLines = 3) }
|
||||
if (movies.isEmpty() && !busy) Text("No checked films yet. Each category checks up to 20 records; this is a small sample of your library.", color = Muted, fontSize = 16.sp)
|
||||
LazyColumn(Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
items(movies, key = { it.item.id }) { movie ->
|
||||
Column(Modifier.fillMaxWidth().background(Panel.copy(alpha = .94f)).padding(10.dp)) {
|
||||
Text(movie.item.title + (movie.year?.let { " ($it)" } ?: ""), color = Color.White, fontSize = 20.sp, maxLines = 2)
|
||||
val details = listOfNotNull(movie.rating.takeIf { it.isNotBlank() }, movie.item.minutes?.let { "$it min" }, movie.item.format.takeIf { it.isNotBlank() })
|
||||
if (details.isNotEmpty()) Text(details.joinToString(" • "), color = Muted, fontSize = 14.sp)
|
||||
Text("Categories: ${movie.genres.joinToString(", ")}", color = Muted, fontSize = 14.sp, maxLines = 2)
|
||||
OrbitButton(if (movie.item.id in approved) "✓ Remove from selection" else "+ Add to channel",
|
||||
selected = movie.item.id in approved, enabled = !busy && (movie.item.id in approved || approved.size < 3),
|
||||
onClick = { onToggle(movie.item.id) })
|
||||
}
|
||||
}
|
||||
}
|
||||
Text("${approved.size}/3 selected • Existing schedules change only when you create or rebuild this channel.", color = Muted, fontSize = 13.sp)
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
OrbitButton("Create / rebuild $AFTER_DARK_NUMBER", enabled = !busy && approved.size in 2..3, onClick = onBuild)
|
||||
OrbitButton("Back", onClick = onBack)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
package tv.orbit.classic
|
||||
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.DisposableEffect
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.focus.FocusRequester
|
||||
import androidx.compose.ui.focus.focusRequester
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.LocalView
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.tv.material3.Text
|
||||
import java.util.Locale
|
||||
|
||||
private fun whole(value: Long) = String.format(Locale.UK, "%,d", value)
|
||||
|
||||
@Composable
|
||||
internal fun CatalogueScreen(summary: CatalogueSummary?, busy: Boolean, canRun: Boolean, message: String?, lastRun: String?,
|
||||
modifier: Modifier, onRun: (Boolean) -> Unit, onBack: () -> Unit, onHealth: () -> Unit = {}) {
|
||||
BackHandler(onBack = onBack)
|
||||
val backFocus = remember { FocusRequester() }
|
||||
LaunchedEffect(Unit) { backFocus.requestFocus() }
|
||||
// A screensaver stops the app, and so the import, so the screen stays on only while it runs.
|
||||
val view = LocalView.current
|
||||
DisposableEffect(view, busy) {
|
||||
view.keepScreenOn = busy
|
||||
onDispose { view.keepScreenOn = false }
|
||||
}
|
||||
Column(modifier.fillMaxWidth().background(Navy).padding(18.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
Text("Library import test", color = Yellow, fontSize = 26.sp)
|
||||
Text("Saves film and series details on this box. Channels and schedules are not changed, and no episodes are read. Importing everything can take a while, as later pages are slower.", color = Color.White, fontSize = 15.sp)
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
OrbitButton(if (busy) "Importing…" else if (summary?.finished == true) "Import finished" else "Import everything", enabled = canRun && summary?.finished != true, onClick = { onRun(true) })
|
||||
OrbitButton("Import next 1,000", enabled = canRun && summary?.finished != true, onClick = { onRun(false) })
|
||||
OrbitButton("Health check", enabled = !busy, onClick = onHealth)
|
||||
OrbitButton("Back", Modifier.focusRequester(backFocus), onClick = onBack)
|
||||
}
|
||||
message?.let { Text(it, color = Yellow, fontSize = 15.sp, maxLines = 3) }
|
||||
lastRun?.let { Text(it, color = Yellow, fontSize = 15.sp) }
|
||||
summary?.let { s ->
|
||||
Column(Modifier.fillMaxWidth().background(Panel).padding(12.dp), verticalArrangement = Arrangement.spacedBy(4.dp)) {
|
||||
Text("Position ${whole(s.next)}${s.total?.let { " of ${whole(it)}" }.orEmpty()}", color = Color.White, fontSize = 19.sp)
|
||||
Text("Saved: ${whole(s.films)} films, ${whole(s.series)} series", color = Color.White, fontSize = 17.sp)
|
||||
Text("With genres ${whole(s.withGenres)} • external IDs ${whole(s.withIds)} • year ${whole(s.withYear)} • rating ${whole(s.withRating)} • date ${whole(s.withDate)} • tags ${whole(s.withTags)}", color = Muted, fontSize = 15.sp)
|
||||
val perRecord = if (s.records > 0) " • about ${whole(s.bytes / s.records)} bytes per title" else ""
|
||||
Text("Database ${whole(s.bytes / 1024)} KB$perRecord", color = Muted, fontSize = 15.sp)
|
||||
}
|
||||
}
|
||||
Text("Leaving this screen stops the import safely. It carries on from the same place next time. Disconnect removes this data.", color = Muted, fontSize = 13.sp)
|
||||
}
|
||||
}
|
||||
@@ -54,11 +54,11 @@ internal val SmartChannels = listOf(
|
||||
SuggestionRule("movie", "Movie Night", "Movie", listOf("Animation", "Action"), 1985..2015, 7f, setOf("NC-17", "X"), 30, setOf("Documentary", "Family"), 60),
|
||||
SuggestionRule("day", "Daytime", "Series", listOf("Animation", "Action"), 1985..2015, 7f, setOf("TV-MA"), 30),
|
||||
SuggestionRule("night", "Evening", "Series", listOf("Anime", "Action"), 1985..2020, 7f, setOf("TV-MA"), 30))),
|
||||
ChannelProgramming(140, "Terra", listOf("The Blue Planet", "Blue Planet II", "Planet Earth", "Planet Earth II", "Planet Earth III", "Frozen Planet", "Frozen Planet II",
|
||||
ChannelProgramming(201, "Terra", listOf("The Blue Planet", "Blue Planet II", "Planet Earth", "Planet Earth II", "Planet Earth III", "Frozen Planet", "Frozen Planet II",
|
||||
"Life on Earth", "The Living Planet", "The Trials of Life", "Our Planet", "Our Planet II", "Dynasties", "Dynasties II", "Seven Worlds, One Planet", "A Perfect Planet",
|
||||
"Hostile Planet", "Africa", "Wild China", "South Pacific", "Great Barrier Reef", "The Hunt", "The Life of Mammals", "The Life of Birds", "Nature's Great Events", "Green Planet", "Prehistoric Planet"),
|
||||
seriesCount = 20, finishTogether = true, exactTitles = true),
|
||||
ChannelProgramming(152, "Paradox", ChannelPresets.first { it.number == 106 }.searches)) +
|
||||
ChannelProgramming(106, "Paradox", ChannelPresets.first { it.number == 106 }.searches)) +
|
||||
ChannelPresets.filter { it.smartOnly }.map { ChannelProgramming(it.number, it.name, it.searches, seriesCount = 60, finishTogether = !it.films, exactTitles = true,
|
||||
filmRestMs = if (it.films) 7 * 24 * 60 * 60_000L else null,
|
||||
suggestionRules = SmartChannelRules[it.number].orEmpty(), dayParts = SmartChannelParts[it.number].orEmpty()) }
|
||||
|
||||
@@ -66,7 +66,7 @@ internal class HttpsEmbyTransport(internal val deviceId: String = UUID.randomUUI
|
||||
connection.connectTimeout = 10_000
|
||||
connection.readTimeout = request.readTimeoutMs ?: if (request.path == "/Sessions/Logout") 5_000 else 15_000
|
||||
connection.setRequestProperty("Accept", "application/json")
|
||||
connection.setRequestProperty("X-Emby-Authorization", "Emby Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.72.0\"")
|
||||
connection.setRequestProperty("X-Emby-Authorization", "Emby Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.73.0\"")
|
||||
request.token?.let { connection.setRequestProperty("X-Emby-Token", it) }
|
||||
if (request.method == "POST") {
|
||||
val bytes = request.body.orEmpty().toByteArray(Charsets.UTF_8)
|
||||
|
||||
@@ -21,6 +21,7 @@ import androidx.compose.foundation.text.input.TextObfuscationMode
|
||||
import androidx.compose.foundation.text.input.maxLength
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.focus.FocusRequester
|
||||
import androidx.compose.ui.focus.focusRequester
|
||||
@@ -32,6 +33,7 @@ import androidx.compose.ui.platform.LocalDensity
|
||||
import androidx.compose.ui.platform.LocalFocusManager
|
||||
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.input.ImeAction
|
||||
import androidx.compose.ui.text.input.KeyboardType
|
||||
import androidx.compose.ui.unit.dp
|
||||
@@ -53,7 +55,7 @@ private const val RESTORE_QUIET_TRIES = 4
|
||||
@Composable
|
||||
internal fun EmbyConnectionScreen(modifier: Modifier = Modifier, visible: Boolean,
|
||||
mainGuide: Boolean, mainHome: Boolean = false, mainDriveIn: Boolean = false, onChannelAvailable: (Boolean) -> Unit, onRestoreChecked: () -> Unit = {}, onGuide: () -> Unit,
|
||||
onHome: () -> Unit = {}, onDriveIn: () -> Unit = {}, onBack: () -> Unit) {
|
||||
onHome: () -> Unit = {}, onDriveIn: () -> Unit = {}) {
|
||||
val appContext = androidx.compose.ui.platform.LocalContext.current.applicationContext
|
||||
val savedStore = remember { RememberedConnectionStore.get(appContext) }
|
||||
var setupSaved by remember { mutableStateOf(false) }
|
||||
@@ -68,23 +70,12 @@ internal fun EmbyConnectionScreen(modifier: Modifier = Modifier, visible: Boolea
|
||||
var busy by remember { mutableStateOf(false) }
|
||||
var seriesMatches by remember { mutableStateOf<List<SeriesMatches>?>(null) }
|
||||
var episodeSamples by remember { mutableStateOf<List<SeriesEpisodes>?>(null) }
|
||||
var reviewingSeries by remember { mutableStateOf(false) }
|
||||
var approvedSeries by remember { mutableStateOf<Set<String>>(emptySet()) }
|
||||
var sample by remember { mutableStateOf<EmbySample?>(null) }
|
||||
var session by remember { mutableStateOf<EmbySampleSession?>(null) }
|
||||
var playback by remember { mutableStateOf<EmbyPlaybackPlan?>(null) }
|
||||
var darkMovies by remember { mutableStateOf<List<AfterDarkMovie>>(emptyList()) }
|
||||
var approvedDark by remember { mutableStateOf<Set<String>>(emptySet()) }
|
||||
var reviewingDark by remember { mutableStateOf(false) }
|
||||
// Deliberately outside the saved setup: the coverage check changes nothing on this device.
|
||||
var metadataCoverage by remember { mutableStateOf<List<MetadataCoverage>?>(null) }
|
||||
var reviewingCoverage by remember { mutableStateOf(false) }
|
||||
val catalogue = remember { CatalogueStore.get(appContext) }
|
||||
var catalogueSummary by remember { mutableStateOf<CatalogueSummary?>(null) }
|
||||
var catalogueRun by remember { mutableStateOf<String?>(null) }
|
||||
var reviewingCatalogue by remember { mutableStateOf(false) }
|
||||
var reviewingHealth by remember { mutableStateOf(false) }
|
||||
var libraryHealth by remember { mutableStateOf<CatalogueHealth?>(null) }
|
||||
var lastNumber by remember { mutableStateOf<Int?>(null) }
|
||||
var afterDarkChannel by remember { mutableStateOf<SampleChannel?>(null) }
|
||||
var toonamiChannel by remember { mutableStateOf<SampleChannel?>(null) }
|
||||
@@ -106,7 +97,6 @@ internal fun EmbyConnectionScreen(modifier: Modifier = Modifier, visible: Boolea
|
||||
var scheduledChannels by remember { mutableStateOf<Map<Int, ScheduledChannel>>(emptyMap()) }
|
||||
var suggesting by remember { mutableStateOf<ChannelProgramming?>(null) }
|
||||
var suggestions by remember { mutableStateOf<List<Suggestion>>(emptyList()) }
|
||||
var connectionTest by remember { mutableStateOf(false) }
|
||||
var settingsSection by remember { mutableStateOf(SettingsSection.Channels) }
|
||||
var savingSuggestions by remember { mutableStateOf(false) }
|
||||
var tickedSuggestions by remember { mutableStateOf<Set<String>>(emptySet()) }
|
||||
@@ -147,11 +137,11 @@ internal fun EmbyConnectionScreen(modifier: Modifier = Modifier, visible: Boolea
|
||||
try { catalogue.clear() }
|
||||
catch (_: Exception) { message = "The library data could not be removed. Clear Orbit TV app data in Android Settings before leaving this device." }
|
||||
}
|
||||
driveInPlan = null; tickets = emptyMap(); reminder = null; connectionTest = false
|
||||
seriesMatches = null; episodeSamples = null; reviewingSeries = false; approvedSeries = emptySet()
|
||||
darkMovies = emptyList(); approvedDark = emptySet(); reviewingDark = false; afterDarkChannel = null
|
||||
metadataCoverage = null; reviewingCoverage = false; reviewingCatalogue = false; catalogueSummary = null; catalogueRun = null; reviewingHealth = false; libraryHealth = null; lastNumber = null
|
||||
playback = null; session = null; sample = null; channel = null; toonamiChannel = null; extraChannels = emptyList(); scheduledChannels = emptyMap(); selectedNumber = 101; watchingChannel = false
|
||||
driveInPlan = null; tickets = emptyMap(); reminder = null
|
||||
seriesMatches = null; episodeSamples = null; approvedSeries = emptySet()
|
||||
darkMovies = emptyList(); approvedDark = emptySet(); afterDarkChannel = null
|
||||
lastNumber = null
|
||||
session = null; sample = null; channel = null; toonamiChannel = null; extraChannels = emptyList(); scheduledChannels = emptyMap(); selectedNumber = 101; watchingChannel = false
|
||||
onChannelAvailable(false)
|
||||
sessionSlot.clear()?.let { active -> EmbyCleanup.run { active.close() } }
|
||||
}
|
||||
@@ -167,7 +157,7 @@ internal fun EmbyConnectionScreen(modifier: Modifier = Modifier, visible: Boolea
|
||||
DisposableEffect(lifecycle) {
|
||||
val observer = LifecycleEventObserver { _, event ->
|
||||
if (event == Lifecycle.Event.ON_STOP) {
|
||||
clearPassword(); job?.cancel(); playback = null; watchingChannel = false; busy = false
|
||||
clearPassword(); job?.cancel(); watchingChannel = false; busy = false
|
||||
if (session == null && !restoring) sessionSlot.clear()?.let { active -> EmbyCleanup.run { active.close() } }
|
||||
}
|
||||
}
|
||||
@@ -285,7 +275,6 @@ internal fun EmbyConnectionScreen(modifier: Modifier = Modifier, visible: Boolea
|
||||
if (session == null) closeSession()
|
||||
busy = false
|
||||
}
|
||||
playback = null
|
||||
}
|
||||
}
|
||||
LaunchedEffect(mainGuide, mainHome) {
|
||||
@@ -319,7 +308,6 @@ internal fun EmbyConnectionScreen(modifier: Modifier = Modifier, visible: Boolea
|
||||
})
|
||||
}
|
||||
val ready = !busy && !restoring && now >= nextAttemptAt && username.isNotBlank() && password.text.isNotEmpty()
|
||||
playback?.let { plan -> session?.let { active -> EmbyPlaybackDialog(active, plan, onClose = { playback = null }) } }
|
||||
val liveSession = session
|
||||
fun rememberUnplayable(itemId: String) {
|
||||
val active = session ?: return
|
||||
@@ -368,148 +356,9 @@ internal fun EmbyConnectionScreen(modifier: Modifier = Modifier, visible: Boolea
|
||||
return
|
||||
}
|
||||
if (!visible) return
|
||||
if (reviewingHealth) {
|
||||
LibraryHealthScreen(libraryHealth, busy, message, modifier, onRun = {
|
||||
if (!busy) {
|
||||
busy = true; message = null
|
||||
job = scope.launch {
|
||||
try {
|
||||
libraryHealth = withContext(Dispatchers.IO) {
|
||||
val context = coroutineContext
|
||||
catalogue.health { context.ensureActive() }
|
||||
}
|
||||
} catch (cancelled: CancellationException) { throw cancelled }
|
||||
catch (_: Exception) { message = "The check could not finish. Your library data hasn't changed." }
|
||||
finally { busy = false }
|
||||
}
|
||||
}
|
||||
}, onBack = { job?.cancel(); busy = false; reviewingHealth = false })
|
||||
return
|
||||
}
|
||||
if (reviewingCatalogue) {
|
||||
LaunchedEffect(Unit) {
|
||||
try { catalogueSummary = withContext(Dispatchers.IO) { catalogue.summary() } }
|
||||
catch (cancelled: CancellationException) { throw cancelled }
|
||||
catch (_: Exception) { message = "The library data could not be read." }
|
||||
}
|
||||
CatalogueScreen(catalogueSummary, busy, !busy && session != null, message, catalogueRun, modifier, onRun = { everything ->
|
||||
val active = session
|
||||
if (!busy && active != null) {
|
||||
busy = true; message = null; catalogueRun = null
|
||||
job = scope.launch {
|
||||
val started = System.currentTimeMillis()
|
||||
try {
|
||||
val result = withContext(Dispatchers.IO) {
|
||||
val context = coroutineContext
|
||||
var pages = 0
|
||||
active.importCatalogue(catalogue, if (everything) CATALOGUE_PAGES_FULL_RUN else CATALOGUE_PAGES_PER_RUN,
|
||||
pause = { Thread.sleep(CATALOGUE_PAUSE_MS) }, checkActive = { context.ensureActive() },
|
||||
// The summary counts the whole table, so it refreshes every few pages, not on each one.
|
||||
onPage = { if (++pages % 5 == 0) { val latest = catalogue.summary(); scope.launch { catalogueSummary = latest; message = null } } },
|
||||
backoff = { attempt -> Thread.sleep(CATALOGUE_BACKOFF_MS * attempt) },
|
||||
onRetry = { size -> scope.launch { message = "The provider is slow here. Retrying with $size titles at a time…" } })
|
||||
}
|
||||
message = null
|
||||
catalogueRun = "Last run: ${result.records} titles in ${result.pages} pages, ${(System.currentTimeMillis() - started) / 1000} seconds. Slowest page ${result.slowestMs / 1000} seconds, ${result.pageSize} titles per page."
|
||||
} catch (cancelled: CancellationException) { throw cancelled }
|
||||
catch (failure: EmbyCheckException) { message = failure.message + " Finished pages are saved." }
|
||||
catch (_: Exception) { message = "The import stopped. Finished pages are saved, and it can carry on later." }
|
||||
finally {
|
||||
busy = false
|
||||
// A page already being written when Disconnect was pressed must not survive it.
|
||||
if (session == null) try { catalogue.clear() } catch (_: Exception) { message = "The library data could not be removed. Clear Orbit TV app data in Android Settings before leaving this device." }
|
||||
else try { catalogueSummary = withContext(Dispatchers.IO) { catalogue.summary() } } catch (cancelled: CancellationException) { throw cancelled } catch (_: Exception) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
}, onBack = { job?.cancel(); busy = false; reviewingCatalogue = false }, onHealth = { message = null; reviewingHealth = true })
|
||||
return
|
||||
}
|
||||
if (reviewingCoverage) {
|
||||
MetadataCoverageScreen(metadataCoverage, busy, !busy && session != null && now >= nextAttemptAt, message, modifier, onRun = {
|
||||
val active = session
|
||||
if (!busy && active != null && System.currentTimeMillis() >= nextAttemptAt) {
|
||||
busy = true; message = null
|
||||
nextAttemptAt = System.currentTimeMillis() + 15_000
|
||||
job = scope.launch {
|
||||
try {
|
||||
metadataCoverage = withContext(Dispatchers.IO) {
|
||||
val context = coroutineContext
|
||||
active.checkMetadataCoverage { context.ensureActive() }
|
||||
}
|
||||
} catch (cancelled: CancellationException) { throw cancelled }
|
||||
catch (failure: EmbyCheckException) { message = failure.message }
|
||||
catch (_: Exception) { message = "The metadata check could not finish. Try again later." }
|
||||
finally { busy = false }
|
||||
}
|
||||
}
|
||||
}, onBack = { job?.cancel(); busy = false; reviewingCoverage = false })
|
||||
return
|
||||
}
|
||||
if (reviewingDark) {
|
||||
AfterDarkReviewScreen(darkMovies, approvedDark, busy, message, modifier,
|
||||
onGenre = { genre ->
|
||||
val active = session
|
||||
if (!busy && active != null) {
|
||||
busy = true; message = null
|
||||
job = scope.launch {
|
||||
try {
|
||||
darkMovies = withContext(Dispatchers.IO) { active.checkAfterDarkMovies(genre) }
|
||||
message = "${darkMovies.size} checked films in this sample. If a category has no matches, it may have no results or incomplete genre metadata in its first page."
|
||||
} catch (cancelled: CancellationException) { throw cancelled }
|
||||
catch (failure: EmbyCheckException) { message = failure.message }
|
||||
catch (_: Exception) { message = "The film check could not finish. Try again later." }
|
||||
finally { busy = false }
|
||||
}
|
||||
}
|
||||
}, onToggle = { id ->
|
||||
if (!busy) approvedDark = if (id in approvedDark) approvedDark - id else if (approvedDark.size < 3) approvedDark + id else approvedDark
|
||||
}, onBuild = {
|
||||
val active = session
|
||||
if (!busy && active != null && approvedDark.size in 2..3) {
|
||||
busy = true; message = null
|
||||
job = scope.launch {
|
||||
try {
|
||||
val built = withContext(Dispatchers.IO) {
|
||||
val context = coroutineContext
|
||||
active.buildAfterDarkChannel(approvedDark) { context.ensureActive() }
|
||||
}
|
||||
afterDarkChannel = built; selectedNumber = AFTER_DARK_NUMBER; reviewingDark = false
|
||||
onChannelAvailable(true); onGuide()
|
||||
} catch (cancelled: CancellationException) { throw cancelled }
|
||||
catch (failure: EmbyCheckException) { message = failure.message }
|
||||
catch (_: Exception) { message = "After Dark could not be prepared. Try again later." }
|
||||
finally { busy = false }
|
||||
}
|
||||
}
|
||||
}, onBack = { job?.cancel(); busy = false; reviewingDark = false })
|
||||
return
|
||||
}
|
||||
fun buildPreset(preset: ChannelPreset) {
|
||||
val active = session ?: return
|
||||
if (busy) return
|
||||
busy = true; busyLabel = "Building ${preset.name}. This checks each episode, so it can take a few minutes…"; message = null
|
||||
job = scope.launch {
|
||||
try {
|
||||
val built = withContext(Dispatchers.IO) {
|
||||
val context = coroutineContext
|
||||
active.buildPresetChannel(preset) { context.ensureActive() }
|
||||
}
|
||||
extraChannels = extraChannels.filter { it.number != preset.number } + built.channel
|
||||
selectedNumber = preset.number
|
||||
onChannelAvailable(true)
|
||||
message = "${preset.name} is ready with ${built.channel.lineup.size} episodes from ${built.shows.joinToString()}." +
|
||||
if (built.missing.isEmpty()) "" else " Not found: ${built.missing.joinToString()}."
|
||||
} catch (cancelled: CancellationException) { throw cancelled }
|
||||
catch (failure: EmbyCheckException) { message = failure.message }
|
||||
catch (_: Exception) { message = "${preset.name} could not be built. Try again later." }
|
||||
finally { busy = false }
|
||||
}
|
||||
}
|
||||
fun setSmartSchedule(programming: ChannelProgramming, turnOn: Boolean) {
|
||||
val active = session ?: return
|
||||
val existing = smartLoop(programming)
|
||||
if (existing == null && ChannelPresets.none { it.number == programming.number }) return
|
||||
// A second press straight after the first is taken as a slip.
|
||||
if (busy || now - lastSmartPress < 5_000) return
|
||||
lastSmartPress = now
|
||||
@@ -591,26 +440,6 @@ internal fun EmbyConnectionScreen(modifier: Modifier = Modifier, visible: Boolea
|
||||
finally { busy = false; savingSuggestions = false }
|
||||
}
|
||||
}
|
||||
fun checkMoreSeries() {
|
||||
val active = session ?: return
|
||||
if (busy) return
|
||||
val start = seriesMatches?.size ?: 0
|
||||
if (start >= ToonamiSearches.size) return
|
||||
busy = true; busyLabel = "Checking next five series…"; message = null
|
||||
job = scope.launch {
|
||||
try {
|
||||
val batch = withContext(Dispatchers.IO) {
|
||||
val context = coroutineContext
|
||||
active.checkToonamiSeries(start) { context.ensureActive() }
|
||||
}
|
||||
seriesMatches = seriesMatches.orEmpty() + batch
|
||||
reviewingSeries = true
|
||||
} catch (cancelled: CancellationException) { throw cancelled }
|
||||
catch (failure: EmbyCheckException) { message = failure.message }
|
||||
catch (_: Exception) { message = "The series check could not finish. Try again later." }
|
||||
finally { busy = false }
|
||||
}
|
||||
}
|
||||
suggesting?.let { programming ->
|
||||
SuggestionsScreen(programming, suggestions, tickedSuggestions, busy, message, modifier,
|
||||
onToggle = { id -> tickedSuggestions = if (id in tickedSuggestions) tickedSuggestions - id else tickedSuggestions + id },
|
||||
@@ -620,65 +449,16 @@ internal fun EmbyConnectionScreen(modifier: Modifier = Modifier, visible: Boolea
|
||||
onBack = { if (!savingSuggestions) { job?.cancel(); busy = false }; suggesting = null })
|
||||
return
|
||||
}
|
||||
if (reviewingSeries) {
|
||||
SeriesReviewScreen(seriesMatches.orEmpty(), approvedSeries, episodeSamples, busy, message, modifier,
|
||||
onToggle = { id ->
|
||||
if (!busy) {
|
||||
approvedSeries = if (id in approvedSeries) approvedSeries - id else if (approvedSeries.size < 3) approvedSeries + id else approvedSeries
|
||||
episodeSamples = null
|
||||
}
|
||||
}, onMore = { checkMoreSeries() }, onEpisodes = {
|
||||
val active = session
|
||||
val selected = seriesMatches.orEmpty().flatMap { it.candidates }.distinctBy { it.id }.filter { it.id in approvedSeries }
|
||||
if (!busy && active != null && selected.size in 1..3) {
|
||||
busy = true; message = null; episodeSamples = null
|
||||
job = scope.launch {
|
||||
try {
|
||||
episodeSamples = withContext(Dispatchers.IO) {
|
||||
val context = coroutineContext
|
||||
active.checkSeriesEpisodes(selected) { context.ensureActive() }
|
||||
}
|
||||
} catch (cancelled: CancellationException) { throw cancelled }
|
||||
catch (failure: EmbyCheckException) { message = failure.message }
|
||||
catch (_: Exception) { message = "The episode check could not finish. Try again later." }
|
||||
finally { busy = false }
|
||||
}
|
||||
}
|
||||
}, onBuild = {
|
||||
val active = session
|
||||
if (!busy && active != null && episodeSamples != null) {
|
||||
busy = true; message = null
|
||||
job = scope.launch {
|
||||
try {
|
||||
val built = withContext(Dispatchers.IO) {
|
||||
val context = coroutineContext
|
||||
active.buildToonamiChannel { context.ensureActive() }
|
||||
}
|
||||
toonamiChannel = built; selectedNumber = VORTEX_NUMBER
|
||||
reviewingSeries = false; onChannelAvailable(true); onGuide()
|
||||
} catch (cancelled: CancellationException) { throw cancelled }
|
||||
catch (failure: EmbyCheckException) { message = failure.message }
|
||||
catch (_: Exception) { message = "Vortex could not be prepared. Try again later." }
|
||||
finally { busy = false }
|
||||
}
|
||||
}
|
||||
}, onBack = { job?.cancel(); busy = false; reviewingSeries = false })
|
||||
return
|
||||
}
|
||||
if (session != null && !connectionTest) {
|
||||
if (session != null) {
|
||||
SettingsScreen(settingsSection, { settingsSection = it }, modifier, busy, message, HttpsEmbyTransport.SERVER, sample?.total,
|
||||
isOn = { scheduledChannels.containsKey(it) }, canStart = { smartLoop(it) != null || ChannelPresets.any { preset -> preset.number == it.number } },
|
||||
onSwitch = { programming, on -> setSmartSchedule(programming, on) }, onSuggestions = { openSuggestions(it) },
|
||||
onSignOut = { job?.cancel(); closeSession(forget = true) }, onCoverage = { message = null; reviewingCoverage = true }, onImport = { message = null; reviewingCatalogue = true },
|
||||
onConnectionTest = { message = null; connectionTest = true })
|
||||
isOn = { scheduledChannels.containsKey(it) }, onSwitch = { programming, on -> setSmartSchedule(programming, on) }, onSuggestions = { openSuggestions(it) },
|
||||
onSignOut = { job?.cancel(); closeSession(forget = true) })
|
||||
return
|
||||
}
|
||||
BackHandler(connectionTest) { connectionTest = false }
|
||||
Row(modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(24.dp)) {
|
||||
Column(Modifier.weight(1f).fillMaxHeight().verticalScroll(rememberScrollState()), verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
Text("Connect Emby", color = Yellow, fontSize = 27.sp)
|
||||
Text(HttpsEmbyTransport.SERVER, color = Muted, fontSize = 15.sp)
|
||||
Text("Sign in for a 20-item playback sample, then create your TV channel.", color = Color.White, fontSize = 16.sp)
|
||||
Box(modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
|
||||
Column(Modifier.width(460.dp).verticalScroll(rememberScrollState()), verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
Text("Sign in to Emby", color = Color.White, fontSize = 26.sp, fontWeight = FontWeight.SemiBold)
|
||||
Text(HttpsEmbyTransport.SERVER, color = Muted, fontSize = 14.sp)
|
||||
Text("Username", color = Muted, fontSize = 14.sp)
|
||||
var userFocused by remember { mutableStateOf(false) }
|
||||
BasicTextField(value = username, onValueChange = { if (it.length <= 256) username = it.replace("\n", "") },
|
||||
@@ -711,7 +491,7 @@ internal fun EmbyConnectionScreen(modifier: Modifier = Modifier, visible: Boolea
|
||||
true
|
||||
} else false
|
||||
}.padding(12.dp))
|
||||
OrbitButton(if (busy) "Checking connection…" else if (now < nextAttemptAt) "Wait before trying again" else "Check 20 items",
|
||||
OrbitButton(if (busy) "Signing in…" else if (now < nextAttemptAt) "Wait before trying again" else "Sign in",
|
||||
Modifier.fillMaxWidth().focusRequester(submitFocus), enabled = ready, onClick = {
|
||||
if (!ready) return@OrbitButton
|
||||
val loginName = username.trim()
|
||||
@@ -738,95 +518,17 @@ internal fun EmbyConnectionScreen(modifier: Modifier = Modifier, visible: Boolea
|
||||
}
|
||||
catch (cancelled: CancellationException) { throw cancelled }
|
||||
catch (failure: EmbyCheckException) { message = failure.message }
|
||||
catch (_: Exception) { message = "The connection check could not finish. Try again later." }
|
||||
catch (_: Exception) { message = "Signing in couldn't finish. Try again later." }
|
||||
finally { busy = false }
|
||||
}
|
||||
})
|
||||
Text("This device remembers the session token and channel choices using encrypted storage. Your password is never saved.", color = Muted, fontSize = 13.sp)
|
||||
if (setupSaved && session != null) Text("Setup saved on this device", color = Yellow, fontSize = 14.sp)
|
||||
if (session != null) OrbitButton("Disconnect", Modifier.fillMaxWidth(), onClick = { job?.cancel(); closeSession(forget = true) })
|
||||
if (session == null && pendingSaved?.identity?.token != null)
|
||||
OrbitButton("Retry saved connection", Modifier.fillMaxWidth(), enabled = !restoring && !busy,
|
||||
onClick = { restoreAttempt++ })
|
||||
if (session == null && pendingSaved != null)
|
||||
OrbitButton("Forget saved connection", Modifier.fillMaxWidth(), enabled = !restoring && !busy,
|
||||
onClick = { closeSession(forget = true) })
|
||||
if (restoring) Text("Restoring saved connection…", color = Yellow, fontSize = 14.sp)
|
||||
OrbitButton(if (connectionTest) "Return to Settings" else "Return to Menu", Modifier.fillMaxWidth(), onClick = { if (connectionTest) connectionTest = false else onBack() })
|
||||
}
|
||||
Column(Modifier.weight(1.15f).fillMaxHeight().background(Panel).padding(16.dp)) {
|
||||
Text(if (sample != null) "Sample received" else "Connection check", color = Yellow, fontSize = 24.sp)
|
||||
Spacer(Modifier.height(10.dp))
|
||||
val result = sample
|
||||
when {
|
||||
busy && result == null -> Text(busyLabel, color = Color.White, fontSize = 18.sp)
|
||||
message != null && result == null -> Text(message.orEmpty(), color = Color.White, fontSize = 18.sp)
|
||||
result != null -> {
|
||||
if (busy) Text(busyLabel, color = Yellow, fontSize = 14.sp)
|
||||
message?.let { Text(it, color = Yellow, fontSize = 14.sp) }
|
||||
Text("${result.items.size} records received${result.total?.let { " • $it available to this account" }.orEmpty()}", color = Color.White, fontSize = 16.sp)
|
||||
Text("Select a title, or create one channel from up to three playable titles.", color = Muted, fontSize = 13.sp)
|
||||
OrbitButton("Channels", Modifier.fillMaxWidth(), enabled = !busy && session != null, onClick = { message = null; settingsSection = SettingsSection.Channels; connectionTest = false })
|
||||
OrbitButton(if (channel == null) "Create sample channel" else "Open TV Guide",
|
||||
Modifier.fillMaxWidth(), enabled = !busy && session != null, onClick = {
|
||||
if (channel != null) { selectedNumber = 101; onGuide() } else {
|
||||
val active = session ?: return@OrbitButton
|
||||
busyLabel = "Preparing your channel…"; busy = true; message = null
|
||||
job = scope.launch {
|
||||
try {
|
||||
channel = withContext(Dispatchers.IO) { active.buildSampleChannel() }
|
||||
selectedNumber = 101
|
||||
onChannelAvailable(true)
|
||||
onGuide()
|
||||
} catch (cancelled: CancellationException) { throw cancelled }
|
||||
catch (failure: EmbyCheckException) { message = failure.message }
|
||||
catch (_: Exception) { message = "The sample channel could not be created. Try again later." }
|
||||
finally { busy = false }
|
||||
}
|
||||
}
|
||||
})
|
||||
OrbitButton("$AFTER_DARK_NUMBER Orbit After Dark — choose films", Modifier.fillMaxWidth(),
|
||||
enabled = !busy && session != null, onClick = { message = null; reviewingDark = true })
|
||||
OrbitButton(if (seriesMatches == null) "$VORTEX_NUMBER Vortex — check shortlist" else "$VORTEX_NUMBER Vortex — review matches",
|
||||
Modifier.fillMaxWidth(), enabled = !busy && session != null, onClick = {
|
||||
if (seriesMatches != null) reviewingSeries = true else checkMoreSeries()
|
||||
})
|
||||
ChannelPresets.filterNot { it.smartOnly }.forEach { preset ->
|
||||
val built = extraChannels.any { it.number == preset.number }
|
||||
OrbitButton("${preset.number} ${preset.name} — ${if (built) "rebuild" else "build"}", Modifier.fillMaxWidth(),
|
||||
enabled = !busy && session != null, onClick = { buildPreset(preset) })
|
||||
}
|
||||
OrbitButton("Check metadata coverage", Modifier.fillMaxWidth(),
|
||||
enabled = !busy && session != null, onClick = { message = null; reviewingCoverage = true })
|
||||
OrbitButton("Library import test", Modifier.fillMaxWidth(),
|
||||
enabled = !busy && session != null, onClick = { message = null; reviewingCatalogue = true })
|
||||
Spacer(Modifier.height(8.dp))
|
||||
if (result.items.isEmpty()) Text("No movies or episodes were returned for this account.", color = Color.White, fontSize = 17.sp)
|
||||
LazyColumn(verticalArrangement = Arrangement.spacedBy(6.dp)) {
|
||||
itemsIndexed(result.items) { index, item ->
|
||||
var focused by remember { mutableStateOf(false) }
|
||||
Column(Modifier.fillMaxWidth().onFocusChanged { focused = it.isFocused }
|
||||
.border(1.dp, if (focused) Yellow else Blue).clickable(enabled = session != null) {
|
||||
if (busy) return@clickable
|
||||
val active = session ?: return@clickable
|
||||
busyLabel = "Preparing selected title…"; busy = true; message = null
|
||||
job = scope.launch {
|
||||
try { playback = withContext(Dispatchers.IO) { active.prepare(item) } }
|
||||
catch (cancelled: CancellationException) { throw cancelled }
|
||||
catch (failure: EmbyCheckException) { message = failure.message }
|
||||
catch (_: Exception) { message = "This sample could not be opened. Try another title." }
|
||||
finally { busy = false }
|
||||
}
|
||||
}.padding(10.dp)) {
|
||||
Text("${index + 1}. ${item.title}", color = Color.White, fontSize = 17.sp, maxLines = 2)
|
||||
Text(listOf(item.type, item.minutes?.let { "$it min" }.orEmpty(), item.format)
|
||||
.filter { it.isNotBlank() }.joinToString(" • "), color = Muted, fontSize = 13.sp)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else -> Text("Enter your provider login on the TV. Read a small sample, then create Orbit One in the main TV Guide.", color = Muted, fontSize = 18.sp)
|
||||
}
|
||||
message?.let { Text(it, color = Yellow, fontSize = 14.sp, maxLines = 4) }
|
||||
if (restoring) Text("Restoring your saved connection…", color = Yellow, fontSize = 14.sp)
|
||||
if (pendingSaved?.identity?.token != null)
|
||||
OrbitButton("Try the saved connection again", Modifier.fillMaxWidth(), enabled = !restoring && !busy, onClick = { restoreAttempt++ })
|
||||
if (pendingSaved != null)
|
||||
OrbitButton("Forget the saved connection", Modifier.fillMaxWidth(), enabled = !restoring && !busy, onClick = { closeSession(forget = true) })
|
||||
Text("Your password is never saved. This box only keeps a sign-in token, in encrypted storage.", color = Muted, fontSize = 12.sp)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
package tv.orbit.classic
|
||||
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.focus.FocusRequester
|
||||
import androidx.compose.ui.focus.focusRequester
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.tv.material3.Text
|
||||
import java.util.Locale
|
||||
|
||||
private fun whole(value: Long) = String.format(Locale.UK, "%,d", value)
|
||||
private fun pairs(items: List<Pair<String, Long>>) = items.joinToString(" • ") { "${it.first} ${whole(it.second)}" }
|
||||
|
||||
@Composable
|
||||
internal fun LibraryHealthScreen(health: CatalogueHealth?, busy: Boolean, message: String?, modifier: Modifier, onRun: () -> Unit, onBack: () -> Unit) {
|
||||
BackHandler(onBack = onBack)
|
||||
val backFocus = remember { FocusRequester() }
|
||||
LaunchedEffect(Unit) { backFocus.requestFocus() }
|
||||
Column(modifier.fillMaxWidth().background(Navy).padding(18.dp), verticalArrangement = Arrangement.spacedBy(6.dp)) {
|
||||
Text("Library health check", color = Yellow, fontSize = 26.sp)
|
||||
Text("Read-only, using the details saved on this box. Nothing is changed and nothing goes over the network.", color = Color.White, fontSize = 15.sp)
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
OrbitButton(if (busy) "Checking…" else if (health == null) "Run check" else "Run again", enabled = !busy, onClick = onRun)
|
||||
OrbitButton("Back", Modifier.focusRequester(backFocus), onClick = onBack)
|
||||
}
|
||||
message?.let { Text(it, color = Yellow, fontSize = 15.sp, maxLines = 2) }
|
||||
health?.let { h ->
|
||||
Column(Modifier.fillMaxWidth().background(Panel).padding(10.dp), verticalArrangement = Arrangement.spacedBy(3.dp)) {
|
||||
Text("${whole(h.titles)} titles: ${whole(h.distinctById)} different by external ID, ${whole(h.distinctByTitle)} by title and year", color = Color.White, fontSize = 17.sp)
|
||||
Text("Likely extra copies by ID: ${whole(h.repeatedById)} • no ID: ${whole(h.withoutId)}", color = Color.White, fontSize = 15.sp)
|
||||
Text(pairs(h.decades), color = Muted, fontSize = 13.sp, maxLines = 2)
|
||||
Text("Genres: ${pairs(h.genres)}", color = Muted, fontSize = 13.sp, maxLines = 2)
|
||||
Text("Tags: ${pairs(h.tags)}", color = Muted, fontSize = 13.sp, maxLines = 2)
|
||||
}
|
||||
Column(Modifier.fillMaxWidth().background(Panel).padding(10.dp), verticalArrangement = Arrangement.spacedBy(2.dp)) {
|
||||
Text("Full pass ${whole(h.scanMs)} ms • database ${whole(h.bytes / 1024)} KB", color = Color.White, fontSize = 15.sp)
|
||||
Text(h.timings.joinToString(" • ") { "${it.label}: ${whole(it.count)} in ${whole(it.ms)} ms" }, color = Muted, fontSize = 13.sp, maxLines = 3)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,31 +5,26 @@ import android.view.WindowManager
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Alignment
|
||||
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.Color
|
||||
import androidx.compose.ui.graphics.ColorFilter
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.text.font.Font
|
||||
import androidx.compose.ui.text.font.FontFamily
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.compose.ui.viewinterop.AndroidView
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.LifecycleEventObserver
|
||||
import androidx.lifecycle.compose.LocalLifecycleOwner
|
||||
import androidx.media3.common.MediaItem
|
||||
import androidx.media3.common.Player
|
||||
import androidx.media3.common.PlaybackException
|
||||
import androidx.media3.exoplayer.ExoPlayer
|
||||
import androidx.media3.ui.PlayerView
|
||||
import androidx.tv.material3.MaterialTheme
|
||||
import androidx.tv.material3.Text
|
||||
import kotlinx.coroutines.delay
|
||||
@@ -37,12 +32,12 @@ import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
|
||||
internal val Barlow = FontFamily(Font(R.font.barlow_regular), Font(R.font.barlow_semibold, FontWeight.SemiBold), Font(R.font.barlow_semibold, FontWeight.Bold))
|
||||
internal val Navy = Color(0xFF071632)
|
||||
internal val Panel = Color(0xFF12356B)
|
||||
internal val Blue = Color(0xFF194C91)
|
||||
internal val Yellow = Color(0xFFFFDE59)
|
||||
internal val Muted = Color(0xFFB7CBE8)
|
||||
private fun elapsed(time: Long): String = "%02d:%02d".format(Locale.UK, time / 60000, (time / 1000) % 60)
|
||||
internal fun clock(time: Long) = SimpleDateFormat("HH:mm", Locale.UK).format(Date(time))
|
||||
|
||||
class MainActivity : ComponentActivity() {
|
||||
@@ -73,192 +68,44 @@ private fun OrbitApp() {
|
||||
LaunchedEffect(Unit) { while (true) { now = System.currentTimeMillis(); delay(1000) } }
|
||||
var realChannelAvailable by remember { mutableStateOf(false) }
|
||||
var section by remember { mutableStateOf("Home") }
|
||||
// The demo guide is only for a box with no saved channels, so it waits until that's known.
|
||||
var restoreChecked by remember { mutableStateOf(false) }
|
||||
val showDemo = section == "TV Guide" && !realChannelAvailable && restoreChecked
|
||||
var tuned by remember { mutableIntStateOf(0) }
|
||||
var fullscreen by remember { mutableStateOf(false) }
|
||||
var selectedChannel by remember { mutableIntStateOf(0) }
|
||||
var selectedColumn by remember { mutableIntStateOf(0) }
|
||||
val selected = Schedule.guide(Schedule.channels[selectedChannel], now)[selectedColumn]
|
||||
var pinned by remember { mutableStateOf(false) }
|
||||
val tabFocus = remember { List(3) { FocusRequester() } }
|
||||
val gearFocus = remember { FocusRequester() }
|
||||
LaunchedEffect(realChannelAvailable, restoreChecked) {
|
||||
if (!realChannelAvailable && restoreChecked && section == "Home") section = "TV Guide"
|
||||
// Channels that come back after a provider outage replace the demo guide with the main menu.
|
||||
if (realChannelAvailable && section == "TV Guide") section = "Home"
|
||||
}
|
||||
val programme = Schedule.programme(Schedule.channels[tuned], now)
|
||||
val context = androidx.compose.ui.platform.LocalContext.current
|
||||
val player = remember { ExoPlayer.Builder(context).build().apply {
|
||||
setMediaItem(MediaItem.fromUri("asset:///orbit-demo.mp4")); prepare(); playWhenReady = true
|
||||
} }
|
||||
DisposableEffect(player) { onDispose { player.release() } }
|
||||
var playbackError by remember { mutableStateOf<String?>(null) }
|
||||
DisposableEffect(player) {
|
||||
val listener = object : Player.Listener {
|
||||
override fun onPlayerError(error: PlaybackException) { playbackError = "Demo video could not play. Return to the guide and try again." }
|
||||
override fun onPlaybackStateChanged(state: Int) { if (state == Player.STATE_READY) playbackError = null }
|
||||
}
|
||||
player.addListener(listener)
|
||||
onDispose { player.removeListener(listener) }
|
||||
}
|
||||
// With nothing to watch yet, the only place to be is signing in or choosing channels.
|
||||
LaunchedEffect(realChannelAvailable, restoreChecked) { if (!realChannelAvailable && restoreChecked) section = "Connect Emby" }
|
||||
val lifecycle = LocalLifecycleOwner.current.lifecycle
|
||||
DisposableEffect(player, lifecycle, section, fullscreen, realChannelAvailable, showDemo) {
|
||||
DisposableEffect(lifecycle, section, realChannelAvailable) {
|
||||
val observer = LifecycleEventObserver { _, event ->
|
||||
if (event == Lifecycle.Event.ON_STOP) {
|
||||
player.pause()
|
||||
// Opening the app always lands on the main menu, wherever it was left.
|
||||
if (realChannelAvailable && section != "Connect Emby") section = "Home"
|
||||
}
|
||||
if (event == Lifecycle.Event.ON_START && (showDemo || fullscreen)) player.play()
|
||||
// Opening the app always lands on the main menu, wherever it was left.
|
||||
if (event == Lifecycle.Event.ON_STOP && realChannelAvailable && section != "Connect Emby") section = "Home"
|
||||
}
|
||||
lifecycle.addObserver(observer)
|
||||
onDispose { lifecycle.removeObserver(observer) }
|
||||
}
|
||||
LaunchedEffect(section, fullscreen, showDemo) {
|
||||
if (showDemo || fullscreen) player.play() else player.pause()
|
||||
}
|
||||
LaunchedEffect(tuned, programme.start) {
|
||||
player.seekTo(programme.offsetAt(System.currentTimeMillis())); if (showDemo || fullscreen) player.play()
|
||||
}
|
||||
// Recheck on resume: a stopped app must rejoin the wall-clock schedule.
|
||||
DisposableEffect(lifecycle, tuned) {
|
||||
val observer = LifecycleEventObserver { _, event ->
|
||||
if (event == Lifecycle.Event.ON_RESUME) {
|
||||
val time = System.currentTimeMillis()
|
||||
player.seekTo(Schedule.programme(Schedule.channels[tuned], time).offsetAt(time))
|
||||
}
|
||||
}
|
||||
lifecycle.addObserver(observer)
|
||||
onDispose { lifecycle.removeObserver(observer) }
|
||||
}
|
||||
// Back on the main menu, or on the demo guide, closes the app.
|
||||
BackHandler(fullscreen || pinned || (section != "TV Guide" && section != "Home")) {
|
||||
when { fullscreen -> fullscreen = false; pinned -> pinned = false; section == "Services" || section == "Connect Emby" -> section = if (realChannelAvailable) "Home" else "Menu"; else -> section = if (realChannelAvailable) "Home" else "TV Guide" }
|
||||
}
|
||||
LaunchedEffect(section, fullscreen, realChannelAvailable, restoreChecked) {
|
||||
if (!fullscreen && restoreChecked) {
|
||||
if (!realChannelAvailable) {
|
||||
val tab = when (section) { "TV Guide" -> 1; "Drive-In" -> 2; else -> 0 }
|
||||
tabFocus[tab].requestFocus()
|
||||
} else if (section != "Home" && section != "TV Guide" && section != "Drive-In" && section != "Connect Emby") gearFocus.requestFocus()
|
||||
}
|
||||
}
|
||||
// Back on the main menu closes the app.
|
||||
BackHandler(realChannelAvailable && section != "TV Guide" && section != "Home") { section = "Home" }
|
||||
Box(Modifier.fillMaxSize().background(Navy)) {
|
||||
if (fullscreen) {
|
||||
Video(player, Modifier.fillMaxSize())
|
||||
Column(Modifier.align(Alignment.BottomStart).fillMaxWidth().background(Navy.copy(alpha = .92f)).padding(24.dp)) {
|
||||
Text("${Schedule.channels[tuned].number} ${Schedule.channels[tuned].name}", color = Yellow, fontSize = 20.sp)
|
||||
Text(programme.title, color = Color.White, fontSize = 26.sp, fontWeight = FontWeight.Bold)
|
||||
Text(playbackError ?: "${clock(programme.start)}–${clock(programme.end)} • Demo signal ${elapsed(player.currentPosition)} / 30:00 • Back for guide", color = Muted, fontSize = 15.sp)
|
||||
}
|
||||
} else Column(if (section == "Drive-In" && realChannelAvailable) Modifier.fillMaxSize() else Modifier.fillMaxSize().padding(horizontal = 36.dp, vertical = 16.dp)) {
|
||||
// The Drive-In takes the whole screen once there are real films to show.
|
||||
if (section != "Drive-In" || !realChannelAvailable) Row(Modifier.fillMaxWidth(), verticalAlignment = Alignment.CenterVertically) {
|
||||
androidx.compose.foundation.Image(androidx.compose.ui.res.painterResource(R.drawable.orbit_logo), "Orbit", Modifier.width(144.dp).height(36.dp))
|
||||
Spacer(Modifier.weight(1f))
|
||||
Text(SimpleDateFormat("EEE d MMM HH:mm", Locale.UK).format(Date(now)), color = Color.White, fontSize = 17.sp)
|
||||
if (realChannelAvailable) {
|
||||
Spacer(Modifier.width(12.dp))
|
||||
HomeCard(Modifier.size(38.dp, 32.dp), gearFocus, onClick = { section = "Connect Emby"; pinned = false }) { focused ->
|
||||
androidx.compose.foundation.Image(androidx.compose.ui.res.painterResource(R.drawable.orbit_icon_gear), "Settings", Modifier.fillMaxSize().padding(5.dp),
|
||||
colorFilter = if (focused) androidx.compose.ui.graphics.ColorFilter.tint(Navy) else null)
|
||||
}
|
||||
Spacer(Modifier.width(8.dp))
|
||||
// Shown from the design, but there's nothing to select until profiles exist.
|
||||
androidx.compose.foundation.Image(androidx.compose.ui.res.painterResource(R.drawable.orbit_icon_profile), "Profile", Modifier.size(38.dp, 32.dp).background(Panel).padding(5.dp))
|
||||
}
|
||||
}
|
||||
if (section != "Drive-In" || !realChannelAvailable) Spacer(Modifier.height(8.dp))
|
||||
// The numbered tabs only serve the demo guide. With real channels, home and the gear replace them.
|
||||
if (!realChannelAvailable && restoreChecked) {
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(6.dp)) {
|
||||
listOf("Menu", "TV Guide", "Drive-In").forEachIndexed { index, title ->
|
||||
OrbitButton("${index + 1} $title", Modifier.focusRequester(tabFocus[index]),
|
||||
section == title, onClick = { section = title; pinned = false })
|
||||
}
|
||||
}
|
||||
Spacer(Modifier.height(8.dp))
|
||||
}
|
||||
if (!restoreChecked) {
|
||||
Text("Tuning in…", color = Muted, fontSize = 15.sp)
|
||||
} else if (showDemo) {
|
||||
Row(Modifier.fillMaxWidth().height(120.dp), horizontalArrangement = Arrangement.spacedBy(20.dp)) {
|
||||
Box(Modifier.width(256.dp).fillMaxHeight().border(1.dp, Muted)) {
|
||||
Video(player, Modifier.fillMaxSize())
|
||||
Text(if (playbackError == null) "Demo transmission" else "Video unavailable", Modifier.align(Alignment.BottomStart).background(Navy).padding(5.dp), color = Yellow, fontSize = 12.sp)
|
||||
}
|
||||
Column(Modifier.weight(1f)) {
|
||||
Text(if (pinned) "Programme information" else "${Schedule.channels[selectedChannel].name} / ${clock(selected.start)}–${clock(selected.end)}", color = Yellow, fontSize = 15.sp)
|
||||
Spacer(Modifier.height(6.dp))
|
||||
Text(selected.title, color = Color.White, fontSize = 21.sp, fontWeight = FontWeight.Bold)
|
||||
Spacer(Modifier.height(6.dp))
|
||||
Text(selected.synopsis, color = Muted, fontSize = 16.sp)
|
||||
Spacer(Modifier.weight(1f))
|
||||
Text(if (pinned) "Future programme • Back to browse" else "All programmes and video in this prototype are fictional.", color = Muted, fontSize = 12.sp)
|
||||
}
|
||||
}
|
||||
Spacer(Modifier.height(8.dp))
|
||||
Row(Modifier.fillMaxWidth().background(Blue).padding(vertical = 6.dp)) {
|
||||
Text("Channel", Modifier.width(170.dp).padding(start = 12.dp), color = Color.White, fontSize = 14.sp)
|
||||
repeat(3) { Text(clock(Math.floorDiv(now, Schedule.SLOT) * Schedule.SLOT + it * Schedule.SLOT), Modifier.weight(1f).padding(start = 12.dp), color = Color.White, fontSize = 14.sp) }
|
||||
}
|
||||
Column(Modifier.weight(1f).verticalScroll(rememberScrollState()), verticalArrangement = Arrangement.spacedBy(5.dp)) {
|
||||
Schedule.channels.forEachIndexed { channelIndex, channel ->
|
||||
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(5.dp), verticalAlignment = Alignment.CenterVertically) {
|
||||
Column(Modifier.width(165.dp).padding(start = 12.dp)) {
|
||||
Text(channel.number.toString(), color = Yellow, fontSize = 15.sp)
|
||||
Text(channel.name, color = Color.White, fontSize = 16.sp)
|
||||
}
|
||||
Schedule.guide(channel, now).forEachIndexed { columnIndex, show ->
|
||||
OrbitButton(show.title, Modifier.weight(1f), onFocus = {
|
||||
selectedColumn = columnIndex; selectedChannel = channelIndex; pinned = false
|
||||
}, onClick = {
|
||||
selectedColumn = columnIndex; selectedChannel = channelIndex
|
||||
if (now >= show.start && now < show.end) {
|
||||
tuned = channelIndex; fullscreen = true
|
||||
if (playbackError != null) player.prepare()
|
||||
player.seekTo(show.offsetAt(now)); player.play()
|
||||
} else pinned = true
|
||||
})
|
||||
}
|
||||
// The Drive-In takes the whole screen.
|
||||
Column(if (section == "Drive-In") Modifier.fillMaxSize() else Modifier.fillMaxSize().padding(horizontal = 36.dp, vertical = 16.dp)) {
|
||||
if (section != "Drive-In") {
|
||||
Row(Modifier.fillMaxWidth(), verticalAlignment = Alignment.CenterVertically) {
|
||||
Image(painterResource(R.drawable.orbit_logo), "Orbit", Modifier.width(144.dp).height(36.dp))
|
||||
Spacer(Modifier.weight(1f))
|
||||
Text(SimpleDateFormat("EEE d MMM HH:mm", Locale.UK).format(Date(now)), color = Color.White, fontSize = 17.sp)
|
||||
if (realChannelAvailable) {
|
||||
Spacer(Modifier.width(12.dp))
|
||||
HomeCard(Modifier.size(38.dp, 32.dp), onClick = { section = "Connect Emby" }) { focused ->
|
||||
Image(painterResource(R.drawable.orbit_icon_gear), "Settings", Modifier.fillMaxSize().padding(5.dp), colorFilter = if (focused) ColorFilter.tint(Navy) else null)
|
||||
}
|
||||
}
|
||||
}
|
||||
Text("Arrows Browse OK Watch now / programme info Back Return", color = Muted, fontSize = 13.sp)
|
||||
} else if (section == "Menu") {
|
||||
OrbitMenu(Modifier.weight(1f), onNavigate = { section = it; pinned = false })
|
||||
} else if (section == "Connect Emby") {
|
||||
// Connection content is kept composed below to retain the temporary session.
|
||||
} else if (section == "Drive-In") {
|
||||
if (!realChannelAvailable) DriveIn(Modifier.weight(1f), onGuide = { section = "TV Guide" })
|
||||
} else if (section != "TV Guide" && section != "Home") {
|
||||
Column(Modifier.fillMaxWidth().weight(1f).background(Panel).padding(28.dp)) {
|
||||
Text("Welcome to Orbit Interactive", color = Yellow, fontSize = 27.sp, fontWeight = FontWeight.Bold)
|
||||
Spacer(Modifier.height(20.dp))
|
||||
Text("OrbHive Bedlam is on the roadmap. Games, channel setup and theme selection will live here.", color = Color.White, fontSize = 21.sp)
|
||||
Spacer(Modifier.height(24.dp))
|
||||
Text("Coming later", color = Muted, fontSize = 16.sp)
|
||||
Spacer(Modifier.height(24.dp))
|
||||
OrbitButton("Return to TV Guide", onClick = { section = "TV Guide" })
|
||||
}
|
||||
Spacer(Modifier.height(8.dp))
|
||||
}
|
||||
if (!restoreChecked) Text("Tuning in…", color = Muted, fontSize = 15.sp)
|
||||
EmbyConnectionScreen(Modifier.weight(1f), visible = section == "Connect Emby",
|
||||
mainGuide = section == "TV Guide" && realChannelAvailable,
|
||||
mainHome = section == "Home" && realChannelAvailable,
|
||||
mainDriveIn = section == "Drive-In" && realChannelAvailable,
|
||||
onChannelAvailable = { realChannelAvailable = it }, onRestoreChecked = { restoreChecked = true },
|
||||
onGuide = { section = "TV Guide" }, onHome = { section = "Home" }, onDriveIn = { section = "Drive-In" }, onBack = { section = if (realChannelAvailable) "Home" else "Menu" })
|
||||
onGuide = { section = "TV Guide" }, onHome = { section = "Home" }, onDriveIn = { section = "Drive-In" })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun Video(player: ExoPlayer, modifier: Modifier) {
|
||||
AndroidView(modifier = modifier, factory = { context -> PlayerView(context).apply {
|
||||
useController = false; isFocusable = false; descendantFocusability = android.view.ViewGroup.FOCUS_BLOCK_DESCENDANTS
|
||||
this.player = player
|
||||
} }, update = { it.player = player }, onRelease = { it.player = null })
|
||||
}
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
package tv.orbit.classic
|
||||
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.focus.FocusRequester
|
||||
import androidx.compose.ui.focus.focusRequester
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.tv.material3.Text
|
||||
|
||||
@Composable
|
||||
internal fun MetadataCoverageScreen(coverage: List<MetadataCoverage>?, busy: Boolean, canRun: Boolean, message: String?,
|
||||
modifier: Modifier, onRun: () -> Unit, onBack: () -> Unit) {
|
||||
BackHandler(onBack = onBack)
|
||||
val backFocus = remember { FocusRequester() }
|
||||
LaunchedEffect(Unit) { backFocus.requestFocus() }
|
||||
Column(modifier.fillMaxWidth().background(Navy).padding(18.dp), verticalArrangement = Arrangement.spacedBy(6.dp)) {
|
||||
Text("Metadata coverage", color = Yellow, fontSize = 26.sp)
|
||||
Text("How many items in a small sample carry each detail. Read-only: no titles are shown and nothing is saved or changed.", color = Color.White, fontSize = 15.sp)
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
OrbitButton(if (busy) "Checking…" else if (coverage == null) "Check metadata coverage" else "Check again", enabled = canRun, onClick = onRun)
|
||||
OrbitButton("Back", Modifier.focusRequester(backFocus), onClick = onBack)
|
||||
}
|
||||
message?.let { Text(it, color = Yellow, fontSize = 15.sp, maxLines = 3) }
|
||||
if (coverage != null) {
|
||||
CoverageRow("Sample", coverage.map { sample -> "${sample.checked}${sample.total?.let { " of $it" }.orEmpty()}" }, Yellow)
|
||||
// Two tables side by side: one long list runs off the bottom of the TV with nothing to scroll it.
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
MetadataCoverageLabels.chunked((MetadataCoverageLabels.size + 1) / 2).forEach { labels ->
|
||||
Column(Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(6.dp)) {
|
||||
CoverageRow("", coverage.map { it.label }, Yellow)
|
||||
labels.forEach { label ->
|
||||
CoverageRow(label, coverage.map { sample -> sample.fields.firstOrNull { it.label == label }?.let { "${it.present}/${sample.checked}" } ?: "–" }, Color.White)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Text("This is a sample, not a library total. A zero can mean the provider didn't return that detail for this request.", color = Muted, fontSize = 13.sp)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun CoverageRow(label: String, values: List<String>, color: Color) {
|
||||
Row(Modifier.fillMaxWidth().background(Panel).padding(horizontal = 10.dp, vertical = 2.dp)) {
|
||||
Text(label, Modifier.weight(1.4f), color = Muted, fontSize = 14.sp, maxLines = 1)
|
||||
values.forEach { Text(it, Modifier.weight(1f), color = color, fontSize = 14.sp, maxLines = 1) }
|
||||
}
|
||||
}
|
||||
@@ -1,124 +0,0 @@
|
||||
package tv.orbit.classic
|
||||
|
||||
import androidx.compose.foundation.Canvas
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.geometry.Offset
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.PathEffect
|
||||
import androidx.compose.ui.text.font.Font
|
||||
import androidx.compose.ui.text.font.FontFamily
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.tv.material3.Text
|
||||
|
||||
internal val Barlow = FontFamily(Font(R.font.barlow_regular), Font(R.font.barlow_semibold, FontWeight.SemiBold), Font(R.font.barlow_semibold, FontWeight.Bold))
|
||||
private val TicketType = FontFamily(Font(R.font.barlow_condensed_medium))
|
||||
private val Paper = Color(0xFFF7EAC8)
|
||||
|
||||
internal data class DriveInEvent(val title: String, val collection: String, val time: String,
|
||||
val synopsis: String, val reference: String)
|
||||
internal val driveInEvents = listOf(
|
||||
DriveInEvent("The Last Shuttle Home", "Orbit Marquee", "Tonight at 21:30",
|
||||
"One final journey brings an unlikely crew together. A fictional premiere for your own front-row seat.", "ORB-001"),
|
||||
DriveInEvent("Twin Moons", "Orbit Double Bill", "Tonight from 20:00",
|
||||
"Two films, one long night under two moons. A fictional double feature with an interval between.", "ORB-003"),
|
||||
DriveInEvent("The Far Side Trilogy", "Orbit Triple Bill", "Saturday from 19:00",
|
||||
"Three chapters back to back, for those who brought snacks. A fictional all-evening event.", "ORB-004"),
|
||||
DriveInEvent("Visitors at Dawn", "The Late Show", "Tonight at 23:00",
|
||||
"First contact arrives in the quietest corner of Earth. A fictional late-night science-fiction special.", "ORB-002")
|
||||
)
|
||||
|
||||
@Composable
|
||||
internal fun OrbitMenu(modifier: Modifier = Modifier, onNavigate: (String) -> Unit) {
|
||||
Row(modifier.fillMaxWidth().background(Panel).padding(24.dp), horizontalArrangement = Arrangement.spacedBy(30.dp)) {
|
||||
Column(Modifier.weight(1f)) {
|
||||
Text("Your evening starts here.", color = Yellow, fontFamily = Barlow, fontWeight = FontWeight.SemiBold, fontSize = 30.sp)
|
||||
Spacer(Modifier.height(10.dp))
|
||||
Text("Your collection. Your channels.\nYour television.", color = Color.White, fontFamily = Barlow, fontSize = 24.sp, lineHeight = 29.sp)
|
||||
Spacer(Modifier.weight(1f))
|
||||
Text("Orbit Classic", color = Muted, fontFamily = TicketType, fontSize = 25.sp)
|
||||
Text("The satellite spirit, in your universe.", color = Muted, fontFamily = Barlow, fontSize = 16.sp)
|
||||
}
|
||||
Column(Modifier.weight(1f).align(Alignment.CenterVertically), verticalArrangement = Arrangement.spacedBy(10.dp)) {
|
||||
OrbitButton("Connect Emby / Check a small sample", Modifier.fillMaxWidth(), onClick = { onNavigate("Connect Emby") })
|
||||
OrbitButton("TV Guide / What's on now", Modifier.fillMaxWidth(), onClick = { onNavigate("TV Guide") })
|
||||
OrbitButton("Orbit Drive-In / Special transmissions", Modifier.fillMaxWidth(), onClick = { onNavigate("Drive-In") })
|
||||
OrbitButton("Services / Orbit Interactive", Modifier.fillMaxWidth(), onClick = { onNavigate("Services") })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
internal fun DriveIn(modifier: Modifier = Modifier, onGuide: () -> Unit) {
|
||||
var selectedEvent by remember { mutableIntStateOf(0) }
|
||||
val event = driveInEvents[selectedEvent]
|
||||
Row(modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(24.dp)) {
|
||||
Column(Modifier.weight(1.55f).fillMaxHeight()) {
|
||||
Row(verticalAlignment = Alignment.Bottom) {
|
||||
Text("Orbit Drive-In", color = Yellow, fontFamily = TicketType, fontSize = 36.sp)
|
||||
Text(" Your front-row seat.", color = Muted, fontFamily = Barlow, fontSize = 17.sp, modifier = Modifier.padding(bottom = 5.dp))
|
||||
}
|
||||
Spacer(Modifier.height(10.dp))
|
||||
AdmissionTicket(event, Modifier.fillMaxWidth().weight(1f))
|
||||
Spacer(Modifier.height(8.dp))
|
||||
Text("Preview ticket • Fictional event • Included in your collection", color = Muted, fontFamily = Barlow, fontSize = 13.sp)
|
||||
}
|
||||
Column(Modifier.weight(1f).fillMaxHeight(), verticalArrangement = Arrangement.spacedBy(10.dp)) {
|
||||
Text("Special transmissions", color = Color.White, fontFamily = Barlow, fontWeight = FontWeight.SemiBold, fontSize = 23.sp)
|
||||
driveInEvents.forEachIndexed { index, item ->
|
||||
OrbitButton(item.collection, Modifier.fillMaxWidth(), selected = selectedEvent == index,
|
||||
onFocus = { selectedEvent = index }, onClick = { selectedEvent = index })
|
||||
}
|
||||
Text(event.synopsis, color = Muted, fontFamily = Barlow, fontSize = 18.sp, lineHeight = 23.sp)
|
||||
Spacer(Modifier.weight(1f))
|
||||
Text("Event playback comes with the Emby connection. For now, explore the ticket and the guide.", color = Muted, fontFamily = Barlow, fontSize = 14.sp)
|
||||
OrbitButton("Return to TV Guide", Modifier.fillMaxWidth(), onClick = onGuide)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun AdmissionTicket(event: DriveInEvent, modifier: Modifier = Modifier) {
|
||||
Box(modifier.background(Paper)) {
|
||||
Canvas(Modifier.matchParentSize()) {
|
||||
val seam = size.width * .76f
|
||||
drawLine(Navy.copy(alpha = .45f), Offset(seam, 0f), Offset(seam, size.height),
|
||||
strokeWidth = 1.dp.toPx(), pathEffect = PathEffect.dashPathEffect(floatArrayOf(5.dp.toPx(), 5.dp.toPx())))
|
||||
for (i in 0..11) {
|
||||
val y = (i + .5f) * size.height / 12
|
||||
drawCircle(Navy, 5.dp.toPx(), Offset(0f, y))
|
||||
drawCircle(Navy, 5.dp.toPx(), Offset(size.width, y))
|
||||
}
|
||||
drawCircle(Navy, 9.dp.toPx(), Offset(seam, 0f))
|
||||
drawCircle(Navy, 9.dp.toPx(), Offset(seam, size.height))
|
||||
}
|
||||
Row(Modifier.fillMaxSize()) {
|
||||
Column(Modifier.weight(.76f).fillMaxHeight().padding(horizontal = 22.dp, vertical = 18.dp)) {
|
||||
Text("Drive-In", color = Navy, fontFamily = TicketType, fontSize = 27.sp)
|
||||
Text(event.collection, color = Navy, fontFamily = Barlow, fontSize = 14.sp)
|
||||
Spacer(Modifier.height(14.dp))
|
||||
Text(event.title, color = Navy, fontFamily = TicketType, fontSize = 33.sp, lineHeight = 35.sp, maxLines = 3)
|
||||
Spacer(Modifier.weight(1f))
|
||||
Text(event.time, color = Navy, fontFamily = Barlow, fontWeight = FontWeight.SemiBold, fontSize = 18.sp)
|
||||
Text("One universe. Best seat in the house.", color = Navy.copy(alpha = .75f), fontFamily = Barlow, fontSize = 14.sp)
|
||||
Spacer(Modifier.height(12.dp))
|
||||
Text("Admit one", Modifier.background(Yellow).padding(horizontal = 14.dp, vertical = 5.dp), color = Navy, fontFamily = TicketType, fontSize = 23.sp)
|
||||
}
|
||||
Column(Modifier.weight(.24f).fillMaxHeight().padding(horizontal = 10.dp, vertical = 22.dp), horizontalAlignment = Alignment.CenterHorizontally) {
|
||||
Text("orbit", color = Navy, fontFamily = Barlow, fontWeight = FontWeight.SemiBold, fontSize = 21.sp)
|
||||
Text("Front row", color = Navy, fontFamily = TicketType, fontSize = 19.sp)
|
||||
Spacer(Modifier.weight(1f))
|
||||
Text("01", color = Navy, fontFamily = TicketType, fontSize = 52.sp)
|
||||
Text("Seat", color = Navy, fontFamily = Barlow, fontSize = 14.sp)
|
||||
Spacer(Modifier.weight(1f))
|
||||
Text(event.reference, color = Navy, fontFamily = TicketType, fontSize = 17.sp)
|
||||
Text("Preview", color = Navy.copy(alpha = .65f), fontFamily = Barlow, fontSize = 12.sp)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -97,13 +97,13 @@ internal object RememberedStateCodec {
|
||||
val approvedDark = (0 until darkApproval.length()).map { darkApproval.getString(it) }.toSet()
|
||||
require(approvedDark.all { value -> darkMovies.any { it.item.id == value } })
|
||||
// Absent in files saved before presets existed.
|
||||
val extra = if (!o.has("extra")) emptyList() else list(o, "extra", ChannelPresets.size).map { c ->
|
||||
val number = c.getInt("number").let { if (o.optInt("numbering", 1) >= 2) it else OldChannelNumbers[it] ?: it }; require(ChannelPresets.any { it.number == number })
|
||||
val extra = if (!o.has("extra")) emptyList() else list(o, "extra", SmartChannels.size).map { c ->
|
||||
val number = c.getInt("number").let { if (o.optInt("numbering", 1) >= 2) it else OldChannelNumbers[it] ?: it }; require(SmartChannels.any { it.number == number })
|
||||
readEntries(c, number)
|
||||
}
|
||||
require(extra.map { it.number }.distinct().size == extra.size)
|
||||
val selected = o.optInt("selectedChannel", o.getInt("selected")).let { if (o.optInt("numbering", 1) >= 2) it else OldChannelNumbers[it] ?: it }
|
||||
require(selected == VORTEX_NUMBER || selected == AFTER_DARK_NUMBER || ChannelPresets.any { it.number == selected })
|
||||
require(SmartChannels.any { it.number == selected })
|
||||
return RememberedState(identity, sample, matches, approved, episodes, one, toonami, selected, dark, darkMovies, approvedDark, extra)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,60 +31,6 @@ import kotlinx.coroutines.withContext
|
||||
import kotlinx.coroutines.sync.Mutex
|
||||
import kotlinx.coroutines.sync.withLock
|
||||
|
||||
@Composable
|
||||
internal fun SampleChannelGuide(channel: SampleChannel, modifier: Modifier = Modifier,
|
||||
onTune: (Long) -> Unit, onBack: () -> Unit, otherChannels: List<SampleChannel> = emptyList(), onSwitch: (Int) -> Unit = {}) {
|
||||
var now by remember { mutableLongStateOf(System.currentTimeMillis()) }
|
||||
LaunchedEffect(Unit) { while (true) { delay(1000); now = System.currentTimeMillis() } }
|
||||
val shows = channel.guide(now)
|
||||
val tuneFocus = remember { FocusRequester() }
|
||||
LaunchedEffect(Unit) { tuneFocus.requestFocus() }
|
||||
BackHandler(onBack = onBack)
|
||||
val branding = ChannelBrands.forNumber(channel.number)
|
||||
Box(modifier.fillMaxWidth().background(if (branding != null) Navy else Panel)) {
|
||||
if (branding != null) Image(painterResource(branding.background), null, Modifier.matchParentSize(), contentScale = ContentScale.Crop, alpha = .65f)
|
||||
Column(Modifier.fillMaxSize().padding(18.dp), verticalArrangement = Arrangement.spacedBy(10.dp)) {
|
||||
Row(Modifier.fillMaxWidth(), verticalAlignment = Alignment.CenterVertically) {
|
||||
Text("TV Guide", color = Yellow, fontSize = 26.sp, fontWeight = FontWeight.Bold)
|
||||
Spacer(Modifier.weight(1f))
|
||||
otherChannels.forEach { other -> OrbitButton("${other.number} ${ChannelBrands.displayName(other)}", onClick = { onSwitch(other.number) }) }
|
||||
Text(clock(now), color = Color.White, fontSize = 20.sp)
|
||||
}
|
||||
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(16.dp)) {
|
||||
Column(Modifier.width(125.dp)) {
|
||||
Text(channel.number.toString(), color = Yellow, fontSize = 36.sp, fontWeight = FontWeight.Bold)
|
||||
if (branding != null) Image(painterResource(branding.logo), branding.displayName, Modifier.width(125.dp).height(40.dp))
|
||||
else Text(channel.name, color = Color.White, fontSize = 19.sp)
|
||||
}
|
||||
Column(Modifier.weight(1f)) {
|
||||
Text("NOW ${clock(shows[0].startMs)}–${clock(shows[0].endMs)}", color = Yellow, fontSize = 15.sp)
|
||||
Text(shows[0].media.item.title, color = Color.White, fontSize = 23.sp, maxLines = 2)
|
||||
}
|
||||
Column(Modifier.weight(1f)) {
|
||||
Text("NEXT ${clock(shows[1].startMs)}", color = Muted, fontSize = 15.sp)
|
||||
Text(shows[1].media.item.title, color = Color.White, fontSize = 21.sp, maxLines = 2)
|
||||
}
|
||||
}
|
||||
LazyColumn(Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(6.dp)) {
|
||||
items(shows.drop(1), key = { it.startMs }) { show ->
|
||||
var focused by remember { mutableStateOf(false) }
|
||||
Row(Modifier.fillMaxWidth().onFocusChanged { focused = it.isFocused }.background(Blue)
|
||||
.border(1.dp, if (focused) Yellow else Blue).focusable().padding(10.dp), horizontalArrangement = Arrangement.spacedBy(16.dp)) {
|
||||
Text("${clock(show.startMs)}–${clock(show.endMs)}", color = Yellow, fontSize = 15.sp, modifier = Modifier.width(125.dp))
|
||||
Text(show.media.item.title, color = Color.White, fontSize = 16.sp, maxLines = 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(10.dp)) {
|
||||
OrbitButton("Watch channel", Modifier.focusRequester(tuneFocus), onClick = { onTune(0) })
|
||||
OrbitButton("Check transition", onClick = { onTune(channel.transitionCheckOffset(System.currentTimeMillis())) })
|
||||
OrbitButton("Menu", onClick = onBack)
|
||||
}
|
||||
Text("${channel.lineup.size} titles • Transition check joins near the end and may update your provider’s viewing history.", color = Muted, fontSize = 12.sp)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** A schedule is only true if the file still runs as long as the slot it was given. */
|
||||
internal fun scheduledRuntimeMatches(openedMs: Long?, scheduledMs: Long) = openedMs != null && kotlin.math.abs(openedMs - scheduledMs) <= 2_000
|
||||
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
package tv.orbit.classic
|
||||
|
||||
/** Fixed UTC slots survive process restarts; only display formatting uses local time. */
|
||||
data class Programme(val title: String, val synopsis: String, val start: Long, val duration: Long) {
|
||||
val end: Long get() = start + duration
|
||||
fun offsetAt(now: Long): Long = (now - start).coerceIn(0, duration - 1)
|
||||
}
|
||||
data class Channel(val number: Int, val name: String, val shows: List<Pair<String, String>>)
|
||||
object Schedule {
|
||||
const val SLOT = 1_800_000L
|
||||
val channels = listOf(
|
||||
Channel(101, "Orbit One", listOf(
|
||||
"The Midnight Observatory" to "An astronomer follows a mysterious signal across the night sky.",
|
||||
"Small Town, Big Orbit" to "An eccentric village prepares for its annual space festival.",
|
||||
"Beyond the Blue" to "Explorers chart an ocean beneath an unfamiliar moon.",
|
||||
"The Last Shuttle Home" to "One final journey brings an unlikely crew together.")),
|
||||
Channel(202, "Orbit Sci-Fi", listOf(
|
||||
"Signal from Europa" to "A research team discovers that the ice is listening.",
|
||||
"Starbound Dispatch" to "Stories from the delivery route at the edge of the galaxy.",
|
||||
"Visitors at Dawn" to "First contact arrives in the quietest corner of Earth.",
|
||||
"Station Nine" to "Life, repairs and peculiar neighbours on a remote outpost.")),
|
||||
Channel(401, "Orbit Kids", listOf(
|
||||
"Moonbug Rangers" to "A brave little team protects a very big lunar garden.",
|
||||
"The Comet Club" to "Saturday adventures with the galaxy's most curious friends.",
|
||||
"Rocket Pocket" to "An inventor's tiny rocket causes enormous surprises.",
|
||||
"Planet of Puzzles" to "Every new world has a puzzle waiting to be solved."))
|
||||
)
|
||||
fun programme(channel: Channel, time: Long): Programme {
|
||||
val slot = Math.floorDiv(time, SLOT)
|
||||
val show = channel.shows[Math.floorMod(slot, channel.shows.size.toLong()).toInt()]
|
||||
return Programme(show.first, show.second, slot * SLOT, SLOT)
|
||||
}
|
||||
fun guide(channel: Channel, time: Long, count: Int = 3) =
|
||||
List(count) { programme(channel, time + it * SLOT) }
|
||||
}
|
||||
@@ -33,7 +33,7 @@ internal class SecureMediaDataSource(private val session: EmbySampleSession) : B
|
||||
next.instanceFollowRedirects = false
|
||||
next.connectTimeout = 10_000
|
||||
next.readTimeout = 20_000
|
||||
next.setRequestProperty("User-Agent", "OrbitTV/0.72.0")
|
||||
next.setRequestProperty("User-Agent", "OrbitTV/0.73.0")
|
||||
next.setRequestProperty("Accept-Encoding", "identity")
|
||||
session.mediaHeaders(address).forEach { (key, value) -> next.setRequestProperty(key, value) }
|
||||
if (dataSpec.position != 0L || dataSpec.length != C.LENGTH_UNSET.toLong()) {
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
package tv.orbit.classic
|
||||
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.tv.material3.Text
|
||||
|
||||
@Composable
|
||||
internal fun SeriesReviewScreen(matches: List<SeriesMatches>, approved: Set<String>, episodes: List<SeriesEpisodes>?,
|
||||
busy: Boolean, message: String?, modifier: Modifier,
|
||||
onToggle: (String) -> Unit, onMore: () -> Unit, onEpisodes: () -> Unit, onBuild: () -> Unit, onBack: () -> Unit) {
|
||||
val listState = rememberLazyListState()
|
||||
LaunchedEffect(episodes) { if (episodes != null) listState.scrollToItem(0) }
|
||||
BackHandler(onBack = onBack)
|
||||
Column(modifier.fillMaxWidth().background(Panel).padding(18.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
Text("$VORTEX_NUMBER Vortex / Series check", color = Yellow, fontSize = 26.sp)
|
||||
Text("Choose up to three versions for this sample. Nothing is scheduled yet.", color = Muted, fontSize = 15.sp)
|
||||
if (busy) Text("Preparing sample…", color = Yellow, fontSize = 15.sp)
|
||||
message?.let { Text(it, color = Yellow, fontSize = 15.sp) }
|
||||
LazyColumn(Modifier.weight(1f), state = listState, verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
episodes?.forEach { sample ->
|
||||
item("episodes-${sample.series.id}") {
|
||||
Column(verticalArrangement = Arrangement.spacedBy(4.dp)) {
|
||||
Text("Episode sample / ${sample.series.title} ${sample.series.variantLabel}", color = Yellow, fontSize = 21.sp)
|
||||
if (sample.episodes.isEmpty()) Text("No usable episodes returned in this page.", color = Muted, fontSize = 15.sp)
|
||||
sample.episodes.forEach { episode ->
|
||||
val order = if (episode.season != null && episode.episode != null) "S${episode.season} E${episode.episode}" else "Order unknown"
|
||||
val runtime = episode.durationMs?.let { "${it / 60_000} min" } ?: "Runtime unknown"
|
||||
Text("$order • ${episode.title} • $runtime", color = Color.White, fontSize = 16.sp)
|
||||
if (episode.mediaLabel.isNotBlank()) Text(episode.mediaLabel, color = Muted, fontSize = 14.sp)
|
||||
}
|
||||
Text(if (sample.moreAvailable) "Sample page only; more episodes exist." else "Sample page only.", color = Muted, fontSize = 13.sp)
|
||||
}
|
||||
}
|
||||
}
|
||||
matches.forEachIndexed { groupIndex, group ->
|
||||
item("heading-$groupIndex") {
|
||||
Text(group.requested, color = Yellow, fontSize = 21.sp)
|
||||
if (group.candidates.isEmpty()) Text("No series match returned by this search.", color = Muted, fontSize = 15.sp)
|
||||
if (group.moreAvailable) Text("Showing at most ten results; other versions may exist.", color = Muted, fontSize = 14.sp)
|
||||
}
|
||||
group.candidates.forEach { candidate ->
|
||||
item("$groupIndex-${candidate.id}") {
|
||||
val details = listOfNotNull(candidate.year?.toString(), candidate.rating.takeIf { it.isNotBlank() }, candidate.variantLabel.takeIf { it.isNotBlank() }).joinToString(" • ")
|
||||
Column {
|
||||
OrbitButton("${if (candidate.id in approved) "✓ Approved" else "+ Approve"} ${candidate.title}",
|
||||
Modifier.fillMaxWidth(), selected = candidate.id in approved, enabled = !busy && (candidate.id in approved || approved.size < 3), onClick = { onToggle(candidate.id) })
|
||||
if (details.isNotEmpty()) Text(details, color = Color.White, fontSize = 14.sp)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Text("${matches.size}/${ToonamiSearches.size} searches • ${approved.size}/3 series approved • Sample repeats; direct sources checked before scheduling.", color = Muted, fontSize = 14.sp)
|
||||
if (episodes != null) OrbitButton("Create playable $VORTEX_NUMBER", enabled = !busy, onClick = onBuild)
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
if (matches.size < ToonamiSearches.size) OrbitButton("Check next five series", enabled = !busy, onClick = onMore)
|
||||
OrbitButton("Check sample episodes", enabled = !busy && approved.isNotEmpty(), onClick = onEpisodes)
|
||||
OrbitButton("Back", onClick = onBack)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -37,8 +37,6 @@ internal enum class SettingsSection(val label: String, val icon: Int) {
|
||||
Channels("Channels", R.drawable.orbit_icon_all),
|
||||
Viewing("Watching", R.drawable.orbit_icon_entertainment),
|
||||
Account("Emby account", R.drawable.orbit_icon_profile),
|
||||
Tools("Tools", R.drawable.orbit_icon_gear),
|
||||
About("About", R.drawable.orbit_icon_documentaries)
|
||||
}
|
||||
|
||||
/** The heading a channel number sits under, matching the blocks in the guide. */
|
||||
@@ -78,7 +76,7 @@ private fun SettingLine(title: String, detail: String, button: @Composable () ->
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun ChannelsDetail(busy: Boolean, message: String?, isOn: (Int) -> Boolean, canStart: (ChannelProgramming) -> Boolean,
|
||||
private fun ChannelsDetail(busy: Boolean, message: String?, isOn: (Int) -> Boolean,
|
||||
onSwitch: (ChannelProgramming, Boolean) -> Unit, onSuggestions: (ChannelProgramming) -> Unit, modifier: Modifier) {
|
||||
val all = SmartChannels.sortedBy { it.number }
|
||||
Column(modifier, verticalArrangement = Arrangement.spacedBy(6.dp)) {
|
||||
@@ -96,8 +94,8 @@ private fun ChannelsDetail(busy: Boolean, message: String?, isOn: (Int) -> Boole
|
||||
Text(programming.number.toString(), Modifier.width(30.dp), color = Muted, fontSize = 12.sp, fontWeight = FontWeight.SemiBold)
|
||||
if (brand != null) Image(painterResource(brand.logo), brand.displayName, Modifier.width(88.dp).height(28.dp))
|
||||
Text(brand?.displayName ?: programming.name, Modifier.weight(1f), color = Color.White, fontSize = 14.sp, maxLines = 1, overflow = TextOverflow.Ellipsis)
|
||||
if (programming.suggestionRules.isNotEmpty()) OrbitButton("Add more", enabled = !busy && canStart(programming), onClick = { onSuggestions(programming) })
|
||||
OrbitButton(if (on) "On" else "Off", Modifier.width(64.dp), selected = on, enabled = !busy && canStart(programming), onClick = { onSwitch(programming, !on) })
|
||||
if (programming.suggestionRules.isNotEmpty()) OrbitButton("Add more", enabled = !busy, onClick = { onSuggestions(programming) })
|
||||
OrbitButton(if (on) "On" else "Off", Modifier.width(64.dp), selected = on, enabled = !busy, onClick = { onSwitch(programming, !on) })
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -119,6 +117,8 @@ private fun ViewingDetail(modifier: Modifier) {
|
||||
|
||||
@Composable
|
||||
private fun AccountDetail(server: String, titles: Long?, onSignOut: () -> Unit, modifier: Modifier) {
|
||||
val context = LocalContext.current
|
||||
val version = remember { runCatching { context.packageManager.getPackageInfo(context.packageName, 0).versionName }.getOrNull().orEmpty() }
|
||||
var confirming by remember { mutableStateOf(false) }
|
||||
Column(modifier, verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
SettingLine("Connected", server + (titles?.let { ", $it titles available" }.orEmpty())) {}
|
||||
@@ -133,36 +133,14 @@ private fun AccountDetail(server: String, titles: Long?, onSignOut: () -> Unit,
|
||||
}
|
||||
}
|
||||
} else SettingLine("Sign out", "Disconnect this box from Emby.") { OrbitButton("Sign out", onClick = { confirming = true }) }
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun ToolsDetail(busy: Boolean, onCoverage: () -> Unit, onImport: () -> Unit, onConnectionTest: () -> Unit, modifier: Modifier) {
|
||||
Column(modifier, verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
Text("You won't need these day to day.", color = Muted, fontSize = 13.sp)
|
||||
SettingLine("Check library details", "See how complete the details are for your films and shows.") { OrbitButton("Open", enabled = !busy, onClick = onCoverage) }
|
||||
SettingLine("Library import and health", "Copy your library's titles to this box, and check that copy.") { OrbitButton("Open", enabled = !busy, onClick = onImport) }
|
||||
SettingLine("Connection test", "The early sample of titles, and older ways of building channels.") { OrbitButton("Open", enabled = !busy, onClick = onConnectionTest) }
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun AboutDetail(modifier: Modifier) {
|
||||
val context = LocalContext.current
|
||||
val version = remember { runCatching { context.packageManager.getPackageInfo(context.packageName, 0).versionName }.getOrNull().orEmpty() }
|
||||
Column(modifier, verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
Image(painterResource(R.drawable.orbit_logo), "Orbit", Modifier.width(192.dp).height(48.dp))
|
||||
Text("Your own TV network, from your own Emby library.", color = Color.White, fontSize = 17.sp)
|
||||
Text("Version $version", color = Muted, fontSize = 14.sp)
|
||||
Text("${SmartChannels.size} channels and the Orbit Drive-In", color = Muted, fontSize = 14.sp)
|
||||
Text("Orbit TV $version", color = Muted, fontSize = 12.sp)
|
||||
}
|
||||
}
|
||||
|
||||
/** Everything behind the gear: a rail of sections on the left, and the chosen one beside it. */
|
||||
@Composable
|
||||
internal fun SettingsScreen(section: SettingsSection, onSection: (SettingsSection) -> Unit, modifier: Modifier, busy: Boolean, message: String?, server: String, titles: Long?,
|
||||
isOn: (Int) -> Boolean, canStart: (ChannelProgramming) -> Boolean, onSwitch: (ChannelProgramming, Boolean) -> Unit, onSuggestions: (ChannelProgramming) -> Unit,
|
||||
onSignOut: () -> Unit, onCoverage: () -> Unit, onImport: () -> Unit, onConnectionTest: () -> Unit) {
|
||||
isOn: (Int) -> Boolean, onSwitch: (ChannelProgramming, Boolean) -> Unit, onSuggestions: (ChannelProgramming) -> Unit, onSignOut: () -> Unit) {
|
||||
val firstFocus = remember { FocusRequester() }
|
||||
LaunchedEffect(Unit) { firstFocus.requestFocus() }
|
||||
Column(modifier.fillMaxWidth(), verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
@@ -175,11 +153,9 @@ internal fun SettingsScreen(section: SettingsSection, onSection: (SettingsSectio
|
||||
}
|
||||
val detail = Modifier.weight(1f).fillMaxHeight()
|
||||
when (section) {
|
||||
SettingsSection.Channels -> ChannelsDetail(busy, message, isOn, canStart, onSwitch, onSuggestions, detail)
|
||||
SettingsSection.Channels -> ChannelsDetail(busy, message, isOn, onSwitch, onSuggestions, detail)
|
||||
SettingsSection.Viewing -> ViewingDetail(detail)
|
||||
SettingsSection.Account -> AccountDetail(server, titles, onSignOut, detail)
|
||||
SettingsSection.Tools -> ToolsDetail(busy, onCoverage, onImport, onConnectionTest, detail)
|
||||
SettingsSection.About -> AboutDetail(detail)
|
||||
}
|
||||
}
|
||||
Text("▲▼ Move ► Into this section OK Select Back Main menu", color = Muted, fontSize = 11.sp)
|
||||
|
||||
Reference in New Issue
Block a user