Skip to content

Unofficial YouTube Music / Spotify Premium client for Android, built in Liquid Glass. Audio effects, Spotify Connect, listening history, 8 languages. Rust core on librespot.

A modal track sheet, and reverb that stops with playback

Lelonio9bed0e98a606
diff --git a/.claude/settings.local.json b/.claude/settings.local.json
index 4bc75c8..e3f2975 100644
--- a/.claude/settings.local.json
+++ b/.claude/settings.local.json
@@ -118,7 +118,8 @@
"Bash(git commit -q -m 'Glass context menus, with remove-from-playlist *)",
"Bash(git commit -q -m 'Menus that refract the page, and a hero that collapses into a bar *)",
"Bash(git commit -q -m 'A hero that actually collapses, and a menu nothing covers *)",
- "Bash(git commit -q -m 'Relink playlist tracks to this market; icon-only track menu *)"
+ "Bash(git commit -q -m 'Relink playlist tracks to this market; icon-only track menu *)",
+ "Bash(git commit -q -m 'A modal track sheet, and reverb that stops with playback *)"
]
}
}
diff --git a/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/configure_fingerprint.bin b/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/configure_fingerprint.bin
index 1a2ae44..13f34a9 100644
--- a/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/configure_fingerprint.bin
+++ b/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/configure_fingerprint.bin
@@ -2,27 +2,27 @@ C/C++ Structured Logl
j
h/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/additional_project_files.txtC
A
-?com.android.build.gradle.internal.cxx.io.EncodedFileFingerPrint  �����3  ����3i
+?com.android.build.gradle.internal.cxx.io.EncodedFileFingerPrint  �����3  ����3i
g
-e/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/android_gradle_build.json  �����3� ����3n
+e/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/android_gradle_build.json  �����3� ����3n
l
-j/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/android_gradle_build_mini.json  �����3� �����3[
+j/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/android_gradle_build_mini.json  �����3� �����3[
Y
-W/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/build.ninja  �����3�� ����3_
+W/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/build.ninja  �����3�� ����3_
]
-[/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/build.ninja.txt  �����3d
+[/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/build.ninja.txt  �����3d
b
-`/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/build_file_index.txt  �����3 @ ����3e
+`/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/build_file_index.txt  �����3 @ ����3e
c
-a/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/compile_commands.json  �����3�� ����3i
+a/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/compile_commands.json  �����3�� ����3i
g
-e/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/compile_commands.json.bin  �����3 �" ����3o
+e/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/compile_commands.json.bin  �����3 �" ����3o
m
-k/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/metadata_generation_command.txt  �����3
+k/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/metadata_generation_command.txt  �����3
� ����3b
`
-^/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/prefab_config.json  �����3  ( ����3g
+^/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/prefab_config.json  �����3  ( ����3g
e
-c/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/symbol_folder_index.txt  �����3  b ����3D
+c/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/symbol_folder_index.txt  �����3  b ����3D
B
-@/Users/emanuele/Progetto Spotify/app/src/main/cpp/CMakeLists.txt  �����3 � �Ȅ��3
\ No newline at end of file
+@/Users/emanuele/Progetto Spotify/app/src/main/cpp/CMakeLists.txt  �����3 � �Ȅ��3
\ No newline at end of file
diff --git a/app/src/main/java/dev/emanuele/spot/playback/AudioOutput.kt b/app/src/main/java/dev/emanuele/spot/playback/AudioOutput.kt
index 00d5027..e3a6b94 100644
--- a/app/src/main/java/dev/emanuele/spot/playback/AudioOutput.kt
+++ b/app/src/main/java/dev/emanuele/spot/playback/AudioOutput.kt
@@ -120,6 +120,12 @@ class AudioOutput {
* into it. A reverb needs a send — the track has to be pointed at the effect
* with `attachAuxEffect` and given a send level above zero. Auxiliary
* effects live on the global output mix, hence session 0.
+ *
+ * That last part is also why [suspendReverb] exists. An effect on the output
+ * mix processes the *mix*, not this track: left running while playback is
+ * paused it keeps ringing out its tail, and any other sound the phone makes
+ * — a notification, another app — arrives into a room it was never meant to
+ * be in. So the effect is only alive while this player is actually playing.
*/
private fun applyReverb() {
val output = track
@@ -193,6 +199,8 @@ class AudioOutput {
output.setVolume(0f)
output.play()
}
+ // Back on the mix now that this player is the thing making sound.
+ synchronized(this) { applyReverb() }
fadeExecutor.execute { ramp(output, 1f, FADE_IN_MS) }
}
@@ -228,7 +236,25 @@ class AudioOutput {
// under the new one when effects are on.
stretcher?.release()
stretcher = null
+
+ suspendReverb()
+ }
+ }
+
+ /**
+ * Takes the reverb off the output mix until playback resumes.
+ *
+ * Not merely muted: the effect is disabled, because an enabled reverb on the
+ * mix processes whatever the phone plays next. Muting the send alone left
+ * the tail of the last few seconds ringing on after the pause, and every
+ * system sound afterwards arriving through it.
+ */
+ private fun suspendReverb() {
+ track?.runCatching {
+ setAuxEffectSendLevel(0f)
+ attachAuxEffect(0)
}
+ reverb?.runCatching { enabled = false }
}
/**
diff --git a/app/src/main/java/dev/emanuele/spot/ui/SpotApp.kt b/app/src/main/java/dev/emanuele/spot/ui/SpotApp.kt
index a5ef831..1680cce 100644
--- a/app/src/main/java/dev/emanuele/spot/ui/SpotApp.kt
+++ b/app/src/main/java/dev/emanuele/spot/ui/SpotApp.kt
@@ -82,8 +82,8 @@ import dev.emanuele.spot.ui.player.GlassFilm
import dev.emanuele.spot.ui.player.AddToPlaylistSheet
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.unit.IntOffset
-import dev.emanuele.spot.ui.components.GlassIconMenu
-import dev.emanuele.spot.ui.components.GlassIconMenuItem
+import dev.emanuele.spot.ui.components.TrackSheet
+import dev.emanuele.spot.ui.components.TrackSheetAction
import dev.emanuele.spot.ui.library.openLink
import com.adamglin.phosphoricons.regular.LinkSimple
import com.adamglin.phosphoricons.regular.Plus
@@ -117,7 +117,6 @@ import com.adamglin.phosphoricons.regular.MusicNotes
/** A track menu waiting to be drawn: what it is about, and where it points. */
private data class TrackMenuRequest(
val track: dev.emanuele.spot.data.CatalogTrack,
- val anchor: IntOffset,
val removable: Boolean,
)
@@ -388,10 +387,9 @@ fun SpotApp(
onAddToPlaylist = { track ->
viewModel.openAddToPlaylist(track.uri, track.name)
},
- onTrackMenu = { track, anchor ->
+ onTrackMenu = { track ->
trackMenu = TrackMenuRequest(
track = track,
- anchor = anchor,
// Only a playlist can have
// something taken out of it.
removable = playlist.kind ==
@@ -521,33 +519,35 @@ fun SpotApp(
// it.
val menu = trackMenu
val clipboard = androidx.compose.ui.platform.LocalClipboardManager.current
- GlassIconMenu(
+ TrackSheet(
visible = menu != null,
- anchor = menu?.anchor ?: IntOffset.Zero,
+ title = menu?.track?.name.orEmpty(),
+ subtitle = menu?.track?.artist.orEmpty(),
+ artworkUrl = menu?.track?.artworkUrl,
backdrop = pageBackdrop,
onDismiss = { trackMenu = null },
) {
if (menu != null) {
- GlassIconMenuItem(PhosphorIcons.Fill.Play, "Riproduci") {
+ TrackSheetAction("Riproduci", PhosphorIcons.Fill.Play) {
trackMenu = null
onPlay(listOf(menu.track), 0)
}
- GlassIconMenuItem(PhosphorIcons.Regular.Queue, "Aggiungi alla coda") {
+ TrackSheetAction("Aggiungi alla coda", PhosphorIcons.Regular.Queue) {
trackMenu = null
onEnqueue(menu.track)
}
- GlassIconMenuItem(PhosphorIcons.Regular.Plus, "Aggiungi a una playlist") {
+ TrackSheetAction("Aggiungi a una playlist", PhosphorIcons.Regular.Plus) {
trackMenu = null
viewModel.openAddToPlaylist(menu.track.uri, menu.track.name)
}
- GlassIconMenuItem(PhosphorIcons.Regular.LinkSimple, "Copia link") {
+ TrackSheetAction("Copia link", PhosphorIcons.Regular.LinkSimple) {
trackMenu = null
clipboard.setText(AnnotatedString(menu.track.openLink()))
}
if (menu.removable) {
- GlassIconMenuItem(
- PhosphorIcons.Regular.Trash,
+ TrackSheetAction(
"Rimuovi dalla playlist",
+ PhosphorIcons.Regular.Trash,
destructive = true,
) {
trackMenu = null
diff --git a/app/src/main/java/dev/emanuele/spot/ui/components/TrackSheet.kt b/app/src/main/java/dev/emanuele/spot/ui/components/TrackSheet.kt
new file mode 100644
index 0000000..f34d421
--- /dev/null
+++ b/app/src/main/java/dev/emanuele/spot/ui/components/TrackSheet.kt
@@ -0,0 +1,185 @@
+package dev.emanuele.spot.ui.components
+
+import androidx.compose.animation.AnimatedVisibility
+import androidx.compose.animation.core.tween
+import androidx.compose.animation.fadeIn
+import androidx.compose.animation.fadeOut
+import androidx.compose.animation.scaleIn
+import androidx.compose.animation.scaleOut
+import androidx.compose.foundation.background
+import androidx.compose.foundation.clickable
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.BoxScope
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.ColumnScope
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.material3.Icon
+import androidx.compose.material3.MaterialTheme
+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.graphics.vector.ImageVector
+import androidx.compose.ui.text.style.TextOverflow
+import androidx.compose.ui.unit.dp
+import com.kyant.backdrop.Backdrop
+import com.kyant.backdrop.drawBackdrop
+import com.kyant.backdrop.effects.blur
+import dev.emanuele.spot.ui.player.GlassSurface
+import dev.emanuele.spot.ui.theme.softShadow
+
+/**
+ * What can be done with one track, as a modal.
+ *
+ * It went through a dropdown and then a row of icons first. Both were wrong for
+ * the same reason: the actions here are about a *particular* track, and a menu
+ * floating beside a list of fifty rows never says which one. The cover and the
+ * title at the top of a sheet do, and are the only part of this that is not a
+ * button.
+ *
+ * The page behind it is blurred rather than merely dimmed. A scrim darkens the
+ * page and leaves it perfectly readable underneath, which is what makes a modal
+ * feel like a panel resting on a screen you are still using. Out of focus, the
+ * screen stops being something to read and the sheet is the only thing left.
+ *
+ * Must be drawn above the tab bar and the now-playing bar — that is, at app
+ * level and not inside a screen, since those are drawn over the whole
+ * navigation host.
+ */
+@Composable
+fun BoxScope.TrackSheet(
+ visible: Boolean,
+ title: String,
+ subtitle: String,
+ artworkUrl: String?,
+ /** The layer the page is recorded into; blurred behind the sheet. */
+ backdrop: Backdrop,
+ onDismiss: () -> Unit,
+ actions: @Composable ColumnScope.() -> Unit,
+) {
+ AnimatedVisibility(
+ visible = visible,
+ enter = fadeIn(tween(200)),
+ exit = fadeOut(tween(180)),
+ modifier = Modifier.fillMaxSize(),
+ ) {
+ Box(
+ Modifier
+ .fillMaxSize()
+ // The whole page, out of focus. Drawn from the recorded layer
+ // rather than with `Modifier.blur` on the content itself, which
+ // would blur the screen for everyone including the sheet.
+ .drawBackdrop(
+ backdrop = backdrop,
+ shape = { androidx.compose.ui.graphics.RectangleShape },
+ effects = { blur(28f.dp.toPx()) },
+ onDrawSurface = { drawRect(Color.Black.copy(alpha = 0.42f)) },
+ )
+ .clickable(interactionSource = null, indication = null, onClick = onDismiss),
+ )
+ }
+
+ AnimatedVisibility(
+ visible = visible,
+ enter = scaleIn(tween(220), initialScale = 0.9f) + fadeIn(tween(160)),
+ exit = scaleOut(tween(160), targetScale = 0.94f) + fadeOut(tween(140)),
+ modifier = Modifier.align(Alignment.Center),
+ ) {
+ val shape = RoundedCornerShape(30.dp)
+ GlassSurface(
+ backdrop = backdrop,
+ shape = shape,
+ surfaceColor = SheetFilm,
+ modifier = Modifier
+ .padding(horizontal = 28.dp)
+ .fillMaxWidth()
+ .clip(shape)
+ .softShadow(shape, elevation = 26.dp, spot = 0.35f)
+ // Swallows the tap that would otherwise close the sheet.
+ .clickable(interactionSource = null, indication = null) {},
+ ) {
+ Column(Modifier.padding(vertical = 22.dp)) {
+ Row(
+ Modifier
+ .fillMaxWidth()
+ .padding(horizontal = 22.dp, vertical = 2.dp),
+ verticalAlignment = Alignment.CenterVertically,
+ ) {
+ Artwork(
+ url = artworkUrl,
+ title = title,
+ modifier = Modifier.size(58.dp),
+ corner = 12.dp,
+ decodeSize = 58.dp,
+ )
+ Column(
+ Modifier
+ .weight(1f)
+ .padding(start = 16.dp),
+ ) {
+ Text(
+ title,
+ style = MaterialTheme.typography.titleMedium,
+ color = Color.White,
+ maxLines = 2,
+ overflow = TextOverflow.Ellipsis,
+ )
+ Text(
+ subtitle,
+ style = MaterialTheme.typography.bodySmall,
+ color = Color.White.copy(alpha = 0.66f),
+ maxLines = 1,
+ overflow = TextOverflow.Ellipsis,
+ )
+ }
+ }
+
+ Box(
+ Modifier
+ .padding(top = 16.dp, bottom = 6.dp)
+ .fillMaxWidth()
+ .padding(horizontal = 22.dp)
+ .size(width = 0.dp, height = 1.dp)
+ .background(Color.White.copy(alpha = 0.12f)),
+ )
+
+ actions()
+ }
+ }
+ }
+}
+
+@Composable
+fun TrackSheetAction(
+ label: String,
+ icon: ImageVector,
+ destructive: Boolean = false,
+ onClick: () -> Unit,
+) {
+ val tint = if (destructive) MaterialTheme.colorScheme.error else Color.White
+ Row(
+ Modifier
+ .fillMaxWidth()
+ .clickable(onClick = onClick)
+ .padding(horizontal = 22.dp, vertical = 14.dp),
+ verticalAlignment = Alignment.CenterVertically,
+ ) {
+ Icon(icon, contentDescription = null, tint = tint, modifier = Modifier.size(20.dp))
+ Text(
+ label,
+ style = MaterialTheme.typography.bodyLarge,
+ color = tint,
+ modifier = Modifier.padding(start = 16.dp),
+ )
+ }
+}
+
+/** Light: the page behind is already blurred, so this only has to be a surface. */
+private val SheetFilm = Color.White.copy(alpha = 0.13f)
diff --git a/app/src/main/java/dev/emanuele/spot/ui/library/PlaylistScreen.kt b/app/src/main/java/dev/emanuele/spot/ui/library/PlaylistScreen.kt
index f39d0b3..1e93301 100644
--- a/app/src/main/java/dev/emanuele/spot/ui/library/PlaylistScreen.kt
+++ b/app/src/main/java/dev/emanuele/spot/ui/library/PlaylistScreen.kt
@@ -122,7 +122,7 @@ fun PlaylistScreen(
* drawn over the whole navigation host — nothing inside a screen can reach
* that far up.
*/
- onTrackMenu: (CatalogTrack, IntOffset) -> Unit,
+ onTrackMenu: (CatalogTrack) -> Unit,
onOpenItem: (dev.emanuele.spot.data.SearchItem) -> Unit = {},
/** The remembered track order, and where a change to it is stored. */
storedSort: String? = null,
@@ -341,7 +341,7 @@ fun PlaylistScreen(
position = index + 1,
isCurrent = track.uri == nowPlayingUri,
onClick = { onPlay(visible, index) },
- onMenu = { anchor -> onTrackMenu(track, anchor) },
+ onMenu = { onTrackMenu(track) },
)
}
}
@@ -795,8 +795,7 @@ private fun TrackRow(
position: Int,
isCurrent: Boolean,
onClick: () -> Unit,
- /** Where the menu button is on screen, for the menu drawn above the list. */
- onMenu: (IntOffset) -> Unit,
+ onMenu: () -> Unit,
) {
val shape = RoundedCornerShape(14.dp)
// Eased rather than snapped: rows change state on every track advance, and
@@ -872,16 +871,7 @@ private fun TrackRow(
)
}
- var buttonPosition by remember { mutableStateOf(IntOffset.Zero) }
- IconButton(
- onClick = { onMenu(buttonPosition) },
- modifier = Modifier
- .size(32.dp)
- .onGloballyPositioned {
- val root = it.boundsInRoot()
- buttonPosition = IntOffset(root.left.toInt(), root.bottom.toInt())
- },
- ) {
+ IconButton(onClick = onMenu, modifier = Modifier.size(32.dp)) {
Icon(
PhosphorIcons.Regular.DotsThree,
contentDescription = "Altro",