Unofficial YouTube Music / Spotify Premium client for Android, built in Liquid Glass. Audio effects, Spotify Connect, listening history, 8 languages. Rust core on librespot.
Kotlin alternativeandroidandroid-applicationclientglassmorphisminnertubelibrespotliquid-glassspotifyspotify-connectspotifyapiyoutube-musicyoutube-playerytdlnis
Glass context menus, with remove-from-playlist
Lelonio7c540ca8521c
diff --git a/.claude/settings.local.json b/.claude/settings.local.jsonindex b02912c..3612619 100644--- a/.claude/settings.local.json+++ b/.claude/settings.local.json@@ -114,7 +114,8 @@"Bash(git commit -q -m 'Read playlists through the Web API, and keep them *)","Bash(git commit -q -m 'A draggable scrollbar, and sorting by when tracks were added *)","Bash(git commit -q -m 'Track menus, a page-coloured glass, and a remembered sort *)",- "Bash(git commit -q -m 'Keep the glass out of the layer it samples *)"+ "Bash(git commit -q -m 'Keep the glass out of the layer it samples *)",+ "Bash(git commit -q -m 'Glass context menus, with remove-from-playlist *)"]}}diff --git a/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/configure_fingerprint.bin b/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/configure_fingerprint.binindex ceed55d..cd70365 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 Logljh/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/additional_project_files.txtCA-?com.android.build.gradle.internal.cxx.io.EncodedFileFingerPrint �����3 ����3i+?com.android.build.gradle.internal.cxx.io.EncodedFileFingerPrint �֥��3 ����3ig-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� ����3nl-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 �֥��3db-`/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 @ ����3ec-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�� ����3ig-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 �" ����3om-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 ( ����3ge-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 ����3DB-@/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 filediff --git a/app/src/main/java/dev/emanuele/spot/data/SpotifyApi.kt b/app/src/main/java/dev/emanuele/spot/data/SpotifyApi.ktindex 3d07e14..687b078 100644--- a/app/src/main/java/dev/emanuele/spot/data/SpotifyApi.kt+++ b/app/src/main/java/dev/emanuele/spot/data/SpotifyApi.kt@@ -4,6 +4,7 @@ import kotlinx.serialization.SerialNameimport kotlinx.serialization.Serializableimport retrofit2.http.Bodyimport retrofit2.http.GET+import retrofit2.http.HTTPimport retrofit2.http.POSTimport retrofit2.http.PUTimport retrofit2.http.Path@@ -112,6 +113,22 @@ interface SpotifyApi {@Body request: AddTracksRequestDto,)+ /**+ * Removes every occurrence of the given tracks from a playlist.+ *+ * Every occurrence: pinning it to one position needs the playlist's+ * snapshot id, and a playlist holding the same track twice is rare enough+ * that carrying snapshot state around for it is not worth the failure modes.+ *+ * `@HTTP` rather than `@DELETE` because this one carries a body, which+ * Retrofit's `@DELETE` does not allow.+ */+ @HTTP(method = "DELETE", path = "v1/playlists/{id}/tracks", hasBody = true)+ suspend fun removeFromPlaylist(+ @Path("id") playlistId: String,+ @Body request: RemoveTracksRequestDto,+ )+@GET("v1/search")suspend fun search(@Query("q") query: String,@@ -123,6 +140,12 @@ interface SpotifyApi {@Serializabledata class AddTracksRequestDto(val uris: List<String>)+@Serializable+data class RemoveTracksRequestDto(val tracks: List<TrackUriDto>)++@Serializable+data class TrackUriDto(val uri: String)+@Serializabledata class PageDto<T>(val items: List<T>,diff --git a/app/src/main/java/dev/emanuele/spot/ui/MainViewModel.kt b/app/src/main/java/dev/emanuele/spot/ui/MainViewModel.ktindex 4987ddb..9a3af37 100644--- a/app/src/main/java/dev/emanuele/spot/ui/MainViewModel.kt+++ b/app/src/main/java/dev/emanuele/spot/ui/MainViewModel.kt@@ -7,6 +7,8 @@ import dev.emanuele.spot.SpotApplicationimport dev.emanuele.spot.auth.SpotifyOAuthimport dev.emanuele.spot.data.Catalogimport dev.emanuele.spot.data.AddTracksRequestDto+import dev.emanuele.spot.data.RemoveTracksRequestDto+import dev.emanuele.spot.data.TrackUriDtoimport dev.emanuele.spot.data.CatalogPlaylistimport dev.emanuele.spot.data.CatalogTrackimport dev.emanuele.spot.data.SearchItem@@ -649,6 +651,39 @@ class MainViewModel(app: Application) : AndroidViewModel(app) {}}+ /**+ * Removes a track from the playlist currently open.+ *+ * Optimistic, unlike adding: the row disappearing *is* the confirmation, and+ * putting it back is a possible outcome the user can see, whereas a row that+ * sits there for a round trip before vanishing reads as a tap that missed.+ * Every occurrence goes, which matters only on a playlist holding the same+ * track twice; see SpotifyApi.removeFromPlaylist.+ */+ fun removeFromPlaylist(track: CatalogTrack) {+ val uri = _playlist.value.uri ?: return+ if (!uri.startsWith("spotify:playlist:")) return++ val before = _playlist.value.tracks+ _playlist.value = _playlist.value.copy(tracks = before.filterNot { it.uri == track.uri })+ invalidateContext(uri)++ viewModelScope.launch {+ runCatching {+ container.api.removeFromPlaylist(+ uri.substringAfterLast(':'),+ RemoveTracksRequestDto(listOf(TrackUriDto(track.uri))),+ )+ }.onFailure {+ android.util.Log.e(TAG, "remove from playlist failed: ${chain(it)}", it)+ // Only if the screen is still showing the same playlist.+ if (_playlist.value.uri == uri) {+ _playlist.value = _playlist.value.copy(tracks = before)+ }+ }+ }+ }+/** Drops a context from the cache so the next open re-reads it. */private fun invalidateContext(uri: String) {contextCache.remove(uri)diff --git a/app/src/main/java/dev/emanuele/spot/ui/SpotApp.kt b/app/src/main/java/dev/emanuele/spot/ui/SpotApp.ktindex eab05b7..d604bf0 100644--- a/app/src/main/java/dev/emanuele/spot/ui/SpotApp.kt+++ b/app/src/main/java/dev/emanuele/spot/ui/SpotApp.kt@@ -367,6 +367,7 @@ fun SpotApp(onAddToPlaylist = { track ->viewModel.openAddToPlaylist(track.uri, track.name)},+ onRemoveFromPlaylist = viewModel::removeFromPlaylist,storedSort = trackSort,onSortChange = viewModel::setTrackSort,onOpenItem = { item ->diff --git a/app/src/main/java/dev/emanuele/spot/ui/components/GlassMenu.kt b/app/src/main/java/dev/emanuele/spot/ui/components/GlassMenu.ktnew file mode 100644index 0000000..6f20c49--- /dev/null+++ b/app/src/main/java/dev/emanuele/spot/ui/components/GlassMenu.kt@@ -0,0 +1,118 @@+package dev.emanuele.spot.ui.components++import androidx.compose.animation.core.animateFloatAsState+import androidx.compose.animation.core.tween+import androidx.compose.foundation.clickable+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.ColumnScope+import androidx.compose.foundation.layout.Row+import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.layout.size+import androidx.compose.foundation.layout.width+import androidx.compose.foundation.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.runtime.getValue+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.TransformOrigin+import androidx.compose.ui.graphics.graphicsLayer+import androidx.compose.ui.graphics.vector.ImageVector+import androidx.compose.ui.unit.IntOffset+import androidx.compose.ui.unit.dp+import androidx.compose.ui.window.Popup+import androidx.compose.ui.window.PopupProperties+import com.kyant.backdrop.Backdrop+import dev.emanuele.spot.ui.player.GlassSurface++/**+ * A context menu made of the same glass as everything else.+ *+ * Material's `DropdownMenu` draws an opaque elevated card. It works, and it is+ * the one surface in the app that announces it came from a different design+ * system — a paper rectangle over a page built entirely out of refraction.+ *+ * The anchor is whatever composable this is placed inside, so it belongs in the+ * `Box` around the button that opens it.+ */+@Composable+fun GlassMenu(+ expanded: Boolean,+ onDismiss: () -> Unit,+ backdrop: Backdrop,+ modifier: Modifier = Modifier,+ /** Where the menu sits relative to its anchor. */+ alignment: Alignment = Alignment.TopEnd,+ offset: IntOffset = IntOffset(0, 0),+ content: @Composable ColumnScope.() -> Unit,+) {+ if (!expanded) return++ Popup(+ alignment = alignment,+ offset = offset,+ onDismissRequest = onDismiss,+ properties = PopupProperties(focusable = true),+ ) {+ val shape = RoundedCornerShape(20.dp)+ val scale by animateFloatAsState(+ targetValue = 1f,+ animationSpec = tween(140),+ label = "menuScale",+ )++ GlassSurface(+ backdrop = backdrop,+ shape = shape,+ surfaceColor = MenuFilm,+ modifier = modifier+ .width(236.dp)+ // Grows out of the corner it is anchored to rather than+ // appearing at full size, which is the only thing that ties it+ // to the button that was tapped.+ .graphicsLayer {+ scaleX = 0.92f + 0.08f * scale+ scaleY = 0.92f + 0.08f * scale+ this.alpha = scale+ transformOrigin = TransformOrigin(1f, 0f)+ }+ .clip(shape),+ ) {+ Column(Modifier.padding(vertical = 6.dp), content = content)+ }+ }+}++@Composable+fun GlassMenuItem(+ label: String,+ icon: ImageVector,+ /** Drawn in the error colour: this one takes something away. */+ destructive: Boolean = false,+ onClick: () -> Unit,+) {+ val tint = if (destructive) MaterialTheme.colorScheme.error else Color.White+ Row(+ Modifier+ .fillMaxWidth()+ .clickable(onClick = onClick)+ .padding(horizontal = 18.dp, vertical = 13.dp),+ verticalAlignment = Alignment.CenterVertically,+ ) {+ Icon(icon, contentDescription = null, tint = tint, modifier = Modifier.size(19.dp))+ Text(+ label,+ style = MaterialTheme.typography.bodyLarge,+ color = tint,+ modifier = Modifier.padding(start = 14.dp),+ )+ }+}++/** Enough film to read text over anything the page puts behind it. */+private val MenuFilm = Color.White.copy(alpha = 0.14f)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.ktindex cd1adf7..7e4d2dd 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@@ -24,8 +24,6 @@ import androidx.compose.foundation.lazy.rememberLazyListStateimport androidx.compose.foundation.shape.CircleShapeimport androidx.compose.foundation.shape.RoundedCornerShapeimport androidx.compose.material3.CircularProgressIndicator-import androidx.compose.material3.DropdownMenu-import androidx.compose.material3.DropdownMenuItemimport androidx.compose.material3.Iconimport androidx.compose.material3.IconButtonimport androidx.compose.material3.MaterialTheme@@ -54,6 +52,8 @@ import com.kyant.backdrop.Backdropimport com.kyant.backdrop.backdrops.layerBackdropimport com.kyant.backdrop.backdrops.rememberLayerBackdropimport dev.emanuele.spot.ui.components.Artwork+import dev.emanuele.spot.ui.components.GlassMenu+import dev.emanuele.spot.ui.components.GlassMenuItemimport dev.emanuele.spot.ui.components.LazyScrollBarimport dev.emanuele.spot.ui.components.SwipeToQueueimport dev.emanuele.spot.ui.glass.LiquidButton@@ -75,6 +75,7 @@ import com.adamglin.phosphoricons.regular.LinkSimpleimport com.adamglin.phosphoricons.regular.Plusimport com.adamglin.phosphoricons.regular.Queueimport com.adamglin.phosphoricons.regular.Shuffle+import com.adamglin.phosphoricons.regular.Trashimport com.adamglin.phosphoricons.regular.X/** How the track list is ordered. */@@ -97,6 +98,7 @@ fun PlaylistScreen(onShuffle: (List<CatalogTrack>) -> Unit,/** Opens the app-wide "add to playlist" sheet for one track. */onAddToPlaylist: (CatalogTrack) -> Unit,+ onRemoveFromPlaylist: (CatalogTrack) -> Unit,onOpenItem: (dev.emanuele.spot.data.SearchItem) -> Unit = {},/** The remembered track order, and where a change to it is stored. */storedSort: String? = null,@@ -205,6 +207,7 @@ fun PlaylistScreen(} else {"Brani"},+ backdrop = pageBackdrop,sort = sort,sortOpen = sortOpen,onSortOpen = { sortOpen = it },@@ -280,6 +283,15 @@ fun PlaylistScreen(onClick = { onPlay(visible, index) },onEnqueue = { onEnqueue(track) },onAddToPlaylist = { onAddToPlaylist(track) },+ // Only a playlist can have something taken out of+ // it; an album or an artist's top tracks is not a+ // list the account owns.+ onRemove = if (state.kind == MainViewModel.DetailKind.PLAYLIST) {+ { onRemoveFromPlaylist(track) }+ } else {+ null+ },+ backdrop = pageBackdrop,)}}@@ -553,6 +565,7 @@ private fun AlbumStrip(@Composableprivate fun SectionHeader(title: String,+ backdrop: Backdrop,sort: TrackSort,sortOpen: Boolean,onSortOpen: (Boolean) -> Unit,@@ -579,18 +592,25 @@ private fun SectionHeader(modifier = Modifier.size(20.dp),)}- DropdownMenu(expanded = sortOpen, onDismissRequest = { onSortOpen(false) }) {+ // The same glass as the track menu: two context menus on one screen+ // made of two different materials is worse than either choice.+ GlassMenu(+ expanded = sortOpen,+ onDismiss = { onSortOpen(false) },+ backdrop = backdrop,+ ) {TrackSort.entries.forEach { option ->- DropdownMenuItem(- text = { Text(option.label) },- trailingIcon = {- if (option == sort) Icon(PhosphorIcons.Regular.Check, contentDescription = null)- },- onClick = {- onSort(option)- onSortOpen(false)+ GlassMenuItem(+ option.label,+ if (option == sort) {+ PhosphorIcons.Regular.Check+ } else {+ PhosphorIcons.Regular.ArrowsDownUp},- )+ ) {+ onSort(option)+ onSortOpen(false)+ }}}}@@ -622,6 +642,8 @@ private fun TrackRow(onClick: () -> Unit,onEnqueue: () -> Unit,onAddToPlaylist: () -> Unit,+ onRemove: (() -> Unit)?,+ backdrop: Backdrop,) {var menuOpen by remember { mutableStateOf(false) }val shape = RoundedCornerShape(14.dp)@@ -710,10 +732,12 @@ private fun TrackRow(TrackMenu(expanded = menuOpen,track = track,+ backdrop = backdrop,onDismiss = { menuOpen = false },onPlay = onClick,onEnqueue = onEnqueue,onAddToPlaylist = onAddToPlaylist,+ onRemove = onRemove,)}}@@ -731,37 +755,40 @@ private fun TrackRow(private fun TrackMenu(expanded: Boolean,track: CatalogTrack,+ backdrop: Backdrop,onDismiss: () -> Unit,onPlay: () -> Unit,onEnqueue: () -> Unit,onAddToPlaylist: () -> Unit,+ /** Null unless this list is a playlist the account can edit. */+ onRemove: (() -> Unit)?,) {val clipboard = LocalClipboardManager.current- DropdownMenu(expanded = expanded, onDismissRequest = onDismiss) {- DropdownMenuItem(- text = { Text("Riproduci") },- leadingIcon = { Icon(PhosphorIcons.Fill.Play, contentDescription = null) },- onClick = { onDismiss(); onPlay() },- )- DropdownMenuItem(- text = { Text("Aggiungi alla coda") },- leadingIcon = { Icon(PhosphorIcons.Regular.Queue, contentDescription = null) },- onClick = { onDismiss(); onEnqueue() },- )- DropdownMenuItem(- text = { Text("Aggiungi a una playlist") },- leadingIcon = { Icon(PhosphorIcons.Regular.Plus, contentDescription = null) },- onClick = { onDismiss(); onAddToPlaylist() },- )- DropdownMenuItem(- text = { Text("Copia link") },- leadingIcon = { Icon(PhosphorIcons.Regular.LinkSimple, contentDescription = null) },- onClick = {+ GlassMenu(expanded = expanded, onDismiss = onDismiss, backdrop = backdrop) {+ GlassMenuItem("Riproduci", PhosphorIcons.Fill.Play) { onDismiss(); onPlay() }+ GlassMenuItem("Aggiungi alla coda", PhosphorIcons.Regular.Queue) {+ onDismiss()+ onEnqueue()+ }+ GlassMenuItem("Aggiungi a una playlist", PhosphorIcons.Regular.Plus) {+ onDismiss()+ onAddToPlaylist()+ }+ GlassMenuItem("Copia link", PhosphorIcons.Regular.LinkSimple) {+ onDismiss()+ clipboard.setText(AnnotatedString(track.openLink()))+ }+ if (onRemove != null) {+ GlassMenuItem(+ "Rimuovi dalla playlist",+ PhosphorIcons.Regular.Trash,+ destructive = true,+ ) {onDismiss()- clipboard.setText(AnnotatedString(track.openLink()))- },- )+ onRemove()+ }+ }}}