Skip to content

Native Android client for Spotify, built with Jetpack Compose

The player, lyrics and lists redraw without recomposing, the bridge log stops serializing whole tracks, and the docs say what the code does

dacrab2b05d395fb45
diff --git a/README.md b/README.md
index aa37df5c..e80d8144 100644
--- a/README.md
+++ b/README.md
@@ -86,7 +86,7 @@ Obtainium (add `https://github.com/kota-zo/myspoti`; the stable app and the beta
**And also**
- Your recap: your top songs, artists and albums, kept on your phone.
-- 11 languages: English, French, German, Spanish, Italian, Portuguese, Brazilian Portuguese, Greek, Russian, Polish and Chinese (Simplified).
+- 69 languages and regional variants, following the phone or picked by hand.
- Data saver, battery saver, AMOLED black, accent colour.
## New since 1.1
@@ -151,11 +151,14 @@ News, help and ideas: the [Discord server](https://discord.gg/jXKnGVFnGS). Bugs
## For developers
-The Android project is in `base/`, split in two:
+The Android project is in `base/`, in seven Gradle modules:
- **`:api`** is the contract the UI talks to: plain Kotlin models and interfaces (player, search, catalog, library, playlists, home, podcasts, users, lyrics, devices, Jam).
- **`:api-spotify`** implements it on Spotify's Web Player. Playback stays in the official player, in a hidden WebView (`:host-android`), driven by a small bridge script. Catalog, search and library calls go straight to Spotify's servers. When Spotify ships a new Web Player, the app reads its new operation list by itself.
+- **`:host-android`** is that WebView, plus the playback service (media session, notification, Android Auto browsing) and the app's Android-only pieces (logbook, covers).
- **`:host-cdp`** runs the same API on desktop Chrome, so the whole API is tested against the real Web Player without a phone.
+- **`:extensions`** is the sandbox third-party scripts run in (manifest, permissions, catalogue), plain JVM: an extension runs the same on a desktop. **`:extensions-cli`** is that desktop runner.
+- **`:app`** is the Compose UI, in its Classic and Immersive looks.
More: [`base/api-spotify/README.md`](base/api-spotify/README.md) and [`docs/api`](docs/api).
diff --git a/base/api-spotify/src/main/kotlin/app/myspoti/spotify/bridge/Bridge.kt b/base/api-spotify/src/main/kotlin/app/myspoti/spotify/bridge/Bridge.kt
index c0ca85cb..84473ad8 100644
--- a/base/api-spotify/src/main/kotlin/app/myspoti/spotify/bridge/Bridge.kt
+++ b/base/api-spotify/src/main/kotlin/app/myspoti/spotify/bridge/Bridge.kt
@@ -105,7 +105,9 @@ class Bridge(private val host: BridgeHost, scope: CoroutineScope) {
if (type == "state") {
val s = msg["state"] as? JsonObject
val line = "page state: " + (s?.get("track") as? JsonObject)?.get("name") + " paused=" + s?.get("isPaused") + " buffering=" + s?.get("isBuffering")
- if (stateWorthLogging(line, s?.get("track")?.toString() + s?.get("isPaused"))) log(line)
+ // The track's uri, not the whole track: serializing it here cost more than the line.
+ val key = ((s?.get("track") as? JsonObject)?.get("uri") as? JsonPrimitive)?.contentOrNull + s?.get("isPaused")
+ if (stateWorthLogging(line, key)) log(line)
} else if (type == "result") {
// Results are logged by call(); never write their values (tokens) here.
} else if (type == "net" && !netWorthLogging(msg)) {
diff --git a/base/api-spotify/src/main/kotlin/app/myspoti/spotify/bridge/LogMask.kt b/base/api-spotify/src/main/kotlin/app/myspoti/spotify/bridge/LogMask.kt
index 2cf7046c..cbf79c57 100644
--- a/base/api-spotify/src/main/kotlin/app/myspoti/spotify/bridge/LogMask.kt
+++ b/base/api-spotify/src/main/kotlin/app/myspoti/spotify/bridge/LogMask.kt
@@ -34,7 +34,13 @@ object LogMask {
/** [text] redacted, then cut to [max] characters with the number cut. */
fun shown(text: String, max: Int = 200): String {
- val clean = redact(text)
- return if (clean.length <= max) clean else clean.take(max) + "… (+${clean.length - max})"
+ // A bridge answer can be tens of kilobytes (a queue dump, a playlist body) while only the
+ // head is ever read: masking the tail costs milliseconds on the main thread for characters
+ // that are thrown away.
+ val head = text.take(max * 4)
+ val clean = redact(head)
+ if (head.length == text.length && clean.length <= max) return clean
+ val cut = if (head.length == text.length) clean.length else text.length
+ return clean.take(max) + "… (+${cut - max})"
}
}
diff --git a/base/api-spotify/src/test/kotlin/app/myspoti/spotify/bridge/LogMaskTest.kt b/base/api-spotify/src/test/kotlin/app/myspoti/spotify/bridge/LogMaskTest.kt
index 5a481347..0826502a 100644
--- a/base/api-spotify/src/test/kotlin/app/myspoti/spotify/bridge/LogMaskTest.kt
+++ b/base/api-spotify/src/test/kotlin/app/myspoti/spotify/bridge/LogMaskTest.kt
@@ -34,4 +34,11 @@ class LogMaskTest {
assertTrue(out.endsWith("(+30)"))
assertFalse(LogMask.shown("short").contains("+"))
}
+
+ @Test fun `shown masks the head of a huge result only`() {
+ // A queue dump: only the head is masked, and the count still says the real size.
+ val out = LogMask.shown("\"access_token\":\"BQsecret\"" + "x".repeat(50_000), 20)
+ assertFalse(out.contains("BQsecret"))
+ assertTrue(out.endsWith("(+50005)"))
+ }
}
diff --git a/base/app/src/main/java/com/music/spotui/data/api/Features.kt b/base/app/src/main/java/com/music/spotui/data/api/Features.kt
index f8f046b3..32312e95 100644
--- a/base/app/src/main/java/com/music/spotui/data/api/Features.kt
+++ b/base/app/src/main/java/com/music/spotui/data/api/Features.kt
@@ -1,6 +1,6 @@
package com.music.spotui.data.api
-/** Parts of the app switched off for now. */
+/** What the app shows: with a flag off, its rows and filters leave the UI. */
object Features {
/** Podcasts and audiobooks (shows, episodes, Your Episodes, playback speed). */
const val PODCASTS = true
diff --git a/base/app/src/main/java/com/music/spotui/data/api/LyricsApi.kt b/base/app/src/main/java/com/music/spotui/data/api/LyricsApi.kt
index 8a756607..6ea302bf 100644
--- a/base/app/src/main/java/com/music/spotui/data/api/LyricsApi.kt
+++ b/base/app/src/main/java/com/music/spotui/data/api/LyricsApi.kt
@@ -482,6 +482,9 @@ object LyricsApi {
}
private val geniusContainer = Regex("<div[^>]*data-lyrics-container=\"true\"[^>]*>", RegexOption.IGNORE_CASE)
+ // Built once: tidy() runs on every line of a parsed song and every word of a word-synced one.
+ private val spaces = Regex("\\s+")
+ private val htmlBreak = Regex("<br\\s*/?>", RegexOption.IGNORE_CASE)
/** The lyrics containers of a Genius song page, as plain text (nested divs balanced). */
internal fun geniusText(html: String): String? {
@@ -500,7 +503,7 @@ object LyricsApi {
}.toList()
if (parts.isEmpty()) return null
return parts.joinToString("\n") { part ->
- androidx.core.text.HtmlCompat.fromHtml(part.replace(Regex("<br\\s*/?>", RegexOption.IGNORE_CASE), "\n"), androidx.core.text.HtmlCompat.FROM_HTML_MODE_LEGACY)
+ androidx.core.text.HtmlCompat.fromHtml(part.replace(htmlBreak, "\n"), androidx.core.text.HtmlCompat.FROM_HTML_MODE_LEGACY)
.toString()
}.trim().takeIf { it.isNotEmpty() }
}
@@ -605,7 +608,7 @@ object LyricsApi {
agent?.trim()?.removePrefix("v")?.toIntOrNull()?.takeIf { it >= 0 }?.let { if (it >= 1000) 0 else it }
/** Backing vocals as plain text: "(Woo-hoo)" → "Woo-hoo". */
- private fun backingText(s: String): String? = s.replace(Regex("\\s+"), " ").trim().removeSurrounding("(", ")").trim().ifEmpty { null }
+ private fun backingText(s: String): String? = s.replace(spaces, " ").trim().removeSurrounding("(", ")").trim().ifEmpty { null }
// ── Word by word: lrc.red (Apple Music TTML, found by ISRC) ──
private fun fromLrcRed(asked: String, title: String, artist: String, durationMs: Long): Lyrics? {
@@ -632,7 +635,7 @@ object LyricsApi {
p.setInput(java.io.StringReader(xml))
fun attr(name: String) = p.getAttributeValue(null, name)
fun lineKey() = (0 until p.attributeCount).firstOrNull { p.getAttributeName(it).let { n -> n == "key" || n.endsWith(":key") } }?.let { p.getAttributeValue(it) }
- fun tidy(sb: CharSequence) = sb.toString().replace(Regex("\\s+"), " ").trim()
+ fun tidy(sb: CharSequence) = sb.toString().replace(spaces, " ").trim()
// Head: only the first translation and the first transliteration, text by line key.
val headTranslation = HashMap<String, String>(); val headRoman = HashMap<String, String>()
var translationLanguage: String? = null
diff --git a/base/app/src/main/java/com/music/spotui/di/OutputLag.kt b/base/app/src/main/java/com/music/spotui/di/OutputLag.kt
index 5dc1967e..dfe0e18b 100644
--- a/base/app/src/main/java/com/music/spotui/di/OutputLag.kt
+++ b/base/app/src/main/java/com/music/spotui/di/OutputLag.kt
@@ -1,6 +1,8 @@
package com.music.spotui.di
import android.os.SystemClock
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.launch
/**
* How late the sound is heard after the player plays it: Bluetooth delays it (~150-250 ms with
@@ -12,16 +14,27 @@ object OutputLag {
private const val BLUETOOTH_MS = 200L
@Volatile private var lag = 0L
- @Volatile private var checkedAt = 0L
+ @Volatile private var askedAt = 0L
+ private val asking = java.util.concurrent.atomic.AtomicBoolean(false)
+ /**
+ * Called from the lyrics' frame path and the clip's sync loop: the route inquiry (audio
+ * service, a binder call) runs on a worker, never on the frame that asked for it.
+ */
fun ms(): Long {
val now = SystemClock.elapsedRealtime()
- if (now - checkedAt > CHECK_MS) {
- checkedAt = now
- val route = com.music.spotui.ui.components.AudioRoute.current(Graph.app)
- val l = if (route.kind == com.music.spotui.ui.components.AudioRoute.Kind.BLUETOOTH) BLUETOOTH_MS else 0L
- if (l != lag) app.myspoti.host.android.Logbook.log("sound heard $l ms late (${route.kind.name.lowercase()}): clip and lyrics follow")
- lag = l
+ if (now - askedAt > CHECK_MS && asking.compareAndSet(false, true)) {
+ askedAt = now
+ app.myspoti.host.android.MyspotiRuntime.scope.launch(Dispatchers.IO) {
+ try {
+ val route = com.music.spotui.ui.components.AudioRoute.current(Graph.app)
+ val l = if (route.kind == com.music.spotui.ui.components.AudioRoute.Kind.BLUETOOTH) BLUETOOTH_MS else 0L
+ if (l != lag) app.myspoti.host.android.Logbook.log("sound heard $l ms late (${route.kind.name.lowercase()}): clip and lyrics follow")
+ lag = l
+ } finally {
+ asking.set(false)
+ }
+ }
}
return lag
}
diff --git a/base/app/src/main/java/com/music/spotui/di/Palette.kt b/base/app/src/main/java/com/music/spotui/di/Palette.kt
index 0a1606a8..0c321ac5 100644
--- a/base/app/src/main/java/com/music/spotui/di/Palette.kt
+++ b/base/app/src/main/java/com/music/spotui/di/Palette.kt
@@ -62,16 +62,13 @@ class Palette {
// before stayed (reported: the tint "doesn't change" between some songs).
val dominantColor = palette?.let { it.darkVibrantSwatch ?: it.darkMutedSwatch ?: it.dominantSwatch ?: it.vibrantSwatch }?.rgb
dominantColor?.let {
- // Convert RGB color integer to ARGB color integer with full opacity
val argbColor = readableUnderWhite(Color(it or (0xFF shl 24)))
colors[key] = argbColor; onColorExtracted(argbColor)
}
}
}
- override fun onLoadCleared(placeholder: Drawable?) {
- // Handle cleanup here if necessary
- }
+ override fun onLoadCleared(placeholder: Drawable?) {}
// No cover (failed load): a neutral tint, never the song before's.
override fun onLoadFailed(errorDrawable: Drawable?) { onColorExtracted(NEUTRAL) }
@@ -87,7 +84,7 @@ class Palette {
.disallowHardwareConfig()
.into(object : CustomTarget<Bitmap>() {
override fun onResourceReady(resource: Bitmap, transition: Transition<in Bitmap>?) {
- // Create a scaled down version of the bitmap
+ // A palette needs no detail: 50 px keeps the scaling (and its allocation) small.
val scaledBitmap = Bitmap.createScaledBitmap(resource, 50, 50, true)
Palette
@@ -95,16 +92,13 @@ class Palette {
.generate { palette ->
val lightVibrantColor = palette?.let { it.mutedSwatch ?: it.darkMutedSwatch ?: it.dominantSwatch ?: it.vibrantSwatch }?.rgb
lightVibrantColor?.let {
- // Convert RGB color integer to ARGB color integer with full opacity
val argbColor = Color(it or (0xFF shl 24))
colors[key] = argbColor; onColorExtracted(argbColor)
}
}
}
- override fun onLoadCleared(placeholder: Drawable?) {
- // Handle cleanup here if necessary
- }
+ override fun onLoadCleared(placeholder: Drawable?) {}
// No cover (failed load): a neutral tint, never the song before's.
override fun onLoadFailed(errorDrawable: Drawable?) { onColorExtracted(NEUTRAL) }
diff --git a/base/app/src/main/java/com/music/spotui/ui/components/FastScrollbar.kt b/base/app/src/main/java/com/music/spotui/ui/components/FastScrollbar.kt
index 53fcead0..9395c7b5 100644
--- a/base/app/src/main/java/com/music/spotui/ui/components/FastScrollbar.kt
+++ b/base/app/src/main/java/com/music/spotui/ui/components/FastScrollbar.kt
@@ -14,6 +14,7 @@ import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
+import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
@@ -35,7 +36,9 @@ import kotlin.math.roundToInt
*/
@Composable
fun FastScrollbar(state: LazyListState, modifier: Modifier = Modifier, minItems: Int = 30) {
- val total = state.layoutInfo.totalItemsCount
+ // The layout info changes on every scroll step: only the count, which rarely changes, is
+ // read in composition.
+ val total by remember { derivedStateOf { state.layoutInfo.totalItemsCount } }
if (total <= minItems) return
var dragging by remember { mutableStateOf(false) }
var visible by remember { mutableStateOf(false) }
@@ -49,16 +52,16 @@ fun FastScrollbar(state: LazyListState, modifier: Modifier = Modifier, minItems:
val density = LocalDensity.current
val thumbPx = with(density) { 56.dp.toPx() }
Box(modifier.fillMaxHeight().width(28.dp).alpha(alpha)) {
- val trackPx = state.layoutInfo.viewportSize.height.toFloat()
- val fraction = if (total <= 1) 0f else {
- val first = state.firstVisibleItemIndex.toFloat()
- (first / (total - 1)).coerceIn(0f, 1f)
- }
- val travel = (trackPx - thumbPx).coerceAtLeast(0f)
Box(
Modifier
.align(androidx.compose.ui.Alignment.TopEnd)
- .offset { IntOffset(0, (fraction * travel).roundToInt()) }
+ .offset {
+ // Read in layout: the thumb follows the scroll without recomposing the bar.
+ val travel = (state.layoutInfo.viewportSize.height - thumbPx).coerceAtLeast(0f)
+ val first = state.firstVisibleItemIndex.toFloat()
+ val fraction = if (total <= 1) 0f else (first / (total - 1)).coerceIn(0f, 1f)
+ IntOffset(0, (fraction * travel).roundToInt())
+ }
.padding(end = 3.dp)
.size(width = 5.dp, height = 56.dp)
.background(AppText.copy(alpha = if (dragging) 0.8f else 0.5f), RoundedCornerShape(50))
diff --git a/base/app/src/main/java/com/music/spotui/ui/immersive/components/ImmersiveCover.kt b/base/app/src/main/java/com/music/spotui/ui/immersive/components/ImmersiveCover.kt
index 121a0501..9c3a7ab9 100644
--- a/base/app/src/main/java/com/music/spotui/ui/immersive/components/ImmersiveCover.kt
+++ b/base/app/src/main/java/com/music/spotui/ui/immersive/components/ImmersiveCover.kt
@@ -24,13 +24,14 @@ import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.MusicNote
import androidx.compose.material3.Icon
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.Color
import androidx.compose.ui.graphics.Shape
+import androidx.compose.ui.graphics.TransformOrigin
+import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.graphics.lerp
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.layout.ContentScale
@@ -119,11 +120,11 @@ fun ImmersiveCoverPlaceholder(
@Composable
fun ImmersivePlayingBars(modifier: Modifier = Modifier) {
val reduceMotion = rememberReduceMotion()
- val heights = listOf(0.38f, 0.78f, 0.52f).mapIndexed { index, minimum ->
+ val barHeights = listOf(0.38f, 0.78f, 0.52f).mapIndexed { index, minimum ->
// Under "reduce motion" the bars rest at their low mark instead of dancing.
- if (reduceMotion) return@mapIndexed minimum
+ if (reduceMotion) return@mapIndexed ({ minimum })
val transition = rememberInfiniteTransition(label = "immersive playing bar $index")
- val height by transition.animateFloat(
+ val height = transition.animateFloat(
initialValue = minimum,
targetValue = 1f - (index * 0.12f),
animationSpec = infiniteRepeatable(
@@ -137,7 +138,7 @@ fun ImmersivePlayingBars(modifier: Modifier = Modifier) {
),
label = "immersive playing bar height $index",
)
- height
+ ({ height.value })
}
Box(
modifier = modifier
@@ -151,11 +152,17 @@ fun ImmersivePlayingBars(modifier: Modifier = Modifier) {
horizontalArrangement = Arrangement.spacedBy(2.dp),
verticalAlignment = Alignment.Bottom,
) {
- heights.forEach { height ->
+ barHeights.forEach { height ->
Box(
Modifier
.width(3.dp)
- .height(14.dp * height)
+ .height(14.dp)
+ // Scaled in the layer, from the bottom: the dance does not relayout
+ // (and recompose) the bars sixty times a second.
+ .graphicsLayer {
+ scaleY = height()
+ transformOrigin = TransformOrigin(0.5f, 1f)
+ }
.clip(RoundedCornerShape(2.dp))
.background(Color.White),
)
diff --git a/base/app/src/main/java/com/music/spotui/ui/immersive/lyrics/ImmersiveLyricsPanel.kt b/base/app/src/main/java/com/music/spotui/ui/immersive/lyrics/ImmersiveLyricsPanel.kt
index da54a3ee..181e10ec 100644
--- a/base/app/src/main/java/com/music/spotui/ui/immersive/lyrics/ImmersiveLyricsPanel.kt
+++ b/base/app/src/main/java/com/music/spotui/ui/immersive/lyrics/ImmersiveLyricsPanel.kt
@@ -58,6 +58,7 @@ import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.FloatState
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.MutableLongState
+import androidx.compose.runtime.State
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
@@ -71,15 +72,15 @@ import androidx.compose.runtime.snapshotFlow
import androidx.compose.runtime.structuralEqualityPolicy
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
-import androidx.compose.ui.draw.BlurredEdgeTreatment
-import androidx.compose.ui.draw.blur
import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.clipToBounds
import androidx.compose.ui.draw.drawBehind
import androidx.compose.ui.draw.drawWithCache
import androidx.compose.ui.geometry.Offset
+import androidx.compose.ui.graphics.BlurEffect
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.graphics.TileMode
import androidx.compose.ui.graphics.TransformOrigin
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.input.nestedscroll.nestedScroll
@@ -652,7 +653,9 @@ private fun PanelRow(
// clears and the old one blurs back in the same short tween. Reduce motion drops blur.
val focusStep = (if (focusLine < 0) 0 else abs(index - focusLine))
.coerceAtMost(LINE_FALLOFF_BLUR.lastIndex)
- val blur by animateDpAsState(
+ // These three animate on every line change: they are read in the row's layer (see `shape`),
+ // so a line settling redraws the rows it touches without recomposing them and their text.
+ val blur = animateDpAsState(
targetValue = when {
!synced || !blurOk || browsing || (focusLine >= 0 && index == focusLine) -> 0.dp
else -> LINE_FALLOFF_BLUR[focusStep]
@@ -660,7 +663,7 @@ private fun PanelRow(
animationSpec = tween(BLUR_SWITCH_MS, easing = LYRIC_EASING),
label = "lyricBlur",
)
- val lineAlpha by animateFloatAsState(
+ val lineAlpha = animateFloatAsState(
targetValue = when {
!synced -> 0.95f
isActive || selected -> 1f
@@ -696,7 +699,7 @@ private fun PanelRow(
var pressAt by remember { mutableStateOf(Offset.Zero) }
var pressWidth by remember { mutableStateOf(0) }
val density = LocalDensity.current
- val scale by animateFloatAsState(
+ val scale = animateFloatAsState(
targetValue = when {
pressed -> PRESSED_SCALE
isActive || !synced -> 1f
@@ -721,12 +724,12 @@ private fun PanelRow(
val shape = Modifier
.fillMaxWidth()
.graphicsLayer {
- scaleX = scale
- scaleY = scale
+ scaleX = scale.value
+ scaleY = scale.value
// Anchored to the left edge (the right one for the second singer), so the words don't
// slide sideways under the highlight.
transformOrigin = TransformOrigin(if (lane == true) 1f else 0f, 0.5f)
- alpha = lineAlpha
+ alpha = lineAlpha.value
// Held back against the list's own movement: the list has already taken this row
// part of the way, so giving back what it has not earned yet is what leaves it
// trailing. Rows with nothing to catch up on never read the clock at all.
@@ -739,8 +742,10 @@ private fun PanelRow(
LYRIC_EASING.transform(((elapsed - staggerDelay) / run.durationMs).coerceIn(0f, 1f))
)
}
+ // What Modifier.blur does, with its radius read here instead of at composition.
+ val radius = blur.value.toPx()
+ renderEffect = if (radius > 0f) BlurEffect(radius, radius, TileMode.Decal) else null
}
- .blur(blur, BlurredEdgeTreatment.Unbounded)
.clip(RoundedCornerShape(10.dp))
.background(pickedFill)
.then(if (onNote != null) Modifier.drawWithCache {
@@ -1104,8 +1109,8 @@ private fun GapRow(
row: PanelLine,
clock: MutableLongState,
isActive: Boolean,
- blur: Dp,
- lineAlpha: Float,
+ blur: State<Dp>,
+ lineAlpha: State<Float>,
onSeek: (Long) -> Unit,
) {
val until = row.untilMs
@@ -1135,7 +1140,6 @@ private fun GapRow(
) {
Box(
modifier = Modifier
- .blur(blur, BlurredEdgeTreatment.Unbounded)
.clip(RoundedCornerShape(10.dp))
.clickable(interactionSource = remember { MutableInteractionSource() }, indication = null) {
onSeek(row.timeMs)
@@ -1149,7 +1153,9 @@ private fun GapRow(
scaleX = grow
scaleY = grow
transformOrigin = TransformOrigin(0f, 0.5f)
- alpha = lineAlpha * swell
+ alpha = lineAlpha.value * swell
+ val radius = blur.value.toPx()
+ if (radius > 0f) renderEffect = BlurEffect(radius, radius, TileMode.Decal)
}
.drawBehind {
val span = (until - row.timeMs).coerceAtLeast(1L)
diff --git a/base/app/src/main/java/com/music/spotui/ui/immersive/lyrics/ImmersiveQueuePanel.kt b/base/app/src/main/java/com/music/spotui/ui/immersive/lyrics/ImmersiveQueuePanel.kt
index ef428961..f9b32e3b 100644
--- a/base/app/src/main/java/com/music/spotui/ui/immersive/lyrics/ImmersiveQueuePanel.kt
+++ b/base/app/src/main/java/com/music/spotui/ui/immersive/lyrics/ImmersiveQueuePanel.kt
@@ -416,6 +416,9 @@ private fun LazyListScope.queueSection(
val rowNow by rememberUpdatedState(row)
// What is left of the drop to walk off: the row's drawn position less its slot's.
val settle = remember { mutableFloatStateOf(0f) }
+ // Hoisted: the drop's settle animates the float, and reading it here would recompose the
+ // row on every frame of it (its translationY is already read in the layer).
+ val settling by remember { derivedStateOf { settle.floatValue != 0f } }
val scope = rememberCoroutineScope()
fun settleBack(from: Float) {
settle.floatValue = from
@@ -442,7 +445,7 @@ private fun LazyListScope.queueSection(
}
}
.then(if (dragged || drag.settling) Modifier else queueMotion())
- .zIndex(if (dragged || settle.floatValue != 0f) 1f else 0f)
+ .zIndex(if (dragged || settling) 1f else 0f)
.graphicsLayer { translationY = (if (dragged) drag.offset else shift * rowPx) + settle.floatValue },
backgroundContent = {
// Drawn only while swiping: the row is transparent, so at rest this × showed
diff --git a/base/app/src/main/java/com/music/spotui/ui/look/LookPreview.kt b/base/app/src/main/java/com/music/spotui/ui/look/LookPreview.kt
index 4a1bf833..2913d98a 100644
--- a/base/app/src/main/java/com/music/spotui/ui/look/LookPreview.kt
+++ b/base/app/src/main/java/com/music/spotui/ui/look/LookPreview.kt
@@ -94,8 +94,8 @@ import kotlin.math.min
/*
* The live preview of the onboarding's look step: each look drawn at a real phone's size, then
- * scaled down into a phone frame, playing DemoScript's loop with DemoSong. Small stateless
- * pieces for now; step (d) of docs/style-choix-onboarding.md swaps them for the real players.
+ * scaled down into a phone frame, playing DemoScript's loop with DemoSong. The pieces are small
+ * and stateless on purpose: they never touch the real players, so the step cannot start a song.
*/
private val PhoneW = 360.dp
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.kt
index 212bdf60..226a7877 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
@@ -161,7 +161,7 @@ fun HomeFeedContent(navController: NavController, feed: HomeFeedModel, facet: St
// section the web home starts with — if the feed leads with a titled section
// ("Jump back in", "Made For …"), it renders as a titled carousel first,
// not force-squeezed into the grid.
- // Podcasts are off for now: their shows and episodes leave the feed.
+ // 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 sections = remember(feed, hideDj) {
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.kt
index fff1d6a5..33326bee 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
@@ -59,7 +59,6 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.foundation.shape.CircleShape
-import androidx.compose.ui.draw.alpha
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
@@ -294,8 +293,6 @@ fun PlayerScreen(navController: NavController) {
androidx.compose.animation.core.tween((CANVAS_FADE_MS * left).toInt(), easing = androidx.compose.animation.core.FastOutSlowInEasing),
)
}
- val canvasAlpha = canvasProgress.value
- val coverAlpha = 1f - canvasProgress.value
// A tap on the Canvas no longer needs its own mode: the immersive view below handles both
// cases (Canvas playing or plain cover), so the Canvas-only fade ("chrome") is gone.
// Music video (YouTube, synced to the Spotify playback): looked up for every track
@@ -367,7 +364,9 @@ fun PlayerScreen(navController: NavController) {
url = canvasUrl,
onFirstFrame = { canvasShown = true },
playing = songPlayingState && !showLyrics && !audioBuffering,
- modifier = Modifier.fillMaxSize().alpha(canvasAlpha),
+ // Read in the layer: the fade then changes the alpha only, without recomposing
+ // the whole player for each of its frames.
+ modifier = Modifier.fillMaxSize().graphicsLayer { alpha = canvasProgress.value },
)
// Darker than the clip itself while the player shows over it, so the text reads;
// gone when the Canvas is shown alone.
@@ -376,7 +375,7 @@ fun PlayerScreen(navController: NavController) {
.fillMaxSize()
// Lighter dim in the immersive view: the clip is the page there, only the
// compact strip needs something to sit on.
- .alpha(canvasAlpha * if (immersive) 0.35f else 1f)
+ .graphicsLayer { alpha = canvasProgress.value * if (immersive) 0.35f else 1f }
.background(
Brush.verticalGradient(
colors = listOf(
@@ -519,8 +518,9 @@ fun PlayerScreen(navController: NavController) {
// Normal layout keeps the inset, rounded cover.
else Modifier.padding(horizontal = coverInset).aspectRatio(1f).clip(RoundedCornerShape(8.dp)))
.graphicsLayer {
- alpha = coverAlpha
- val grow = 1f + (1f - coverAlpha) * 0.06f
+ val shown = 1f - canvasProgress.value
+ alpha = shown
+ val grow = 1f + (1f - shown) * 0.06f
scaleX = grow; scaleY = grow
},
model = app.myspoti.host.android.Covers.large(cover),
@@ -531,7 +531,7 @@ fun PlayerScreen(navController: NavController) {
blend,
(if (immersive) Modifier.fillMaxSize()
else Modifier.padding(horizontal = coverInset).aspectRatio(1f).clip(RoundedCornerShape(8.dp)))
- .graphicsLayer { alpha = coverAlpha },
+ .graphicsLayer { alpha = 1f - canvasProgress.value },
)
}
}
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.kt
index 0f5346d3..eb644ce5 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
@@ -515,7 +515,7 @@ private fun OrientationRow() {
}
}
-/** "App language": Automatic (French or English) or any language with Spotify's labels. */
+/** "App language": follow the phone, or any language the app has strings for. */
@OptIn(androidx.compose.material3.ExperimentalMaterial3Api::class)
@Composable
private fun LanguageRow() {
diff --git a/docs/api/CAPTURE-MAP.md b/docs/api/CAPTURE-MAP.md
index 74813dd8..e269d8cd 100644
--- a/docs/api/CAPTURE-MAP.md
+++ b/docs/api/CAPTURE-MAP.md
@@ -70,7 +70,6 @@ Free account: no shuffle button on a playlist context in the web UI.
| Save / unsave album | `addToLibrary` / `removeFromLibrary` |
| Follow / unfollow artist | `addToLibrary` / `removeFromLibrary` |
-## Not captured yet
-
-Remove a track from a playlist, delete a playlist, reorder, Connect to another device,
-podcasts, ads (`ads/v2/config` is fetched at startup).
+Folders, pins, row moves, playlist access and cover, Connect transfer, podcasts, Blend and
+Jam were captured later and are implemented in `base/api-spotify` (`SpotifyLibrary`,
+`SpotifyBlends`, `SpotifyMore`); `ads/v2/config` is fetched at startup.
diff --git a/docs/api/LIBRARY.md b/docs/api/LIBRARY.md
index 50929c89..c424c236 100644
--- a/docs/api/LIBRARY.md
+++ b/docs/api/LIBRARY.md
@@ -536,37 +536,28 @@ has joined: joining one's own invitation returned a `playlist_uri` that `fetchPl
The Blend page itself (members, taste match, rename, leave) uses calls the Web Player has no
screen for; they are the ones Spotify's mobile apps make for that page. The two reads were
-checked live on a real two-member Blend (21/10), and rename; leave was not sent yet:
+checked live on a real two-member Blend (21/10), and rename; leaving is sent by the app, its
+answer not captured:
| Call | Answer |
|---|---|
| `GET /v3/get-invitation/{playlistId}` | `200 {title, button_text, invitation_link, members[{name, image_url, hash, username}]}` (`image_url` may be `""`) |
| `GET /v3/data-stories/{playlistId}` | `200 {intro_story{title1{text,text_color}, subtitle1, background_color, audio_uri}, stories[{story_type, title, subtitle, body, image, background_color, button{navigation_uri}}]}` |
| `PUT blend-writer/v1/rename/{playlistId}` `{"name":…}` | `200`, empty body (checked with the Blend's own name) |
-| `PUT /v1/leave` `{"playlist_uri":"spotify:playlist:…"}` | not sent yet |
+| `PUT /v1/leave` `{"playlist_uri":"spotify:playlist:…"}` | answer not captured (sent when leaving a Blend; nothing in it is read) |
`blend-writer` is a sibling of `blend-invitation` on the same host. The texts (titles, button
words, story lines) come translated in the account's language.
-## Gaps (not captured)
-
-- Remove tracks from a playlist: GraphQL `removeFromPlaylist {playlistUri, uids}` removes
- exactly the rows named by `uid` (checked live: the same song twice has two uids, removing
- one leaves the other). Never address a row by its track uri.
-- Reorder tracks (`MOV`, or `addToPlaylist`/move with `fromUid`; unknown).
-- Delete a playlist (for an own playlist the Web Player probably only does the rootlist
- `REM`; not confirmed).
-- Folders: create, rename, move items into folders, rootlist folder markers, and
- `libraryV3` with `folderUri`/`expandedFolders`/`flatten` set.
-- `libraryV3` with a filter or another sort: the variable names for the selected filter
- and sort (`order` is null by default, no filter key was sent) are not known.
-- Pin / unpin in Your Library.
-- Change description, cover image, public/private, collaborative.
-- `applyCurations` with `CURATE` (adding through the heart sheet), multi-playlist curations.
-- Liked Songs for podcasts (`YOUR_EPISODES_V2`), shows, audiobooks.
-- Error responses (rate limit, revision conflict, permission denied).
+## Gaps
-## TODO
+`removeFromPlaylist`, `MOV` (both `moveTracks` and drag-and-drop), playlist delete, folders
+(`libraryV3`'s `folderUri`/`expandedFolders`/`flatten`, the rootlist folder markers and
+`RootlistAPI` create/rename/remove), `libraryV3` filters and sorts, pin/unpin, and a
+playlist's description, cover, access and collaborators are all implemented in
+`base/api-spotify` now (see `SpotifyLibrary`). Rows are addressed by `uid`, never by track
+uri: the same song twice has two. What is still missing:
-- TODO: libraryV3 filters and sorts — capture a session with a filter chip and each sort order to get the variable names.
-- TODO: rootlist folders — capture folder create/move to see folder markers in rootlist `items` and the `changes` ops.
+- `applyCurations` with `CURATE` (adding through the heart sheet), multi-playlist curations
+ (Myspoti saves with `addToLibrary` instead).
+- Error responses (rate limit, revision conflict, permission denied).