Split the shared code into a core module

The Yandex Music client, the player, the app state and the stores move from the
TV app to :core (it.panov.musyx.*), so a phone app can build on them. The TV app
becomes :tv with the same application id. CoverHues, SessionPlayer and the
strings the state layer shows move with them; LRCLIB's user agent is set by
each app.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Yuriy PanovandClaude Opus 5.5 committed 2026-10-23 10:07:21 +06:00
1 parent 90ac73facc
commit 4c978efa80
121 files changed
+464 -397

No files matched your search

+75
View File
@@ -0,0 +1,75 @@
import java.util.Properties
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.compose)
}
android {
namespace = "it.panov.musyx.tv"
compileSdk = 37
defaultConfig {
applicationId = "it.panov.musyx.tv"
// Compose (and so Compose for TV) needs API 23.
minSdk = 23
targetSdk = 37
versionCode = 6
versionName = "0.1.5"
}
// A release key comes from keystore.properties (gitignored): storeFile, storePassword,
// keyAlias, keyPassword. Without one, release builds use the debug key so they still install.
val keystore = rootProject.file("keystore.properties").takeIf { it.exists() }?.let { file ->
Properties().apply { file.inputStream().use(::load) }
}
signingConfigs {
if (keystore != null) {
create("release") {
storeFile = rootProject.file(keystore.getProperty("storeFile"))
storePassword = keystore.getProperty("storePassword")
keyAlias = keystore.getProperty("keyAlias")
keyPassword = keystore.getProperty("keyPassword")
}
}
}
buildTypes {
release {
signingConfig = signingConfigs.findByName("release") ?: signingConfigs.getByName("debug")
isMinifyEnabled = true
isShrinkResources = true
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
}
buildFeatures {
compose = true
buildConfig = true
}
}
dependencies {
implementation(project(":core"))
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.activity.compose)
implementation(libs.androidx.lifecycle.runtime.compose)
implementation(platform(libs.compose.bom))
implementation(libs.compose.ui)
implementation(libs.compose.ui.graphics)
implementation(libs.compose.foundation)
implementation(libs.compose.ui.tooling.preview)
implementation(libs.tv.material)
debugImplementation(libs.compose.ui.tooling)
implementation(libs.media3.exoplayer)
implementation(libs.media3.session)
implementation(libs.coil.compose)
implementation(libs.coil.network.okhttp)
implementation(libs.zxing.core)
testImplementation(libs.junit)
testImplementation(libs.kotlinx.coroutines.test)
}
+11
View File
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<lint>
<!-- The whole Lucide set is converted up front; screens adopt icons as they are built. -->
<issue id="UnusedResources">
<ignore path="src/main/res/drawable/ic_*.xml" />
</issue>
<!-- Android TV wants the 320x180 launcher banner in drawable-xhdpi only. -->
<issue id="IconMissingDensityFolder" severity="ignore" />
<!-- The language setting overrides the activity locale; the APK ships every language, no bundles. -->
<issue id="AppBundleLocaleChanges" severity="ignore" />
</lint>
+1
View File
@@ -0,0 +1 @@
# Project-specific R8 rules. The libraries in use ship their own consumer rules.
+53
View File
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<!-- A TV app that also installs on other devices: neither Leanback nor touch is required. -->
<uses-feature
android:name="android.software.leanback"
android:required="false" />
<uses-feature
android:name="android.hardware.touchscreen"
android:required="false" />
<application
android:name=".Musyx"
android:allowBackup="false"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:banner="@drawable/banner"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/Theme.Musyx">
<activity
android:name=".MainActivity"
android:configChanges="keyboard|keyboardHidden|navigation|screenSize|smallestScreenSize|screenLayout|orientation|uiMode"
android:launchMode="singleTask"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
</intent-filter>
</activity>
<service
android:name=".player.PlaybackService"
android:exported="true"
android:foregroundServiceType="mediaPlayback"
tools:ignore="ExportedService">
<!-- Exported so the system and remotes can reach the media session. -->
<intent-filter>
<action android:name="androidx.media3.session.MediaSessionService" />
</intent-filter>
</service>
</application>
</manifest>
@@ -0,0 +1,142 @@
package it.panov.musyx.tv
import android.annotation.SuppressLint
import android.content.ComponentName
import android.content.Context
import android.content.res.Configuration
import android.os.Bundle
import android.view.KeyEvent
import android.view.MotionEvent
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.snapshotFlow
import androidx.media3.session.MediaController
import androidx.media3.session.SessionToken
import com.google.common.util.concurrent.ListenableFuture
import it.panov.musyx.data.Appearance
import it.panov.musyx.data.SettingsStore
import it.panov.musyx.tv.player.PlaybackService
import it.panov.musyx.player.Status
import it.panov.musyx.tv.ui.MusyxApp
import it.panov.musyx.tv.ui.screens.ScreenSaverState
import it.panov.musyx.tv.ui.theme.MusyxTheme
import it.panov.musyx.tv.ui.theme.isMusyxDark
import kotlinx.coroutines.flow.drop
import java.util.Locale
class MainActivity : ComponentActivity() {
/** Binds the playback service so it can go foreground when playback starts. */
private var controller: ListenableFuture<MediaController>? = null
private val saver = ScreenSaverState()
/** The key that woke the screen saver: its release is swallowed too. */
private var wakingKey: Int? = null
/** The interface language follows the setting, not only the system. */
override fun attachBaseContext(newBase: Context) {
val tag = SettingsStore(newBase).language().tag
if (tag == null) return super.attachBaseContext(newBase)
val config = Configuration(newBase.resources.configuration)
val locale = Locale.forLanguageTag(tag)
Locale.setDefault(locale)
config.setLocale(locale)
super.attachBaseContext(newBase.createConfigurationContext(config))
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val state = Musyx.graph(this).state
state.start()
setContent {
val dark = when (state.settings.appearance) {
Appearance.System -> isMusyxDark()
Appearance.Light -> false
Appearance.Dark -> true
}
// A new interface language means new resources: rebuild the activity in it.
LaunchedEffect(Unit) {
snapshotFlow { state.settings.language }.drop(1).collect { recreate() }
}
MusyxTheme(dark = dark, typeScale = state.settings.fontSize.scale) {
MusyxApp(state, saver, onExit = { finish() })
}
}
}
override fun onStart() {
super.onStart()
val token = SessionToken(this, ComponentName(this, PlaybackService::class.java))
controller = MediaController.Builder(this, token).buildAsync()
}
override fun onStop() {
controller?.let { MediaController.releaseFuture(it) }
controller = null
super.onStop()
}
/**
* Any key counts as activity for the screen saver. The key that wakes it does nothing else,
* except media and volume keys, which still act.
*/
// Lint mistakes this platform Activity override for androidx.core's restricted one.
@SuppressLint("RestrictedApi")
override fun dispatchKeyEvent(event: KeyEvent): Boolean {
if (event.action == KeyEvent.ACTION_UP && event.keyCode == wakingKey) {
wakingKey = null
return true
}
val woke = saver.onInput()
if (woke && event.action == KeyEvent.ACTION_DOWN && event.keyCode !in PASS_THROUGH_KEYS) {
wakingKey = event.keyCode
return true
}
return super.dispatchKeyEvent(event)
}
override fun dispatchTouchEvent(event: MotionEvent): Boolean {
if (saver.onInput() && event.actionMasked == MotionEvent.ACTION_DOWN) return true
return super.dispatchTouchEvent(event)
}
override fun dispatchGenericMotionEvent(event: MotionEvent): Boolean {
saver.onInput()
return super.dispatchGenericMotionEvent(event)
}
/** Remote media keys while the app is in front go straight to the player. */
override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
val playback = Musyx.graph(this).state.playback
when (keyCode) {
KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE, KeyEvent.KEYCODE_HEADSETHOOK -> playback.toggle()
KeyEvent.KEYCODE_MEDIA_PLAY -> playback.setPlaying(true)
KeyEvent.KEYCODE_MEDIA_PAUSE -> if (playback.state.status == Status.Playing) playback.toggle()
KeyEvent.KEYCODE_MEDIA_NEXT -> playback.next()
KeyEvent.KEYCODE_MEDIA_PREVIOUS -> playback.previous()
KeyEvent.KEYCODE_MEDIA_FAST_FORWARD -> playback.seekBy(SEEK_STEP_MS)
KeyEvent.KEYCODE_MEDIA_REWIND -> playback.seekBy(-SEEK_STEP_MS)
else -> return super.onKeyDown(keyCode, event)
}
return true
}
companion object {
const val SEEK_STEP_MS = 10_000L
private val PASS_THROUGH_KEYS = setOf(
KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE,
KeyEvent.KEYCODE_HEADSETHOOK,
KeyEvent.KEYCODE_MEDIA_PLAY,
KeyEvent.KEYCODE_MEDIA_PAUSE,
KeyEvent.KEYCODE_MEDIA_NEXT,
KeyEvent.KEYCODE_MEDIA_PREVIOUS,
KeyEvent.KEYCODE_MEDIA_FAST_FORWARD,
KeyEvent.KEYCODE_MEDIA_REWIND,
KeyEvent.KEYCODE_VOLUME_UP,
KeyEvent.KEYCODE_VOLUME_DOWN,
KeyEvent.KEYCODE_VOLUME_MUTE,
)
}
}
@@ -0,0 +1,63 @@
// The application: one AppState for the activity and the playback service to share.
package it.panov.musyx.tv
import android.app.Application
import android.content.Context
import android.content.res.Resources
import androidx.core.os.ConfigurationCompat
import coil3.ImageLoader
import coil3.PlatformContext
import coil3.SingletonImageLoader
import coil3.disk.DiskCache
import coil3.disk.directory
import coil3.memory.MemoryCache
import coil3.network.okhttp.OkHttpNetworkFetcherFactory
import coil3.request.crossfade
import it.panov.musyx.api.Lrclib
import it.panov.musyx.data.CredentialStore
import it.panov.musyx.data.SettingsStore
import it.panov.musyx.state.AppState
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.withContext
class Musyx : Application(), SingletonImageLoader.Factory {
/** Lives as long as the process; everything in it runs on the main thread. */
val scope = CoroutineScope(SupervisorJob() + Dispatchers.Main.immediate)
override fun onCreate() {
super.onCreate()
Lrclib.agent = "Musyx-TV/${BuildConfig.VERSION_NAME} (https://git.panov.it/panov/musyz-mobile)"
}
val state: AppState by lazy {
AppState(
context = this,
scope = scope,
credentialStore = CredentialStore(this),
settingsStore = SettingsStore(this),
systemLanguage = { ConfigurationCompat.getLocales(Resources.getSystem().configuration)[0]?.language.orEmpty() },
clearCovers = {
withContext(Dispatchers.IO) { SingletonImageLoader.get(this@Musyx).diskCache?.clear() }
},
)
}
/** Covers: kept in memory and on disk so rows of cards open instantly the second time. */
override fun newImageLoader(context: PlatformContext): ImageLoader = ImageLoader.Builder(context)
.components { add(OkHttpNetworkFetcherFactory()) }
.memoryCache { MemoryCache.Builder().maxSizePercent(context, 0.2).build() }
.diskCache {
DiskCache.Builder().directory(cacheDir.resolve("covers")).maxSizeBytes(COVER_CACHE_BYTES).build()
}
.crossfade(true)
.build()
companion object {
private const val COVER_CACHE_BYTES = 200L * 1024 * 1024
/** The app state, from any context of this app. */
fun graph(context: Context): Musyx = context.applicationContext as Musyx
}
}
@@ -0,0 +1,44 @@
// Background audio and remote control: the media session that the TV's Now Playing card,
// the remote's media keys and Google Assistant talk to.
package it.panov.musyx.tv.player
import android.app.PendingIntent
import android.content.Intent
import androidx.annotation.OptIn
import androidx.media3.common.util.UnstableApi
import androidx.media3.session.MediaSession
import androidx.media3.session.MediaSessionService
import it.panov.musyx.tv.MainActivity
import it.panov.musyx.tv.Musyx
@OptIn(UnstableApi::class)
class PlaybackService : MediaSessionService() {
private var session: MediaSession? = null
override fun onCreate() {
super.onCreate()
val open = PendingIntent.getActivity(
this,
0,
Intent(this, MainActivity::class.java).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP),
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT,
)
session = MediaSession.Builder(this, Musyx.graph(this).state.playback.sessionPlayer)
.setSessionActivity(open)
.build()
}
override fun onGetSession(controllerInfo: MediaSession.ControllerInfo): MediaSession? = session
override fun onTaskRemoved(rootIntent: Intent?) {
val player = session?.player
if (player == null || !player.playWhenReady || player.mediaItemCount == 0) stopSelf()
}
override fun onDestroy() {
// The player belongs to the app and outlives the service.
session?.release()
session = null
super.onDestroy()
}
}
@@ -0,0 +1,121 @@
// Words and numbers as the interface shows them, in the interface language.
package it.panov.musyx.tv.ui
import androidx.compose.runtime.Composable
import androidx.compose.runtime.ReadOnlyComposable
import androidx.compose.ui.platform.LocalResources
import androidx.compose.ui.res.pluralStringResource
import androidx.compose.ui.res.stringResource
import it.panov.musyx.tv.R
import it.panov.musyx.api.AlbumKind
import it.panov.musyx.api.AlbumSummary
import it.panov.musyx.api.Clip
import it.panov.musyx.api.PlaylistSummary
import it.panov.musyx.api.Track
import it.panov.musyx.state.UiText
@Composable
fun text(ui: UiText): String {
val res = LocalResources.current
fun resolve(t: UiText): String = when (t) {
is UiText.Raw -> t.text
is UiText.Res -> res.getString(t.id, *t.args.map { if (it is UiText) resolve(it) else it }.toTypedArray())
is UiText.Plural -> res.getQuantityString(t.id, t.count, *t.args.map { if (it is UiText) resolve(it) else it }.toTypedArray())
}
return resolve(ui)
}
@Composable
@ReadOnlyComposable
fun Track.artistsOrUnknown(): String = artistLine ?: if (spoken) "" else stringResource(R.string.unknown_artist)
@Composable
@ReadOnlyComposable
fun Clip.artistsOrUnknown(): String = artistLine ?: stringResource(R.string.unknown_artist)
@Composable
@ReadOnlyComposable
fun kindLabel(kind: AlbumKind): String = stringResource(
when (kind) {
AlbumKind.Album -> R.string.kind_album
AlbumKind.Single -> R.string.kind_single
AlbumKind.Compilation -> R.string.kind_compilation
AlbumKind.Podcast -> R.string.kind_podcast
AlbumKind.Audiobook -> R.string.kind_audiobook
},
)
/** "Кино · 1988", the line under a card. Podcasts often list no artist: "Podcast · 2022". */
@Composable
@ReadOnlyComposable
fun AlbumSummary.subtitle(): String {
val who = artistLine ?: kindLabel(kind)
return if (year != null) "$who · $year" else who
}
@Composable
@ReadOnlyComposable
fun PlaylistSummary.subtitle(): String {
val count = tracksWord(trackCount)
return if (ownerName.isEmpty()) count else "$ownerName · $count"
}
/** "1 track", "12 tracks". */
@Composable
@ReadOnlyComposable
fun tracksWord(n: Int): String = pluralStringResource(R.plurals.tracks, n, n)
/** "47 min" or "1 h 12 min". */
@Composable
@ReadOnlyComposable
fun durationWords(ms: Long): String {
val mins = (ms / 60_000).toInt()
return if (mins >= 60) stringResource(R.string.duration_h_min, mins / 60, mins % 60)
else stringResource(R.string.duration_min, mins)
}
/** `m:ss`, or `h:mm:ss` for podcast-length items. */
fun clock(ms: Long): String {
val s = (ms.coerceAtLeast(0) / 1000)
val (h, m, sec) = Triple(s / 3600, (s / 60) % 60, s % 60)
return if (h > 0) "%d:%02d:%02d".format(h, m, sec) else "%d:%02d".format(m, sec)
}
/** "4.1M", "830K", "912"; in Russian "4,1 млн", "830 тыс.", "912". */
fun compact(n: Long, russian: Boolean): String {
val (value, en, ru) = when {
n >= 1_000_000 -> Triple("%.1f".format(java.util.Locale.US, n / 1e6), "M", " млн")
n >= 10_000 -> Triple((n / 1000).toString(), "K", " тыс.")
n >= 1_000 -> Triple("%.1f".format(java.util.Locale.US, n / 1e3), "K", " тыс.")
else -> return n.toString()
}
val v = value.removeSuffix(".0")
return if (russian) v.replace('.', ',') + ru else v + en
}
@Composable
@ReadOnlyComposable
fun isRussian(): Boolean = stringResource(R.string.lang_code) == "ru"
/** A compact count and its noun: "4.1M listeners a month", "3 лайка". */
@Composable
@ReadOnlyComposable
fun counted(n: Long, plural: Int): String {
// An abbreviated number ("4,1 млн") reads as many.
val form = if (n >= 1_000) 5 else n.toInt().coerceAtLeast(0)
return pluralStringResource(plural, form, compact(n, isRussian()))
}
/** `2027-01-05T00:00:00+03:00` → `5 January 2027` (`5 января 2027`). */
@Composable
@ReadOnlyComposable
fun humanDate(iso: String): String? {
if (iso.length < 10) return null
val parts = iso.substring(0, 10).split('-')
if (parts.size != 3) return null
val year = parts[0].toIntOrNull() ?: return null
val month = parts[1].toIntOrNull()?.takeIf { it in 1..12 } ?: return null
val day = parts[2].toIntOrNull() ?: return null
val months = LocalResources.current.getStringArray(R.array.months_genitive)
return "$day ${months[month - 1]} $year"
}
@@ -0,0 +1,275 @@
// The app's frame: the full-screen sign-in states, and once signed in the navigation
// drawer, the routed content, the mini player, dialogs and toasts.
package it.panov.musyx.tv.ui
import androidx.activity.compose.BackHandler
import androidx.annotation.DrawableRes
import androidx.annotation.StringRes
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.core.FastOutSlowInEasing
import androidx.compose.animation.core.animateDpAsState
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.animation.core.tween
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.foundation.background
import androidx.compose.foundation.focusGroup
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.selection.selectableGroup
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveableStateHolder
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clipToBounds
import androidx.compose.ui.draw.drawBehind
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusProperties
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.focus.onFocusChanged
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.selected
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.tv.material3.LocalContentColor
import androidx.tv.material3.NavigationDrawerItemDefaults
import androidx.tv.material3.Text
import it.panov.musyx.tv.R
import it.panov.musyx.state.AppState
import it.panov.musyx.state.Route
import it.panov.musyx.state.Session
import it.panov.musyx.tv.ui.components.onInk
import it.panov.musyx.tv.ui.components.FocusEntry
import it.panov.musyx.tv.ui.components.Focusable
import it.panov.musyx.tv.ui.components.LocalDrawer
import it.panov.musyx.tv.ui.components.MusyxIcon
import it.panov.musyx.tv.ui.screens.AlbumScreen
import it.panov.musyx.tv.ui.screens.ArtistScreen
import it.panov.musyx.tv.ui.screens.ChartScreen
import it.panov.musyx.tv.ui.screens.CollectionScreen
import it.panov.musyx.tv.ui.screens.GenreScreen
import it.panov.musyx.tv.ui.screens.HoldingScreen
import it.panov.musyx.tv.ui.screens.HomeScreen
import it.panov.musyx.tv.ui.screens.MiniPlayer
import it.panov.musyx.tv.ui.screens.NowPlayingScreen
import it.panov.musyx.tv.ui.screens.PlaylistScreen
import it.panov.musyx.tv.ui.screens.PodcastsScreen
import it.panov.musyx.tv.ui.screens.ScreenSaverHost
import it.panov.musyx.tv.ui.screens.ScreenSaverState
import it.panov.musyx.tv.ui.screens.SearchScreen
import it.panov.musyx.tv.ui.screens.SettingsScreen
import it.panov.musyx.tv.ui.screens.SheetHost
import it.panov.musyx.tv.ui.screens.SignInScreen
import it.panov.musyx.tv.ui.screens.ToastHost
import it.panov.musyx.tv.ui.screens.UnreachableScreen
import it.panov.musyx.tv.ui.screens.WaveScreen
import it.panov.musyx.tv.ui.theme.MusyxTheme
private const val WORDMARK = "musyx"
private const val DRAWER_MS = 150
private const val DRAWER_ITEM_SCALE = 1.05f
private const val DRAWER_DIM = 0.4f
@Composable
fun MusyxApp(state: AppState, saver: ScreenSaverState, onExit: () -> Unit) {
val c = MusyxTheme.colors
Box(Modifier.fillMaxSize().background(c.bg)) {
when (val s = state.session) {
Session.Restoring -> HoldingScreen(stringResource(R.string.session_checking))
is Session.Connecting -> HoldingScreen(stringResource(R.string.session_signing_in))
Session.Unreachable -> UnreachableScreen(state)
is Session.SignedOut -> SignInScreen(s.signIn)
is Session.SignedIn -> Shell(state, onExit)
}
ToastHost(state)
if (state.session is Session.SignedIn) ScreenSaverHost(state, saver)
}
}
/** A drawer destination. */
private class NavItem(val route: Route, @param:StringRes val label: Int, @param:DrawableRes val icon: Int)
private val NAV = listOf(
NavItem(Route.Home, R.string.nav_home, R.drawable.ic_house),
NavItem(Route.Wave, R.string.nav_wave, R.drawable.ic_audio_lines),
NavItem(Route.Search, R.string.nav_search, R.drawable.ic_search),
NavItem(Route.Collection, R.string.nav_collection, R.drawable.ic_library),
NavItem(Route.Podcasts, R.string.nav_podcasts, R.drawable.ic_podcast),
)
private val SETTINGS = NavItem(Route.Settings, R.string.nav_settings, R.drawable.ic_settings)
@Composable
private fun Shell(state: AppState, onExit: () -> Unit) {
val c = MusyxTheme.colors
val route = state.nav.current
val entry = remember { FocusEntry() }
val pages = rememberSaveableStateHolder()
// Each newly shown screen puts focus on its first control.
LaunchedEffect(route) { entry.pending = true }
BackHandler { if (!state.back()) onExit() }
val drawerItem = remember { FocusRequester() }
Box(Modifier.fillMaxSize().background(c.bg)) {
// The page sits beside the rail and keeps its size: the open drawer covers it rather
// than pushing it, so opening never re-lays out the page.
Column(Modifier.fillMaxSize().padding(start = drawerWidth(open = false))) {
Box(Modifier.weight(1f).fillMaxWidth()) {
pages.SaveableStateProvider(route.toString()) {
CompositionLocalProvider(LocalDrawer provides drawerItem) { Page(state, route, entry) }
}
}
if (route != Route.NowPlaying && state.playback.state.hasTrack) MiniPlayer(state)
}
Drawer(current = state.nav.section, onNavigate = state::navigate, selectedItem = drawerItem)
}
SheetHost(state)
}
@Composable
private fun Page(state: AppState, route: Route, entry: FocusEntry) {
when (route) {
Route.Home -> HomeScreen(state, entry)
Route.Wave -> WaveScreen(state, entry)
Route.Search -> SearchScreen(state, entry)
Route.Collection -> CollectionScreen(state, entry)
Route.Podcasts -> PodcastsScreen(state, entry)
Route.Settings -> SettingsScreen(state, entry)
Route.NowPlaying -> NowPlayingScreen(state, entry)
Route.Chart -> ChartScreen(state, entry)
is Route.Genre -> GenreScreen(state, route.index, entry)
is Route.Album -> AlbumScreen(state, route, entry)
is Route.Artist -> ArtistScreen(state, route, entry)
is Route.Playlist -> PlaylistScreen(state, route, entry)
}
}
/** The drawer's width: the icon rail while closed, labels too while open. */
@Composable
private fun drawerWidth(open: Boolean): Dp =
(if (open) NavigationDrawerItemDefaults.ExpandedDrawerItemWidth else NavigationDrawerItemDefaults.CollapsedDrawerItemWidth) +
MusyxTheme.space.m * 2
/** The rail opens while it holds focus: one short tween, and only the drawer itself moves. */
@Composable
private fun Drawer(current: Route, onNavigate: (Route) -> Unit, selectedItem: FocusRequester) {
val c = MusyxTheme.colors
val space = MusyxTheme.space
var open by remember { mutableStateOf(false) }
val motion = tween<Float>(DRAWER_MS, easing = FastOutSlowInEasing)
val width by animateDpAsState(drawerWidth(open), tween(DRAWER_MS, easing = FastOutSlowInEasing), label = "drawer")
val dim by animateFloatAsState(if (open) DRAWER_DIM else 0f, motion, label = "drawer dim")
// Dims the covered page; drawn, not composed, so it costs nothing per frame.
Box(Modifier.fillMaxSize().drawBehind { if (dim > 0f) drawRect(Color.Black, alpha = dim) })
Column(
modifier = Modifier
.fillMaxHeight()
.width(width)
.clipToBounds()
.background(c.panel)
.padding(horizontal = space.m, vertical = space.safeY)
.selectableGroup()
.onFocusChanged { open = it.hasFocus }
// Entering the drawer lands on the current destination, not the nearest item.
.focusProperties { onEnter = { selectedItem.requestFocus() } }
.focusGroup(),
verticalArrangement = Arrangement.spacedBy(space.xxs),
) {
Wordmark(expanded = open, modifier = Modifier.padding(start = space.s10, bottom = space.xl))
NAV.forEach { DrawerItem(it, current, open, selectedItem, onNavigate) }
Spacer(Modifier.weight(1f))
DrawerItem(SETTINGS, current, open, selectedItem, onNavigate)
}
}
@Composable
private fun DrawerItem(item: NavItem, current: Route, open: Boolean, selectedItem: FocusRequester, onNavigate: (Route) -> Unit) {
val c = MusyxTheme.colors
val selected = item.route == current
val iconSize = NavigationDrawerItemDefaults.IconSize
Focusable(
onClick = { onNavigate(item.route) },
modifier = Modifier
.fillMaxWidth()
.height(NavigationDrawerItemDefaults.ContainerHeightOneLine)
.semantics { this.selected = selected }
.then(if (selected) Modifier.focusRequester(selectedItem) else Modifier),
container = if (selected) c.raised else Color.Transparent,
contentColor = if (selected) c.fg else c.muted,
scale = DRAWER_ITEM_SCALE,
) {
Row(
Modifier.fillMaxSize().padding(start = (NavigationDrawerItemDefaults.CollapsedDrawerItemWidth - iconSize) / 2),
verticalAlignment = Alignment.CenterVertically,
) {
MusyxIcon(item.icon, tint = if (selected) onInk(c.accent) else LocalContentColor.current, size = iconSize)
if (open) {
// One unwrapped line, clipped while the drawer is still widening.
Text(
stringResource(item.label),
style = MusyxTheme.type.bodyMedium,
maxLines = 1,
softWrap = false,
overflow = TextOverflow.Clip,
modifier = Modifier.padding(start = MusyxTheme.space.m).weight(1f, fill = false),
)
}
}
}
}
/** `musyx` and the amber dot; only the dot while the drawer is collapsed to its rail. */
@Composable
fun Wordmark(modifier: Modifier = Modifier, expanded: Boolean = true) {
val c = MusyxTheme.colors
val scale = MusyxTheme.type.scale
val dot = (7 * scale).dp
Row(modifier = modifier) {
if (expanded) {
// Weighted, so the dot keeps its place while a widening drawer still clips the word.
Text(
WORDMARK,
style = MusyxTheme.type.wordmark,
color = c.fg,
softWrap = false,
overflow = TextOverflow.Clip,
modifier = Modifier.alignByBaseline().weight(1f, fill = false),
)
Spacer(Modifier.width((3 * scale).dp))
}
// The dot sits on the baseline, as in the desktop sidebar.
Box(
Modifier
.alignBy { it.measuredHeight }
.size(dot)
.background(c.accent, CircleShape),
)
}
}
/** Fades content in and out, for toasts and the like. */
@Composable
fun Fade(visible: Boolean, modifier: Modifier = Modifier, content: @Composable () -> Unit) {
AnimatedVisibility(visible, modifier, enter = fadeIn(), exit = fadeOut()) { content() }
}
@@ -0,0 +1,358 @@
// Buttons, chips, tabs and the focus plumbing every screen uses. Desktop hover becomes TV
// focus, and focus is ink: a focused control fills with the text colour and its content turns
// to the background colour, the way TV launchers mark focus. Tiles and covers keep their own
// colours and lift instead: they grow and cast a soft shadow.
package it.panov.musyx.tv.ui.components
import androidx.annotation.DrawableRes
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxScope
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.IntrinsicSize
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.focusGroup
import androidx.compose.animation.core.FastOutSlowInEasing
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.animation.core.tween
import androidx.compose.foundation.interaction.InteractionSource
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.interaction.collectIsFocusedAsState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.ReadOnlyComposable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.compositionLocalOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.Stable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusProperties
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.layout.onGloballyPositioned
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.tv.material3.ClickableSurfaceDefaults
import androidx.tv.material3.Icon
import androidx.tv.material3.LocalContentColor
import androidx.tv.material3.Surface
import androidx.tv.material3.Text
import it.panov.musyx.tv.R
import it.panov.musyx.tv.ui.theme.MusyxTheme
import it.panov.musyx.tv.ui.theme.TV_TYPE_SCALE
/** Icons are 18 px on the desktop; on TV they grow with the type. */
val IconSize: Dp = (18 * TV_TYPE_SCALE).dp
/**
* Where focus lands when a screen opens. The shell marks it pending on navigation; the
* screen tags its first control with [entry], which takes focus as soon as it's laid out,
* so content that arrives late still gets it.
*/
@Stable
class FocusEntry {
val requester = FocusRequester()
var pending by mutableStateOf(false)
}
/**
* The drawer's current item, for controls at a page's left edge whose Left must open the
* drawer rather than whatever the geometric search finds above them.
*/
val LocalDrawer = compositionLocalOf<FocusRequester?> { null }
fun Modifier.entry(entry: FocusEntry?): Modifier {
if (entry == null) return this
return focusRequester(entry.requester).onGloballyPositioned {
if (entry.pending && runCatching { entry.requester.requestFocus() }.isSuccess) entry.pending = false
}
}
/** Whether the enclosing [Focusable] has focus, for content that picks its own colours. */
val LocalFocused = compositionLocalOf { false }
/** `color` at rest; on a focused control's ink fill, the content colour instead. */
@Composable
@ReadOnlyComposable
fun onInk(color: Color): Color = if (LocalFocused.current) LocalContentColor.current else color
/** Secondary text: muted at rest, the content colour softened on a focused control's ink fill. */
@Composable
@ReadOnlyComposable
fun subtle(): Color = if (LocalFocused.current) LocalContentColor.current.copy(alpha = 0.72f) else MusyxTheme.colors.muted
/** How far a lifted tile rises: the elevation its shadow is drawn at. */
private val LiftElevation = 14.dp
private const val LIFT_MS = 150
/**
* Lifts a tile while `interaction` has focus: it grows to `scale` and casts a real shadow,
* offset below it the way light falls, rather than a halo around it. A black shadow vanishes
* on the dark theme's ground, so there the tile casts light instead.
*/
@Composable
fun Modifier.lift(interaction: InteractionSource, shape: Shape, scale: Float): Modifier {
val focused by interaction.collectIsFocusedAsState()
val t by animateFloatAsState(if (focused) 1f else 0f, tween(LIFT_MS, easing = FastOutSlowInEasing), label = "lift")
val elevation = with(LocalDensity.current) { LiftElevation.toPx() }
val c = MusyxTheme.colors
val shadow = if (c.isDark) c.fg.copy(alpha = 0.5f) else Color.Black
return graphicsLayer {
val grown = 1f + (scale - 1f) * t
scaleX = grown
scaleY = grown
shadowElevation = elevation * t
ambientShadowColor = shadow
spotShadowColor = shadow
this.shape = shape
clip = false
}
}
/**
* A focusable area. Focused, it fills with ink (the text colour) and its content turns to the
* background colour; `lift` keeps the resting colours and grows the area with a shadow
* instead, for coloured tiles.
*/
@Composable
fun Focusable(
onClick: () -> Unit,
modifier: Modifier = Modifier,
onLongClick: (() -> Unit)? = null,
enabled: Boolean = true,
shape: Shape = RoundedCornerShape(MusyxTheme.radius.control),
container: Color = Color.Transparent,
contentColor: Color = MusyxTheme.colors.fg,
scale: Float = 1f,
lift: Boolean = false,
content: @Composable BoxScope.() -> Unit,
) {
val c = MusyxTheme.colors
val interaction = remember { MutableInteractionSource() }
val focused by interaction.collectIsFocusedAsState()
val focusedContainer = if (lift) container else c.fg
val focusedContent = if (lift) contentColor else c.bg
Surface(
onClick = onClick,
onLongClick = onLongClick,
enabled = enabled,
modifier = if (lift) modifier.lift(interaction, shape, maxOf(scale, LIFT_SCALE)) else modifier,
shape = ClickableSurfaceDefaults.shape(shape),
colors = ClickableSurfaceDefaults.colors(
containerColor = container,
contentColor = contentColor,
focusedContainerColor = focusedContainer,
focusedContentColor = focusedContent,
pressedContainerColor = focusedContainer,
pressedContentColor = focusedContent,
disabledContainerColor = container,
disabledContentColor = c.muted.copy(alpha = 0.5f),
),
scale = ClickableSurfaceDefaults.scale(focusedScale = if (lift) 1f else scale),
border = ClickableSurfaceDefaults.border(),
glow = ClickableSurfaceDefaults.glow(),
interactionSource = interaction,
) {
CompositionLocalProvider(LocalFocused provides (focused && !lift)) { content() }
}
}
/** How much a lifted tile grows on focus. */
private const val LIFT_SCALE = 1.06f
@Composable
fun MusyxIcon(@DrawableRes icon: Int, modifier: Modifier = Modifier, tint: Color = LocalContentColor.current, size: Dp = IconSize) {
Icon(painterResource(icon), contentDescription = null, tint = tint, modifier = modifier.size(size))
}
/** The amber pill: Play, Get sign-in code, Try again. */
@Composable
fun PrimaryButton(
label: String,
onClick: () -> Unit,
modifier: Modifier = Modifier,
@DrawableRes icon: Int? = null,
enabled: Boolean = true,
) {
val c = MusyxTheme.colors
val shape = RoundedCornerShape(MusyxTheme.radius.pill)
Focusable(
onClick = onClick,
enabled = enabled,
modifier = modifier,
shape = shape,
container = c.accent,
contentColor = c.accentInk,
scale = 1.06f,
) {
ButtonContent(label, icon, PaddingValues(horizontal = 26.dp, vertical = 14.dp))
}
}
/** The outlined pill: Shuffle, Sign out, Rename. */
@Composable
fun GhostButton(
label: String,
onClick: () -> Unit,
modifier: Modifier = Modifier,
@DrawableRes icon: Int? = null,
enabled: Boolean = true,
danger: Boolean = false,
) {
val c = MusyxTheme.colors
val shape = RoundedCornerShape(MusyxTheme.radius.pill)
Focusable(
onClick = onClick,
enabled = enabled,
modifier = modifier,
shape = shape,
container = if (danger) c.like else c.raised,
contentColor = if (danger) Color.White else c.fg,
scale = 1.05f,
) {
ButtonContent(label, icon, PaddingValues(horizontal = 22.dp, vertical = 12.dp))
}
}
@Composable
private fun ButtonContent(label: String, @DrawableRes icon: Int?, padding: PaddingValues) {
Row(
Modifier.padding(padding),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(10.dp),
) {
if (icon != null) MusyxIcon(icon)
Text(label, style = MusyxTheme.type.bodyMedium, maxLines = 1)
}
}
/** A round icon-only button: like, more, transport. Focused, it's an ink disc. */
@Composable
fun IconButton(
@DrawableRes icon: Int,
onClick: () -> Unit,
modifier: Modifier = Modifier,
tint: Color = MusyxTheme.colors.muted,
size: Dp = IconSize,
padding: Dp = 10.dp,
enabled: Boolean = true,
) {
Focusable(
onClick = onClick,
enabled = enabled,
modifier = modifier,
shape = RoundedCornerShape(MusyxTheme.radius.pill),
contentColor = tint,
scale = 1.1f,
) {
MusyxIcon(icon, size = size, modifier = Modifier.padding(padding))
}
}
/** The chosen item of the [ChoiceRow] or [TabBar] around it: where focus lands on entering. */
private val LocalChosen = compositionLocalOf<FocusRequester?> { null }
/** Tags the chosen item of a row so entering the row lands on it. */
@Composable
private fun Modifier.chosen(on: Boolean): Modifier {
val chosen = LocalChosen.current
return if (on && chosen != null) focusRequester(chosen) else this
}
/** A row of choices; moving into it lands on the chosen one, not the nearest. */
@Composable
private fun ChoiceGroup(modifier: Modifier, spacing: Dp, content: @Composable () -> Unit) {
val chosen = remember { FocusRequester() }
Row(
modifier
.focusProperties { onEnter = { runCatching { chosen.requestFocus() } } }
.focusGroup(),
horizontalArrangement = Arrangement.spacedBy(spacing),
verticalAlignment = Alignment.CenterVertically,
) {
CompositionLocalProvider(LocalChosen provides chosen, content = content)
}
}
/** Chips for one setting: quality, appearance, wave mood. */
@Composable
fun ChoiceRow(modifier: Modifier = Modifier, content: @Composable () -> Unit) =
ChoiceGroup(modifier, MusyxTheme.space.s, content)
/** A choice among a few: quality, appearance, wave mood. */
@Composable
fun Chip(label: String, on: Boolean, onClick: () -> Unit, modifier: Modifier = Modifier, enabled: Boolean = true) {
val c = MusyxTheme.colors
Focusable(
onClick = onClick,
enabled = enabled,
modifier = modifier.chosen(on),
shape = RoundedCornerShape(MusyxTheme.radius.pill),
container = if (on) c.accent else c.raised,
contentColor = if (on) c.accentInk else c.fg,
scale = 1.05f,
) {
// The check keeps the choice readable while focus fills the chip with ink.
Row(
Modifier.padding(start = if (on) 12.dp else 18.dp, end = 18.dp, top = 10.dp, bottom = 10.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(6.dp),
) {
if (on) MusyxIcon(R.drawable.ic_check, size = 18.dp)
Text(label, style = MusyxTheme.type.meta, maxLines = 1)
}
}
}
/** A tab with an amber underline when selected, and an optional count beside it. */
@Composable
fun Tab(label: String, on: Boolean, onClick: () -> Unit, modifier: Modifier = Modifier, count: String? = null) {
val c = MusyxTheme.colors
Focusable(onClick = onClick, modifier = modifier.chosen(on), contentColor = if (on) c.fg else c.muted) {
// As wide as the label, so the underline doesn't stretch the tab across the row.
Column(Modifier.width(IntrinsicSize.Max).padding(horizontal = 14.dp, vertical = 8.dp)) {
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp)) {
Text(label, style = MusyxTheme.type.bodyMedium, maxLines = 1)
if (count != null) Text(count, style = MusyxTheme.type.small, color = subtle(), maxLines = 1)
}
Box(
Modifier
.padding(top = 8.dp)
.height(3.dp)
.fillMaxWidth()
.background(if (on) c.accent else Color.Transparent, RoundedCornerShape(2.dp)),
)
}
}
}
/** Tabs; moving into the bar lands on the selected tab. */
@Composable
fun TabBar(modifier: Modifier = Modifier, content: @Composable () -> Unit) = ChoiceGroup(modifier, 6.dp, content)
/** A thin rule between sections. */
@Composable
fun Divider(modifier: Modifier = Modifier) {
Box(modifier.fillMaxWidth().height(1.dp).background(MusyxTheme.colors.line))
}
@Composable
fun Spacer(width: Dp = 0.dp, height: Dp = 0.dp) {
androidx.compose.foundation.layout.Spacer(Modifier.width(width).height(height))
}
@@ -0,0 +1,266 @@
// Covers, cards, rows of cards and grids.
package it.panov.musyx.tv.ui.components
import androidx.compose.foundation.background
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxWithConstraints
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.focus.focusRestorer
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.tv.material3.Card
import androidx.tv.material3.CardDefaults
import androidx.tv.material3.Text
import coil3.compose.AsyncImage
import it.panov.musyx.tv.R
import it.panov.musyx.tv.ui.theme.CoverPlaceholder
import it.panov.musyx.tv.ui.theme.DarkColors
import it.panov.musyx.tv.ui.theme.MusyxTheme
/** Cover sizes asked of the image server. */
const val COVER_SMALL = 100
const val COVER_LARGE = 400
/** Desktop cards are 168 px wide; on TV they keep that in dp and grow on focus. */
val CardWidth = 168.dp
private const val FOCUSED_SCALE = 1.1f
/** A cover image, with the two-hue placeholder while it loads or when there's none. */
@Composable
fun Cover(url: String?, hues: Pair<Float, Float>, modifier: Modifier = Modifier, shape: Shape = RoundedCornerShape(MusyxTheme.radius.smallCover)) {
Box(modifier.clip(shape)) {
CoverPlaceholder(hues, Modifier.fillMaxSize())
if (url != null) {
AsyncImage(
model = url,
contentDescription = null,
contentScale = ContentScale.Crop,
modifier = Modifier.fillMaxSize(),
)
}
}
}
/** What a card shows. */
class CardData(
val key: Any,
val title: String,
val subtitle: String,
val cover: String?,
val hues: Pair<Float, Float>,
val round: Boolean = false,
val liked: Boolean? = null,
/** A short label on the cover's corner, such as a chart position. */
val badge: String? = null,
/** What's playing comes from this card: an equaliser on its cover. */
val playing: Boolean = false,
val onClick: () -> Unit,
val onLongClick: (() -> Unit)? = null,
)
@Composable
fun MediaCard(card: CardData, modifier: Modifier = Modifier, width: Dp = CardWidth) {
val c = MusyxTheme.colors
val shape = if (card.round) CircleShape else RoundedCornerShape(MusyxTheme.radius.cover)
Column(Modifier.width(width), verticalArrangement = Arrangement.spacedBy(9.dp)) {
val interaction = remember { MutableInteractionSource() }
Card(
onClick = card.onClick,
onLongClick = card.onLongClick,
modifier = modifier.lift(interaction, shape, FOCUSED_SCALE).fillMaxWidth().aspectRatio(1f),
shape = CardDefaults.shape(shape),
colors = CardDefaults.colors(containerColor = c.raised),
scale = CardDefaults.scale(focusedScale = 1f),
interactionSource = interaction,
) {
Box(Modifier.fillMaxSize()) {
Cover(card.cover, card.hues, Modifier.fillMaxSize(), shape)
card.badge?.let { badge ->
Text(
badge,
style = MusyxTheme.type.wordmark,
color = Color.White,
modifier = Modifier
.align(Alignment.BottomStart)
.padding(10.dp)
.background(Color.Black.copy(alpha = 0.55f), RoundedCornerShape(MusyxTheme.radius.control))
.padding(horizontal = 10.dp, vertical = 4.dp),
)
}
if (card.playing) PlayingBadge(Modifier.align(Alignment.TopStart).padding(10.dp))
if (card.liked == true) {
MusyxIcon(
R.drawable.ic_heart_fill,
tint = c.like,
modifier = Modifier.align(Alignment.TopEnd).padding(10.dp),
)
}
}
}
Column(Modifier.padding(top = MusyxTheme.space.xs)) {
Text(card.title, style = MusyxTheme.type.bodyMedium, color = c.fg, maxLines = 1, overflow = TextOverflow.Ellipsis)
Text(card.subtitle, style = MusyxTheme.type.meta, color = c.muted, maxLines = 1, overflow = TextOverflow.Ellipsis)
}
}
}
/** The equaliser on a cover whose music is playing: amber on a dark disc, legible on any art. */
@Composable
fun PlayingBadge(modifier: Modifier = Modifier) {
Box(
modifier.size(40.dp).background(Color.Black.copy(alpha = 0.6f), CircleShape),
contentAlignment = Alignment.Center,
) {
MusyxIcon(R.drawable.ic_audio_lines, tint = DarkColors.accent, size = 22.dp)
}
}
/** A heading over a horizontal row of cards, the TV way to show a shelf. */
@Composable
fun CardShelf(
title: String?,
cards: List<CardData>,
modifier: Modifier = Modifier,
entry: FocusEntry? = null,
/** A last tile that opens the whole list, such as the full chart. */
more: ShelfMore? = null,
) {
val space = MusyxTheme.space
Column(modifier, verticalArrangement = Arrangement.spacedBy(space.s)) {
if (title != null) SectionTitle(title, Modifier.padding(horizontal = space.safeX))
ShelfRow { first ->
itemsIndexed(cards, key = { _, it -> it.key }) { i, card ->
MediaCard(card, if (i == 0) first.entry(entry) else Modifier)
}
if (more != null) item(key = "more") { MoreCard(more) }
}
}
}
/**
* A horizontal row of tiles that remembers where you left it: moving into it returns to the
* tile last visited, or the first on a first visit, never whichever tile happens to sit
* under the control above. Content tags its first tile with the modifier it's given.
*/
@Composable
fun ShelfRow(spacing: Dp = MusyxTheme.space.xl, content: LazyListScope.(first: Modifier) -> Unit) {
val space = MusyxTheme.space
val first = remember { FocusRequester() }
LazyRow(
modifier = Modifier.focusRestorer(first),
horizontalArrangement = Arrangement.spacedBy(spacing),
// Room for the focused tile to grow, and for the shadow it casts below, inside the row.
contentPadding = PaddingValues(start = space.safeX, end = space.safeX, top = space.m, bottom = space.xl + space.s),
) {
content(Modifier.focusRequester(first))
}
}
/** The tile at the end of a shelf that opens the whole list. */
class ShelfMore(val label: String, val onClick: () -> Unit)
@Composable
private fun MoreCard(more: ShelfMore) {
val c = MusyxTheme.colors
val shape = RoundedCornerShape(MusyxTheme.radius.cover)
val interaction = remember { MutableInteractionSource() }
Card(
onClick = more.onClick,
modifier = Modifier.lift(interaction, shape, FOCUSED_SCALE).width(CardWidth).aspectRatio(1f),
shape = CardDefaults.shape(shape),
colors = CardDefaults.colors(containerColor = c.raised, focusedContainerColor = c.raised),
scale = CardDefaults.scale(focusedScale = 1f),
interactionSource = interaction,
) {
Column(
Modifier.fillMaxSize().padding(16.dp),
verticalArrangement = Arrangement.spacedBy(10.dp, Alignment.CenterVertically),
horizontalAlignment = Alignment.CenterHorizontally,
) {
MusyxIcon(R.drawable.ic_chevron_right, tint = c.accent, size = 36.dp)
Text(more.label, style = MusyxTheme.type.bodyMedium, color = c.fg, maxLines = 2, overflow = TextOverflow.Ellipsis)
}
}
}
/** Cards wrapped into as many columns as fit, for lists that are the whole page. */
@Composable
fun CardGrid(cards: List<CardData>, entry: FocusEntry? = null) {
val space = MusyxTheme.space
BoxWithConstraints(Modifier.padding(horizontal = space.safeX).padding(top = space.m)) {
val columns = ((maxWidth + space.xl) / (CardWidth + space.xl)).toInt().coerceAtLeast(1)
GridRows(cards, columns, entry)
}
}
@Composable
private fun GridRows(cards: List<CardData>, columns: Int, entry: FocusEntry?) {
val space = MusyxTheme.space
Column(verticalArrangement = Arrangement.spacedBy(space.xl)) {
cards.chunked(columns).forEachIndexed { r, row ->
Row(horizontalArrangement = Arrangement.spacedBy(space.xl)) {
row.forEachIndexed { i, card ->
MediaCard(card, if (r == 0 && i == 0) Modifier.entry(entry) else Modifier)
}
}
}
}
}
@Composable
fun SectionTitle(title: String, modifier: Modifier = Modifier, trailing: (@Composable () -> Unit)? = null) {
Row(modifier.fillMaxWidth(), verticalAlignment = Alignment.CenterVertically) {
Text(title, style = MusyxTheme.type.section, color = MusyxTheme.colors.fg, modifier = Modifier.weight(1f))
trailing?.invoke()
}
}
@Composable
fun ScreenTitle(title: String, modifier: Modifier = Modifier) {
Text(
title,
style = MusyxTheme.type.displayS,
color = MusyxTheme.colors.fg,
maxLines = 2,
overflow = TextOverflow.Ellipsis,
modifier = modifier.padding(horizontal = MusyxTheme.space.safeX),
)
}
/** A small square cover for rows and the mini player. */
@Composable
fun Thumb(url: String?, hues: Pair<Float, Float>, size: Dp, round: Boolean = false) {
Cover(
url,
hues,
Modifier.size(size).height(size),
if (round) CircleShape else RoundedCornerShape(MusyxTheme.radius.smallCover),
)
}
@@ -0,0 +1,46 @@
// Loading text, failures with a retry button, empty states.
package it.panov.musyx.tv.ui.components
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.widthIn
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.tv.material3.Text
import it.panov.musyx.tv.R
import it.panov.musyx.api.YmError
import it.panov.musyx.tv.ui.theme.MusyxTheme
/** Muted running text inside the safe margin. */
@Composable
fun Note(text: String, modifier: Modifier = Modifier) {
Text(
text,
style = MusyxTheme.type.body,
color = MusyxTheme.colors.muted,
modifier = modifier.padding(horizontal = MusyxTheme.space.safeX).widthIn(max = 720.dp),
)
}
/**
* A failure with a retry button. `what` is the object of "Couldn't load …", such as
* "your albums", already in the interface language.
*/
@Composable
fun Failure(error: YmError, what: String, onRetry: () -> Unit, entry: FocusEntry? = null) {
Column(
Modifier.padding(horizontal = MusyxTheme.space.safeX),
verticalArrangement = Arrangement.spacedBy(MusyxTheme.space.l),
) {
Text(
if (error is YmError.Network) stringResource(R.string.load_failed_network, what) else stringResource(R.string.load_failed, what),
style = MusyxTheme.type.body,
color = MusyxTheme.colors.muted,
modifier = Modifier.widthIn(max = 720.dp),
)
PrimaryButton(stringResource(R.string.action_try_again), onClick = onRetry, modifier = Modifier.entry(entry))
}
}
@@ -0,0 +1,230 @@
// Track rows and the play bar above lists. A row plays on select and opens its menu on a
// long press; the heart and "more" sit to its right for D-pad users. Up and down always land
// on the row itself, so a list reads as one column of stops; right reaches the buttons.
package it.panov.musyx.tv.ui.components
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.foundation.focusGroup
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusProperties
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.tv.material3.Text
import it.panov.musyx.tv.R
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.Sheet
import it.panov.musyx.tv.ui.artistsOrUnknown
import it.panov.musyx.tv.ui.clock
import it.panov.musyx.tv.ui.theme.MusyxTheme
import it.panov.musyx.tv.ui.theme.tabular
/**
* Which columns a list shows. Album pages drop the cover and album; an artist's page puts the
* album under the title instead of the artist, who would be the same on every row.
*/
data class Columns(val cover: Boolean = true, val album: Boolean = true, val artist: Boolean = true) {
companion object {
val FULL = Columns()
val ALBUM_PAGE = Columns(cover = false, album = false)
val ARTIST_PAGE = Columns(album = false, artist = false)
}
}
/**
* The rows of a track list, as items of the page's lazy column. Selecting a row plays
* the list from it; `shifts` adds chart movement; `playlist` adds edit actions.
*/
fun LazyListScope.trackItems(
state: AppState,
tracks: List<Track>,
columns: Columns = Columns.FULL,
shifts: List<Int>? = null,
playlist: PlaylistId? = null,
/** Server indices of `tracks` in `playlist`. */
positions: List<Int>? = null,
entry: FocusEntry? = null,
keyPrefix: String = "t",
/** Off in Liked tracks, where every heart would be full; unliking is in the menu. */
hearts: Boolean = true,
) {
itemsIndexed(tracks, key = { i, t -> "$keyPrefix:$i:${t.id}" }) { i, track ->
TrackRow(
index = i,
track = track,
playing = state.playback.state.track?.id == track.id,
liked = state.liked.contains(track.id),
columns = columns,
shift = shifts?.getOrNull(i),
onPlay = { state.playTracks(tracks, i) },
onLike = if (hearts) ({ state.likeTrack(track, !state.liked.contains(track.id)) }) else null,
onMore = {
val at = positions ?: tracks.indices.toList()
state.openSheet(Sheet.TrackMenu(track, playlist?.let { PlaylistSlot(it, at[i], at.getOrNull(i - 1), at.getOrNull(i + 1)) }))
},
modifier = if (i == 0) Modifier.entry(entry) else Modifier,
)
}
}
@Composable
fun TrackRow(
index: Int,
track: Track,
playing: Boolean,
liked: Boolean,
columns: Columns,
shift: Int?,
onPlay: () -> Unit,
/** Null hides the heart. */
onLike: (() -> Unit)?,
onMore: () -> Unit,
modifier: Modifier = Modifier,
) {
val c = MusyxTheme.colors
val space = MusyxTheme.space
val titleColor = when {
!track.available -> c.muted
playing -> c.accent
else -> c.fg
}
// On the focused row's ink fill, every colour gives way to the fill's content colour.
val row = remember { FocusRequester() }
val drawer = LocalDrawer.current
Row(
Modifier
.fillMaxWidth()
.padding(horizontal = space.safeX - 12.dp)
.focusProperties { onEnter = { runCatching { row.requestFocus() } } }
.focusGroup(),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(6.dp),
) {
Focusable(
onClick = { if (track.available) onPlay() },
onLongClick = onMore,
modifier = modifier
.focusRequester(row)
// The row is the left edge of the list: Left opens the drawer, never the row above.
.focusProperties { if (drawer != null) left = drawer }
.weight(1f),
) {
Row(
Modifier.padding(horizontal = 12.dp).height(MusyxTheme.shell.trackRow * 1.3f),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(14.dp),
) {
Box(Modifier.width(40.dp), contentAlignment = Alignment.Center) {
if (playing) {
MusyxIcon(R.drawable.ic_audio_lines, tint = onInk(c.accent))
} else {
Text("${index + 1}", style = MusyxTheme.type.meta.tabular(), color = subtle())
}
}
if (shift != null) ShiftMarker(shift)
if (columns.cover) Thumb(track.coverUrl(COVER_SMALL), track.hues, 48.dp)
Column(Modifier.weight(22f)) {
Text(track.fullTitle, style = MusyxTheme.type.bodyMedium, color = onInk(titleColor), maxLines = 1, overflow = TextOverflow.Ellipsis)
val subtitle = if (columns.artist) track.artistsOrUnknown() else track.album?.title.orEmpty()
if (subtitle.isNotEmpty()) {
Text(subtitle, style = MusyxTheme.type.meta, color = subtle(), maxLines = 1, overflow = TextOverflow.Ellipsis)
}
}
if (columns.album) {
Text(
track.album?.title.orEmpty(),
style = MusyxTheme.type.meta,
color = subtle(),
maxLines = 1,
overflow = TextOverflow.Ellipsis,
modifier = Modifier.weight(14f),
)
}
Text(
clock(track.durationMs),
style = MusyxTheme.type.meta.tabular(),
color = subtle(),
textAlign = TextAlign.End,
modifier = Modifier.width(64.dp),
)
}
}
if (onLike != null) {
IconButton(
if (liked) R.drawable.ic_heart_fill else R.drawable.ic_heart,
onClick = onLike,
tint = if (liked) c.like else c.muted.copy(alpha = 0.5f),
)
}
IconButton(R.drawable.ic_ellipsis, onClick = onMore)
}
}
/** The arrow beside a chart position. */
@Composable
fun ShiftMarker(shift: Int) {
val c = MusyxTheme.colors
val (glyph, colour) = when {
shift > 0 -> "▲" to c.ok
shift < 0 -> "▼" to c.like
else -> "–" to c.muted
}
Text(glyph, style = MusyxTheme.type.small, color = colour, modifier = Modifier.width(18.dp), textAlign = TextAlign.Center)
}
/**
* Play and Shuffle, then any page actions (the heart), then a summary. Shared by every page
* with tracks.
*/
@Composable
fun PlayBar(
state: AppState,
tracks: List<Track>,
modifier: Modifier = Modifier,
summary: String = "",
entry: FocusEntry? = null,
actions: @Composable () -> Unit = {},
) {
val space = MusyxTheme.space
Row(
modifier.fillMaxWidth().padding(horizontal = space.safeX),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(space.m),
) {
PrimaryButton(
stringResource(R.string.action_play),
onClick = { state.playTracks(tracks, 0) },
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) },
icon = R.drawable.ic_shuffle,
enabled = tracks.isNotEmpty(),
)
actions()
if (summary.isNotEmpty()) {
Text(summary, style = MusyxTheme.type.meta, color = MusyxTheme.colors.muted, modifier = Modifier.padding(start = space.s))
}
}
}
@@ -0,0 +1,325 @@
// Pieces several screens share: the page column, card builders, genre tiles, loading states.
package it.panov.musyx.tv.ui.screens
import android.content.ActivityNotFoundException
import android.content.Context
import android.content.Intent
import androidx.annotation.StringRes
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.focusGroup
import androidx.compose.foundation.gestures.BringIntoViewSpec
import androidx.compose.foundation.gestures.LocalBringIntoViewSpec
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxWithConstraints
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.remember
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.focusRestorer
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.core.net.toUri
import androidx.tv.material3.Text
import it.panov.musyx.tv.R
import it.panov.musyx.api.AlbumSummary
import it.panov.musyx.api.ArtistSummary
import it.panov.musyx.api.Clip
import it.panov.musyx.api.Genre
import it.panov.musyx.api.PlaylistSummary
import it.panov.musyx.api.Track
import it.panov.musyx.state.AppState
import it.panov.musyx.state.Loadable
import it.panov.musyx.state.Route
import it.panov.musyx.state.Sheet
import it.panov.musyx.state.UiText
import it.panov.musyx.tv.ui.artistsOrUnknown
import it.panov.musyx.tv.ui.clock
import it.panov.musyx.tv.ui.components.COVER_LARGE
import it.panov.musyx.tv.ui.components.CardData
import it.panov.musyx.tv.ui.components.CardShelf
import it.panov.musyx.tv.ui.components.CardWidth
import it.panov.musyx.tv.ui.components.Failure
import it.panov.musyx.tv.ui.components.FocusEntry
import it.panov.musyx.tv.ui.components.Focusable
import it.panov.musyx.tv.ui.components.Note
import it.panov.musyx.tv.ui.components.SectionTitle
import it.panov.musyx.tv.ui.components.ShelfMore
import it.panov.musyx.tv.ui.components.ShelfRow
import it.panov.musyx.tv.ui.components.entry
import it.panov.musyx.tv.ui.subtitle
import it.panov.musyx.tv.ui.theme.DarkColors
import it.panov.musyx.tv.ui.theme.MusyxTheme
import it.panov.musyx.tv.ui.theme.mix
/** A scrolling page: sections stacked with the section gap, inside the TV's safe area. */
@OptIn(ExperimentalFoundationApi::class)
@Composable
fun PageColumn(content: LazyListScope.() -> Unit) {
val space = MusyxTheme.space
CompositionLocalProvider(LocalBringIntoViewSpec provides rememberEnoughScroll()) {
LazyColumn(
state = rememberLazyListState(),
modifier = Modifier.fillMaxSize(),
contentPadding = PaddingValues(top = space.safeY, bottom = space.safeY * 2),
verticalArrangement = Arrangement.spacedBy(space.s),
content = content,
)
}
}
/** Room kept above a focused item, and below it for a card's title and subtitle. */
private val ScrollMarginTop = 40.dp
private val ScrollMarginBottom = 88.dp
/**
* Scrolls only as far as it takes to show the focused item with some room around it. TV's
* default parks focus a third of the way down, which pushed page headers off the top as soon
* as the first button took focus.
*/
@OptIn(ExperimentalFoundationApi::class)
@Composable
private fun rememberEnoughScroll(): BringIntoViewSpec {
val density = LocalDensity.current
return remember(density) {
val top = with(density) { ScrollMarginTop.toPx() }
val bottom = with(density) { ScrollMarginBottom.toPx() }
object : BringIntoViewSpec {
override fun calculateScrollDistance(offset: Float, size: Float, containerSize: Float): Float {
val end = offset + size
return when {
// Taller than the room there is: line its top up with the margin.
size > containerSize - top - bottom -> offset - top
offset < top -> offset - top
end > containerSize - bottom -> end - (containerSize - bottom)
else -> 0f
}
}
}
}
}
/** Space between two sections of a page. */
fun LazyListScope.gap(key: Any) {
item(key = key) { androidx.compose.foundation.layout.Spacer(Modifier.height(MusyxTheme.space.section - MusyxTheme.space.s)) }
}
/** An album, podcast or book. `heart` is off where every card is liked anyway. */
@Composable
fun albumCard(state: AppState, a: AlbumSummary, heart: Boolean = true) = CardData(
key = "al${a.id}",
title = a.fullTitle,
subtitle = a.subtitle(),
cover = a.coverUrl(COVER_LARGE),
hues = a.hues,
liked = heart && a.id in state.likes.albums,
playing = state.playback.state.track?.album?.id == a.id,
onClick = { state.navigate(Route.Album(a.id)) },
)
@Composable
fun artistCard(state: AppState, a: ArtistSummary) = CardData(
key = "ar${a.id}",
title = a.name,
subtitle = a.genres.firstOrNull() ?: stringResource(R.string.kind_artist),
cover = a.coverUrl(COVER_LARGE),
hues = a.hues,
round = true,
onClick = { state.navigate(Route.Artist(a.id)) },
)
@Composable
fun playlistCard(state: AppState, p: PlaylistSummary, subtitle: String? = null) = CardData(
key = "pl${p.id.key}",
title = p.title,
subtitle = subtitle ?: p.subtitle(),
cover = p.coverUrl(COVER_LARGE),
hues = p.hues,
onClick = { state.navigate(Route.Playlist(p.id)) },
)
/**
* A track as a card: select plays `tracks` from it, a long press opens its menu. `badge`
* labels the cover, such as a chart position.
*/
@Composable
fun trackCard(state: AppState, tracks: List<Track>, index: Int, badge: String? = null): CardData {
val track = tracks[index]
return CardData(
key = "tr$index:${track.id}",
title = track.fullTitle,
subtitle = track.artistsOrUnknown(),
cover = track.coverUrl(COVER_LARGE),
hues = track.hues,
liked = state.liked.contains(track.id),
badge = badge,
playing = state.playback.state.track?.id == track.id,
onClick = { if (track.available) state.playTracks(tracks, index) },
onLongClick = { state.openSheet(Sheet.TrackMenu(track)) },
)
}
/** A music video. It opens in the browser; a long press likes or unlikes it. */
@Composable
fun clipCard(state: AppState, clip: Clip): CardData {
val context = LocalContext.current
val liked = clip.id in state.likes.clips
return CardData(
key = "cl${clip.id}",
title = clip.title,
subtitle = "${clip.artistsOrUnknown()} · ${clock(clip.durationSec * 1000)}",
cover = clip.coverUrl(COVER_LARGE),
hues = clip.hues,
liked = liked,
onClick = { openClip(context, state, clip) },
onLongClick = { state.likeClip(clip, !liked) },
)
}
private fun openClip(context: Context, state: AppState, clip: Clip) {
try {
context.startActivity(Intent(Intent.ACTION_VIEW, clip.url.toUri()).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK))
state.toast(UiText.Res(R.string.toast_opening_clip, clip.title))
} catch (_: ActivityNotFoundException) {
state.toast(UiText.Res(R.string.toast_no_browser))
}
}
/**
* What to show for a [Loadable] list section: nothing yet, a note while loading, a retry on
* failure, or `loaded` with the value.
*/
fun <T> LazyListScope.loadable(
key: String,
value: Loadable<T>,
loading: @Composable () -> String,
what: @Composable () -> String,
retry: () -> Unit,
entry: FocusEntry?,
loaded: LazyListScope.(T) -> Unit,
) {
when (value) {
is Loadable.Loaded -> loaded(value.value)
is Loadable.Failed -> item(key = "$key-failed") { Failure(value.error, what(), retry, entry) }
else -> item(key = "$key-loading") { Note(loading()) }
}
}
/** Genre tiles in a shelf; sub-genres are reached from their parent's page. */
/**
* The top-level genres: a titled row on Home, or on Browse, where they're the whole page, a
* grid under the page's own title.
*/
fun LazyListScope.genreShelf(state: AppState, entry: FocusEntry?, grid: Boolean = false) {
if (!grid) {
item(key = "genres-title") { SectionTitle(stringResource(R.string.section_genres), Modifier.padding(horizontal = MusyxTheme.space.safeX)) }
}
loadable(
"genres",
state.genres,
loading = { stringResource(R.string.loading_genres) },
what = { stringResource(R.string.what_genres) },
retry = state::loadGenres,
entry = entry,
) { list ->
val top = list.withIndex().filter { (_, g) -> list.none { p -> p.subGenres.any { it.id == g.id } } }
item(key = "genres-row") {
if (grid) {
GenreGrid(top.map { (index, genre) -> genre to { state.navigate(Route.Genre(index)) } }, entry)
} else {
ShelfRow(MusyxTheme.space.m) { first ->
itemsIndexed(top, key = { _, g -> g.value.id }) { i, (index, genre) ->
GenreTile(genre, { state.navigate(Route.Genre(index)) }, if (i == 0) first.entry(entry) else Modifier)
}
}
}
}
}
}
@Composable
fun GenreTile(genre: Genre, onClick: () -> Unit, modifier: Modifier = Modifier, fill: Boolean = false) {
// Genres without a colour get the dark raised tone, so the white title reads in either theme.
val tint = genre.color?.let(::parseHex) ?: DarkColors.raised
val shape = RoundedCornerShape(MusyxTheme.radius.cover)
Focusable(onClick = onClick, modifier = modifier, shape = shape, scale = 1.06f, lift = true) {
Box(
Modifier
.then(if (fill) Modifier.fillMaxWidth() else Modifier.width(CardWidth))
.height(88.dp)
.background(Brush.linearGradient(listOf(tint, mix(tint, Color.Black, 0.45f))), shape)
.padding(horizontal = 16.dp),
contentAlignment = Alignment.CenterStart,
) {
Text(genre.title, style = MusyxTheme.type.bodyMedium, color = Color.White, maxLines = 2)
}
}
}
/** Genre tiles wrapped into as many columns as fit; moving in returns to the last tile visited. */
@Composable
private fun GenreGrid(genres: List<Pair<Genre, () -> Unit>>, entry: FocusEntry?) {
val space = MusyxTheme.space
val first = remember { FocusRequester() }
BoxWithConstraints(Modifier.fillMaxWidth().padding(horizontal = space.safeX).padding(vertical = space.m)) {
val columns = ((maxWidth + space.m) / (CardWidth + space.m)).toInt().coerceAtLeast(1)
Column(
Modifier.focusRestorer(first).focusGroup(),
verticalArrangement = Arrangement.spacedBy(space.m),
) {
genres.chunked(columns).forEachIndexed { r, row ->
// Columns share the width; a short last row keeps the same tile size.
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(space.m)) {
row.forEachIndexed { i, (genre, open) ->
val tagged = if (r == 0 && i == 0) Modifier.focusRequester(first).entry(entry) else Modifier
GenreTile(genre, open, Modifier.weight(1f).then(tagged), fill = true)
}
repeat(columns - row.size) { androidx.compose.foundation.layout.Spacer(Modifier.weight(1f)) }
}
}
}
}
}
/** `#rrggbb` → colour. */
fun parseHex(s: String): Color? {
val h = s.removePrefix("#").takeIf { s.startsWith('#') && it.length == 6 } ?: return null
val n = h.toLongOrNull(16) ?: return null
return Color(0xFF000000 or n)
}
/** A shelf of cards as one item of a page. */
fun LazyListScope.shelf(
key: String,
@StringRes title: Int?,
cards: @Composable () -> List<CardData>,
entry: FocusEntry? = null,
more: (@Composable () -> ShelfMore)? = null,
) {
item(key = key) {
val list = cards()
if (list.isNotEmpty()) CardShelf(title?.let { stringResource(it) }, list, entry = entry, more = more?.invoke())
}
}
@@ -0,0 +1,256 @@
// Album, artist and playlist pages: a cover header, then tracks and shelves.
package it.panov.musyx.tv.ui.screens
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.tv.material3.Text
import it.panov.musyx.tv.R
import it.panov.musyx.api.AlbumPage
import it.panov.musyx.api.ArtistPage
import it.panov.musyx.api.PlaylistPage
import it.panov.musyx.api.PlaylistSummary
import it.panov.musyx.api.YmError
import it.panov.musyx.state.AppState
import it.panov.musyx.state.Loadable
import it.panov.musyx.state.Page
import it.panov.musyx.state.Route
import it.panov.musyx.state.Sheet
import it.panov.musyx.tv.ui.components.COVER_LARGE
import it.panov.musyx.tv.ui.components.Columns
import it.panov.musyx.tv.ui.components.Cover
import it.panov.musyx.tv.ui.components.Failure
import it.panov.musyx.tv.ui.components.FocusEntry
import it.panov.musyx.tv.ui.components.GhostButton
import it.panov.musyx.tv.ui.components.IconButton
import it.panov.musyx.tv.ui.components.Note
import it.panov.musyx.tv.ui.components.PlayBar
import it.panov.musyx.tv.ui.components.trackItems
import it.panov.musyx.tv.ui.counted
import it.panov.musyx.tv.ui.durationWords
import it.panov.musyx.tv.ui.kindLabel
import it.panov.musyx.tv.ui.theme.MusyxTheme
import it.panov.musyx.tv.ui.tracksWord
/** How a page talks about what it's loading. */
private class What(val loading: Int, val gone: Int, val retry: Int)
/** The shared frame: loading, gone, failure, or the page. */
@Composable
private fun DetailPage(state: AppState, route: Route, what: What, entry: FocusEntry, content: LazyListScope.(Page) -> Unit) {
PageColumn {
when (val page = state.pages[route] ?: Loadable.Loading) {
is Loadable.Loaded -> content(page.value)
is Loadable.Failed -> item(key = "failed") {
if (page.error is YmError.NotFound) Note(stringResource(what.gone))
else Failure(page.error, stringResource(what.retry), { state.retryPage(route) }, entry)
}
else -> item(key = "loading") { Note(stringResource(what.loading)) }
}
}
}
/** Cover on the left; kind, title, byline, meta and actions on the right. */
@Composable
private fun Head(
cover: String?,
hues: Pair<Float, Float>,
round: Boolean,
kind: String,
title: String,
by: String?,
meta: String,
actions: (@Composable () -> Unit)? = null,
) {
val c = MusyxTheme.colors
val space = MusyxTheme.space
Row(
Modifier.padding(horizontal = space.safeX).fillMaxWidth(),
verticalAlignment = Alignment.Bottom,
horizontalArrangement = Arrangement.spacedBy(28.dp),
) {
Cover(cover, hues, Modifier.size(200.dp), if (round) CircleShape else RoundedCornerShape(MusyxTheme.radius.cover))
Column(Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(8.dp)) {
Text(kind, style = MusyxTheme.type.meta, color = c.muted, maxLines = 1)
Text(title, style = MusyxTheme.type.displayL, color = c.fg, maxLines = 2, overflow = TextOverflow.Ellipsis)
if (by != null) Text(by, style = MusyxTheme.type.bodyMedium, color = c.fg, maxLines = 1)
if (meta.isNotEmpty()) Text(meta, style = MusyxTheme.type.meta, color = c.muted, maxLines = 1)
if (actions != null) {
Row(horizontalArrangement = Arrangement.spacedBy(space.s), verticalAlignment = Alignment.CenterVertically) { actions() }
}
}
}
}
/** A round heart that adds or removes something from the collection. */
@Composable
private fun LikeButton(liked: Boolean, onClick: () -> Unit) {
val c = MusyxTheme.colors
IconButton(
if (liked) R.drawable.ic_heart_fill else R.drawable.ic_heart,
onClick = onClick,
tint = if (liked) c.like else c.fg,
padding = 12.dp,
)
}
@Composable
fun AlbumScreen(state: AppState, route: Route.Album, entry: FocusEntry) {
DetailPage(state, route, What(R.string.loading_album, R.string.gone_album, R.string.what_album), entry) { page ->
val info = (page as Page.OfAlbum).info
albumPage(state, info, entry)
}
}
private fun LazyListScope.albumPage(state: AppState, info: AlbumPage, entry: FocusEntry) {
val a = info.album
item(key = "head") {
val kind = kindLabel(a.kind).let { if (a.year != null) "$it · ${a.year}" else it }
val length = "${tracksWord(info.tracks.size)} · ${durationWords(info.tracks.sumOf { it.durationMs })}"
val artist = a.artists.firstOrNull { it.id != null }
Head(
a.coverUrl(COVER_LARGE), a.hues, false, kind, a.fullTitle, a.artistLine,
listOfNotNull(length, info.label).joinToString(" · "),
artist?.let { { GhostButton(it.name, onClick = { state.navigate(Route.Artist(it.id!!)) }, icon = R.drawable.ic_chevron_right) } },
)
}
gap("play-gap")
item(key = "play") {
val liked = a.id in state.likes.albums
PlayBar(state, info.tracks, entry = entry) { LikeButton(liked) { state.likeAlbum(a.id, !liked) } }
}
trackItems(state, info.tracks, Columns.ALBUM_PAGE, keyPrefix = "album")
}
@Composable
fun ArtistScreen(state: AppState, route: Route.Artist, entry: FocusEntry) {
DetailPage(state, route, What(R.string.loading_artist, R.string.gone_artist, R.string.what_artist), entry) { page ->
artistPage(state, (page as Page.OfArtist).info, entry)
}
}
private fun LazyListScope.artistPage(state: AppState, info: ArtistPage, entry: FocusEntry) {
val a = info.artist
item(key = "head") {
val kind = if (a.genres.isEmpty()) stringResource(R.string.kind_artist)
else stringResource(R.string.kind_artist_genres, a.genres.joinToString(", "))
val meta = info.monthlyListeners?.let { counted(it, R.plurals.listeners_a_month) }
?: a.likes?.let { counted(it, R.plurals.likes) }
?: ""
val liked = a.id in state.likes.artists
// With popular tracks the heart sits beside Play; without, it stays here.
Head(
a.coverUrl(COVER_LARGE), a.hues, true, kind, a.name, null, meta,
if (info.popular.isEmpty()) ({ LikeButton(liked) { state.likeArtist(a.id, !liked) } }) else null,
)
}
if (info.popular.isNotEmpty()) {
gap("popular-gap")
item(key = "popular-title") {
Text(
stringResource(R.string.section_popular),
style = MusyxTheme.type.section,
color = MusyxTheme.colors.fg,
modifier = Modifier.padding(horizontal = MusyxTheme.space.safeX),
)
}
item(key = "play") {
val liked = a.id in state.likes.artists
PlayBar(state, info.popular, entry = entry) { LikeButton(liked) { state.likeArtist(a.id, !liked) } }
}
trackItems(state, info.popular, Columns.ARTIST_PAGE, keyPrefix = "popular")
}
if (info.albums.isNotEmpty()) {
gap("albums-gap")
shelf("albums", R.string.tab_albums, { info.albums.map { albumCard(state, it) } })
}
if (info.alsoAlbums.isNotEmpty()) {
gap("also-gap")
shelf("also", R.string.section_appears_on, { info.alsoAlbums.map { albumCard(state, it) } })
}
if (info.clips.isNotEmpty()) {
gap("clips-gap")
shelf("clips", R.string.tab_clips, { info.clips.map { clipCard(state, it) } })
}
if (info.similar.isNotEmpty()) {
gap("similar-gap")
shelf("similar", R.string.section_similar_artists, { info.similar.map { artistCard(state, it) } })
}
}
@Composable
fun PlaylistScreen(state: AppState, route: Route.Playlist, entry: FocusEntry) {
DetailPage(state, route, What(R.string.loading_playlist, R.string.gone_playlist, R.string.what_playlist), entry) { page ->
playlistPage(state, (page as Page.OfPlaylist).info, entry)
}
}
private fun LazyListScope.playlistPage(state: AppState, info: PlaylistPage, entry: FocusEntry) {
val p = info.playlist
val own = p.id.owner == state.account?.uid
item(key = "head") {
val kind = stringResource(R.string.kind_playlist_by, stringResource(if (p.public) R.string.visibility_public else R.string.visibility_private))
val meta = "${tracksWord(info.tracks.size)} · ${durationWords(info.tracks.sumOf { it.durationMs })}"
val likeHere = !own && info.tracks.isEmpty()
Head(
p.coverUrl(COVER_LARGE), p.hues, false, kind, p.title, p.ownerName.takeIf { it.isNotEmpty() }, meta,
if (own || likeHere) ({ PlaylistActions(state, p, own) }) else null,
)
}
info.description?.let { d ->
item(key = "description") {
Text(
d,
style = MusyxTheme.type.meta,
color = MusyxTheme.colors.muted,
maxLines = 3,
overflow = TextOverflow.Ellipsis,
modifier = Modifier.padding(horizontal = MusyxTheme.space.safeX).widthIn(max = 760.dp),
)
}
}
gap("play-gap")
if (info.tracks.isEmpty()) {
item(key = "empty") { Note(stringResource(R.string.playlist_empty)) }
return
}
item(key = "play") {
PlayBar(state, info.tracks, entry = entry) {
if (!own) {
val liked = p.id in state.likes.playlists
LikeButton(liked) { state.likePlaylist(p.id, !liked) }
}
}
}
trackItems(state, info.tracks, playlist = if (own) p.id else null, positions = info.positions, keyPrefix = "pl")
}
/** Rename, visibility and delete for your own playlist; the heart for someone else's. */
@Composable
private fun PlaylistActions(state: AppState, p: PlaylistSummary, own: Boolean) {
if (own) {
GhostButton(stringResource(R.string.action_rename), onClick = { state.openSheet(Sheet.Rename(p.id, p.title)) }, icon = R.drawable.ic_pencil)
GhostButton(
stringResource(if (p.public) R.string.action_make_private else R.string.action_make_public),
onClick = { state.setPlaylistPublic(p.id, !p.public) },
icon = if (p.public) R.drawable.ic_lock else R.drawable.ic_globe,
)
GhostButton(stringResource(R.string.action_delete), onClick = { state.openSheet(Sheet.ConfirmDelete(p.id, p.title)) }, icon = R.drawable.ic_trash_2)
} else {
val liked = p.id in state.likes.playlists
LikeButton(liked) { state.likePlaylist(p.id, !liked) }
}
}
@@ -0,0 +1,320 @@
// Home and My Wave: the animated hero, the picks, station settings and other stations.
package it.panov.musyx.tv.ui.screens
import androidx.compose.animation.core.LinearEasing
import androidx.compose.animation.core.RepeatMode
import androidx.compose.animation.core.animateFloat
import androidx.compose.animation.core.infiniteRepeatable
import androidx.compose.animation.core.rememberInfiniteTransition
import androidx.compose.animation.core.tween
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Path
import androidx.compose.ui.graphics.drawscope.Stroke
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.tv.material3.Text
import it.panov.musyx.tv.R
import it.panov.musyx.api.Character
import it.panov.musyx.api.Language
import it.panov.musyx.api.MY_WAVE
import it.panov.musyx.api.Mood
import it.panov.musyx.api.Station
import it.panov.musyx.api.WaveSettings
import it.panov.musyx.player.Status
import it.panov.musyx.state.AppState
import it.panov.musyx.state.Route
import it.panov.musyx.tv.ui.components.CardWidth
import it.panov.musyx.tv.ui.components.Chip
import it.panov.musyx.tv.ui.components.PlayingBadge
import it.panov.musyx.tv.ui.components.ShelfMore
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.Focusable
import it.panov.musyx.tv.ui.components.Note
import it.panov.musyx.tv.ui.components.PrimaryButton
import it.panov.musyx.tv.ui.components.SectionTitle
import it.panov.musyx.tv.ui.components.entry
import it.panov.musyx.tv.ui.theme.MusyxTheme
import it.panov.musyx.tv.ui.theme.mix
import kotlin.math.PI
import kotlin.math.ceil
import kotlin.math.sin
/** Chart positions shown on Home before "Show all". */
private const val HOME_CHART = 12
/** Cards per Home shelf. */
private const val HOME_CARDS = 12
@Composable
fun HomeScreen(state: AppState, entry: FocusEntry) {
PageColumn {
item(key = "hero") { WaveHero(state, big = false, entry = entry) }
// Only worth a section when it has something; a failure stays in the log.
state.recent.get()?.takeIf { it.isNotEmpty() }?.let { recent ->
gap("recent-gap")
shelf("recent", R.string.section_recent, { recent.indices.map { trackCard(state, recent, it) } })
}
gap("home-gap")
loadable(
"home",
state.home,
loading = { stringResource(R.string.loading_home) },
what = { stringResource(R.string.what_home) },
retry = state::loadHome,
entry = null,
) { home ->
if (home.personal.isNotEmpty()) {
shelf("personal", R.string.section_made_for_you, {
home.personal.map { p -> playlistCard(state, p.playlist, subtitle = p.description) }
})
}
if (home.chart.isNotEmpty()) {
gap("chart-gap")
val top = home.chart.take(HOME_CHART).map { it.track }
shelf(
"chart",
R.string.section_chart,
{ top.indices.map { trackCard(state, top, it, badge = "${it + 1}") } },
more = { ShelfMore(stringResource(R.string.action_show_all_n, home.chart.size)) { state.navigate(Route.Chart) } },
)
}
if (home.newReleases.isNotEmpty()) {
gap("releases-gap")
shelf("releases", R.string.section_new_releases, { home.newReleases.take(HOME_CARDS).map { albumCard(state, it) } })
}
if (home.newPlaylists.isNotEmpty()) {
gap("playlists-gap")
shelf("new-playlists", R.string.section_new_playlists, { home.newPlaylists.take(HOME_CARDS).map { playlistCard(state, it) } })
}
}
gap("genres-gap")
genreShelf(state, null)
}
}
/** Whether My Wave itself is what's playing, and how. */
private fun myWaveStatus(state: AppState): Status? =
state.playback.state.takeIf { it.waveStation == MY_WAVE }?.status
/** The My Wave hero, on Home (`big = false`) and the My Wave screen. */
@Composable
fun WaveHero(state: AppState, big: Boolean, entry: FocusEntry?) {
val c = MusyxTheme.colors
val space = MusyxTheme.space
val status = myWaveStatus(state)
val playing = status == Status.Playing
val settings = state.waveShown
// Why My Wave stopped, when it did, so a failed start isn't silent here.
val notice = state.playback.state.takeIf { it.waveStation == MY_WAVE && status != Status.Playing }?.notice
val blurb = if (notice != null) {
noticeText(notice)
} else if (settings != null && !settings.isDefault) {
stringResource(
R.string.wave_tuned,
stringResource(moodLabel(settings.mood)).lowercase(),
stringResource(characterLabel(settings.character)).lowercase(),
stringResource(languageLabel(settings.language)).lowercase(),
)
} else {
stringResource(R.string.wave_blurb)
}
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) }
else -> Triple(R.string.action_resume, R.drawable.ic_play_fill) { state.playback.toggle() }
}
val shape = RoundedCornerShape(MusyxTheme.radius.hero)
Box(
Modifier
.padding(horizontal = space.safeX)
.fillMaxWidth()
.height(if (big) 240.dp else 168.dp)
.clip(shape)
.background(Brush.horizontalGradient(listOf(c.panel, mix(c.panel, c.accent, 0.10f))), shape),
) {
WaveArt(playing, Modifier.fillMaxSize())
Row(
Modifier.align(Alignment.BottomStart).fillMaxWidth().padding(horizontal = 28.dp, vertical = 24.dp),
verticalAlignment = Alignment.Bottom,
horizontalArrangement = Arrangement.spacedBy(28.dp),
) {
Column(Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(6.dp)) {
Text(stringResource(R.string.nav_wave), style = if (big) MusyxTheme.type.displayXl else MusyxTheme.type.displayM, color = c.fg)
Text(blurb, style = MusyxTheme.type.meta, color = c.muted, modifier = Modifier.widthIn(max = 520.dp))
}
PrimaryButton(stringResource(label), onClick = action, icon = icon, modifier = Modifier.entry(entry))
}
}
}
/** Lines drifting across the hero. They move only while My Wave plays. */
@Composable
private fun WaveArt(playing: Boolean, modifier: Modifier) {
val accent = MusyxTheme.colors.accent
val transition = rememberInfiniteTransition(label = "wave")
val drift by transition.animateFloat(
initialValue = 0f,
targetValue = (2 * PI * 20).toFloat(),
animationSpec = infiniteRepeatable(tween(durationMillis = 120_000, easing = LinearEasing), RepeatMode.Restart),
label = "phase",
)
val phase = if (playing) drift else 0f
val energy = if (playing) 1f else 0.45f
Canvas(modifier) {
val (w, h) = size.width to size.height
val lines = 14
for (k in 0 until lines) {
val kf = k.toFloat()
val base = h * (0.22f + kf * 0.028f)
val amp = h * (0.05f + kf * 0.006f) * energy
val freq = 1.6f + kf * 0.09f
val ph = phase * (0.35f + kf * 0.02f) + kf * 0.5f
val path = Path()
val steps = ceil(w / 8f).toInt()
for (i in 0..steps) {
val x = i * 8f
val u = x / w
val y = base + sin(u * PI.toFloat() * freq + ph) * amp + sin(u * PI.toFloat() * 4.2f - ph * 0.7f) * amp * 0.35f
if (i == 0) path.moveTo(x, y) else path.lineTo(x, y)
}
val alpha = 0.08f + (kf / lines) * 0.55f
drawPath(path, accent.copy(alpha = alpha), style = Stroke(width = 1.5f + kf * 0.12f))
}
}
}
fun moodLabel(m: Mood) = when (m) {
Mood.Any -> R.string.wave_any
Mood.Energetic -> R.string.mood_energetic
Mood.Cheerful -> R.string.mood_cheerful
Mood.Calm -> R.string.mood_calm
Mood.Sad -> R.string.mood_sad
}
fun characterLabel(ch: Character) = when (ch) {
Character.Default -> R.string.wave_any
Character.Favourite -> R.string.character_favourite
Character.Unfamiliar -> R.string.character_unfamiliar
Character.Popular -> R.string.character_popular
}
fun languageLabel(l: Language) = when (l) {
Language.Any -> R.string.wave_any
Language.Russian -> R.string.language_russian
Language.Foreign -> R.string.language_foreign
}
@Composable
fun WaveScreen(state: AppState, entry: FocusEntry) {
val space = MusyxTheme.space
PageColumn {
item(key = "hero") { WaveHero(state, big = true, entry = entry) }
gap("settings-gap")
val shown = state.waveShown
val saving = state.waveSaving != null
if (shown != null) {
item(key = "mood") {
SettingRow(stringResource(R.string.wave_mood), Mood.entries.map { m ->
Triple(stringResource(moodLabel(m)), m == shown.mood, shown.copy(mood = m))
}, saving, state::setWaveSettings)
}
item(key = "character") {
SettingRow(stringResource(R.string.wave_character), Character.entries.map { ch ->
Triple(stringResource(characterLabel(ch)), ch == shown.character, shown.copy(character = ch))
}, saving, state::setWaveSettings)
}
item(key = "language") {
SettingRow(stringResource(R.string.wave_language), Language.entries.map { l ->
Triple(stringResource(languageLabel(l)), l == shown.language, shown.copy(language = l))
}, saving, state::setWaveSettings)
}
} else {
loadable(
"wave-settings",
state.waveSettings,
loading = { stringResource(R.string.loading_wave_settings) },
what = { stringResource(R.string.what_wave_settings) },
retry = state::loadWave,
entry = null,
) {}
}
gap("stations-gap")
item(key = "stations-title") { SectionTitle(stringResource(R.string.section_stations), Modifier.padding(horizontal = space.safeX)) }
loadable(
"stations",
state.stations,
loading = { stringResource(R.string.loading_stations) },
what = { stringResource(R.string.what_stations) },
retry = state::loadWave,
entry = null,
) { list ->
val others = list.filter { it.id != MY_WAVE }
if (others.isEmpty()) {
item(key = "no-stations") { Note(stringResource(R.string.stations_none)) }
} else {
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) }
}
}
}
}
}
}
}
@Composable
private fun SettingRow(title: String, options: List<Triple<String, Boolean, WaveSettings>>, saving: Boolean, pick: (WaveSettings) -> Unit) {
val space = MusyxTheme.space
Column(Modifier.padding(horizontal = space.safeX, vertical = space.s), verticalArrangement = Arrangement.spacedBy(space.s)) {
Text(title, style = MusyxTheme.type.bodyMedium, color = MusyxTheme.colors.muted)
ChoiceRow {
options.forEach { (label, on, next) -> Chip(label, on, onClick = { if (!on && !saving) pick(next) }) }
}
}
}
@Composable
private fun StationTile(station: Station, playing: Boolean, modifier: Modifier = Modifier, onClick: () -> Unit) {
val c = MusyxTheme.colors
val tint = station.color?.let(::parseHex) ?: c.raised
val shape = RoundedCornerShape(MusyxTheme.radius.cover)
Column(Modifier.width(CardWidth), verticalArrangement = Arrangement.spacedBy(9.dp)) {
Focusable(onClick = onClick, modifier = modifier, shape = shape, container = tint, scale = 1.08f, lift = true) {
Box(Modifier.size(CardWidth), contentAlignment = Alignment.Center) {
val icon = station.iconUrl(200)
if (icon != null) AsyncImage(model = icon, contentDescription = null, modifier = Modifier.size(96.dp))
if (playing) PlayingBadge(Modifier.align(Alignment.TopStart).padding(10.dp))
}
}
Text(station.name, style = MusyxTheme.type.bodyMedium, color = c.fg, maxLines = 1)
}
}
@@ -0,0 +1,242 @@
// Collection, the chart, genres and podcasts.
package it.panov.musyx.tv.ui.screens
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import it.panov.musyx.tv.R
import it.panov.musyx.state.AppState
import it.panov.musyx.state.CollectionTab
import it.panov.musyx.state.Liked
import it.panov.musyx.state.Loadable
import it.panov.musyx.state.Route
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.Note
import it.panov.musyx.tv.ui.components.PlayBar
import it.panov.musyx.tv.ui.components.PrimaryButton
import it.panov.musyx.tv.ui.components.ScreenTitle
import it.panov.musyx.tv.ui.components.Tab
import it.panov.musyx.tv.ui.components.TabBar
import it.panov.musyx.tv.ui.components.entry
import it.panov.musyx.tv.ui.components.trackItems
import it.panov.musyx.tv.ui.durationWords
import it.panov.musyx.tv.ui.theme.MusyxTheme
import it.panov.musyx.tv.ui.tracksWord
private fun tabLabel(tab: CollectionTab) = when (tab) {
CollectionTab.Tracks -> R.string.tab_liked_tracks
CollectionTab.Albums -> R.string.tab_albums
CollectionTab.Artists -> R.string.tab_artists
CollectionTab.Playlists -> R.string.tab_playlists
CollectionTab.Clips -> R.string.tab_clips
}
@Composable
fun CollectionScreen(state: AppState, entry: FocusEntry) {
val space = MusyxTheme.space
PageColumn {
item(key = "title") { ScreenTitle(stringResource(R.string.nav_collection)) }
item(key = "tabs") {
TabBar(Modifier.padding(horizontal = space.safeX - 14.dp)) {
CollectionTab.entries.forEach { tab ->
val count = when (tab) {
CollectionTab.Tracks -> state.liked.tracks()?.size
CollectionTab.Albums -> state.albums.get()?.size
CollectionTab.Artists -> state.artists.get()?.size
CollectionTab.Playlists -> state.playlists.get()?.let { it.own.size + it.liked.size }
CollectionTab.Clips -> state.clips.get()?.size
}
Tab(
stringResource(tabLabel(tab)),
tab == state.collectionTab,
{ state.selectTab(tab) },
modifier = if (tab == state.collectionTab) Modifier.entry(entry) else Modifier,
count = count?.toString(),
)
}
}
}
gap("body-gap")
when (state.collectionTab) {
CollectionTab.Tracks -> when (val liked = state.liked) {
Liked.NotLoaded, Liked.Loading -> item(key = "loading") { Note(stringResource(R.string.loading_liked)) }
is Liked.Failed -> item(key = "failed") {
Failure(liked.error, stringResource(R.string.what_liked), state::loadLiked)
}
is Liked.Loaded -> if (liked.tracks.isEmpty()) {
item(key = "empty") { Note(stringResource(R.string.empty_liked)) }
} else {
item(key = "play") {
PlayBar(
state,
liked.tracks,
summary = "${tracksWord(liked.tracks.size)} · ${durationWords(liked.tracks.sumOf { it.durationMs })}",
)
}
trackItems(state, liked.tracks, keyPrefix = "liked", hearts = false)
}
}
CollectionTab.Albums -> loadable(
"albums", state.albums,
loading = { stringResource(R.string.loading_what, stringResource(R.string.what_albums)) },
what = { stringResource(R.string.what_albums) },
retry = { state.forceLoadTab(CollectionTab.Albums) },
entry = null,
) { albums ->
item(key = "grid") {
if (albums.isEmpty()) Note(stringResource(R.string.empty_albums))
else CardGrid(albums.map { albumCard(state, it, heart = false) })
}
}
CollectionTab.Artists -> loadable(
"artists", state.artists,
loading = { stringResource(R.string.loading_what, stringResource(R.string.what_artists)) },
what = { stringResource(R.string.what_artists) },
retry = { state.forceLoadTab(CollectionTab.Artists) },
entry = null,
) { artists ->
item(key = "grid") {
if (artists.isEmpty()) Note(stringResource(R.string.empty_artists))
else CardGrid(artists.map { artistCard(state, it) })
}
}
CollectionTab.Playlists -> loadable(
"playlists", state.playlists,
loading = { stringResource(R.string.loading_what, stringResource(R.string.what_playlists)) },
what = { stringResource(R.string.what_playlists) },
retry = { state.forceLoadTab(CollectionTab.Playlists) },
entry = null,
) { p ->
item(key = "new") {
Box(Modifier.padding(horizontal = space.safeX)) {
Chip(stringResource(R.string.action_new_playlist), false, { state.openSheet(it.panov.musyx.state.Sheet.NewPlaylist(null)) })
}
}
if (p.own.isEmpty() && p.liked.isEmpty()) {
item(key = "empty") { Note(stringResource(R.string.empty_playlists)) }
}
if (p.own.isNotEmpty()) shelf("own", R.string.section_your_playlists, { p.own.map { playlistCard(state, it) } })
if (p.liked.isNotEmpty()) {
gap("liked-gap")
shelf("liked", R.string.section_liked_playlists, { p.liked.map { playlistCard(state, it) } })
}
}
CollectionTab.Clips -> loadable(
"clips", state.clips,
loading = { stringResource(R.string.loading_what, stringResource(R.string.what_clips)) },
what = { stringResource(R.string.what_clips) },
retry = { state.forceLoadTab(CollectionTab.Clips) },
entry = null,
) { clips ->
item(key = "grid") {
if (clips.isEmpty()) Note(stringResource(R.string.empty_clips))
else CardGrid(clips.map { clipCard(state, it) })
}
item(key = "hint") { Note(stringResource(R.string.clips_hint)) }
}
}
}
}
@Composable
fun ChartScreen(state: AppState, entry: FocusEntry) {
PageColumn {
item(key = "title") { ScreenTitle(stringResource(R.string.section_chart)) }
loadable(
"chart", state.home,
loading = { stringResource(R.string.loading_chart) },
what = { stringResource(R.string.what_chart) },
retry = state::loadHome,
entry = entry,
) { home ->
if (home.chart.isEmpty()) {
item(key = "empty") { Note(stringResource(R.string.chart_empty)) }
return@loadable
}
val tracks = home.chart.map { it.track }
item(key = "play") { PlayBar(state, tracks, summary = stringResource(R.string.chart_blurb), entry = entry) }
trackItems(state, tracks, shifts = home.chart.map { it.shift }, keyPrefix = "chart")
}
}
}
@Composable
fun GenreScreen(state: AppState, index: Int, entry: FocusEntry) {
val space = MusyxTheme.space
val genres = state.genres.get().orEmpty()
val genre = genres.getOrNull(index)
PageColumn {
if (genre == null) {
// The list itself may still be on its way (after a language switch).
item(key = "gone") {
Note(stringResource(if (state.genres.get() == null) R.string.loading_genres else R.string.genre_gone))
}
return@PageColumn
}
item(key = "title") {
Row(
Modifier.fillMaxWidth().padding(end = space.safeX),
verticalAlignment = Alignment.CenterVertically,
) {
Box(Modifier.weight(1f)) { ScreenTitle(genre.title) }
PrimaryButton(
stringResource(R.string.action_play_radio),
onClick = { state.playWave("genre:${genre.id}") },
icon = R.drawable.ic_audio_lines,
modifier = Modifier.entry(entry),
)
}
}
val subs = genre.subGenres.mapNotNull { s -> genres.indexOfFirst { it.id == s.id }.takeIf { it >= 0 }?.let { it to s } }
if (subs.isNotEmpty()) {
item(key = "subs") {
Row(Modifier.padding(horizontal = space.safeX), horizontalArrangement = Arrangement.spacedBy(space.s)) {
subs.take(8).forEach { (i, s) -> Chip(s.title, false, { state.navigate(Route.Genre(i)) }) }
}
}
}
gap("playlists-gap")
val playlists = state.genrePlaylists[index] ?: Loadable.Loading
loadable(
"playlists", playlists,
loading = { stringResource(R.string.loading_playlists) },
what = { stringResource(R.string.what_the_playlists) },
retry = { state.loadGenre(index, force = true) },
entry = null,
) { list ->
if (list.isEmpty()) item(key = "empty") { Note(stringResource(R.string.genre_empty)) }
else item(key = "grid") { CardGrid(list.map { playlistCard(state, it) }) }
}
}
}
@Composable
fun PodcastsScreen(state: AppState, entry: FocusEntry) {
PageColumn {
item(key = "title") { ScreenTitle(stringResource(R.string.podcasts_title)) }
val mine = state.albums.get()?.filter { it.isPodcast }.orEmpty()
if (mine.isNotEmpty()) {
shelf("yours", R.string.section_yours, { mine.map { albumCard(state, it, heart = false) } }, entry)
gap("featured-gap")
}
loadable(
"featured", state.podcasts,
loading = { stringResource(R.string.loading_podcasts) },
what = { stringResource(R.string.what_podcasts) },
retry = state::loadPodcasts,
entry = entry,
) { list ->
shelf("featured", R.string.section_featured, { list.map { albumCard(state, it) } }, if (mine.isEmpty()) entry else null)
}
}
}
@@ -0,0 +1,586 @@
// Now Playing: a stage with the cover over a blurred copy of itself, what's playing beside it
// and the transport along the bottom; the queue and lyrics slide in from the right on request.
// Also the mini player that sits under every other screen.
package it.panov.musyx.tv.ui.screens
import android.os.Build
import androidx.activity.compose.BackHandler
import androidx.annotation.DrawableRes
import androidx.annotation.StringRes
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.core.tween
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.slideInHorizontally
import androidx.compose.animation.slideOutHorizontally
import androidx.compose.foundation.focusGroup
import androidx.compose.foundation.layout.BoxWithConstraints
import androidx.compose.foundation.layout.offset
import androidx.compose.ui.draw.blur
import androidx.compose.ui.draw.shadow
import androidx.compose.ui.focus.FocusDirection
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusProperties
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale
import coil3.compose.AsyncImage
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.focusable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.interaction.collectIsFocusedAsState
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.input.key.Key
import androidx.compose.ui.input.key.KeyEventType
import androidx.compose.ui.input.key.key
import androidx.compose.ui.input.key.onPreviewKeyEvent
import androidx.compose.ui.input.key.type
import androidx.compose.ui.res.pluralStringResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.tv.material3.Text
import it.panov.musyx.tv.MainActivity
import it.panov.musyx.tv.R
import it.panov.musyx.api.Lyrics
import it.panov.musyx.api.LyricsSource
import it.panov.musyx.api.Track
import it.panov.musyx.player.Notice
import it.panov.musyx.player.PlaybackState
import it.panov.musyx.player.Repeat
import it.panov.musyx.player.Status
import it.panov.musyx.state.AppState
import it.panov.musyx.state.Loadable
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
import it.panov.musyx.tv.ui.components.subtle
import it.panov.musyx.tv.ui.components.onInk
import it.panov.musyx.tv.ui.components.COVER_LARGE
import it.panov.musyx.tv.ui.components.COVER_SMALL
import it.panov.musyx.tv.ui.components.Cover
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.PrimaryButton
import it.panov.musyx.tv.ui.components.Tab
import it.panov.musyx.tv.ui.components.TabBar
import it.panov.musyx.tv.ui.components.Thumb
import it.panov.musyx.tv.ui.components.entry
import it.panov.musyx.tv.ui.theme.MusyxTheme
import it.panov.musyx.tv.ui.theme.tabular
/** Upcoming items listed at once; a long liked list would otherwise build thousands of rows. */
private const val QUEUE_SHOWN = 100
@Composable
internal fun noticeText(notice: Notice): String = when (notice) {
Notice.StationDry -> stringResource(R.string.notice_station_dry)
Notice.TooManyFailures -> stringResource(R.string.notice_too_many)
is Notice.Skipped -> stringResource(R.string.notice_skipped, notice.title)
}
/** The cover on the stage: as large as the stage's height allows under the transport. */
private val StageCover = 320.dp
/** The queue and lyrics panel that slides in over the stage's right edge. */
private val PanelWidth = 380.dp
@Composable
fun NowPlayingScreen(state: AppState, entry: FocusEntry) {
val p = state.playback.state
val c = MusyxTheme.colors
val space = MusyxTheme.space
val track = p.track
if (track == null) {
Column(
Modifier.fillMaxSize().padding(horizontal = space.safeX, vertical = space.safeY),
verticalArrangement = Arrangement.spacedBy(space.m),
) {
Text(stringResource(R.string.nothing_playing), style = MusyxTheme.type.displayS, color = c.fg)
Text(p.notice?.let { noticeText(it) } ?: stringResource(R.string.pick_a_track), style = MusyxTheme.type.body, color = c.muted)
}
return
}
var panel by rememberSaveable { mutableStateOf<Panel?>(null) }
val panelEntry = remember { FocusEntry() }
val toggles = remember { mapOf(Panel.Queue to FocusRequester(), Panel.Lyrics to FocusRequester()) }
var closedFrom by remember { mutableStateOf<Panel?>(null) }
val open = { which: Panel ->
panel = which
panelEntry.pending = true
}
val close = {
closedFrom = panel
panel = null
}
BackHandler(enabled = panel != null) { close() }
// Back from the panel returns focus to the button that opened it.
LaunchedEffect(closedFrom) {
closedFrom?.let { runCatching { toggles.getValue(it).requestFocus() } }
closedFrom = null
}
Box(Modifier.fillMaxSize()) {
Backdrop(track)
Column(
Modifier
.fillMaxSize()
.padding(horizontal = space.safeX, vertical = space.safeY)
// While the panel is open the stage sits behind it, out of the D-pad's reach.
.focusProperties { onEnter = { if (panel != null) cancelFocusChange() } }
.focusGroup(),
) {
Row(
Modifier.weight(1f).fillMaxWidth(),
horizontalArrangement = Arrangement.spacedBy(space.section + 6.dp),
verticalAlignment = Alignment.CenterVertically,
) {
Cover(
track.coverUrl(COVER_LARGE),
track.hues,
Modifier
.size(StageCover)
.shadow(28.dp, RoundedCornerShape(MusyxTheme.radius.cover), clip = false),
RoundedCornerShape(MusyxTheme.radius.cover),
)
TrackInfo(state, p, track, Modifier.weight(1f))
}
SeekBar(state, p, Modifier.padding(top = space.xl))
Row(Modifier.fillMaxWidth().padding(top = space.s), verticalAlignment = Alignment.CenterVertically) {
Transport(state, p, entry)
androidx.compose.foundation.layout.Spacer(Modifier.weight(1f))
PanelToggle(R.drawable.ic_list_music, R.string.panel_queue, panel == Panel.Queue, toggles.getValue(Panel.Queue)) {
if (panel == Panel.Queue) close() else open(Panel.Queue)
}
PanelToggle(R.drawable.ic_mic_vocal, R.string.panel_lyrics, panel == Panel.Lyrics, toggles.getValue(Panel.Lyrics)) {
if (panel == Panel.Lyrics) close() else open(Panel.Lyrics)
}
}
}
AnimatedVisibility(
panel != null,
modifier = Modifier.align(Alignment.CenterEnd),
enter = slideInHorizontally(tween(PANEL_MS)) { it } + fadeIn(tween(PANEL_MS)),
exit = slideOutHorizontally(tween(PANEL_MS)) { it } + fadeOut(tween(PANEL_MS)),
) {
// The last panel stays composed while it slides away.
val shown = remember { mutableStateOf(Panel.Queue) }
panel?.let { shown.value = it }
SidePanel(
state,
p,
shown.value,
onPanel = { panel = it },
entry = panelEntry,
modifier = Modifier
.width(PanelWidth)
.fillMaxHeight()
// Leaving the panel leftward closes it, rather than jumping over the stage
// into the drawer; up, down and right stay inside.
.focusProperties {
onExit = {
when (requestedFocusDirection) {
FocusDirection.Left -> {
cancelFocusChange()
close()
}
FocusDirection.Up, FocusDirection.Down, FocusDirection.Right -> cancelFocusChange()
// Focus handed back to the button that opened the panel goes through.
else -> Unit
}
}
},
)
}
}
}
private const val PANEL_MS = 220
/** The cover again, blurred across the whole stage and washed with the background. */
@Composable
private fun Backdrop(track: Track) {
val c = MusyxTheme.colors
// Blur needs Android 12; before it the cover would show sharp, so it's washed out further.
val blurs = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S
AsyncImage(
model = track.coverUrl(COVER_LARGE),
contentDescription = null,
contentScale = ContentScale.Crop,
modifier = Modifier.fillMaxSize().then(if (blurs) Modifier.blur(90.dp) else Modifier),
)
Box(
Modifier
.fillMaxSize()
.background(
Brush.verticalGradient(
0f to c.bg.copy(alpha = if (blurs) 0.62f else 0.9f),
1f to c.bg.copy(alpha = if (blurs) 0.9f else 0.96f),
),
),
)
}
/** Quality, title, artist, album and year, the notice when there is one, and the actions. */
@Composable
private fun TrackInfo(state: AppState, p: PlaybackState, track: Track, modifier: Modifier) {
val c = MusyxTheme.colors
Column(modifier, verticalArrangement = Arrangement.spacedBy(10.dp)) {
p.stream?.let { s ->
val label = if (s.preview) stringResource(R.string.badge_preview) else s.label
Text(
label,
style = MusyxTheme.type.small,
color = if (s.lossless) c.accent else c.muted,
modifier = Modifier
.border(1.dp, if (s.lossless) c.accent else c.line, RoundedCornerShape(4.dp))
.padding(horizontal = 8.dp, vertical = 2.dp),
)
}
Text(track.fullTitle, style = MusyxTheme.type.displayM, color = c.fg, maxLines = 3, overflow = TextOverflow.Ellipsis)
Text(track.artistsOrUnknown(), style = MusyxTheme.type.section, color = c.fg, maxLines = 1, overflow = TextOverflow.Ellipsis)
track.album?.let { album ->
val line = listOfNotNull(album.title.takeIf { it.isNotBlank() }, album.year?.toString()).joinToString(" · ")
if (line.isNotEmpty()) Text(line, style = MusyxTheme.type.body, color = c.muted, maxLines = 1, overflow = TextOverflow.Ellipsis)
}
val notice = p.notice
if (notice != null && (p.status == Status.Loading || p.status == Status.Paused)) {
Text(noticeText(notice), style = MusyxTheme.type.meta, color = c.like, maxLines = 2)
}
TrackActions(state, track, Modifier.padding(top = 6.dp))
}
}
/** Position and length around a bar; focused, left and right step through the track. */
@Composable
private fun SeekBar(state: AppState, p: PlaybackState, modifier: Modifier = Modifier) {
val c = MusyxTheme.colors
val position = state.playback.positionMs.coerceAtMost(p.durationMs)
val interaction = remember { MutableInteractionSource() }
val focused by interaction.collectIsFocusedAsState()
val fraction = if (p.durationMs > 0) position.toFloat() / p.durationMs else 0f
Row(modifier, verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(14.dp)) {
Text(clock(position), style = MusyxTheme.type.meta.tabular(), color = c.muted)
BoxWithConstraints(
Modifier
.weight(1f)
.height(28.dp)
.onPreviewKeyEvent { e ->
if (e.type != KeyEventType.KeyDown) return@onPreviewKeyEvent false
when (e.key) {
Key.DirectionLeft -> { state.playback.seekBy(-MainActivity.SEEK_STEP_MS); true }
Key.DirectionRight -> { state.playback.seekBy(MainActivity.SEEK_STEP_MS); true }
else -> false
}
}
.focusable(interactionSource = interaction),
contentAlignment = Alignment.CenterStart,
) {
val bar = if (focused) 8.dp else 5.dp
val done = fraction.coerceIn(0f, 1f)
Box(Modifier.fillMaxWidth().height(bar).background(c.fg.copy(alpha = 0.18f), RoundedCornerShape(4.dp)))
Box(Modifier.fillMaxWidth(done).height(bar).background(c.accent, RoundedCornerShape(4.dp)))
// Focused, a knob marks the playhead: left and right move it.
if (focused) {
Box(
Modifier
.offset(x = maxWidth * done - 9.dp)
.size(18.dp)
.background(c.fg, CircleShape),
)
}
}
Text(clock(p.durationMs), style = MusyxTheme.type.meta.tabular(), color = c.muted)
}
}
@Composable
private fun Transport(state: AppState, p: PlaybackState, entry: FocusEntry) {
val c = MusyxTheme.colors
val playback = state.playback
val playing = p.status == Status.Playing || p.status == Status.Loading
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(12.dp)) {
// A station decides its own order.
Toggle(R.drawable.ic_shuffle, on = p.shuffle, onClick = playback::toggleShuffle, enabled = p.waveStation == null)
IconButton(R.drawable.ic_skip_back, onClick = playback::previous, tint = c.fg)
// The play disc: amber, round, with the text colour as its focus ring.
Focusable(
onClick = playback::toggle,
modifier = Modifier.entry(entry),
shape = CircleShape,
container = c.accent,
contentColor = c.accentInk,
scale = 1.08f,
) {
MusyxIcon(if (playing) R.drawable.ic_pause_fill else R.drawable.ic_play_fill, Modifier.padding(18.dp), size = 30.dp)
}
IconButton(R.drawable.ic_skip_forward, onClick = playback::next, tint = c.fg)
Toggle(
if (p.repeat == Repeat.One) R.drawable.ic_repeat_1 else R.drawable.ic_repeat,
on = p.repeat != Repeat.Off,
onClick = playback::cycleRepeat,
)
}
}
/**
* Shuffle and repeat: the text colour when off, amber with a dot under it when on, and faded
* only when it can't be used, so off never reads as disabled.
*/
@Composable
private fun Toggle(@DrawableRes icon: Int, on: Boolean, onClick: () -> Unit, enabled: Boolean = true) {
val c = MusyxTheme.colors
Box(contentAlignment = Alignment.BottomCenter) {
IconButton(icon, onClick = onClick, tint = if (on) c.accent else c.fg, enabled = enabled)
if (on && enabled) Box(Modifier.padding(bottom = 1.dp).size(5.dp).background(c.accent, CircleShape))
}
}
/** Opens the queue or the lyrics panel; lit while its panel is open. */
@Composable
private fun PanelToggle(@DrawableRes icon: Int, @StringRes label: Int, on: Boolean, requester: FocusRequester, onClick: () -> Unit) {
val c = MusyxTheme.colors
Focusable(
onClick = onClick,
modifier = Modifier.focusRequester(requester),
shape = RoundedCornerShape(MusyxTheme.radius.pill),
container = if (on) c.raised else Color.Transparent,
contentColor = if (on) c.accent else c.fg,
scale = 1.05f,
) {
Row(
Modifier.padding(horizontal = 16.dp, vertical = 10.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(8.dp),
) {
MusyxIcon(icon)
Text(stringResource(label), style = MusyxTheme.type.bodyMedium, maxLines = 1)
}
}
}
/** Like and the track menu, under the title. "Don't recommend" lives in the menu, away from the heart. */
@Composable
private fun TrackActions(state: AppState, track: Track, modifier: Modifier = Modifier) {
val c = MusyxTheme.colors
val liked = state.liked.contains(track.id)
Row(modifier, verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(4.dp)) {
IconButton(
if (liked) R.drawable.ic_heart_fill else R.drawable.ic_heart,
onClick = { state.likeTrack(track, !liked) },
tint = if (liked) c.like else c.fg,
)
IconButton(R.drawable.ic_ellipsis, onClick = { state.openSheet(Sheet.TrackMenu(track)) }, tint = c.fg)
}
}
private enum class Panel { Queue, Lyrics }
@Composable
private fun SidePanel(state: AppState, p: PlaybackState, panel: Panel, onPanel: (Panel) -> Unit, entry: FocusEntry, modifier: Modifier) {
val c = MusyxTheme.colors
Column(
modifier
.shadow(24.dp, RoundedCornerShape(topStart = MusyxTheme.radius.card, bottomStart = MusyxTheme.radius.card))
.background(c.panel, RoundedCornerShape(topStart = MusyxTheme.radius.card, bottomStart = MusyxTheme.radius.card))
.padding(vertical = 20.dp, horizontal = 8.dp)
.focusGroup(),
) {
TabBar(Modifier.padding(horizontal = 8.dp)) {
Tab(stringResource(R.string.panel_queue), panel == Panel.Queue, { onPanel(Panel.Queue) }, if (panel == Panel.Queue) Modifier.entry(entry) else Modifier)
Tab(stringResource(R.string.panel_lyrics), panel == Panel.Lyrics, { onPanel(Panel.Lyrics) }, if (panel == Panel.Lyrics) Modifier.entry(entry) else Modifier)
}
val track = p.track
when {
panel == Panel.Queue -> QueueList(state, p)
track == null -> PanelNote(stringResource(R.string.lyrics_play_first))
else -> {
LaunchedEffect(track.id) { state.wantLyrics(track) }
when (val l = state.lyrics[track.id] ?: Loadable.Loading) {
is Loadable.Loaded -> l.value?.let { LyricsList(state, it) } ?: PanelNote(stringResource(R.string.lyrics_none))
is Loadable.Failed -> Column(Modifier.padding(16.dp), verticalArrangement = Arrangement.spacedBy(12.dp)) {
Text(stringResource(R.string.lyrics_failed), style = MusyxTheme.type.meta, color = c.muted)
PrimaryButton(stringResource(R.string.action_try_again), onClick = { state.retryLyrics(track) })
}
else -> PanelNote(stringResource(R.string.lyrics_loading))
}
}
}
}
}
@Composable
private fun PanelNote(text: String) {
Text(text, style = MusyxTheme.type.meta, color = MusyxTheme.colors.muted, modifier = Modifier.padding(16.dp))
}
@Composable
private fun QueueList(state: AppState, p: PlaybackState) {
val track = p.track
if (track == null) {
PanelNote(stringResource(R.string.queue_empty))
return
}
LazyColumn(contentPadding = PaddingValues(8.dp), verticalArrangement = Arrangement.spacedBy(2.dp)) {
heading("now", R.string.queue_now)
item(key = "current") { QueueItem(track, now = true, onClick = null) }
item(key = "next-heading") {
val n = p.upcoming.size
Heading(if (n == 0) stringResource(R.string.queue_nothing_after) else stringResource(R.string.queue_next_up, n))
}
itemsIndexed(p.upcoming.take(QUEUE_SHOWN), key = { _, (pos, t) -> "$pos:${t.id}" }) { _, (pos, t) ->
QueueItem(t, now = false, onClick = { state.playback.jumpTo(pos) })
}
if (p.upcoming.size > QUEUE_SHOWN) {
item(key = "more") { Heading(pluralStringResource(R.plurals.queue_and_more, p.upcoming.size - QUEUE_SHOWN, p.upcoming.size - QUEUE_SHOWN)) }
}
}
}
private fun LazyListScope.heading(key: String, id: Int) {
item(key = key) { Heading(stringResource(id)) }
}
@Composable
private fun Heading(text: String) {
Text(text, style = MusyxTheme.type.small, color = MusyxTheme.colors.muted, modifier = Modifier.padding(start = 8.dp, top = 12.dp, bottom = 6.dp))
}
@Composable
private fun QueueItem(track: Track, now: Boolean, onClick: (() -> Unit)?) {
val c = MusyxTheme.colors
Focusable(onClick = { onClick?.invoke() }, modifier = Modifier.fillMaxWidth()) {
Row(
Modifier.padding(horizontal = 8.dp, vertical = 6.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(10.dp),
) {
Thumb(track.coverUrl(COVER_SMALL), track.hues, 40.dp)
Column(Modifier.weight(1f)) {
Text(track.fullTitle, style = MusyxTheme.type.meta, color = onInk(if (now) c.accent else c.fg), maxLines = 1, overflow = TextOverflow.Ellipsis)
Text(track.artistsOrUnknown(), style = MusyxTheme.type.small, color = subtle(), maxLines = 1, overflow = TextOverflow.Ellipsis)
}
Text(clock(track.durationMs), style = MusyxTheme.type.small.tabular(), color = subtle())
}
}
}
/** Synced lyrics follow the song and seek on select; plain lyrics just scroll. */
@Composable
private fun LyricsList(state: AppState, lyrics: Lyrics) {
val c = MusyxTheme.colors
val current = lyrics.current(state.playback.positionMs)
val list = rememberLazyListState()
LaunchedEffect(current) { if (current != null) list.animateScrollToItem((current - 2).coerceAtLeast(0)) }
LazyColumn(state = list, contentPadding = PaddingValues(8.dp), verticalArrangement = Arrangement.spacedBy(2.dp)) {
itemsIndexed(lyrics.lines) { i, line ->
val (color, style) = when {
current == i -> c.fg to MusyxTheme.type.bodyMedium
current != null && i < current -> c.muted.copy(alpha = 0.6f) to MusyxTheme.type.meta
lyrics.synced -> c.muted to MusyxTheme.type.meta
else -> c.fg to MusyxTheme.type.meta
}
val at = line.atMs
Focusable(onClick = { if (at != null) state.playback.seek(at) }, modifier = Modifier.fillMaxWidth()) {
Text(line.text.ifEmpty { "♪" }, style = style, color = onInk(color), modifier = Modifier.padding(horizontal = 10.dp, vertical = 4.dp))
}
}
if (lyrics.writers.isNotEmpty()) {
item(key = "writers") {
Text(
stringResource(R.string.lyrics_writers, lyrics.writers.joinToString(", ")),
style = MusyxTheme.type.small,
color = c.muted,
modifier = Modifier.padding(10.dp),
)
}
}
if (lyrics.source == LyricsSource.Lrclib) {
item(key = "source") {
Text(
stringResource(R.string.lyrics_source_lrclib),
style = MusyxTheme.type.small,
color = c.muted,
modifier = Modifier.padding(10.dp),
)
}
}
}
}
/** The bar under every other screen: what's playing, play/pause and next. */
@Composable
fun MiniPlayer(state: AppState) {
val p = state.playback.state
val track = p.track ?: return
val c = MusyxTheme.colors
val space = MusyxTheme.space
val playing = p.status == Status.Playing || p.status == Status.Loading
val fraction = if (p.durationMs > 0) state.playback.positionMs.toFloat() / p.durationMs else 0f
Column(Modifier.fillMaxWidth().background(c.panel)) {
Box(Modifier.fillMaxWidth().height(2.dp).background(c.raised)) {
Box(Modifier.fillMaxWidth(fraction.coerceIn(0f, 1f)).height(2.dp).background(c.accent))
}
Row(
Modifier.padding(horizontal = space.safeX - 10.dp, vertical = 6.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(space.s),
) {
Focusable(onClick = { state.navigate(Route.NowPlaying) }, modifier = Modifier.weight(1f)) {
Row(
Modifier.padding(horizontal = 10.dp, vertical = 6.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(14.dp),
) {
Thumb(track.coverUrl(COVER_SMALL), track.hues, 44.dp)
Column(Modifier.weight(1f)) {
Text(track.fullTitle, style = MusyxTheme.type.bodyMedium, color = onInk(c.fg), maxLines = 1, overflow = TextOverflow.Ellipsis)
val notice = p.notice?.takeIf { p.status == Status.Loading || p.status == Status.Paused }
Text(
notice?.let { noticeText(it) } ?: track.artistsOrUnknown(),
style = MusyxTheme.type.meta,
color = if (notice != null) onInk(c.like) else subtle(),
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
}
MusyxIcon(R.drawable.ic_list_music, tint = subtle())
}
}
IconButton(if (playing) R.drawable.ic_pause_fill else R.drawable.ic_play_fill, onClick = state.playback::toggle, tint = c.fg)
IconButton(R.drawable.ic_skip_forward, onClick = state.playback::next, tint = c.fg)
}
}
}
@@ -0,0 +1,339 @@
// The app's own screen saver. While music plays the screen stays on, so the system's saver
// never starts; after the system's screen saver delay without input, photos of the artist and
// the cover drift across the screen with what's playing, and the lyrics when Settings asks for
// them. Paused for a while, or with nothing queued, the app lets go and the TV's own saver and
// sleep take over again.
package it.panov.musyx.tv.ui.screens
import android.content.Context
import android.os.SystemClock
import android.provider.Settings
import androidx.compose.animation.AnimatedContent
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.Crossfade
import androidx.compose.animation.SizeTransform
import androidx.compose.animation.core.Animatable
import androidx.compose.animation.core.LinearEasing
import androidx.compose.animation.core.tween
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.togetherWith
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.Stable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableLongStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shadow
import androidx.compose.ui.graphics.TransformOrigin
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.tv.material3.Text
import coil3.SingletonImageLoader
import coil3.compose.AsyncImage
import coil3.request.ImageRequest
import it.panov.musyx.api.Lyrics
import it.panov.musyx.api.Track
import it.panov.musyx.state.AppState
import it.panov.musyx.state.Loadable
import it.panov.musyx.player.Status
import it.panov.musyx.tv.ui.artistsOrUnknown
import it.panov.musyx.tv.ui.theme.CoverPlaceholder
import it.panov.musyx.tv.ui.theme.MusyxTheme
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
/** Used when the system's screen saver delay can't be read. */
private const val DEFAULT_DELAY_MS = 5 * 60_000L
private const val MIN_DELAY_MS = 15_000L
/** How long a paused track still keeps the screen on before the system takes over. */
private const val PAUSED_HOLD_MS = 10 * 60_000L
/** How long each photo stays, and the crossfade between two. */
private const val PHOTO_MS = 20_000L
private const val PHOTO_FADE_MS = 2_000
private const val SAVER_FADE_MS = 1_000
/** How far a photo zooms in over its time on screen. */
private const val PHOTO_ZOOM = 1.12f
/** The largest size the image server gives. */
private const val PHOTO_SIZE = 1000
/** Artists whose galleries are fetched, from the start of the track's artist list. */
private const val GALLERY_ARTISTS = 2
/** The crossfade from one lyric line to the next. */
private const val LYRIC_FADE_MS = 400
/** The caption's width, and the wider column it shares with the lyrics. */
private val CAPTION_WIDTH = 560.dp
private val LYRICS_WIDTH = 620.dp
/** When the remote was last touched, and whether the screen saver covers the app. */
@Stable
class ScreenSaverState {
var showing by mutableStateOf(false)
private set
var lastInputAt by mutableLongStateOf(SystemClock.uptimeMillis())
private set
/** Any input wakes the app. True when the saver was up, so the input only woke it. */
fun onInput(): Boolean {
lastInputAt = SystemClock.uptimeMillis()
if (!showing) return false
showing = false
return true
}
internal fun show() {
showing = true
}
internal fun hide() {
showing = false
}
}
/**
* Holds the screen on while music plays and shows the saver once the remote has been idle for
* the system's screen saver delay.
*/
@Composable
fun ScreenSaverHost(state: AppState, saver: ScreenSaverState) {
val p = state.playback.state
val playing = p.status == Status.Playing || p.status == Status.Loading
var holding by remember { mutableStateOf(false) }
LaunchedEffect(p.hasTrack, playing) {
holding = p.hasTrack
if (p.hasTrack && !playing) {
delay(PAUSED_HOLD_MS)
holding = false
}
}
val view = LocalView.current
DisposableEffect(view, holding) {
view.keepScreenOn = holding
onDispose { view.keepScreenOn = false }
}
val context = LocalContext.current
// A dialog is its own window, out of reach of the activity's key handling: no saver over it.
val allowed = holding && state.sheet == null
LaunchedEffect(allowed, saver.lastInputAt) {
if (!allowed) return@LaunchedEffect saver.hide()
val after = systemSaverDelayMs(context) ?: return@LaunchedEffect
delay(after - (SystemClock.uptimeMillis() - saver.lastInputAt))
saver.show()
}
// Artist galleries, kept for the process so a returning artist costs nothing.
val galleries = remember { mutableMapOf<Long, List<String>>() }
AnimatedVisibility(saver.showing, enter = fadeIn(tween(SAVER_FADE_MS)), exit = fadeOut(tween(SAVER_FADE_MS / 4))) {
p.track?.let { ScreenSaver(state, it, galleries) }
}
}
/** The delay the user chose for the system's screen saver, or null when it never starts. */
private fun systemSaverDelayMs(context: Context): Long? {
val ms = Settings.System.getLong(context.contentResolver, Settings.System.SCREEN_OFF_TIMEOUT, DEFAULT_DELAY_MS)
return if (ms <= 0 || ms >= Int.MAX_VALUE) null else ms.coerceAtLeast(MIN_DELAY_MS)
}
/** One photo on screen; `n` tells two showings of the same photo apart. */
private data class Slide(val url: String?, val n: Int)
@Composable
private fun ScreenSaver(state: AppState, track: Track, galleries: MutableMap<Long, List<String>>) {
val context = LocalContext.current
var slide by remember { mutableStateOf(Slide(null, 0)) }
LaunchedEffect(track.id) {
// The cover first, so a new song shows as one; then the artists' photos.
var photos = (listOfNotNull(track.coverUrl(PHOTO_SIZE)) + track.artists.mapNotNull { it.coverUrl(PHOTO_SIZE) }).distinct()
slide = Slide(photos.firstOrNull(), slide.n + 1)
launch {
val client = state.client ?: return@launch
val more = track.artists.mapNotNull { it.id }.take(GALLERY_ARTISTS).flatMap { id ->
galleries[id] ?: runCatching { client.artistPhotos(id, PHOTO_SIZE) }.getOrNull()?.also { galleries[id] = it }.orEmpty()
}
photos = (photos + more).distinct()
}
var i = 0
while (true) {
photos.getOrNull((i + 1) % photos.size.coerceAtLeast(1))?.let { next ->
SingletonImageLoader.get(context).enqueue(ImageRequest.Builder(context).data(next).build())
}
delay(PHOTO_MS)
if (photos.size < 2) continue
i = (i + 1) % photos.size
slide = Slide(photos[i], slide.n + 1)
}
}
val showLyrics = state.settings.saverLyrics
LaunchedEffect(track.id, showLyrics) { if (showLyrics) state.wantLyrics(track) }
val lyrics = if (showLyrics) (state.lyrics[track.id] as? Loadable.Loaded)?.value else null
Box(Modifier.fillMaxSize().background(Color.Black)) {
Crossfade(slide, animationSpec = tween(PHOTO_FADE_MS), label = "photo") { s ->
Photo(s, track.hues)
}
Box(
Modifier
.fillMaxSize()
.background(Brush.verticalGradient(0.45f to Color.Transparent, 1f to Color.Black.copy(alpha = 0.8f))),
)
// 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.
Crossfade(slide.n % 2 == 0, animationSpec = tween(PHOTO_FADE_MS), label = "caption") { left ->
Box(Modifier.fillMaxSize()) {
if (lyrics != null) {
val shade = Color.Black.copy(alpha = 0.6f)
Box(
Modifier.fillMaxSize().background(
if (left) {
Brush.horizontalGradient(0f to shade, 0.6f to Color.Transparent)
} else {
Brush.horizontalGradient(0.4f to Color.Transparent, 1f to shade)
},
),
)
}
Box(Modifier.fillMaxSize().padding(horizontal = MusyxTheme.space.safeX, vertical = MusyxTheme.space.safeY)) {
Column(
Modifier
.align(if (left) Alignment.BottomStart else Alignment.BottomEnd)
.width(if (lyrics != null) LYRICS_WIDTH else CAPTION_WIDTH),
horizontalAlignment = if (left) Alignment.Start else Alignment.End,
) {
if (lyrics != null) {
SaverLyrics(state, lyrics, left, Modifier.fillMaxWidth().padding(bottom = MusyxTheme.space.xl))
}
Caption(state, track, left, Modifier.fillMaxWidth())
}
}
}
}
}
}
/** A photo that slowly zooms in toward one side while it's shown. */
@Composable
private fun Photo(slide: Slide, hues: Pair<Float, Float>) {
val zoom = remember { Animatable(1f) }
LaunchedEffect(Unit) {
zoom.animateTo(PHOTO_ZOOM, tween((PHOTO_MS + PHOTO_FADE_MS).toInt(), easing = LinearEasing))
}
val origin = if (slide.n % 2 == 0) TransformOrigin(0.25f, 0.35f) else TransformOrigin(0.75f, 0.35f)
Box(
Modifier.fillMaxSize().graphicsLayer {
scaleX = zoom.value
scaleY = zoom.value
transformOrigin = origin
},
) {
if (slide.url == null) {
CoverPlaceholder(hues, Modifier.fillMaxSize())
} else {
AsyncImage(
model = slide.url,
contentDescription = null,
contentScale = ContentScale.Crop,
modifier = Modifier.fillMaxSize(),
)
}
}
}
/** Artist, song, album and year, over a thin line of the track's progress. */
@Composable
private fun Caption(state: AppState, track: Track, left: Boolean, modifier: Modifier) {
val type = MusyxTheme.type
val align = if (left) TextAlign.Start else TextAlign.End
val p = state.playback.state
val fraction = if (p.durationMs > 0) state.playback.positionMs.toFloat() / p.durationMs else 0f
Column(
modifier,
horizontalAlignment = if (left) Alignment.Start else Alignment.End,
verticalArrangement = Arrangement.spacedBy(6.dp),
) {
Text(track.artistsOrUnknown(), style = type.section, color = Color.White.copy(alpha = 0.85f), textAlign = align, maxLines = 1, overflow = TextOverflow.Ellipsis)
Text(track.fullTitle, style = type.displayM, color = Color.White, textAlign = align, maxLines = 2, overflow = TextOverflow.Ellipsis)
track.album?.let { album ->
val line = listOfNotNull(album.title.takeIf { it.isNotBlank() }, album.year?.toString()).joinToString(" · ")
if (line.isNotEmpty()) {
Text(line, style = type.body, color = Color.White.copy(alpha = 0.7f), textAlign = align, maxLines = 1, overflow = TextOverflow.Ellipsis)
}
}
Box(Modifier.padding(top = MusyxTheme.space.s).fillMaxWidth().height(3.dp).background(Color.White.copy(alpha = 0.25f), RoundedCornerShape(2.dp))) {
Box(
Modifier
.fillMaxWidth(fraction.coerceIn(0f, 1f))
.height(3.dp)
.background(MusyxTheme.colors.accent, RoundedCornerShape(2.dp)),
)
}
}
}
/**
* The line being sung, large, between the one before and the one to come. Plain lyrics can't
* know the line, so all three are the same size and only roughly where the song is. The block
* is anchored at its foot and the next line's slot is always kept, so the lines sit at the same
* distance above the song name whatever they say.
*/
@Composable
private fun SaverLyrics(state: AppState, lyrics: Lyrics, left: Boolean, modifier: Modifier) {
val glance = lyrics.glance(state.playback.positionMs, state.playback.state.durationMs) ?: return
val type = MusyxTheme.type
val align = if (left) TextAlign.Start else TextAlign.End
val shadow = Shadow(Color.Black.copy(alpha = 0.7f), Offset(0f, 2f), blurRadius = 12f)
val side = type.section.copy(shadow = shadow)
val now = if (lyrics.synced) type.displayM.copy(shadow = shadow) else side
AnimatedContent(
glance,
modifier,
transitionSpec = {
fadeIn(tween(LYRIC_FADE_MS)) togetherWith fadeOut(tween(LYRIC_FADE_MS)) using SizeTransform(clip = false)
},
contentAlignment = if (left) Alignment.BottomStart else Alignment.BottomEnd,
label = "lyric",
) { g ->
Column(
Modifier.fillMaxWidth(),
horizontalAlignment = if (left) Alignment.Start else Alignment.End,
verticalArrangement = Arrangement.spacedBy(14.dp),
) {
g.previous?.let { Text(it.ifBlank { "♪" }, style = side, color = Color.White.copy(alpha = 0.45f), textAlign = align, maxLines = 1, overflow = TextOverflow.Ellipsis) }
g.current?.let { Text(it.ifBlank { "♪" }, style = now, color = Color.White, textAlign = align, maxLines = 2, overflow = TextOverflow.Ellipsis) }
val alpha = if (g.current == null || !lyrics.synced) 0.85f else 0.6f
Text(g.next?.ifBlank { "♪" }.orEmpty(), style = side, color = Color.White.copy(alpha = alpha), textAlign = align, maxLines = 1, overflow = TextOverflow.Ellipsis)
}
}
}
@@ -0,0 +1,231 @@
// Search: a field the TV keyboard fills, suggestions, results by kind, more on request.
// With no query it shows genres to browse.
package it.panov.musyx.tv.ui.screens
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.unit.dp
import androidx.tv.material3.Text
import it.panov.musyx.tv.R
import it.panov.musyx.api.BestMatch
import it.panov.musyx.api.SearchKind
import it.panov.musyx.state.ALL_TAB_TRACKS
import it.panov.musyx.state.AppState
import it.panov.musyx.state.Route
import it.panov.musyx.tv.ui.artistsOrUnknown
import it.panov.musyx.tv.ui.compact
import it.panov.musyx.tv.ui.components.subtle
import it.panov.musyx.tv.ui.components.onInk
import it.panov.musyx.tv.ui.components.COVER_LARGE
import it.panov.musyx.tv.ui.components.CardGrid
import it.panov.musyx.tv.ui.components.Cover
import it.panov.musyx.tv.ui.components.FocusEntry
import it.panov.musyx.tv.ui.components.Focusable
import it.panov.musyx.tv.ui.components.GhostButton
import it.panov.musyx.tv.ui.components.MusyxIcon
import it.panov.musyx.tv.ui.components.Note
import it.panov.musyx.tv.ui.components.PlayBar
import it.panov.musyx.tv.ui.components.ScreenTitle
import it.panov.musyx.tv.ui.components.SectionTitle
import it.panov.musyx.tv.ui.components.Tab
import it.panov.musyx.tv.ui.components.TabBar
import it.panov.musyx.tv.ui.components.entry
import it.panov.musyx.tv.ui.components.trackItems
import it.panov.musyx.tv.ui.isRussian
import it.panov.musyx.tv.ui.kindLabel
import it.panov.musyx.tv.ui.theme.MusyxTheme
fun searchKindLabel(kind: SearchKind) = when (kind) {
SearchKind.All -> R.string.search_all
SearchKind.Tracks -> R.string.search_tracks
SearchKind.Albums -> R.string.search_albums
SearchKind.Artists -> R.string.search_artists
SearchKind.Playlists -> R.string.search_playlists
SearchKind.Podcasts -> R.string.search_podcasts
}
@Composable
fun SearchScreen(state: AppState, entry: FocusEntry) {
val search = state.search
val space = MusyxTheme.space
PageColumn {
item(key = "field") {
Row(
Modifier.padding(horizontal = space.safeX).fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(space.m),
) {
MusyxIcon(R.drawable.ic_search, tint = MusyxTheme.colors.muted)
TextInput(
value = search.text,
onChange = search::change,
placeholder = stringResource(R.string.search_placeholder),
onSubmit = search::submit,
imeAction = ImeAction.Search,
modifier = Modifier.weight(1f).entry(entry),
)
}
}
if (search.suggestions.isNotEmpty()) {
items(search.suggestions.size, key = { "s$it" }) { i ->
val s = search.suggestions[i]
Focusable(onClick = { search.pick(s) }, modifier = Modifier.padding(horizontal = space.safeX).fillMaxWidth()) {
Row(
Modifier.padding(horizontal = 16.dp, vertical = 10.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(12.dp),
) {
MusyxIcon(R.drawable.ic_search, tint = subtle())
Text(s, style = MusyxTheme.type.body)
}
}
}
}
gap("title-gap")
if (search.query.isEmpty()) {
item(key = "browse") { ScreenTitle(stringResource(R.string.search_browse)) }
genreShelf(state, null, grid = true)
return@PageColumn
}
item(key = "title") { ScreenTitle(stringResource(R.string.search_results_for, search.query)) }
search.results.get()?.data?.corrected?.let { corrected ->
item(key = "corrected") { Note(stringResource(R.string.search_corrected, corrected)) }
}
item(key = "tabs") {
val russian = isRussian()
TabBar(Modifier.padding(horizontal = space.safeX - 14.dp)) {
SearchKind.entries.forEach { kind ->
val total = search.results.get()?.data?.totals?.get(kind)?.takeIf { it > 0 }
Tab(stringResource(searchKindLabel(kind)), kind == search.kind, { search.tab(kind) }, count = total?.let { compact(it.toLong(), russian) })
}
}
}
loadable(
"results",
search.results,
loading = { stringResource(R.string.searching) },
what = { stringResource(R.string.what_results) },
retry = search::retry,
entry = null,
) { r ->
val d = r.data
if (d.isEmpty) {
item(key = "empty") { Note(stringResource(R.string.search_nothing, search.query)) }
return@loadable
}
when (search.kind) {
SearchKind.All -> {
d.best?.let { best -> item(key = "best") { BestCard(state, best) } }
if (d.tracks.isNotEmpty()) {
gap("tracks-gap")
item(key = "tracks-title") { SectionTitle(stringResource(R.string.search_tracks), Modifier.padding(horizontal = space.safeX)) }
trackItems(state, d.tracks.take(ALL_TAB_TRACKS), keyPrefix = "top")
// Where Down from the last track lands, like the tile at the end of a shelf.
item(key = "tracks-all") {
Box(Modifier.padding(horizontal = space.safeX, vertical = space.xs)) {
GhostButton(
stringResource(R.string.search_show_all_tracks),
onClick = { search.tab(SearchKind.Tracks) },
icon = R.drawable.ic_chevron_right,
)
}
}
}
if (d.artists.isNotEmpty()) {
gap("artists-gap")
shelf("artists", R.string.search_artists, { d.artists.map { artistCard(state, it) } })
}
if (d.albums.isNotEmpty()) {
gap("albums-gap")
shelf("albums", R.string.search_albums, { d.albums.map { albumCard(state, it) } })
}
if (d.playlists.isNotEmpty()) {
gap("playlists-gap")
shelf("playlists", R.string.search_playlists, { d.playlists.map { playlistCard(state, it) } })
}
if (d.podcasts.isNotEmpty()) {
gap("podcasts-gap")
shelf("podcasts", R.string.search_podcasts, { d.podcasts.map { albumCard(state, it) } })
}
}
SearchKind.Tracks -> {
item(key = "play") { PlayBar(state, d.tracks) }
trackItems(state, d.tracks, keyPrefix = "all")
}
SearchKind.Albums -> item(key = "grid") { CardGrid(d.albums.map { albumCard(state, it) }) }
SearchKind.Artists -> item(key = "grid") { CardGrid(d.artists.map { artistCard(state, it) }) }
SearchKind.Playlists -> item(key = "grid") { CardGrid(d.playlists.map { playlistCard(state, it) }) }
SearchKind.Podcasts -> item(key = "grid") { CardGrid(d.podcasts.map { albumCard(state, it) }) }
}
if (search.hasMore(r)) {
item(key = "more") {
Box(Modifier.padding(horizontal = space.safeX, vertical = space.l)) {
GhostButton(
stringResource(if (r.loadingMore) R.string.loading else R.string.action_show_more),
onClick = search::more,
enabled = !r.loadingMore,
)
}
}
}
}
}
}
/** The top result as a wide card: cover, name, kind, and the action it implies. */
@Composable
private fun BestCard(state: AppState, best: BestMatch) {
val c = MusyxTheme.colors
val space = MusyxTheme.space
data class Shown(val cover: String?, val hues: Pair<Float, Float>, val round: Boolean, val title: String, val kind: String, val go: () -> Unit)
val shown = when (best) {
is BestMatch.OfArtist -> Shown(best.artist.coverUrl(COVER_LARGE), best.artist.hues, true, best.artist.name, stringResource(R.string.kind_artist)) {
state.navigate(Route.Artist(best.artist.id))
}
is BestMatch.OfAlbum -> Shown(
best.album.coverUrl(COVER_LARGE), best.album.hues, false, best.album.fullTitle,
listOfNotNull(kindLabel(best.album.kind), best.album.artistLine).joinToString(" · "),
) { state.navigate(Route.Album(best.album.id)) }
is BestMatch.OfPlaylist -> Shown(
best.playlist.coverUrl(COVER_LARGE), best.playlist.hues, false, best.playlist.title,
stringResource(R.string.kind_playlist_by, best.playlist.ownerName),
) { state.navigate(Route.Playlist(best.playlist.id)) }
is BestMatch.OfTrack -> Shown(
best.track.coverUrl(COVER_LARGE), best.track.hues, false, best.track.fullTitle,
stringResource(R.string.kind_track_by, best.track.artistsOrUnknown()),
) { state.playTracks(listOf(best.track), 0) }
}
Focusable(
onClick = shown.go,
modifier = Modifier.padding(horizontal = space.safeX).fillMaxWidth(),
shape = RoundedCornerShape(MusyxTheme.radius.card),
container = c.panel,
) {
Row(Modifier.padding(18.dp), verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(20.dp)) {
Cover(shown.cover, shown.hues, Modifier.size(108.dp), if (shown.round) CircleShape else RoundedCornerShape(MusyxTheme.radius.cover))
Column(Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(6.dp)) {
Text(stringResource(R.string.search_top_result), style = MusyxTheme.type.small, color = subtle())
Text(shown.title, style = MusyxTheme.type.displayS, color = onInk(c.fg), maxLines = 1)
Text(shown.kind, style = MusyxTheme.type.meta, color = subtle(), maxLines = 1)
}
MusyxIcon(
if (best is BestMatch.OfTrack) R.drawable.ic_play_fill else R.drawable.ic_chevron_right,
tint = onInk(c.accent),
modifier = Modifier.width(32.dp),
)
}
}
}
@@ -0,0 +1,400 @@
// The full-screen states outside a session: checking, unreachable, and sign-in.
package it.panov.musyx.tv.ui.screens
import android.os.SystemClock
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.ui.focus.FocusDirection
import androidx.compose.ui.focus.focusProperties
import androidx.compose.ui.input.key.Key
import androidx.compose.ui.input.key.KeyEventType
import androidx.compose.ui.input.key.key
import androidx.compose.ui.input.key.onPreviewKeyEvent
import androidx.compose.ui.input.key.type
import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.BasicTextField
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.produceState
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.runtime.withFrameNanos
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.geometry.Offset
import androidx.compose.ui.geometry.Size
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.text.input.PasswordVisualTransformation
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.em
import androidx.tv.material3.Text
import com.google.zxing.BarcodeFormat
import com.google.zxing.EncodeHintType
import com.google.zxing.qrcode.QRCodeWriter
import it.panov.musyx.tv.R
import it.panov.musyx.state.AppState
import it.panov.musyx.state.SignInState
import it.panov.musyx.tv.ui.Wordmark
import it.panov.musyx.tv.ui.components.Focusable
import it.panov.musyx.tv.ui.components.GhostButton
import it.panov.musyx.tv.ui.components.MusyxIcon
import it.panov.musyx.tv.ui.components.PrimaryButton
import it.panov.musyx.tv.ui.text
import it.panov.musyx.tv.ui.theme.MusyxTheme
import it.panov.musyx.tv.ui.theme.mix
import kotlinx.coroutines.delay
/** Shown while the stored session is checked or a new one connects. */
@Composable
fun HoldingScreen(label: String) {
Column(
Modifier.fillMaxSize(),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally,
) {
Wordmark()
Spacer(Modifier.height(MusyxTheme.space.l))
Text(label, style = MusyxTheme.type.body, color = MusyxTheme.colors.muted)
}
}
/** Stored credentials exist but Yandex can't be reached. */
@Composable
fun UnreachableScreen(state: AppState) {
val focus = remember { FocusRequester() }
LaunchedEffect(Unit) { runCatching { focus.requestFocus() } }
Column(
Modifier.fillMaxSize(),
verticalArrangement = Arrangement.spacedBy(MusyxTheme.space.l, Alignment.CenterVertically),
horizontalAlignment = Alignment.CenterHorizontally,
) {
Wordmark()
Text(stringResource(R.string.unreachable_title), style = MusyxTheme.type.displayS, color = MusyxTheme.colors.fg)
Text(
stringResource(R.string.unreachable_body),
style = MusyxTheme.type.body,
color = MusyxTheme.colors.muted,
modifier = Modifier.widthIn(max = 560.dp),
)
Row(horizontalArrangement = Arrangement.spacedBy(MusyxTheme.space.m)) {
PrimaryButton(stringResource(R.string.action_try_again), onClick = state::restore, modifier = Modifier.focusRequester(focus))
GhostButton(stringResource(R.string.action_sign_out), onClick = state::signOut, icon = R.drawable.ic_log_out)
}
}
}
@Composable
fun SignInScreen(signIn: SignInState) {
val c = MusyxTheme.colors
val space = MusyxTheme.space
val focus = remember { FocusRequester() }
LaunchedEffect(signIn.stage::class) {
// The new stage's control is placed on the next frame.
withFrameNanos { }
runCatching { focus.requestFocus() }
}
Row(Modifier.fillMaxSize()) {
Column(
Modifier
.weight(3f)
.fillMaxHeight()
// The token field can push past the bottom; focus scrolls it into view.
.verticalScroll(rememberScrollState())
.padding(horizontal = space.safeX, vertical = space.safeY),
verticalArrangement = Arrangement.spacedBy(space.l),
) {
Wordmark()
val waiting = signIn.stage is SignInState.Stage.Waiting
Text(
stringResource(R.string.signin_title),
style = if (waiting) MusyxTheme.type.section else MusyxTheme.type.displayS,
color = c.fg,
)
// While a code is up, the steps need the room.
if (!waiting) Text(stringResource(R.string.signin_blurb), style = MusyxTheme.type.meta, color = c.muted)
when (val stage = signIn.stage) {
SignInState.Stage.Idle -> PrimaryButton(
stringResource(R.string.signin_get_code),
onClick = signIn::getCode,
modifier = Modifier.focusRequester(focus),
)
SignInState.Stage.Requesting -> PrimaryButton(
stringResource(R.string.signin_getting_code),
onClick = {},
enabled = false,
)
is SignInState.Stage.Waiting -> Steps(signIn, stage, focus)
}
signIn.error?.let { Text(text(it), style = MusyxTheme.type.meta, color = c.like) }
if (!waiting) TokenFallback(signIn)
Spacer(Modifier.height(space.s))
if (!waiting) Text(stringResource(R.string.signin_footer), style = MusyxTheme.type.small, color = c.muted)
}
Box(
Modifier
.weight(2f)
.fillMaxHeight()
.background(Brush.linearGradient(listOf(c.panel, mix(c.panel, c.accent, 0.14f)))),
contentAlignment = Alignment.Center,
) {
QrCard((signIn.stage as? SignInState.Stage.Waiting)?.code?.verificationUrl)
}
}
}
@Composable
private fun Steps(signIn: SignInState, stage: SignInState.Stage.Waiting, focus: FocusRequester) {
val c = MusyxTheme.colors
val code = stage.code
val host = code.verificationUrl.removePrefix("https://").removePrefix("http://").trimEnd('/')
val remaining by produceState(stage.deadline - SystemClock.elapsedRealtime(), stage) {
while (true) {
value = (stage.deadline - SystemClock.elapsedRealtime()).coerceAtLeast(0)
delay(1_000)
}
}
Column(verticalArrangement = Arrangement.spacedBy(MusyxTheme.space.m)) {
Step(1, stringResource(R.string.signin_step_open, host), stringResource(R.string.signin_step_open_hint))
Row(horizontalArrangement = Arrangement.spacedBy(MusyxTheme.space.l)) {
Badge(2)
Column(verticalArrangement = Arrangement.spacedBy(MusyxTheme.space.s)) {
Text(stringResource(R.string.signin_step_code), style = MusyxTheme.type.bodyMedium, color = c.fg)
// Shown exactly as it must be typed: a space or capital here ends up on the phone,
// and Yandex rejects the code. Letter spacing keeps it readable without one.
Text(
code.userCode,
style = MusyxTheme.type.displayS.copy(letterSpacing = 0.12.em),
color = c.fg,
maxLines = 1,
softWrap = false,
modifier = Modifier
.background(c.panel, RoundedCornerShape(MusyxTheme.radius.card))
.border(BorderStroke(1.dp, c.line), RoundedCornerShape(MusyxTheme.radius.card))
.padding(horizontal = 20.dp, vertical = 8.dp),
)
Text(stringResource(R.string.signin_step_code_hint), style = MusyxTheme.type.small, color = c.muted)
}
}
Step(3, stringResource(R.string.signin_step_back), stringResource(R.string.signin_step_back_hint))
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(MusyxTheme.space.m)) {
Box(Modifier.size(10.dp).background(c.accent, CircleShape))
val secs = remaining / 1000
Text(
stringResource(R.string.signin_waiting, "%d:%02d".format(secs / 60, secs % 60)),
style = MusyxTheme.type.meta,
color = c.muted,
modifier = Modifier.weight(1f, fill = false),
)
GhostButton(stringResource(R.string.action_cancel), onClick = signIn::cancel, modifier = Modifier.focusRequester(focus))
}
}
}
@Composable
private fun Step(n: Int, title: String, hint: String) {
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(MusyxTheme.space.l)) {
Badge(n)
Column {
Text(title, style = MusyxTheme.type.bodyMedium, color = MusyxTheme.colors.fg)
Text(hint, style = MusyxTheme.type.small, color = MusyxTheme.colors.muted)
}
}
}
@Composable
private fun Badge(n: Int) {
val c = MusyxTheme.colors
Box(
Modifier.size(36.dp).border(BorderStroke(1.dp, c.line), CircleShape),
contentAlignment = Alignment.Center,
) {
Text("$n", style = MusyxTheme.type.meta, color = c.muted)
}
}
/** Sign-in with a token someone already has; handy where the phone flow isn't. */
@Composable
private fun TokenFallback(signIn: SignInState) {
val c = MusyxTheme.colors
Column(verticalArrangement = Arrangement.spacedBy(MusyxTheme.space.s)) {
Focusable(onClick = signIn::toggleToken, contentColor = c.muted) {
Text(
stringResource(if (signIn.tokenOpen) R.string.signin_token_hide else R.string.signin_token_show),
style = MusyxTheme.type.meta,
modifier = Modifier.padding(horizontal = 10.dp, vertical = 6.dp),
)
}
if (signIn.tokenOpen) {
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(MusyxTheme.space.m)) {
TextInput(
value = signIn.token,
onChange = { signIn.token = it },
placeholder = stringResource(R.string.signin_token_placeholder),
secret = true,
onSubmit = signIn::useToken,
modifier = Modifier.width(320.dp),
)
GhostButton(stringResource(R.string.action_sign_in), onClick = signIn::useToken, enabled = signIn.token.isNotBlank())
}
}
}
}
/**
* A text field the remote can pass through. Focused, it's a control like any other: the
* D-pad moves on and the keyboard stays down. Select (or a tap) starts editing and brings the
* keyboard up; up and down still leave, and submitting ends editing. The amber ring shows focus.
*/
@Composable
fun TextInput(
value: String,
onChange: (String) -> Unit,
placeholder: String,
modifier: Modifier = Modifier,
secret: Boolean = false,
onSubmit: () -> Unit = {},
imeAction: ImeAction = ImeAction.Done,
) {
val c = MusyxTheme.colors
val shape = RoundedCornerShape(MusyxTheme.radius.pill)
var focused by remember { mutableStateOf(false) }
var editing by remember { mutableStateOf(false) }
// Focused, the field takes the ink fill every focused control has.
val ink = if (focused) c.bg else c.fg
val field = remember { FocusRequester() }
val shell = remember { FocusRequester() }
val keyboard = LocalSoftwareKeyboardController.current
val focusManager = LocalFocusManager.current
LaunchedEffect(editing) {
if (editing) {
field.requestFocus()
keyboard?.show()
}
}
val stop = {
keyboard?.hide()
editing = false
shell.requestFocus()
}
val submit = {
stop()
onSubmit()
}
Box(
modifier
.focusRequester(shell)
.onFocusChanged { focused = it.hasFocus }
.clickable(interactionSource = remember { MutableInteractionSource() }, indication = null) { editing = true }
.background(if (focused) c.fg else c.raised, shape)
.border(BorderStroke(1.dp, if (focused) c.fg else c.line), shape)
.padding(horizontal = 20.dp, vertical = 12.dp),
) {
if (value.isEmpty()) Text(placeholder, style = MusyxTheme.type.body, color = if (focused) ink.copy(alpha = 0.72f) else c.muted, maxLines = 1)
BasicTextField(
value = value,
onValueChange = onChange,
singleLine = true,
textStyle = MusyxTheme.type.body.copy(color = ink),
cursorBrush = SolidColor(if (focused) ink else c.accent),
visualTransformation = if (secret) PasswordVisualTransformation() else androidx.compose.ui.text.input.VisualTransformation.None,
keyboardOptions = KeyboardOptions(
keyboardType = if (secret) KeyboardType.Password else KeyboardType.Text,
imeAction = imeAction,
),
keyboardActions = KeyboardActions(onDone = { submit() }, onSearch = { submit() }, onGo = { submit() }),
modifier = Modifier
.fillMaxWidth()
.focusRequester(field)
// Only reachable while editing, so moving through the page never lands in it.
.focusProperties { canFocus = editing }
.onFocusChanged { if (!it.isFocused && editing) editing = false }
.onPreviewKeyEvent { e ->
if (e.type != KeyEventType.KeyDown) return@onPreviewKeyEvent false
val direction = when (e.key) {
Key.DirectionUp -> FocusDirection.Up
Key.DirectionDown -> FocusDirection.Down
else -> return@onPreviewKeyEvent false
}
stop()
focusManager.moveFocus(direction)
true
},
)
}
}
/** The QR for the sign-in page, on a white card; a lock until a code exists. */
@Composable
private fun QrCard(url: String?) {
val matrix = remember(url) {
url?.let {
runCatching {
QRCodeWriter().encode(it, BarcodeFormat.QR_CODE, 0, 0, mapOf(EncodeHintType.MARGIN to 1))
}.getOrNull()
}
}
val ink = Color(0xFF1C1A22)
Column(
Modifier
.width(280.dp)
.background(Color.White, RoundedCornerShape(MusyxTheme.radius.hero))
.padding(24.dp),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(14.dp),
) {
Box(Modifier.size(220.dp), contentAlignment = Alignment.Center) {
if (matrix != null) {
Canvas(Modifier.fillMaxSize()) {
val cell = size.width / matrix.width
for (y in 0 until matrix.height) for (x in 0 until matrix.width) {
if (matrix[x, y]) drawRect(ink, Offset(x * cell, y * cell), Size(cell + 0.5f, cell + 0.5f))
}
}
} else {
MusyxIcon(R.drawable.ic_lock, tint = Color(0xFF686178), size = 48.dp)
}
}
Text(
stringResource(if (matrix != null) R.string.signin_qr_scan else R.string.signin_qr_later),
style = MusyxTheme.type.small,
color = Color(0xFF4A4458),
textAlign = TextAlign.Center,
)
}
}
@@ -0,0 +1,187 @@
// Settings: account, streaming quality, appearance, font size, language, screen saver, storage.
package it.panov.musyx.tv.ui.screens
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.tv.material3.Text
import it.panov.musyx.tv.BuildConfig
import it.panov.musyx.tv.R
import it.panov.musyx.data.Appearance
import it.panov.musyx.data.FontSize
import it.panov.musyx.data.Locale
import it.panov.musyx.data.Quality
import it.panov.musyx.state.AppState
import it.panov.musyx.state.qualityLabel
import it.panov.musyx.tv.ui.components.Chip
import it.panov.musyx.tv.ui.components.ChoiceRow
import it.panov.musyx.tv.ui.components.FocusEntry
import it.panov.musyx.tv.ui.components.GhostButton
import it.panov.musyx.tv.ui.components.ScreenTitle
import it.panov.musyx.tv.ui.components.entry
import it.panov.musyx.tv.ui.humanDate
import it.panov.musyx.tv.ui.theme.MusyxTheme
private fun qualityDetail(q: Quality) = when (q) {
Quality.Lossless -> R.string.quality_lossless_detail
Quality.Best -> R.string.quality_best_detail
Quality.Balanced -> R.string.quality_balanced_detail
Quality.DataSaver -> R.string.quality_data_saver_detail
}
private fun appearanceLabel(a: Appearance) = when (a) {
Appearance.System -> R.string.match_system
Appearance.Light -> R.string.appearance_light
Appearance.Dark -> R.string.appearance_dark
}
private fun fontSizeLabel(f: FontSize) = when (f) {
FontSize.Small -> R.string.font_size_small
FontSize.Medium -> R.string.font_size_medium
FontSize.Large -> R.string.font_size_large
}
@Composable
fun SettingsScreen(state: AppState, entry: FocusEntry) {
val settings = state.settings
PageColumn {
item(key = "title") { ScreenTitle(stringResource(R.string.nav_settings)) }
item(key = "account") { AccountCard(state) }
item(key = "quality") {
Section(stringResource(R.string.settings_quality)) {
ChoiceRow {
Quality.entries.forEach { q ->
Chip(
stringResource(qualityLabel(q)),
q == settings.quality,
{ if (q != settings.quality) state.setQuality(q) },
if (q == settings.quality) Modifier.entry(entry) else Modifier,
)
}
}
Text(stringResource(qualityDetail(settings.quality)), style = MusyxTheme.type.meta, color = MusyxTheme.colors.muted)
}
}
item(key = "appearance") {
Section(stringResource(R.string.settings_appearance)) {
ChoiceRow {
Appearance.entries.forEach { a ->
Chip(stringResource(appearanceLabel(a)), a == settings.appearance, { state.setAppearance(a) })
}
}
}
}
item(key = "font-size") {
Section(stringResource(R.string.settings_font_size)) {
ChoiceRow {
FontSize.entries.forEach { f ->
Chip(stringResource(fontSizeLabel(f)), f == settings.fontSize, { state.setFontSize(f) })
}
}
}
}
item(key = "language") {
Section(stringResource(R.string.settings_language)) {
ChoiceRow {
Locale.entries.forEach { l ->
// Language names stay in their own language so they can be found in either.
val label = when (l) {
Locale.System -> stringResource(R.string.match_system)
Locale.English -> "English"
Locale.Russian -> "Русский"
}
Chip(label, l == settings.language, { if (l != settings.language) state.setLanguage(l) })
}
}
}
}
item(key = "screen-saver") {
Section(stringResource(R.string.settings_screen_saver)) {
ChoiceRow {
Chip(stringResource(R.string.saver_photos), !settings.saverLyrics, { state.setSaverLyrics(false) })
Chip(stringResource(R.string.saver_photos_lyrics), settings.saverLyrics, { state.setSaverLyrics(true) })
}
Text(
stringResource(if (settings.saverLyrics) R.string.saver_photos_lyrics_detail else R.string.saver_photos_detail),
style = MusyxTheme.type.meta,
color = MusyxTheme.colors.muted,
)
}
}
item(key = "storage") {
Section(stringResource(R.string.settings_storage)) {
Text(stringResource(R.string.settings_storage_detail), style = MusyxTheme.type.meta, color = MusyxTheme.colors.muted)
GhostButton(stringResource(R.string.action_clear_covers), onClick = state::clearCoverCache, icon = R.drawable.ic_trash_2)
}
}
item(key = "version") {
Text(
stringResource(R.string.settings_version, BuildConfig.VERSION_NAME),
style = MusyxTheme.type.small,
color = MusyxTheme.colors.muted,
modifier = Modifier.padding(horizontal = MusyxTheme.space.safeX, vertical = MusyxTheme.space.l),
)
}
}
}
@Composable
private fun Section(title: String, content: @Composable () -> Unit) {
val space = MusyxTheme.space
Column(
Modifier
.padding(horizontal = space.safeX, vertical = space.s)
.fillMaxWidth()
.background(MusyxTheme.colors.panel, RoundedCornerShape(MusyxTheme.radius.card))
.padding(24.dp),
verticalArrangement = Arrangement.spacedBy(space.l),
) {
Text(title, style = MusyxTheme.type.section, color = MusyxTheme.colors.fg)
content()
}
}
@Composable
private fun AccountCard(state: AppState) {
val me = state.account ?: return
val c = MusyxTheme.colors
val space = MusyxTheme.space
val end = me.subscriptionEnd?.let { humanDate(it) }
val plan = when {
me.hasPlus && end != null -> stringResource(R.string.plus_until, end)
me.hasPlus -> stringResource(R.string.plus)
else -> stringResource(R.string.plus_none)
}
Row(
Modifier
.padding(horizontal = space.safeX, vertical = space.s)
.fillMaxWidth()
.background(c.panel, RoundedCornerShape(MusyxTheme.radius.card))
.padding(24.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(18.dp),
) {
Box(Modifier.size(64.dp).background(c.accent, CircleShape), contentAlignment = Alignment.Center) {
Text(me.initial, style = MusyxTheme.type.section, color = c.accentInk)
}
Column(Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(4.dp)) {
Text(me.name, style = MusyxTheme.type.section, color = c.fg)
Text(me.login, style = MusyxTheme.type.body, color = c.muted)
Text(plan, style = MusyxTheme.type.meta, color = if (me.hasPlus) c.ok else c.muted, modifier = Modifier.widthIn(max = 560.dp))
}
GhostButton(stringResource(R.string.action_sign_out), onClick = state::signOut, icon = R.drawable.ic_log_out)
}
}
@@ -0,0 +1,259 @@
// Dialogs over the screen (track actions, new/rename playlist, delete confirmation) and the
// toast that floats above everything after an action.
package it.panov.musyx.tv.ui.screens
import androidx.annotation.DrawableRes
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
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.res.stringResource
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Dialog
import androidx.tv.material3.Text
import it.panov.musyx.tv.R
import it.panov.musyx.state.AppState
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.components.subtle
import it.panov.musyx.tv.ui.components.Divider
import it.panov.musyx.tv.ui.components.Focusable
import it.panov.musyx.tv.ui.components.GhostButton
import it.panov.musyx.tv.ui.components.MusyxIcon
import it.panov.musyx.tv.ui.components.PrimaryButton
import it.panov.musyx.tv.ui.text
import it.panov.musyx.tv.ui.theme.MusyxTheme
import kotlinx.coroutines.delay
/** How long a status message stays up. */
private const val TOAST_MS = 4_000L
@Composable
fun SheetHost(state: AppState) {
val sheet = state.sheet ?: return
Dialog(onDismissRequest = state::closeSheet) {
val c = MusyxTheme.colors
Column(
Modifier
.width(520.dp)
.background(c.panel, RoundedCornerShape(MusyxTheme.radius.card))
.border(1.dp, c.line, RoundedCornerShape(MusyxTheme.radius.card))
.padding(20.dp),
verticalArrangement = Arrangement.spacedBy(14.dp),
) {
when (sheet) {
is Sheet.TrackMenu -> if (sheet.choosing) ChoosePlaylist(state, sheet) else TrackMenu(state, sheet)
is Sheet.NewPlaylist -> NameDialog(
title = stringResource(R.string.sheet_new_playlist),
initial = "",
hint = stringResource(if (sheet.add != null) R.string.sheet_new_hint_track else R.string.sheet_new_hint),
confirm = stringResource(R.string.action_create),
onCancel = state::closeSheet,
) { state.createPlaylist(it, sheet.add) }
is Sheet.Rename -> NameDialog(
title = stringResource(R.string.sheet_rename_playlist),
initial = sheet.name,
hint = null,
confirm = stringResource(R.string.action_rename),
onCancel = state::closeSheet,
) { state.renamePlaylist(sheet.id, it) }
is Sheet.ConfirmDelete -> {
Title(stringResource(R.string.sheet_delete_title, sheet.title), null)
Text(stringResource(R.string.sheet_delete_body), style = MusyxTheme.type.meta, color = c.muted)
val focus = remember { FocusRequester() }
LaunchedEffect(Unit) { runCatching { focus.requestFocus() } }
Row(horizontalArrangement = Arrangement.spacedBy(10.dp, Alignment.End), modifier = Modifier.fillMaxWidth()) {
GhostButton(stringResource(R.string.action_cancel), onClick = state::closeSheet, modifier = Modifier.focusRequester(focus))
GhostButton(stringResource(R.string.action_delete), onClick = { state.deletePlaylist(sheet.id) }, danger = true)
}
}
}
}
}
}
@Composable
private fun Title(title: String, subtitle: String?) {
Column(verticalArrangement = Arrangement.spacedBy(2.dp)) {
Text(title, style = MusyxTheme.type.section, color = MusyxTheme.colors.fg, maxLines = 2, overflow = TextOverflow.Ellipsis)
if (subtitle != null) Text(subtitle, style = MusyxTheme.type.meta, color = MusyxTheme.colors.muted, maxLines = 1)
}
}
/** A list of actions that takes focus on its first item when it opens. */
@Composable
private fun Actions(content: LazyListScope.(FocusRequester) -> Unit) {
val first = remember { FocusRequester() }
LaunchedEffect(Unit) {
delay(50)
runCatching { first.requestFocus() }
}
LazyColumn(Modifier.heightIn(max = 420.dp), contentPadding = PaddingValues(vertical = 2.dp), verticalArrangement = Arrangement.spacedBy(2.dp)) {
content(first)
}
}
@Composable
private fun Item(@DrawableRes icon: Int, label: String, modifier: Modifier = Modifier, onClick: () -> Unit) {
Focusable(onClick = onClick, modifier = modifier.fillMaxWidth()) {
Row(
Modifier.padding(horizontal = 12.dp, vertical = 10.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(14.dp),
) {
MusyxIcon(icon, tint = subtle())
Text(label, style = MusyxTheme.type.bodyMedium, maxLines = 1, overflow = TextOverflow.Ellipsis)
}
}
}
@Composable
private fun TrackMenu(state: AppState, sheet: Sheet.TrackMenu) {
val track = sheet.track
val playing = state.playback.state.track?.id == track.id
val liked = state.liked.contains(track.id)
val disliked = track.id in state.likes.dislikedTracks
// Where the menu was opened: no "go to" for the page already showing.
val here = state.nav.current
Title(track.fullTitle, track.artistsOrUnknown().ifEmpty { null })
Actions { first ->
item {
if (playing) Item(R.drawable.ic_skip_forward, stringResource(R.string.menu_next_track), Modifier.focusRequester(first), state::skipFromMenu)
else Item(R.drawable.ic_skip_forward, stringResource(R.string.menu_play_next), Modifier.focusRequester(first)) { state.playNext(track) }
}
item { Item(R.drawable.ic_list_music, stringResource(R.string.menu_add_to_queue)) { state.addToQueue(track) } }
item {
Item(
if (liked) R.drawable.ic_heart_fill else R.drawable.ic_heart,
stringResource(if (liked) R.string.menu_unlike else R.string.menu_like),
) {
state.closeSheet()
state.likeTrack(track, !liked)
}
}
item { Item(R.drawable.ic_plus, stringResource(R.string.menu_add_to_playlist)) { state.openSheet(sheet.copy(choosing = true)) } }
// Similar tracks and recommendations are about music; an episode or a chapter has neither.
if (!track.spoken) {
item { Item(R.drawable.ic_audio_lines, stringResource(R.string.menu_play_similar)) { state.playSimilar(track) } }
}
track.album?.takeIf { here != Route.Album(it.id) }?.let { album ->
item { Item(R.drawable.ic_disc_3, stringResource(R.string.menu_go_to_album)) { state.navigate(Route.Album(album.id)) } }
}
track.artists.filter { a -> a.id?.let { here != Route.Artist(it) } == true }.take(3).forEach { artist ->
item {
Item(R.drawable.ic_mic_vocal, stringResource(R.string.menu_go_to_artist_named, artist.name)) {
state.navigate(Route.Artist(artist.id!!))
}
}
}
if (!track.spoken) {
item {
Item(R.drawable.ic_ban, stringResource(if (disliked) R.string.menu_undislike else R.string.menu_dislike)) {
state.dislikeTrack(track, !disliked)
}
}
}
sheet.playlist?.let { slot ->
item { Divider(Modifier.padding(vertical = 6.dp)) }
slot.up?.let { up ->
item {
Item(R.drawable.ic_chevron_left, stringResource(R.string.menu_move_up)) {
state.movePlaylistTrack(slot.id, track, slot.index, up)
}
}
}
// Delete-then-insert: the row below shifts up one, so inserting at its old index lands after it.
slot.down?.let { down ->
item {
Item(R.drawable.ic_chevron_right, stringResource(R.string.menu_move_down)) {
state.movePlaylistTrack(slot.id, track, slot.index, down)
}
}
}
item { Item(R.drawable.ic_trash_2, stringResource(R.string.menu_remove_from_playlist)) { state.removeFromPlaylist(slot.id, slot.index) } }
}
}
}
@Composable
private fun ChoosePlaylist(state: AppState, sheet: Sheet.TrackMenu) {
val own = state.playlists.get()?.own.orEmpty()
Title(stringResource(R.string.sheet_add_to_playlist), sheet.track.fullTitle)
Actions { first ->
item {
Item(R.drawable.ic_plus, stringResource(R.string.menu_new_playlist), Modifier.focusRequester(first)) {
state.openSheet(Sheet.NewPlaylist(sheet.track))
}
}
own.forEach { p ->
item(key = p.id.key) { Item(R.drawable.ic_list_music, p.title) { state.addToPlaylist(p.id, sheet.track) } }
}
}
}
@Composable
private fun NameDialog(title: String, initial: String, hint: String?, confirm: String, onCancel: () -> Unit, onConfirm: (String) -> Unit) {
var name by remember { mutableStateOf(initial) }
val focus = remember { FocusRequester() }
LaunchedEffect(Unit) {
delay(50)
runCatching { focus.requestFocus() }
}
Title(title, null)
TextInput(
value = name,
onChange = { name = it },
placeholder = stringResource(R.string.sheet_playlist_name),
onSubmit = { if (name.isNotBlank()) onConfirm(name) },
modifier = Modifier.fillMaxWidth().focusRequester(focus),
)
if (hint != null) Text(hint, style = MusyxTheme.type.meta, color = MusyxTheme.colors.muted)
Row(horizontalArrangement = Arrangement.spacedBy(10.dp, Alignment.End), modifier = Modifier.fillMaxWidth()) {
GhostButton(stringResource(R.string.action_cancel), onClick = onCancel)
PrimaryButton(confirm, onClick = { onConfirm(name) }, enabled = name.isNotBlank())
}
}
/** The status line that floats above the bottom of the screen after an action. */
@Composable
fun ToastHost(state: AppState) {
val toast = state.toast ?: return
LaunchedEffect(toast.serial) {
delay(TOAST_MS)
state.dismissToast(toast.serial)
}
val c = MusyxTheme.colors
Box(Modifier.fillMaxSize().padding(bottom = 96.dp), contentAlignment = Alignment.BottomCenter) {
Text(
text(toast.text),
style = MusyxTheme.type.bodyMedium,
color = c.bg,
modifier = Modifier
.background(c.fg, RoundedCornerShape(MusyxTheme.radius.pill))
.padding(horizontal = 24.dp, vertical = 12.dp),
)
}
}
@@ -0,0 +1,366 @@
// Design tokens and the Compose theme. Mirrors DESIGN.md and the desktop app's
// `src/ui/theme.rs`; change all three together.
package it.panov.musyx.tv.ui.theme
import android.content.res.Configuration
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.Immutable
import androidx.compose.runtime.ReadOnlyComposable
import androidx.compose.runtime.remember
import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.text.TextStyle
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.dp
import androidx.compose.ui.unit.em
import androidx.compose.ui.unit.sp
import androidx.tv.material3.ColorScheme
import androidx.tv.material3.MaterialTheme
import androidx.tv.material3.Shapes
import androidx.tv.material3.Typography
import androidx.tv.material3.darkColorScheme
import androidx.tv.material3.lightColorScheme
import it.panov.musyx.tv.R
import kotlin.math.abs
// ---- Colour ----
/** Colour tokens for one theme mode. */
@Immutable
data class MusyxColors(
val bg: Color,
val panel: Color,
val raised: Color,
val line: Color,
val fg: Color,
val muted: Color,
val accent: Color,
val accentInk: Color,
val like: Color,
val ok: Color,
val isDark: Boolean,
)
val DarkColors = MusyxColors(
bg = Color(0xFF1C1A22),
panel = Color(0xFF23202B),
raised = Color(0xFF2D2937),
line = Color(0xFF3A3546),
fg = Color(0xFFEEEAF3),
muted = Color(0xFFA39CB0),
accent = Color(0xFFF0B23E),
accentInk = Color(0xFF2A1D04),
like = Color(0xFFF27286),
ok = Color(0xFF7FCB9B),
isDark = true,
)
/**
* Light is porcelain: cool neutral greys with near-black ink and a petrol accent, a muted
* blue-green that belongs to the cool ground the way amber belongs to the dark one.
*/
val LightColors = MusyxColors(
bg = Color(0xFFF1F2F5),
panel = Color(0xFFFFFFFF),
raised = Color(0xFFE5E7EC),
line = Color(0xFFD5D8DF),
fg = Color(0xFF1B1C22),
muted = Color(0xFF5C606C),
accent = Color(0xFF1F5F7A),
accentInk = Color(0xFFF2F8FA),
like = Color(0xFFB5304B),
ok = Color(0xFF24704A),
isDark = false,
)
/**
* Musyx is dark-first: it goes light only when the system explicitly asks for it, so an
* undefined night mode (common on TVs) stays dark. `values-notnight/colors.xml` matches this.
*/
@Composable
@ReadOnlyComposable
fun isMusyxDark(): Boolean =
LocalConfiguration.current.uiMode and Configuration.UI_MODE_NIGHT_MASK != Configuration.UI_MODE_NIGHT_NO
private fun MusyxColors.toColorScheme(): ColorScheme =
(if (isDark) darkColorScheme() else lightColorScheme()).copy(
primary = accent,
onPrimary = accentInk,
primaryContainer = raised,
onPrimaryContainer = fg,
inversePrimary = accent,
secondary = muted,
onSecondary = bg,
secondaryContainer = raised,
onSecondaryContainer = fg,
tertiary = ok,
onTertiary = bg,
tertiaryContainer = raised,
onTertiaryContainer = fg,
background = bg,
onBackground = fg,
surface = panel,
onSurface = fg,
surfaceVariant = raised,
onSurfaceVariant = muted,
surfaceTint = raised,
inverseSurface = fg,
inverseOnSurface = bg,
error = like,
onError = accentInk,
errorContainer = raised,
onErrorContainer = like,
border = line,
borderVariant = line,
)
// ---- Type ----
val Onest = FontFamily(
Font(R.font.onest_regular, FontWeight.Normal),
Font(R.font.onest_medium, FontWeight.Medium),
Font(R.font.onest_semibold, FontWeight.SemiBold),
)
val Unbounded = FontFamily(Font(R.font.unbounded_semibold, FontWeight.SemiBold))
/**
* Desktop sizes are in px at arm's length. The TV is read from across the room, so every
* size is multiplied by this once; tune it here rather than per style. The font size setting
* swaps in its own scale for text; icons and controls stay at this one.
*/
const val TV_TYPE_SCALE = 1.5f
/** The type roles of DESIGN.md, at TV size. Line heights and tracking follow the mockup. */
@Immutable
data class MusyxType(
/** My Wave hero, big (46). */
val displayXl: TextStyle,
/** Detail page titles (40). */
val displayL: TextStyle,
/** My Wave hero, sign-in headline (34). */
val displayM: TextStyle,
/** Screen titles (30). */
val displayS: TextStyle,
/** `musyx` + the amber dot (20). */
val wordmark: TextStyle,
/** Section headings such as "Made for you" (19). */
val section: TextStyle,
/** Rows and running text (14). */
val body: TextStyle,
/** Titles in rows and cards, nav labels (14, Medium). */
val bodyMedium: TextStyle,
/** Subtitles and secondary lines (13). */
val meta: TextStyle,
/** Table heads, small labels (12.5). */
val small: TextStyle,
/** The multiplier applied to the desktop sizes, for things drawn to match the text. */
val scale: Float,
)
private fun display(scale: Float, size: Float, lineHeight: Float, tracking: Float) = TextStyle(
fontFamily = Unbounded,
fontWeight = FontWeight.SemiBold,
fontSize = (size * scale).sp,
lineHeight = lineHeight.em,
letterSpacing = tracking.em,
)
private fun onest(scale: Float, size: Float, weight: FontWeight = FontWeight.Normal) = TextStyle(
fontFamily = Onest,
fontWeight = weight,
fontSize = (size * scale).sp,
lineHeight = 1.45.em,
)
/** The type roles with every desktop size multiplied by [scale]. */
fun musyxType(scale: Float = TV_TYPE_SCALE) = MusyxType(
displayXl = display(scale, 46f, 1.05f, -0.02f),
displayL = display(scale, 40f, 1.08f, -0.02f),
displayM = display(scale, 34f, 1.05f, -0.02f),
displayS = display(scale, 30f, 1.15f, -0.015f),
wordmark = display(scale, 20f, 1f, -0.01f),
section = onest(scale, 19f, FontWeight.SemiBold).copy(lineHeight = 1.2.em, letterSpacing = (-0.005).em),
body = onest(scale, 14f),
bodyMedium = onest(scale, 14f, FontWeight.Medium),
meta = onest(scale, 13f),
small = onest(scale, 12.5f),
scale = scale,
)
val MusyxTypeScale = musyxType()
/** Durations and counts use tabular figures. */
fun TextStyle.tabular(): TextStyle = copy(fontFeatureSettings = "tnum")
private fun MusyxType.toTypography() = Typography(
displayLarge = displayXl,
displayMedium = displayL,
displaySmall = displayM,
headlineLarge = displayS,
headlineMedium = wordmark,
headlineSmall = section,
titleLarge = section,
titleMedium = bodyMedium,
titleSmall = bodyMedium,
bodyLarge = body,
bodyMedium = body,
bodySmall = meta,
labelLarge = bodyMedium,
labelMedium = meta,
labelSmall = small,
)
// ---- Space and shape ----
/** Spacing steps 2 · 4 · 6 · 8 · 10 · 12 · 14 · 18 · 22 · 28 · 34, named as in theme.rs. */
@Immutable
data class MusyxSpacing(
val xxs: Dp = 2.dp,
val xs: Dp = 4.dp,
val s6: Dp = 6.dp,
val s: Dp = 8.dp,
val s10: Dp = 10.dp,
val m: Dp = 12.dp,
val s14: Dp = 14.dp,
val l: Dp = 18.dp,
val xl: Dp = 22.dp,
/** Content gutter. */
val gutter: Dp = 28.dp,
/** Gap between sections. */
val section: Dp = 34.dp,
/** TV overscan: keep content inside 5% of the 960×540 dp screen (Android TV guidance). */
val safeX: Dp = 48.dp,
val safeY: Dp = 27.dp,
)
@Immutable
data class MusyxRadius(
val cover: Dp = 10.dp,
val control: Dp = 8.dp,
val smallCover: Dp = 6.dp,
val pill: Dp = 999.dp,
val hero: Dp = 16.dp,
/** Window cards (empty state, device-code box). */
val card: Dp = 14.dp,
)
/** Shell dimensions from the desktop app; the sidebar is the TV navigation drawer. */
@Immutable
data class MusyxShell(
val sidebar: Dp = 232.dp,
val player: Dp = 80.dp,
val drawer: Dp = 320.dp,
val trackRow: Dp = 52.dp,
val icon: Dp = 18.dp,
)
private fun MusyxRadius.toShapes() = Shapes(
extraSmall = RoundedCornerShape(smallCover),
small = RoundedCornerShape(control),
medium = RoundedCornerShape(cover),
large = RoundedCornerShape(card),
extraLarge = RoundedCornerShape(hero),
)
// ---- Cover placeholder ----
/** Placeholder art for an item without a cover yet: two hues on a 135° diagonal. */
fun coverBrush(h1: Float, h2: Float): Brush = Brush.linearGradient(
0f to hsl(h1, 0.70f, 0.60f),
0.55f to hsl((h1 + h2) / 2f, 0.45f, 0.30f),
1f to hsl(h2, 0.40f, 0.16f),
start = Offset.Zero,
end = Offset.Infinite,
)
@Composable
fun CoverPlaceholder(hues: Pair<Float, Float>, modifier: Modifier = Modifier) {
Box(modifier.background(coverBrush(hues.first, hues.second)))
}
internal fun hsl(h: Float, s: Float, l: Float): Color {
val c = (1f - abs(2f * l - 1f)) * s
val hp = h.mod(360f) / 60f
val x = c * (1f - abs(hp % 2f - 1f))
val (r, g, b) = when (hp.toInt()) {
0 -> Triple(c, x, 0f)
1 -> Triple(x, c, 0f)
2 -> Triple(0f, c, x)
3 -> Triple(0f, x, c)
4 -> Triple(x, 0f, c)
else -> Triple(c, 0f, x)
}
val m = l - c / 2f
return Color(r + m, g + m, b + m)
}
/** Linear blend of two colours; `amount` is the share of `b`. */
fun mix(a: Color, b: Color, amount: Float): Color = Color(
red = a.red + (b.red - a.red) * amount,
green = a.green + (b.green - a.green) * amount,
blue = a.blue + (b.blue - a.blue) * amount,
alpha = a.alpha + (b.alpha - a.alpha) * amount,
)
// ---- Theme ----
val LocalMusyxColors = staticCompositionLocalOf { DarkColors }
val LocalMusyxType = staticCompositionLocalOf { MusyxTypeScale }
val LocalMusyxSpacing = staticCompositionLocalOf { MusyxSpacing() }
val LocalMusyxRadius = staticCompositionLocalOf { MusyxRadius() }
val LocalMusyxShell = staticCompositionLocalOf { MusyxShell() }
/**
* The Musyx theme over tv-material's [MaterialTheme]. Material components get a colour scheme,
* type scale and shapes built from the tokens; Musyx code reads the tokens through [MusyxTheme].
*/
@Composable
fun MusyxTheme(
dark: Boolean = isMusyxDark(),
typeScale: Float = TV_TYPE_SCALE,
content: @Composable () -> Unit,
) {
val colors = if (dark) DarkColors else LightColors
val type = remember(typeScale) { musyxType(typeScale) }
val radius = MusyxRadius()
CompositionLocalProvider(
LocalMusyxColors provides colors,
LocalMusyxType provides type,
LocalMusyxSpacing provides MusyxSpacing(),
LocalMusyxRadius provides radius,
LocalMusyxShell provides MusyxShell(),
) {
MaterialTheme(
colorScheme = colors.toColorScheme(),
shapes = radius.toShapes(),
typography = type.toTypography(),
content = content,
)
}
}
/** Token access for the current composition, like `MaterialTheme.colorScheme`. */
object MusyxTheme {
val colors: MusyxColors
@Composable @ReadOnlyComposable get() = LocalMusyxColors.current
val type: MusyxType
@Composable @ReadOnlyComposable get() = LocalMusyxType.current
val space: MusyxSpacing
@Composable @ReadOnlyComposable get() = LocalMusyxSpacing.current
val radius: MusyxRadius
@Composable @ReadOnlyComposable get() = LocalMusyxRadius.current
val shell: MusyxShell
@Composable @ReadOnlyComposable get() = LocalMusyxShell.current
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Lucide audio-lines (ISC, assets/icons/LICENSE.txt). Generated by tool/svg_to_vector.py; tint it in code. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M 2 10 v 3"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 6 6 v 11"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 10 3 v 18"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 14 8 v 7"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 18 5 v 13"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 22 10 v 3"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
</vector>
+20
View File
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Lucide ban (ISC, assets/icons/LICENSE.txt). Generated by tool/svg_to_vector.py; tint it in code. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M 2 12 a 10 10 0 1 0 20 0 a 10 10 0 1 0 -20 0 Z"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="m 4.9 4.9 14.2 14.2"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
</vector>
+14
View File
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Lucide check (ISC, assets/icons/LICENSE.txt). Generated by tool/svg_to_vector.py; tint it in code. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M 20 6 9 17 l -5 -5"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
</vector>
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Lucide chevron-left (ISC, assets/icons/LICENSE.txt). Generated by tool/svg_to_vector.py; tint it in code. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="m 15 18 -6 -6 6 -6"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
</vector>
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Lucide chevron-right (ISC, assets/icons/LICENSE.txt). Generated by tool/svg_to_vector.py; tint it in code. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="m 9 18 6 -6 -6 -6"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
</vector>
+20
View File
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Lucide clock-3 (ISC, assets/icons/LICENSE.txt). Generated by tool/svg_to_vector.py; tint it in code. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M 2 12 a 10 10 0 1 0 20 0 a 10 10 0 1 0 -20 0 Z"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 12 6 L 12 12 L 16.5 12"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
</vector>
+20
View File
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Lucide copy (ISC, assets/icons/LICENSE.txt). Generated by tool/svg_to_vector.py; tint it in code. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M 10 8 h 10 a 2 2 0 0 1 2 2 v 10 a 2 2 0 0 1 -2 2 h -10 a 2 2 0 0 1 -2 -2 v -10 a 2 2 0 0 1 2 -2 Z"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 4 16 c -1.1 0 -2 -0.9 -2 -2 V 4 c 0 -1.1 0.9 -2 2 -2 h 10 c 1.1 0 2 0.9 2 2"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
</vector>
+32
View File
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Lucide disc-3 (ISC, assets/icons/LICENSE.txt). Generated by tool/svg_to_vector.py; tint it in code. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M 2 12 a 10 10 0 1 0 20 0 a 10 10 0 1 0 -20 0 Z"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 6 12 c 0 -1.7 0.7 -3.2 1.8 -4.2"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 10 12 a 2 2 0 1 0 4 0 a 2 2 0 1 0 -4 0 Z"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 18 12 c 0 1.7 -0.7 3.2 -1.8 4.2"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
</vector>
+26
View File
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Lucide ellipsis (ISC, assets/icons/LICENSE.txt). Generated by tool/svg_to_vector.py; tint it in code. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M 11 12 a 1 1 0 1 0 2 0 a 1 1 0 1 0 -2 0 Z"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 18 12 a 1 1 0 1 0 2 0 a 1 1 0 1 0 -2 0 Z"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 4 12 a 1 1 0 1 0 2 0 a 1 1 0 1 0 -2 0 Z"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
</vector>
+26
View File
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Lucide globe (ISC, assets/icons/LICENSE.txt). Generated by tool/svg_to_vector.py; tint it in code. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M 2 12 a 10 10 0 1 0 20 0 a 10 10 0 1 0 -20 0 Z"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 12 2 a 14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0 -20"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 2 12 h 20"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
</vector>
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Lucide grip-vertical (ISC, assets/icons/LICENSE.txt). Generated by tool/svg_to_vector.py; tint it in code. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M 8 12 a 1 1 0 1 0 2 0 a 1 1 0 1 0 -2 0 Z"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 8 5 a 1 1 0 1 0 2 0 a 1 1 0 1 0 -2 0 Z"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 8 19 a 1 1 0 1 0 2 0 a 1 1 0 1 0 -2 0 Z"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 14 12 a 1 1 0 1 0 2 0 a 1 1 0 1 0 -2 0 Z"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 14 5 a 1 1 0 1 0 2 0 a 1 1 0 1 0 -2 0 Z"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 14 19 a 1 1 0 1 0 2 0 a 1 1 0 1 0 -2 0 Z"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
</vector>
+14
View File
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Lucide heart (ISC, assets/icons/LICENSE.txt). Generated by tool/svg_to_vector.py; tint it in code. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M 19 14 c 1.49 -1.46 3 -3.21 3 -5.5 A 5.5 5.5 0 0 0 16.5 3 c -1.76 0 -3 0.5 -4.5 2 -1.5 -1.5 -2.74 -2 -4.5 -2 A 5.5 5.5 0 0 0 2 8.5 c 0 2.3 1.5 4.05 3 5.5 l 7 7 Z"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
</vector>
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Lucide heart-fill (ISC, assets/icons/LICENSE.txt). Generated by tool/svg_to_vector.py; tint it in code. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M 19 14 c 1.49 -1.46 3 -3.21 3 -5.5 A 5.5 5.5 0 0 0 16.5 3 c -1.76 0 -3 0.5 -4.5 2 -1.5 -1.5 -2.74 -2 -4.5 -2 A 5.5 5.5 0 0 0 2 8.5 c 0 2.3 1.5 4.05 3 5.5 l 7 7 Z"
android:fillColor="@android:color/white"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
</vector>
+20
View File
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Lucide house (ISC, assets/icons/LICENSE.txt). Generated by tool/svg_to_vector.py; tint it in code. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M 15 21 v -8 a 1 1 0 0 0 -1 -1 h -4 a 1 1 0 0 0 -1 1 v 8"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 3 10 a 2 2 0 0 1 0.709 -1.528 l 7 -5.999 a 2 2 0 0 1 2.582 0 l 7 5.999 A 2 2 0 0 1 21 10 v 9 a 2 2 0 0 1 -2 2 H 5 a 2 2 0 0 1 -2 -2 z"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
</vector>
+32
View File
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Lucide library (ISC, assets/icons/LICENSE.txt). Generated by tool/svg_to_vector.py; tint it in code. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="m 16 6 4 14"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 12 6 v 14"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 8 8 v 12"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 4 4 v 16"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
</vector>
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Lucide list-music (ISC, assets/icons/LICENSE.txt). Generated by tool/svg_to_vector.py; tint it in code. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M 21 15 V 6"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 18.5 18 a 2.5 2.5 0 1 0 0 -5 2.5 2.5 0 0 0 0 5 Z"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 12 12 H 3"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 16 6 H 3"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 12 18 H 3"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
</vector>
+20
View File
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Lucide lock (ISC, assets/icons/LICENSE.txt). Generated by tool/svg_to_vector.py; tint it in code. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M 5 11 h 14 a 2 2 0 0 1 2 2 v 7 a 2 2 0 0 1 -2 2 h -14 a 2 2 0 0 1 -2 -2 v -7 a 2 2 0 0 1 2 -2 Z"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 7 11 V 7 a 5 5 0 0 1 10 0 v 4"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
</vector>
+26
View File
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Lucide log-out (ISC, assets/icons/LICENSE.txt). Generated by tool/svg_to_vector.py; tint it in code. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M 9 21 H 5 a 2 2 0 0 1 -2 -2 V 5 a 2 2 0 0 1 2 -2 h 4"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 16 17 L 21 12 L 16 7"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 21 12 L 9 12"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
</vector>
+26
View File
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Lucide mic-vocal (ISC, assets/icons/LICENSE.txt). Generated by tool/svg_to_vector.py; tint it in code. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="m 11 7.601 -5.994 8.19 a 1 1 0 0 0 0.1 1.298 l 0.817 0.818 a 1 1 0 0 0 1.314 0.087 L 15.09 12"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 16.5 21.174 C 15.5 20.5 14.372 20 13 20 c -2.058 0 -3.928 2.356 -6 2 -2.072 -0.356 -2.775 -3.369 -1.5 -4.5"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 11 7 a 5 5 0 1 0 10 0 a 5 5 0 1 0 -10 0 Z"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
</vector>
+20
View File
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Lucide pause (ISC, assets/icons/LICENSE.txt). Generated by tool/svg_to_vector.py; tint it in code. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M 15 4 h 2 a 1 1 0 0 1 1 1 v 14 a 1 1 0 0 1 -1 1 h -2 a 1 1 0 0 1 -1 -1 v -14 a 1 1 0 0 1 1 -1 Z"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 7 4 h 2 a 1 1 0 0 1 1 1 v 14 a 1 1 0 0 1 -1 1 h -2 a 1 1 0 0 1 -1 -1 v -14 a 1 1 0 0 1 1 -1 Z"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
</vector>
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Lucide pause-fill (ISC, assets/icons/LICENSE.txt). Generated by tool/svg_to_vector.py; tint it in code. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M 15 4 h 2 a 1 1 0 0 1 1 1 v 14 a 1 1 0 0 1 -1 1 h -2 a 1 1 0 0 1 -1 -1 v -14 a 1 1 0 0 1 1 -1 Z"
android:fillColor="@android:color/white"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 7 4 h 2 a 1 1 0 0 1 1 1 v 14 a 1 1 0 0 1 -1 1 h -2 a 1 1 0 0 1 -1 -1 v -14 a 1 1 0 0 1 1 -1 Z"
android:fillColor="@android:color/white"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
</vector>
+20
View File
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Lucide pencil (ISC, assets/icons/LICENSE.txt). Generated by tool/svg_to_vector.py; tint it in code. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M 21.174 6.812 a 1 1 0 0 0 -3.986 -3.987 L 3.842 16.174 a 2 2 0 0 0 -0.5 0.83 l -1.321 4.352 a 0.5 0.5 0 0 0 0.623 0.622 l 4.353 -1.32 a 2 2 0 0 0 0.83 -0.497 z"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="m 15 5 4 4"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
</vector>
+14
View File
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Lucide play (ISC, assets/icons/LICENSE.txt). Generated by tool/svg_to_vector.py; tint it in code. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M 6 3 L 20 12 L 6 21 L 6 3 Z"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
</vector>
+15
View File
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Lucide play-fill (ISC, assets/icons/LICENSE.txt). Generated by tool/svg_to_vector.py; tint it in code. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M 6 3 L 20 12 L 6 21 L 6 3 Z"
android:fillColor="@android:color/white"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
</vector>
+20
View File
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Lucide plus (ISC, assets/icons/LICENSE.txt). Generated by tool/svg_to_vector.py; tint it in code. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M 5 12 h 14"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 12 5 v 14"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
</vector>
+32
View File
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Lucide podcast (ISC, assets/icons/LICENSE.txt). Generated by tool/svg_to_vector.py; tint it in code. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M 16.85 18.58 a 9 9 0 1 0 -9.7 0"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 8 14 a 5 5 0 1 1 8 0"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 11 11 a 1 1 0 1 0 2 0 a 1 1 0 1 0 -2 0 Z"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 13 17 a 1 1 0 1 0 -2 0 l 0.5 4.5 a 0.5 0.5 0 1 0 1 0 Z"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
</vector>
+32
View File
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Lucide repeat (ISC, assets/icons/LICENSE.txt). Generated by tool/svg_to_vector.py; tint it in code. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="m 17 2 4 4 -4 4"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 3 11 v -1 a 4 4 0 0 1 4 -4 h 14"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="m 7 22 -4 -4 4 -4"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 21 13 v 1 a 4 4 0 0 1 -4 4 H 3"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
</vector>
+38
View File
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Lucide repeat-1 (ISC, assets/icons/LICENSE.txt). Generated by tool/svg_to_vector.py; tint it in code. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="m 17 2 4 4 -4 4"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 3 11 v -1 a 4 4 0 0 1 4 -4 h 14"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="m 7 22 -4 -4 4 -4"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 21 13 v 1 a 4 4 0 0 1 -4 4 H 3"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 11 10 h 1 v 4"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
</vector>
+20
View File
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Lucide search (ISC, assets/icons/LICENSE.txt). Generated by tool/svg_to_vector.py; tint it in code. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M 3 11 a 8 8 0 1 0 16 0 a 8 8 0 1 0 -16 0 Z"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="m 21 21 -4.3 -4.3"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
</vector>
+20
View File
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Lucide settings (ISC, assets/icons/LICENSE.txt). Generated by tool/svg_to_vector.py; tint it in code. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M 12.22 2 h -0.44 a 2 2 0 0 0 -2 2 v 0.18 a 2 2 0 0 1 -1 1.73 l -0.43 0.25 a 2 2 0 0 1 -2 0 l -0.15 -0.08 a 2 2 0 0 0 -2.73 0.73 l -0.22 0.38 a 2 2 0 0 0 0.73 2.73 l 0.15 0.1 a 2 2 0 0 1 1 1.72 v 0.51 a 2 2 0 0 1 -1 1.74 l -0.15 0.09 a 2 2 0 0 0 -0.73 2.73 l 0.22 0.38 a 2 2 0 0 0 2.73 0.73 l 0.15 -0.08 a 2 2 0 0 1 2 0 l 0.43 0.25 a 2 2 0 0 1 1 1.73 V 20 a 2 2 0 0 0 2 2 h 0.44 a 2 2 0 0 0 2 -2 v -0.18 a 2 2 0 0 1 1 -1.73 l 0.43 -0.25 a 2 2 0 0 1 2 0 l 0.15 0.08 a 2 2 0 0 0 2.73 -0.73 l 0.22 -0.39 a 2 2 0 0 0 -0.73 -2.73 l -0.15 -0.08 a 2 2 0 0 1 -1 -1.74 v -0.5 a 2 2 0 0 1 1 -1.74 l 0.15 -0.09 a 2 2 0 0 0 0.73 -2.73 l -0.22 -0.38 a 2 2 0 0 0 -2.73 -0.73 l -0.15 0.08 a 2 2 0 0 1 -2 0 l -0.43 -0.25 a 2 2 0 0 1 -1 -1.73 V 4 a 2 2 0 0 0 -2 -2 z"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 9 12 a 3 3 0 1 0 6 0 a 3 3 0 1 0 -6 0 Z"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
</vector>
+38
View File
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Lucide shuffle (ISC, assets/icons/LICENSE.txt). Generated by tool/svg_to_vector.py; tint it in code. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M 2 18 h 1.4 c 1.3 0 2.5 -0.6 3.3 -1.7 l 6.1 -8.6 c 0.7 -1.1 2 -1.7 3.3 -1.7 H 22"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="m 18 2 4 4 -4 4"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 2 6 h 1.9 c 1.5 0 2.9 0.9 3.6 2.2"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 22 18 h -5.9 c -1.3 0 -2.6 -0.7 -3.3 -1.8 l -0.5 -0.8"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="m 18 14 4 4 -4 4"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
</vector>
+20
View File
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Lucide skip-back (ISC, assets/icons/LICENSE.txt). Generated by tool/svg_to_vector.py; tint it in code. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M 19 20 L 9 12 L 19 4 L 19 20 Z"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 5 19 L 5 5"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
</vector>
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Lucide skip-forward (ISC, assets/icons/LICENSE.txt). Generated by tool/svg_to_vector.py; tint it in code. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M 5 4 L 15 12 L 5 20 L 5 4 Z"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 19 5 L 19 19"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
</vector>
@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Lucide sliders-horizontal (ISC, assets/icons/LICENSE.txt). Generated by tool/svg_to_vector.py; tint it in code. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M 21 4 L 14 4"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 10 4 L 3 4"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 21 12 L 12 12"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 8 12 L 3 12"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 21 20 L 16 20"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 12 20 L 3 20"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 14 2 L 14 6"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 8 10 L 8 14"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 16 18 L 16 22"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
</vector>
+38
View File
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Lucide trash-2 (ISC, assets/icons/LICENSE.txt). Generated by tool/svg_to_vector.py; tint it in code. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M 3 6 h 18"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 19 6 v 14 c 0 1 -1 2 -2 2 H 7 c -1 0 -2 -1 -2 -2 V 6"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 8 6 V 4 c 0 -1 1 -2 2 -2 h 4 c 1 0 2 1 2 2 v 2"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 10 11 L 10 17"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 14 11 L 14 17"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
</vector>
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Lucide trending-up (ISC, assets/icons/LICENSE.txt). Generated by tool/svg_to_vector.py; tint it in code. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M 22 7 L 13.5 15.5 L 8.5 10.5 L 2 17"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 16 7 L 22 7 L 22 13"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
</vector>
+26
View File
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Lucide volume-2 (ISC, assets/icons/LICENSE.txt). Generated by tool/svg_to_vector.py; tint it in code. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M 11 4.702 a 0.705 0.705 0 0 0 -1.203 -0.498 L 6.413 7.587 A 1.4 1.4 0 0 1 5.416 8 H 3 a 1 1 0 0 0 -1 1 v 6 a 1 1 0 0 0 1 1 h 2.416 a 1.4 1.4 0 0 1 0.997 0.413 l 3.383 3.384 A 0.705 0.705 0 0 0 11 19.298 z"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 16 9 a 5 5 0 0 1 0 6"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 19.364 18.364 a 9 9 0 0 0 0 -12.728"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
</vector>
+26
View File
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Lucide volume-x (ISC, assets/icons/LICENSE.txt). Generated by tool/svg_to_vector.py; tint it in code. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M 11 4.702 a 0.705 0.705 0 0 0 -1.203 -0.498 L 6.413 7.587 A 1.4 1.4 0 0 1 5.416 8 H 3 a 1 1 0 0 0 -1 1 v 6 a 1 1 0 0 0 1 1 h 2.416 a 1.4 1.4 0 0 1 0.997 0.413 l 3.383 3.384 A 0.705 0.705 0 0 0 11 19.298 z"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 22 9 L 16 15"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M 16 9 L 22 15"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
</vector>
+20
View File
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Lucide x (ISC, assets/icons/LICENSE.txt). Generated by tool/svg_to_vector.py; tint it in code. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M 18 6 6 18"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="m 6 6 12 12"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
</vector>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="bg">#F1F2F5</color>
</resources>
+284
View File
@@ -0,0 +1,284 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Terms follow the Yandex Music apps ("Моя волна", "Мне нравится", "Чарт"), as on the desktop. -->
<resources>
<string name="lang_code">ru</string>
<string name="nav_home">Главная</string>
<string name="nav_wave">Моя волна</string>
<string name="nav_search">Поиск</string>
<string name="nav_collection">Коллекция</string>
<string name="nav_podcasts">Подкасты</string>
<string name="nav_settings">Настройки</string>
<string name="unknown_artist">Неизвестный исполнитель</string>
<string name="session_checking">Проверяем вход…</string>
<string name="session_signing_in">Входим…</string>
<string name="unreachable_title">Яндекс Музыка недоступна</string>
<string name="unreachable_body">Вы по-прежнему в аккаунте. Проверьте подключение к интернету и попробуйте ещё раз.</string>
<string name="signin_title">Войдите с аккаунтом Яндекса</string>
<string name="signin_blurb">Musyx играет вашу коллекцию Яндекс Музыки, Мою волну и плейлисты. Вход подтверждается на странице самого Яндекса, поэтому пароль никогда не проходит через это приложение.</string>
<string name="signin_footer">Musyx — неофициальный клиент, не связанный с Яндексом. Токен входа хранится на этом устройстве в зашифрованном виде.</string>
<string name="signin_get_code">Получить код для входа</string>
<string name="signin_getting_code">Получаем код…</string>
<string name="signin_step_open">Откройте %1$s</string>
<string name="signin_step_open_hint">На телефоне или компьютере. Можно и отсканировать QR-код.</string>
<string name="signin_step_code">Введите этот код</string>
<string name="signin_step_code_hint">Строчными буквами, без пробелов. Если телефон сделает букву заглавной или исправит слово, верните как было.</string>
<string name="signin_step_back">Вернитесь сюда</string>
<string name="signin_step_back_hint">Musyx войдёт, как только вы разрешите доступ.</string>
<string name="signin_waiting">Ждём подтверждения · код действует ещё %1$s</string>
<string name="signin_token_show">Войти с готовым токеном</string>
<string name="signin_token_hide">Скрыть вход по токену</string>
<string name="signin_token_placeholder">Вставьте OAuth-токен</string>
<string name="signin_qr_scan">Отсканируйте, чтобы открыть страницу входа</string>
<string name="signin_qr_later">QR-код появится вместе с кодом для входа</string>
<string name="action_play">Слушать</string>
<string name="action_shuffle">Вперемешку</string>
<string name="action_pause">Пауза</string>
<string name="action_resume">Продолжить</string>
<string name="action_try_again">Повторить</string>
<string name="action_cancel">Отмена</string>
<string name="action_sign_in">Войти</string>
<string name="action_sign_out">Выйти</string>
<string name="action_show_all_n">Показать все %1$d</string>
<string name="action_show_more">Показать ещё</string>
<string name="action_play_radio">Включить радио</string>
<string name="action_rename">Переименовать</string>
<string name="action_make_private">Сделать закрытым</string>
<string name="action_make_public">Сделать открытым</string>
<string name="action_delete">Удалить</string>
<string name="action_create">Создать</string>
<string name="action_new_playlist">Новый плейлист…</string>
<string name="action_clear_covers">Очистить кеш обложек</string>
<string name="section_recent">Вы недавно слушали</string>
<string name="section_made_for_you">Собрано для вас</string>
<string name="section_chart">Чарт</string>
<string name="section_new_releases">Новые релизы</string>
<string name="section_new_playlists">Новые плейлисты</string>
<string name="section_genres">Жанры</string>
<string name="section_stations">Станции</string>
<string name="section_your_playlists">Ваши плейлисты</string>
<string name="section_liked_playlists">Понравившиеся плейлисты</string>
<string name="section_popular">Популярные треки</string>
<string name="section_appears_on">Участвует в</string>
<string name="section_similar_artists">Похожие исполнители</string>
<string name="section_yours">Ваши</string>
<string name="section_featured">Рекомендуем</string>
<string name="chart_blurb">Самые популярные треки Яндекс Музыки сегодня</string>
<string name="chart_empty">Чарт сейчас пуст.</string>
<string name="genre_gone">Этот жанр больше недоступен.</string>
<string name="genre_empty">В этом жанре пока нет плейлистов.</string>
<string name="podcasts_title">Подкасты и книги</string>
<string name="loading">Загрузка…</string>
<string name="loading_what">Загружаем %1$s…</string>
<string name="load_failed_network">Не удалось загрузить %1$s. Проверьте подключение и попробуйте ещё раз.</string>
<string name="load_failed">Не удалось загрузить %1$s. Попробуйте чуть позже.</string>
<string name="loading_home">Подбираем музыку для вас…</string>
<string name="loading_chart">Загружаем чарт…</string>
<string name="loading_genres">Загружаем жанры…</string>
<string name="loading_podcasts">Загружаем подкасты…</string>
<string name="loading_playlists">Загружаем плейлисты…</string>
<string name="loading_liked">Загружаем ваши любимые треки…</string>
<string name="loading_album">Загружаем альбом…</string>
<string name="loading_artist">Загружаем исполнителя…</string>
<string name="loading_playlist">Загружаем плейлист…</string>
<string name="loading_wave_settings">Загружаем настройки…</string>
<string name="loading_stations">Загружаем станции…</string>
<string name="what_home">главную страницу</string>
<string name="what_chart">чарт</string>
<string name="what_genres">жанры</string>
<string name="what_podcasts">подкасты</string>
<string name="what_stations">станции</string>
<string name="what_wave_settings">настройки волны</string>
<string name="what_albums">ваши альбомы</string>
<string name="what_artists">ваших исполнителей</string>
<string name="what_playlists">ваши плейлисты</string>
<string name="what_clips">ваши клипы</string>
<string name="what_liked">ваши любимые треки</string>
<string name="what_album">альбом</string>
<string name="what_artist">исполнителя</string>
<string name="what_playlist">плейлист</string>
<string name="what_the_playlists">плейлисты</string>
<string name="what_results">результаты</string>
<string name="tab_liked_tracks">Мне нравится</string>
<string name="tab_albums">Альбомы</string>
<string name="tab_artists">Исполнители</string>
<string name="tab_playlists">Плейлисты</string>
<string name="tab_clips">Клипы</string>
<string name="empty_liked">Любимых треков пока нет. Нажмите на сердечко у любого трека, и он появится здесь.</string>
<string name="empty_albums">Понравившихся альбомов пока нет. Отметьте альбом сердечком, и он появится здесь.</string>
<string name="empty_artists">Понравившихся исполнителей пока нет. Отметьте исполнителя сердечком, и он появится здесь.</string>
<string name="empty_playlists">Плейлистов пока нет. Здесь появятся ваши плейлисты и те, что вам понравились.</string>
<string name="empty_clips">Понравившихся клипов пока нет. Отметьте клип на странице исполнителя, и он появится здесь.</string>
<string name="clips_hint">Клипы открываются в браузере. Удерживайте кнопку выбора на клипе, чтобы отметить его или снять отметку.</string>
<string name="kind_album">Альбом</string>
<string name="kind_single">Сингл</string>
<string name="kind_compilation">Сборник</string>
<string name="kind_podcast">Подкаст</string>
<string name="kind_audiobook">Аудиокнига</string>
<string name="kind_artist">Исполнитель</string>
<string name="kind_artist_genres">Исполнитель · %1$s</string>
<string name="kind_playlist_by">Плейлист · %1$s</string>
<string name="kind_track_by">Трек · %1$s</string>
<string name="visibility_public">Открытый</string>
<string name="visibility_private">Закрытый</string>
<string name="gone_album">Этого альбома больше нет в Яндекс Музыке.</string>
<string name="gone_artist">Этого исполнителя больше нет в Яндекс Музыке.</string>
<string name="gone_playlist">Этого плейлиста больше нет в Яндекс Музыке.</string>
<string name="playlist_empty">В этом плейлисте пока пусто.</string>
<string name="search_placeholder">Исполнители, треки, подкасты</string>
<string name="search_browse">Обзор</string>
<string name="search_all">Всё</string>
<string name="search_tracks">Треки</string>
<string name="search_show_all_tracks">Все треки</string>
<string name="search_albums">Альбомы</string>
<string name="search_artists">Исполнители</string>
<string name="search_playlists">Плейлисты</string>
<string name="search_podcasts">Подкасты</string>
<string name="search_results_for">Результаты по запросу «%1$s»</string>
<string name="search_nothing">По запросу «%1$s» ничего не нашлось. Проверьте написание или сократите запрос.</string>
<string name="search_corrected">Показаны результаты по запросу «%1$s»</string>
<string name="search_top_result">Лучшее совпадение</string>
<string name="searching">Ищем…</string>
<string name="wave_play">Слушать Мою волну</string>
<string name="wave_blurb">Бесконечный поток музыки, который подстраивается под то, что вы слушаете, лайкаете и пропускаете.</string>
<string name="wave_tuned">Настроено: настроение — %1$s, характер — %2$s, язык — %3$s.</string>
<string name="wave_mood">Настроение</string>
<string name="wave_character">Характер</string>
<string name="wave_language">Язык</string>
<string name="wave_any">Не важно</string>
<string name="mood_energetic">Бодрое</string>
<string name="mood_cheerful">Весёлое</string>
<string name="mood_calm">Спокойное</string>
<string name="mood_sad">Грустное</string>
<string name="character_favourite">Любимое</string>
<string name="character_unfamiliar">Незнакомое</string>
<string name="character_popular">Популярное</string>
<string name="language_russian">Русский</string>
<string name="language_foreign">Иностранный</string>
<string name="stations_none">Других станций сейчас не предлагается.</string>
<string name="settings_quality">Качество звука</string>
<string name="quality_lossless_detail">FLAC, если Яндекс даёт его для вашей подписки и региона, иначе лучшее из доступного. Трафика в 3–5 раз больше, чем у MP3, и треки дольше запускаются.</string>
<string name="quality_best_detail">Самый высокий битрейт MP3, который даёт Яндекс, до 320 кбит/с.</string>
<string name="quality_balanced_detail">До 192 кбит/с. Примерно на 40% меньше трафика.</string>
<string name="quality_data_saver_detail">До 128 кбит/с, для медленного или платного интернета.</string>
<string name="settings_appearance">Оформление</string>
<string name="match_system">Как в системе</string>
<string name="appearance_light">Светлое</string>
<string name="appearance_dark">Тёмное</string>
<string name="settings_font_size">Размер шрифта</string>
<string name="font_size_small">Мелкий</string>
<string name="font_size_medium">Средний</string>
<string name="font_size_large">Крупный</string>
<string name="settings_language">Язык</string>
<string name="settings_screen_saver">Заставка</string>
<string name="saver_photos">Фото</string>
<string name="saver_photos_lyrics">Фото и текст</string>
<string name="saver_photos_detail">Пока играет музыка и пульт не трогают, по экрану плывут фото исполнителя и название трека.</string>
<string name="saver_photos_lyrics_detail">Вместе с ними — текст песни: строка, которая звучит сейчас, если текст синхронизирован, иначе примерно то место, до которого дошла песня.</string>
<string name="settings_storage">Хранилище</string>
<string name="settings_storage_detail">Обложки хранятся на диске, чтобы страницы открывались мгновенно. Очистка освободит место, а обложки снова загрузятся по мере просмотра.</string>
<string name="settings_version">Musyx %1$s · неофициальный клиент Яндекс Музыки</string>
<string name="plus">Яндекс Плюс</string>
<string name="plus_until">Яндекс Плюс до %1$s</string>
<string name="plus_none">Нет подписки Плюс. Треки играют фрагментами по 30 секунд.</string>
<string name="nothing_playing">Ничего не играет</string>
<string name="pick_a_track">Выберите трек</string>
<string name="badge_preview">Фрагмент</string>
<string name="panel_queue">Очередь</string>
<string name="panel_lyrics">Текст</string>
<string name="queue_now">Сейчас играет</string>
<string name="queue_nothing_after">Дальше ничего нет</string>
<string name="queue_next_up">Далее · %1$d</string>
<string name="queue_empty">Очередь пока пуста. Здесь появятся треки, которые вы включите, и те, что за ними.</string>
<string name="lyrics_play_first">Включите трек, чтобы увидеть его текст.</string>
<string name="lyrics_none">Текст этого трека не найден.</string>
<string name="lyrics_failed">Не удалось загрузить текст. Проверьте подключение и попробуйте ещё раз.</string>
<string name="lyrics_loading">Загружаем текст…</string>
<string name="lyrics_writers">Авторы: %1$s</string>
<string name="lyrics_source_lrclib">Текст из LRCLIB</string>
<string name="notice_station_dry">Не удалось загрузить продолжение станции. Проверьте подключение и попробуйте ещё раз.</string>
<string name="notice_too_many">Несколько треков подряд не удалось воспроизвести. Проверьте подключение и попробуйте ещё раз.</string>
<string name="notice_skipped">Не удалось воспроизвести «%1$s», трек пропущен.</string>
<string name="menu_next_track">Следующий трек</string>
<string name="menu_play_next">Играть следующим</string>
<string name="menu_add_to_queue">Добавить в очередь</string>
<string name="menu_like">Добавить в «Мне нравится»</string>
<string name="menu_unlike">Убрать из «Мне нравится»</string>
<string name="menu_add_to_playlist">Добавить в плейлист…</string>
<string name="menu_play_similar">Слушать похожие</string>
<string name="menu_go_to_album">Перейти к альбому</string>
<string name="menu_go_to_artist_named">Перейти: %1$s</string>
<string name="menu_dislike">Не рекомендовать этот трек</string>
<string name="menu_undislike">Снова рекомендовать этот трек</string>
<string name="menu_move_up">Переместить выше</string>
<string name="menu_move_down">Переместить ниже</string>
<string name="menu_remove_from_playlist">Удалить из этого плейлиста</string>
<string name="menu_new_playlist">Новый плейлист…</string>
<string name="sheet_add_to_playlist">Добавить в плейлист</string>
<string name="sheet_new_playlist">Новый плейлист</string>
<string name="sheet_rename_playlist">Переименовать плейлист</string>
<string name="sheet_playlist_name">Название плейлиста</string>
<string name="sheet_new_hint_track">Трек добавится, как только плейлист будет создан.</string>
<string name="sheet_new_hint">Его видите только вы, пока не сделаете его открытым.</string>
<string name="sheet_delete_title">Удалить «%1$s»?</string>
<string name="sheet_delete_body">Плейлист и порядок треков удалятся навсегда. Сами треки останутся в Яндекс Музыке.</string>
<string name="toast_opening_clip">Открываем «%1$s» в браузере</string>
<string name="toast_no_browser">На этом телевизоре нет браузера, чтобы открыть клип.</string>
<string name="duration_min">%1$d мин</string>
<string name="duration_h_min">%1$d ч %2$d мин</string>
<plurals name="queue_and_more">
<item quantity="one">и ещё %1$d</item>
<item quantity="few">и ещё %1$d</item>
<item quantity="many">и ещё %1$d</item>
<item quantity="other">и ещё %1$d</item>
</plurals>
<plurals name="tracks">
<item quantity="one">%1$d трек</item>
<item quantity="few">%1$d трека</item>
<item quantity="many">%1$d треков</item>
<item quantity="other">%1$d трека</item>
</plurals>
<plurals name="listeners_a_month">
<item quantity="one">%1$s слушатель в месяц</item>
<item quantity="few">%1$s слушателя в месяц</item>
<item quantity="many">%1$s слушателей в месяц</item>
<item quantity="other">%1$s слушателя в месяц</item>
</plurals>
<plurals name="likes">
<item quantity="one">%1$s лайк</item>
<item quantity="few">%1$s лайка</item>
<item quantity="many">%1$s лайков</item>
<item quantity="other">%1$s лайка</item>
</plurals>
<string-array name="months_genitive">
<item>января</item>
<item>февраля</item>
<item>марта</item>
<item>апреля</item>
<item>мая</item>
<item>июня</item>
<item>июля</item>
<item>августа</item>
<item>сентября</item>
<item>октября</item>
<item>ноября</item>
<item>декабря</item>
</string-array>
</resources>
+5
View File
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- DESIGN.md `bg`, dark. The light value is in values-notnight. -->
<color name="bg">#1C1A22</color>
</resources>
+293
View File
@@ -0,0 +1,293 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name" translatable="false">Musyx</string>
<!-- The interface language, for number formatting. -->
<string name="lang_code">en</string>
<!-- Navigation and pages -->
<string name="nav_home">Home</string>
<string name="nav_wave">My Wave</string>
<string name="nav_search">Search</string>
<string name="nav_collection">Collection</string>
<string name="nav_podcasts">Podcasts</string>
<string name="nav_settings">Settings</string>
<string name="unknown_artist">Unknown artist</string>
<!-- Session -->
<string name="session_checking">Checking your sign-in…</string>
<string name="session_signing_in">Signing in…</string>
<string name="unreachable_title">Can\'t reach Yandex Music</string>
<string name="unreachable_body">You\'re still signed in. Check your internet connection, then try again.</string>
<!-- Sign-in -->
<string name="signin_title">Sign in with your Yandex account</string>
<string name="signin_blurb">Musyx plays your Yandex Music library, My Wave and playlists. You confirm sign-in on Yandex\'s own page, so your password never passes through this app.</string>
<string name="signin_footer">Musyx is an unofficial client and isn\'t affiliated with Yandex. Your sign-in token is kept encrypted on this device.</string>
<string name="signin_get_code">Get sign-in code</string>
<string name="signin_getting_code">Getting a code…</string>
<string name="signin_step_open">Open %1$s</string>
<string name="signin_step_open_hint">On your phone or computer. You can also scan the QR code.</string>
<string name="signin_step_code">Enter this code</string>
<string name="signin_step_code_hint">Lowercase, no spaces. If your phone capitalises or autocorrects it, fix it before you continue.</string>
<string name="signin_step_back">Come back here</string>
<string name="signin_step_back_hint">Musyx signs you in as soon as you allow access.</string>
<string name="signin_waiting">Waiting for confirmation · code expires in %1$s</string>
<string name="signin_token_show">Sign in with an existing token instead</string>
<string name="signin_token_hide">Hide token sign-in</string>
<string name="signin_token_placeholder">Paste OAuth token</string>
<string name="signin_qr_scan">Scan to open the sign-in page</string>
<string name="signin_qr_later">A QR code appears with your sign-in code</string>
<!-- Actions -->
<string name="action_play">Play</string>
<string name="action_shuffle">Shuffle</string>
<string name="action_pause">Pause</string>
<string name="action_resume">Resume</string>
<string name="action_try_again">Try again</string>
<string name="action_cancel">Cancel</string>
<string name="action_sign_in">Sign in</string>
<string name="action_sign_out">Sign out</string>
<string name="action_show_all_n">Show all %1$d</string>
<string name="action_show_more">Show more</string>
<string name="action_play_radio">Play radio</string>
<string name="action_rename">Rename</string>
<string name="action_make_private">Make private</string>
<string name="action_make_public">Make public</string>
<string name="action_delete">Delete</string>
<string name="action_create">Create</string>
<string name="action_new_playlist">New playlist…</string>
<string name="action_clear_covers">Clear cover cache</string>
<!-- Home, chart, genres, podcasts -->
<string name="section_recent">Recently played</string>
<string name="section_made_for_you">Made for you</string>
<string name="section_chart">Chart</string>
<string name="section_new_releases">New releases</string>
<string name="section_new_playlists">New playlists</string>
<string name="section_genres">Genres</string>
<string name="section_stations">Stations</string>
<string name="section_your_playlists">Your playlists</string>
<string name="section_liked_playlists">Liked playlists</string>
<string name="section_popular">Popular tracks</string>
<string name="section_appears_on">Appears on</string>
<string name="section_similar_artists">Similar artists</string>
<string name="section_yours">Yours</string>
<string name="section_featured">Featured</string>
<string name="chart_blurb">The most played tracks on Yandex Music today</string>
<string name="chart_empty">The chart is empty right now.</string>
<string name="genre_gone">This genre isn\'t available any more.</string>
<string name="genre_empty">No playlists in this genre yet.</string>
<string name="podcasts_title">Podcasts and books</string>
<!-- Loading and failures; %1$s is an object such as "your albums" -->
<string name="loading">Loading…</string>
<string name="loading_what">Loading %1$s…</string>
<string name="load_failed_network">Couldn\'t load %1$s. Check your connection and try again.</string>
<string name="load_failed">Couldn\'t load %1$s. Try again in a moment.</string>
<string name="loading_home">Loading your picks…</string>
<string name="loading_chart">Loading the chart…</string>
<string name="loading_genres">Loading genres…</string>
<string name="loading_podcasts">Loading podcasts…</string>
<string name="loading_playlists">Loading playlists…</string>
<string name="loading_liked">Loading your liked tracks…</string>
<string name="loading_album">Loading the album…</string>
<string name="loading_artist">Loading the artist…</string>
<string name="loading_playlist">Loading the playlist…</string>
<string name="loading_wave_settings">Loading your settings…</string>
<string name="loading_stations">Loading stations…</string>
<string name="what_home">your home page</string>
<string name="what_chart">the chart</string>
<string name="what_genres">genres</string>
<string name="what_podcasts">podcasts</string>
<string name="what_stations">stations</string>
<string name="what_wave_settings">your station settings</string>
<string name="what_albums">your albums</string>
<string name="what_artists">your artists</string>
<string name="what_playlists">your playlists</string>
<string name="what_clips">your clips</string>
<string name="what_liked">your liked tracks</string>
<string name="what_album">the album</string>
<string name="what_artist">the artist</string>
<string name="what_playlist">the playlist</string>
<string name="what_the_playlists">the playlists</string>
<string name="what_results">the results</string>
<!-- Collection -->
<string name="tab_liked_tracks">Liked tracks</string>
<string name="tab_albums">Albums</string>
<string name="tab_artists">Artists</string>
<string name="tab_playlists">Playlists</string>
<string name="tab_clips">Clips</string>
<string name="empty_liked">No liked tracks yet. Select the heart on any track and it lands here.</string>
<string name="empty_albums">No liked albums yet. Like an album and it lands here.</string>
<string name="empty_artists">No liked artists yet. Like an artist and they land here.</string>
<string name="empty_playlists">No playlists yet. Playlists you make or like show up here.</string>
<string name="empty_clips">No liked clips yet. Like a clip on an artist\'s page and it lands here.</string>
<string name="clips_hint">Clips open in the browser. Hold select on a clip to like or unlike it.</string>
<!-- Kinds -->
<string name="kind_album">Album</string>
<string name="kind_single">Single</string>
<string name="kind_compilation">Compilation</string>
<string name="kind_podcast">Podcast</string>
<string name="kind_audiobook">Audiobook</string>
<string name="kind_artist">Artist</string>
<string name="kind_artist_genres">Artist · %1$s</string>
<string name="kind_playlist_by">Playlist · %1$s</string>
<string name="kind_track_by">Track · %1$s</string>
<string name="visibility_public">Public</string>
<string name="visibility_private">Private</string>
<!-- Detail pages -->
<string name="gone_album">This album isn\'t available on Yandex Music any more.</string>
<string name="gone_artist">This artist isn\'t available on Yandex Music any more.</string>
<string name="gone_playlist">This playlist isn\'t available on Yandex Music any more.</string>
<string name="playlist_empty">This playlist is empty.</string>
<!-- Search -->
<string name="search_placeholder">Search artists, tracks, podcasts</string>
<string name="search_browse">Browse</string>
<string name="search_all">All</string>
<string name="search_tracks">Tracks</string>
<string name="search_show_all_tracks">Show all tracks</string>
<string name="search_albums">Albums</string>
<string name="search_artists">Artists</string>
<string name="search_playlists">Playlists</string>
<string name="search_podcasts">Podcasts</string>
<string name="search_results_for">Results for “%1$s”</string>
<string name="search_nothing">Nothing found for “%1$s”. Check the spelling or try fewer words.</string>
<string name="search_corrected">Showing results for “%1$s”</string>
<string name="search_top_result">Top result</string>
<string name="searching">Searching…</string>
<!-- My Wave -->
<string name="wave_play">Play My Wave</string>
<string name="wave_blurb">An endless stream picked from what you play, like and skip.</string>
<string name="wave_tuned">Tuned to: %1$s mood, %2$s tracks, %3$s language.</string>
<string name="wave_mood">Mood</string>
<string name="wave_character">Character</string>
<string name="wave_language">Language</string>
<string name="wave_any">Any</string>
<string name="mood_energetic">Energetic</string>
<string name="mood_cheerful">Cheerful</string>
<string name="mood_calm">Calm</string>
<string name="mood_sad">Sad</string>
<string name="character_favourite">Favourite</string>
<string name="character_unfamiliar">Unfamiliar</string>
<string name="character_popular">Popular</string>
<string name="language_russian">Russian</string>
<string name="language_foreign">Foreign</string>
<string name="stations_none">No other stations suggested right now.</string>
<!-- Settings -->
<string name="settings_quality">Streaming quality</string>
<string name="quality_lossless_detail">FLAC when Yandex offers it for your subscription and region, otherwise the best it allows. About 3–5 times the data of MP3, and tracks take longer to start.</string>
<string name="quality_best_detail">Highest MP3 bitrate Yandex offers, up to 320 kbps.</string>
<string name="quality_balanced_detail">Up to 192 kbps. About 40% less data.</string>
<string name="quality_data_saver_detail">Up to 128 kbps, for slow or metered connections.</string>
<string name="settings_appearance">Appearance</string>
<string name="match_system">Match system</string>
<string name="appearance_light">Light</string>
<string name="appearance_dark">Dark</string>
<string name="settings_font_size">Font size</string>
<string name="font_size_small">Small</string>
<string name="font_size_medium">Medium</string>
<string name="font_size_large">Large</string>
<string name="settings_language">Language</string>
<string name="settings_screen_saver">Screen saver</string>
<string name="saver_photos">Photos</string>
<string name="saver_photos_lyrics">Photos and lyrics</string>
<string name="saver_photos_detail">While music plays and the remote rests, photos of the artist drift by with what\'s playing.</string>
<string name="saver_photos_lyrics_detail">The lyrics come along too: the line being sung when they\'re synced, else the words about as far in as the song is.</string>
<string name="settings_storage">Storage</string>
<string name="settings_storage_detail">Covers are kept on disk so pages open instantly next time. Clearing them frees the space; they download again as you browse.</string>
<string name="settings_version">Musyx %1$s · unofficial Yandex Music client</string>
<string name="plus">Yandex Plus</string>
<string name="plus_until">Yandex Plus until %1$s</string>
<string name="plus_none">No Plus subscription. Tracks play as 30-second previews.</string>
<!-- Now Playing, queue and lyrics -->
<string name="nothing_playing">Nothing playing</string>
<string name="pick_a_track">Pick a track to start</string>
<string name="badge_preview">Preview</string>
<string name="panel_queue">Queue</string>
<string name="panel_lyrics">Lyrics</string>
<string name="queue_now">Now playing</string>
<string name="queue_nothing_after">Nothing after this</string>
<string name="queue_next_up">Next up · %1$d</string>
<string name="queue_empty">Nothing queued yet. Tracks you play, and the ones lined up after them, show up here.</string>
<string name="lyrics_play_first">Play a track to see its lyrics.</string>
<string name="lyrics_none">No lyrics found for this track.</string>
<string name="lyrics_failed">Couldn\'t load the lyrics. Check your connection and try again.</string>
<string name="lyrics_loading">Loading lyrics…</string>
<string name="lyrics_writers">Written by %1$s</string>
<string name="lyrics_source_lrclib">Lyrics from LRCLIB</string>
<string name="notice_station_dry">Couldn\'t load more of this station. Check your connection and try again.</string>
<string name="notice_too_many">Several tracks in a row couldn\'t be played. Check your connection and try again.</string>
<string name="notice_skipped">Couldn\'t play “%1$s”, so it was skipped.</string>
<!-- Track menu and dialogs -->
<string name="menu_next_track">Next track</string>
<string name="menu_play_next">Play next</string>
<string name="menu_add_to_queue">Add to queue</string>
<string name="menu_like">Add to Liked tracks</string>
<string name="menu_unlike">Remove from Liked tracks</string>
<string name="menu_add_to_playlist">Add to playlist…</string>
<string name="menu_play_similar">Play similar tracks</string>
<string name="menu_go_to_album">Go to album</string>
<string name="menu_go_to_artist_named">Go to %1$s</string>
<string name="menu_dislike">Don\'t recommend this track</string>
<string name="menu_undislike">Recommend this track again</string>
<string name="menu_move_up">Move up</string>
<string name="menu_move_down">Move down</string>
<string name="menu_remove_from_playlist">Remove from this playlist</string>
<string name="menu_new_playlist">New playlist…</string>
<string name="sheet_add_to_playlist">Add to playlist</string>
<string name="sheet_new_playlist">New playlist</string>
<string name="sheet_rename_playlist">Rename playlist</string>
<string name="sheet_playlist_name">Playlist name</string>
<string name="sheet_new_hint_track">The track goes in once it\'s created.</string>
<string name="sheet_new_hint">Only you can see it until you make it public.</string>
<string name="sheet_delete_title">Delete “%1$s”?</string>
<string name="sheet_delete_body">The playlist and its track order go away for good. The tracks stay in Yandex Music.</string>
<!-- Toasts -->
<string name="toast_opening_clip">Opening “%1$s” in the browser</string>
<string name="toast_no_browser">There\'s no browser on this TV to play clips in.</string>
<!-- Units -->
<string name="duration_min">%1$d min</string>
<string name="duration_h_min">%1$d h %2$d min</string>
<plurals name="queue_and_more">
<item quantity="one">and %1$d more</item>
<item quantity="other">and %1$d more</item>
</plurals>
<plurals name="tracks">
<item quantity="one">%1$d track</item>
<item quantity="other">%1$d tracks</item>
</plurals>
<plurals name="listeners_a_month">
<item quantity="one">%1$s listener a month</item>
<item quantity="other">%1$s listeners a month</item>
</plurals>
<plurals name="likes">
<item quantity="one">%1$s like</item>
<item quantity="other">%1$s likes</item>
</plurals>
<string-array name="months_genitive">
<item>January</item>
<item>February</item>
<item>March</item>
<item>April</item>
<item>May</item>
<item>June</item>
<item>July</item>
<item>August</item>
<item>September</item>
<item>October</item>
<item>November</item>
<item>December</item>
</string-array>
</resources>
+8
View File
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Only the window: everything else is drawn by MusyxTheme in Compose. -->
<style name="Theme.Musyx" parent="android:Theme.Material.NoActionBar">
<item name="android:windowBackground">@color/bg</item>
<item name="android:colorBackground">@color/bg</item>
</style>
</resources>
+9
View File
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Android 11 and lower; data_extraction_rules.xml covers 12+. Nothing is backed up. -->
<full-backup-content>
<exclude domain="root" />
<exclude domain="file" />
<exclude domain="database" />
<exclude domain="sharedpref" />
<exclude domain="external" />
</full-backup-content>
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Nothing is backed up or transferred: the OAuth token is device-bound (Keystore) and the
rest is a cache of the server. -->
<data-extraction-rules>
<cloud-backup>
<exclude domain="root" />
<exclude domain="file" />
<exclude domain="database" />
<exclude domain="sharedpref" />
<exclude domain="external" />
</cloud-backup>
<device-transfer>
<exclude domain="root" />
<exclude domain="file" />
<exclude domain="database" />
<exclude domain="sharedpref" />
<exclude domain="external" />
</device-transfer>
</data-extraction-rules>
@@ -0,0 +1,38 @@
package it.panov.musyx.tv.ui.theme
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.sp
import it.panov.musyx.data.FontSize
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Test
/** Ports the desktop theme.rs tests, plus parity checks for the placeholder hues. */
class ThemeTest {
@Test
fun accentMatchesDesign() {
assertEquals(Color(0xF0, 0xB2, 0x3E), DarkColors.accent)
assertEquals(Color(0x1F, 0x5F, 0x7A), LightColors.accent)
}
@Test
fun hslPrimaries() {
val red = hsl(0f, 1f, 0.5f)
assertEquals(1f, red.red, 1e-5f)
assertEquals(0f, red.green, 1e-5f)
assertEquals(0f, red.blue, 1e-5f)
val blue = hsl(240f, 1f, 0.5f)
assertEquals(1f, blue.blue, 1e-5f)
assertEquals(0f, blue.red, 1e-5f)
}
// Every size scales the desktop sizes, and all of them stay under the original TV scale.
@Test
fun fontSizeScalesType() {
assertEquals(12.6f, musyxType(FontSize.Small.scale).body.fontSize.value, 1e-4f)
assertEquals(14.7f, musyxType(FontSize.Medium.scale).body.fontSize.value, 1e-4f)
assertEquals(16.8f, musyxType(FontSize.Large.scale).body.fontSize.value, 1e-4f)
FontSize.entries.forEach { assertTrue(it.scale < TV_TYPE_SCALE) }
assertEquals(21.sp, MusyxTypeScale.body.fontSize)
}
}