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
Take a song back out of Liked Songs, and stop the capsule flashing
Lelonioa12c6ce41a8d
diff --git a/app/src/main/java/dev/lelonio/square/data/SpotifyApi.kt b/app/src/main/java/dev/lelonio/square/data/SpotifyApi.ktindex 073dad5..db60501 100644--- a/app/src/main/java/dev/lelonio/square/data/SpotifyApi.kt+++ b/app/src/main/java/dev/lelonio/square/data/SpotifyApi.kt@@ -305,6 +305,10 @@ interface SpotifyApi {@PUT("v1/me/tracks")suspend fun saveTracks(@Query("ids") ids: String)+ /** And takes them out again, which is the heart pressed a second time. */+ @DELETE("v1/me/tracks")+ suspend fun removeSavedTracks(@Query("ids") ids: String)+@PUT("v1/me/albums")suspend fun saveAlbums(@Query("ids") ids: String)diff --git a/app/src/main/java/dev/lelonio/square/ui/MainViewModel.kt b/app/src/main/java/dev/lelonio/square/ui/MainViewModel.ktindex e5e0b37..2ff3e97 100644--- a/app/src/main/java/dev/lelonio/square/ui/MainViewModel.kt+++ b/app/src/main/java/dev/lelonio/square/ui/MainViewModel.kt@@ -635,6 +635,15 @@ class MainViewModel(app: Application) : AndroidViewModel(app) {val busy: String? = null,/** Name of the playlist the track just went into. */val done: String? = null,+ /** And of the one it just came out of, which only Liked Songs can be. */+ val removed: String? = null,+ /**+ * Whether the track is already in Liked Songs.+ *+ * The one row in this list whose answer is known, and the one that can+ * be undone: picking it again takes the track back out.+ */+ val liked: Boolean = false,val error: String? = null,)@@ -651,6 +660,7 @@ class MainViewModel(app: Application) : AndroidViewModel(app) {trackUri = trackUri,trackTitle = trackTitle,playlists = (_state.value as? UiState.Ready)?.playlists.orEmpty(),+ liked = trackUri != null && trackUri in _liked.value,error = when {trackUri?.startsWith("spotify:track:") != true ->string(R.string.track_cannot_be_added)@@ -684,23 +694,33 @@ class MainViewModel(app: Application) : AndroidViewModel(app) {// endpoint. Picking it is what puts the heart on the track, and picking// anything else is what puts the tick there.val toLibrary = playlist.uri.endsWith(":collection")+ // Picking Liked Songs when the track is already there takes it out+ // again: the heart is the one mark in this list that can be undone,+ // and pressing it twice is how everything else undoes a like.+ val unsaving = toLibrary && current.liked- _addToPlaylist.value = current.copy(busy = playlist.uri, done = null, error = null)+ _addToPlaylist.value =+ current.copy(busy = playlist.uri, done = null, removed = null, error = null)viewModelScope.launch {runCatching {- if (toLibrary) {- container.api.saveTracks(trackUri.substringAfterLast(':'))- } else {- container.api.addToPlaylist(id, AddTracksRequestDto(listOf(trackUri)))+ when {+ unsaving -> container.api.removeSavedTracks(trackUri.substringAfterLast(':'))+ toLibrary -> container.api.saveTracks(trackUri.substringAfterLast(':'))+ else -> container.api.addToPlaylist(id, AddTracksRequestDto(listOf(trackUri)))}}.onSuccess {- _addToPlaylist.value =- _addToPlaylist.value.copy(busy = null, done = playlist.name)+ _addToPlaylist.value = _addToPlaylist.value.copy(+ busy = null,+ done = if (unsaving) null else playlist.name,+ removed = if (unsaving) playlist.name else null,+ liked = toLibrary && !unsaving,+ )// Known at once, rather than when that playlist is next// read: the tick is about the track, and the track is in a// playlist from this moment.- if (toLibrary) _liked.value = _liked.value + trackUri+ if (unsaving) _liked.value = _liked.value - trackUri+ else if (toLibrary) _liked.value = _liked.value + trackUrielse _inPlaylists.value = _inPlaylists.value + trackUri// The detail screen holds a list resolved before this track// was in it; if that is the playlist just written to, read@@ -715,7 +735,11 @@ class MainViewModel(app: Application) : AndroidViewModel(app) {// A playlist the account follows but does not own is the// one failure worth naming: it looks identical to the// user's own in every list the app draws.- error = string(R.string.add_failed, playlist.name),+ error = if (unsaving) {+ string(R.string.remove_failed, playlist.name)+ } else {+ string(R.string.add_failed, playlist.name)+ },)}}diff --git a/app/src/main/java/dev/lelonio/square/ui/player/AddToPlaylistSheet.kt b/app/src/main/java/dev/lelonio/square/ui/player/AddToPlaylistSheet.ktindex 9ad7eba..11e9e98 100644--- a/app/src/main/java/dev/lelonio/square/ui/player/AddToPlaylistSheet.kt+++ b/app/src/main/java/dev/lelonio/square/ui/player/AddToPlaylistSheet.kt@@ -36,7 +36,9 @@ import androidx.compose.ui.graphics.Colorimport androidx.compose.ui.text.style.TextOverflowimport androidx.compose.ui.unit.dpimport com.adamglin.PhosphorIcons+import com.adamglin.phosphoricons.Fillimport com.adamglin.phosphoricons.Regular+import com.adamglin.phosphoricons.fill.Heartimport com.adamglin.phosphoricons.regular.Checkimport dev.lelonio.square.ui.glass.backdrop.Backdropimport dev.lelonio.square.R@@ -135,9 +137,13 @@ fun AddToPlaylistSheet()}- if (state.done != null) {+ if (state.done != null || state.removed != null) {Text(- stringResource(R.string.added_to, state.done.orEmpty()),+ if (state.removed != null) {+ stringResource(R.string.removed_from, state.removed.orEmpty())+ } else {+ stringResource(R.string.added_to, state.done.orEmpty())+ },style = MaterialTheme.typography.bodyMedium,color = MaterialTheme.colorScheme.primary,modifier = Modifier.padding(horizontal = 22.dp, vertical = 8.dp),@@ -163,6 +169,10 @@ fun AddToPlaylistSheet(playlist = playlist,busy = state.busy == playlist.uri,added = state.done == playlist.name,+ // Liked Songs is the one row that knows where+ // the track already is, and the one a second+ // press takes it out of.+ liked = state.liked && playlist.uri.endsWith(":collection"),enabled = state.trackUri != null && state.busy == null,onClick = { onSelect(playlist) },)@@ -213,9 +223,13 @@ fun PlaylistPicker()}- if (state.done != null) {+ if (state.done != null || state.removed != null) {Text(- stringResource(R.string.added_to, state.done.orEmpty()),+ if (state.removed != null) {+ stringResource(R.string.removed_from, state.removed.orEmpty())+ } else {+ stringResource(R.string.added_to, state.done.orEmpty())+ },style = MaterialTheme.typography.bodyMedium,color = MaterialTheme.colorScheme.primary,modifier = Modifier.padding(horizontal = 22.dp, vertical = 8.dp),@@ -241,6 +255,10 @@ fun PlaylistPicker(playlist = playlist,busy = state.busy == playlist.uri,added = state.done == playlist.name,+ // Liked Songs is the one row that knows where+ // the track already is, and the one a second+ // press takes it out of.+ liked = state.liked && playlist.uri.endsWith(":collection"),enabled = state.trackUri != null && state.busy == null,onClick = { onSelect(playlist) },)@@ -255,6 +273,8 @@ private fun PlaylistRow(playlist: CatalogPlaylist,busy: Boolean,added: Boolean,+ /** In Liked Songs already, so this row removes rather than adds. */+ liked: Boolean = false,enabled: Boolean,onClick: () -> Unit,) {@@ -289,6 +309,13 @@ private fun PlaylistRow(modifier = Modifier.size(18.dp),)+ liked -> Icon(+ PhosphorIcons.Fill.Heart,+ contentDescription = stringResource(R.string.remove_from_liked),+ tint = MaterialTheme.colorScheme.primary,+ modifier = Modifier.size(20.dp),+ )+added -> Icon(PhosphorIcons.Regular.Check,contentDescription = null,diff --git a/app/src/main/java/dev/lelonio/square/ui/player/GlassSurface.kt b/app/src/main/java/dev/lelonio/square/ui/player/GlassSurface.ktindex d52861d..d9c77bc 100644--- a/app/src/main/java/dev/lelonio/square/ui/player/GlassSurface.kt+++ b/app/src/main/java/dev/lelonio/square/ui/player/GlassSurface.kt@@ -28,13 +28,20 @@ import dev.lelonio.square.ui.glass.liquidGlass* the screen stays usable rather than breaking on older phones.*//**- * Whether panes actually refract, or fall back to a plain film.+ * Whether panes refresh what they are reflecting, or hold the last look at it.** False while the player is in motion. A pane's blur and lens are RuntimeShaders* sampling a recorded layer, and during the expansion that layer changes every* frame — several full-screen shader passes per frame, which is most of what- * made the animation stutter. Nobody can see refraction through a surface that- * is travelling anyway.+ * made the animation stutter.+ *+ * It used to mean "no glass at all", and the pane fell back to a plain film for+ * the length of the travel. That saved the same work and cost a visible one:+ * this is the only surface in the player that answers the flag, so the title+ * capsule alone arrived as a flat grey patch among panes of glass and turned+ * into glass a frame after the player stopped. Holding the recording gets the+ * saving without the change of material — what is behind the player barely+ * moves anyway, being the artwork it is opening over.*/val LocalGlassEnabled = androidx.compose.runtime.staticCompositionLocalOf { true }@@ -64,18 +71,6 @@ fun GlassSurface(surfaceColor: Color = Color.Unspecified,content: @Composable () -> Unit,) {- if (!LocalGlassEnabled.current) {- Box(- modifier.background(- color = if (surfaceColor.isSpecified) surfaceColor else FallbackFilm,- shape = shape,- ),- ) {- content()- }- return- }-// The same material the bottom bar is made of, so one app has one glass.//// The bar came from elsewhere and brought its own recipe with it, and next@@ -106,11 +101,15 @@ fun GlassSurface(return}+ // Held rather than dropped while the player travels; see LocalGlassEnabled.+ val moving = !LocalGlassEnabled.current+Box(modifier.liquidGlass(config = config,shape = cornerShape,blurRadiusDp = blurDp,+ frozen = { moving },// The bar's rim, not the library's default: the app's chrome is one// material and the edge light is most of what says so.highlightAlpha = BarHighlightAlpha,diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xmlindex 7af1d6b..93380ff 100644--- a/app/src/main/res/values-de/strings.xml+++ b/app/src/main/res/values-de/strings.xml@@ -87,10 +87,13 @@<string name="remove_from_playlist">Aus der Playlist entfernen</string><string name="queued">In der Warteschlange</string><string name="added_to">Zu %1$s hinzugefügt</string>+ <string name="removed_from">Aus %1$s entfernt</string>+ <string name="remove_from_liked">Aus deinen Lieblingssongs entfernen</string><string name="no_playlists_in_account">Keine Playlists in deinem Konto</string><string name="track_cannot_be_added">Dieser Titel lässt sich nicht hinzufügen.</string><string name="connect_app_in_settings">Verbinde deine Anwendung in den Einstellungen.</string><string name="add_failed">Zu %1$s konnte nichts hinzugefügt werden. Wenn die Playlist nicht dir gehört, kannst du sie nicht ändern.</string>+ <string name="remove_failed">%1$s konnte nicht geändert werden. Versuch es gleich noch einmal.</string><string name="play_on">Abspielen auf</string><string name="no_devices">Keine Geräte verfügbar</string>diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xmlindex d7c486b..550af2e 100644--- a/app/src/main/res/values-es/strings.xml+++ b/app/src/main/res/values-es/strings.xml@@ -87,10 +87,13 @@<string name="remove_from_playlist">Quitar de la playlist</string><string name="queued">En cola</string><string name="added_to">Añadido a %1$s</string>+ <string name="removed_from">Eliminado de %1$s</string>+ <string name="remove_from_liked">Quitar de tus canciones que te gustan</string><string name="no_playlists_in_account">No hay playlists en tu cuenta</string><string name="track_cannot_be_added">Esta canción no se puede añadir.</string><string name="connect_app_in_settings">Conecta tu aplicación en los ajustes.</string><string name="add_failed">No se ha podido añadir a %1$s. Si la playlist no es tuya, no puedes modificarla.</string>+ <string name="remove_failed">No se ha podido modificar %1$s. Inténtalo dentro de un momento.</string><string name="play_on">Reproducir en</string><string name="no_devices">Ningún dispositivo disponible</string>diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xmlindex c151c20..273ba3a 100644--- a/app/src/main/res/values-fr/strings.xml+++ b/app/src/main/res/values-fr/strings.xml@@ -87,10 +87,13 @@<string name="remove_from_playlist">Retirer de la playlist</string><string name="queued">Dans la file</string><string name="added_to">Ajouté à %1$s</string>+ <string name="removed_from">Retiré de %1$s</string>+ <string name="remove_from_liked">Retirer de vos titres likés</string><string name="no_playlists_in_account">Aucune playlist dans votre compte</string><string name="track_cannot_be_added">Ce titre ne peut pas être ajouté.</string><string name="connect_app_in_settings">Connectez votre application dans les réglages.</string><string name="add_failed">Impossible d\'ajouter à %1$s. Si la playlist n\'est pas la vôtre, vous ne pouvez pas la modifier.</string>+ <string name="remove_failed">Impossible de modifier %1$s. Réessayez dans un instant.</string><string name="play_on">Lire sur</string><string name="no_devices">Aucun appareil disponible</string>diff --git a/app/src/main/res/values-hi/strings.xml b/app/src/main/res/values-hi/strings.xmlindex 162249f..c3f98ac 100644--- a/app/src/main/res/values-hi/strings.xml+++ b/app/src/main/res/values-hi/strings.xml@@ -96,10 +96,13 @@<string name="remove_from_playlist">प्लेलिस्ट से हटाएँ</string><string name="queued">कतार में</string><string name="added_to">%1$s में जोड़ा गया</string>+ <string name="removed_from">%1$s से हटाया गया</string>+ <string name="remove_from_liked">पसंद किए गए गानों से हटाएं</string><string name="no_playlists_in_account">आपके खाते में कोई प्लेलिस्ट नहीं</string><string name="track_cannot_be_added">यह गाना जोड़ा नहीं जा सकता।</string><string name="connect_app_in_settings">सेटिंग में अपना ऐप्लिकेशन कनेक्ट करें।</string><string name="add_failed">%1$s में नहीं जोड़ा जा सका। अगर प्लेलिस्ट आपकी नहीं है तो आप उसे बदल नहीं सकते।</string>+ <string name="remove_failed">%1$s को बदला नहीं जा सका। थोड़ी देर बाद फिर कोशिश करें।</string><!-- Player --><string name="play_on">यहाँ चलाएँ</string>diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xmlindex 936c643..7c9f086 100644--- a/app/src/main/res/values-it/strings.xml+++ b/app/src/main/res/values-it/strings.xml@@ -88,10 +88,13 @@<string name="remove_from_playlist">Rimuovi dalla playlist</string><string name="queued">In coda</string><string name="added_to">Aggiunto a %1$s</string>+ <string name="removed_from">Rimosso da %1$s</string>+ <string name="remove_from_liked">Togli dai brani che ti piacciono</string><string name="no_playlists_in_account">Nessuna playlist nel tuo account</string><string name="track_cannot_be_added">Questo brano non può essere aggiunto.</string><string name="connect_app_in_settings">Collega la tua applicazione nelle impostazioni.</string><string name="add_failed">Non è stato possibile aggiungere a %1$s. Se la playlist non è tua, non puoi modificarla.</string>+ <string name="remove_failed">Non è stato possibile modificare %1$s. Riprova tra poco.</string><string name="play_on">Riproduci su</string><string name="no_devices">Nessun dispositivo disponibile</string>diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xmlindex 513f43c..7518ba0 100644--- a/app/src/main/res/values-pt/strings.xml+++ b/app/src/main/res/values-pt/strings.xml@@ -87,10 +87,13 @@<string name="remove_from_playlist">Remover da playlist</string><string name="queued">Na fila</string><string name="added_to">Adicionado a %1$s</string>+ <string name="removed_from">Removido de %1$s</string>+ <string name="remove_from_liked">Remover das suas músicas curtidas</string><string name="no_playlists_in_account">Nenhuma playlist na sua conta</string><string name="track_cannot_be_added">Esta faixa não pode ser adicionada.</string><string name="connect_app_in_settings">Conecte a sua aplicação nas configurações.</string><string name="add_failed">Não foi possível adicionar a %1$s. Se a playlist não é sua, você não pode alterá-la.</string>+ <string name="remove_failed">Não foi possível alterar %1$s. Tente de novo daqui a pouco.</string><string name="play_on">Tocar em</string><string name="no_devices">Nenhum dispositivo disponível</string>diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xmlindex 4ef266b..3422766 100644--- a/app/src/main/res/values-tr/strings.xml+++ b/app/src/main/res/values-tr/strings.xml@@ -96,10 +96,13 @@<string name="remove_from_playlist">Çalma listesinden çıkar</string><string name="queued">Sıraya eklendi</string><string name="added_to">%1$s listesine eklendi</string>+ <string name="removed_from">%1$s içinden kaldırıldı</string>+ <string name="remove_from_liked">Beğenilen şarkılardan kaldır</string><string name="no_playlists_in_account">Hesabında çalma listesi yok</string><string name="track_cannot_be_added">Bu şarkı eklenemiyor.</string><string name="connect_app_in_settings">Uygulamanı ayarlardan bağla.</string><string name="add_failed">%1$s listesine eklenemedi. Liste senin değilse değiştiremezsin.</string>+ <string name="remove_failed">%1$s değiştirilemedi. Birazdan tekrar dene.</string><!-- Player --><string name="play_on">Şurada çal</string>diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xmlindex 92837a8..c7085d4 100644--- a/app/src/main/res/values/strings.xml+++ b/app/src/main/res/values/strings.xml@@ -102,10 +102,13 @@<string name="remove_from_playlist">Remove from playlist</string><string name="queued">Queued</string><string name="added_to">Added to %1$s</string>+ <string name="removed_from">Removed from %1$s</string>+ <string name="remove_from_liked">Remove from Liked Songs</string><string name="no_playlists_in_account">No playlists in your account</string><string name="track_cannot_be_added">This song cannot be added.</string><string name="connect_app_in_settings">Connect your application in settings.</string><string name="add_failed">%1$s could not be added to. If the playlist is not yours, you cannot change it.</string>+ <string name="remove_failed">%1$s could not be changed. Try again in a moment.</string><!-- Player --><string name="play_on">Play on</string>