From 2a7e1722dcee8e91d2728da6ac81596c70fccec2 Mon Sep 17 00:00:00 2001 From: Yuriy Panov Date: Wed, 4 Nov 2026 15:24:51 +0600 Subject: [PATCH] Open the fullscreen player when starting a wave or a collection on TV Co-Authored-By: Claude Opus 5.5 --- .../it/panov/musyx/tv/ui/components/Tracks.kt | 18 ++++++++++++++++-- .../it/panov/musyx/tv/ui/screens/HomeWave.kt | 5 +++-- .../it/panov/musyx/tv/ui/screens/Library.kt | 3 ++- .../it/panov/musyx/tv/ui/screens/Player.kt | 6 ++++++ tv/src/main/res/values-ru/strings.xml | 1 + tv/src/main/res/values/strings.xml | 1 + 6 files changed, 29 insertions(+), 5 deletions(-) diff --git a/tv/src/main/java/it/panov/musyx/tv/ui/components/Tracks.kt b/tv/src/main/java/it/panov/musyx/tv/ui/components/Tracks.kt index 367d235..df4dc7d 100644 --- a/tv/src/main/java/it/panov/musyx/tv/ui/components/Tracks.kt +++ b/tv/src/main/java/it/panov/musyx/tv/ui/components/Tracks.kt @@ -31,6 +31,7 @@ import it.panov.musyx.api.PlaylistId import it.panov.musyx.api.Track import it.panov.musyx.state.AppState import it.panov.musyx.state.PlaylistSlot +import it.panov.musyx.state.Route import it.panov.musyx.state.Sheet import it.panov.musyx.tv.ui.artistsOrUnknown import it.panov.musyx.tv.ui.clock @@ -190,6 +191,19 @@ fun ShiftMarker(shift: Int) { Text(glyph, style = MusyxTheme.type.small, color = colour, modifier = Modifier.width(18.dp), textAlign = TextAlign.Center) } +/** Plays a whole list from the top and opens the player, as Play and Shuffle do. */ +fun AppState.playTracksOpen(tracks: List, shuffle: Boolean = false) { + if (tracks.isEmpty()) return + playTracks(tracks, 0, shuffle) + navigate(Route.NowPlaying) +} + +/** Starts a wave and opens the player, so tuning in lands on the full-screen view. */ +fun AppState.playWaveOpen(station: String) { + playWave(station) + navigate(Route.NowPlaying) +} + /** * Play and Shuffle, then any page actions (the heart), then a summary. Shared by every page * with tracks. @@ -211,14 +225,14 @@ fun PlayBar( ) { PrimaryButton( stringResource(R.string.action_play), - onClick = { state.playTracks(tracks, 0) }, + onClick = { state.playTracksOpen(tracks) }, icon = R.drawable.ic_play_fill, enabled = tracks.isNotEmpty(), modifier = Modifier.entry(entry), ) GhostButton( stringResource(R.string.action_shuffle), - onClick = { state.playTracks(tracks, 0, shuffle = true) }, + onClick = { state.playTracksOpen(tracks, shuffle = true) }, icon = R.drawable.ic_shuffle, enabled = tracks.isNotEmpty(), ) diff --git a/tv/src/main/java/it/panov/musyx/tv/ui/screens/HomeWave.kt b/tv/src/main/java/it/panov/musyx/tv/ui/screens/HomeWave.kt index 65d65fb..c357364 100644 --- a/tv/src/main/java/it/panov/musyx/tv/ui/screens/HomeWave.kt +++ b/tv/src/main/java/it/panov/musyx/tv/ui/screens/HomeWave.kt @@ -53,6 +53,7 @@ import it.panov.musyx.tv.ui.components.ShelfRow import it.panov.musyx.tv.ui.components.ChoiceRow import coil3.compose.AsyncImage import it.panov.musyx.tv.ui.components.FocusEntry +import it.panov.musyx.tv.ui.components.playWaveOpen import it.panov.musyx.tv.ui.components.Focusable import it.panov.musyx.tv.ui.components.Note import it.panov.musyx.tv.ui.components.PrimaryButton @@ -147,7 +148,7 @@ fun WaveHero(state: AppState, big: Boolean, entry: FocusEntry?) { } val (label, icon, action) = when (status) { Status.Playing, Status.Loading -> Triple(R.string.action_pause, R.drawable.ic_pause_fill) { state.playback.toggle() } - null -> Triple(R.string.wave_play, R.drawable.ic_play_fill) { state.playWave(MY_WAVE) } + null -> Triple(R.string.wave_play, R.drawable.ic_play_fill) { state.playWaveOpen(MY_WAVE) } else -> Triple(R.string.action_resume, R.drawable.ic_play_fill) { state.playback.toggle() } } val shape = RoundedCornerShape(MusyxTheme.radius.hero) @@ -282,7 +283,7 @@ fun WaveScreen(state: AppState, entry: FocusEntry) { item(key = "stations-row") { ShelfRow { first -> itemsIndexed(others, key = { _, s -> s.id }) { i, s -> - StationTile(s, playing = state.playback.state.waveStation == s.id, if (i == 0) first else Modifier) { state.playWave(s.id) } + StationTile(s, playing = state.playback.state.waveStation == s.id, if (i == 0) first else Modifier) { state.playWaveOpen(s.id) } } } } diff --git a/tv/src/main/java/it/panov/musyx/tv/ui/screens/Library.kt b/tv/src/main/java/it/panov/musyx/tv/ui/screens/Library.kt index 8622470..880a62d 100644 --- a/tv/src/main/java/it/panov/musyx/tv/ui/screens/Library.kt +++ b/tv/src/main/java/it/panov/musyx/tv/ui/screens/Library.kt @@ -21,6 +21,7 @@ import it.panov.musyx.tv.ui.components.CardGrid import it.panov.musyx.tv.ui.components.Chip import it.panov.musyx.tv.ui.components.Failure import it.panov.musyx.tv.ui.components.FocusEntry +import it.panov.musyx.tv.ui.components.playWaveOpen import it.panov.musyx.tv.ui.components.Note import it.panov.musyx.tv.ui.components.PlayBar import it.panov.musyx.tv.ui.components.PrimaryButton @@ -191,7 +192,7 @@ fun GenreScreen(state: AppState, index: Int, entry: FocusEntry) { Box(Modifier.weight(1f)) { ScreenTitle(genre.title) } PrimaryButton( stringResource(R.string.action_play_radio), - onClick = { state.playWave("genre:${genre.id}") }, + onClick = { state.playWaveOpen("genre:${genre.id}") }, icon = R.drawable.ic_audio_lines, modifier = Modifier.entry(entry), ) diff --git a/tv/src/main/java/it/panov/musyx/tv/ui/screens/Player.kt b/tv/src/main/java/it/panov/musyx/tv/ui/screens/Player.kt index b4df5b2..b1f26c1 100644 --- a/tv/src/main/java/it/panov/musyx/tv/ui/screens/Player.kt +++ b/tv/src/main/java/it/panov/musyx/tv/ui/screens/Player.kt @@ -92,6 +92,7 @@ import it.panov.musyx.tv.ui.components.FocusEntry import it.panov.musyx.tv.ui.components.Focusable import it.panov.musyx.tv.ui.components.IconButton import it.panov.musyx.tv.ui.components.MusyxIcon +import it.panov.musyx.tv.ui.components.Note import it.panov.musyx.tv.ui.components.PrimaryButton import it.panov.musyx.tv.ui.components.Tab import it.panov.musyx.tv.ui.components.TabBar @@ -123,6 +124,11 @@ fun NowPlayingScreen(state: AppState, entry: FocusEntry) { val c = MusyxTheme.colors val space = MusyxTheme.space val track = p.track + // A wave fetches its first track after the player opens: say so rather than "nothing". + if (track == null && p.status == Status.Loading) { + Note(stringResource(R.string.loading_wave), Modifier.padding(vertical = space.safeY)) + return + } if (track == null) { Column( Modifier.fillMaxSize().padding(horizontal = space.safeX, vertical = space.safeY), diff --git a/tv/src/main/res/values-ru/strings.xml b/tv/src/main/res/values-ru/strings.xml index 937acb6..19d6df5 100644 --- a/tv/src/main/res/values-ru/strings.xml +++ b/tv/src/main/res/values-ru/strings.xml @@ -88,6 +88,7 @@ Загружаем плейлист… Загружаем настройки… Загружаем станции… + Настраиваемся на волну… главную страницу чарт жанры diff --git a/tv/src/main/res/values/strings.xml b/tv/src/main/res/values/strings.xml index c3fb66e..cd1b212 100644 --- a/tv/src/main/res/values/strings.xml +++ b/tv/src/main/res/values/strings.xml @@ -95,6 +95,7 @@ Loading the playlist… Loading your settings… Loading stations… + Tuning in… your home page the chart genres