10 Commits
Author SHA1 Message Date
yuriy.pandClaude Opus 5.5 d9a2571d63 Bump version to 0.1.12 (13)
CI / check (push) Successful in 29m4s
Release / release (push) Successful in 1h13m42s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 23:16:16 +06:00
yuriy.pandClaude Opus 5.5 2a7e1722dc Open the fullscreen player when starting a wave or a collection on TV
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 15:24:51 +06:00
yuriy.pandClaude Opus 5.5 7674bcd99f Bump phone app version to 0.1.6 (7)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 15:21:08 +06:00
yuriy.pandClaude Opus 5.5 82a31acd8c Add a shuffle toggle to Android Auto's player
Also give the Shuffle row in track lists an icon, so it no longer
reads as a heading.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 15:20:14 +06:00
yuriy.pandClaude Opus 5.5 9ff5c92650 Bump version to 0.1.11 (12)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 15:11:56 +06:00
yuriy.pandClaude Opus 5.5 f83f020d71 Bump phone app version to 0.1.5 (6)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 15:11:56 +06:00
yuriy.pandClaude Opus 5.5 30daf267a0 Add Shuffle to collection and download lists in Android Auto
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 15:08:45 +06:00
yuriy.pandClaude Opus 5.5 5597c4c235 Save My Wave settings as JSON
settings3 now answers a form body with 415 unsupported-media-type,
so every choice reverted to Any.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 15:00:57 +06:00
yuriy.pandClaude Opus 5.5 d65db50bd6 Bump version to 0.1.10 (11)
CI / check (push) Successful in 9m24s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 14:58:43 +06:00
yuriy.pandClaude Opus 5.5 ed39d0c2a8 Keep the screensaver caption on the right
Also shorten the language lookup in attachBaseContext.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 14:58:43 +06:00
15 changed files with 122 additions and 40 deletions

No files matched your search

