Skip to content

Native Android client for Spotify, built with Jetpack Compose

Lock screen: play / pause in the middle, centred icon

kota-zod7655d464aac
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5edfa400..07cafc65 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -20,6 +20,7 @@ A new engine, written from scratch, and a cleaner app on top of it.
- **Hearts show at once** in playlists: the liked songs were only checked after a tap (a playlist in the check made Spotify refuse it). Lists at the top of the library and the home shortcuts load before you open them.
- **Setup screen** after signing in: notifications, local music, Bluetooth and unrestricted battery, each with its own button.
- **Folders in Local Files**: choose the folders shown; WhatsApp, Telegram, recordings and ringtones start hidden.
+- **Lock screen and Now Bar**: play / pause in the middle (like, previous, play, next, shuffle) and a centred app icon.
- **Spotify keeps working after its updates**: the app picks up the Web Player's new operations by itself when Spotify ships a new version.
- **No ads**: the ad audio is refused, so the player skips the ad within a second, and nothing false is reported to Spotify.
- **Podcasts and audiobooks are back**: shows, episodes, chapters, **Your Episodes** in Your Library, and **playback speed** (from the song menu) for episodes.
diff --git a/base/app/src/main/java/com/music/spotui/di/SongPlayer.kt b/base/app/src/main/java/com/music/spotui/di/SongPlayer.kt
index c5fa0efb..ffb24206 100644
--- a/base/app/src/main/java/com/music/spotui/di/SongPlayer.kt
+++ b/base/app/src/main/java/com/music/spotui/di/SongPlayer.kt
@@ -133,6 +133,7 @@ object SongPlayer {
override fun playFromMediaId(mediaId: String) = AutoBrowser.play(mediaId)
override fun playFromSearch(query: String) { scope.launch { AutoBrowser.playFromSearch(query) } }
override fun setRemoteVolume(volume: Int) = SongPlayer.setRemoteVolume(volume)
+ override fun setShuffle(on: Boolean) = SongPlayer.setShuffle(on)
}
// ── Last track: shown at launch (mini player) before the Web Player reports ──
@@ -242,6 +243,7 @@ object SongPlayer {
playing = isPlaying(),
buffering = isBuffering,
liked = liked,
+ shuffle = st?.shuffle?.value == true,
))
com.music.spotui.widget.NowPlayingWidget.show(Graph.app,
title = song?.title ?: st?.title?.value.orEmpty(),
diff --git a/base/host-android/src/main/kotlin/app/myspoti/host/android/PlaybackService.kt b/base/host-android/src/main/kotlin/app/myspoti/host/android/PlaybackService.kt
index 7bcbd28f..87e08080 100644
--- a/base/host-android/src/main/kotlin/app/myspoti/host/android/PlaybackService.kt
+++ b/base/host-android/src/main/kotlin/app/myspoti/host/android/PlaybackService.kt
@@ -43,6 +43,7 @@ data class NowPlayingInfo(
val playing: Boolean,
val buffering: Boolean = false,
val liked: Boolean = false,
+ val shuffle: Boolean = false,
)
/** Commands from the system (notification buttons, headset, car, lock screen). */
@@ -56,6 +57,7 @@ interface PlaybackControls {
fun playFromMediaId(mediaId: String)
fun playFromSearch(query: String)
fun setRemoteVolume(volume: Int)
+ fun setShuffle(on: Boolean) {}
}
/** Android Auto / media browser content. */
@@ -116,7 +118,10 @@ class PlaybackService : MediaBrowserServiceCompat() {
override fun onPlayFromMediaId(mediaId: String, extras: Bundle?) { controls?.playFromMediaId(mediaId) }
override fun onPlayFromSearch(query: String, extras: Bundle?) { controls?.playFromSearch(query) }
override fun onCustomAction(action: String, extras: Bundle?) {
- if (action == ACTION_LIKE) controls?.setLiked(!(current?.liked ?: false))
+ when (action) {
+ ACTION_LIKE -> controls?.setLiked(!(current?.liked ?: false))
+ ACTION_SHUFFLE -> controls?.setShuffle(!(current?.shuffle ?: false))
+ }
}
}
@@ -142,8 +147,12 @@ class PlaybackService : MediaBrowserServiceCompat() {
PlaybackStateCompat.ACTION_SEEK_TO or PlaybackStateCompat.ACTION_PLAY_FROM_MEDIA_ID or
PlaybackStateCompat.ACTION_PLAY_FROM_SEARCH
)
+ // Like on the left of previous / play / next, shuffle on the right: five buttons, so
+ // play / pause sits in the middle (lock screen, Samsung Now Bar, Android 13+ shade).
.addCustomAction(ACTION_LIKE, if (info.liked) "Unlike" else "Like",
if (info.liked) R.drawable.msp_ic_liked else R.drawable.msp_ic_like)
+ .addCustomAction(ACTION_SHUFFLE, if (info.shuffle) "Shuffle off" else "Shuffle on",
+ if (info.shuffle) R.drawable.msp_ic_shuffle_on else R.drawable.msp_ic_shuffle)
.setState(state, info.positionMs, if (info.playing && !info.buffering) 1f else 0f)
.build())
if (info.coverUrl != lastCoverUrl) loadCover(info.coverUrl)
@@ -278,6 +287,7 @@ class PlaybackService : MediaBrowserServiceCompat() {
private const val CHANNEL_ID = "playback"
private const val NOTIFICATION_ID = 1
private const val ACTION_LIKE = "like"
+ private const val ACTION_SHUFFLE = "shuffle"
private val http = OkHttpClient()
@Volatile private var instance: PlaybackService? = null
diff --git a/base/host-android/src/main/res/drawable/msp_ic_notification.xml b/base/host-android/src/main/res/drawable/msp_ic_notification.xml
index 057d8738..aae9e16b 100644
--- a/base/host-android/src/main/res/drawable/msp_ic_notification.xml
+++ b/base/host-android/src/main/res/drawable/msp_ic_notification.xml
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
+<!-- Two beamed notes, balanced around the centre (the status bar and Now Bar centre the icon). -->
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24" android:viewportHeight="24">
- <path android:fillColor="#FFFFFFFF" android:pathData="M12,3v10.55c-0.59,-0.34 -1.27,-0.55 -2,-0.55 -2.21,0 -4,1.79 -4,4s1.79,4 4,4 4,-1.79 4,-4V7h4V3h-6z" />
+ <path android:fillColor="#FFFFFFFF" android:pathData="M8.6,6.6L18.6,4.2L18.6,15.2A2.7,2.7 0,1 1,16.8 12.7L16.8,8.3L10.4,9.8L10.4,17.4A2.7,2.7 0,1 1,8.6 14.9Z" />
</vector>
diff --git a/base/host-android/src/main/res/drawable/msp_ic_shuffle.xml b/base/host-android/src/main/res/drawable/msp_ic_shuffle.xml
new file mode 100644
index 00000000..e3c8c9e9
--- /dev/null
+++ b/base/host-android/src/main/res/drawable/msp_ic_shuffle.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24" android:viewportHeight="24">
+ <path android:fillColor="#FFFFFFFF" android:pathData="M10.59,9.17L5.41,4 4,5.41l5.17,5.17 1.42,-1.41zM14.5,4l2.04,2.04L4,18.59 5.41,20 17.96,7.46 20,9.5L20,4h-5.5zM14.83,13.41l-1.41,1.41 3.13,3.13L14.5,20L20,20v-5.5l-2.04,2.04 -3.13,-3.13z" />
+</vector>
diff --git a/base/host-android/src/main/res/drawable/msp_ic_shuffle_on.xml b/base/host-android/src/main/res/drawable/msp_ic_shuffle_on.xml
new file mode 100644
index 00000000..97c94c16
--- /dev/null
+++ b/base/host-android/src/main/res/drawable/msp_ic_shuffle_on.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24" android:viewportHeight="24">
+ <path android:fillColor="#FF1DB954" android:pathData="M10.59,9.17L5.41,4 4,5.41l5.17,5.17 1.42,-1.41zM14.5,4l2.04,2.04L4,18.59 5.41,20 17.96,7.46 20,9.5L20,4h-5.5zM14.83,13.41l-1.41,1.41 3.13,3.13L14.5,20L20,20v-5.5l-2.04,2.04 -3.13,-3.13z" />
+</vector>