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.

Say where the track came from, and colour the control that opened a panel

Leloniob352563425ab
diff --git a/app/.cxx/Debug/286k5v33/arm64-v8a/configure_fingerprint.bin b/app/.cxx/Debug/286k5v33/arm64-v8a/configure_fingerprint.bin
index 60109df..4765012 100644
--- a/app/.cxx/Debug/286k5v33/arm64-v8a/configure_fingerprint.bin
+++ b/app/.cxx/Debug/286k5v33/arm64-v8a/configure_fingerprint.bin
@@ -2,27 +2,27 @@ C/C++ Structured Logc
a
_/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/additional_project_files.txtC
A
-?com.android.build.gradle.internal.cxx.io.EncodedFileFingerPrint  �����3  ��߈�3`
+?com.android.build.gradle.internal.cxx.io.EncodedFileFingerPrint  �Ӝ��3  ��߈�3`
^
-\/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/android_gradle_build.json  �����3� ��߈�3e
+\/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/android_gradle_build.json  �Ӝ��3� ��߈�3e
c
-a/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/android_gradle_build_mini.json  �����3� ��߈�3R
+a/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/android_gradle_build_mini.json  �Ӝ��3� ��߈�3R
P
-N/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/build.ninja  �����3� ��߈�3V
+N/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/build.ninja  �Ӝ��3� ��߈�3V
T
-R/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/build.ninja.txt  �����3[
+R/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/build.ninja.txt  �Ӝ��3[
Y
-W/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/build_file_index.txt  �����3 @ ��߈�3\
+W/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/build_file_index.txt  �Ӝ��3 @ ��߈�3\
Z
-X/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/compile_commands.json  �����3֚ ��߈�3`
+X/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/compile_commands.json  �Ӝ��3֚ ��߈�3`
^
-\/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/compile_commands.json.bin  �����3 �" ��߈�3f
+\/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/compile_commands.json.bin  �Ӝ��3 �" ��߈�3f
d
-b/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/metadata_generation_command.txt  �����3
+b/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/metadata_generation_command.txt  �Ӝ��3
� ��߈�3Y
W
-U/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/prefab_config.json  �����3  ( ��߈�3^
+U/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/prefab_config.json  �Ӝ��3  ( ��߈�3^
\
-Z/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/symbol_folder_index.txt  �����3  Y ��߈�3D
+Z/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/symbol_folder_index.txt  �Ӝ��3  Y ��߈�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/ui/MainActivity.kt b/app/src/main/java/dev/emanuele/spot/ui/MainActivity.kt
index a834c47..f49de14 100644
--- a/app/src/main/java/dev/emanuele/spot/ui/MainActivity.kt
+++ b/app/src/main/java/dev/emanuele/spot/ui/MainActivity.kt
@@ -105,9 +105,14 @@ class MainActivity : ComponentActivity() {
index: Int,
contextUri: String? = null,
asContext: Boolean = false,
+ contextLabel: String = "",
) {
val player = controller ?: return
- player.setMediaItems(tracks.map { toMediaItem(it, contextUri, asContext) }, index, 0L)
+ player.setMediaItems(
+ tracks.map { toMediaItem(it, contextUri, asContext, contextLabel) },
+ index,
+ 0L,
+ )
player.prepare()
player.play()
}
@@ -132,6 +137,7 @@ class MainActivity : ComponentActivity() {
track: CatalogTrack,
contextUri: String? = null,
asContext: Boolean = false,
+ contextLabel: String = "",
): MediaItem =
MediaItem.Builder()
// The media id carries the Spotify URI; PlayQueue refuses anything else.
@@ -147,10 +153,11 @@ class MainActivity : ComponentActivity() {
// the engine lives in the service and this is the only
// channel between them that survives the session boundary.
.setExtras(
- contextUri?.let {
- android.os.Bundle().apply {
- putString(EXTRA_CONTEXT_URI, it)
- putBoolean(EXTRA_CONTEXT_ORDERED, asContext)
+ android.os.Bundle().apply {
+ contextUri?.let { putString(EXTRA_CONTEXT_URI, it) }
+ putBoolean(EXTRA_CONTEXT_ORDERED, asContext)
+ if (contextLabel.isNotEmpty()) {
+ putString(EXTRA_CONTEXT_LABEL, contextLabel)
}
},
)
@@ -164,3 +171,6 @@ const val EXTRA_CONTEXT_URI = "dev.emanuele.spot.CONTEXT_URI"
/** Whether that queue is the context in its own order; see SpotApp's `onPlay`. */
const val EXTRA_CONTEXT_ORDERED = "dev.emanuele.spot.CONTEXT_ORDERED"
+
+/** What to show the listener: "Playlist · Estate 2025", "Ricerca". */
+const val EXTRA_CONTEXT_LABEL = "dev.emanuele.spot.CONTEXT_LABEL"
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 6829b7c..4973a1f 100644
--- a/app/src/main/java/dev/emanuele/spot/ui/SpotApp.kt
+++ b/app/src/main/java/dev/emanuele/spot/ui/SpotApp.kt
@@ -162,7 +162,7 @@ fun SpotApp(
* the queue *is* that context in its own order, in which case playback is
* handed to Spotify as the context itself.
*/
- onPlay: (List<CatalogTrack>, Int, String?, Boolean) -> Unit,
+ onPlay: (List<CatalogTrack>, Int, String?, Boolean, String) -> Unit,
/** Appends one track to the end of the queue; see the swipe gesture on rows. */
onEnqueue: (CatalogTrack) -> Unit,
/**
@@ -393,7 +393,7 @@ fun SpotApp(
playlistOrder = playlistOrder,
recent = recent,
onPlayRecent = { tracks, index ->
- onPlay(tracks, index, null, false)
+ onPlay(tracks, index, null, false, "Riascolta")
},
feed = feed,
onOpenItem = { item ->
@@ -415,7 +415,7 @@ fun SpotApp(
onClientIdChange = viewModel::onWebApiClientIdChange,
onConnectWebApi = { viewModel.connectWebApi() },
onPlayTrack = { tracks, index ->
- onPlay(tracks, index, null, false)
+ onPlay(tracks, index, null, false, "Ricerca")
},
onEnqueue = onEnqueue,
onOpenContext = { item ->
@@ -469,7 +469,13 @@ fun SpotApp(
nowPlayingUri = playback.mediaId,
onBack = { navController.popBackStack() },
onPlay = { tracks, index, asContext ->
- onPlay(tracks, index, playlist.uri, asContext)
+ onPlay(
+ tracks,
+ index,
+ playlist.uri,
+ asContext,
+ playlist.sourceLabel(),
+ )
},
onEnqueue = onEnqueue,
onShuffle = { tracks ->
@@ -480,7 +486,13 @@ fun SpotApp(
// Shuffled: the order on screen is not
// the one that will play, so this is a
// selection rather than the context.
- onPlay(tracks, 0, playlist.uri, false)
+ onPlay(
+ tracks,
+ 0,
+ playlist.uri,
+ false,
+ playlist.sourceLabel(),
+ )
},
onAddToPlaylist = { track ->
viewModel.openAddToPlaylist(track.uri, track.name)
@@ -636,7 +648,7 @@ fun SpotApp(
if (menu != null) {
TrackSheetAction("Riproduci", PhosphorIcons.Fill.Play) {
trackMenu = null
- onPlay(listOf(menu.track), 0, null, false)
+ onPlay(listOf(menu.track), 0, null, false, "")
}
TrackSheetAction("Aggiungi alla coda", PhosphorIcons.Regular.Queue) {
trackMenu = null
@@ -890,6 +902,15 @@ private fun NavHostController.openPlaylist(viewModel: MainViewModel, playlist: C
* Without popping back to the start, tapping between tabs would grow the back
* stack forever and the system back button would walk the entire history.
*/
+/**
+ * What the player says the track is coming from: "Playlist · Estate 2025".
+ *
+ * The kind first, because the name alone reads as a title and the two are worth
+ * telling apart at a glance while a cover is filling the screen.
+ */
+private fun MainViewModel.PlaylistState.sourceLabel(): String =
+ if (name.isBlank()) kind.label else "${kind.label} · $name"
+
private fun NavHostController.switchTab(route: String) {
if (currentDestination?.route == route) return
navigate(route) {
diff --git a/app/src/main/java/dev/emanuele/spot/ui/player/PlayerPanel.kt b/app/src/main/java/dev/emanuele/spot/ui/player/PlayerPanel.kt
index 16a8127..8550136 100644
--- a/app/src/main/java/dev/emanuele/spot/ui/player/PlayerPanel.kt
+++ b/app/src/main/java/dev/emanuele/spot/ui/player/PlayerPanel.kt
@@ -46,10 +46,14 @@ import dev.emanuele.spot.ui.glass.LiquidSlider
import kotlin.math.ln
import kotlin.math.roundToInt
import com.adamglin.PhosphorIcons
+import com.adamglin.phosphoricons.Fill
import com.adamglin.phosphoricons.Regular
import com.adamglin.phosphoricons.regular.Plus
import com.adamglin.phosphoricons.regular.SlidersHorizontal
import com.adamglin.phosphoricons.regular.TextAlignLeft
+import com.adamglin.phosphoricons.fill.SlidersHorizontal
+import com.adamglin.phosphoricons.fill.TextAlignLeft
+import com.adamglin.phosphoricons.fill.VinylRecord
import com.adamglin.phosphoricons.regular.VinylRecord
import com.adamglin.phosphoricons.regular.X
@@ -132,13 +136,24 @@ fun PlayerPanelSection(
.fillMaxWidth(0.72f)
.padding(top = 14.dp),
) {
- PanelTab(PhosphorIcons.Regular.VinylRecord, "Copertina", selected == 0) { onSelect(PlayerPanel.NONE) }
- PanelTab(PhosphorIcons.Regular.TextAlignLeft, "Testo", selected == 1) {
- onSelect(PlayerPanel.LYRICS)
- }
- PanelTab(PhosphorIcons.Regular.SlidersHorizontal, "Effetti", selected == 2) {
- onSelect(PlayerPanel.EFFECTS)
- }
+ PanelTab(
+ icon = PhosphorIcons.Regular.VinylRecord,
+ activeIcon = PhosphorIcons.Fill.VinylRecord,
+ label = "Copertina",
+ selected = selected == 0,
+ ) { onSelect(PlayerPanel.NONE) }
+ PanelTab(
+ icon = PhosphorIcons.Regular.TextAlignLeft,
+ activeIcon = PhosphorIcons.Fill.TextAlignLeft,
+ label = "Testo",
+ selected = selected == 1,
+ ) { onSelect(PlayerPanel.LYRICS) }
+ PanelTab(
+ icon = PhosphorIcons.Regular.SlidersHorizontal,
+ activeIcon = PhosphorIcons.Fill.SlidersHorizontal,
+ label = "Effetti",
+ selected = selected == 2,
+ ) { onSelect(PlayerPanel.EFFECTS) }
}
}
@@ -147,13 +162,19 @@ fun PlayerPanelSection(
@Composable
private fun RowScope.PanelTab(
icon: androidx.compose.ui.graphics.vector.ImageVector,
+ /** The filled cut of the same glyph, for the view being shown. */
+ activeIcon: androidx.compose.ui.graphics.vector.ImageVector,
label: String,
selected: Boolean,
onClick: () -> Unit,
) {
LiquidBottomTab(onClick = onClick) {
Icon(
- imageVector = icon,
+ // Filled rather than only brighter. The indicator behind the icon
+ // moves, so at a glance the two states differed by a shade of grey
+ // sliding around; a solid glyph says which view you are in without
+ // being read against its neighbours.
+ imageVector = if (selected) activeIcon else icon,
contentDescription = label,
tint = if (selected) GlassInk else GlassInkDim,
modifier = Modifier.size(19.dp),
diff --git a/app/src/main/java/dev/emanuele/spot/ui/player/PlayerScreen.kt b/app/src/main/java/dev/emanuele/spot/ui/player/PlayerScreen.kt
index 9cdaf90..c92b9ac 100644
--- a/app/src/main/java/dev/emanuele/spot/ui/player/PlayerScreen.kt
+++ b/app/src/main/java/dev/emanuele/spot/ui/player/PlayerScreen.kt
@@ -335,6 +335,7 @@ fun PlayerScreen(
TopBar(
backdrop = glassBackdrop,
panel = panel,
+ source = state.source,
onCollapse = onCollapse,
onOpenDevices = {
panel = if (panel == PlayerPanel.DEVICES) {
@@ -528,11 +529,11 @@ fun PlayerScreen(
Icon(
PhosphorIcons.Regular.Queue,
contentDescription = "Coda",
- tint = if (panel == PlayerPanel.QUEUE) {
- MaterialTheme.colorScheme.primary
- } else {
- GlassInk
- },
+ // Coloured while its panel is the one
+ // open: these buttons stay on screen
+ // with the panel showing, and nothing
+ // else said which of them put it there.
+ tint = panelTint(panel == PlayerPanel.QUEUE),
modifier = Modifier.size(20.dp),
)
}
@@ -552,7 +553,7 @@ fun PlayerScreen(
Icon(
PhosphorIcons.Regular.Plus,
contentDescription = "Aggiungi a una playlist",
- tint = GlassInk,
+ tint = panelTint(panel == PlayerPanel.ADD_TO_PLAYLIST),
modifier = Modifier.size(20.dp),
)
}
@@ -619,6 +620,8 @@ fun PlayerScreen(
private fun TopBar(
backdrop: Backdrop,
panel: PlayerPanel,
+ /** Where the queue came from: "Playlist · Estate 2025", "Ricerca". */
+ source: String,
onCollapse: () -> Unit,
onOpenDevices: () -> Unit,
) {
@@ -640,7 +643,12 @@ private fun TopBar(
PlayerPanel.QUEUE -> "In coda"
PlayerPanel.DEVICES -> "Riproduci su"
PlayerPanel.ADD_TO_PLAYLIST -> "Aggiungi a una playlist"
- PlayerPanel.NONE -> "In riproduzione"
+ // The source in place of the words "in riproduzione", which
+ // said nothing the screen was not already saying. What is worth
+ // knowing here is where the track came from — the playlist you
+ // opened, the album, the search — and this is the one line of
+ // the player not already spoken for.
+ PlayerPanel.NONE -> source.ifBlank { "In riproduzione" }
},
animationSpec = tween(220),
label = "topBarTitle",
@@ -660,7 +668,7 @@ private fun TopBar(
Icon(
PhosphorIcons.Regular.Devices,
contentDescription = "Dispositivi",
- tint = GlassInk,
+ tint = panelTint(panel == PlayerPanel.DEVICES),
)
}
@@ -914,6 +922,11 @@ private fun GlassButton(
RoundGlassButton(backdrop = backdrop, size = 44.dp, onClick = onClick) { content() }
}
+/** A control that opened the panel currently showing is coloured, not just lit. */
+@Composable
+private fun panelTint(active: Boolean) =
+ if (active) MaterialTheme.colorScheme.primary else GlassInk
+
@Composable
private fun ToggleIcon(
icon: androidx.compose.ui.graphics.vector.ImageVector,
diff --git a/app/src/main/java/dev/emanuele/spot/ui/player/PlayerState.kt b/app/src/main/java/dev/emanuele/spot/ui/player/PlayerState.kt
index 3b03f08..4c8f9b6 100644
--- a/app/src/main/java/dev/emanuele/spot/ui/player/PlayerState.kt
+++ b/app/src/main/java/dev/emanuele/spot/ui/player/PlayerState.kt
@@ -8,6 +8,7 @@ import androidx.compose.runtime.mutableLongStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.media3.common.Player
+import dev.emanuele.spot.ui.EXTRA_CONTEXT_LABEL
import kotlinx.coroutines.delay
/**
@@ -36,6 +37,15 @@ data class PlaybackState(
val speed: Float = 1f,
/** Pitch, independent of [speed]. */
val pitch: Float = 1f,
+ /**
+ * Where this queue came from, ready to read: "Playlist · Estate 2025".
+ *
+ * Carried on the media item rather than derived here, because by the time
+ * the player sees a track the only thing left of the tap that started it is
+ * a URI, and a URI does not say whether it was reached from a playlist, an
+ * album, an artist or a search.
+ */
+ val source: String = "",
)
/** Mirrors the slow-changing part of a [Player] into Compose state. */
@@ -66,6 +76,7 @@ fun rememberPlaybackState(player: Player?): State<PlaybackState> {
repeatMode = player.repeatMode,
speed = player.playbackParameters.speed,
pitch = player.playbackParameters.pitch,
+ source = metadata.extras?.getString(EXTRA_CONTEXT_LABEL).orEmpty(),
)
// Equality check, not blind assignment: the player emits events far
// more often than these fields actually change.