Add a phone app with Android Auto support

:mobile (it.panov.musyx) is a Material 3 phone app over the shared AppState: Home,
My Wave, search, collection, detail pages, Now Playing with queue and lyrics,
and sign-in through Yandex's page in the browser.

Its playback service is a MediaLibraryService, so Android Auto and Automotive
can browse My Wave and stations, Home picks and the collection, search, and
play by voice. Covers reach the car through a content provider limited to
Yandex hosts. Signed out, the car shows a Sign in button, and it reloads when
the session changes.

The session's playlist is now the current track and PlayerCore's next 50, so a
car's queue screen lists them and picking one jumps there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Yuriy PanovandClaude Opus 5.5 committed 2026-10-23 12:19:27 +06:00
1 parent f004859395
commit 729b9b8aef
89 files changed
+5773 -15

No files matched your search

+14 -1
View File
@@ -51,7 +51,12 @@ runs the JVM tests (the queue and player rules, API parsing and request signing,
decryption and theme parity, mostly ported from the desktop tests), and `./gradlew lint` runs Android
Lint, with a report in each module's `build/reports/lint-results-debug.html`.
To run it, start an Android TV or Google TV emulator (Device Manager in Android Studio, TV
The phone app builds with `./gradlew :mobile:assembleDebug` and installs with
`./gradlew :mobile:installDebug`. To try it in Android Auto, run the Desktop Head Unit (SDK
Manager, SDK Tools, Android Auto Desktop Head Unit) against a phone with Android Auto, with
Auto's developer settings on and "Unknown sources" allowed, since the app isn't from Play.
To run the TV app, start an Android TV or Google TV emulator (Device Manager in Android Studio, TV
category) or connect a TV with ADB debugging on, then:
```bash
@@ -94,6 +99,14 @@ changing the sources:
- `player/PlaybackService.kt`: the media session.
- `ui/`: the shell (drawer, mini player, dialogs, toasts), `screens/` and `components/`.
The theme is `ui/theme/Theme.kt`, a 1:1 port of `DESIGN.md`.
- `mobile/`: the phone app (`it.panov.musyx`), under `mobile/src/main/java/it/panov/musyx/mobile`:
- `PlaybackService.kt`: a `MediaLibraryService`, so the notification, lock screen,
Bluetooth and Android Auto all reach the player.
- `Library.kt`: the browse tree Android Auto shows (My Wave and stations, Home picks, the
collection) and its search and voice requests.
- `ArtworkProvider.kt`: serves covers to Auto as `content://` URIs, Yandex hosts only.
- `ui/`: Material 3 screens over the shared `AppState`; `res/values/strings.xml` is
copied from the TV app by name, `strings_phone.xml` has the phone's own.
- `gradle/libs.versions.toml`: dependency versions.
- `DESIGN.md`: design tokens (colour, type, space, components), shared with the desktop app.
- `design/mockup.html`: the approved desktop mockup.
@@ -10,7 +10,6 @@ import android.os.Looper
import androidx.media3.common.AudioAttributes
import androidx.media3.common.C
import androidx.media3.common.MediaItem
import androidx.media3.common.MediaMetadata
import androidx.media3.common.PlaybackException
import androidx.media3.common.Player
import androidx.annotation.OptIn
@@ -91,15 +90,7 @@ class ExoEngine(context: Context, private val token: () -> String?, private val
keys.clear()
val key = stream.key?.let { hexKey(it) }
if (key != null) stream.urls.forEach { keys[it] = key }
val metadata = MediaMetadata.Builder()
.setTitle(track.fullTitle)
.setArtist(track.artistLine)
.setAlbumTitle(track.album?.title)
.setArtworkUri(track.coverUrl(400)?.let(Uri::parse))
.setIsPlayable(true)
.setIsBrowsable(false)
.build()
item = MediaItem.Builder().setMediaId(track.id).setMediaMetadata(metadata)
item = MediaItem.Builder().setMediaId(track.id).setMediaMetadata(track.mediaMetadata())
start(play)
}
@@ -122,6 +122,7 @@ class PlaybackController(
waveStation = core.waveStation,
)
positionMs = core.positionMs
sessionPlayer.queueChanged()
}
// ---- Engine events ----
@@ -1,22 +1,49 @@
// The player that each app's media session wraps.
package it.panov.musyx.player
import android.net.Uri
import androidx.annotation.OptIn
import androidx.media3.common.C
import androidx.media3.common.ForwardingSimpleBasePlayer
import androidx.media3.common.MediaItem
import androidx.media3.common.MediaMetadata
import androidx.media3.common.Player
import androidx.media3.common.util.UnstableApi
import com.google.common.util.concurrent.Futures
import com.google.common.util.concurrent.ListenableFuture
import it.panov.musyx.api.Track
/** Upcoming tracks shown to controllers; a long liked list would make every update heavy. */
private const val QUEUE_SHOWN = 50
/** How a track describes itself to the media session, for what's playing and what's next. */
internal fun Track.mediaMetadata(): MediaMetadata = MediaMetadata.Builder()
.setTitle(fullTitle)
.setArtist(artistLine)
.setAlbumTitle(album?.title)
.setArtworkUri(coverUrl(400)?.let(Uri::parse))
.setIsPlayable(true)
.setIsBrowsable(false)
.build()
/**
* The ExoPlayer as the media session sees it. ExoPlayer only ever holds the current
* track, so next and previous are added here and routed to the queue, as are play,
* pause and seeks, so PlayerCore stays the one source of truth.
* pause and seeks, so PlayerCore stays the one source of truth. The playlist controllers
* see is the current track followed by PlayerCore's upcoming ones, so a car's queue
* screen lists them and picking one jumps there.
*/
@OptIn(UnstableApi::class)
class SessionPlayer(player: Player, private val controller: PlaybackController) :
class SessionPlayer(private val player: Player, private val controller: PlaybackController) :
ForwardingSimpleBasePlayer(player) {
/** The upcoming tracks behind the playlist last shown, and their items, so a pick finds its track. */
private var shown: List<Pair<Int, Track>> = emptyList()
private var shownItems: List<MediaItemData> = emptyList()
/** PlayerCore's queue changed: controllers re-read the playlist. */
fun queueChanged() = invalidateState()
override fun getState(): State {
val state = super.getState()
val commands = state.availableCommands.buildUpon()
@@ -26,9 +53,40 @@ class SessionPlayer(player: Player, private val controller: PlaybackController)
Player.COMMAND_SEEK_TO_NEXT_MEDIA_ITEM,
Player.COMMAND_SEEK_TO_PREVIOUS,
Player.COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM,
Player.COMMAND_SEEK_TO_MEDIA_ITEM,
)
.build()
return state.buildUpon().setAvailableCommands(commands).build()
val builder = state.buildUpon().setAvailableCommands(commands)
val current = player.currentMediaItem
val upcoming = controller.state.upcoming.take(QUEUE_SHOWN)
if (current != null && upcoming.isNotEmpty()) {
builder.setPlaylist(listOf(nowPlaying(current)) + queued(upcoming)).setCurrentMediaItemIndex(0)
} else {
shown = emptyList()
}
return builder.build()
}
/** The track ExoPlayer holds, as ExoPlayer describes it. */
private fun nowPlaying(item: MediaItem): MediaItemData = MediaItemData.Builder("now:${item.mediaId}")
.setMediaItem(item)
.setTracks(player.currentTracks)
.setIsSeekable(player.isCurrentMediaItemSeekable)
.setDurationUs(player.duration.takeIf { it != C.TIME_UNSET }?.times(1000) ?: C.TIME_UNSET)
.build()
private fun queued(upcoming: List<Pair<Int, Track>>): List<MediaItemData> {
if (upcoming != shown) {
shown = upcoming
shownItems = upcoming.map { (pos, track) ->
val item = MediaItem.Builder().setMediaId(track.id).setMediaMetadata(track.mediaMetadata()).build()
MediaItemData.Builder("next:$pos:${track.id}")
.setMediaItem(item)
.setDurationUs(track.durationMs * 1000)
.build()
}
}
return shownItems
}
override fun handleSetPlayWhenReady(playWhenReady: Boolean): ListenableFuture<*> {
@@ -45,10 +103,22 @@ class SessionPlayer(player: Player, private val controller: PlaybackController)
/** The queue prepares tracks itself; play after a stop goes through [handleSetPlayWhenReady]. */
override fun handlePrepare(): ListenableFuture<*> = Futures.immediateVoidFuture()
/**
* Items a controller (Android Auto, say) asks to play never reach ExoPlayer: the library
* session has already started them through PlayerCore by the time they arrive here.
*/
override fun handleSetMediaItems(mediaItems: List<MediaItem>, startIndex: Int, startPositionMs: Long): ListenableFuture<*> =
Futures.immediateVoidFuture()
override fun handleAddMediaItems(index: Int, mediaItems: List<MediaItem>): ListenableFuture<*> = Futures.immediateVoidFuture()
override fun handleSeek(mediaItemIndex: Int, positionMs: Long, seekCommand: Int): ListenableFuture<*> {
when (seekCommand) {
Player.COMMAND_SEEK_TO_NEXT, Player.COMMAND_SEEK_TO_NEXT_MEDIA_ITEM -> controller.next()
Player.COMMAND_SEEK_TO_PREVIOUS, Player.COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM -> controller.previous()
// A pick from the queue: index 0 is the current track, the rest are `shown` in order.
Player.COMMAND_SEEK_TO_MEDIA_ITEM -> shown.getOrNull(mediaItemIndex - 1)?.let { (pos, _) -> controller.jumpTo(pos) }
?: controller.seek(positionMs.coerceAtLeast(0))
else -> controller.seek(positionMs.coerceAtLeast(0))
}
return Futures.immediateVoidFuture()
+1
View File
@@ -24,6 +24,7 @@ compose-ui-graphics = { module = "androidx.compose.ui:ui-graphics" }
compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling" }
compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview" }
compose-foundation = { module = "androidx.compose.foundation:foundation" }
compose-material3 = { module = "androidx.compose.material3:material3" }
compose-runtime = { module = "androidx.compose.runtime:runtime" }
tv-material = { module = "androidx.tv:tv-material", version.ref = "tv-material" }
media3-exoplayer = { module = "androidx.media3:media3-exoplayer", version.ref = "media3" }
+70
View File
@@ -0,0 +1,70 @@
import java.util.Properties
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.compose)
}
android {
namespace = "it.panov.musyx.mobile"
compileSdk = 37
defaultConfig {
applicationId = "it.panov.musyx"
minSdk = 23
targetSdk = 37
versionCode = 1
versionName = "0.1.0"
}
// The same keystore.properties as the TV app; without one, release builds use the debug key.
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.material3)
implementation(libs.compose.ui.tooling.preview)
debugImplementation(libs.compose.ui.tooling)
implementation(libs.media3.exoplayer)
implementation(libs.media3.session)
implementation(libs.okhttp)
implementation(libs.coil.compose)
implementation(libs.coil.network.okhttp)
}
+9
View File
@@ -0,0 +1,9 @@
<?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>
<!-- 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.
+62
View File
@@ -0,0 +1,62 @@
<?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" />
<application
android:name=".Musyx"
android:allowBackup="false"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/Theme.Musyx">
<!-- Android Auto: this app is a media source it can browse. -->
<meta-data
android:name="com.google.android.gms.car.application"
android:resource="@xml/automotive_app_desc" />
<activity
android:name=".MainActivity"
android:configChanges="keyboard|keyboardHidden|navigation|screenSize|smallestScreenSize|screenLayout|orientation|uiMode"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<!-- "Play … on Musyx" from the Assistant. -->
<intent-filter>
<action android:name="android.media.action.MEDIA_PLAY_FROM_SEARCH" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<service
android:name=".PlaybackService"
android:exported="true"
android:foregroundServiceType="mediaPlayback"
tools:ignore="ExportedService">
<!-- Exported so the system, Bluetooth controls and Android Auto reach the media library. -->
<intent-filter>
<action android:name="androidx.media3.session.MediaLibraryService" />
<action android:name="android.media.browse.MediaBrowserService" />
</intent-filter>
</service>
<!-- Covers for Android Auto, which can't load https itself. Read-only, Yandex hosts only. -->
<provider
android:name=".ArtworkProvider"
android:authorities="${applicationId}.artwork"
android:exported="true"
tools:ignore="ExportedContentProvider" />
</application>
</manifest>
@@ -0,0 +1,63 @@
// Covers for Android Auto. Auto loads browse artwork only from content:// URIs, so each https
// cover is fetched once into the cache and served from there.
package it.panov.musyx.mobile
import android.content.ContentProvider
import android.content.ContentValues
import android.content.Context
import android.database.Cursor
import android.net.Uri
import android.os.ParcelFileDescriptor
import okhttp3.OkHttpClient
import okhttp3.Request
import java.io.File
import java.io.FileNotFoundException
import java.security.MessageDigest
class ArtworkProvider : ContentProvider() {
private val http by lazy { OkHttpClient() }
override fun onCreate(): Boolean = true
override fun openFile(uri: Uri, mode: String): ParcelFileDescriptor {
val url = uri.lastPathSegment?.let(Uri::parse) ?: throw FileNotFoundException("$uri")
// Exported for the car, so it fetches only Yandex covers, never an arbitrary URL.
val host = url.host.orEmpty()
if (url.scheme != "https" || !(host == "yandex.net" || host.endsWith(".yandex.net"))) throw FileNotFoundException("$uri")
val file = File(requireNotNull(context).cacheDir, "artwork/${sha1(url.toString())}")
if (!file.exists()) fetch(url.toString(), file)
return ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY)
}
/** Downloads to a temporary file first, so a broken download never passes for a cover. */
private fun fetch(url: String, file: File) {
file.parentFile?.mkdirs()
val part = File(file.path + ".part")
try {
http.newCall(Request.Builder().url(url).build()).execute().use { response ->
if (!response.isSuccessful) throw FileNotFoundException("$url: http ${response.code}")
part.outputStream().use { response.body.byteStream().copyTo(it) }
}
if (!part.renameTo(file)) throw FileNotFoundException(url)
} catch (e: java.io.IOException) {
part.delete()
throw FileNotFoundException("$url: $e")
}
}
override fun getType(uri: Uri): String = "image/jpeg"
override fun query(uri: Uri, projection: Array<out String>?, selection: String?, selectionArgs: Array<out String>?, sortOrder: String?): Cursor? = null
override fun insert(uri: Uri, values: ContentValues?): Uri? = null
override fun delete(uri: Uri, selection: String?, selectionArgs: Array<out String>?): Int = 0
override fun update(uri: Uri, values: ContentValues?, selection: String?, selectionArgs: Array<out String>?): Int = 0
companion object {
/** The content URI the car loads `url` from. */
fun uri(context: Context, url: String): Uri =
Uri.Builder().scheme("content").authority("${context.packageName}.artwork").appendPath(url).build()
private fun sha1(s: String): String =
MessageDigest.getInstance("SHA-1").digest(s.toByteArray()).joinToString("") { "%02x".format(it) }
}
}
@@ -0,0 +1,361 @@
// The media library Android Auto browses: My Wave and stations, picks from Home, and the
// collection. Playing an item starts it through PlayerCore, like a tap in the app would.
package it.panov.musyx.mobile
import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.util.Log
import androidx.annotation.OptIn
import androidx.compose.runtime.snapshotFlow
import androidx.compose.runtime.snapshots.Snapshot
import androidx.media3.common.C
import androidx.media3.common.MediaItem
import androidx.media3.common.MediaMetadata
import androidx.media3.common.util.UnstableApi
import androidx.media3.session.LibraryResult
import androidx.media3.session.MediaConstants
import androidx.media3.session.MediaLibraryService.LibraryParams
import androidx.media3.session.MediaLibraryService.MediaLibrarySession
import androidx.media3.session.MediaSession
import androidx.media3.session.MediaSession.MediaItemsWithStartPosition
import androidx.media3.session.SessionError
import com.google.common.collect.ImmutableList
import com.google.common.util.concurrent.Futures
import com.google.common.util.concurrent.ListenableFuture
import com.google.common.util.concurrent.SettableFuture
import it.panov.musyx.api.AlbumSummary
import it.panov.musyx.api.MY_WAVE
import it.panov.musyx.api.PlaylistId
import it.panov.musyx.api.PlaylistSummary
import it.panov.musyx.api.SearchKind
import it.panov.musyx.api.Station
import it.panov.musyx.api.Track
import it.panov.musyx.api.YmClient
import it.panov.musyx.state.AppState
import it.panov.musyx.state.Liked
import it.panov.musyx.state.Session
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.drop
import kotlinx.coroutines.launch
import kotlinx.coroutines.withTimeoutOrNull
/** Covers in the car: big enough for the grid, small enough to load quickly. */
private const val ART_SIZE = 300
/** Recently played tracks listed in the car. */
private const val RECENT_SHOWN = 30
/** How long to wait for the stored sign-in when Auto connects before the app has run. */
private const val RESTORE_MS = 20_000L
// Media ids. Folders are plain names or `kind:id`; a playable track is `t|<folder>|<index>`,
// so playing it can queue the rest of its folder.
private const val ROOT = "root"
private const val WAVE = "wave"
private const val HOME = "home"
private const val COLLECTION = "collection"
private const val LIKED = "liked"
private const val RECENT = "recent"
private const val CHART = "chart"
private const val PLAYLISTS = "playlists"
private const val ALBUMS = "albums"
private const val STATION = "station|"
private const val TRACK = "t|"
private const val SEARCH = "search:"
@OptIn(UnstableApi::class)
class Library(private val context: Context, private val state: AppState, private val scope: CoroutineScope) :
MediaLibrarySession.Callback {
/** Track lists by folder, as last shown, so playing a row queues what was on screen. */
private val shown = HashMap<String, List<Track>>()
/** Search results by query, between onSearch and onGetSearchResult. */
private val searches = HashMap<String, List<MediaItem>>()
/**
* Has the car reload whenever someone signs in or out, so it never keeps showing "Sign in"
* (or someone else's music). Returns what stops watching.
*/
fun watchSession(session: MediaLibrarySession): () -> Unit {
// snapshotFlow hears about changes through Compose's apply notifications, which only the
// app's UI sends; with just the car connected, nothing would. Send them here as well.
var queued = false
val writes = Snapshot.registerGlobalWriteObserver {
if (!queued) {
queued = true
scope.launch(Dispatchers.Main) {
queued = false
Snapshot.sendApplyNotifications()
}
}
}
val job = scope.launch {
snapshotFlow { state.session is Session.SignedIn }
.distinctUntilChanged()
.drop(1)
.collect {
shown.clear()
searches.clear()
session.notifyChildrenChanged(ROOT, Int.MAX_VALUE, null)
}
}
return {
job.cancel()
writes.dispose()
}
}
override fun onGetLibraryRoot(
session: MediaLibrarySession,
browser: MediaSession.ControllerInfo,
params: LibraryParams?,
): ListenableFuture<LibraryResult<MediaItem>> {
// Folders of albums and playlists show as grids, tracks as lists.
val extras = Bundle().apply {
putInt(MediaConstants.EXTRAS_KEY_CONTENT_STYLE_BROWSABLE, MediaConstants.EXTRAS_VALUE_CONTENT_STYLE_GRID_ITEM)
putInt(MediaConstants.EXTRAS_KEY_CONTENT_STYLE_PLAYABLE, MediaConstants.EXTRAS_VALUE_CONTENT_STYLE_LIST_ITEM)
}
val root = folder(ROOT, context.getString(R.string.app_name))
return Futures.immediateFuture(LibraryResult.ofItem(root, LibraryParams.Builder().setExtras(extras).build()))
}
override fun onGetChildren(
session: MediaLibrarySession,
browser: MediaSession.ControllerInfo,
parentId: String,
page: Int,
pageSize: Int,
params: LibraryParams?,
): ListenableFuture<LibraryResult<ImmutableList<MediaItem>>> = future {
val client = client() ?: return@future signedOut()
val items = children(client, parentId) ?: return@future LibraryResult.ofError(SessionError.ERROR_BAD_VALUE)
LibraryResult.ofItemList(items.page(page, pageSize), params)
}
override fun onGetItem(
session: MediaLibrarySession,
browser: MediaSession.ControllerInfo,
mediaId: String,
): ListenableFuture<LibraryResult<MediaItem>> {
val item = if (mediaId == ROOT) folder(ROOT, context.getString(R.string.app_name)) else null
return Futures.immediateFuture(item?.let { LibraryResult.ofItem(it, null) } ?: LibraryResult.ofError(SessionError.ERROR_BAD_VALUE))
}
override fun onSearch(
session: MediaLibrarySession,
browser: MediaSession.ControllerInfo,
query: String,
params: LibraryParams?,
): ListenableFuture<LibraryResult<Void>> = future {
val client = client() ?: return@future signedOut()
val tracks = client.search(query, SearchKind.Tracks, 0).tracks
val folder = SEARCH + query
shown[folder] = tracks
searches[query] = tracks.mapIndexed { i, t -> track(folder, i, t) }
session.notifySearchResultChanged(browser, query, tracks.size, params)
LibraryResult.ofVoid()
}
override fun onGetSearchResult(
session: MediaLibrarySession,
browser: MediaSession.ControllerInfo,
query: String,
page: Int,
pageSize: Int,
params: LibraryParams?,
): ListenableFuture<LibraryResult<ImmutableList<MediaItem>>> =
Futures.immediateFuture(LibraryResult.ofItemList(searches[query].orEmpty().page(page, pageSize), params))
/**
* Plays what the car picked: a station, a track with the rest of its folder, or, for a
* spoken request, the best tracks for it (My Wave when nothing was named).
*/
override fun onSetMediaItems(
mediaSession: MediaSession,
controller: MediaSession.ControllerInfo,
mediaItems: List<MediaItem>,
startIndex: Int,
startPositionMs: Long,
): ListenableFuture<MediaItemsWithStartPosition> = future {
val item = mediaItems.getOrNull(startIndex.coerceAtLeast(0)) ?: mediaItems.first()
val id = item.mediaId
val query = item.requestMetadata.searchQuery
when {
id.startsWith(STATION) -> state.playWave(id.removePrefix(STATION))
id.startsWith(TRACK) -> {
val (folder, index) = id.removePrefix(TRACK).let { it.substringBeforeLast('|') to it.substringAfterLast('|').toIntOrNull() }
val tracks = shown[folder] ?: client()?.let { tracks(it, folder) }
if (tracks != null && index != null && index in tracks.indices) state.playTracks(tracks, index)
}
id.isEmpty() -> playFromSearch(state, query)
}
MediaItemsWithStartPosition(mediaItems, startIndex, C.TIME_UNSET)
}
// ---- The tree ----
private suspend fun children(client: YmClient, parent: String): List<MediaItem>? = when (parent) {
ROOT -> listOf(
folder(WAVE, context.getString(R.string.nav_wave), browsable = MediaConstants.EXTRAS_VALUE_CONTENT_STYLE_LIST_ITEM),
folder(HOME, context.getString(R.string.nav_home)),
folder(COLLECTION, context.getString(R.string.nav_collection), browsable = MediaConstants.EXTRAS_VALUE_CONTENT_STYLE_LIST_ITEM),
)
WAVE -> {
val stations = runCatching { client.stations() }.getOrDefault(emptyList()).filter { it.id != MY_WAVE }
listOf(station(MY_WAVE, context.getString(R.string.nav_wave), null)) + stations.map(::station)
}
HOME -> {
val home = client.home()
listOf(
folder(RECENT, context.getString(R.string.section_recent)),
folder(CHART, context.getString(R.string.section_chart)),
) + home.personal.map { playlist(it.playlist) }
}
COLLECTION -> listOf(
folder(LIKED, context.getString(R.string.tab_liked_tracks)),
folder(PLAYLISTS, context.getString(R.string.tab_playlists)),
folder(ALBUMS, context.getString(R.string.tab_albums)),
)
PLAYLISTS -> client.libraryPlaylists().let { it.own + it.liked }.map(::playlist)
ALBUMS -> client.likedAlbums().filter { !it.isPodcast }.map(::album)
else -> tracks(client, parent)?.let { tracks ->
shown[parent] = tracks
tracks.mapIndexed { i, t -> track(parent, i, t) }
}
}
/** The tracks of a track folder; null for anything else. */
private suspend fun tracks(client: YmClient, folder: String): List<Track>? = when {
folder == LIKED -> (state.liked as? Liked.Loaded)?.tracks ?: client.likedTracks()
folder == RECENT -> client.recentlyPlayed(RECENT_SHOWN)
folder == CHART -> client.chart().map { it.track }
folder.startsWith("album:") -> folder.removePrefix("album:").toLongOrNull()?.let { client.album(it).tracks }
folder.startsWith("playlist:") -> folder.removePrefix("playlist:").split(':').mapNotNull { it.toLongOrNull() }
.takeIf { it.size == 2 }
?.let { (owner, kind) -> client.playlist(PlaylistId(owner, kind)).tracks }
folder.startsWith(SEARCH) -> client.search(folder.removePrefix(SEARCH), SearchKind.Tracks, 0).tracks
else -> null
}
private fun folder(id: String, title: String, art: String? = null, subtitle: String? = null, browsable: Int? = null): MediaItem {
val extras = browsable?.let { Bundle().apply { putInt(MediaConstants.EXTRAS_KEY_CONTENT_STYLE_BROWSABLE, it) } }
return MediaItem.Builder()
.setMediaId(id)
.setMediaMetadata(
MediaMetadata.Builder()
.setTitle(title)
.setSubtitle(subtitle)
.setArtworkUri(artwork(art))
.setIsBrowsable(true)
.setIsPlayable(false)
.setMediaType(MediaMetadata.MEDIA_TYPE_FOLDER_MIXED)
.setExtras(extras)
.build(),
)
.build()
}
private fun playlist(p: PlaylistSummary) =
folder("playlist:${p.id.owner}:${p.id.kind}", p.title, p.coverUrl(ART_SIZE), p.ownerName.takeIf { it.isNotEmpty() }, MediaConstants.EXTRAS_VALUE_CONTENT_STYLE_LIST_ITEM)
private fun album(a: AlbumSummary) =
folder("album:${a.id}", a.fullTitle, a.coverUrl(ART_SIZE), a.artistLine, MediaConstants.EXTRAS_VALUE_CONTENT_STYLE_LIST_ITEM)
private fun station(s: Station) = station(s.id, s.name, s.iconUrl(ART_SIZE))
private fun station(id: String, name: String, art: String?) = MediaItem.Builder()
.setMediaId(STATION + id)
.setMediaMetadata(
MediaMetadata.Builder()
.setTitle(name)
.setArtworkUri(artwork(art))
.setIsBrowsable(false)
.setIsPlayable(true)
.setMediaType(MediaMetadata.MEDIA_TYPE_RADIO_STATION)
.build(),
)
.build()
private fun track(folder: String, index: Int, t: Track) = MediaItem.Builder()
.setMediaId("$TRACK$folder|$index")
.setMediaMetadata(
MediaMetadata.Builder()
.setTitle(t.fullTitle)
.setArtist(t.artistLine)
.setAlbumTitle(t.album?.title)
.setArtworkUri(artwork(t.coverUrl(ART_SIZE)))
.setDurationMs(t.durationMs)
.setIsBrowsable(false)
.setIsPlayable(t.available)
.setMediaType(MediaMetadata.MEDIA_TYPE_MUSIC)
.build(),
)
.build()
private fun artwork(url: String?): Uri? = url?.let { ArtworkProvider.uri(context, it) }
// ---- Plumbing ----
private suspend fun client(): YmClient? = awaitClient(state)
/** Signed out: the car shows why, with a button that opens the app's sign-in. */
private fun <V : Any> signedOut(): LibraryResult<V> {
val open = PendingIntent.getActivity(
context,
0,
Intent(context, MainActivity::class.java).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK),
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT,
)
val extras = Bundle().apply {
putString(MediaConstants.EXTRAS_KEY_ERROR_RESOLUTION_ACTION_LABEL_COMPAT, context.getString(R.string.action_sign_in))
putParcelable(MediaConstants.EXTRAS_KEY_ERROR_RESOLUTION_ACTION_INTENT_COMPAT, open)
}
val error = SessionError(SessionError.ERROR_SESSION_AUTHENTICATION_EXPIRED, context.getString(R.string.auto_sign_in), extras)
return LibraryResult.ofError<V>(error)
}
/** Runs `block` on the app's main-thread scope; a failure fails the future, which the car shows as an error. */
private fun <T> future(block: suspend () -> T): ListenableFuture<T> {
val result = SettableFuture.create<T>()
scope.launch {
try {
result.set(block())
} catch (e: CancellationException) {
result.cancel(false)
throw e
} catch (e: Throwable) {
Log.w(TAG, "library: $e")
result.setException(e)
}
}
return result
}
private fun <T> List<T>.page(page: Int, size: Int): List<T> =
if (size <= 0 || size == Int.MAX_VALUE) this else drop(page * size).take(size)
private companion object {
const val TAG = "Musyx"
}
}
/** The signed-in client, once the stored sign-in has been checked; null when signed out. */
internal suspend fun awaitClient(state: AppState): YmClient? {
// Polled: without the app's UI running, nothing delivers Compose state changes to observers.
withTimeoutOrNull(RESTORE_MS) {
while (state.session is Session.Restoring || state.session is Session.Connecting) delay(100)
}
return state.client
}
/** A spoken request ("play … on Musyx"): the best tracks for `query`, or My Wave when nothing was named. */
internal suspend fun playFromSearch(state: AppState, query: String?) {
if (query.isNullOrBlank()) return state.playWave(MY_WAVE)
val tracks = awaitClient(state)?.search(query, SearchKind.Tracks, 0)?.tracks.orEmpty()
if (tracks.isNotEmpty()) state.playTracks(tracks, 0)
}
@@ -0,0 +1,16 @@
package it.panov.musyx.mobile
import android.content.Context
import android.content.res.Configuration
import it.panov.musyx.data.SettingsStore
import java.util.Locale
/** This context in the interface language the settings pick; as it is when they follow the system. */
fun Context.inAppLanguage(): Context {
val tag = SettingsStore(this).language().tag ?: return this
val config = Configuration(resources.configuration)
val locale = Locale.forLanguageTag(tag)
Locale.setDefault(locale)
config.setLocale(locale)
return createConfigurationContext(config)
}
@@ -0,0 +1,105 @@
package it.panov.musyx.mobile
import android.Manifest
import android.app.SearchManager
import android.content.ComponentName
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import android.os.Build
import android.os.Bundle
import android.provider.MediaStore
import androidx.activity.ComponentActivity
import androidx.activity.SystemBarStyle
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.activity.result.contract.ActivityResultContracts
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.snapshotFlow
import androidx.compose.ui.graphics.toArgb
import androidx.core.content.ContextCompat
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.mobile.ui.MusyxApp
import it.panov.musyx.mobile.ui.theme.DarkColors
import it.panov.musyx.mobile.ui.theme.LightColors
import it.panov.musyx.mobile.ui.theme.MusyxTheme
import it.panov.musyx.mobile.ui.theme.isMusyxDark
import it.panov.musyx.state.Session
import kotlinx.coroutines.flow.drop
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.launch
class MainActivity : ComponentActivity() {
/** Binds the playback service so it can go foreground when playback starts. */
private var controller: ListenableFuture<MediaController>? = null
private val askNotifications = registerForActivityResult(ActivityResultContracts.RequestPermission()) {}
/** The interface language follows the setting, not only the system. */
override fun attachBaseContext(newBase: Context) = super.attachBaseContext(newBase.inAppLanguage())
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val state = Musyx.graph(this).state
state.start()
if (savedInstanceState == null) handleVoiceSearch(intent)
setContent {
val dark = when (state.settings.appearance) {
Appearance.System -> isMusyxDark()
Appearance.Light -> false
Appearance.Dark -> true
}
LaunchedEffect(dark) {
val bg = (if (dark) DarkColors else LightColors).bg.toArgb()
val bars = if (dark) SystemBarStyle.dark(bg) else SystemBarStyle.light(bg, bg)
enableEdgeToEdge(statusBarStyle = bars, navigationBarStyle = bars)
}
// A new interface language means new resources: rebuild the activity in it.
LaunchedEffect(Unit) {
snapshotFlow { state.settings.language }.drop(1).collect { recreate() }
}
// The playback notification needs permission from Android 13; ask once signed in.
LaunchedEffect(Unit) {
snapshotFlow { state.session }.first { it is Session.SignedIn }
askForNotifications()
}
MusyxTheme(dark = dark, typeScale = state.settings.fontSize.scale) {
MusyxApp(state, onExit = { moveTaskToBack(true) })
}
}
}
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
handleVoiceSearch(intent)
}
/** A spoken "play … on Musyx": the activity is only the way in, the search runs in the app. */
private fun handleVoiceSearch(intent: Intent?) {
if (intent?.action != MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH) return
val app = Musyx.graph(this)
val query = intent.getStringExtra(SearchManager.QUERY)
app.scope.launch { runCatching { playFromSearch(app.state, query) } }
}
private fun askForNotifications() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) return
if (ContextCompat.checkSelfPermission(this, Manifest.permission.POST_NOTIFICATIONS) == PackageManager.PERMISSION_GRANTED) return
askNotifications.launch(Manifest.permission.POST_NOTIFICATIONS)
}
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()
}
}
@@ -0,0 +1,63 @@
// The application: one AppState for the activity, the playback service and Android Auto to share.
package it.panov.musyx.mobile
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/${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,54 @@
// Background audio and everything outside the app that controls it: the notification, the
// lock screen, Bluetooth buttons, and Android Auto, which also browses the library here.
package it.panov.musyx.mobile
import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import androidx.annotation.OptIn
import androidx.media3.common.util.UnstableApi
import androidx.media3.session.MediaLibraryService
import androidx.media3.session.MediaSession
@OptIn(UnstableApi::class)
class PlaybackService : MediaLibraryService() {
private var session: MediaLibrarySession? = null
private var stopWatching: (() -> Unit)? = null
/** Folder names in Android Auto follow the app's language setting. */
override fun attachBaseContext(newBase: Context) = super.attachBaseContext(newBase.inAppLanguage())
override fun onCreate() {
super.onCreate()
val app = Musyx.graph(this)
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,
)
// Android Auto may start the service with no activity: restore the sign-in for it.
app.state.start()
val library = Library(this, app.state, app.scope)
session = MediaLibrarySession.Builder(this, app.state.playback.sessionPlayer, library)
.setSessionActivity(open)
.build()
.also { stopWatching = library.watchSession(it) }
}
override fun onGetSession(controllerInfo: MediaSession.ControllerInfo): MediaLibrarySession? = session
override fun onTaskRemoved(rootIntent: Intent?) {
val player = session?.player
if (player == null || !player.playWhenReady || player.mediaItemCount == 0) stopSelf()
}
override fun onDestroy() {
stopWatching?.invoke()
stopWatching = null
// 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.mobile.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.mobile.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,194 @@
// The app's frame: the full-screen sign-in states, and once signed in the top bar, the routed
// page, the mini player, the navigation bar, sheets and toasts.
package it.panov.musyx.mobile.ui
import androidx.activity.compose.BackHandler
import androidx.annotation.DrawableRes
import androidx.annotation.StringRes
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.slideInVertically
import androidx.compose.animation.slideOutVertically
import androidx.compose.foundation.background
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.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.statusBarsPadding
import androidx.compose.foundation.layout.systemBarsPadding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material3.IconButton
import androidx.compose.material3.NavigationBar
import androidx.compose.material3.NavigationBarItem
import androidx.compose.material3.NavigationBarItemDefaults
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.saveable.rememberSaveableStateHolder
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.mobile.R
import it.panov.musyx.mobile.ui.components.MusyxIcon
import it.panov.musyx.mobile.ui.screens.AlbumScreen
import it.panov.musyx.mobile.ui.screens.ArtistScreen
import it.panov.musyx.mobile.ui.screens.ChartScreen
import it.panov.musyx.mobile.ui.screens.CollectionScreen
import it.panov.musyx.mobile.ui.screens.GenreScreen
import it.panov.musyx.mobile.ui.screens.HoldingScreen
import it.panov.musyx.mobile.ui.screens.HomeScreen
import it.panov.musyx.mobile.ui.screens.MiniPlayer
import it.panov.musyx.mobile.ui.screens.NowPlayingScreen
import it.panov.musyx.mobile.ui.screens.PlaylistScreen
import it.panov.musyx.mobile.ui.screens.PodcastsScreen
import it.panov.musyx.mobile.ui.screens.SearchScreen
import it.panov.musyx.mobile.ui.screens.SettingsScreen
import it.panov.musyx.mobile.ui.screens.SheetHost
import it.panov.musyx.mobile.ui.screens.SignInScreen
import it.panov.musyx.mobile.ui.screens.ToastHost
import it.panov.musyx.mobile.ui.screens.UnreachableScreen
import it.panov.musyx.mobile.ui.screens.WaveScreen
import it.panov.musyx.mobile.ui.theme.MusyxTheme
import it.panov.musyx.state.AppState
import it.panov.musyx.state.Route
import it.panov.musyx.state.Session
private const val WORDMARK = "musyx"
@Composable
fun MusyxApp(state: AppState, onExit: () -> Unit) {
Box(Modifier.fillMaxSize().background(MusyxTheme.colors.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)
}
if (state.session !is Session.SignedIn) ToastHost(state, Modifier.systemBarsPadding())
}
}
/** A navigation bar 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),
)
@Composable
private fun Shell(state: AppState, onExit: () -> Unit) {
val route = state.nav.current
val pages = rememberSaveableStateHolder()
BackHandler { if (!state.back()) onExit() }
Scaffold(
containerColor = MusyxTheme.colors.bg,
topBar = { TopBar(state, route) },
bottomBar = {
Column {
if (state.playback.state.hasTrack) MiniPlayer(state)
NavBar(state.nav.section, state::navigate)
}
},
) { padding ->
Box(Modifier.fillMaxSize().padding(padding)) {
pages.SaveableStateProvider(route.toString()) { Page(state, route) }
ToastHost(state)
}
}
// Now Playing slides up over everything, bars included.
AnimatedVisibility(
route == Route.NowPlaying,
enter = slideInVertically { it },
exit = slideOutVertically { it },
) {
Box(Modifier.fillMaxSize().background(MusyxTheme.colors.bg).systemBarsPadding()) {
NowPlayingScreen(state, onClose = { state.back() })
ToastHost(state)
}
}
SheetHost(state)
}
@Composable
private fun Page(state: AppState, route: Route) {
when (route) {
Route.Home -> HomeScreen(state)
Route.Wave -> WaveScreen(state)
Route.Search -> SearchScreen(state)
Route.Collection -> CollectionScreen(state)
Route.Podcasts -> PodcastsScreen(state)
Route.Settings -> SettingsScreen(state)
// Drawn over the shell; the page underneath stays the one Now Playing was opened from.
Route.NowPlaying -> {}
Route.Chart -> ChartScreen(state)
is Route.Genre -> GenreScreen(state, route.index)
is Route.Album -> AlbumScreen(state, route)
is Route.Artist -> ArtistScreen(state, route)
is Route.Playlist -> PlaylistScreen(state, route)
}
}
/** Back on pages under a section, the wordmark on the sections themselves; Settings on the right. */
@Composable
private fun TopBar(state: AppState, route: Route) {
Row(
Modifier.fillMaxWidth().statusBarsPadding().height(56.dp).padding(horizontal = 4.dp),
verticalAlignment = Alignment.CenterVertically,
) {
if (route in Route.SECTIONS || !state.nav.canGoBack) {
Wordmark(Modifier.padding(start = MusyxTheme.space.gutter - 4.dp))
} else {
IconButton(onClick = { state.back() }) { MusyxIcon(R.drawable.ic_chevron_left) }
}
Spacer(Modifier.weight(1f))
if (route != Route.Settings) {
IconButton(onClick = { state.navigate(Route.Settings) }) { MusyxIcon(R.drawable.ic_settings, tint = MusyxTheme.colors.muted) }
}
}
}
@Composable
private fun NavBar(current: Route, onNavigate: (Route) -> Unit) {
val c = MusyxTheme.colors
NavigationBar(containerColor = c.panel) {
NAV.forEach { item ->
val selected = item.route == current
NavigationBarItem(
selected = selected,
onClick = { onNavigate(item.route) },
icon = { MusyxIcon(item.icon, tint = if (selected) c.accentInk else c.muted) },
label = { Text(stringResource(item.label), maxLines = 1) },
colors = NavigationBarItemDefaults.colors(
indicatorColor = c.accent,
selectedTextColor = c.fg,
unselectedTextColor = c.muted,
),
)
}
}
}
/** `musyx` and the amber dot. */
@Composable
fun Wordmark(modifier: Modifier = Modifier) {
val c = MusyxTheme.colors
val scale = MusyxTheme.type.scale
Row(modifier) {
Text(WORDMARK, style = MusyxTheme.type.wordmark, color = c.fg, modifier = Modifier.alignByBaseline())
Spacer(Modifier.width((3 * scale).dp))
// The dot sits on the baseline, as in the desktop sidebar.
Box(Modifier.alignBy { it.measuredHeight }.size((7 * scale).dp).background(c.accent, CircleShape))
}
}
@@ -0,0 +1,190 @@
// Covers, cards, shelves of cards and grids.
package it.panov.musyx.mobile.ui.components
import androidx.annotation.DrawableRes
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.combinedClickable
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.Spacer
import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.foundation.layout.fillMaxSize
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.lazy.LazyRow
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Icon
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
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.res.painterResource
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import coil3.compose.AsyncImage
import it.panov.musyx.mobile.R
import it.panov.musyx.mobile.ui.theme.CoverPlaceholder
import it.panov.musyx.mobile.ui.theme.DarkColors
import it.panov.musyx.mobile.ui.theme.MusyxTheme
/** Cover sizes asked of the image server. */
const val COVER_SMALL = 100
const val COVER_LARGE = 400
/** Cards in a shelf; grids work out their own width. */
val CardWidth = 144.dp
/** A Lucide icon from `res/drawable`, tinted. */
@Composable
fun MusyxIcon(@DrawableRes icon: Int, modifier: Modifier = Modifier, tint: Color = MusyxTheme.colors.fg, size: Dp = 22.dp) {
Icon(painterResource(icon), contentDescription = null, tint = tint, modifier = modifier.size(size))
}
/** 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())
}
}
}
@Composable
fun Thumb(url: String?, hues: Pair<Float, Float>, size: Dp, round: Boolean = false) {
Cover(url, hues, Modifier.size(size), if (round) CircleShape else RoundedCornerShape(MusyxTheme.radius.smallCover))
}
/** 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,
)
@OptIn(ExperimentalFoundationApi::class)
@Composable
fun MediaCard(card: CardData, modifier: Modifier = Modifier) {
val c = MusyxTheme.colors
val shape = if (card.round) CircleShape else RoundedCornerShape(MusyxTheme.radius.cover)
Column(
modifier
.clip(RoundedCornerShape(MusyxTheme.radius.cover))
.combinedClickable(onClick = card.onClick, onLongClick = card.onLongClick),
verticalArrangement = Arrangement.spacedBy(6.dp),
) {
Box(Modifier.fillMaxWidth().aspectRatio(1f)) {
Cover(card.cover, card.hues, Modifier.fillMaxSize(), shape)
card.badge?.let { badge ->
Text(
badge,
style = MusyxTheme.type.section,
color = Color.White,
modifier = Modifier
.align(Alignment.BottomStart)
.padding(8.dp)
.background(Color.Black.copy(alpha = 0.55f), RoundedCornerShape(MusyxTheme.radius.control))
.padding(horizontal = 8.dp, vertical = 2.dp),
)
}
if (card.playing) PlayingBadge(Modifier.align(Alignment.TopStart).padding(8.dp))
if (card.liked == true) {
MusyxIcon(R.drawable.ic_heart_fill, Modifier.align(Alignment.TopEnd).padding(8.dp), tint = c.like, size = 18.dp)
}
}
Column {
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(32.dp).background(Color.Black.copy(alpha = 0.6f), CircleShape), contentAlignment = Alignment.Center) {
MusyxIcon(R.drawable.ic_audio_lines, tint = DarkColors.accent, size = 18.dp)
}
}
/** A link at the end of a shelf's heading, such as "Show all 100". */
class ShelfMore(val label: String, val onClick: () -> Unit)
/** A heading over a row of cards that scrolls sideways. */
@Composable
fun CardShelf(title: String?, cards: List<CardData>, modifier: Modifier = Modifier, more: ShelfMore? = null) {
val space = MusyxTheme.space
Column(modifier, verticalArrangement = Arrangement.spacedBy(space.s)) {
if (title != null || more != null) {
Row(Modifier.fillMaxWidth().padding(start = space.gutter, end = space.xs), verticalAlignment = Alignment.CenterVertically) {
Box(Modifier.weight(1f)) { if (title != null) SectionTitle(title) }
if (more != null) TextButton(onClick = more.onClick) { Text(more.label, style = MusyxTheme.type.meta) }
}
}
LazyRow(
horizontalArrangement = Arrangement.spacedBy(space.m),
contentPadding = PaddingValues(horizontal = space.gutter),
) {
items(cards, key = { it.key }) { MediaCard(it, Modifier.width(CardWidth)) }
}
}
}
/** Cards wrapped into as many columns as fit, as one item of a page. */
@Composable
fun CardGrid(cards: List<CardData>, modifier: Modifier = Modifier) {
val space = MusyxTheme.space
BoxWithConstraints(modifier.fillMaxWidth().padding(horizontal = space.gutter)) {
val columns = ((maxWidth + space.m) / (CardWidth + space.m)).toInt().coerceAtLeast(2)
Column(verticalArrangement = Arrangement.spacedBy(space.l)) {
cards.chunked(columns).forEach { row ->
Row(horizontalArrangement = Arrangement.spacedBy(space.m)) {
row.forEach { MediaCard(it, Modifier.weight(1f)) }
repeat(columns - row.size) { Spacer(Modifier.weight(1f)) }
}
}
}
}
}
@Composable
fun SectionTitle(text: String, modifier: Modifier = Modifier) {
Text(text, style = MusyxTheme.type.section, color = MusyxTheme.colors.fg, modifier = modifier)
}
/** A page's own title, at the top of its column. */
@Composable
fun ScreenTitle(text: String) {
Text(
text,
style = MusyxTheme.type.displayS,
color = MusyxTheme.colors.fg,
modifier = Modifier.padding(horizontal = MusyxTheme.space.gutter, vertical = MusyxTheme.space.s),
)
}
@@ -0,0 +1,41 @@
// Loading text, failures with a retry button, empty states.
package it.panov.musyx.mobile.ui.components
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Button
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import it.panov.musyx.api.YmError
import it.panov.musyx.mobile.R
import it.panov.musyx.mobile.ui.theme.MusyxTheme
/** Muted running text inside the page 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.gutter, vertical = MusyxTheme.space.s),
)
}
/** A failure with a retry button. `what` is the object of "Couldn't load …", such as "your albums". */
@Composable
fun Failure(error: YmError, what: String, onRetry: () -> Unit) {
Column(
Modifier.padding(horizontal = MusyxTheme.space.gutter, vertical = MusyxTheme.space.s),
verticalArrangement = Arrangement.spacedBy(MusyxTheme.space.m),
) {
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,
)
Button(onClick = onRetry) { Text(stringResource(R.string.action_try_again)) }
}
}
@@ -0,0 +1,177 @@
// Track rows and the play bar above lists. A tap plays the list from the row; a long press or
// the "more" button opens the track's menu.
package it.panov.musyx.mobile.ui.components
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.combinedClickable
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.lazy.LazyListScope
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.material3.Button
import androidx.compose.material3.IconButton
import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.Text
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.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import it.panov.musyx.api.PlaylistId
import it.panov.musyx.api.Track
import it.panov.musyx.mobile.R
import it.panov.musyx.mobile.ui.artistsOrUnknown
import it.panov.musyx.mobile.ui.clock
import it.panov.musyx.mobile.ui.theme.MusyxTheme
import it.panov.musyx.mobile.ui.theme.tabular
import it.panov.musyx.state.AppState
import it.panov.musyx.state.PlaylistSlot
import it.panov.musyx.state.Sheet
/** Which parts a row shows: album pages drop the cover; artist pages show the album, not the artist. */
data class Columns(val cover: Boolean = true, val artist: Boolean = true) {
companion object {
val FULL = Columns()
val ALBUM_PAGE = Columns(cover = false)
val ARTIST_PAGE = Columns(artist = false)
}
}
/**
* The rows of a track list, as items of the page's lazy column. `shifts` adds chart
* movement; `playlist` adds edit actions to the menu, at `positions` on the server.
*/
fun LazyListScope.trackItems(
state: AppState,
tracks: List<Track>,
columns: Columns = Columns.FULL,
shifts: List<Int>? = null,
playlist: PlaylistId? = null,
positions: List<Int>? = 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)) }))
},
)
}
}
@OptIn(ExperimentalFoundationApi::class)
@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,
) {
val c = MusyxTheme.colors
val titleColor = when {
!track.available -> c.muted
playing -> c.accent
else -> c.fg
}
Row(
Modifier
.fillMaxWidth()
.combinedClickable(onClick = { if (track.available) onPlay() }, onLongClick = onMore)
.padding(start = MusyxTheme.space.gutter, end = 4.dp, top = 6.dp, bottom = 6.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(12.dp),
) {
if (columns.cover) {
Box(contentAlignment = Alignment.Center) {
Thumb(track.coverUrl(COVER_SMALL), track.hues, 48.dp)
if (playing) PlayingBadge()
}
} else {
Box(Modifier.width(28.dp), contentAlignment = Alignment.Center) {
if (playing) MusyxIcon(R.drawable.ic_audio_lines, tint = c.accent, size = 18.dp)
else Text("${index + 1}", style = MusyxTheme.type.meta.tabular(), color = c.muted)
}
}
if (shift != null) ShiftMarker(shift)
Column(Modifier.weight(1f)) {
Text(track.fullTitle, style = MusyxTheme.type.bodyMedium, color = titleColor, maxLines = 1, overflow = TextOverflow.Ellipsis)
val subtitle = listOfNotNull(
(if (columns.artist) track.artistsOrUnknown() else track.album?.title).takeIf { !it.isNullOrEmpty() },
clock(track.durationMs),
).joinToString(" · ")
Text(subtitle, style = MusyxTheme.type.meta, color = c.muted, maxLines = 1, overflow = TextOverflow.Ellipsis)
}
if (onLike != null) {
IconButton(onClick = onLike) {
MusyxIcon(if (liked) R.drawable.ic_heart_fill else R.drawable.ic_heart, tint = if (liked) c.like else c.muted, size = 20.dp)
}
}
IconButton(onClick = onMore) { MusyxIcon(R.drawable.ic_ellipsis, tint = c.muted, size = 20.dp) }
}
}
/** 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(14.dp), textAlign = TextAlign.Center)
}
/** Play and Shuffle, then any page actions (the heart), then a summary. */
@Composable
fun PlayBar(state: AppState, tracks: List<Track>, summary: String = "", actions: @Composable () -> Unit = {}) {
val space = MusyxTheme.space
Column(Modifier.fillMaxWidth().padding(horizontal = space.gutter), verticalArrangement = Arrangement.spacedBy(space.s)) {
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(space.s)) {
Button(onClick = { state.playTracks(tracks, 0) }, enabled = tracks.isNotEmpty()) {
MusyxIcon(R.drawable.ic_play_fill, tint = MusyxTheme.colors.accentInk, size = 18.dp)
Text(stringResource(R.string.action_play), modifier = Modifier.padding(start = 8.dp))
}
OutlinedButton(onClick = { state.playTracks(tracks, 0, shuffle = true) }, enabled = tracks.isNotEmpty()) {
MusyxIcon(R.drawable.ic_shuffle, size = 18.dp)
Text(stringResource(R.string.action_shuffle), modifier = Modifier.padding(start = 8.dp))
}
actions()
}
if (summary.isNotEmpty()) Text(summary, style = MusyxTheme.type.meta, color = MusyxTheme.colors.muted)
}
}
/** A round heart that adds or removes something from the collection. */
@Composable
fun LikeButton(liked: Boolean, onClick: () -> Unit) {
val c = MusyxTheme.colors
IconButton(onClick = onClick, modifier = Modifier.size(44.dp)) {
MusyxIcon(if (liked) R.drawable.ic_heart_fill else R.drawable.ic_heart, tint = if (liked) c.like else c.fg)
}
}
@@ -0,0 +1,259 @@
// Pieces several screens share: the page column, card builders, genre tiles, loading states.
package it.panov.musyx.mobile.ui.screens
import android.content.ActivityNotFoundException
import android.content.Context
import android.content.Intent
import androidx.annotation.StringRes
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
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.Spacer
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.items
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
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.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.core.net.toUri
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.mobile.R
import it.panov.musyx.mobile.ui.artistsOrUnknown
import it.panov.musyx.mobile.ui.clock
import it.panov.musyx.mobile.ui.components.COVER_LARGE
import it.panov.musyx.mobile.ui.components.CardData
import it.panov.musyx.mobile.ui.components.CardShelf
import it.panov.musyx.mobile.ui.components.CardWidth
import it.panov.musyx.mobile.ui.components.Failure
import it.panov.musyx.mobile.ui.components.Note
import it.panov.musyx.mobile.ui.components.SectionTitle
import it.panov.musyx.mobile.ui.components.ShelfMore
import it.panov.musyx.mobile.ui.subtitle
import it.panov.musyx.mobile.ui.theme.DarkColors
import it.panov.musyx.mobile.ui.theme.MusyxTheme
import it.panov.musyx.mobile.ui.theme.mix
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
/** A scrolling page: sections stacked with a small gap, room at the bottom for the mini player. */
@Composable
fun PageColumn(content: LazyListScope.() -> Unit) {
val space = MusyxTheme.space
LazyColumn(
state = rememberLazyListState(),
modifier = Modifier.fillMaxSize(),
contentPadding = PaddingValues(top = space.s, bottom = space.section),
verticalArrangement = Arrangement.spacedBy(space.s),
content = content,
)
}
/** Space between two sections of a page. */
fun LazyListScope.gap(key: Any) {
item(key = key) { Spacer(Modifier.height(MusyxTheme.space.section - MusyxTheme.space.s * 2)) }
}
/** 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: a tap plays `tracks` from it, a long press opens its menu. */
@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 or the Yandex Music app; 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))
} catch (_: ActivityNotFoundException) {
state.toast(UiText.Res(R.string.toast_no_browser))
}
}
/** A loading note, 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,
loaded: LazyListScope.(T) -> Unit,
) {
when (value) {
is Loadable.Loaded -> loaded(value.value)
is Loadable.Failed -> item(key = "$key-failed") { Failure(value.error, what(), retry) }
else -> item(key = "$key-loading") { Note(loading()) }
}
}
/** A shelf of cards as one item of a page. */
fun LazyListScope.shelf(
key: String,
@StringRes title: Int?,
cards: @Composable () -> List<CardData>,
more: (@Composable () -> ShelfMore)? = null,
) {
item(key = key) {
val list = cards()
if (list.isNotEmpty()) CardShelf(title?.let { stringResource(it) }, list, more = more?.invoke())
}
}
/** The top-level genres: a row on Home, or a grid on Search before anything is typed. */
fun LazyListScope.genreShelf(state: AppState, grid: Boolean = false) {
if (!grid) {
item(key = "genres-title") { SectionTitle(stringResource(R.string.section_genres), Modifier.padding(horizontal = MusyxTheme.space.gutter)) }
}
loadable(
"genres",
state.genres,
loading = { stringResource(R.string.loading_genres) },
what = { stringResource(R.string.what_genres) },
retry = state::loadGenres,
) { 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)) } })
} else {
LazyRow(
horizontalArrangement = Arrangement.spacedBy(MusyxTheme.space.m),
contentPadding = PaddingValues(horizontal = MusyxTheme.space.gutter),
) {
items(top, key = { it.value.id }) { (index, genre) ->
GenreTile(genre, { state.navigate(Route.Genre(index)) }, Modifier.width(CardWidth))
}
}
}
}
}
}
@Composable
fun GenreTile(genre: Genre, onClick: () -> Unit, modifier: Modifier = Modifier) {
// 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)
Box(
modifier
.height(72.dp)
.clip(shape)
.background(Brush.linearGradient(listOf(tint, mix(tint, Color.Black, 0.45f))))
.clickable(onClick = onClick)
.padding(horizontal = 14.dp),
contentAlignment = Alignment.CenterStart,
) {
Text(genre.title, style = MusyxTheme.type.bodyMedium, color = Color.White, maxLines = 2)
}
}
@Composable
private fun GenreGrid(genres: List<Pair<Genre, () -> Unit>>) {
val space = MusyxTheme.space
BoxWithConstraints(Modifier.fillMaxWidth().padding(horizontal = space.gutter)) {
val columns = ((maxWidth + space.m) / (CardWidth + space.m)).toInt().coerceAtLeast(2)
Column(verticalArrangement = Arrangement.spacedBy(space.m)) {
genres.chunked(columns).forEach { row ->
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(space.m)) {
row.forEach { (genre, open) -> GenreTile(genre, open, Modifier.weight(1f)) }
repeat(columns - row.size) { 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)
}
@@ -0,0 +1,250 @@
// Album, artist and playlist pages: a cover header, then tracks and shelves.
package it.panov.musyx.mobile.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.lazy.LazyListScope
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.DropdownMenu
import androidx.compose.material3.DropdownMenuItem
import androidx.compose.material3.IconButton
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
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.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
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.mobile.R
import it.panov.musyx.mobile.ui.components.COVER_LARGE
import it.panov.musyx.mobile.ui.components.Columns
import it.panov.musyx.mobile.ui.components.Cover
import it.panov.musyx.mobile.ui.components.Failure
import it.panov.musyx.mobile.ui.components.LikeButton
import it.panov.musyx.mobile.ui.components.MusyxIcon
import it.panov.musyx.mobile.ui.components.Note
import it.panov.musyx.mobile.ui.components.PlayBar
import it.panov.musyx.mobile.ui.components.SectionTitle
import it.panov.musyx.mobile.ui.components.trackItems
import it.panov.musyx.mobile.ui.counted
import it.panov.musyx.mobile.ui.durationWords
import it.panov.musyx.mobile.ui.kindLabel
import it.panov.musyx.mobile.ui.theme.MusyxTheme
import it.panov.musyx.mobile.ui.tracksWord
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
/** 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, 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) }
}
else -> item(key = "loading") { Note(stringResource(what.loading)) }
}
}
}
/** The cover centred over kind, title, byline and meta, then any actions. */
@Composable
private fun Head(
cover: String?,
hues: Pair<Float, Float>,
round: Boolean,
kind: String,
title: String,
by: String?,
meta: String,
onBy: (() -> Unit)? = null,
actions: (@Composable () -> Unit)? = null,
) {
val c = MusyxTheme.colors
Column(
Modifier.fillMaxWidth().padding(horizontal = MusyxTheme.space.gutter),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(6.dp),
) {
Cover(cover, hues, Modifier.size(220.dp).padding(bottom = 8.dp), if (round) CircleShape else RoundedCornerShape(MusyxTheme.radius.cover))
Text(kind, style = MusyxTheme.type.meta, color = c.muted, maxLines = 1)
Text(title, style = MusyxTheme.type.displayL, color = c.fg, maxLines = 3, overflow = TextOverflow.Ellipsis, textAlign = TextAlign.Center)
if (by != null) {
if (onBy != null) TextButton(onClick = onBy) { Text(by, style = MusyxTheme.type.bodyMedium, maxLines = 1) }
else Text(by, style = MusyxTheme.type.bodyMedium, color = c.fg, maxLines = 1)
}
if (meta.isNotEmpty()) Text(meta, style = MusyxTheme.type.meta, color = c.muted, maxLines = 2, textAlign = TextAlign.Center)
if (actions != null) Row(horizontalArrangement = Arrangement.spacedBy(MusyxTheme.space.s), verticalAlignment = Alignment.CenterVertically) { actions() }
}
}
@Composable
fun AlbumScreen(state: AppState, route: Route.Album) {
DetailPage(state, route, What(R.string.loading_album, R.string.gone_album, R.string.what_album)) { page ->
albumPage(state, (page as Page.OfAlbum).info)
}
}
private fun LazyListScope.albumPage(state: AppState, info: AlbumPage) {
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(" · "),
onBy = artist?.let { { state.navigate(Route.Artist(it.id!!)) } },
)
}
item(key = "play") {
val liked = a.id in state.likes.albums
PlayBar(state, info.tracks) { LikeButton(liked) { state.likeAlbum(a.id, !liked) } }
}
trackItems(state, info.tracks, Columns.ALBUM_PAGE, keyPrefix = "album")
}
@Composable
fun ArtistScreen(state: AppState, route: Route.Artist) {
DetailPage(state, route, What(R.string.loading_artist, R.string.gone_artist, R.string.what_artist)) { page ->
artistPage(state, (page as Page.OfArtist).info)
}
}
private fun LazyListScope.artistPage(state: AppState, info: ArtistPage) {
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
Head(
a.coverUrl(COVER_LARGE), a.hues, true, kind, a.name, null, meta,
actions = if (info.popular.isEmpty()) ({ LikeButton(liked) { state.likeArtist(a.id, !liked) } }) else null,
)
}
if (info.popular.isNotEmpty()) {
gap("popular-gap")
item(key = "popular-title") { SectionTitle(stringResource(R.string.section_popular), Modifier.padding(horizontal = MusyxTheme.space.gutter)) }
item(key = "play") {
val liked = a.id in state.likes.artists
PlayBar(state, info.popular) { 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) {
DetailPage(state, route, What(R.string.loading_playlist, R.string.gone_playlist, R.string.what_playlist)) { page ->
playlistPage(state, (page as Page.OfPlaylist).info)
}
}
private fun LazyListScope.playlistPage(state: AppState, info: PlaylistPage) {
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,
actions = if (likeHere) ({ val liked = p.id in state.likes.playlists; LikeButton(liked) { state.likePlaylist(p.id, !liked) } }) else null,
)
}
info.description?.let { d ->
item(key = "description") {
Text(
d,
style = MusyxTheme.type.meta,
color = MusyxTheme.colors.muted,
maxLines = 4,
overflow = TextOverflow.Ellipsis,
modifier = Modifier.padding(horizontal = MusyxTheme.space.gutter),
)
}
}
if (info.tracks.isEmpty()) {
if (own) item(key = "own-actions") { Row(Modifier.padding(horizontal = MusyxTheme.space.gutter)) { OwnPlaylistMenu(state, p) } }
item(key = "empty") { Note(stringResource(R.string.playlist_empty)) }
return
}
item(key = "play") {
PlayBar(state, info.tracks) {
if (own) {
OwnPlaylistMenu(state, p)
} else {
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, behind a "more" button. */
@Composable
private fun OwnPlaylistMenu(state: AppState, p: PlaylistSummary) {
var open by remember { mutableStateOf(false) }
IconButton(onClick = { open = true }) { MusyxIcon(R.drawable.ic_ellipsis) }
DropdownMenu(expanded = open, onDismissRequest = { open = false }) {
DropdownMenuItem(
text = { Text(stringResource(R.string.action_rename)) },
leadingIcon = { MusyxIcon(R.drawable.ic_pencil, size = 18.dp) },
onClick = { open = false; state.openSheet(Sheet.Rename(p.id, p.title)) },
)
DropdownMenuItem(
text = { Text(stringResource(if (p.public) R.string.action_make_private else R.string.action_make_public)) },
leadingIcon = { MusyxIcon(if (p.public) R.drawable.ic_lock else R.drawable.ic_globe, size = 18.dp) },
onClick = { open = false; state.setPlaylistPublic(p.id, !p.public) },
)
DropdownMenuItem(
text = { Text(stringResource(R.string.action_delete), color = MusyxTheme.colors.like) },
leadingIcon = { MusyxIcon(R.drawable.ic_trash_2, tint = MusyxTheme.colors.like, size = 18.dp) },
onClick = { open = false; state.openSheet(Sheet.ConfirmDelete(p.id, p.title)) },
)
}
}
@@ -0,0 +1,313 @@
// Home and My Wave: the animated hero, the picks, station settings and other stations.
package it.panov.musyx.mobile.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.layout.ExperimentalLayoutApi
import androidx.compose.foundation.layout.FlowRow
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
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.lazy.LazyRow
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Button
import androidx.compose.material3.FilterChip
import androidx.compose.material3.Text
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.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import coil3.compose.AsyncImage
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.mobile.R
import it.panov.musyx.mobile.ui.components.CardWidth
import it.panov.musyx.mobile.ui.components.MusyxIcon
import it.panov.musyx.mobile.ui.components.Note
import it.panov.musyx.mobile.ui.components.PlayingBadge
import it.panov.musyx.mobile.ui.components.SectionTitle
import it.panov.musyx.mobile.ui.components.ShelfMore
import it.panov.musyx.mobile.ui.theme.MusyxTheme
import it.panov.musyx.mobile.ui.theme.mix
import it.panov.musyx.player.Status
import it.panov.musyx.state.AppState
import it.panov.musyx.state.Route
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) {
PageColumn {
item(key = "hero") { WaveHero(state, big = false) }
// 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,
) { 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)
}
}
/** The My Wave hero, on Home (`big = false`) and the My Wave screen. */
@Composable
fun WaveHero(state: AppState, big: Boolean) {
val c = MusyxTheme.colors
val space = MusyxTheme.space
val status = state.playback.state.takeIf { it.waveStation == MY_WAVE }?.status
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.gutter)
.fillMaxWidth()
.height(if (big) 220.dp else 180.dp)
.clip(shape)
.background(Brush.horizontalGradient(listOf(c.panel, mix(c.panel, c.accent, 0.10f)))),
) {
WaveArt(playing, Modifier.fillMaxSize())
Column(
Modifier.align(Alignment.BottomStart).fillMaxWidth().padding(20.dp),
verticalArrangement = Arrangement.spacedBy(6.dp),
) {
Text(stringResource(R.string.nav_wave), style = if (big) MusyxTheme.type.displayL else MusyxTheme.type.displayM, color = c.fg)
Text(blurb, style = MusyxTheme.type.meta, color = c.muted, maxLines = 2, overflow = TextOverflow.Ellipsis)
Button(onClick = action, modifier = Modifier.padding(top = 6.dp)) {
MusyxIcon(icon, tint = c.accentInk, size = 18.dp)
Text(stringResource(label), modifier = Modifier.padding(start = 8.dp))
}
}
}
}
/** 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.18f + kf * 0.024f)
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) {
val space = MusyxTheme.space
PageColumn {
item(key = "hero") { WaveHero(state, big = true) }
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,
) {}
}
gap("stations-gap")
item(key = "stations-title") { SectionTitle(stringResource(R.string.section_stations), Modifier.padding(horizontal = space.gutter)) }
loadable(
"stations",
state.stations,
loading = { stringResource(R.string.loading_stations) },
what = { stringResource(R.string.what_stations) },
retry = state::loadWave,
) { 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") {
LazyRow(horizontalArrangement = Arrangement.spacedBy(space.m), contentPadding = PaddingValues(horizontal = space.gutter)) {
items(others, key = { it.id }) { s ->
StationTile(s, playing = state.playback.state.waveStation == s.id) { state.playWave(s.id) }
}
}
}
}
}
}
}
@OptIn(ExperimentalLayoutApi::class)
@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.gutter, vertical = space.xs), verticalArrangement = Arrangement.spacedBy(space.xs)) {
Text(title, style = MusyxTheme.type.bodyMedium, color = MusyxTheme.colors.muted)
FlowRow(horizontalArrangement = Arrangement.spacedBy(space.s)) {
options.forEach { (label, on, next) ->
FilterChip(selected = on, onClick = { if (!on && !saving) pick(next) }, label = { Text(label) })
}
}
}
}
@Composable
private fun StationTile(station: Station, playing: Boolean, onClick: () -> Unit) {
val c = MusyxTheme.colors
val tint = station.color?.let(::parseHex) ?: c.raised
val shape = RoundedCornerShape(MusyxTheme.radius.cover)
Column(Modifier.width(CardWidth).clickable(onClick = onClick), verticalArrangement = Arrangement.spacedBy(6.dp)) {
Box(Modifier.size(CardWidth).clip(shape).background(tint), contentAlignment = Alignment.Center) {
val icon = station.iconUrl(200)
if (icon != null) AsyncImage(model = icon, contentDescription = null, modifier = Modifier.size(80.dp))
if (playing) PlayingBadge(Modifier.align(Alignment.TopStart).padding(8.dp))
}
Row { Text(station.name, style = MusyxTheme.type.bodyMedium, color = c.fg, maxLines = 1, overflow = TextOverflow.Ellipsis) }
}
}
@@ -0,0 +1,227 @@
// Collection, the chart, genres and podcasts.
package it.panov.musyx.mobile.ui.screens
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.ExperimentalLayoutApi
import androidx.compose.foundation.layout.FlowRow
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.AssistChip
import androidx.compose.material3.Button
import androidx.compose.material3.PrimaryScrollableTabRow
import androidx.compose.material3.Tab
import androidx.compose.material3.Text
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.mobile.R
import it.panov.musyx.mobile.ui.components.CardGrid
import it.panov.musyx.mobile.ui.components.Failure
import it.panov.musyx.mobile.ui.components.MusyxIcon
import it.panov.musyx.mobile.ui.components.Note
import it.panov.musyx.mobile.ui.components.PlayBar
import it.panov.musyx.mobile.ui.components.ScreenTitle
import it.panov.musyx.mobile.ui.components.trackItems
import it.panov.musyx.mobile.ui.durationWords
import it.panov.musyx.mobile.ui.theme.MusyxTheme
import it.panov.musyx.mobile.ui.tracksWord
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.state.Sheet
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) {
PageColumn {
item(key = "title") { ScreenTitle(stringResource(R.string.nav_collection)) }
item(key = "tabs") {
val tabs = CollectionTab.entries
PrimaryScrollableTabRow(selectedTabIndex = tabs.indexOf(state.collectionTab), edgePadding = MusyxTheme.space.gutter) {
tabs.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
}
val label = stringResource(tabLabel(tab))
Tab(
selected = tab == state.collectionTab,
onClick = { state.selectTab(tab) },
text = { Text(if (count != null) "$label $count" else label, maxLines = 1) },
)
}
}
}
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) },
) { 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) },
) { 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) },
) { p ->
item(key = "new") {
Box(Modifier.padding(horizontal = MusyxTheme.space.gutter)) {
AssistChip(
onClick = { state.openSheet(Sheet.NewPlaylist(null)) },
label = { Text(stringResource(R.string.action_new_playlist)) },
leadingIcon = { MusyxIcon(R.drawable.ic_plus, size = 18.dp) },
)
}
}
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) },
) { clips ->
item(key = "grid") {
if (clips.isEmpty()) Note(stringResource(R.string.empty_clips))
else CardGrid(clips.map { clipCard(state, it) })
}
}
}
}
}
@Composable
fun ChartScreen(state: AppState) {
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,
) { 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)) }
trackItems(state, tracks, shifts = home.chart.map { it.shift }, keyPrefix = "chart")
}
}
}
@OptIn(ExperimentalLayoutApi::class)
@Composable
fun GenreScreen(state: AppState, index: Int) {
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") { ScreenTitle(genre.title) }
item(key = "radio") {
Row(Modifier.fillMaxWidth().padding(horizontal = space.gutter), verticalAlignment = Alignment.CenterVertically) {
Button(onClick = { state.playWave("genre:${genre.id}") }) {
MusyxIcon(R.drawable.ic_audio_lines, tint = MusyxTheme.colors.accentInk, size = 18.dp)
Text(stringResource(R.string.action_play_radio), modifier = Modifier.padding(start = 8.dp))
}
}
}
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") {
FlowRow(Modifier.padding(horizontal = space.gutter), horizontalArrangement = Arrangement.spacedBy(space.s)) {
subs.forEach { (i, s) -> AssistChip(onClick = { state.navigate(Route.Genre(i)) }, label = { Text(s.title) }) }
}
}
}
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) },
) { 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) {
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) } })
gap("featured-gap")
}
loadable(
"featured", state.podcasts,
loading = { stringResource(R.string.loading_podcasts) },
what = { stringResource(R.string.what_podcasts) },
retry = state::loadPodcasts,
) { list ->
item(key = "featured-grid") { CardGrid(list.map { albumCard(state, it) }) }
}
}
}
@@ -0,0 +1,407 @@
// Now Playing: the cover over a blurred copy of itself, what's playing, the seek bar and the
// transport. The queue and the lyrics take the cover's place on request. Also the mini player
// that sits above the navigation bar on every other screen.
package it.panov.musyx.mobile.ui.screens
import android.os.Build
import androidx.activity.compose.BackHandler
import androidx.annotation.DrawableRes
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
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.Spacer
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.widthIn
import androidx.compose.foundation.lazy.LazyColumn
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.material3.FilledIconButton
import androidx.compose.material3.IconButton
import androidx.compose.material3.IconButtonDefaults
import androidx.compose.material3.Slider
import androidx.compose.material3.SliderDefaults
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
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.draw.blur
import androidx.compose.ui.draw.shadow
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.layout.ContentScale
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 coil3.compose.AsyncImage
import it.panov.musyx.api.LyricsSource
import it.panov.musyx.api.Lyrics
import it.panov.musyx.api.Track
import it.panov.musyx.mobile.R
import it.panov.musyx.mobile.ui.artistsOrUnknown
import it.panov.musyx.mobile.ui.clock
import it.panov.musyx.mobile.ui.components.COVER_LARGE
import it.panov.musyx.mobile.ui.components.COVER_SMALL
import it.panov.musyx.mobile.ui.components.Cover
import it.panov.musyx.mobile.ui.components.MusyxIcon
import it.panov.musyx.mobile.ui.components.Thumb
import it.panov.musyx.mobile.ui.theme.MusyxTheme
import it.panov.musyx.mobile.ui.theme.tabular
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
/** 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)
}
private enum class Panel { Queue, Lyrics }
@Composable
fun NowPlayingScreen(state: AppState, onClose: () -> Unit) {
val p = state.playback.state
val c = MusyxTheme.colors
val space = MusyxTheme.space
val track = p.track
var panel by rememberSaveable { mutableStateOf<Panel?>(null) }
BackHandler(enabled = panel != null) { panel = null }
Box(Modifier.fillMaxSize().background(c.bg)) {
track?.let { Backdrop(it) }
Column(Modifier.fillMaxSize().padding(horizontal = space.gutter)) {
Row(Modifier.fillMaxWidth().padding(vertical = space.xs), verticalAlignment = Alignment.CenterVertically) {
IconButton(onClick = onClose) { MusyxIcon(R.drawable.ic_chevron_left) }
Spacer(Modifier.weight(1f))
PanelToggle(R.drawable.ic_list_music, panel == Panel.Queue) { panel = if (panel == Panel.Queue) null else Panel.Queue }
PanelToggle(R.drawable.ic_mic_vocal, panel == Panel.Lyrics) { panel = if (panel == Panel.Lyrics) null else Panel.Lyrics }
}
if (track == null) {
Column(Modifier.weight(1f).padding(top = space.section), 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@Column
}
Box(Modifier.weight(1f).fillMaxWidth(), contentAlignment = Alignment.Center) {
when (panel) {
null -> Cover(
track.coverUrl(COVER_LARGE),
track.hues,
Modifier
.widthIn(max = 420.dp)
.fillMaxWidth()
.aspectRatio(1f)
.shadow(24.dp, RoundedCornerShape(MusyxTheme.radius.cover), clip = false),
RoundedCornerShape(MusyxTheme.radius.cover),
)
Panel.Queue -> QueueList(state, p)
Panel.Lyrics -> LyricsPanel(state, track)
}
}
TrackInfo(state, p, track)
SeekBar(state, p)
Transport(state, p)
Spacer(Modifier.height(space.l))
}
}
}
/** The cover again, blurred across the whole screen 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(80.dp) else Modifier),
)
Box(
Modifier.fillMaxSize().background(
Brush.verticalGradient(
0f to c.bg.copy(alpha = if (blurs) 0.55f else 0.9f),
1f to c.bg.copy(alpha = if (blurs) 0.92f else 0.96f),
),
),
)
}
@Composable
private fun PanelToggle(@DrawableRes icon: Int, on: Boolean, onClick: () -> Unit) {
val c = MusyxTheme.colors
IconButton(
onClick = onClick,
colors = IconButtonDefaults.iconButtonColors(containerColor = if (on) c.raised else androidx.compose.ui.graphics.Color.Transparent),
) { MusyxIcon(icon, tint = if (on) c.accent else c.fg) }
}
/** Quality, title, artist and album, the notice when there is one, and the heart and menu. */
@Composable
private fun TrackInfo(state: AppState, p: PlaybackState, track: Track) {
val c = MusyxTheme.colors
val liked = state.liked.contains(track.id)
Row(Modifier.fillMaxWidth().padding(top = MusyxTheme.space.l), verticalAlignment = Alignment.CenterVertically) {
Column(Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(4.dp)) {
p.stream?.let { s ->
Text(
if (s.preview) stringResource(R.string.badge_preview) else s.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 = 6.dp, vertical = 1.dp),
)
}
Text(track.fullTitle, style = MusyxTheme.type.displayS, color = c.fg, maxLines = 2, overflow = TextOverflow.Ellipsis)
val artist = track.artists.firstOrNull { it.id != null }
Text(
track.artistsOrUnknown(),
style = MusyxTheme.type.body,
color = c.muted,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
modifier = if (artist != null) Modifier.clickable { state.navigate(Route.Artist(artist.id!!)) } else Modifier,
)
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)
}
}
IconButton(onClick = { state.likeTrack(track, !liked) }) {
MusyxIcon(if (liked) R.drawable.ic_heart_fill else R.drawable.ic_heart, tint = if (liked) c.like else c.fg)
}
IconButton(onClick = { state.openSheet(Sheet.TrackMenu(track)) }) { MusyxIcon(R.drawable.ic_ellipsis) }
}
}
/** Position and length around a slider; the track seeks when the thumb is let go. */
@Composable
private fun SeekBar(state: AppState, p: PlaybackState) {
val c = MusyxTheme.colors
var dragging by remember { mutableStateOf<Float?>(null) }
val position = state.playback.positionMs.coerceAtMost(p.durationMs)
val fraction = dragging ?: if (p.durationMs > 0) position.toFloat() / p.durationMs else 0f
Column(Modifier.fillMaxWidth().padding(top = MusyxTheme.space.s)) {
Slider(
value = fraction.coerceIn(0f, 1f),
onValueChange = { dragging = it },
onValueChangeFinished = {
dragging?.let { state.playback.seek((it * p.durationMs).toLong()) }
dragging = null
},
enabled = p.durationMs > 0,
colors = SliderDefaults.colors(thumbColor = c.accent, activeTrackColor = c.accent, inactiveTrackColor = c.fg.copy(alpha = 0.18f)),
)
Row(Modifier.fillMaxWidth()) {
val shown = dragging?.let { (it * p.durationMs).toLong() } ?: position
Text(clock(shown), style = MusyxTheme.type.small.tabular(), color = c.muted)
Spacer(Modifier.weight(1f))
Text(clock(p.durationMs), style = MusyxTheme.type.small.tabular(), color = c.muted)
}
}
}
@Composable
private fun Transport(state: AppState, p: PlaybackState) {
val c = MusyxTheme.colors
val playback = state.playback
val playing = p.status == Status.Playing || p.status == Status.Loading
Row(
Modifier.fillMaxWidth().padding(top = MusyxTheme.space.s),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceEvenly,
) {
// A station decides its own order.
Toggle(R.drawable.ic_shuffle, on = p.shuffle, onClick = playback::toggleShuffle, enabled = p.waveStation == null)
IconButton(onClick = playback::previous, modifier = Modifier.size(56.dp)) { MusyxIcon(R.drawable.ic_skip_back, size = 28.dp) }
FilledIconButton(
onClick = playback::toggle,
modifier = Modifier.size(72.dp),
colors = IconButtonDefaults.filledIconButtonColors(containerColor = c.accent, contentColor = c.accentInk),
) {
MusyxIcon(if (playing) R.drawable.ic_pause_fill else R.drawable.ic_play_fill, tint = c.accentInk, size = 32.dp)
}
IconButton(onClick = playback::next, modifier = Modifier.size(56.dp)) { MusyxIcon(R.drawable.ic_skip_forward, size = 28.dp) }
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: amber with a dot under it when on, faded only when it can't be used. */
@Composable
private fun Toggle(@DrawableRes icon: Int, on: Boolean, onClick: () -> Unit, enabled: Boolean = true) {
val c = MusyxTheme.colors
Box(contentAlignment = Alignment.BottomCenter) {
IconButton(onClick = onClick, enabled = enabled) {
MusyxIcon(icon, tint = if (!enabled) c.muted.copy(alpha = 0.5f) else if (on) c.accent else c.fg)
}
if (on && enabled) Box(Modifier.padding(bottom = 2.dp).size(4.dp).background(c.accent, CircleShape))
}
}
@Composable
private fun QueueList(state: AppState, p: PlaybackState) {
val track = p.track ?: return
LazyColumn(Modifier.fillMaxSize(), contentPadding = PaddingValues(vertical = 8.dp)) {
item(key = "now") { Heading(stringResource(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)) }
}
}
}
@Composable
private fun Heading(text: String) {
Text(text, style = MusyxTheme.type.small, color = MusyxTheme.colors.muted, modifier = Modifier.padding(top = 12.dp, bottom = 6.dp))
}
@Composable
private fun QueueItem(track: Track, now: Boolean, onClick: (() -> Unit)?) {
val c = MusyxTheme.colors
Row(
Modifier
.fillMaxWidth()
.then(if (onClick != null) Modifier.clickable(onClick = onClick) else Modifier)
.padding(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.bodyMedium, color = if (now) c.accent else c.fg, maxLines = 1, overflow = TextOverflow.Ellipsis)
Text(track.artistsOrUnknown(), style = MusyxTheme.type.meta, color = c.muted, maxLines = 1, overflow = TextOverflow.Ellipsis)
}
Text(clock(track.durationMs), style = MusyxTheme.type.small.tabular(), color = c.muted)
}
}
@Composable
private fun LyricsPanel(state: AppState, track: Track) {
val c = MusyxTheme.colors
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(verticalArrangement = Arrangement.spacedBy(12.dp), horizontalAlignment = Alignment.CenterHorizontally) {
Text(stringResource(R.string.lyrics_failed), style = MusyxTheme.type.meta, color = c.muted)
TextButton(onClick = { state.retryLyrics(track) }) { Text(stringResource(R.string.action_try_again)) }
}
else -> PanelNote(stringResource(R.string.lyrics_loading))
}
}
@Composable
private fun PanelNote(text: String) {
Text(text, style = MusyxTheme.type.body, color = MusyxTheme.colors.muted)
}
/** Synced lyrics follow the song and seek on a tap; 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(Modifier.fillMaxSize(), state = list, contentPadding = PaddingValues(vertical = 8.dp)) {
itemsIndexed(lyrics.lines) { i, line ->
val (color, style) = when {
current == i -> c.fg to MusyxTheme.type.section
current != null && i < current -> c.muted.copy(alpha = 0.6f) to MusyxTheme.type.body
lyrics.synced -> c.muted to MusyxTheme.type.body
else -> c.fg to MusyxTheme.type.body
}
val at = line.atMs
Text(
line.text.ifEmpty { "♪" },
style = style,
color = color,
modifier = Modifier
.fillMaxWidth()
.then(if (at != null) Modifier.clickable { state.playback.seek(at) } else Modifier)
.padding(vertical = 6.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(top = 12.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(top = 8.dp))
}
}
}
}
/** The bar above the navigation: what's playing, play/pause and next. A tap opens Now Playing. */
@Composable
fun MiniPlayer(state: AppState) {
val p = state.playback.state
val track = p.track ?: return
val c = MusyxTheme.colors
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).clickable { state.navigate(Route.NowPlaying) }) {
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(start = MusyxTheme.space.gutter, end = 4.dp, top = 6.dp, bottom = 6.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(12.dp),
) {
Thumb(track.coverUrl(COVER_SMALL), track.hues, 40.dp)
Column(Modifier.weight(1f)) {
Text(track.fullTitle, style = MusyxTheme.type.bodyMedium, color = 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) c.like else c.muted,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
}
IconButton(onClick = state.playback::toggle) { MusyxIcon(if (playing) R.drawable.ic_pause_fill else R.drawable.ic_play_fill) }
IconButton(onClick = state.playback::next) { MusyxIcon(R.drawable.ic_skip_forward) }
}
}
}
@@ -0,0 +1,234 @@
// Search: a field, suggestions while typing, results by kind, more on request. With no query
// it shows genres to browse.
package it.panov.musyx.mobile.ui.screens
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
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.lazy.items
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material3.IconButton
import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.PrimaryScrollableTabRow
import androidx.compose.material3.Tab
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import it.panov.musyx.api.BestMatch
import it.panov.musyx.api.SearchKind
import it.panov.musyx.mobile.R
import it.panov.musyx.mobile.ui.artistsOrUnknown
import it.panov.musyx.mobile.ui.compact
import it.panov.musyx.mobile.ui.components.COVER_LARGE
import it.panov.musyx.mobile.ui.components.CardGrid
import it.panov.musyx.mobile.ui.components.Cover
import it.panov.musyx.mobile.ui.components.MusyxIcon
import it.panov.musyx.mobile.ui.components.Note
import it.panov.musyx.mobile.ui.components.PlayBar
import it.panov.musyx.mobile.ui.components.ScreenTitle
import it.panov.musyx.mobile.ui.components.SectionTitle
import it.panov.musyx.mobile.ui.components.trackItems
import it.panov.musyx.mobile.ui.isRussian
import it.panov.musyx.mobile.ui.kindLabel
import it.panov.musyx.mobile.ui.theme.MusyxTheme
import it.panov.musyx.state.ALL_TAB_TRACKS
import it.panov.musyx.state.AppState
import it.panov.musyx.state.Route
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) {
val search = state.search
val space = MusyxTheme.space
val focus = LocalFocusManager.current
PageColumn {
item(key = "field") {
OutlinedTextField(
value = search.text,
onValueChange = search::change,
placeholder = { Text(stringResource(R.string.search_placeholder)) },
leadingIcon = { MusyxIcon(R.drawable.ic_search, tint = MusyxTheme.colors.muted) },
trailingIcon = if (search.text.isNotEmpty()) ({
IconButton(onClick = search::clear) { MusyxIcon(R.drawable.ic_x, tint = MusyxTheme.colors.muted) }
}) else null,
singleLine = true,
shape = RoundedCornerShape(MusyxTheme.radius.pill),
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Search),
keyboardActions = KeyboardActions(onSearch = {
focus.clearFocus()
search.submit()
}),
modifier = Modifier.fillMaxWidth().padding(horizontal = space.gutter),
)
}
items(search.suggestions, key = { "s$it" }) { s ->
Row(
Modifier
.fillMaxWidth()
.clickable {
focus.clearFocus()
search.pick(s)
}
.padding(horizontal = space.gutter + 4.dp, vertical = 10.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(12.dp),
) {
MusyxIcon(R.drawable.ic_search, tint = MusyxTheme.colors.muted, size = 18.dp)
Text(s, style = MusyxTheme.type.body, color = MusyxTheme.colors.fg)
}
}
if (search.query.isEmpty()) {
item(key = "browse") { ScreenTitle(stringResource(R.string.search_browse)) }
genreShelf(state, grid = true)
return@PageColumn
}
search.results.get()?.data?.corrected?.let { corrected ->
item(key = "corrected") { Note(stringResource(R.string.search_corrected, corrected)) }
}
item(key = "tabs") {
val russian = isRussian()
val kinds = SearchKind.entries
PrimaryScrollableTabRow(selectedTabIndex = kinds.indexOf(search.kind), edgePadding = space.gutter) {
kinds.forEach { kind ->
val total = search.results.get()?.data?.totals?.get(kind)?.takeIf { it > 0 }
val label = stringResource(searchKindLabel(kind))
Tab(
selected = kind == search.kind,
onClick = { search.tab(kind) },
text = { Text(if (total != null) "$label ${compact(total.toLong(), russian)}" else label, maxLines = 1) },
)
}
}
}
loadable(
"results",
search.results,
loading = { stringResource(R.string.searching) },
what = { stringResource(R.string.what_results) },
retry = search::retry,
) { 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()) {
item(key = "tracks-title") { SectionTitle(stringResource(R.string.search_tracks), Modifier.padding(horizontal = space.gutter, vertical = space.xs)) }
trackItems(state, d.tracks.take(ALL_TAB_TRACKS), keyPrefix = "top")
item(key = "tracks-all") {
TextButton(onClick = { search.tab(SearchKind.Tracks) }, modifier = Modifier.padding(horizontal = space.s)) {
Text(stringResource(R.string.search_show_all_tracks))
}
}
}
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.gutter, vertical = space.l)) {
OutlinedButton(onClick = search::more, enabled = !r.loadingMore) {
Text(stringResource(if (r.loadingMore) R.string.loading else R.string.action_show_more))
}
}
}
}
}
}
}
/** 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
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) }
}
val shape = RoundedCornerShape(MusyxTheme.radius.card)
Row(
Modifier
.padding(horizontal = MusyxTheme.space.gutter)
.fillMaxWidth()
.clip(shape)
.background(c.panel)
.clickable(onClick = shown.go)
.padding(14.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(14.dp),
) {
Cover(shown.cover, shown.hues, Modifier.size(80.dp), if (shown.round) CircleShape else RoundedCornerShape(MusyxTheme.radius.cover))
Column(Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(2.dp)) {
Text(stringResource(R.string.search_top_result), style = MusyxTheme.type.small, color = c.muted)
Text(shown.title, style = MusyxTheme.type.section, color = c.fg, maxLines = 2, overflow = TextOverflow.Ellipsis)
Text(shown.kind, style = MusyxTheme.type.meta, color = c.muted, maxLines = 1, overflow = TextOverflow.Ellipsis)
}
MusyxIcon(if (best is BestMatch.OfTrack) R.drawable.ic_play_fill else R.drawable.ic_chevron_right, tint = c.accent)
}
}
@@ -0,0 +1,205 @@
// The full-screen states outside a session: checking, unreachable, and sign-in. On the phone
// the device code is confirmed in the browser right here, so there's no QR to scan.
package it.panov.musyx.mobile.ui.screens
import android.content.ActivityNotFoundException
import android.content.ClipData
import android.content.Intent
import android.os.SystemClock
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.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.imePadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.systemBarsPadding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Button
import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.produceState
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.ClipEntry
import androidx.compose.ui.platform.LocalClipboard
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.text.input.PasswordVisualTransformation
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.em
import androidx.core.net.toUri
import it.panov.musyx.mobile.R
import it.panov.musyx.mobile.ui.Wordmark
import it.panov.musyx.mobile.ui.components.MusyxIcon
import it.panov.musyx.mobile.ui.text
import it.panov.musyx.mobile.ui.theme.MusyxTheme
import it.panov.musyx.state.AppState
import it.panov.musyx.state.SignInState
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
/** 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) {
Column(
Modifier.fillMaxSize().padding(horizontal = MusyxTheme.space.gutter * 2),
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, textAlign = TextAlign.Center)
Text(stringResource(R.string.unreachable_body), style = MusyxTheme.type.body, color = MusyxTheme.colors.muted, textAlign = TextAlign.Center)
Row(horizontalArrangement = Arrangement.spacedBy(MusyxTheme.space.m)) {
Button(onClick = state::restore) { Text(stringResource(R.string.action_try_again)) }
OutlinedButton(onClick = state::signOut) { Text(stringResource(R.string.action_sign_out)) }
}
}
}
@Composable
fun SignInScreen(signIn: SignInState) {
val c = MusyxTheme.colors
val space = MusyxTheme.space
Column(
Modifier
.fillMaxSize()
.systemBarsPadding()
.imePadding()
.verticalScroll(rememberScrollState())
.padding(horizontal = space.gutter + 8.dp, vertical = space.section),
verticalArrangement = Arrangement.spacedBy(space.l),
) {
Wordmark()
Spacer(Modifier.height(space.s))
Text(stringResource(R.string.signin_title), style = MusyxTheme.type.displayM, color = c.fg)
Text(stringResource(R.string.signin_blurb), style = MusyxTheme.type.body, color = c.muted)
when (val stage = signIn.stage) {
SignInState.Stage.Idle -> Button(onClick = signIn::getCode, modifier = Modifier.fillMaxWidth()) {
Text(stringResource(R.string.signin_get_code))
}
SignInState.Stage.Requesting -> Button(onClick = {}, enabled = false, modifier = Modifier.fillMaxWidth()) {
Text(stringResource(R.string.signin_getting_code))
}
is SignInState.Stage.Waiting -> CodeCard(signIn, stage)
}
signIn.error?.let { Text(text(it), style = MusyxTheme.type.meta, color = c.like) }
if (signIn.stage !is SignInState.Stage.Waiting) TokenFallback(signIn)
Text(stringResource(R.string.signin_footer), style = MusyxTheme.type.small, color = c.muted)
}
}
/** The code, a button that opens Yandex's page for it, and the time left. */
@Composable
private fun CodeCard(signIn: SignInState, stage: SignInState.Stage.Waiting) {
val c = MusyxTheme.colors
val context = LocalContext.current
val clipboard = LocalClipboard.current
val scope = rememberCoroutineScope()
val code = stage.code
val remaining by produceState(stage.deadline - SystemClock.elapsedRealtime(), stage) {
while (true) {
value = (stage.deadline - SystemClock.elapsedRealtime()).coerceAtLeast(0)
delay(1_000)
}
}
val shape = RoundedCornerShape(MusyxTheme.radius.card)
Column(
Modifier.fillMaxWidth().background(c.panel, shape).border(1.dp, c.line, shape).padding(20.dp),
verticalArrangement = Arrangement.spacedBy(MusyxTheme.space.m),
) {
Text(stringResource(R.string.signin_step_code), style = MusyxTheme.type.bodyMedium, color = c.fg)
Row(verticalAlignment = Alignment.CenterVertically) {
// Shown exactly as it must be typed: a space or capital here ends up on Yandex's page.
Text(
code.userCode,
style = MusyxTheme.type.displayS.copy(letterSpacing = 0.12.em),
color = c.fg,
maxLines = 1,
modifier = Modifier.weight(1f),
)
TextButton(onClick = { scope.launch { clipboard.setClipEntry(ClipEntry(ClipData.newPlainText("code", code.userCode))) } }) {
MusyxIcon(R.drawable.ic_copy, size = 18.dp)
Text(stringResource(R.string.action_copy), modifier = Modifier.padding(start = 6.dp))
}
}
Button(
onClick = {
// The code goes to the clipboard on the way, ready to paste on Yandex's page.
scope.launch { clipboard.setClipEntry(ClipEntry(ClipData.newPlainText("code", code.userCode))) }
try {
context.startActivity(Intent(Intent.ACTION_VIEW, code.verificationUrl.toUri()))
} catch (_: ActivityNotFoundException) {
}
},
modifier = Modifier.fillMaxWidth(),
) { Text(stringResource(R.string.signin_open_page)) }
Text(stringResource(R.string.signin_phone_hint), style = MusyxTheme.type.small, color = c.muted)
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(MusyxTheme.space.s)) {
Box(Modifier.size(8.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),
)
TextButton(onClick = signIn::cancel) { Text(stringResource(R.string.action_cancel)) }
}
}
}
/** Sign-in with a token someone already has. */
@Composable
private fun TokenFallback(signIn: SignInState) {
Column(verticalArrangement = Arrangement.spacedBy(MusyxTheme.space.s)) {
TextButton(onClick = signIn::toggleToken) {
Text(stringResource(if (signIn.tokenOpen) R.string.signin_token_hide else R.string.signin_token_show), color = MusyxTheme.colors.muted)
}
if (signIn.tokenOpen) {
OutlinedTextField(
value = signIn.token,
onValueChange = { signIn.token = it },
placeholder = { Text(stringResource(R.string.signin_token_placeholder)) },
singleLine = true,
visualTransformation = PasswordVisualTransformation(),
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Password, imeAction = ImeAction.Done),
keyboardActions = KeyboardActions(onDone = { signIn.useToken() }),
modifier = Modifier.fillMaxWidth(),
)
Button(onClick = signIn::useToken, enabled = signIn.token.isNotBlank(), modifier = Modifier.width(160.dp)) {
Text(stringResource(R.string.action_sign_in))
}
}
}
}
@@ -0,0 +1,176 @@
// Settings: account, streaming quality, appearance, font size, language, storage.
package it.panov.musyx.mobile.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.ExperimentalLayoutApi
import androidx.compose.foundation.layout.FlowRow
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.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.FilterChip
import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.Text
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.data.Appearance
import it.panov.musyx.data.FontSize
import it.panov.musyx.data.Locale
import it.panov.musyx.data.Quality
import it.panov.musyx.mobile.BuildConfig
import it.panov.musyx.mobile.R
import it.panov.musyx.mobile.ui.components.MusyxIcon
import it.panov.musyx.mobile.ui.components.ScreenTitle
import it.panov.musyx.mobile.ui.humanDate
import it.panov.musyx.mobile.ui.theme.MusyxTheme
import it.panov.musyx.state.AppState
import it.panov.musyx.state.qualityLabel
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
}
@OptIn(ExperimentalLayoutApi::class)
@Composable
fun SettingsScreen(state: AppState) {
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)) {
FlowRow(horizontalArrangement = Arrangement.spacedBy(MusyxTheme.space.s)) {
Quality.entries.forEach { q ->
FilterChip(selected = q == settings.quality, onClick = { if (q != settings.quality) state.setQuality(q) }, label = { Text(stringResource(qualityLabel(q))) })
}
}
Text(stringResource(qualityDetail(settings.quality)), style = MusyxTheme.type.meta, color = MusyxTheme.colors.muted)
}
}
item(key = "appearance") {
Section(stringResource(R.string.settings_appearance)) {
FlowRow(horizontalArrangement = Arrangement.spacedBy(MusyxTheme.space.s)) {
Appearance.entries.forEach { a ->
FilterChip(selected = a == settings.appearance, onClick = { state.setAppearance(a) }, label = { Text(stringResource(appearanceLabel(a))) })
}
}
}
}
item(key = "font-size") {
Section(stringResource(R.string.settings_font_size)) {
FlowRow(horizontalArrangement = Arrangement.spacedBy(MusyxTheme.space.s)) {
FontSize.entries.forEach { f ->
FilterChip(selected = f == settings.fontSize, onClick = { state.setFontSize(f) }, label = { Text(stringResource(fontSizeLabel(f))) })
}
}
}
}
item(key = "language") {
Section(stringResource(R.string.settings_language)) {
FlowRow(horizontalArrangement = Arrangement.spacedBy(MusyxTheme.space.s)) {
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 -> "Русский"
}
FilterChip(selected = l == settings.language, onClick = { if (l != settings.language) state.setLanguage(l) }, label = { Text(label) })
}
}
}
}
item(key = "storage") {
Section(stringResource(R.string.settings_storage)) {
Text(stringResource(R.string.settings_storage_detail), style = MusyxTheme.type.meta, color = MusyxTheme.colors.muted)
OutlinedButton(onClick = state::clearCoverCache) {
MusyxIcon(R.drawable.ic_trash_2, size = 18.dp)
Text(stringResource(R.string.action_clear_covers), modifier = Modifier.padding(start = 8.dp))
}
}
}
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.gutter, vertical = MusyxTheme.space.l),
)
}
}
}
@Composable
private fun Section(title: String, content: @Composable () -> Unit) {
val space = MusyxTheme.space
Column(
Modifier
.padding(horizontal = space.gutter, vertical = space.xs)
.fillMaxWidth()
.background(MusyxTheme.colors.panel, RoundedCornerShape(MusyxTheme.radius.card))
.padding(18.dp),
verticalArrangement = Arrangement.spacedBy(space.m),
) {
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)
}
Column(
Modifier
.padding(horizontal = space.gutter, vertical = space.xs)
.fillMaxWidth()
.background(c.panel, RoundedCornerShape(MusyxTheme.radius.card))
.padding(18.dp),
verticalArrangement = Arrangement.spacedBy(space.m),
) {
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(14.dp)) {
Box(Modifier.size(52.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(2.dp)) {
Text(me.name, style = MusyxTheme.type.section, color = c.fg)
Text(me.login, style = MusyxTheme.type.meta, color = c.muted)
}
}
Text(plan, style = MusyxTheme.type.meta, color = if (me.hasPlus) c.ok else c.muted)
OutlinedButton(onClick = state::signOut) {
MusyxIcon(R.drawable.ic_log_out, size = 18.dp)
Text(stringResource(R.string.action_sign_out), modifier = Modifier.padding(start = 8.dp))
}
}
}
@@ -0,0 +1,237 @@
// The track menu as a bottom sheet, the playlist dialogs, and the toast that floats above the
// bottom of the screen after an action.
package it.panov.musyx.mobile.ui.screens
import androidx.annotation.DrawableRes
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
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.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.ModalBottomSheet
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
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 it.panov.musyx.mobile.R
import it.panov.musyx.mobile.ui.artistsOrUnknown
import it.panov.musyx.mobile.ui.components.COVER_SMALL
import it.panov.musyx.mobile.ui.components.MusyxIcon
import it.panov.musyx.mobile.ui.components.Thumb
import it.panov.musyx.mobile.ui.text
import it.panov.musyx.mobile.ui.theme.MusyxTheme
import it.panov.musyx.state.AppState
import it.panov.musyx.state.Route
import it.panov.musyx.state.Sheet
import kotlinx.coroutines.delay
/** How long a status message stays up. */
private const val TOAST_MS = 4_000L
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun SheetHost(state: AppState) {
when (val sheet = state.sheet ?: return) {
is Sheet.TrackMenu -> ModalBottomSheet(onDismissRequest = state::closeSheet, containerColor = MusyxTheme.colors.panel) {
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 -> AlertDialog(
onDismissRequest = state::closeSheet,
title = { Text(stringResource(R.string.sheet_delete_title, sheet.title)) },
text = { Text(stringResource(R.string.sheet_delete_body)) },
confirmButton = {
TextButton(onClick = { state.deletePlaylist(sheet.id) }) { Text(stringResource(R.string.action_delete), color = MusyxTheme.colors.like) }
},
dismissButton = { TextButton(onClick = state::closeSheet) { Text(stringResource(R.string.action_cancel)) } },
containerColor = MusyxTheme.colors.panel,
)
}
}
/** The sheet's head: the track's cover, title and artist. */
@Composable
private fun Head(title: String, subtitle: String?, cover: (@Composable () -> Unit)? = null) {
Row(
Modifier.fillMaxWidth().padding(horizontal = MusyxTheme.space.gutter, vertical = MusyxTheme.space.s),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(12.dp),
) {
cover?.invoke()
Column(Modifier.weight(1f)) {
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)
}
}
}
@Composable
private fun Actions(content: LazyListScope.() -> Unit) {
LazyColumn(contentPadding = PaddingValues(bottom = MusyxTheme.space.l), content = content)
}
@Composable
private fun Item(@DrawableRes icon: Int, label: String, onClick: () -> Unit) {
Row(
Modifier.fillMaxWidth().clickable(onClick = onClick).padding(horizontal = MusyxTheme.space.gutter + 4.dp, vertical = 14.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(16.dp),
) {
MusyxIcon(icon, tint = MusyxTheme.colors.muted, size = 20.dp)
Text(label, style = MusyxTheme.type.bodyMedium, color = MusyxTheme.colors.fg, 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
Head(track.fullTitle, track.artistsOrUnknown().ifEmpty { null }) { Thumb(track.coverUrl(COVER_SMALL), track.hues, 48.dp) }
HorizontalDivider(color = MusyxTheme.colors.line)
Actions {
item {
if (playing) Item(R.drawable.ic_skip_forward, stringResource(R.string.menu_next_track), state::skipFromMenu)
else Item(R.drawable.ic_skip_forward, stringResource(R.string.menu_play_next)) { 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 { HorizontalDivider(Modifier.padding(vertical = 6.dp), color = MusyxTheme.colors.line) }
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()
Head(stringResource(R.string.sheet_add_to_playlist), sheet.track.fullTitle)
HorizontalDivider(color = MusyxTheme.colors.line)
Actions {
item { Item(R.drawable.ic_plus, stringResource(R.string.menu_new_playlist)) { 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() }
}
AlertDialog(
onDismissRequest = onCancel,
title = { Text(title) },
text = {
Column(verticalArrangement = Arrangement.spacedBy(MusyxTheme.space.s)) {
OutlinedTextField(
value = name,
onValueChange = { name = it },
placeholder = { Text(stringResource(R.string.sheet_playlist_name)) },
singleLine = true,
modifier = Modifier.fillMaxWidth().focusRequester(focus),
)
if (hint != null) Text(hint, style = MusyxTheme.type.meta, color = MusyxTheme.colors.muted)
}
},
confirmButton = { TextButton(onClick = { onConfirm(name) }, enabled = name.isNotBlank()) { Text(confirm) } },
dismissButton = { TextButton(onClick = onCancel) { Text(stringResource(R.string.action_cancel)) } },
containerColor = MusyxTheme.colors.panel,
)
}
/** The status line that floats above the bottom of the screen after an action. */
@Composable
fun ToastHost(state: AppState, modifier: Modifier = Modifier) {
val toast = state.toast ?: return
LaunchedEffect(toast.serial) {
delay(TOAST_MS)
state.dismissToast(toast.serial)
}
val c = MusyxTheme.colors
Box(modifier.fillMaxSize().padding(16.dp), contentAlignment = Alignment.BottomCenter) {
Text(
text(toast.text),
style = MusyxTheme.type.bodyMedium,
color = c.bg,
modifier = Modifier
.background(c.fg, RoundedCornerShape(MusyxTheme.radius.pill))
.clickable { state.dismissToast(toast.serial) }
.padding(horizontal = 20.dp, vertical = 10.dp),
)
}
}
@@ -0,0 +1,308 @@
// Design tokens and the Compose theme for the phone. The colours and type roles are DESIGN.md's,
// as in the TV app's Theme.kt and the desktop's theme.rs; change them together.
package it.panov.musyx.mobile.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.material3.ColorScheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Shapes
import androidx.compose.material3.Typography
import androidx.compose.material3.darkColorScheme
import androidx.compose.material3.lightColorScheme
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 it.panov.musyx.mobile.R
import kotlin.math.abs
// ---- Colour ----
@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,
)
/** Porcelain: cool greys, near-black ink and a petrol accent. */
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,
)
/** Dark-first: light only when the system explicitly asks for it. Matches `values-notnight`. */
@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,
secondary = muted,
onSecondary = bg,
secondaryContainer = raised,
onSecondaryContainer = fg,
tertiary = ok,
onTertiary = bg,
background = bg,
onBackground = fg,
surface = bg,
onSurface = fg,
surfaceVariant = raised,
onSurfaceVariant = muted,
surfaceTint = Color.Transparent,
surfaceContainerLowest = bg,
surfaceContainerLow = panel,
surfaceContainer = panel,
surfaceContainerHigh = panel,
surfaceContainerHighest = raised,
inverseSurface = fg,
inverseOnSurface = bg,
error = like,
onError = accentInk,
outline = line,
outlineVariant = 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))
/** The type roles of DESIGN.md. Desktop sizes read about right on a phone at the medium font size. */
@Immutable
data class MusyxType(
val displayXl: TextStyle,
val displayL: TextStyle,
val displayM: TextStyle,
val displayS: TextStyle,
val wordmark: TextStyle,
val section: TextStyle,
val body: TextStyle,
val bodyMedium: TextStyle,
val meta: TextStyle,
val small: TextStyle,
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,
)
/** Display sizes are trimmed for the phone's width; text sizes are the desktop's. */
fun musyxType(scale: Float) = MusyxType(
displayXl = display(scale, 34f, 1.05f, -0.02f),
displayL = display(scale, 26f, 1.1f, -0.02f),
displayM = display(scale, 24f, 1.08f, -0.02f),
displayS = display(scale, 22f, 1.15f, -0.015f),
wordmark = display(scale, 20f, 1f, -0.01f),
section = onest(scale, 18f, FontWeight.SemiBold).copy(lineHeight = 1.2.em, letterSpacing = (-0.005).em),
body = onest(scale, 15f),
bodyMedium = onest(scale, 15f, FontWeight.Medium),
meta = onest(scale, 13f),
small = onest(scale, 12f),
scale = scale,
)
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 ----
@Immutable
data class MusyxSpacing(
val xxs: Dp = 2.dp,
val xs: Dp = 4.dp,
val s: Dp = 8.dp,
val m: Dp = 12.dp,
val l: Dp = 18.dp,
val xl: Dp = 22.dp,
/** Left and right page margin. */
val gutter: Dp = 16.dp,
/** Gap between sections. */
val section: Dp = 28.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,
val card: Dp = 14.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 { musyxType(1f) }
val LocalMusyxSpacing = staticCompositionLocalOf { MusyxSpacing() }
val LocalMusyxRadius = staticCompositionLocalOf { MusyxRadius() }
/** Material 3 built from the tokens, with the tokens themselves through [MusyxTheme]. */
@Composable
fun MusyxTheme(dark: Boolean = isMusyxDark(), typeScale: Float = 1f, 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,
) {
MaterialTheme(
colorScheme = colors.toColorScheme(),
shapes = radius.toShapes(),
typography = type.toTypography(),
content = content,
)
}
}
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
}
@@ -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>
@@ -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>
@@ -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>
@@ -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>
@@ -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>
@@ -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>
@@ -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>
@@ -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>
@@ -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>
@@ -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>
@@ -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>
@@ -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>
@@ -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>
@@ -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>
@@ -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>
@@ -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>
@@ -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>
@@ -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>
@@ -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>
+246
View File
@@ -0,0 +1,246 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copied from the TV app by name; strings_phone.xml has the phone's own. -->
<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_code">Введите этот код</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="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="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="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_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_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="queue_now">Сейчас играет</string>
<string name="queue_nothing_after">Дальше ничего нет</string>
<string name="queue_next_up">Далее · %1$d</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_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>
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="action_copy">Скопировать</string>
<string name="signin_open_page">Открыть страницу входа Яндекса</string>
<string name="signin_phone_hint">Код копируется, когда открывается страница. Вставьте его там, подтвердите вход и вернитесь сюда — дальше всё произойдёт само.</string>
<string name="auto_sign_in">Войдите в Musyx, чтобы ваша музыка появилась здесь.</string>
</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>
+239
View File
@@ -0,0 +1,239 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copied from the TV app by name; strings_phone.xml has the phone's own. -->
<resources>
<string name="app_name" translatable="false">Musyx</string>
<string name="lang_code">en</string>
<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>
<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>
<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_code">Enter this code</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="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>
<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="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>
<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>
<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="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>
<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>
<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_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>
<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>
<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_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>
<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="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="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>
<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>
<string name="toast_no_browser">There\'s no browser on this TV to play clips in.</string>
<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>
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Strings only the phone app has. -->
<resources>
<string name="action_copy">Copy</string>
<string name="signin_open_page">Open Yandex\'s sign-in page</string>
<string name="signin_phone_hint">Opening the page copies the code. Paste it there, confirm, and come back: sign-in finishes on its own.</string>
<!-- Shown in the car (Android Auto or Automotive) when nobody is signed in. -->
<string name="auto_sign_in">Sign in to Musyx to see your music here.</string>
</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>
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Tells Android Auto this app offers media to browse and play. -->
<automotiveApp>
<uses name="media" />
</automotiveApp>
+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>
+1 -1
View File
@@ -21,4 +21,4 @@ dependencyResolutionManagement {
}
rootProject.name = "musyx-mobile"
include(":core", ":tv")
include(":core", ":tv", ":mobile")