Native Android client for Spotify, built with Jetpack Compose
Kotlin ad-freeadblockandroidjetpack-composekotlinlyricsmusic-playermusic-videomyspotispotifyspotify-adblockerspotify-clientspotify-connectspotui
Picture-in-picture for songs (Settings > Display, off by default): leaving the app while a song plays keeps its cover, the line being sung and previous, play/pause and next in a small window; look-only extensions (ui.style action, manifest "ui": colours, hidden parts, Classic tab order, text size, fixed Home blocks, never on protected surfaces), documented in docs/extensions/UI-LOOKS.md with the sunset-look sample
kota-zo9f99d39c1b7d
diff --git a/base/app/src/main/java/app/myspoti/MainActivity.kt b/base/app/src/main/java/app/myspoti/MainActivity.ktindex 8e472a36..026c4bfe 100644--- a/base/app/src/main/java/app/myspoti/MainActivity.kt+++ b/base/app/src/main/java/app/myspoti/MainActivity.kt@@ -91,8 +91,12 @@ class MainActivity : AppCompatActivity() {private var loginProblem by mutableStateOf(false)/** The one-time setup screen (permissions, battery) after signing in. */private var setupNeeded by mutableStateOf(false)- /** In the picture-in-picture window: only the music video is drawn. */+ /** In the picture-in-picture window: only the music video (or, with [pipSong], the song card) is drawn. */private var inPip by mutableStateOf(false)+ /** The window holds the song ([com.music.spotui.ui.components.SongPip]), not the music video. */+ private var pipSong by mutableStateOf(false)+ private var pipReceiver: android.content.BroadcastReceiver? = null+ private var pipWatch: kotlinx.coroutines.Job? = null/** Debug builds: `am start ... --ez showLook true` opens the look step alone, signed in or not. */private var showLook by mutableStateOf(false)/** The "new look" popup was already shown (or the onboarding look step covered it). */@@ -189,7 +193,9 @@ class MainActivity : AppCompatActivity() {androidx.compose.ui.Modifier.align(androidx.compose.ui.Alignment.BottomEnd))// Picture-in-picture: the clip alone, over the app (which stays composed underneath,// so coming back finds the same screen).- if (inPip) com.music.spotui.ui.components.PipVideo()+ if (inPip) {+ if (pipSong) com.music.spotui.ui.components.PipSong() else com.music.spotui.ui.components.PipVideo()+ }}} } }}@@ -299,8 +305,15 @@ class MainActivity : AppCompatActivity() {override fun onUserLeaveHint() {super.onUserLeaveHint()val mv = com.music.spotui.video.MusicVideoController- if (!com.music.spotui.data.preferences.MusicVideoPref.on || !mv.on.value || mv.player == null) returnif (!com.music.spotui.di.SongPlayer.isPlaying() || isInPictureInPictureMode) return+ if (!com.music.spotui.data.preferences.MusicVideoPref.on || !mv.on.value || mv.player == null) {+ // No clip: the song itself, when the Picture-in-picture setting is on.+ if (!signedIn || !com.music.spotui.ui.components.SongPip.wanted()) return+ pipSong = true+ if (!runCatching { enterPictureInPictureMode(com.music.spotui.ui.components.SongPip.params(this)) }.getOrDefault(false)) pipSong = false+ return+ }+ pipSong = falseval ratio = mv.aspect.floatValue.coerceIn(0.5f, 2.3f)runCatching {enterPictureInPictureMode(@@ -314,7 +327,22 @@ class MainActivity : AppCompatActivity() {override fun onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean, newConfig: android.content.res.Configuration) {super.onPictureInPictureModeChanged(isInPictureInPictureMode, newConfig)inPip = isInPictureInPictureMode- com.music.spotui.video.MusicVideoController.inPip.value = isInPictureInPictureMode+ if (!pipSong) com.music.spotui.video.MusicVideoController.inPip.value = isInPictureInPictureMode+ if (isInPictureInPictureMode && pipSong) {+ if (pipReceiver == null) pipReceiver = com.music.spotui.ui.components.SongPip.listen(this)+ // Play and pause swap on the window's middle button as the music stops and starts.+ pipWatch?.cancel()+ pipWatch = lifecycleScope.launch {+ androidx.compose.runtime.snapshotFlow { com.music.spotui.di.Graph.currentSongState.playingState.value }.collect {+ runCatching { setPictureInPictureParams(com.music.spotui.ui.components.SongPip.params(this@MainActivity)) }+ }+ }+ } else if (!isInPictureInPictureMode) {+ pipWatch?.cancel(); pipWatch = null+ pipReceiver?.let { runCatching { unregisterReceiver(it) } }+ pipReceiver = null+ pipSong = false+ }}override fun onNewIntent(intent: Intent) {@@ -345,6 +373,8 @@ class MainActivity : AppCompatActivity() {}override fun onDestroy() {+ pipReceiver?.let { runCatching { unregisterReceiver(it) } }+ pipReceiver = null// The process-wide WebView lives in this activity's root while attached:// detach it, or view.parent -> root keeps the destroyed activity (and its// whole view tree) alive for the rest of the playback session.diff --git a/base/app/src/main/java/com/music/spotui/data/preferences/SettingsPref.kt b/base/app/src/main/java/com/music/spotui/data/preferences/SettingsPref.ktindex c0e96593..bf6771f4 100644--- a/base/app/src/main/java/com/music/spotui/data/preferences/SettingsPref.kt+++ b/base/app/src/main/java/com/music/spotui/data/preferences/SettingsPref.kt@@ -239,6 +239,9 @@ object HideDjPref {var on by androidx.compose.runtime.mutableStateOf(prefs(com.music.spotui.di.Graph.app).getBoolean(KEY, false))private set+ /** Hidden here or by an extension's look (`home.dj`). */+ val hidden: Boolean get() = on || com.music.spotui.extensions.ExtensionLook.hides(app.myspoti.extensions.UiPart.HOME_DJ)+fun set(c: Context, value: Boolean) {on = valueprefs(c).edit().putBoolean(KEY, value).apply()@@ -288,6 +291,9 @@ object PlayerLyricsCardPref {var on by androidx.compose.runtime.mutableStateOf(prefs(com.music.spotui.di.Graph.app).getBoolean(KEY, true))private set+ /** Shown: on here and not hidden by an extension's look (`player.lyrics-card`). */+ val shown: Boolean get() = on && !com.music.spotui.extensions.ExtensionLook.hides(app.myspoti.extensions.UiPart.PLAYER_LYRICS_CARD)+fun set(c: Context, value: Boolean) {on = valueprefs(c).edit().putBoolean(KEY, value).apply()@@ -304,6 +310,9 @@ object PlayerSourceLinePref {var on by androidx.compose.runtime.mutableStateOf(prefs(com.music.spotui.di.Graph.app).getBoolean(KEY, true))private set+ /** Shown: on here and not hidden by an extension's look (`player.source`). */+ val shown: Boolean get() = on && !com.music.spotui.extensions.ExtensionLook.hides(app.myspoti.extensions.UiPart.PLAYER_SOURCE)+fun set(c: Context, value: Boolean) {on = valueprefs(c).edit().putBoolean(KEY, value).apply()@@ -320,6 +329,9 @@ object PlayerCapsulePref {var on by androidx.compose.runtime.mutableStateOf(prefs(com.music.spotui.di.Graph.app).getBoolean(KEY, true))private set+ /** Shown: on here and not hidden by an extension's look (`player.capsule`). */+ val shown: Boolean get() = on && !com.music.spotui.extensions.ExtensionLook.hides(app.myspoti.extensions.UiPart.PLAYER_CAPSULE)+fun set(c: Context, value: Boolean) {on = valueprefs(c).edit().putBoolean(KEY, value).apply()@@ -372,3 +384,20 @@ object LyricsKeepAwakePref {prefs(c).edit().putBoolean(KEY, value).apply()}}++/**+ * "Picture-in-picture" (Settings > Display, both looks): leaving the app while a song plays opens+ * a small window with its cover, the line being sung and previous, play/pause and next buttons+ * ([com.music.spotui.ui.components.SongPip]). Off by default: asked for on Discord, and "keep it+ * optional" there too. A music video keeps its own window whatever this says.+ */+object SongPipPref {+ private const val KEY = "song_pip"+ var on by androidx.compose.runtime.mutableStateOf(prefs(com.music.spotui.di.Graph.app).getBoolean(KEY, false))+ private set++ fun set(c: Context, value: Boolean) {+ on = value+ prefs(c).edit().putBoolean(KEY, value).apply()+ }+}diff --git a/base/app/src/main/java/com/music/spotui/extensions/ExtensionLook.kt b/base/app/src/main/java/com/music/spotui/extensions/ExtensionLook.ktnew file mode 100644index 00000000..8828866a--- /dev/null+++ b/base/app/src/main/java/com/music/spotui/extensions/ExtensionLook.kt@@ -0,0 +1,62 @@+package com.music.spotui.extensions++import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableStateOf+import androidx.compose.runtime.setValue+import androidx.compose.ui.graphics.Color+import app.myspoti.extensions.Action+import app.myspoti.extensions.AppliedLook+import app.myspoti.extensions.Area+import app.myspoti.extensions.SurfaceGuard+import app.myspoti.extensions.UiPart+import app.myspoti.extensions.UiStyle+import kotlinx.coroutines.CoroutineScope+import kotlinx.coroutines.Dispatchers+import kotlinx.coroutines.SupervisorJob+import kotlinx.coroutines.flow.combine+import kotlinx.coroutines.launch++/**+ * The look the enabled `ui.style` extensions give the app ([AppliedLook]), read by the theme+ * (colours, text size), the tab bar (order), the pages that can hide a part, and Home (blocks).+ * Compose state: what reads it follows an install, a switch or a reorder at once. While a+ * protected surface is on screen it is [AppliedLook.NONE]: nothing of theirs restyles those.+ */+object ExtensionLook {+ private var look by mutableStateOf(AppliedLook.NONE)+ private var shielded by mutableStateOf(false)++ /** What applies now. */+ val applied: AppliedLook get() = if (shielded) AppliedLook.NONE else look++ private var watching = false++ /** Follows the installed extensions and the protected surfaces (called by [Extensions.init]). */+ fun watch() {+ if (watching) return+ watching = true+ CoroutineScope(SupervisorJob() + Dispatchers.Default).launch {+ combine(Extensions.registry, SurfaceGuard.app.state) { r, guard -> r to guard.isNotEmpty() }.collect { (r, guard) ->+ val looks = r.byPriority(Area.OTHER.key, r.extensions.filter { it.enabled && Action.UI_STYLE.key in it.granted }) { it.id }+ .mapNotNull { e -> Extensions.manifest(e.id)?.look()?.let { e.id to it } }+ val next = runCatching { AppliedLook.of(looks) }.getOrDefault(AppliedLook.NONE)+ kotlinx.coroutines.withContext(Dispatchers.Main) {+ if (look != next) look = next+ shielded = guard+ }+ }+ }+ }++ /** The colour a look sets for [key] ([UiStyle.ACCENT], [UiStyle.BACKGROUND], [UiStyle.SURFACE]), or null. */+ fun color(key: String): Color? = applied.colors[key]?.let { Color(it) }++ /** Whether a look hides [part]. */+ fun hides(part: UiPart): Boolean = part in applied.hidden++ /** The text size a look asks for, 1 without one. */+ val textScale: Float get() = applied.textScale ?: 1f++ /** The Classic look's bottom tabs as a look orders them (`home`, `search`, `library`), or null. */+ val navOrder: List<String>? get() = applied.navOrder+}diff --git a/base/app/src/main/java/com/music/spotui/extensions/ExtensionUi.kt b/base/app/src/main/java/com/music/spotui/extensions/ExtensionUi.ktindex b77b68d5..8e6a3a1a 100644--- a/base/app/src/main/java/com/music/spotui/extensions/ExtensionUi.kt+++ b/base/app/src/main/java/com/music/spotui/extensions/ExtensionUi.kt@@ -25,6 +25,7 @@ import androidx.compose.material.icons.automirrored.rounded.PlaylistPlayimport androidx.compose.material.icons.automirrored.rounded.QueueMusicimport androidx.compose.material.icons.automirrored.rounded.VolumeUpimport androidx.compose.material.icons.rounded.Add+import androidx.compose.material.icons.rounded.Paletteimport androidx.compose.material.icons.rounded.Albumimport androidx.compose.material.icons.rounded.BarChartimport androidx.compose.material.icons.rounded.Bolt@@ -161,6 +162,7 @@ fun actionIcon(a: Action?): ImageVector = when (a) {Action.WEBVIEW_AUTH -> Icons.Rounded.KeyAction.STORAGE -> Icons.Rounded.SaveAction.ATTEST -> Icons.Rounded.Fingerprint+ Action.UI_STYLE -> Icons.Rounded.Palettenull -> Icons.Rounded.Extension}@@ -189,6 +191,7 @@ fun actionLabel(a: Action?): Int = when (a) {Action.WEBVIEW_AUTH -> R.string.action_webview_authAction.STORAGE -> R.string.action_storageAction.ATTEST -> R.string.action_attest+ Action.UI_STYLE -> R.string.action_ui_stylenull -> R.string.action_unknown}diff --git a/base/app/src/main/java/com/music/spotui/extensions/Extensions.kt b/base/app/src/main/java/com/music/spotui/extensions/Extensions.ktindex 247cb9ad..faf55f06 100644--- a/base/app/src/main/java/com/music/spotui/extensions/Extensions.kt+++ b/base/app/src/main/java/com/music/spotui/extensions/Extensions.kt@@ -201,6 +201,8 @@ object Extensions {watchPlayback()watchNetwork()watchStatus()+ // Look-only extensions (ui.style): their colours, hidden parts and order, applied by the app.+ ExtensionLook.watch()watchProvided()}@@ -709,11 +711,15 @@ object Extensions {suspend fun blocks(hook: Hook, surface: Surface, input: String): Conflicts.Shown<String> {if (!isReady || guard.suspended) return Conflicts.Shown(emptyList(), emptyList())val providers = providing(hook)- if (providers.isEmpty()) return Conflicts.Shown(emptyList(), emptyList())+ // Home blocks a look declares (ui.blocks.home): fixed, nothing to ask.+ val declared = if (surface == Surface.HOME) ExtensionLook.applied.homeBlocks.mapNotNull { (id, json) ->+ runCatching { id to Blocks.parse(json, surface) }.getOrNull()+ } else emptyList()+ if (providers.isEmpty() && declared.isEmpty()) return Conflicts.Shown(emptyList(), emptyList())val answers = kotlinx.coroutines.coroutineScope {providers.map { (id, rt) -> async { id to (callHook(id, rt, hook, input, BLOCKS_MS) { Blocks.parse(it, surface) } ?: emptyList()) } }.map { it.await() }}- return Conflicts.merge(answers, surface)+ return Conflicts.merge(answers + declared, surface)}/** A block of [id] with an action was tapped on [surface]; [context]: what the place is about (JSON). */diff --git a/base/app/src/main/java/com/music/spotui/ui/components/SongOptionsSheet.kt b/base/app/src/main/java/com/music/spotui/ui/components/SongOptionsSheet.ktindex cbff0ea6..dad2df86 100644--- a/base/app/src/main/java/com/music/spotui/ui/components/SongOptionsSheet.kt+++ b/base/app/src/main/java/com/music/spotui/ui/components/SongOptionsSheet.kt@@ -351,7 +351,7 @@ fun SongOptionsSheet(tint = if (active) MenuGreen else MenuIconColor,) { showSleep = true }// The source line of the player is turned off: its sheet is here instead.- if (!com.music.spotui.data.preferences.PlayerSourceLinePref.on) {+ if (!com.music.spotui.data.preferences.PlayerSourceLinePref.shown) {MenuRow(Icons.Outlined.GraphicEq, stringResource(R.string.quality_sheet_title)) { showQuality = true }}MenuRow(Icons.Outlined.Analytics, stringResource(R.string.nerd_title)) { showNerd = true }diff --git a/base/app/src/main/java/com/music/spotui/ui/components/SongPip.kt b/base/app/src/main/java/com/music/spotui/ui/components/SongPip.ktnew file mode 100644index 00000000..22987626--- /dev/null+++ b/base/app/src/main/java/com/music/spotui/ui/components/SongPip.kt@@ -0,0 +1,139 @@+package com.music.spotui.ui.components++import android.app.Activity+import android.app.PendingIntent+import android.app.PictureInPictureParams+import android.app.RemoteAction+import android.content.BroadcastReceiver+import android.content.Context+import android.content.Intent+import android.content.IntentFilter+import android.graphics.drawable.Icon+import android.util.Rational+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.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.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.Color+import androidx.compose.ui.layout.ContentScale+import androidx.compose.ui.text.font.FontWeight+import androidx.compose.ui.text.style.TextAlign+import androidx.compose.ui.text.style.TextOverflow+import androidx.compose.ui.unit.dp+import androidx.compose.ui.unit.sp+import androidx.core.content.ContextCompat+import app.myspoti.engine.R+import com.bumptech.glide.integration.compose.ExperimentalGlideComposeApi+import com.bumptech.glide.integration.compose.GlideImage+import com.bumptech.glide.integration.compose.placeholder+import com.music.spotui.di.Graph+import com.music.spotui.di.SongPlayer++/**+ * The song in a picture-in-picture window ([com.music.spotui.data.preferences.SongPipPref], off by+ * default): asked for on Discord by people whose phone kills apps in the background, with the+ * lyrics and the playback buttons (the window's own actions: previous, play/pause, next).+ */+object SongPip {+ private const val ACTION = "app.myspoti.PIP_CONTROL"+ private const val EXTRA = "what"++ /** A card a little taller than wide, like the one shared on Discord. */+ private val RATIO = Rational(2, 3)++ fun wanted(): Boolean =+ com.music.spotui.data.preferences.SongPipPref.on && SongPlayer.isPlaying() && Graph.currentSongState.title.value.isNotBlank()++ fun params(c: Context): PictureInPictureParams {+ val playing = Graph.currentSongState.playingState.value+ return PictureInPictureParams.Builder()+ .setAspectRatio(RATIO)+ .setActions(+ listOf(+ action(c, 0, R.drawable.ic_skip_prev, R.string.pip_previous, "prev"),+ if (playing) action(c, 1, R.drawable.ic_pause, R.string.pip_pause, "toggle")+ else action(c, 1, R.drawable.ic_play, R.string.pip_play, "toggle"),+ action(c, 2, R.drawable.ic_skip_next, R.string.pip_next, "next"),+ ),+ )+ .build()+ }++ private fun action(c: Context, code: Int, icon: Int, label: Int, what: String): RemoteAction {+ val intent = Intent(ACTION).setPackage(c.packageName).putExtra(EXTRA, what)+ val pending = PendingIntent.getBroadcast(c, code, intent, PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT)+ val text = c.getString(label)+ return RemoteAction(Icon.createWithResource(c, icon), text, text, pending)+ }++ /** Listens to the window's buttons while it is shown; returns what [Activity.unregisterReceiver] takes. */+ fun listen(activity: Activity): BroadcastReceiver {+ val receiver = object : BroadcastReceiver() {+ override fun onReceive(context: Context, intent: Intent) {+ when (intent.getStringExtra(EXTRA)) {+ "prev" -> SongPlayer.previous()+ "next" -> SongPlayer.next()+ "toggle" -> if (SongPlayer.isPlaying()) SongPlayer.pause() else SongPlayer.play()+ }+ }+ }+ ContextCompat.registerReceiver(activity, receiver, IntentFilter(ACTION), ContextCompat.RECEIVER_NOT_EXPORTED)+ return receiver+ }+}++/** What the song's picture-in-picture window shows: the cover, the title and artist, the line being sung. */+@OptIn(ExperimentalGlideComposeApi::class)+@Composable+fun PipSong() {+ val song = Graph.currentSongState+ val title = song.title.value+ val artist = song.singer.value+ val (line, next) = com.music.spotui.ui.screens.rememberPipLyricLines(title, artist)+ Column(+ Modifier.fillMaxSize().background(Color(0xFF121212)).padding(10.dp),+ horizontalAlignment = Alignment.CenterHorizontally,+ verticalArrangement = Arrangement.Center,+ ) {+ if (line == null) {+ GlideImage(+ model = song.coverUri.value.takeIf { it.isNotBlank() },+ contentDescription = null,+ contentScale = ContentScale.Crop,+ loading = placeholder(R.drawable.placeholder),+ failure = placeholder(R.drawable.placeholder),+ modifier = Modifier.fillMaxWidth(0.8f).aspectRatio(1f).clip(RoundedCornerShape(8.dp)),+ )+ Spacer(Modifier.height(8.dp))+ }+ Text(title, color = Color.White, fontSize = 13.sp, fontWeight = FontWeight.Bold, maxLines = 1,+ overflow = TextOverflow.Ellipsis, textAlign = TextAlign.Center)+ Text(artist, color = Color.White.copy(alpha = 0.7f), fontSize = 11.sp, maxLines = 1,+ overflow = TextOverflow.Ellipsis, textAlign = TextAlign.Center)+ if (line != null) {+ Box(Modifier.weight(1f).fillMaxWidth(), contentAlignment = Alignment.Center) {+ Column(horizontalAlignment = Alignment.CenterHorizontally) {+ Text(line, color = Color.White, fontSize = 15.sp, fontWeight = FontWeight.Bold, maxLines = 4,+ overflow = TextOverflow.Ellipsis, textAlign = TextAlign.Center)+ if (next != null) {+ Spacer(Modifier.height(6.dp))+ Text(next, color = Color.White.copy(alpha = 0.45f), fontSize = 12.sp, maxLines = 2,+ overflow = TextOverflow.Ellipsis, textAlign = TextAlign.Center)+ }+ }+ }+ }+ }+}diff --git a/base/app/src/main/java/com/music/spotui/ui/immersive/ImmersiveTheme.kt b/base/app/src/main/java/com/music/spotui/ui/immersive/ImmersiveTheme.ktindex 6528ea33..9e7e49bc 100644--- a/base/app/src/main/java/com/music/spotui/ui/immersive/ImmersiveTheme.kt+++ b/base/app/src/main/java/com/music/spotui/ui/immersive/ImmersiveTheme.kt@@ -21,16 +21,17 @@ import com.music.spotui.ui.look.ImmersiveSans*/object Immersive {// Colours.- val Page = Color.Black- val Raised = Color(0xFF1C1C1E)+ /** Black, or an extension's look background (unless the AMOLED setting is on). */+ val Page: Color get() = if (app.myspoti.power.EnergySettings.oledBlack) Color.Black+ else com.music.spotui.extensions.ExtensionLook.color(app.myspoti.extensions.UiStyle.BACKGROUND) ?: Color.Black+ val Raised: Color get() = com.music.spotui.extensions.ExtensionLook.color(app.myspoti.extensions.UiStyle.SURFACE) ?: Color(0xFF1C1C1E)val Separator = Color.White.copy(alpha = 0.10f)val Text = Color.Whiteval TextSecondary = Color.White.copy(alpha = 0.60f)val TextTertiary = Color.White.copy(alpha = 0.38f)/** The look's own pink until an Immersive accent colour is chosen in Settings, then that colour (links, the selected tab, toggles). */- val Accent: Color get() = com.music.spotui.data.api.SupportReminder.run {- if (immersiveAccentChosen) immersiveAccent.color else Color(0xFFFF4F7B)- }+ val Accent: Color get() = com.music.spotui.extensions.ExtensionLook.color(app.myspoti.extensions.UiStyle.ACCENT)+ ?: com.music.spotui.data.api.SupportReminder.run { if (immersiveAccentChosen) immersiveAccent.color else Color(0xFFFF4F7B) }val GlassFill = Color(0xFF2C2C34).copy(alpha = 0.88f)val GlassEdge = Color.White.copy(alpha = 0.12f)/** The red of a destructive swipe, menu entry or confirmation (Leave, Remove, an error). */diff --git a/base/app/src/main/java/com/music/spotui/ui/immersive/pages/ImmersiveSettingsScreen.kt b/base/app/src/main/java/com/music/spotui/ui/immersive/pages/ImmersiveSettingsScreen.ktindex 8bcb8c4d..1289a4b9 100644--- a/base/app/src/main/java/com/music/spotui/ui/immersive/pages/ImmersiveSettingsScreen.kt+++ b/base/app/src/main/java/com/music/spotui/ui/immersive/pages/ImmersiveSettingsScreen.kt@@ -856,6 +856,10 @@ private fun DisplayPage(open: (SettingsPage) -> Unit, back: () -> Unit) {ImmersiveSwitchRow(stringResource(R.string.settings_music_video_title), checked = com.music.spotui.data.preferences.MusicVideoPref.on,onChecked = { com.music.spotui.data.preferences.MusicVideoPref.set(ctx, it) }, detail = stringResource(R.string.settings_music_video_detail))}+ row {+ ImmersiveSwitchRow(stringResource(R.string.settings_song_pip_title), checked = com.music.spotui.data.preferences.SongPipPref.on,+ onChecked = { com.music.spotui.data.preferences.SongPipPref.set(ctx, it) }, detail = stringResource(R.string.settings_song_pip_detail))+ }row {ImmersiveSwitchRow(stringResource(R.string.settings_hide_dj_title), checked = com.music.spotui.data.preferences.HideDjPref.on,onChecked = { com.music.spotui.data.preferences.HideDjPref.set(ctx, it) }, detail = stringResource(R.string.settings_hide_dj_detail))diff --git a/base/app/src/main/java/com/music/spotui/ui/immersive/player/ImmersivePlayer.kt b/base/app/src/main/java/com/music/spotui/ui/immersive/player/ImmersivePlayer.ktindex efc1f830..e56cdbf1 100644--- a/base/app/src/main/java/com/music/spotui/ui/immersive/player/ImmersivePlayer.kt+++ b/base/app/src/main/java/com/music/spotui/ui/immersive/player/ImmersivePlayer.kt@@ -597,7 +597,7 @@ private fun RowScope.PlayerCredits(// a moment after the song starts), so its arrival fades in below the title and artist// instead of moving them.val sourceLabel = com.music.spotui.ui.components.playingSourceLabel()- val sourceShown = com.music.spotui.data.preferences.PlayerSourceLinePref.on+ val sourceShown = com.music.spotui.data.preferences.PlayerSourceLinePref.shownval hasSource = sourceLabel.isNotBlank() && !state.adPlayingval sourceAlpha by animateFloatAsState(if (hasSource) 1f else 0f, tween(250), label = "sourceLine")val lineH = if (state.adPlaying) 24.sp else 22.spdiff --git a/base/app/src/main/java/com/music/spotui/ui/immersive/player/PlayerControls.kt b/base/app/src/main/java/com/music/spotui/ui/immersive/player/PlayerControls.ktindex db2882e5..aeff680f 100644--- a/base/app/src/main/java/com/music/spotui/ui/immersive/player/PlayerControls.kt+++ b/base/app/src/main/java/com/music/spotui/ui/immersive/player/PlayerControls.kt@@ -485,7 +485,7 @@ internal fun PlayerActionRow(onOpenDevices: () -> Unit,) {val modes = com.music.spotui.data.preferences.PlayerModesPref.on- val capsule = com.music.spotui.data.preferences.PlayerCapsulePref.on+ val capsule = com.music.spotui.data.preferences.PlayerCapsulePref.shownBoxWithConstraints(Modifier.fillMaxWidth()) {val widestRow = BOTTOM_ACTION_SIZE * 2 + pillWidth(if (modes) 3 else 2)val edgeInset = ((maxWidth - widestRow) / 4).coerceAtLeast(0.dp)diff --git a/base/app/src/main/java/com/music/spotui/ui/immersive/screens/ImmersiveHomeScreen.kt b/base/app/src/main/java/com/music/spotui/ui/immersive/screens/ImmersiveHomeScreen.ktindex c682b854..af8bdf8d 100644--- a/base/app/src/main/java/com/music/spotui/ui/immersive/screens/ImmersiveHomeScreen.kt+++ b/base/app/src/main/java/com/music/spotui/ui/immersive/screens/ImmersiveHomeScreen.kt@@ -128,7 +128,7 @@ fun ImmersiveHomeScreen(navController: NavController) {}// Podcasts can be off: their shows and episodes then leave the feed.- val hideDj = com.music.spotui.data.preferences.HideDjPref.on+ val hideDj = com.music.spotui.data.preferences.HideDjPref.hiddenval sections = remember(feed, hideDj) { feed?.let { visibleSections(it) }.orEmpty().let { if (hideDj) it.withoutDj() else it } }// Only the untitled section the web home starts with is a shortcut grid; a titled lead// section is a carousel like any other.diff --git a/base/app/src/main/java/com/music/spotui/ui/immersive/sheets/ImmersiveSongOptionsSheet.kt b/base/app/src/main/java/com/music/spotui/ui/immersive/sheets/ImmersiveSongOptionsSheet.ktindex aa6a5e6c..41eeb7cb 100644--- a/base/app/src/main/java/com/music/spotui/ui/immersive/sheets/ImmersiveSongOptionsSheet.kt+++ b/base/app/src/main/java/com/music/spotui/ui/immersive/sheets/ImmersiveSongOptionsSheet.kt@@ -332,10 +332,10 @@ fun ImmersiveSongOptionsSheet(tint = if (SongPlayer.sleepEndsAt.value != null) LocalImmersiveSheetTint.current.accent else null,) { showSleep = true }// The player's source line and capsule are turned off: their sheets are here instead.- if (!com.music.spotui.data.preferences.PlayerSourceLinePref.on) {+ if (!com.music.spotui.data.preferences.PlayerSourceLinePref.shown) {ImmersiveSheetRow(Icons.Rounded.GraphicEq, stringResource(R.string.quality_sheet_title)) { showQuality = true }}- if (!com.music.spotui.data.preferences.PlayerCapsulePref.on) {+ if (!com.music.spotui.data.preferences.PlayerCapsulePref.shown) {ImmersiveSheetRow(Icons.Rounded.Devices, stringResource(R.string.listen_on)) { showDevices = true }}ImmersiveSheetRow(Icons.Rounded.Analytics, stringResource(R.string.nerd_title)) { showNerd = true }diff --git a/base/app/src/main/java/com/music/spotui/ui/navigation/MainBottomNavigation.kt b/base/app/src/main/java/com/music/spotui/ui/navigation/MainBottomNavigation.ktindex e8fa4973..33d8aeb0 100644--- a/base/app/src/main/java/com/music/spotui/ui/navigation/MainBottomNavigation.kt+++ b/base/app/src/main/java/com/music/spotui/ui/navigation/MainBottomNavigation.kt@@ -169,7 +169,13 @@ fun MainBottomNavigation(navController: NavHostController) {}// Friend activity opens from Home's header (as in Spotify), not from a tab.-private val TabItems = listOf(Routes.Home, Routes.Search, Routes.Library)+/** The tabs, in the order an extension's look sets (`ui.order.nav`) or the app's own. */+private val TabItems: List<Routes>+ get() {+ val tabs = mapOf("home" to Routes.Home, "search" to Routes.Search, "library" to Routes.Library)+ return com.music.spotui.extensions.ExtensionLook.navOrder?.mapNotNull { tabs[it] }?.takeIf { it.size == tabs.size }+ ?: listOf(Routes.Home, Routes.Search, Routes.Library)+ }/** The tab shown (also on its sub-pages) and what a tap on a tab does; shared by the bar and the rail. */private class TabNavigation(private val navController: NavHostController, private val state: androidx.compose.runtime.MutableState<String>, private val currentRoute: String?) {diff --git a/base/app/src/main/java/com/music/spotui/ui/screens/HomeScreen.kt b/base/app/src/main/java/com/music/spotui/ui/screens/HomeScreen.ktindex 7b284b55..a89a0559 100644--- a/base/app/src/main/java/com/music/spotui/ui/screens/HomeScreen.kt+++ b/base/app/src/main/java/com/music/spotui/ui/screens/HomeScreen.kt@@ -172,7 +172,7 @@ fun HomeFeedContent(navController: NavController, feed: HomeFeedModel, facet: St// not force-squeezed into the grid.// With podcasts off, their shows and episodes leave the feed (and a section left empty goes).// Kept between recompositions: a new list for every one of them would restart the rows below.- val hideDj = com.music.spotui.data.preferences.HideDjPref.on+ val hideDj = com.music.spotui.data.preferences.HideDjPref.hiddenval sections = remember(feed, hideDj) {val all = if (com.music.spotui.data.api.Features.PODCASTS) feed.sectionselse feed.sections.map { s -> s.copy(items = s.items.filterNot { it is HomeItem.Show }) }.filter { it.items.isNotEmpty() }diff --git a/base/app/src/main/java/com/music/spotui/ui/screens/LyricsScreen.kt b/base/app/src/main/java/com/music/spotui/ui/screens/LyricsScreen.ktindex 717112f2..e7a6657e 100644--- a/base/app/src/main/java/com/music/spotui/ui/screens/LyricsScreen.kt+++ b/base/app/src/main/java/com/music/spotui/ui/screens/LyricsScreen.kt@@ -1093,3 +1093,18 @@ fun LyricsOverlay(}}}++/**+ * The line being sung and the one after it, for the picture-in-picture window ([SongPip]): both+ * null while the song has no synced lyrics (or none were found).+ */+@Composable+internal fun rememberPipLyricLines(title: String, artist: String): Pair<String?, String?> {+ val state = rememberLyricsState(viewModel(), title, artist)+ val l = (state as? LyricsViewModel.State.Loaded)?.lyrics?.takeIf { it.synced } ?: return null to null+ val position = rememberPosition(com.music.spotui.di.Graph.currentSongState.playingState.value)+ val active by remember(l) { derivedStateOf { activeIndexFor(l, position()) } }+ val now = l.lines.getOrNull(active)?.text?.takeIf { it.isNotBlank() }+ val next = l.lines.drop(active + 1).firstOrNull { it.text.isNotBlank() }?.text+ return now to next+}diff --git a/base/app/src/main/java/com/music/spotui/ui/screens/PlayerScreen.kt b/base/app/src/main/java/com/music/spotui/ui/screens/PlayerScreen.ktindex 89c6abad..a402cf7f 100644--- a/base/app/src/main/java/com/music/spotui/ui/screens/PlayerScreen.kt+++ b/base/app/src/main/java/com/music/spotui/ui/screens/PlayerScreen.kt@@ -705,7 +705,7 @@ fun PlayerScreen(navController: NavController) {// artwork only, so a swipe there cannot pull a card up under the compact strip.if (!immersive) item {// T4: no lyrics card during an ad break — the song it belongs to is not what plays.- if (!audioBuffering && !adPlaying && com.music.spotui.data.preferences.PlayerLyricsCardPref.on) InlineLyrics(+ if (!audioBuffering && !adPlaying && com.music.spotui.data.preferences.PlayerLyricsCardPref.shown) InlineLyrics(title = songTitle,artist = songSinger,album = playerViewModel.currentSongAlbum.value,@@ -1414,7 +1414,7 @@ fun PlayerConnectRow(var nerd by remember { mutableStateOf(false) }if (quality) com.music.spotui.ui.components.QualitySheet { quality = false }if (nerd) com.music.spotui.ui.components.StatsForNerdsSheet { nerd = false }- if (source.isNotBlank() && com.music.spotui.data.preferences.PlayerSourceLinePref.on) Text(+ if (source.isNotBlank() && com.music.spotui.data.preferences.PlayerSourceLinePref.shown) Text(text = source,color = com.music.spotui.ui.theme.AppMuted,fontSize = 11.sp,diff --git a/base/app/src/main/java/com/music/spotui/ui/screens/SettingsScreen.kt b/base/app/src/main/java/com/music/spotui/ui/screens/SettingsScreen.ktindex 6b0bc49d..dba24e48 100644--- a/base/app/src/main/java/com/music/spotui/ui/screens/SettingsScreen.kt+++ b/base/app/src/main/java/com/music/spotui/ui/screens/SettingsScreen.kt@@ -364,6 +364,12 @@ fun SettingsScreen(navController: NavController) {checked = com.music.spotui.data.preferences.SolidNavBar.on,onChecked = { com.music.spotui.data.preferences.SolidNavBar.set(ctx, it) },)+ OptionRow(+ label = stringResource(R.string.settings_song_pip_title),+ detail = stringResource(R.string.settings_song_pip_detail),+ checked = com.music.spotui.data.preferences.SongPipPref.on,+ onChecked = { com.music.spotui.data.preferences.SongPipPref.set(ctx, it) },+ )OptionRow(label = stringResource(R.string.settings_hide_dj_title),detail = stringResource(R.string.settings_hide_dj_detail),diff --git a/base/app/src/main/java/com/music/spotui/ui/theme/Color.kt b/base/app/src/main/java/com/music/spotui/ui/theme/Color.ktindex 31d755f4..8e19c15c 100644--- a/base/app/src/main/java/com/music/spotui/ui/theme/Color.kt+++ b/base/app/src/main/java/com/music/spotui/ui/theme/Color.kt@@ -3,13 +3,16 @@ package com.music.spotui.ui.themeimport androidx.compose.ui.graphics.Colorimport androidx.compose.ui.graphics.lerp+/** The page: black with the AMOLED setting (an extension's look never undoes it), else a look's background or #121212. */val AppBackground: Color get() =- if (app.myspoti.power.EnergySettings.oledBlack) Color.Black else Color(0xFF121212)-val GridBackground: Color get() = tone(0xFF2A2A2A)-/** The accent (Spotify green, the colour chosen in the settings, or the wallpaper's: see DynamicColorPref). */+ if (app.myspoti.power.EnergySettings.oledBlack) Color.Black+ else com.music.spotui.extensions.ExtensionLook.color(app.myspoti.extensions.UiStyle.BACKGROUND) ?: Color(0xFF121212)+val GridBackground: Color get() = com.music.spotui.extensions.ExtensionLook.color(app.myspoti.extensions.UiStyle.SURFACE) ?: tone(0xFF2A2A2A)+/** The accent (Spotify green, the colour chosen in the settings, the wallpaper's: see DynamicColorPref, or an extension's look). */val AppPalette: Color get() = AppAccentval AppAccent: Color get() =- com.music.spotui.data.preferences.DynamicColorPref.accent() ?: com.music.spotui.data.api.SupportReminder.accentColor+ com.music.spotui.extensions.ExtensionLook.color(app.myspoti.extensions.UiStyle.ACCENT)+ ?: com.music.spotui.data.preferences.DynamicColorPref.accent() ?: com.music.spotui.data.api.SupportReminder.accentColor/** Primary text and icons. */val AppText: Color = Color.Whitediff --git a/base/app/src/main/java/com/music/spotui/ui/theme/Theme.kt b/base/app/src/main/java/com/music/spotui/ui/theme/Theme.ktindex 2c97ff86..51f07c09 100644--- a/base/app/src/main/java/com/music/spotui/ui/theme/Theme.kt+++ b/base/app/src/main/java/com/music/spotui/ui/theme/Theme.kt@@ -96,12 +96,20 @@ fun SpotuiTheme(// Bare Text() uses LocalTextStyle, which MaterialTheme does NOT derive// from the typography — so provide Montserrat as the global default so// every screen picks it up without touching each Text call.- androidx.compose.material3.ProvideTextStyle(- value = androidx.compose.material3.LocalTextStyle.current.copy(- fontFamily = Montserrat,- letterSpacing = (-0.2).sp,- ),- content = content,- )+ // An extension's look may make the text a little smaller or larger (ui.styles.text.scale).+ val density = androidx.compose.ui.platform.LocalDensity.current+ val scale = com.music.spotui.extensions.ExtensionLook.textScale+ androidx.compose.runtime.CompositionLocalProvider(+ androidx.compose.ui.platform.LocalDensity provides+ if (scale == 1f) density else androidx.compose.ui.unit.Density(density.density, density.fontScale * scale),+ ) {+ androidx.compose.material3.ProvideTextStyle(+ value = androidx.compose.material3.LocalTextStyle.current.copy(+ fontFamily = Montserrat,+ letterSpacing = (-0.2).sp,+ ),+ content = content,+ )+ }}}diff --git a/base/app/src/main/res/values-de/myspoti_strings.xml b/base/app/src/main/res/values-de/myspoti_strings.xmlindex 770a8388..72ae62ca 100644--- a/base/app/src/main/res/values-de/myspoti_strings.xml+++ b/base/app/src/main/res/values-de/myspoti_strings.xml@@ -555,6 +555,12 @@<string name="settings_player_source_detail">Die Zeile, die sagt, was wie läuft. Aus: Klangqualität und Stats for nerds stehen im Menü des Players.</string><string name="settings_player_capsule_title">Kapsel im Player</string><string name="settings_player_capsule_detail">Die Tasten unten im Player. Aus: „Hören auf“ steht im Menü des Players.</string>+ <string name="settings_song_pip_title">Bild-im-Bild</string>+ <string name="settings_song_pip_detail">Beim Verlassen der App während der Wiedergabe bleibt der Song in einem kleinen Fenster: Cover, Songtext und Wiedergabetasten. Ein Musikvideo hat sein eigenes Fenster.</string>+ <string name="pip_previous">Zurück</string>+ <string name="pip_play">Abspielen</string>+ <string name="pip_pause">Pause</string>+ <string name="pip_next">Weiter</string><string name="downloads_need_source">Downloads brauchen eine Quell-Erweiterung. Installiere eine unter Einstellungen, Erweiterungen.</string><string name="downloads_source_row_title">Download-Quelle</string><string name="downloads_source_row_on">Eine Erweiterung liefert die Dateien. Tippen, um Erweiterungen zu verwalten.</string>diff --git a/base/app/src/main/res/values-de/security_strings.xml b/base/app/src/main/res/values-de/security_strings.xmlindex 8b18536a..37ccc804 100644--- a/base/app/src/main/res/values-de/security_strings.xml+++ b/base/app/src/main/res/values-de/security_strings.xml@@ -2,5 +2,6 @@<resources><string name="action_playback_mirror">Hält Spotify hier lautlos am Laufen; zählt Wiedergaben auf deinem Konto</string><string name="action_attest">Beweisen, dass dies Myspoti ist</string>+ <string name="action_ui_style">Aussehen ändern</string><string name="mirror_indicator">Spotify gespiegelt von %1$s</string></resources>diff --git a/base/app/src/main/res/values-el/myspoti_strings.xml b/base/app/src/main/res/values-el/myspoti_strings.xmlindex ab13d0ff..e7ce3087 100644--- a/base/app/src/main/res/values-el/myspoti_strings.xml+++ b/base/app/src/main/res/values-el/myspoti_strings.xml@@ -555,6 +555,12 @@<string name="settings_player_source_detail">Η γραμμή που λέει τι παίζει και πώς. Απενεργοποιημένη, η Ποιότητα ήχου και το Stats for nerds είναι στο μενού.</string><string name="settings_player_capsule_title">Κάψουλα στο πρόγραμμα αναπαραγωγής</string><string name="settings_player_capsule_detail">Τα κουμπιά στο κάτω μέρος. Απενεργοποιημένη, το «Ακρόαση σε» είναι στο μενού.</string>+ <string name="settings_song_pip_title">Εικόνα σε εικόνα</string>+ <string name="settings_song_pip_detail">Όταν φεύγετε από την εφαρμογή ενώ παίζει ένα τραγούδι, μένει σε ένα μικρό παράθυρο: εξώφυλλο, στίχοι και κουμπιά αναπαραγωγής. Ένα μουσικό βίντεο έχει το δικό του παράθυρο.</string>+ <string name="pip_previous">Προηγούμενο</string>+ <string name="pip_play">Αναπαραγωγή</string>+ <string name="pip_pause">Παύση</string>+ <string name="pip_next">Επόμενο</string><string name="downloads_need_source">Οι λήψεις χρειάζονται μια επέκταση πηγής. Εγκαταστήστε μία στις Ρυθμίσεις, Επεκτάσεις.</string><string name="downloads_source_row_title">Πηγή λήψεων</string><string name="downloads_source_row_on">Μια επέκταση παρέχει τα αρχεία. Πατήστε για διαχείριση των επεκτάσεων.</string>diff --git a/base/app/src/main/res/values-el/security_strings.xml b/base/app/src/main/res/values-el/security_strings.xmlindex b74cd1e6..b864c44b 100644--- a/base/app/src/main/res/values-el/security_strings.xml+++ b/base/app/src/main/res/values-el/security_strings.xml@@ -2,5 +2,6 @@<resources><string name="action_playback_mirror">Κρατά το Spotify να παίζει αθόρυβα εδώ· μετρά ακροάσεις στον λογαριασμό σας</string><string name="action_attest">Απόδειξη ότι είναι το Myspoti</string>+ <string name="action_ui_style">Αλλαγή εμφάνισης</string><string name="mirror_indicator">Spotify σε αντικατοπτρισμό από %1$s</string></resources>diff --git a/base/app/src/main/res/values-es/myspoti_strings.xml b/base/app/src/main/res/values-es/myspoti_strings.xmlindex b37c760d..898723cb 100644--- a/base/app/src/main/res/values-es/myspoti_strings.xml+++ b/base/app/src/main/res/values-es/myspoti_strings.xml@@ -555,6 +555,12 @@<string name="settings_player_source_detail">La línea que dice qué suena y cómo. Desactivada, Calidad de sonido y Stats for nerds están en el menú del reproductor.</string><string name="settings_player_capsule_title">Cápsula en el reproductor</string><string name="settings_player_capsule_detail">Los botones de la parte inferior del reproductor. Desactivada, Escuchar en está en el menú del reproductor.</string>+ <string name="settings_song_pip_title">Imagen en imagen</string>+ <string name="settings_song_pip_detail">Al salir de la app mientras suena una canción, sigue en una ventana pequeña: portada, letra y botones de reproducción. Un videoclip tiene su propia ventana.</string>+ <string name="pip_previous">Anterior</string>+ <string name="pip_play">Reproducir</string>+ <string name="pip_pause">Pausa</string>+ <string name="pip_next">Siguiente</string><string name="downloads_need_source">Las descargas necesitan una extensión de origen. Instala una en Ajustes, Extensiones.</string><string name="downloads_source_row_title">Origen de descargas</string><string name="downloads_source_row_on">Una extensión proporciona los archivos. Toca para gestionar las extensiones.</string>diff --git a/base/app/src/main/res/values-es/security_strings.xml b/base/app/src/main/res/values-es/security_strings.xmlindex a15d8ca1..bc3aeef9 100644--- a/base/app/src/main/res/values-es/security_strings.xml+++ b/base/app/src/main/res/values-es/security_strings.xml@@ -2,5 +2,6 @@<resources><string name="action_playback_mirror">Mantiene Spotify sonando en silencio aquí; cuenta reproducciones en tu cuenta</string><string name="action_attest">Demostrar que es Myspoti</string>+ <string name="action_ui_style">Cambiar el aspecto</string><string name="mirror_indicator">Spotify reflejado por %1$s</string></resources>diff --git a/base/app/src/main/res/values-fr/myspoti_strings.xml b/base/app/src/main/res/values-fr/myspoti_strings.xmlindex 356bb985..cb54bc67 100644--- a/base/app/src/main/res/values-fr/myspoti_strings.xml+++ b/base/app/src/main/res/values-fr/myspoti_strings.xml@@ -562,6 +562,12 @@<string name="settings_player_source_detail">La ligne qui dit ce qui joue et comment. Désactivée, Qualité du son et Stats for nerds sont dans le menu du lecteur.</string><string name="settings_player_capsule_title">Capsule dans le lecteur</string><string name="settings_player_capsule_detail">Les boutons en bas du lecteur. Désactivée, Écouter sur est dans le menu du lecteur.</string>+ <string name="settings_song_pip_title">Image dans l\'image</string>+ <string name="settings_song_pip_detail">Quitter l\'app pendant la lecture garde le titre dans une petite fenêtre : pochette, paroles et boutons de lecture. Un clip a sa propre fenêtre.</string>+ <string name="pip_previous">Précédent</string>+ <string name="pip_play">Lecture</string>+ <string name="pip_pause">Pause</string>+ <string name="pip_next">Suivant</string><string name="downloads_need_source">Les téléchargements ont besoin d\'une extension source. Installez-en une dans Réglages, Extensions.</string><string name="downloads_source_row_title">Source des téléchargements</string><string name="downloads_source_row_on">Une extension fournit les fichiers. Touchez pour gérer les extensions.</string>diff --git a/base/app/src/main/res/values-fr/security_strings.xml b/base/app/src/main/res/values-fr/security_strings.xmlindex 217dc2f1..087ea4d8 100644--- a/base/app/src/main/res/values-fr/security_strings.xml+++ b/base/app/src/main/res/values-fr/security_strings.xml@@ -2,5 +2,6 @@<resources><string name="action_playback_mirror">Garde Spotify en lecture silencieuse ici ; compte des écoutes sur votre compte</string><string name="action_attest">Prouver que c\'est Myspoti</string>+ <string name="action_ui_style">Changer l\'apparence</string><string name="mirror_indicator">Spotify en miroir par %1$s</string></resources>diff --git a/base/app/src/main/res/values-it/myspoti_strings.xml b/base/app/src/main/res/values-it/myspoti_strings.xmlindex 48b25a90..02583fb0 100644--- a/base/app/src/main/res/values-it/myspoti_strings.xml+++ b/base/app/src/main/res/values-it/myspoti_strings.xml@@ -555,6 +555,12 @@<string name="settings_player_source_detail">La riga che dice cosa suona e come. Disattivata, Qualità audio e Stats for nerds sono nel menu del lettore.</string><string name="settings_player_capsule_title">Capsula nel lettore</string><string name="settings_player_capsule_detail">I pulsanti in fondo al lettore. Disattivata, Ascolta su è nel menu del lettore.</string>+ <string name="settings_song_pip_title">Picture-in-picture</string>+ <string name="settings_song_pip_detail">Uscendo dall\'app mentre suona un brano, resta in una piccola finestra: copertina, testo e pulsanti di riproduzione. Un video musicale ha la sua finestra.</string>+ <string name="pip_previous">Precedente</string>+ <string name="pip_play">Riproduci</string>+ <string name="pip_pause">Pausa</string>+ <string name="pip_next">Successivo</string><string name="downloads_need_source">I download richiedono un\'estensione sorgente. Installane una in Impostazioni, Estensioni.</string><string name="downloads_source_row_title">Sorgente dei download</string><string name="downloads_source_row_on">Un\'estensione fornisce i file. Tocca per gestire le estensioni.</string>diff --git a/base/app/src/main/res/values-it/security_strings.xml b/base/app/src/main/res/values-it/security_strings.xmlindex 490a48e2..a1ed6ec3 100644--- a/base/app/src/main/res/values-it/security_strings.xml+++ b/base/app/src/main/res/values-it/security_strings.xml@@ -2,5 +2,6 @@<resources><string name="action_playback_mirror">Mantiene Spotify in riproduzione silenziosa qui; conta gli ascolti sul tuo account</string><string name="action_attest">Dimostrare che è Myspoti</string>+ <string name="action_ui_style">Cambiare l\'aspetto</string><string name="mirror_indicator">Spotify rispecchiato da %1$s</string></resources>diff --git a/base/app/src/main/res/values-pl/myspoti_strings.xml b/base/app/src/main/res/values-pl/myspoti_strings.xmlindex 956fb4e8..c509860b 100644--- a/base/app/src/main/res/values-pl/myspoti_strings.xml+++ b/base/app/src/main/res/values-pl/myspoti_strings.xml@@ -577,6 +577,12 @@<string name="settings_player_source_detail">Wiersz mówiący, co gra i jak. Wyłączony: Jakość dźwięku i Stats for nerds są w menu odtwarzacza.</string><string name="settings_player_capsule_title">Kapsuła w odtwarzaczu</string><string name="settings_player_capsule_detail">Przyciski na dole odtwarzacza. Wyłączona: Słuchaj na jest w menu odtwarzacza.</string>+ <string name="settings_song_pip_title">Obraz w obrazie</string>+ <string name="settings_song_pip_detail">Po wyjściu z aplikacji podczas odtwarzania utwór zostaje w małym oknie: okładka, tekst i przyciski odtwarzania. Teledysk ma własne okno.</string>+ <string name="pip_previous">Poprzedni</string>+ <string name="pip_play">Odtwórz</string>+ <string name="pip_pause">Pauza</string>+ <string name="pip_next">Następny</string><string name="downloads_need_source">Pobieranie wymaga rozszerzenia źródłowego. Zainstaluj je w Ustawieniach, Rozszerzenia.</string><string name="downloads_source_row_title">Źródło pobierania</string><string name="downloads_source_row_on">Pliki dostarcza rozszerzenie. Dotknij, aby zarządzać rozszerzeniami.</string>diff --git a/base/app/src/main/res/values-pl/security_strings.xml b/base/app/src/main/res/values-pl/security_strings.xmlindex 6dce23b1..8d299753 100644--- a/base/app/src/main/res/values-pl/security_strings.xml+++ b/base/app/src/main/res/values-pl/security_strings.xml@@ -2,5 +2,6 @@<resources><string name="action_playback_mirror">Utrzymuje ciche odtwarzanie Spotify tutaj; liczy odtworzenia na Twoim koncie</string><string name="action_attest">Potwierdzić, że to Myspoti</string>+ <string name="action_ui_style">Zmienić wygląd</string><string name="mirror_indicator">Spotify odzwierciedlane przez %1$s</string></resources>diff --git a/base/app/src/main/res/values-pt-rBR/myspoti_strings.xml b/base/app/src/main/res/values-pt-rBR/myspoti_strings.xmlindex fc4d2cf0..8161f129 100644--- a/base/app/src/main/res/values-pt-rBR/myspoti_strings.xml+++ b/base/app/src/main/res/values-pt-rBR/myspoti_strings.xml@@ -566,6 +566,12 @@<string name="settings_player_source_detail">A linha que diz o que está tocando e como. Desativada, Qualidade do som e Stats for nerds ficam no menu do player.</string><string name="settings_player_capsule_title">Cápsula no player</string><string name="settings_player_capsule_detail">Os botões na parte de baixo do player. Desativada, Ouvir em fica no menu do player.</string>+ <string name="settings_song_pip_title">Picture-in-picture</string>+ <string name="settings_song_pip_detail">Ao sair do app enquanto uma música toca, ela fica em uma janela pequena: capa, letra e botões de reprodução. Um videoclipe tem sua própria janela.</string>+ <string name="pip_previous">Anterior</string>+ <string name="pip_play">Tocar</string>+ <string name="pip_pause">Pausar</string>+ <string name="pip_next">Próxima</string><string name="downloads_need_source">Os downloads precisam de uma extensão de fonte. Instale uma em Configurações, Extensões.</string><string name="downloads_source_row_title">Fonte de downloads</string><string name="downloads_source_row_on">Uma extensão fornece os arquivos. Toque para gerenciar as extensões.</string>diff --git a/base/app/src/main/res/values-pt-rBR/security_strings.xml b/base/app/src/main/res/values-pt-rBR/security_strings.xmlindex 67b2b2bc..bb3aa61c 100644--- a/base/app/src/main/res/values-pt-rBR/security_strings.xml+++ b/base/app/src/main/res/values-pt-rBR/security_strings.xml@@ -2,5 +2,6 @@<resources><string name="action_playback_mirror">Mantém o Spotify tocando em silêncio aqui; conta reproduções na sua conta</string><string name="action_attest">Provar que é o Myspoti</string>+ <string name="action_ui_style">Mudar a aparência</string><string name="mirror_indicator">Spotify espelhado por %1$s</string></resources>diff --git a/base/app/src/main/res/values-pt-rPT/security_strings.xml b/base/app/src/main/res/values-pt-rPT/security_strings.xmlindex a0476848..44420656 100644--- a/base/app/src/main/res/values-pt-rPT/security_strings.xml+++ b/base/app/src/main/res/values-pt-rPT/security_strings.xml@@ -2,5 +2,6 @@<resources><string name="action_playback_mirror">Mantém o Spotify a tocar em silêncio aqui; conta reproduções na sua conta</string><string name="action_attest">Provar que é o Myspoti</string>+ <string name="action_ui_style">Mudar o aspeto</string><string name="mirror_indicator">Spotify espelhado por %1$s</string></resources>diff --git a/base/app/src/main/res/values-pt/myspoti_strings.xml b/base/app/src/main/res/values-pt/myspoti_strings.xmlindex 2e1786a1..e061620a 100644--- a/base/app/src/main/res/values-pt/myspoti_strings.xml+++ b/base/app/src/main/res/values-pt/myspoti_strings.xml@@ -555,6 +555,12 @@<string name="settings_player_source_detail">A linha que diz o que toca e como. Desativada, Qualidade do som e Stats for nerds ficam no menu do leitor.</string><string name="settings_player_capsule_title">Cápsula no leitor</string><string name="settings_player_capsule_detail">Os botões na parte de baixo do leitor. Desativada, Ouvir em fica no menu do leitor.</string>+ <string name="settings_song_pip_title">Imagem na imagem</string>+ <string name="settings_song_pip_detail">Ao sair da app enquanto uma música toca, ela fica numa pequena janela: capa, letra e botões de reprodução. Um videoclipe tem a sua própria janela.</string>+ <string name="pip_previous">Anterior</string>+ <string name="pip_play">Reproduzir</string>+ <string name="pip_pause">Pausa</string>+ <string name="pip_next">Seguinte</string><string name="downloads_need_source">Os downloads precisam de uma extensão de origem. Instale uma em Configurações, Extensões.</string><string name="downloads_source_row_title">Origem dos downloads</string><string name="downloads_source_row_on">Uma extensão fornece os arquivos. Toque para gerenciar as extensões.</string>diff --git a/base/app/src/main/res/values-pt/security_strings.xml b/base/app/src/main/res/values-pt/security_strings.xmlindex 67b2b2bc..f02c88fe 100644--- a/base/app/src/main/res/values-pt/security_strings.xml+++ b/base/app/src/main/res/values-pt/security_strings.xml@@ -2,5 +2,6 @@<resources><string name="action_playback_mirror">Mantém o Spotify tocando em silêncio aqui; conta reproduções na sua conta</string><string name="action_attest">Provar que é o Myspoti</string>+ <string name="action_ui_style">Mudar o aspeto</string><string name="mirror_indicator">Spotify espelhado por %1$s</string></resources>diff --git a/base/app/src/main/res/values-ru/myspoti_strings.xml b/base/app/src/main/res/values-ru/myspoti_strings.xmlindex 089ac9eb..3f18ae68 100644--- a/base/app/src/main/res/values-ru/myspoti_strings.xml+++ b/base/app/src/main/res/values-ru/myspoti_strings.xml@@ -577,6 +577,12 @@<string name="settings_player_source_detail">Строка о том, что и как играет. Если выключено, «Качество звука» и Stats for nerds — в меню плеера.</string><string name="settings_player_capsule_title">Капсула в плеере</string><string name="settings_player_capsule_detail">Кнопки внизу плеера. Если выключено, «Слушать на» — в меню плеера.</string>+ <string name="settings_song_pip_title">Картинка в картинке</string>+ <string name="settings_song_pip_detail">Если выйти из приложения во время воспроизведения, трек останется в маленьком окне: обложка, текст и кнопки управления. У клипа своё окно.</string>+ <string name="pip_previous">Предыдущий</string>+ <string name="pip_play">Воспроизвести</string>+ <string name="pip_pause">Пауза</string>+ <string name="pip_next">Следующий</string><string name="downloads_need_source">Для загрузок нужно расширение-источник. Установите его в разделе «Настройки», «Расширения».</string><string name="downloads_source_row_title">Источник загрузок</string><string name="downloads_source_row_on">Файлы предоставляет расширение. Нажмите, чтобы управлять расширениями.</string>diff --git a/base/app/src/main/res/values-ru/security_strings.xml b/base/app/src/main/res/values-ru/security_strings.xmlindex 002aa4d4..725aca17 100644--- a/base/app/src/main/res/values-ru/security_strings.xml+++ b/base/app/src/main/res/values-ru/security_strings.xml@@ -2,5 +2,6 @@<resources><string name="action_playback_mirror">Тихо воспроизводит Spotify здесь; засчитывает прослушивания в вашем аккаунте</string><string name="action_attest">Подтвердить, что это Myspoti</string>+ <string name="action_ui_style">Менять оформление</string><string name="mirror_indicator">Spotify зеркалируется: %1$s</string></resources>diff --git a/base/app/src/main/res/values-zh/myspoti_strings.xml b/base/app/src/main/res/values-zh/myspoti_strings.xmlindex 272cb356..7e96c3fd 100644--- a/base/app/src/main/res/values-zh/myspoti_strings.xml+++ b/base/app/src/main/res/values-zh/myspoti_strings.xml@@ -568,6 +568,12 @@<string name="settings_player_source_detail">说明正在播放什么以及如何播放的那一行。关闭后,“音质”和 Stats for nerds 在播放器菜单中。</string><string name="settings_player_capsule_title">播放器中的胶囊按钮</string><string name="settings_player_capsule_detail">播放器底部的按钮。关闭后,“在…上收听”在播放器菜单中。</string>+ <string name="settings_song_pip_title">画中画</string>+ <string name="settings_song_pip_detail">播放歌曲时离开应用,歌曲会显示在小窗口中:封面、歌词和播放按钮。音乐视频有自己的窗口。</string>+ <string name="pip_previous">上一首</string>+ <string name="pip_play">播放</string>+ <string name="pip_pause">暂停</string>+ <string name="pip_next">下一首</string><string name="downloads_need_source">下载需要一个来源扩展。请在“设置”>“扩展”中安装一个。</string><string name="downloads_source_row_title">下载来源</string><string name="downloads_source_row_on">由扩展提供文件。点按以管理扩展。</string>diff --git a/base/app/src/main/res/values-zh/security_strings.xml b/base/app/src/main/res/values-zh/security_strings.xmlindex d525d44a..e90a3086 100644--- a/base/app/src/main/res/values-zh/security_strings.xml+++ b/base/app/src/main/res/values-zh/security_strings.xml@@ -2,5 +2,6 @@<resources><string name="action_playback_mirror">在此静音播放 Spotify;会在你的账户上计入收听次数</string><string name="action_attest">证明这是 Myspoti</string>+ <string name="action_ui_style">更改外观</string><string name="mirror_indicator">Spotify 由 %1$s 镜像</string></resources>diff --git a/base/app/src/main/res/values/myspoti_strings.xml b/base/app/src/main/res/values/myspoti_strings.xmlindex 98921864..ff5198cb 100644--- a/base/app/src/main/res/values/myspoti_strings.xml+++ b/base/app/src/main/res/values/myspoti_strings.xml@@ -582,6 +582,12 @@<string name="settings_player_source_detail">The line that says what plays and how. Off, Sound quality and Stats for nerds are in the player\'s menu.</string><string name="settings_player_capsule_title">Capsule in the player</string><string name="settings_player_capsule_detail">The buttons at the bottom of the player. Off, Listen on is in the player\'s menu.</string>+ <string name="settings_song_pip_title">Picture-in-picture</string>+ <string name="settings_song_pip_detail">Leaving the app while a song plays keeps it in a small window: cover, lyrics and playback buttons. A music video has its own window.</string>+ <string name="pip_previous">Previous</string>+ <string name="pip_play">Play</string>+ <string name="pip_pause">Pause</string>+ <string name="pip_next">Next</string><string name="downloads_need_source">Downloads need a source extension. Install one in Settings, Extensions.</string><string name="downloads_source_row_title">Download source</string><string name="downloads_source_row_on">An extension gives the files. Tap to manage extensions.</string>diff --git a/base/app/src/main/res/values/security_strings.xml b/base/app/src/main/res/values/security_strings.xmlindex 4a04269f..96cef6cb 100644--- a/base/app/src/main/res/values/security_strings.xml+++ b/base/app/src/main/res/values/security_strings.xml@@ -2,5 +2,6 @@<resources><string name="action_playback_mirror">Keeps Spotify playing silently here; counts listens on your account</string><string name="action_attest">Prove this is Myspoti</string>+ <string name="action_ui_style">Change the look</string><string name="mirror_indicator">Spotify mirrored by %1$s</string></resources>diff --git a/base/extensions-cli/src/main/kotlin/app/myspoti/extensions/cli/Run.kt b/base/extensions-cli/src/main/kotlin/app/myspoti/extensions/cli/Run.ktindex 96cf7e53..aaa0961f 100644--- a/base/extensions-cli/src/main/kotlin/app/myspoti/extensions/cli/Run.kt+++ b/base/extensions-cli/src/main/kotlin/app/myspoti/extensions/cli/Run.kt@@ -170,6 +170,7 @@ private fun check(dir: File) {val fieldProblems = m.settingFieldProblems()fieldProblems.forEach { println("✗ $it") }m.settingFieldWarnings().forEach { println("! $it") }+ m.uiWarnings().forEach { println("! $it") }problems.forEach { println("✗ $it") }if (m.isLegacy) println("! old format (provides + permissions): it still installs, mapped to actions; write \"actions\" instead (docs/extensions/API.md §2)")val granted = m.asks().map { it.key }.toSet()diff --git a/base/extensions/src/main/kotlin/app/myspoti/extensions/Actions.kt b/base/extensions/src/main/kotlin/app/myspoti/extensions/Actions.ktindex 9eab5883..81524ac1 100644--- a/base/extensions/src/main/kotlin/app/myspoti/extensions/Actions.kt+++ b/base/extensions/src/main/kotlin/app/myspoti/extensions/Actions.kt@@ -94,6 +94,8 @@ enum class Action("myspoti.auth.open({ url, callback }) → myspoti.on('auth'): a full web view with its own cookies, apart from the app's; only the callback address comes back"),STORAGE("storage", Level.NORMAL, null, "Save", "Keep its own data","myspoti.storage get/set/remove (512 KB)"),+ UI_STYLE("ui.style", Level.NORMAL, Area.OTHER, "Palette", "Change the look",+ "manifest \"ui\": colours, hidden parts, tab order, text size and Home blocks, applied by the app (never on protected surfaces)", takeover = true),ATTEST("attest", Level.NORMAL, null, "Fingerprint", "Prove this is Myspoti","myspoti.attest enroll/publicKey/sign/reset: a signing key of its own in this phone's hardware keystore, so its server can tell its requests come from a genuine Myspoti install");diff --git a/base/extensions/src/main/kotlin/app/myspoti/extensions/Manifest.kt b/base/extensions/src/main/kotlin/app/myspoti/extensions/Manifest.ktindex 0e41bb87..d7dea98b 100644--- a/base/extensions/src/main/kotlin/app/myspoti/extensions/Manifest.kt+++ b/base/extensions/src/main/kotlin/app/myspoti/extensions/Manifest.kt@@ -69,6 +69,11 @@ data class Manifest(val replaces: List<String> = emptyList(),/** Extensions (ids) that must not run with this one: the user is asked which to keep. */val conflictsWith: List<String> = emptyList(),+ /**+ * `ui`: the look it gives the app ([UiStyle]), applied with the `ui.style` action. Ignored+ * without it (and by an older Myspoti).+ */+ val ui: UiStyle? = null,/*** The texts shown to people in other languages, by BCP 47 tag (`"fr"`, `"pt-BR"`): any of* `name`, `description`, `changelog`, `welcome`, an action's reason (`actions`: name → why) and@@ -275,6 +280,10 @@ data class Manifest(}if (actions.size != actions.map { it.name }.toSet().size) add("actions: an action listed twice")if (settings.isNotEmpty() && actions.none { it.name == Action.SETTINGS_PAGE.key }) add("settings: add the settings.page action (with its why) to have a settings page")+ if (actions.any { it.name == Action.UI_STYLE.key }) {+ if (ui == null) add("ui.style: describe the look in \"ui\" (colors, hide, order, styles, blocks)")+ else addAll(ui.problems())+ }}/** The rules of an old manifest, as they were: it still installs, mapped to actions. */@@ -334,6 +343,16 @@ data class Manifest(}}+ /** What is left aside in `ui`, or `ui` without the `ui.style` action, for `myspoti-ext check`: never a reason to refuse. */+ fun uiWarnings(): List<String> = when {+ ui == null -> emptyList()+ !declares(Action.UI_STYLE) -> listOf("ui: ignored without the ui.style action")+ else -> ui.warnings()+ }++ /** The look it gives the app, when it asks for it (`ui.style` and `ui`). */+ fun look(): UiStyle? = ui?.takeIf { declares(Action.UI_STYLE) }+/** Where the store files it: the declared category if its actions fit it, else [Category.OTHER]. */fun category(): Category = Category.of(category, actionSet())diff --git a/base/extensions/src/main/kotlin/app/myspoti/extensions/Store.kt b/base/extensions/src/main/kotlin/app/myspoti/extensions/Store.ktindex 1e7527f5..d3edc599 100644--- a/base/extensions/src/main/kotlin/app/myspoti/extensions/Store.kt+++ b/base/extensions/src/main/kotlin/app/myspoti/extensions/Store.kt@@ -26,7 +26,7 @@ enum class Category(val key: String) {LIBRARY -> setOf(Action.LIBRARY_READ, Action.LIBRARY_WRITE, Action.PLAYLISTS_WRITE)DISCOVERY -> setOf(Action.HOME_SECTIONS, Action.SEARCH_PROVIDE, Action.SPOTIFY_CATALOG)STATS -> setOf(Action.PLAYBACK_EVENTS, Action.LIBRARY_READ)- LOOK -> Action.BLOCKS + Action.WEBVIEW_PAGE+ LOOK -> Action.BLOCKS + Action.WEBVIEW_PAGE + Action.UI_STYLESOCIAL -> setOf(Action.NETWORK, Action.LIBRARY_READ, Action.SPOTIFY_CATALOG)TOOLS, OTHER -> emptySet()}diff --git a/base/extensions/src/main/kotlin/app/myspoti/extensions/UiStyle.kt b/base/extensions/src/main/kotlin/app/myspoti/extensions/UiStyle.ktnew file mode 100644index 00000000..5b73bec3--- /dev/null+++ b/base/extensions/src/main/kotlin/app/myspoti/extensions/UiStyle.kt@@ -0,0 +1,152 @@+package app.myspoti.extensions++import kotlinx.serialization.Serializable+import kotlinx.serialization.json.JsonElement+import kotlinx.serialization.json.JsonPrimitive+import kotlinx.serialization.json.doubleOrNull++/**+ * The manifest's `ui`: what a look-only extension ([Action.UI_STYLE]) changes in the app, all+ * declared, nothing drawn by the extension. The app applies it on its pages and never on a+ * [ProtectedSurface]: while one is on screen the whole app is back to its own look.+ *+ * - [colors]: `accent`, `background`, `surface`, as `#RRGGBB` (or `#AARRGGBB`, opaque only for the+ * backgrounds). A background or surface too light for the app's white text is not applied.+ * - [hide]: parts of the app the user can also hide in Settings ([UiPart]).+ * - [order]: `nav`, the Classic look's bottom tabs (`home`, `search`, `library`).+ * - [styles]: CSS-like rules, a selector and its properties: `text` { `scale` 0.85 to 1.3 }.+ * - [blocks]: `home`, native blocks ([Blocks]) shown on Home under the extension's name.+ *+ * Unknown colours, parts, orders, selectors and properties are ignored (a newer extension on an+ * older app), `myspoti-ext check` tells the author ([warnings]).+ */+@Serializable+data class UiStyle(+ val colors: Map<String, String> = emptyMap(),+ val hide: List<String> = emptyList(),+ val order: Map<String, List<String>> = emptyMap(),+ val styles: Map<String, Map<String, JsonElement>> = emptyMap(),+ val blocks: Map<String, JsonElement> = emptyMap(),+) {+ /** Every reason this `ui` cannot be installed (empty: it can). */+ fun problems(): List<String> = buildList {+ if (colors.isEmpty() && hide.isEmpty() && order.isEmpty() && styles.isEmpty() && blocks.isEmpty())+ add("ui: nothing to change (colors, hide, order, styles or blocks)")+ colors.forEach { (k, v) -> if (k in COLORS && argb(v) == null) add("ui.colors.$k \"$v\": a colour like #1ED760 or #CC1ED760") }+ if (hide.size > 20) add("ui.hide: 20 parts at most")+ order[NAV]?.let { tabs ->+ if (tabs.toSet() != NAV_TABS.toSet() || tabs.size != NAV_TABS.size) add("ui.order.nav: each of ${NAV_TABS.joinToString()} once")+ }+ styles[TEXT]?.get(SCALE)?.let { s ->+ val v = (s as? JsonPrimitive)?.doubleOrNull+ if (v == null || v < MIN_SCALE || v > MAX_SCALE) add("ui.styles.text.scale: a number from $MIN_SCALE to $MAX_SCALE")+ }+ blocks[HOME]?.let { b ->+ runCatching { Blocks.parse(b.toString(), Surface.HOME) }.exceptionOrNull()?.let { add("ui.blocks.home: ${it.message}") }+ }+ }++ /** What this Myspoti does not know and leaves aside: told to the author, never a reason to refuse. */+ fun warnings(): List<String> = buildList {+ (colors.keys - COLORS).forEach { add("ui.colors.$it: unknown (known: ${COLORS.joinToString()}), ignored") }+ hide.filter { UiPart.of(it) == null }.forEach { add("ui.hide \"$it\": unknown (known: ${UiPart.entries.joinToString { p -> p.key }}), ignored") }+ (order.keys - NAV).forEach { add("ui.order.$it: unknown (known: $NAV), ignored") }+ (styles.keys - TEXT).forEach { add("ui.styles.$it: unknown selector (known: $TEXT), ignored") }+ styles[TEXT]?.keys?.minus(SCALE)?.forEach { add("ui.styles.text.$it: unknown property (known: $SCALE), ignored") }+ (blocks.keys - HOME).forEach { add("ui.blocks.$it: unknown place (known: $HOME), ignored") }+ }++ companion object {+ const val ACCENT = "accent"+ const val BACKGROUND = "background"+ const val SURFACE = "surface"+ val COLORS = setOf(ACCENT, BACKGROUND, SURFACE)+ const val NAV = "nav"+ val NAV_TABS = listOf("home", "search", "library")+ const val TEXT = "text"+ const val SCALE = "scale"+ const val HOME = "home"+ const val MIN_SCALE = 0.85+ const val MAX_SCALE = 1.3++ /** Brighter than this (relative luminance), a background would hide the app's white text. */+ const val MAX_BACKGROUND_LUMINANCE = 0.2++ private val HEX = Regex("^#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$")++ /** `#RRGGBB` or `#AARRGGBB` as an ARGB int, or null. */+ fun argb(text: String): Int? {+ if (!HEX.matches(text)) return null+ val v = text.substring(1).toLong(16)+ return (if (text.length == 7) v or 0xFF000000 else v).toInt()+ }++ /** The relative luminance of an opaque [argb] colour, 0 (black) to 1 (white). */+ fun luminance(argb: Int): Double {+ fun ch(shift: Int): Double {+ val c = ((argb shr shift) and 0xFF) / 255.0+ return if (c <= 0.03928) c / 12.92 else Math.pow((c + 0.055) / 1.055, 2.4)+ }+ return 0.2126 * ch(16) + 0.7152 * ch(8) + 0.0722 * ch(0)+ }+ }+}++/** The parts a look may hide: each one the user can also turn off in Settings > Display. */+enum class UiPart(val key: String) {+ /** Spotify's DJ on Home. */+ HOME_DJ("home.dj"),+ /** The lyrics card under the Classic player. */+ PLAYER_LYRICS_CARD("player.lyrics-card"),+ /** The line under the player's title that says what plays and how. */+ PLAYER_SOURCE("player.source"),+ /** The capsule at the bottom of the Immersive player. */+ PLAYER_CAPSULE("player.capsule");++ companion object {+ fun of(key: String) = entries.firstOrNull { it.key == key }+ }+}++/**+ * The looks of the enabled extensions as the app applies them: for each colour, order and style,+ * the first extension in the user's order that sets it wins; hidden parts add up; Home blocks are+ * each extension's own ([homeBlocks], by id).+ */+data class AppliedLook(+ val colors: Map<String, Int> = emptyMap(),+ val hidden: Set<UiPart> = emptySet(),+ val navOrder: List<String>? = null,+ val textScale: Float? = null,+ val homeBlocks: List<Pair<String, String>> = emptyList(),+) {+ companion object {+ val NONE = AppliedLook()++ /** [looks]: (extension id, its `ui`), in the user's order. Values a manifest check would refuse are skipped. */+ fun of(looks: List<Pair<String, UiStyle>>): AppliedLook {+ val colors = LinkedHashMap<String, Int>()+ val hidden = LinkedHashSet<UiPart>()+ var nav: List<String>? = null+ var scale: Float? = null+ val home = ArrayList<Pair<String, String>>()+ for ((id, ui) in looks) {+ ui.colors.forEach { (k, v) ->+ if (k !in UiStyle.COLORS || k in colors) return@forEach+ val c = UiStyle.argb(v) ?: return@forEach+ if (k != UiStyle.ACCENT) {+ // A page must be opaque and dark enough for white text.+ if ((c ushr 24) != 0xFF || UiStyle.luminance(c) > UiStyle.MAX_BACKGROUND_LUMINANCE) return@forEach+ }+ colors[k] = c+ }+ ui.hide.mapNotNullTo(hidden) { UiPart.of(it) }+ if (nav == null) ui.order[UiStyle.NAV]?.takeIf { it.size == UiStyle.NAV_TABS.size && it.toSet() == UiStyle.NAV_TABS.toSet() }?.let { nav = it }+ if (scale == null) ((ui.styles[UiStyle.TEXT]?.get(UiStyle.SCALE) as? JsonPrimitive)?.doubleOrNull)+ ?.takeIf { it in UiStyle.MIN_SCALE..UiStyle.MAX_SCALE }?.let { scale = it.toFloat() }+ ui.blocks[UiStyle.HOME]?.let { home += id to it.toString() }+ }+ return AppliedLook(colors, hidden, nav, scale, home)+ }+ }+}diff --git a/base/extensions/src/test/kotlin/app/myspoti/extensions/ActionsTest.kt b/base/extensions/src/test/kotlin/app/myspoti/extensions/ActionsTest.ktindex 7e125edc..3759a0d3 100644--- a/base/extensions/src/test/kotlin/app/myspoti/extensions/ActionsTest.kt+++ b/base/extensions/src/test/kotlin/app/myspoti/extensions/ActionsTest.kt@@ -31,7 +31,7 @@ class ActionsTest {// ── The catalogue ──@Test fun theCatalogueIsClosedAndComplete() {- assertEquals(24, Action.entries.size)+ assertEquals(25, Action.entries.size)assertEquals(Action.entries.size, Action.entries.map { it.key }.toSet().size)assertEquals(setOf("audio.source", "download.source", "library.write", "playlists.write", "spotify.raw", "webview.page", "webview.auth", "playback.mirror"),diff --git a/base/extensions/src/test/kotlin/app/myspoti/extensions/UiStyleTest.kt b/base/extensions/src/test/kotlin/app/myspoti/extensions/UiStyleTest.ktnew file mode 100644index 00000000..fc34a487--- /dev/null+++ b/base/extensions/src/test/kotlin/app/myspoti/extensions/UiStyleTest.kt@@ -0,0 +1,71 @@+package app.myspoti.extensions++import org.junit.Assert.assertEquals+import org.junit.Assert.assertNull+import org.junit.Assert.assertTrue+import org.junit.Test++class UiStyleTest {+ private fun manifest(ui: String?, actions: String = """[{ "name": "ui.style", "why": "A warm orange look" }]""") = Manifest.parse(+ """{ "id": "io.github.you.look", "name": "Look", "version": "1.0", "author": "You", "actions": $actions${ui?.let { ", \"ui\": $it" } ?: ""} }""",+ )++ @Test fun theSampleLookInstalls() {+ val m = manifest(+ """{ "colors": { "accent": "#FF9E3D", "background": "#120B06" }, "hide": ["home.dj"],+ "order": { "nav": ["library", "home", "search"] }, "styles": { "text": { "scale": 1.1 } },+ "blocks": { "home": [{ "type": "text", "text": "Hello", "style": "title" }] } }""",+ )+ assertEquals(emptyList<String>(), m.problems())+ assertEquals(emptyList<String>(), m.uiWarnings())+ assertTrue(Action.UI_STYLE in m.actionSet())+ assertEquals(Category.LOOK, Category.of("look", m.actionSet()))+ }++ @Test fun theActionNeedsAUi() {+ assertTrue(manifest(null).problems().any { it.startsWith("ui.style") })+ assertTrue(manifest("{}").problems().any { it.startsWith("ui: nothing") })+ }++ @Test fun badValuesRefuseTheLook() {+ val p = manifest("""{ "colors": { "accent": "orange" }, "order": { "nav": ["home"] }, "styles": { "text": { "scale": 3 } }, "blocks": { "home": "x" } }""").problems()+ assertTrue(p.toString(), p.any { it.startsWith("ui.colors.accent") })+ assertTrue(p.toString(), p.any { it.startsWith("ui.order.nav") })+ assertTrue(p.toString(), p.any { it.startsWith("ui.styles.text.scale") })+ assertTrue(p.toString(), p.any { it.startsWith("ui.blocks.home") })+ }++ @Test fun unknownThingsAreWarningsNotProblems() {+ val m = manifest("""{ "colors": { "accent": "#FFFFFF", "glow": "#FF0000" }, "hide": ["about"], "styles": { "cover": { "corner": 4 } } }""")+ assertEquals(emptyList<String>(), m.problems())+ assertEquals(3, m.uiWarnings().size)+ }++ @Test fun aUiKeyWithoutTheActionChangesNothing() {+ // Before ui.style, "ui" was an unknown key: a manifest that had one still installs as it did.+ val m = manifest("""{ "colors": { "accent": "nonsense" } }""", """[{ "name": "notify", "why": "Says hello" }]""")+ assertEquals(emptyList<String>(), m.problems())+ assertNull(m.look())+ assertEquals(listOf("ui: ignored without the ui.style action"), m.uiWarnings())+ }++ @Test fun theFirstLookWinsAndLightPagesAreLeftOut() {+ val first = UiStyle(colors = mapOf("accent" to "#FF9E3D", "background" to "#FFFFFF"), hide = listOf("home.dj"))+ val second = UiStyle(colors = mapOf("accent" to "#00FF00", "background" to "#101010", "surface" to "#80202020"), hide = listOf("player.capsule", "nope"),+ order = mapOf("nav" to listOf("search", "home", "library")))+ val look = AppliedLook.of(listOf("a" to first, "b" to second))+ assertEquals(0xFFFF9E3D.toInt(), look.colors["accent"])+ // White is too light for the app's white text; the second one's dark page applies.+ assertEquals(0xFF101010.toInt(), look.colors["background"])+ // A see-through surface is not applied.+ assertNull(look.colors["surface"])+ assertEquals(setOf(UiPart.HOME_DJ, UiPart.PLAYER_CAPSULE), look.hidden)+ assertEquals(listOf("search", "home", "library"), look.navOrder)+ assertNull(look.textScale)+ }++ @Test fun noProtectedSurfaceCanBeHidden() {+ val protectedKeys = ProtectedSurface.entries.map { it.key }.toSet()+ assertTrue(UiPart.entries.none { it.key in protectedKeys || it.key.substringBefore('.') in protectedKeys })+ }+}diff --git a/docs/extensions/API.md b/docs/extensions/API.mdindex 7b67fdc4..252bd766 100644--- a/docs/extensions/API.md+++ b/docs/extensions/API.md@@ -11,6 +11,9 @@ API it unlocks; the user sees them as icons, each with your reason, before instaThis page documents what the build ships (API version 1). Nothing here is a promise aboutanything else.+Look-only extensions (colours, hidden parts, tab order, text size, fixed Home blocks, all declared+in the manifest and applied by the app) are described in [UI-LOOKS.md](UI-LOOKS.md).+Feature-gated media transforms and concurrent source resolution are described in[SOURCE-PIPELINES.md](SOURCE-PIPELINES.md). Providers and recording matching remainextension responsibilities; the host keeps its existing safe media transport.@@ -123,10 +126,11 @@ extensions did there ("Lyrics of X from Y", "Skipped by Z") with a one-tap Turn| `replaces` | string[] | `[]` | Extension ids this one takes the place of (10 at most): installing it offers to turn them off. || `conflictsWith` | string[] | `[]` | Extension ids that must not run with this one (10 at most): the user picks which to keep. Either side declaring it is enough. || `icon` | string | none | A `.png` at the root of the package (square, 256 px or less). Without it, `icon.png` is used if the package has one, else a tile with the name's first letter. |-| `category` | string | `other` | Where the store files it, one of a fixed list: `lyrics` (needs `lyrics.provide` or `trackinfo.provide`), `playback` (Playback & audio: a `playback.*`, `audio.source` or `player.buttons` action), `library` (`library.read`, `library.write` or `playlists.write`), `discovery` (`home.sections`, `search.provide` or `spotify.catalog`), `stats` (`playback.events` or `library.read`), `look` (Look & feel: a blocks action or `webview.page`), `social` (`network`, `library.read` or `spotify.catalog`), `tools`, `other`. A category the actions do not fit, or an unknown one, is filed under `other` (`myspoti-ext check` says so); an extension with `download.source` is always under `tools`. `tags` are shown and found by the search, not filtered on. |+| `category` | string | `other` | Where the store files it, one of a fixed list: `lyrics` (needs `lyrics.provide` or `trackinfo.provide`), `playback` (Playback & audio: a `playback.*`, `audio.source` or `player.buttons` action), `library` (`library.read`, `library.write` or `playlists.write`), `discovery` (`home.sections`, `search.provide` or `spotify.catalog`), `stats` (`playback.events` or `library.read`), `look` (Look & feel: a blocks action, `webview.page` or `ui.style`), `social` (`network`, `library.read` or `spotify.catalog`), `tools`, `other`. A category the actions do not fit, or an unknown one, is filed under `other` (`myspoti-ext check` says so); an extension with `download.source` is always under `tools`. `tags` are shown and found by the search, not filtered on. || `tags` | string[] | `[]` | 8 at most, each 1 to 24 characters: lower case letters, digits, spaces, `-`. The store's search finds them. || `minAppVersion` | string | none | The oldest Myspoti it works on (`"2.0.2"`, `"2.0.2-beta.4"`), compared like semantic versions (a release is newer than its betas). An older Myspoti shows "Requires Myspoti 2.0.2 or newer" and does not install it. || `changelog` | string | `""` | What changed in this version, 2000 characters at most: shown on the store page and before an update. |+| `ui` | object | none | The look the extension gives the app, with the `ui.style` action: see [UI-LOOKS.md](UI-LOOKS.md). Ignored without that action (and by an older app). || `welcome` | object | none | `{ "message": "...", "steps": ["...", "..."] }`, shown once right after the first install (not on updates): what the extension does (600 characters at most) and what is left to do (5 steps at most, 160 characters each). Older apps ignore it. || `translations` | object | `{}` | The texts people see, in other languages, by language tag (`"fr"`, `"pt-BR"`; 80 at most). Below. Older apps ignore it. |@@ -756,6 +760,7 @@ until the user accepts them all with the same tick.| `webview.auth` | Key | Sign in on a website | **critical** | takeover | `myspoti.auth.open`, `auth` event || `storage` | Save | Keep its own data | normal | shared | `myspoti.storage` (512 KB) || `attest` | Fingerprint | Prove this is Myspoti | normal | shared | `myspoti.attest` (section 10) |+| `ui.style` | Palette | Change the look | normal | takeover | manifest `ui`: colours, hidden parts, tab order, text size, Home blocks ([UI-LOOKS.md](UI-LOOKS.md)); never on a protected surface (4.3) |### 4.1 Old manifestsdiff --git a/docs/extensions/UI-LOOKS.md b/docs/extensions/UI-LOOKS.mdnew file mode 100644index 00000000..ee78cc11--- /dev/null+++ b/docs/extensions/UI-LOOKS.md@@ -0,0 +1,132 @@+# Look-only extensions (`ui.style`)++A look-only extension changes how Myspoti looks, nothing else: colours, parts of the app it hides,+the order of the Classic tabs, the text size and a few fixed blocks on Home. Everything is+**declared** in `manifest.json` under `ui`; the extension never draws and needs no code. The app+applies the look on its own pages, with its own fonts, icons and spacing.++It is an ordinary extension package (see [API.md](API.md), sections 1 and 2) with one action,+`ui.style`, and the `ui` object. Everything else in API.md still holds: the install prompt, the+store, `myspoti-ext pack` and `myspoti-ext check`, the switch and the order on the Installed tab.++## 1. A minimal look++`manifest.json`:++```json+{+ "id": "io.github.you.sunset",+ "name": "Sunset",+ "version": "1.0.0",+ "author": "You",+ "category": "look",+ "actions": [+ { "name": "ui.style", "why": "Warm orange colours and Library first" }+ ],+ "ui": {+ "colors": { "accent": "#FF9E3D", "background": "#140C08" },+ "order": { "nav": ["library", "home", "search"] }+ }+}+```++`main.js` is still needed by the package format; for a look it can be a single comment:++```js+// Look only: everything this extension changes is in manifest.json ("ui").+```++A script can live next to the look (an extension may list `ui.style` with any other action, for+example `home.sections`): the look stays declared, whatever the script does.++`docs/extensions/samples/sunset-look` uses every field.++## 2. The `ui` object++Every field is optional, but `ui` must change something. A value the app cannot use refuses the+package (`myspoti-ext check` says why); a name this Myspoti does not know (a colour, a part, a+selector...) is left aside and `check` warns, so a look written for a newer app still installs.++| Field | Type | What it does |+|---|---|---|+| `colors` | object | Colours of the app, as `#RRGGBB` or `#AARRGGBB` (see below). |+| `hide` | string[] | Parts of the app to hide, 20 at most (see below). |+| `order` | object | `nav`: the Classic look's bottom tabs, each of `home`, `search`, `library` once. The Immersive tab bar keeps its own layout. |+| `styles` | object | CSS-like rules: a selector and its properties (see below). |+| `blocks` | object | `home`: native blocks shown on Home under the extension's name. |++### `colors`++| Key | Classic look | Immersive look |+|---|---|---|+| `accent` | The accent (buttons, switches, the selected tab, links) | The accent |+| `background` | The page colour (instead of #121212) | The page colour (instead of black) |+| `surface` | Raised greys (grid tiles, cards) | Raised surfaces (#1C1C1E) |++- The text stays white: a `background` or `surface` that is see-through, or too light for white+ text (relative luminance above 0.2), is not applied. The accent can be any colour.+- The **AMOLED black** setting wins over `background`: the user chose it to save power.+- A look's accent replaces the one chosen in Settings while the extension is on.++### `hide`++Each part is one the user can also turn off in Settings → Display; the switch there keeps the+user's own value, the look only hides on top of it.++| Part | What it hides |+|---|---|+| `home.dj` | Spotify's DJ on Home |+| `player.lyrics-card` | The lyrics card under the Classic player (a swipe up on the cover still opens the lyrics) |+| `player.source` | The line under the player's title that says what plays and how (Sound quality and Stats for nerds move to the player's menu) |+| `player.capsule` | The capsule at the bottom of the Immersive player (Listen on moves to the player's menu) |++### `styles`++A rule is a selector and its properties, as in CSS but from a closed list:++```json+"styles": { "text": { "scale": 1.1 } }+```++| Selector | Property | Values | Effect |+|---|---|---|---|+| `text` | `scale` | 0.85 to 1.3 | All the app's text, on top of the phone's own font size |++### `blocks`++`home`: a list of native blocks, the same as a `home` hook answer (API.md section 3, "Blocks"),+fixed in the manifest: a `card` or `image` that opens a `spotify:` uri, a `text`, a list of+`tracks`, `albums`, `playlists` or `artists`. They are shown with the other extensions' Home+blocks, under "From <your extension>", with the same quotas. A block with an `action` calls the+extension's `tap` hook, so it needs a script that answers it.++```json+"blocks": {+ "home": [+ { "type": "card", "title": "Sunset mix", "subtitle": "Your evening playlist", "open": "spotify:playlist:37i9dQZF1DX6R7QUWePReA" }+ ]+}+```++## 3. Several looks++Looks are applied in the order of the **Pages & more** area on the Installed tab (arrows): for+each colour, the tab order and each style, the highest look that sets it wins; hidden parts add+up; every look's Home blocks are shown. Turning a look off (or uninstalling it) gives the app its+own look back at once.++## 4. What a look cannot do++- Restyle a protected surface (API.md section 4.3): while the donation reminder, the Support+ sheets, the "New version" card, the install prompt, a critical confirmation, the Report button+ or About is on screen, the whole app is back to its own look. No part of `hide` names one.+- Draw anything itself, load a font, an image as a background, or run code from the look.+- Hide the player's controls, the tab bar, Settings or the Extensions screen.++## 5. Compatibility++- `ui.style` and `ui` are new: an older Myspoti refuses a package that lists `ui.style` (an unknown+ action), so set `minAppVersion` to the first release that has it if you publish one.+- A manifest with a `ui` object but without the `ui.style` action installs as before and its `ui`+ is ignored (`check` warns): `ui` was an unknown key until now, and unknown keys are ignored.+- Nothing about the other actions, hooks or the `myspoti` object changed.diff --git a/docs/extensions/samples/sunset-look/main.js b/docs/extensions/samples/sunset-look/main.jsnew file mode 100644index 00000000..76b759f0--- /dev/null+++ b/docs/extensions/samples/sunset-look/main.js@@ -0,0 +1 @@+// Look only: everything this extension changes is in manifest.json ("ui").diff --git a/docs/extensions/samples/sunset-look/manifest.json b/docs/extensions/samples/sunset-look/manifest.jsonnew file mode 100644index 00000000..f4e5c8d4--- /dev/null+++ b/docs/extensions/samples/sunset-look/manifest.json@@ -0,0 +1,23 @@+{+ "id": "app.myspoti.samples.sunsetlook",+ "name": "Sunset look (sample)",+ "version": "1.0.0",+ "versionCode": 1,+ "author": "Myspoti",+ "description": "A sample look-only extension: warm colours, no DJ on Home, Library first in the Classic tabs, slightly larger text and a small card on Home.",+ "category": "look",+ "actions": [+ { "name": "ui.style", "why": "Warm orange colours, Library first, a little larger text" }+ ],+ "ui": {+ "colors": { "accent": "#FF9E3D", "background": "#140C08", "surface": "#2A1A12" },+ "hide": ["home.dj"],+ "order": { "nav": ["library", "home", "search"] },+ "styles": { "text": { "scale": 1.05 } },+ "blocks": {+ "home": [+ { "type": "card", "title": "Sunset mix", "subtitle": "Your evening playlist", "open": "spotify:playlist:37i9dQZF1DX6R7QUWePReA" }+ ]+ }+ }+}