Skip to content

Native Android client for Spotify, built with Jetpack Compose

The playing bars keep round corners while they dance (drawn at their height instead of squashed in a layer), a lyric break blurs at its full radius outside its grow and clip again, and a cut log line masks the whole text when masking shrank its head so much that a value cut at its end could be kept unmasked

kota-zo1544794b0e72
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 cbf79c57..84185742 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
@@ -38,9 +38,15 @@ object LogMask {
// 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})"
+ var clean = redact(head)
+ var size = if (head.length == text.length) clean.length else text.length
+ // A value cut at the end of the head is no longer matched whole (a blob under 120 characters,
+ // an address without its domain) and stays as it is. When masking shrank the head so much that
+ // this tail could reach the kept characters, the whole text is masked instead.
+ if (head.length < text.length && clean.length < max * 3) {
+ clean = redact(text)
+ size = clean.length
+ }
+ return if (size <= max) clean else clean.take(max) + "… (+${size - 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 0826502a..5d1f529b 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
@@ -41,4 +41,12 @@ class LogMaskTest {
assertFalse(out.contains("BQsecret"))
assertTrue(out.endsWith("(+50005)"))
}
+
+ @Test fun `shown masks a value cut at the end of the head`() {
+ // The blob shrinks to a placeholder, so the token cut at the head's end would be kept unmasked.
+ val text = "{\"x\":\"" + "A".repeat(700) + "\",\"v\":\"" + "B".repeat(300) + "\"}"
+ val out = LogMask.shown(text, 200)
+ assertFalse(out.contains("BBBB"))
+ assertFalse(out.contains("AAAA"))
+ }
}
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 9c3a7ab9..05176542 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
@@ -27,11 +27,13 @@ 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.draw.drawBehind
+import androidx.compose.ui.geometry.CornerRadius
+import androidx.compose.ui.geometry.Offset
+import androidx.compose.ui.geometry.Size
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.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
@@ -157,14 +159,17 @@ fun ImmersivePlayingBars(modifier: Modifier = Modifier) {
Modifier
.width(3.dp)
.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),
+ // Drawn at its height from the bottom: the dance does not relayout (and
+ // recompose) the bars sixty times a second, and the corners stay round.
+ .drawBehind {
+ val barHeight = size.height * height()
+ drawRoundRect(
+ color = Color.White,
+ topLeft = Offset(0f, size.height - barHeight),
+ size = Size(size.width, barHeight),
+ cornerRadius = CornerRadius(2.dp.toPx()),
+ )
+ },
)
}
}
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 181e10ec..b60f1b07 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
@@ -1140,6 +1140,12 @@ private fun GapRow(
) {
Box(
modifier = Modifier
+ // Its own layer, outside the clip and the grow below: the dots blur at the full
+ // radius and the blur bleeds past the rounded rect, as a sung line's does.
+ .graphicsLayer {
+ val radius = blur.value.toPx()
+ renderEffect = if (radius > 0f) BlurEffect(radius, radius, TileMode.Decal) else null
+ }
.clip(RoundedCornerShape(10.dp))
.clickable(interactionSource = remember { MutableInteractionSource() }, indication = null) {
onSeek(row.timeMs)
@@ -1154,8 +1160,6 @@ private fun GapRow(
scaleY = grow
transformOrigin = TransformOrigin(0f, 0.5f)
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)