@@ -239,15 +239,15 @@ class YmClient private constructor(
return WaveSettings.from(first["settings2"] ?: first["settings"]) return WaveSettings.from(first["settings2"] ?: first["settings"])
} }
/** `settings3` takes JSON only: a form body gets `415 unsupported-media-type`. */
suspend fun setWaveSettings(station: String, settings: WaveSettings) { suspend fun setWaveSettings(station: String, settings: WaveSettings) {
val result = http.postForm( val body = buildJsonObject {
"/rotor/station/$station/settings3", put("moodEnergy", settings.mood.api ?: "all")
Params() put("diversity", settings.character.api ?: "default")
.add("moodEnergy", settings.mood.api ?: "all") put("language", settings.language.api ?: "any")
.add("diversity", settings.character.api ?: "default") put("type", "rotor")
.add("type", "rotor") }
.add("language", settings.language.api ?: "any"), val result = http.postJson("/rotor/station/$station/settings3", body)
)
requireAck(result, "station settings") requireAck(result, "station settings")
} }
+2 -2
View File
@@ -13,8 +13,8 @@ android {
applicationId = "it.panov.musyx" applicationId = "it.panov.musyx"
minSdk = 23 minSdk = 23
targetSdk = 37 targetSdk = 37
versionCode = 5 versionCode = 7
versionName = "0.1.4" versionName = "0.1.6"
} }
// The same keystore.properties as the TV app; without one, release builds use the debug key. // The same keystore.properties as the TV app; without one, release builds use the debug key.
@@ -1,11 +1,13 @@
// Covers for Android Auto. Auto loads browse artwork only from content:// URIs, so each https // Covers for Android Auto. Auto loads browse artwork only from content:// URIs, so each https
// cover is fetched once into the cache and served from there. // cover is fetched once into the cache and served from there, as are the app's own icons.
package it.panov.musyx.mobile package it.panov.musyx.mobile
import android.content.ContentProvider import android.content.ContentProvider
import android.content.ContentValues import android.content.ContentValues
import android.content.Context import android.content.Context
import android.database.Cursor import android.database.Cursor
import android.graphics.Bitmap
import android.graphics.Canvas
import android.net.Uri import android.net.Uri
import android.os.ParcelFileDescriptor import android.os.ParcelFileDescriptor
import it.panov.musyx.data.Downloads import it.panov.musyx.data.Downloads
@@ -21,6 +23,7 @@ class ArtworkProvider : ContentProvider() {
override fun onCreate(): Boolean = true override fun onCreate(): Boolean = true
override fun openFile(uri: Uri, mode: String): ParcelFileDescriptor { override fun openFile(uri: Uri, mode: String): ParcelFileDescriptor {
if (uri.lastPathSegment == SHUFFLE) return ParcelFileDescriptor.open(icon(R.drawable.ic_shuffle, "shuffle"), ParcelFileDescriptor.MODE_READ_ONLY)
val url = uri.lastPathSegment?.let(Uri::parse) ?: throw FileNotFoundException("$uri") val url = uri.lastPathSegment?.let(Uri::parse) ?: throw FileNotFoundException("$uri")
// Exported for the car, so it fetches only Yandex covers, never an arbitrary URL. // Exported for the car, so it fetches only Yandex covers, never an arbitrary URL.
val host = url.host.orEmpty() val host = url.host.orEmpty()
@@ -50,7 +53,23 @@ class ArtworkProvider : ContentProvider() {
} }
} }
override fun getType(uri: Uri): String = "image/jpeg" /** A white icon on clear ground, drawn once into the cache as a PNG; the car can't draw vectors. */
private fun icon(id: Int, name: String): File {
val file = File(requireNotNull(context).cacheDir, "artwork/icon-$name.png")
if (file.exists()) return file
val drawable = requireNotNull(requireNotNull(context).getDrawable(id))
val bitmap = Bitmap.createBitmap(ICON_PX, ICON_PX, Bitmap.Config.ARGB_8888)
val inset = ICON_PX / 5
drawable.setBounds(inset, inset, ICON_PX - inset, ICON_PX - inset)
drawable.draw(Canvas(bitmap))
file.parentFile?.mkdirs()
val part = File(file.path + ".part")
part.outputStream().use { bitmap.compress(Bitmap.CompressFormat.PNG, 100, it) }
if (!part.renameTo(file)) throw FileNotFoundException(file.path)
return file
}
override fun getType(uri: Uri): String = if (uri.lastPathSegment == SHUFFLE) "image/png" else "image/jpeg"
override fun query(uri: Uri, projection: Array<out String>?, selection: String?, selectionArgs: Array<out String>?, sortOrder: String?): Cursor? = null override fun query(uri: Uri, projection: Array<out String>?, selection: String?, selectionArgs: Array<out String>?, sortOrder: String?): Cursor? = null
override fun insert(uri: Uri, values: ContentValues?): Uri? = null override fun insert(uri: Uri, values: ContentValues?): Uri? = null
@@ -58,6 +77,10 @@ class ArtworkProvider : ContentProvider() {
override fun update(uri: Uri, values: ContentValues?, selection: String?, selectionArgs: Array<out String>?): Int = 0 override fun update(uri: Uri, values: ContentValues?, selection: String?, selectionArgs: Array<out String>?): Int = 0
companion object { companion object {
/** The path of the Shuffle row's icon, in place of a cover's URL. */
const val SHUFFLE = "icon:shuffle"
private const val ICON_PX = 192
/** The content URI the car loads `url` from. */ /** The content URI the car loads `url` from. */
fun uri(context: Context, url: String): Uri = fun uri(context: Context, url: String): Uri =
Uri.Builder().scheme("content").authority("${context.packageName}.artwork").appendPath(url).build() Uri.Builder().scheme("content").authority("${context.packageName}.artwork").appendPath(url).build()
@@ -60,7 +60,7 @@ private const val RECENT_SHOWN = 30
private const val RESTORE_MS = 20_000L private const val RESTORE_MS = 20_000L
// Media ids. Folders are plain names or `kind:id`; a playable track is `t|<folder>|<index>`, // Media ids. Folders are plain names or `kind:id`; a playable track is `t|<folder>|<index>`,
// so playing it can queue the rest of its folder. // so playing it can queue the rest of its folder, and `s|<folder>` plays the folder shuffled.
private const val ROOT = "root" private const val ROOT = "root"
private const val WAVE = "wave" private const val WAVE = "wave"
private const val HOME = "home" private const val HOME = "home"
@@ -72,6 +72,7 @@ private const val PLAYLISTS = "playlists"
private const val ALBUMS = "albums" private const val ALBUMS = "albums"
private const val STATION = "station|" private const val STATION = "station|"
private const val TRACK = "t|" private const val TRACK = "t|"
private const val SHUFFLE = "s|"
private const val SEARCH = "search:" private const val SEARCH = "search:"
private const val DOWNLOADS = "downloads" private const val DOWNLOADS = "downloads"
/** Every downloaded track. */ /** Every downloaded track. */
@@ -79,9 +80,10 @@ private const val OFFLINE_ALL = "offline"
/** A downloaded album, playlist or Liked tracks, by its [it.panov.musyx.data.OfflineSet] key. */ /** A downloaded album, playlist or Liked tracks, by its [it.panov.musyx.data.OfflineSet] key. */
private const val OFFLINE = "offline:" private const val OFFLINE = "offline:"
// The buttons beside the car's transport: the heart, and "don't recommend". // The buttons beside the car's transport: the heart, "don't recommend", and shuffle.
private val LIKE = SessionCommand("it.panov.musyx.LIKE", Bundle.EMPTY) private val LIKE = SessionCommand("it.panov.musyx.LIKE", Bundle.EMPTY)
private val DISLIKE = SessionCommand("it.panov.musyx.DISLIKE", Bundle.EMPTY) private val DISLIKE = SessionCommand("it.panov.musyx.DISLIKE", Bundle.EMPTY)
private val SHUFFLE_MODE = SessionCommand("it.panov.musyx.SHUFFLE", Bundle.EMPTY)
@OptIn(UnstableApi::class) @OptIn(UnstableApi::class)
class Library(private val context: Context, private val state: AppState, private val scope: CoroutineScope) : class Library(private val context: Context, private val state: AppState, private val scope: CoroutineScope) :
@@ -95,7 +97,7 @@ class Library(private val context: Context, private val state: AppState, private
/** /**
* Has the car reload whenever someone signs in or out, or the app goes offline or back, so * Has the car reload whenever someone signs in or out, or the app goes offline or back, so
* it never keeps showing "Sign in" (or someone else's music, or music it can't reach), and * it never keeps showing "Sign in" (or someone else's music, or music it can't reach), and
* keeps the heart in step with the track. Returns what stops watching. * keeps the heart and shuffle in step with the player. Returns what stops watching.
*/ */
fun watch(session: MediaLibrarySession): () -> Unit { fun watch(session: MediaLibrarySession): () -> Unit {
// snapshotFlow hears about changes through Compose's apply notifications, which only the // snapshotFlow hears about changes through Compose's apply notifications, which only the
@@ -123,8 +125,9 @@ class Library(private val context: Context, private val state: AppState, private
} }
val buttons = scope.launch { val buttons = scope.launch {
snapshotFlow { snapshotFlow {
val track = state.playback.state.track val p = state.playback.state
Triple(track?.id, track?.let { state.liked.contains(it.id) }, track?.let { it.id in state.likes.dislikedTracks }) val track = p.track
listOf(track?.id, track?.let { state.liked.contains(it.id) }, track?.let { it.id in state.likes.dislikedTracks }, p.shuffle, p.waveStation)
} }
.distinctUntilChanged() .distinctUntilChanged()
.collect { session.setMediaButtonPreferences(buttons()) } .collect { session.setMediaButtonPreferences(buttons()) }
@@ -136,7 +139,7 @@ class Library(private val context: Context, private val state: AppState, private
} }
} }
/** Every controller may like and dislike, and starts with the buttons for what's playing. */ /** Every controller may like, dislike and shuffle, and starts with the buttons for what's playing. */
override fun onConnect(session: MediaSession, controller: MediaSession.ControllerInfo): MediaSession.ConnectionResult { override fun onConnect(session: MediaSession, controller: MediaSession.ControllerInfo): MediaSession.ConnectionResult {
// The library commands must stay: without "get root" a car's browser connection is refused. // The library commands must stay: without "get root" a car's browser connection is refused.
val library = if (controller.isTrusted) { val library = if (controller.isTrusted) {
@@ -145,7 +148,7 @@ class Library(private val context: Context, private val state: AppState, private
MediaSession.ConnectionResult.DEFAULT_UNTRUSTED_SESSION_AND_LIBRARY_COMMANDS MediaSession.ConnectionResult.DEFAULT_UNTRUSTED_SESSION_AND_LIBRARY_COMMANDS
} }
return MediaSession.ConnectionResult.AcceptedResultBuilder(session) return MediaSession.ConnectionResult.AcceptedResultBuilder(session)
.setAvailableSessionCommands(library.buildUpon().add(LIKE).add(DISLIKE).build()) .setAvailableSessionCommands(library.buildUpon().add(LIKE).add(DISLIKE).add(SHUFFLE_MODE).build())
.setMediaButtonPreferences(buttons()) .setMediaButtonPreferences(buttons())
.build() .build()
} }
@@ -162,32 +165,38 @@ class Library(private val context: Context, private val state: AppState, private
LIKE.customAction -> state.likeTrack(track, !state.liked.contains(track.id)) LIKE.customAction -> state.likeTrack(track, !state.liked.contains(track.id))
// Disliking the playing track also skips it, as from the app's menu. // Disliking the playing track also skips it, as from the app's menu.
DISLIKE.customAction -> state.dislikeTrack(track, track.id !in state.likes.dislikedTracks) DISLIKE.customAction -> state.dislikeTrack(track, track.id !in state.likes.dislikedTracks)
SHUFFLE_MODE.customAction -> state.playback.toggleShuffle()
else -> return Futures.immediateFuture(SessionResult(SessionError.ERROR_NOT_SUPPORTED)) else -> return Futures.immediateFuture(SessionResult(SessionError.ERROR_NOT_SUPPORTED))
} }
return Futures.immediateFuture(SessionResult(SessionResult.RESULT_SUCCESS)) return Futures.immediateFuture(SessionResult(SessionResult.RESULT_SUCCESS))
} }
/** /**
* The heart and "don't recommend" for what's playing, asked for right after next; previous * The heart, "don't recommend" and shuffle for what's playing, asked for right after next;
* and next keep their slots. Android Auto ignores the slot and puts them at the right edge. * previous and next keep their slots. Android Auto ignores the slot and puts them at the
* Speech has nothing to recommend. * right edge. Speech has nothing to recommend, and a station decides its own order.
*/ */
private fun buttons(): List<CommandButton> { private fun buttons(): List<CommandButton> {
val track = state.playback.state.track ?: return emptyList() val p = state.playback.state
val track = p.track ?: return emptyList()
val liked = state.liked.contains(track.id) val liked = state.liked.contains(track.id)
val heart = CommandButton.Builder(if (liked) CommandButton.ICON_HEART_FILLED else CommandButton.ICON_HEART_UNFILLED) val heart = CommandButton.Builder(if (liked) CommandButton.ICON_HEART_FILLED else CommandButton.ICON_HEART_UNFILLED)
.setDisplayName(context.getString(if (liked) R.string.menu_unlike else R.string.menu_like)) .setDisplayName(context.getString(if (liked) R.string.menu_unlike else R.string.menu_like))
.setSessionCommand(LIKE) .setSessionCommand(LIKE)
.setSlots(CommandButton.SLOT_FORWARD_SECONDARY, CommandButton.SLOT_OVERFLOW) .setSlots(CommandButton.SLOT_FORWARD_SECONDARY, CommandButton.SLOT_OVERFLOW)
.build() .build()
if (track.spoken) return listOf(heart)
val disliked = track.id in state.likes.dislikedTracks val disliked = track.id in state.likes.dislikedTracks
val block = CommandButton.Builder(CommandButton.ICON_BLOCK) val block = if (track.spoken) null else CommandButton.Builder(CommandButton.ICON_BLOCK)
.setDisplayName(context.getString(if (disliked) R.string.menu_undislike else R.string.menu_dislike)) .setDisplayName(context.getString(if (disliked) R.string.menu_undislike else R.string.menu_dislike))
.setSessionCommand(DISLIKE) .setSessionCommand(DISLIKE)
.setSlots(CommandButton.SLOT_FORWARD_SECONDARY, CommandButton.SLOT_OVERFLOW) .setSlots(CommandButton.SLOT_FORWARD_SECONDARY, CommandButton.SLOT_OVERFLOW)
.build() .build()
return listOf(heart, block) val shuffle = if (p.waveStation != null) null else CommandButton.Builder(if (p.shuffle) CommandButton.ICON_SHUFFLE_ON else CommandButton.ICON_SHUFFLE_OFF)
.setDisplayName(context.getString(if (p.shuffle) R.string.action_shuffle_off else R.string.action_shuffle))
.setSessionCommand(SHUFFLE_MODE)
.setSlots(CommandButton.SLOT_FORWARD_SECONDARY, CommandButton.SLOT_OVERFLOW)
.build()
return listOfNotNull(heart, block, shuffle)
} }
override fun onGetLibraryRoot( override fun onGetLibraryRoot(
@@ -264,8 +273,8 @@ class Library(private val context: Context, private val state: AppState, private
Futures.immediateFuture(LibraryResult.ofItemList(searches[query].orEmpty().page(page, pageSize), params)) Futures.immediateFuture(LibraryResult.ofItemList(searches[query].orEmpty().page(page, pageSize), params))
/** /**
* Plays what the car picked: a station, a track with the rest of its folder, or, for a * Plays what the car picked: a station, a track with the rest of its folder, a folder
* spoken request, the best tracks for it (My Wave when nothing was named). * shuffled, or, for a spoken request, the best tracks for it (My Wave when nothing was named).
*/ */
override fun onSetMediaItems( override fun onSetMediaItems(
mediaSession: MediaSession, mediaSession: MediaSession,
@@ -281,9 +290,10 @@ class Library(private val context: Context, private val state: AppState, private
id.startsWith(STATION) -> state.playWave(id.removePrefix(STATION)) id.startsWith(STATION) -> state.playWave(id.removePrefix(STATION))
id.startsWith(TRACK) -> { id.startsWith(TRACK) -> {
val (folder, index) = id.removePrefix(TRACK).let { it.substringBeforeLast('|') to it.substringAfterLast('|').toIntOrNull() } val (folder, index) = id.removePrefix(TRACK).let { it.substringBeforeLast('|') to it.substringAfterLast('|').toIntOrNull() }
val tracks = shown[folder] ?: offlineTracks(folder) ?: client()?.let { tracks(it, folder) } val tracks = folderTracks(folder)
if (tracks != null && index != null && index in tracks.indices) state.playTracks(tracks, index) if (tracks != null && index != null && index in tracks.indices) state.playTracks(tracks, index)
} }
id.startsWith(SHUFFLE) -> folderTracks(id.removePrefix(SHUFFLE))?.takeIf { it.isNotEmpty() }?.let { state.playTracks(it, 0, shuffle = true) }
id.isEmpty() -> playFromSearch(state, query) id.isEmpty() -> playFromSearch(state, query)
} }
MediaItemsWithStartPosition(mediaItems, startIndex, C.TIME_UNSET) MediaItemsWithStartPosition(mediaItems, startIndex, C.TIME_UNSET)
@@ -324,11 +334,20 @@ class Library(private val context: Context, private val state: AppState, private
else -> tracks(client, parent)?.let { tracks -> trackItems(parent, tracks) } else -> tracks(client, parent)?.let { tracks -> trackItems(parent, tracks) }
} }
/** A folder's tracks; the collection's and the downloads' start with Shuffle, as in the app. */
private fun trackItems(folder: String, tracks: List<Track>): List<MediaItem> { private fun trackItems(folder: String, tracks: List<Track>): List<MediaItem> {
shown[folder] = tracks shown[folder] = tracks
return tracks.mapIndexed { i, t -> track(folder, i, t) } val rows = tracks.mapIndexed { i, t -> track(folder, i, t) }
return if (shuffles(folder) && tracks.size > 1) listOf(shuffle(folder)) + rows else rows
} }
/** Liked tracks, albums, playlists and downloads; not the recent, the chart or search results. */
private fun shuffles(folder: String): Boolean =
folder == LIKED || folder == OFFLINE_ALL || folder.startsWith(OFFLINE) || folder.startsWith("album:") || folder.startsWith("playlist:")
/** A folder's tracks as last shown, or fetched again when the car plays it cold. */
private suspend fun folderTracks(folder: String): List<Track>? = shown[folder] ?: offlineTracks(folder) ?: client()?.let { tracks(it, folder) }
/** Every downloaded track, then the albums and playlists with any of theirs on the phone. */ /** Every downloaded track, then the albums and playlists with any of theirs on the phone. */
private fun downloads(): List<MediaItem> { private fun downloads(): List<MediaItem> {
val d = state.downloads val d = state.downloads
@@ -402,6 +421,20 @@ class Library(private val context: Context, private val state: AppState, private
) )
.build() .build()
private fun shuffle(folder: String) = MediaItem.Builder()
.setMediaId(SHUFFLE + folder)
.setMediaMetadata(
MediaMetadata.Builder()
.setTitle(context.getString(R.string.action_shuffle))
// Without an icon the row reads as a heading.
.setArtworkUri(ArtworkProvider.uri(context, ArtworkProvider.SHUFFLE))
.setIsBrowsable(false)
.setIsPlayable(true)
.setMediaType(MediaMetadata.MEDIA_TYPE_PLAYLIST)
.build(),
)
.build()
private fun track(folder: String, index: Int, t: Track) = MediaItem.Builder() private fun track(folder: String, index: Int, t: Track) = MediaItem.Builder()
.setMediaId("$TRACK$folder|$index") .setMediaId("$TRACK$folder|$index")
.setMediaMetadata( .setMediaMetadata(
@@ -25,6 +25,7 @@
<string name="signin_token_placeholder">Вставьте OAuth-токен</string> <string name="signin_token_placeholder">Вставьте OAuth-токен</string>
<string name="action_play">Слушать</string> <string name="action_play">Слушать</string>
<string name="action_shuffle">Вперемешку</string> <string name="action_shuffle">Вперемешку</string>
<string name="action_shuffle_off">Выключить перемешивание</string>
<string name="action_pause">Пауза</string> <string name="action_pause">Пауза</string>
<string name="action_resume">Продолжить</string> <string name="action_resume">Продолжить</string>
<string name="action_try_again">Повторить</string> <string name="action_try_again">Повторить</string>
+1
View File
@@ -26,6 +26,7 @@
<string name="signin_token_placeholder">Paste OAuth token</string> <string name="signin_token_placeholder">Paste OAuth token</string>
<string name="action_play">Play</string> <string name="action_play">Play</string>
<string name="action_shuffle">Shuffle</string> <string name="action_shuffle">Shuffle</string>
<string name="action_shuffle_off">Turn off shuffle</string>
<string name="action_pause">Pause</string> <string name="action_pause">Pause</string>
<string name="action_resume">Resume</string> <string name="action_resume">Resume</string>
<string name="action_try_again">Try again</string> <string name="action_try_again">Try again</string>
+2 -2
View File
@@ -14,8 +14,8 @@ android {
// Compose (and so Compose for TV) needs API 23. // Compose (and so Compose for TV) needs API 23.
minSdk = 23 minSdk = 23
targetSdk = 37 targetSdk = 37
versionCode = 10 versionCode = 13
versionName = "0.1.9" versionName = "0.1.12"
} }
// A release key comes from keystore.properties (gitignored): storeFile, storePassword, // A release key comes from keystore.properties (gitignored): storeFile, storePassword,
@@ -36,8 +36,7 @@ class MainActivity : ComponentActivity() {
/** The interface language follows the setting, not only the system. */ /** The interface language follows the setting, not only the system. */
override fun attachBaseContext(newBase: Context) { override fun attachBaseContext(newBase: Context) {
val tag = SettingsStore(newBase).language().tag val tag = SettingsStore(newBase).language().tag ?: return super.attachBaseContext(newBase)
if (tag == null) return super.attachBaseContext(newBase)
val config = Configuration(newBase.resources.configuration) val config = Configuration(newBase.resources.configuration)
val locale = Locale.forLanguageTag(tag) val locale = Locale.forLanguageTag(tag)
Locale.setDefault(locale) Locale.setDefault(locale)
@@ -31,6 +31,7 @@ import it.panov.musyx.api.PlaylistId
import it.panov.musyx.api.Track import it.panov.musyx.api.Track
import it.panov.musyx.state.AppState import it.panov.musyx.state.AppState
import it.panov.musyx.state.PlaylistSlot import it.panov.musyx.state.PlaylistSlot
import it.panov.musyx.state.Route
import it.panov.musyx.state.Sheet import it.panov.musyx.state.Sheet
import it.panov.musyx.tv.ui.artistsOrUnknown import it.panov.musyx.tv.ui.artistsOrUnknown
import it.panov.musyx.tv.ui.clock 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) 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<Track>, 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 * Play and Shuffle, then any page actions (the heart), then a summary. Shared by every page
* with tracks. * with tracks.
@@ -211,14 +225,14 @@ fun PlayBar(
) { ) {
PrimaryButton( PrimaryButton(
stringResource(R.string.action_play), stringResource(R.string.action_play),
onClick = { state.playTracks(tracks, 0) }, onClick = { state.playTracksOpen(tracks) },
icon = R.drawable.ic_play_fill, icon = R.drawable.ic_play_fill,
enabled = tracks.isNotEmpty(), enabled = tracks.isNotEmpty(),
modifier = Modifier.entry(entry), modifier = Modifier.entry(entry),
) )
GhostButton( GhostButton(
stringResource(R.string.action_shuffle), stringResource(R.string.action_shuffle),
onClick = { state.playTracks(tracks, 0, shuffle = true) }, onClick = { state.playTracksOpen(tracks, shuffle = true) },
icon = R.drawable.ic_shuffle, icon = R.drawable.ic_shuffle,
enabled = tracks.isNotEmpty(), enabled = tracks.isNotEmpty(),
) )
@@ -53,6 +53,7 @@ import it.panov.musyx.tv.ui.components.ShelfRow
import it.panov.musyx.tv.ui.components.ChoiceRow import it.panov.musyx.tv.ui.components.ChoiceRow
import coil3.compose.AsyncImage import coil3.compose.AsyncImage
import it.panov.musyx.tv.ui.components.FocusEntry 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.Focusable
import it.panov.musyx.tv.ui.components.Note import it.panov.musyx.tv.ui.components.Note
import it.panov.musyx.tv.ui.components.PrimaryButton 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) { val (label, icon, action) = when (status) {
Status.Playing, Status.Loading -> Triple(R.string.action_pause, R.drawable.ic_pause_fill) { state.playback.toggle() } 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() } else -> Triple(R.string.action_resume, R.drawable.ic_play_fill) { state.playback.toggle() }
} }
val shape = RoundedCornerShape(MusyxTheme.radius.hero) val shape = RoundedCornerShape(MusyxTheme.radius.hero)
@@ -282,7 +283,7 @@ fun WaveScreen(state: AppState, entry: FocusEntry) {
item(key = "stations-row") { item(key = "stations-row") {
ShelfRow { first -> ShelfRow { first ->
itemsIndexed(others, key = { _, s -> s.id }) { i, s -> 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) }
} }
} }
} }
@@ -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.Chip
import it.panov.musyx.tv.ui.components.Failure import it.panov.musyx.tv.ui.components.Failure
import it.panov.musyx.tv.ui.components.FocusEntry 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.Note
import it.panov.musyx.tv.ui.components.PlayBar import it.panov.musyx.tv.ui.components.PlayBar
import it.panov.musyx.tv.ui.components.PrimaryButton 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) } Box(Modifier.weight(1f)) { ScreenTitle(genre.title) }
PrimaryButton( PrimaryButton(
stringResource(R.string.action_play_radio), stringResource(R.string.action_play_radio),
onClick = { state.playWave("genre:${genre.id}") }, onClick = { state.playWaveOpen("genre:${genre.id}") },
icon = R.drawable.ic_audio_lines, icon = R.drawable.ic_audio_lines,
modifier = Modifier.entry(entry), modifier = Modifier.entry(entry),
) )
@@ -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.Focusable
import it.panov.musyx.tv.ui.components.IconButton import it.panov.musyx.tv.ui.components.IconButton
import it.panov.musyx.tv.ui.components.MusyxIcon 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.PrimaryButton
import it.panov.musyx.tv.ui.components.Tab import it.panov.musyx.tv.ui.components.Tab
import it.panov.musyx.tv.ui.components.TabBar import it.panov.musyx.tv.ui.components.TabBar
@@ -123,6 +124,11 @@ fun NowPlayingScreen(state: AppState, entry: FocusEntry) {
val c = MusyxTheme.colors val c = MusyxTheme.colors
val space = MusyxTheme.space val space = MusyxTheme.space
val track = p.track 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) { if (track == null) {
Column( Column(
Modifier.fillMaxSize().padding(horizontal = space.safeX, vertical = space.safeY), Modifier.fillMaxSize().padding(horizontal = space.safeX, vertical = space.safeY),
@@ -211,7 +211,8 @@ private fun ScreenSaver(state: AppState, track: Track, galleries: MutableMap<Lon
) )
// The caption changes sides with each photo, so nothing sits still on the panel. // The caption changes sides with each photo, so nothing sits still on the panel.
// The lyrics ride with it, stacked right above the song name over a shade of their own. // The lyrics ride with it, stacked right above the song name over a shade of their own.
Crossfade(slide.n % 2 == 0, animationSpec = tween(PHOTO_FADE_MS), label = "caption") { left -> // always align right
Crossfade(/*slide.n % 2 == 0*/ false, animationSpec = tween(PHOTO_FADE_MS), label = "caption") { left ->
Box(Modifier.fillMaxSize()) { Box(Modifier.fillMaxSize()) {
if (lyrics != null) { if (lyrics != null) {
val shade = Color.Black.copy(alpha = 0.6f) val shade = Color.Black.copy(alpha = 0.6f)
+1
View File
@@ -88,6 +88,7 @@
<string name="loading_playlist">Загружаем плейлист…</string> <string name="loading_playlist">Загружаем плейлист…</string>
<string name="loading_wave_settings">Загружаем настройки…</string> <string name="loading_wave_settings">Загружаем настройки…</string>
<string name="loading_stations">Загружаем станции…</string> <string name="loading_stations">Загружаем станции…</string>
<string name="loading_wave">Настраиваемся на волну…</string>
<string name="what_home">главную страницу</string> <string name="what_home">главную страницу</string>
<string name="what_chart">чарт</string> <string name="what_chart">чарт</string>
<string name="what_genres">жанры</string> <string name="what_genres">жанры</string>
+1
View File
@@ -95,6 +95,7 @@
<string name="loading_playlist">Loading the playlist…</string> <string name="loading_playlist">Loading the playlist…</string>
<string name="loading_wave_settings">Loading your settings…</string> <string name="loading_wave_settings">Loading your settings…</string>
<string name="loading_stations">Loading stations…</string> <string name="loading_stations">Loading stations…</string>
<string name="loading_wave">Tuning in…</string>
<string name="what_home">your home page</string> <string name="what_home">your home page</string>
<string name="what_chart">the chart</string> <string name="what_chart">the chart</string>
<string name="what_genres">genres</string> <string name="what_genres">genres</string>