Skip to content

Native Android client for Spotify, built with Jetpack Compose

Jam controls the host as Spotify lets it, Liquid Glass pill no longer see-through, Settings regrouped, crossfade on a slider, Home's Following chip, friend activity out of the tab bar

kota-zo488c273e4c2e
diff --git a/base/api-spotify/src/main/kotlin/app/myspoti/spotify/SpotifyMore.kt b/base/api-spotify/src/main/kotlin/app/myspoti/spotify/SpotifyMore.kt
index 027df78a..b3ba6fa0 100644
--- a/base/api-spotify/src/main/kotlin/app/myspoti/spotify/SpotifyMore.kt
+++ b/base/api-spotify/src/main/kotlin/app/myspoti/spotify/SpotifyMore.kt
@@ -91,9 +91,11 @@ private fun shelf(section: JsonElement): Shelf? {
}
class SpotifyHome(private val gql: Gql) : Home {
- override suspend fun feed(filter: HomeFilter, itemsPerShelf: Int): HomeFeed {
+ override suspend fun feed(filter: HomeFilter, itemsPerShelf: Int): HomeFeed = feed(filter.facet, itemsPerShelf)
+
+ override suspend fun feed(facet: String, itemsPerShelf: Int): HomeFeed {
val home = gql.query("home", vars(
- "timeZone" to TimeZone.getDefault().id, "sp_t" to "", "facet" to filter.facet,
+ "timeZone" to TimeZone.getDefault().id, "sp_t" to "", "facet" to facet,
"sectionItemsLimit" to itemsPerShelf, "homeEndUserIntegration" to "INTEGRATION_WEB_PLAYER",
"includeEpisodeContentRatingsV2" to true, "includeHomeChapterVideoCards" to false,
)).entity("data.home", "home")
@@ -102,9 +104,17 @@ class SpotifyHome(private val gql: Gql) : Home {
greeting = home.str("greeting.transformedLabel") ?: "",
filters = listOf(HomeFilter.ALL) + filters,
shelves = home.list("sectionContainer.sections.items").mapNotNull(::shelf),
+ chips = home.list("homeChips").mapNotNull(::homeChip),
)
}
+ /** {id, label.transformedLabel, subChips[]}, as the Web Player reads it (a chip with no label is not shown there). */
+ private fun homeChip(c: JsonElement): app.myspoti.api.HomeChip? {
+ val id = c.str("id")?.takeIf { it.isNotBlank() } ?: return null
+ val label = c.str("label.transformedLabel")?.takeIf { it.isNotBlank() } ?: return null
+ return app.myspoti.api.HomeChip(id, label, c.list("subChips").mapNotNull(::homeChip))
+ }
+
override suspend fun categories(): List<Category> =
gql.query("browseAll", vars(
"pagePagination" to mapOf("offset" to 0, "limit" to 10),
@@ -521,10 +531,15 @@ class SpotifyJam(private val bridge: Bridge, private val http: SpotifyHttp) : Ja
/** The session this account is in, read from Spotify (404: none): also a Jam joined in the room, which the page does not know. */
override suspend fun refresh() {
val (code, body) = http.send("GET", "$SOCIAL/v2/sessions/current")
- _session.value = if (code in 200..299) parse(runCatching { Json.parseToJsonElement(body) }.getOrNull()) else if (code == 404) null
+ val read = if (code in 200..299) parse(runCatching { Json.parseToJsonElement(body) }.getOrNull()) else if (code == 404) null
else parse(bridge.service("SocialConnectAPI", "fetchCurrentSession"))
+ // How this phone joined is not in the session read again: kept from the join.
+ _session.value = read?.copy(listensHere = read.id == listeningIn)
}
+ /** The session this phone joined as a listener (REMOTE), null when it joined to control the host. */
+ @Volatile private var listeningIn: String? = null
+
override suspend fun start(): JamSession {
if (availability() == JamAvailability.RESTRICTED) throw UnsupportedOperationException("Jam is restricted on this account")
// GET social-connect/v2/sessions/current_or_new?activate=true, as the official apps. Its answer is
@@ -537,8 +552,11 @@ class SpotifyJam(private val bridge: Bridge, private val http: SpotifyHttp) : Ja
override suspend fun join(joinToken: String): JamSession {
// Sent to Spotify directly, as the page's own join dialog sends it (docs/api/JAM.md): the page's
// service gives up at once on an account it marks RESTRICTED, while Spotify lets a free account
- // join as in the room. Listening here first (LISTEN_AND_CONTROL, Premium), else in the room
- // (CONTROL: this phone controls the host's playback), each try with its own attempt id.
+ // join as in the room. As the official apps offer it: "Continue on this device" first
+ // (LISTEN_AND_CONTROL: this phone streams the Jam itself, Spotify's own playback), else "Play
+ // from the host's speaker" (CONTROL: this phone controls the host's playback). Measured on a
+ // free account (3 Nov 2026): the first is answered 403 "User not allowed to join session",
+ // the second 200. Each try has its own attempt id.
// The page's own Connect device joins (local_device_id): without it the session took this
// account but not always the page's device, which then knew of no Jam, made itself the
// active device at the first command (a transfer to itself) and so left the Jam.
@@ -551,10 +569,17 @@ class SpotifyJam(private val bridge: Bridge, private val http: SpotifyHttp) : Ja
put("join_attempt_id", java.util.UUID.randomUUID().toString()); put("permission_mode", "FULL")
}
last = http.send("POST", "$SOCIAL/v3/sessions/join", body.toString())
- if (last.first in 200..299) parse(runCatching { Json.parseToJsonElement(last.second) }.getOrNull())?.let {
- _session.value = it
- awaitJamDevice()
- return it
+ // What Spotify answered each way of joining: the diagnostic says how this phone is in the Jam.
+ bridge.logger?.invoke("jam: join as $control (device ${device?.take(6) ?: "none"}) -> HTTP ${last.first} ${last.second.take(300)}")
+ if (last.first in 200..299) parse(runCatching { Json.parseToJsonElement(last.second) }.getOrNull())?.let { joined ->
+ val listening = control == "LISTEN_AND_CONTROL"
+ listeningIn = joined.id.takeIf { listening }
+ val s = joined.copy(listensHere = listening)
+ _session.value = s
+ // Listening, the page is the Jam's player itself: nothing to wait for. Controlling, the
+ // first command waits for the page to see the host's device (else it went to itself).
+ if (!listening) awaitJamDevice()
+ return s
}
}
throw GqlException("jam", "join failed: HTTP ${last.first} ${last.second.take(200)}")
@@ -580,14 +605,15 @@ class SpotifyJam(private val bridge: Bridge, private val http: SpotifyHttp) : Ja
}
/** Another account takes the page: the Jam known is that of the account that left. */
- internal fun forgetSession() { _session.value = null }
+ internal fun forgetSession() { _session.value = null; listeningIn = null }
- /** In a Jam this account joined: the music plays on the host's device, never to be pulled here. */
+ /** In a Jam this account joined: its songs are Spotify's (the Jam's), never an extension's. */
val member: Boolean get() = _session.value?.isHost == false
override suspend fun leave() {
_session.value?.let { http.send("POST", "$SOCIAL/v3/sessions/${it.id}/leave") }
_session.value = null
+ listeningIn = null
}
override suspend fun end() {
diff --git a/base/api/src/main/kotlin/app/myspoti/api/Api.kt b/base/api/src/main/kotlin/app/myspoti/api/Api.kt
index 9c4f2f4d..c272aaa7 100644
--- a/base/api/src/main/kotlin/app/myspoti/api/Api.kt
+++ b/base/api/src/main/kotlin/app/myspoti/api/Api.kt
@@ -218,6 +218,9 @@ interface Playlists {
interface Home {
suspend fun feed(filter: HomeFilter = HomeFilter.ALL, itemsPerShelf: Int = 10): HomeFeed
+ /** The feed of any facet Spotify offers, a sub-chip's too ([HomeChip.id], e.g. Music > Following). */
+ suspend fun feed(facet: String, itemsPerShelf: Int = 10): HomeFeed =
+ feed(HomeFilter.entries.firstOrNull { it.facet == facet } ?: HomeFilter.ALL, itemsPerShelf)
suspend fun categories(): List<Category>
suspend fun category(uri: Uri): BrowsePage
/** New releases from the artists the user follows, newest first ("What's new"). */
diff --git a/base/api/src/main/kotlin/app/myspoti/api/Media.kt b/base/api/src/main/kotlin/app/myspoti/api/Media.kt
index 52ee47cd..259dcc05 100644
--- a/base/api/src/main/kotlin/app/myspoti/api/Media.kt
+++ b/base/api/src/main/kotlin/app/myspoti/api/Media.kt
@@ -66,7 +66,13 @@ data class Shelf(val uri: Uri?, val title: String?, val items: List<MediaCard>,
enum class HomeFilter(val facet: String) { ALL(""), MUSIC("music-chip"), PODCASTS("podcasts-chip"), AUDIOBOOKS("audiobooks-chip") }
-data class HomeFeed(val greeting: String, val filters: List<HomeFilter>, val shelves: List<Shelf>)
+/**
+ * A chip of the home's filter row as Spotify sends it ([id] is the facet to load). [subChips]: the
+ * ones that open beside it once it is picked (Music > Following), each a facet of its own.
+ */
+data class HomeChip(val id: String, val label: String, val subChips: List<HomeChip> = emptyList())
+
+data class HomeFeed(val greeting: String, val filters: List<HomeFilter>, val shelves: List<Shelf>, val chips: List<HomeChip> = emptyList())
data class Category(val uri: Uri, val title: String, val images: List<Image>, val color: String?)
@@ -257,6 +263,13 @@ data class JamSession(
val members: List<JamMember>,
val isHost: Boolean,
val queueOnly: Boolean,
+ /**
+ * A member whose own device plays the Jam (joined as REMOTE, "Continue on this device"), as the
+ * official apps do for Premium. False: joined IN_PERSON (Spotify refuses the other way to a free
+ * account: 403 "User not allowed to join session"), the music plays on the host's device and this
+ * one controls it. Known from the join; false for a host and after a restart.
+ */
+ val listensHere: Boolean = false,
)
data class HistoryEntry(val uri: Uri, val kind: MediaKind, val name: String, val images: List<Image>, val playedAtMs: Long?)
diff --git a/base/app/src/main/java/com/music/spotui/cli/CliReceiver.kt b/base/app/src/main/java/com/music/spotui/cli/CliReceiver.kt
index 6db789d6..6a9009e7 100644
--- a/base/app/src/main/java/com/music/spotui/cli/CliReceiver.kt
+++ b/base/app/src/main/java/com/music/spotui/cli/CliReceiver.kt
@@ -277,7 +277,7 @@ class CliReceiver : BroadcastReceiver() {
}
private fun jamJson(s: app.myspoti.api.JamSession?): JsonElement = if (s == null) JsonNull else buildJsonObject {
- put("id", s.id); put("token", s.joinToken ?: ""); put("host", s.isHost); put("queueOnly", s.queueOnly)
+ put("id", s.id); put("token", s.joinToken ?: ""); put("host", s.isHost); put("queueOnly", s.queueOnly); put("listensHere", s.listensHere)
put("members", JsonArray(s.members.map { m -> JsonPrimitive(m.name + if (m.host) " (host)" else "") }))
}
diff --git a/base/app/src/main/java/com/music/spotui/data/api/Api.kt b/base/app/src/main/java/com/music/spotui/data/api/Api.kt
index ef43a9ae..2d1e3e6f 100644
--- a/base/app/src/main/java/com/music/spotui/data/api/Api.kt
+++ b/base/app/src/main/java/com/music/spotui/data/api/Api.kt
@@ -415,14 +415,15 @@ class Api constructor(
)
}
- /** [facet]: "" (all), "music-chip", "podcasts-chip", "audiobooks-chip". */
+ /** [facet]: "" (all), "music-chip", "podcasts-chip", "audiobooks-chip", or a sub-chip Spotify sent (HomeSubChips). */
suspend fun getHomeFeed(facet: String = ""): Flow<Response<HomeFeedModel>> = flow {
val cached = if (facet.isEmpty()) HomeCache.home ?: diskHome() else HomeCache.facets[facet]
cached?.let { emit(Response.Success(it)) } ?: emit(Response.Loading())
if (!ready()) { if (cached == null) emit(Response.Error(notSignedIn())); return@flow }
- val filter = app.myspoti.api.HomeFilter.entries.firstOrNull { it.facet == facet } ?: app.myspoti.api.HomeFilter.ALL
- runCatching { api.home.feed(filter, itemsPerShelf = 20) }.fold(
+ // Any facet Spotify offers: a top chip, or one opened beside it (Music > Following).
+ runCatching { api.home.feed(facet, itemsPerShelf = 20) }.fold(
onSuccess = { feed ->
+ com.music.spotui.data.entity.HomeSubChips.learn(feed.chips)
val sections = feed.shelves.mapNotNull { shelf ->
val items = shelf.items.distinctBy { it.uri }.mapNotNull(::homeItem)
.distinctBy { it::class.simpleName + "|" + it.name.lowercase() }
diff --git a/base/app/src/main/java/com/music/spotui/data/entity/HomeFeedModel.kt b/base/app/src/main/java/com/music/spotui/data/entity/HomeFeedModel.kt
index f8280d53..53538f9d 100644
--- a/base/app/src/main/java/com/music/spotui/data/entity/HomeFeedModel.kt
+++ b/base/app/src/main/java/com/music/spotui/data/entity/HomeFeedModel.kt
@@ -11,6 +11,24 @@ data class HomeFeedModel(
val sections: List<HomeSection> = emptyList(),
)
+/**
+ * The chips Spotify opens beside a home chip once it is picked (Music > Following, Podcasts >
+ * Following), by the parent's facet, as the last feeds told: (facet, label). Compose state.
+ */
+object HomeSubChips {
+ val byParent = androidx.compose.runtime.mutableStateMapOf<String, List<Pair<String, String>>>()
+
+ /** The chip [facet] opens under, itself when it has sub-chips; null for "All" and a chip with none. */
+ fun parentOf(facet: String): String? =
+ if (facet in byParent) facet else byParent.entries.firstOrNull { e -> e.value.any { it.first == facet } }?.key
+
+ fun learn(chips: List<app.myspoti.api.HomeChip>) {
+ val found = chips.filter { it.subChips.isNotEmpty() }.associate { c -> c.id to c.subChips.map { it.id to it.label } }
+ if (found.isEmpty()) return
+ android.os.Handler(android.os.Looper.getMainLooper()).post { found.forEach { (k, v) -> if (byParent[k] != v) byParent[k] = v } }
+ }
+}
+
@kotlinx.serialization.Serializable
data class HomeSection(
val title: String,
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 1d95d031..c44339ef 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
@@ -1569,6 +1569,7 @@ object SongPlayer {
if (!stateSeen) resumeWhenReady = true
val uri = _nowPlaying.value.uri
transport(checkAfter = true) { api.player.resume() }
+ jamFollowUp(wantPaused = false)
// An episode ignored by a plain resume (the page's element stays paused, which is what
// "the podcast stopped and the play button does nothing" was — B11) is asked for again
// by its uri, where it was. Music keeps the plain resume: it never showed that.
@@ -1596,9 +1597,30 @@ object SongPlayer {
if (LocalPlayer.active.value) { LocalPlayer.pause(); return }
intendPaused()
positionMs = getCurrentPosition(); positionAt = SystemClock.elapsedRealtime(); playing = false
- if (send) transport(pullBack = false) { api.player.pause() }
+ if (send) { transport(pullBack = false) { api.player.pause() }; jamFollowUp(wantPaused = true) }
}
+ /**
+ * In a Jam this phone controls (the music on the host's device): a play or pause the host has
+ * not followed [JAM_FOLLOW_MS] later is sent once more. Reported: "starting the sound from the
+ * phone does not work": the first play after joining was answered 202 by Spotify and never
+ * reached the host; the next one did.
+ */
+ private fun jamFollowUp(wantPaused: Boolean) {
+ val jam = api.jam.session.value ?: return
+ if (jam.isHost || jam.listensHere) return
+ scope.launch {
+ kotlinx.coroutines.delay(JAM_FOLLOW_MS)
+ if (playing == wantPaused) return@launch // asked otherwise since
+ kotlinx.coroutines.withTimeoutOrNull(RECONCILE_READ_MS) { runCatching { MyspotiRuntime.spotify.player.refresh() } }
+ val s = api.player.state.value ?: return@launch
+ if (s.isPaused == wantPaused || playing == wantPaused) return@launch
+ app.myspoti.host.android.Logbook.log("jam: the host did not ${if (wantPaused) "pause" else "play"} in ${JAM_FOLLOW_MS / 1000} s, sent again")
+ transport(pullBack = false) { if (wantPaused) api.player.pause() else api.player.resume() }
+ }
+ }
+ private val JAM_FOLLOW_MS = 3_000L
+
fun stop() = pause()
/**
diff --git a/base/app/src/main/java/com/music/spotui/ui/components/CrossfadeSlider.kt b/base/app/src/main/java/com/music/spotui/ui/components/CrossfadeSlider.kt
new file mode 100644
index 00000000..9ccb4096
--- /dev/null
+++ b/base/app/src/main/java/com/music/spotui/ui/components/CrossfadeSlider.kt
@@ -0,0 +1,56 @@
+package com.music.spotui.ui.components
+
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.padding
+import androidx.compose.material3.Slider
+import androidx.compose.material3.SliderDefaults
+import androidx.compose.material3.Text
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableFloatStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.setValue
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.platform.LocalContext
+import androidx.compose.ui.res.stringResource
+import androidx.compose.ui.text.font.FontWeight
+import androidx.compose.ui.unit.dp
+import androidx.compose.ui.unit.sp
+import app.myspoti.engine.R
+import com.music.spotui.data.preferences.CrossfadePref
+import kotlin.math.roundToInt
+
+/**
+ * The crossfade's length on a slider, 1 to [CrossfadePref.MAX] seconds a second at a time (it was
+ * four fixed choices: 3, 6, 9, 12 s). The value shows while it moves and is saved when it is let go,
+ * so the player is not handed every step of a drag. Shared by both looks: [accent] fills the track,
+ * [text] and [muted] colour the label and the bounds.
+ */
+@Composable
+fun CrossfadeSlider(accent: Color, text: Color, muted: Color, modifier: Modifier = Modifier) {
+ val ctx = LocalContext.current
+ var value by remember(CrossfadePref.seconds) { mutableFloatStateOf(CrossfadePref.seconds.coerceIn(1, CrossfadePref.MAX).toFloat()) }
+ Column(modifier.fillMaxWidth()) {
+ Row(Modifier.fillMaxWidth()) {
+ Text(stringResource(R.string.settings_crossfade_length), color = text, fontSize = 16.sp, modifier = Modifier.weight(1f))
+ Text(stringResource(R.string.settings_crossfade_seconds, value.roundToInt()), color = accent, fontSize = 16.sp, fontWeight = FontWeight.Bold)
+ }
+ Slider(
+ value = value,
+ onValueChange = { value = it },
+ onValueChangeFinished = { CrossfadePref.set(ctx, value.roundToInt()) },
+ valueRange = 1f..CrossfadePref.MAX.toFloat(),
+ steps = CrossfadePref.MAX - 2,
+ colors = SliderDefaults.colors(thumbColor = accent, activeTrackColor = accent, inactiveTrackColor = muted.copy(alpha = 0.3f),
+ activeTickColor = Color.Transparent, inactiveTickColor = Color.Transparent),
+ modifier = Modifier.padding(top = 2.dp),
+ )
+ Row(Modifier.fillMaxWidth()) {
+ Text(stringResource(R.string.settings_crossfade_seconds, 1), color = muted, fontSize = 12.sp, modifier = Modifier.weight(1f))
+ Text(stringResource(R.string.settings_crossfade_seconds, CrossfadePref.MAX), color = muted, fontSize = 12.sp)
+ }
+ }
+}
diff --git a/base/app/src/main/java/com/music/spotui/ui/components/PlayerSheets.kt b/base/app/src/main/java/com/music/spotui/ui/components/PlayerSheets.kt
index 6d72397b..5f0f7a16 100644
--- a/base/app/src/main/java/com/music/spotui/ui/components/PlayerSheets.kt
+++ b/base/app/src/main/java/com/music/spotui/ui/components/PlayerSheets.kt
@@ -394,6 +394,9 @@ private fun JamSection(onDismiss: () -> Unit) {
val s = session
if (s != null) {
Text(stringResource(R.string.jam_members, s.members.size), color = Green, fontSize = 13.sp, modifier = Modifier.padding(top = 4.dp))
+ // A member: where the music plays, as Spotify let this phone in (see JamSession.listensHere).
+ if (!s.isHost) Text(stringResource(if (s.listensHere) R.string.jam_plays_here else R.string.jam_plays_on_host),
+ color = AppMuted, fontSize = 13.sp, modifier = Modifier.padding(top = 4.dp, bottom = 4.dp))
Text(stringResource(R.string.jam_invite), color = AppText, fontSize = 15.sp,
modifier = Modifier.fillMaxWidth().clickable {
scope.launch {
@@ -421,10 +424,7 @@ private fun JamSection(onDismiss: () -> Unit) {
com.google.mlkit.vision.codescanner.GmsBarcodeScanning.getClient(context).startScan()
.addOnSuccessListener { code ->
val raw = code.rawValue.orEmpty()
- scope.launch {
- val token = JamLinks.token(raw)
- if (token == null || runCatching { jam.join(token) }.isFailure) failed() else onDismiss()
- }
+ joinJam(context, raw, onDismiss)
}
// No scanner on this phone (Play services missing or too old): say so.
.addOnFailureListener { failed() }
@@ -434,14 +434,32 @@ private fun JamSection(onDismiss: () -> Unit) {
modifier = Modifier.fillMaxWidth().clickable {
val clip = context.getSystemService(android.content.ClipboardManager::class.java)?.primaryClip
val raw = clip?.takeIf { it.itemCount > 0 }?.getItemAt(0)?.coerceToText(context)?.toString().orEmpty()
- scope.launch {
- val token = JamLinks.token(raw)
- if (token == null || runCatching { jam.join(token) }.isFailure) failed() else onDismiss()
- }
+ joinJam(context, raw, onDismiss)
}.padding(vertical = 10.dp))
}
}
+/**
+ * Joins the Jam of the invite [raw] (a link, a QR code's text) on the app's scope, not the sheet's.
+ * Reported: "Spotify refused the Jam" while the phone was in it: the sheet closes as soon as the
+ * Jam's device shows up, which cancelled the join still waiting on the page, and that cancellation
+ * was shown as a failure. Only an answer Spotify refused (or a link that is not one) says so now.
+ */
+private fun joinJam(context: android.content.Context, raw: String, onDismiss: () -> Unit) {
+ fun failed() = android.widget.Toast.makeText(context.applicationContext, context.getString(R.string.jam_failed), android.widget.Toast.LENGTH_SHORT).show()
+ onDismiss()
+ app.myspoti.host.android.MyspotiRuntime.scope.launch {
+ // A short link (spotify.link) is followed to its token first.
+ val token = JamLinks.token(raw)
+ ?: return@launch kotlinx.coroutines.withContext(kotlinx.coroutines.Dispatchers.Main) { failed() }
+ val error = runCatching { app.myspoti.host.android.MyspotiRuntime.api.jam.join(token) }.exceptionOrNull()
+ if (error != null && error !is kotlinx.coroutines.CancellationException) {
+ app.myspoti.host.android.Logbook.log("jam: join failed: ${error.message}")
+ kotlinx.coroutines.withContext(kotlinx.coroutines.Dispatchers.Main) { failed() }
+ }
+ }
+}
+
/** Jam invite codes: `open.spotify.com/socialsession/<token>`, or a spotify.link short link to it. */
private object JamLinks {
private val http = okhttp3.OkHttpClient.Builder().followRedirects(true).build()
diff --git a/base/app/src/main/java/com/music/spotui/ui/immersive/motion/ImmersiveMotion.kt b/base/app/src/main/java/com/music/spotui/ui/immersive/motion/ImmersiveMotion.kt
index 2704985a..f1661e57 100644
--- a/base/app/src/main/java/com/music/spotui/ui/immersive/motion/ImmersiveMotion.kt
+++ b/base/app/src/main/java/com/music/spotui/ui/immersive/motion/ImmersiveMotion.kt
@@ -85,7 +85,7 @@ object ImmersiveMotion {
* instead of jumping once the transition is over.
*/
object Pages {
- private val tabRoutes = setOf(Routes.Home.route, Routes.Search.route, Routes.Library.route, Routes.Friends.route)
+ private val tabRoutes = setOf(Routes.Home.route, Routes.Search.route, Routes.Library.route)
private fun AnimatedContentTransitionScope<NavBackStackEntry>.isTabSwitch() =
initialState.destination.route in tabRoutes && targetState.destination.route in tabRoutes
diff --git a/base/app/src/main/java/com/music/spotui/ui/immersive/pages/ImmersiveActivityScreens.kt b/base/app/src/main/java/com/music/spotui/ui/immersive/pages/ImmersiveActivityScreens.kt
index 46db9827..db8b2bb3 100644
--- a/base/app/src/main/java/com/music/spotui/ui/immersive/pages/ImmersiveActivityScreens.kt
+++ b/base/app/src/main/java/com/music/spotui/ui/immersive/pages/ImmersiveActivityScreens.kt
@@ -105,8 +105,8 @@ fun ImmersiveFriendsScreen(navController: NavController) {
val now = remember(state) { System.currentTimeMillis() }
ImmersivePage(
title = stringResource(R.string.friends_title),
- // A tab of its own: no back arrow.
- onBack = null,
+ // Opened from Home's header (no longer a tab): back to it.
+ onBack = { navController.popBackStack() },
actions = {
ImmersiveBarAction(Icons.Rounded.Refresh, stringResource(R.string.friends_refresh), onClick = { state = null; attempt++ })
},
diff --git a/base/app/src/main/java/com/music/spotui/ui/immersive/pages/ImmersiveSettingsScreen.kt b/base/app/src/main/java/com/music/spotui/ui/immersive/pages/ImmersiveSettingsScreen.kt
index 4eeabaf9..4cdc85af 100644
--- a/base/app/src/main/java/com/music/spotui/ui/immersive/pages/ImmersiveSettingsScreen.kt
+++ b/base/app/src/main/java/com/music/spotui/ui/immersive/pages/ImmersiveSettingsScreen.kt
@@ -31,6 +31,7 @@ import androidx.compose.material.icons.rounded.SignalCellularAlt
import androidx.compose.material.icons.rounded.Info
import androidx.compose.material.icons.rounded.Refresh
import androidx.compose.material.icons.rounded.Storage
+import androidx.compose.material.icons.rounded.Lyrics
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
@@ -71,7 +72,7 @@ import com.music.spotui.ui.screens.shareDiagnosticReport
import kotlinx.coroutines.launch
/** Where the Immersive Settings are: the list of categories, one category, or a choice inside it. */
-private enum class SettingsPage { Root, Playback, StreamingWifi, StreamingCell, Crossfade, Downloads, DownloadQuality, Storage, Data, Display, Look, Rotation, Language, LyricsLanguage, App, Accounts }
+private enum class SettingsPage { Root, Playback, Lyrics, StreamingWifi, StreamingCell, Crossfade, Downloads, DownloadQuality, Storage, Data, Display, Look, Rotation, Language, LyricsLanguage, App, Accounts }
private val StreamingChoices = listOf(
Triple(StreamingQuality.AUTO, R.string.quality_streaming_auto, R.string.quality_streaming_auto_detail),
@@ -129,6 +130,7 @@ fun ImmersiveSettingsScreen(navController: NavController) {
when (p) {
SettingsPage.Root -> SettingsRoot(navController, open, back)
SettingsPage.Playback -> PlaybackPage(navController, open, back)
+ SettingsPage.Lyrics -> LyricsPage(open, back)
SettingsPage.StreamingWifi -> StreamingPage(cellular = false, back)
SettingsPage.StreamingCell -> StreamingPage(cellular = true, back)
SettingsPage.Crossfade -> CrossfadePage(back)
@@ -156,6 +158,7 @@ private fun SettingsRoot(navController: NavController, open: (SettingsPage) -> U
ImmersivePage(title = stringResource(R.string.settings_title), onBack = back) {
immersiveGroup("root") {
row { ImmersiveGroupRow(stringResource(R.string.settings_section_playback), icon = Icons.Rounded.PlayArrow, chevron = true, onClick = { open(SettingsPage.Playback) }) }
+ row { ImmersiveGroupRow(stringResource(R.string.settings_section_lyrics), icon = Icons.Rounded.Lyrics, chevron = true, onClick = { open(SettingsPage.Lyrics) }) }
row { ImmersiveGroupRow(stringResource(R.string.settings_section_downloads), icon = Icons.Rounded.Download, chevron = true, onClick = { open(SettingsPage.Downloads) }) }
row { ImmersiveGroupRow(stringResource(R.string.settings_section_storage), icon = Icons.Rounded.Storage, chevron = true, onClick = { open(SettingsPage.Storage) }) }
row { ImmersiveGroupRow(stringResource(R.string.settings_section_data), icon = Icons.Rounded.SignalCellularAlt, chevron = true, onClick = { open(SettingsPage.Data) }) }
@@ -221,8 +224,6 @@ private fun PlaybackPage(navController: NavController, open: (SettingsPage) -> U
val label = { q: StreamingQuality -> StreamingChoices.first { it.first == q }.second }
var headsetSkip by remember { mutableStateOf(app.myspoti.host.android.PlaybackService.skipsOnEpisodes(ctx)) }
var keepPlaying by remember { mutableStateOf(app.myspoti.host.android.PlaybackService.keepsPlayingOnClose(ctx)) }
- var wordSync by remember { mutableStateOf(com.music.spotui.data.preferences.isLyricsWordSync(ctx)) }
- var lyricsExtra by remember { mutableStateOf(com.music.spotui.data.preferences.isLyricsExtraSources(ctx)) }
val crossfade = com.music.spotui.data.preferences.CrossfadePref.seconds
// The first source of the audio order, when it is an extension announcing settings here:
// they show, and Spotify's quality (kept, still used for what Spotify plays) leaves the screen.
@@ -273,6 +274,9 @@ private fun PlaybackPage(navController: NavController, open: (SettingsPage) -> U
chevron = true, onClick = { navController.navigate(Routes.Equalizer.route) },
)
}
+ }
+ // What keeps the music going and what the headset buttons do.
+ immersiveGroup("controls", headerRes = R.string.settings_section_controls) {
row {
ImmersiveSwitchRow(
stringResource(R.string.settings_keep_playing_title), checked = keepPlaying,
@@ -287,6 +291,9 @@ private fun PlaybackPage(navController: NavController, open: (SettingsPage) -> U
detail = stringResource(R.string.settings_headset_skip_detail),
)
}
+ }
+ // What other devices see of this phone, and a Jam joined here.
+ immersiveGroup("connect", headerRes = R.string.settings_section_connect) {
// Songs an extension streams, played by Spotify too (unheard): counted there, seen by Connect.
if (com.music.spotui.extensions.Extensions.sources(app.myspoti.extensions.Action.AUDIO_SOURCE).isNotEmpty()) row {
ImmersiveSwitchRow(
@@ -296,15 +303,6 @@ private fun PlaybackPage(navController: NavController, open: (SettingsPage) -> U
detail = stringResource(R.string.settings_connect_mirror_detail),
)
}
- // Live Radio: adds the pinned Library row under Local Files (see com.music.spotui.radio).
- row {
- ImmersiveSwitchRow(
- stringResource(R.string.live_radio_settings_title),
- checked = com.music.spotui.radio.RadioFeaturePref.on,
- onChecked = { com.music.spotui.radio.RadioFeaturePref.set(ctx, it) },
- detail = stringResource(R.string.live_radio_settings_detail),
- )
- }
// Downloaded songs, played from their files online, played by Spotify too (unheard), as an extension's.
row {
ImmersiveSwitchRow(
@@ -314,6 +312,17 @@ private fun PlaybackPage(navController: NavController, open: (SettingsPage) -> U
detail = stringResource(R.string.settings_download_sync_detail),
)
}
+ }
+ immersiveGroup("library", headerRes = R.string.settings_section_library) {
+ // Live Radio: adds the pinned Library row under Local Files (see com.music.spotui.radio).
+ row {
+ ImmersiveSwitchRow(
+ stringResource(R.string.live_radio_settings_title),
+ checked = com.music.spotui.radio.RadioFeaturePref.on,
+ onChecked = { com.music.spotui.radio.RadioFeaturePref.set(ctx, it) },
+ detail = stringResource(R.string.live_radio_settings_detail),
+ )
+ }
// Songs marked "Not interested": skipped by lists, listed here to be shown again.
row {
ImmersiveGroupRow(
@@ -323,7 +332,19 @@ private fun PlaybackPage(navController: NavController, open: (SettingsPage) -> U
}
}
sourcesGroup(app.myspoti.extensions.Action.AUDIO_SOURCE, navController)
- immersiveGroup("lyrics", headerRes = R.string.settings_section_lyrics) {
+ // Podcasts: SponsorBlock (SponsorBlockGroup.kt).
+ sponsorBlockGroup()
+ }
+}
+
+/** Lyrics: their sources, word by word or by line, the screen kept on, romanization and translation. */
+@Composable
+private fun LyricsPage(open: (SettingsPage) -> Unit, back: () -> Unit) {
+ val ctx = LocalContext.current
+ var wordSync by remember { mutableStateOf(com.music.spotui.data.preferences.isLyricsWordSync(ctx)) }
+ var lyricsExtra by remember { mutableStateOf(com.music.spotui.data.preferences.isLyricsExtraSources(ctx)) }
+ ImmersivePage(title = stringResource(R.string.settings_section_lyrics), onBack = back) {
+ immersiveGroup("lyrics") {
// Lyrics: word by word (karaoke) first, or line by line with Spotify's first.
row {
ImmersiveSwitchRow(
@@ -378,8 +399,6 @@ private fun PlaybackPage(navController: NavController, open: (SettingsPage) -> U
)
}
}
- // Podcasts: SponsorBlock (SponsorBlockGroup.kt).
- sponsorBlockGroup()
}
}
@@ -406,7 +425,6 @@ private fun StreamingPage(cellular: Boolean, back: () -> Unit) {
@Composable
private fun CrossfadePage(back: () -> Unit) {
val ctx = LocalContext.current
- val pref = com.music.spotui.data.preferences.CrossfadePref
val transition = com.music.spotui.data.preferences.TransitionPref
val automix = com.music.spotui.automix.AutoMix
val mode = transition.mode
@@ -438,10 +456,10 @@ private fun CrossfadePage(back: () -> Unit) {
row { ImmersiveGroupRow(stringResource(reason)) }
}
if (mode == TransitionMode.CROSSFADE) immersiveGroup("length", headerRes = R.string.settings_crossfade_length, footerRes = R.string.settings_crossfade_detail) {
- for (v in listOf(3, 6, 9, 12)) {
- row {
- ImmersiveChoiceRow(stringResource(R.string.settings_crossfade_seconds, v), selected = pref.seconds == v, onClick = { pref.set(ctx, v) })
- }
+ // Any length from 1 to 12 s on a slider (it was four fixed choices).
+ row {
+ com.music.spotui.ui.components.CrossfadeSlider(Immersive.Accent, Immersive.Text, Immersive.TextSecondary,
+ Modifier.padding(horizontal = 16.dp, vertical = 12.dp))
}
}
if (mode == TransitionMode.AUTOMIX) immersiveGroup("automix", headerRes = R.string.settings_automix_title, footerRes = R.string.settings_automix_detail) {
diff --git a/base/app/src/main/java/com/music/spotui/ui/immersive/screens/ImmersiveHomeChips.kt b/base/app/src/main/java/com/music/spotui/ui/immersive/screens/ImmersiveHomeChips.kt
index 6cb56b18..ca8dfd11 100644
--- a/base/app/src/main/java/com/music/spotui/ui/immersive/screens/ImmersiveHomeChips.kt
+++ b/base/app/src/main/java/com/music/spotui/ui/immersive/screens/ImmersiveHomeChips.kt
@@ -15,6 +15,8 @@ import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.layout.size
+import androidx.compose.material.icons.rounded.Close
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Text
@@ -58,12 +60,13 @@ internal fun ImmersiveChipRow(
internal fun ImmersiveChip(
label: String,
selected: Boolean,
+ shape: androidx.compose.ui.graphics.Shape = ChipShape,
onClick: () -> Unit,
) {
val haptics = LocalHapticFeedback.current
Box(
modifier = Modifier
- .clip(ChipShape)
+ .clip(shape)
.background(if (selected) Immersive.Text else Immersive.Raised)
// Only a pill that is not already selected has anything to report: re-tapping the
// current one changes nothing, so buzzing for it would be feedback for a no-op.
@@ -83,3 +86,52 @@ internal fun ImmersiveChip(
)
}
}
+
+/** The left half of two chips joined (a picked chip and the one it opened), and the right one. */
+private val JoinedStart = RoundedCornerShape(topStart = 12.dp, bottomStart = 12.dp, topEnd = 4.dp, bottomEnd = 4.dp)
+private val JoinedEnd = RoundedCornerShape(topStart = 4.dp, bottomStart = 4.dp, topEnd = 12.dp, bottomEnd = 12.dp)
+
+/**
+ * The Home facets as Spotify shows them: All, Music, Podcasts, Audiobooks; once one is picked, a
+ * close chip, the picked one, and joined to it the chips it opens (Following: only what the user
+ * follows), which slide out of it. A label Spotify sent is shown as it came (in the app's language).
+ */
+@Composable
+internal fun ImmersiveHomeFacets(facet: String, labels: Map<String, String>, podcasts: Boolean, select: (String) -> Unit) {
+ val parent = com.music.spotui.data.entity.HomeSubChips.parentOf(facet) ?: facet
+ val subs = com.music.spotui.data.entity.HomeSubChips.byParent[parent].orEmpty()
+ ImmersiveChipRow {
+ if (facet.isEmpty()) {
+ ImmersiveChip(labels[""].orEmpty(), selected = true) {}
+ for (id in listOfNotNull("music-chip", "podcasts-chip".takeIf { podcasts }, "audiobooks-chip".takeIf { podcasts })) {
+ ImmersiveChip(labels[id].orEmpty(), selected = false) { select(id) }
+ }
+ return@ImmersiveChipRow
+ }
+ // Back to everything.
+ Box(
+ Modifier.clip(ChipShape).background(Immersive.Raised).clickable(role = Role.Button) { select("") }
+ .padding(horizontal = 8.dp, vertical = 6.dp),
+ ) {
+ androidx.compose.material3.Icon(
+ androidx.compose.material.icons.Icons.Rounded.Close, contentDescription = labels[""],
+ tint = Immersive.Text, modifier = Modifier.size(18.dp),
+ )
+ }
+ Row(horizontalArrangement = Arrangement.spacedBy(2.dp)) {
+ ImmersiveChip(labels[parent] ?: subs.firstOrNull { it.first == parent }?.second.orEmpty(), selected = true,
+ shape = if (subs.isEmpty()) ChipShape else JoinedStart) { select(parent) }
+ subs.forEachIndexed { i, (id, label) ->
+ // Slides out of the picked chip the first time it shows.
+ val shown = androidx.compose.runtime.remember(id) { androidx.compose.animation.core.MutableTransitionState(false).apply { targetState = true } }
+ androidx.compose.animation.AnimatedVisibility(
+ visibleState = shown,
+ enter = androidx.compose.animation.expandHorizontally(expandFrom = Alignment.Start) + androidx.compose.animation.fadeIn(),
+ ) {
+ ImmersiveChip(label, selected = facet == id,
+ shape = if (i == subs.lastIndex) JoinedEnd else RoundedCornerShape(4.dp)) { select(id) }
+ }
+ }
+ }
+ }
+}
diff --git a/base/app/src/main/java/com/music/spotui/ui/immersive/screens/ImmersiveHomeScreen.kt b/base/app/src/main/java/com/music/spotui/ui/immersive/screens/ImmersiveHomeScreen.kt
index 91597c51..c682b854 100644
--- a/base/app/src/main/java/com/music/spotui/ui/immersive/screens/ImmersiveHomeScreen.kt
+++ b/base/app/src/main/java/com/music/spotui/ui/immersive/screens/ImmersiveHomeScreen.kt
@@ -39,6 +39,7 @@ import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.draw.clip
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
+import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
@@ -157,22 +158,17 @@ fun ImmersiveHomeScreen(navController: NavController) {
modifier = Modifier.fillMaxSize().immersiveHazeSource().immersiveChromeScroll(),
) {
item(key = "home:facets") {
- ImmersiveChipRow {
- ImmersiveChip(stringResource(R.string.filter_chip_all_label), selected = facet.isEmpty()) {
- if (facet.isNotEmpty()) homeViewModel.selectFacet(facet)
- }
- ImmersiveChip(stringResource(R.string.recents_content_filter_music), selected = facet == "music-chip") {
- homeViewModel.selectFacet("music-chip")
- }
- if (Features.PODCASTS) {
- ImmersiveChip(stringResource(R.string.ad_category_title_podcasts), selected = facet == "podcasts-chip") {
- homeViewModel.selectFacet("podcasts-chip")
- }
- ImmersiveChip(stringResource(R.string.audiobooks_title), selected = facet == "audiobooks-chip") {
- homeViewModel.selectFacet("audiobooks-chip")
- }
- }
- }
+ ImmersiveHomeFacets(
+ facet,
+ labels = mapOf(
+ "" to stringResource(R.string.filter_chip_all_label),
+ "music-chip" to stringResource(R.string.recents_content_filter_music),
+ "podcasts-chip" to stringResource(R.string.ad_category_title_podcasts),
+ "audiobooks-chip" to stringResource(R.string.audiobooks_title),
+ ),
+ podcasts = Features.PODCASTS,
+ select = homeViewModel::selectFacet,
+ )
}
when {
feed != null && feed.sections.isNotEmpty() -> {
@@ -210,6 +206,12 @@ fun ImmersiveHomeScreen(navController: NavController) {
}
// The greeting and the profile disc on floating glass; the feed scrolls under it.
ImmersiveFloatingHeader(title, collapse = rememberTopBarCollapse(listState, 24.dp)) {
+ // Friend activity, out of the tab bar: beside the profile, as Spotify has it.
+ com.music.spotui.ui.immersive.shell.ImmersiveBarAction(
+ androidx.compose.ui.graphics.vector.ImageVector.vectorResource(R.drawable.ic_friends_big),
+ contentDescription = stringResource(R.string.friends_title),
+ onClick = { navController.navigate(com.music.spotui.ui.navigation.Routes.Friends.route) },
+ )
val size = LocalBarControlSize.current
// The tap area is the header's full height and reaches past the disc toward the
// title, so the small disc of the minimized bar is still easy to hit.
diff --git a/base/app/src/main/java/com/music/spotui/ui/immersive/shell/ImmersiveTabBar.kt b/base/app/src/main/java/com/music/spotui/ui/immersive/shell/ImmersiveTabBar.kt
index 007c34f9..d50491b6 100644
--- a/base/app/src/main/java/com/music/spotui/ui/immersive/shell/ImmersiveTabBar.kt
+++ b/base/app/src/main/java/com/music/spotui/ui/immersive/shell/ImmersiveTabBar.kt
@@ -179,10 +179,11 @@ internal fun rememberTabNavigation(navController: NavController): TabNavigation
return TabNavigation(selectedTab, onTabClick, fullScreen)
}
-private val TabRoutes = listOf(Routes.Home.route, Routes.Search.route, Routes.Library.route, Routes.Friends.route)
+// Friend activity is not a tab any more: it opens from Home's header, as in Spotify.
+private val TabRoutes = listOf(Routes.Home.route, Routes.Search.route, Routes.Library.route)
/** The tabs the bar shows. */
-internal val TabItems = listOf(Routes.Home, Routes.Library, Routes.Friends, Routes.Search)
+internal val TabItems = listOf(Routes.Home, Routes.Library, Routes.Search)
/** The tab bar itself (pill and Search circle), filling the width [modifier] leaves it. */
@Composable
@@ -216,7 +217,7 @@ internal fun TabBarContent(
contentKey = selectedTab,
) {
// Search is the odd one out: a circle of its own beside the pill.
- listOf(Routes.Home, Routes.Library, Routes.Friends).forEach { item ->
+ listOf(Routes.Home, Routes.Library).forEach { item ->
val tint = if (selectedTab == item.route) Immersive.Accent else Immersive.Text.copy(alpha = 0.65f)
tab(
key = item.route,
diff --git a/base/app/src/main/java/com/music/spotui/ui/immersive/shell/backdrop/DrawBackdropModifier.kt b/base/app/src/main/java/com/music/spotui/ui/immersive/shell/backdrop/DrawBackdropModifier.kt
index 0fcc3d9d..c321e3dc 100644
--- a/base/app/src/main/java/com/music/spotui/ui/immersive/shell/backdrop/DrawBackdropModifier.kt
+++ b/base/app/src/main/java/com/music/spotui/ui/immersive/shell/backdrop/DrawBackdropModifier.kt
@@ -27,6 +27,8 @@ import androidx.compose.ui.graphics.drawscope.scale
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.graphics.layer.GraphicsLayer
import androidx.compose.ui.graphics.layer.drawLayer
+import androidx.compose.ui.graphics.drawscope.clipPath
+import androidx.compose.ui.graphics.addOutline
import androidx.compose.ui.layout.LayoutCoordinates
import androidx.compose.ui.layout.Measurable
import androidx.compose.ui.layout.MeasureResult
@@ -385,10 +387,17 @@ private class DrawBackdropNode(
exportedBackdrop?.graphicsLayer?.let { layer ->
recordLayer(this@DrawBackdropNode, layer) {
- onDrawBehind?.invoke(this)
- drawRecordedBackdrop()
- onDrawSurface?.invoke(this)
- onDrawFront?.invoke(this)
+ // Inside the surface's own shape, as on screen: a lens lifted past the bar's edge
+ // would otherwise show the blur's padding as a square of glass around it.
+ val clip = androidx.compose.ui.graphics.Path().apply {
+ addOutline(shapeProvider.shape.createOutline(size, layoutDirection, this@recordLayer))
+ }
+ clipPath(clip) {
+ onDrawBehind?.invoke(this)
+ drawRecordedBackdrop()
+ onDrawSurface?.invoke(this)
+ onDrawFront?.invoke(this)
+ }
}
}
}
diff --git a/base/app/src/main/java/com/music/spotui/ui/immersive/shell/backdrop/backdrops/LayerBackdrop.kt b/base/app/src/main/java/com/music/spotui/ui/immersive/shell/backdrop/backdrops/LayerBackdrop.kt
index d1ba24fe..6efded53 100644
--- a/base/app/src/main/java/com/music/spotui/ui/immersive/shell/backdrop/backdrops/LayerBackdrop.kt
+++ b/base/app/src/main/java/com/music/spotui/ui/immersive/shell/backdrop/backdrops/LayerBackdrop.kt
@@ -149,16 +149,32 @@ class LayerBackdrop internal constructor(
with(obtainInverseLayerScope()) { inverseTransform(density, layerBlock) }
}
}) {
- drawSources { src ->
+ val offsetOf: (LayoutCoordinates) -> Offset = { src ->
try {
src.localPositionOf(coordinates)
} catch (_: Exception) {
coordinates.positionInWindow() - src.positionInWindow()
}
}
+ if (sources.isNotEmpty()) drawSources(offsetOf) else drawExported(offsetOf)
}
}
+ /**
+ * A glass exported here (drawBackdrop's exportedBackdrop: the tab bar's glass, for its
+ * selection lens) records into [graphicsLayer] and sets [layerCoordinates], with no page source.
+ * Reported: a tap or a drag on the Liquid Glass tab bar left the selection pill fully see-through
+ * (the bare page, no glass) until it landed and the flat pill took over with a jump: only the
+ * page sources were drawn here, so the lens refracted the page, the fill and the tabs, never
+ * the bar's glass under them.
+ */
+ private fun DrawScope.drawExported(offsetOf: (LayoutCoordinates) -> Offset) {
+ val c = layerCoordinates ?: return
+ if (!c.isAttached || graphicsLayer.isReleased || graphicsLayer.size.width <= 0) return
+ val o = offsetOf(c)
+ withTransform({ translate(-o.x, -o.y) }) { drawLayer(graphicsLayer) }
+ }
+
private fun obtainInverseLayerScope(): InverseLayerScope {
return inverseLayerScope?.apply { reset() }
?: InverseLayerScope().also { inverseLayerScope = it }
diff --git a/base/app/src/main/java/com/music/spotui/ui/navigation/MainBottomNavigation.kt b/base/app/src/main/java/com/music/spotui/ui/navigation/MainBottomNavigation.kt
index 25ee8ed4..e8fa4973 100644
--- a/base/app/src/main/java/com/music/spotui/ui/navigation/MainBottomNavigation.kt
+++ b/base/app/src/main/java/com/music/spotui/ui/navigation/MainBottomNavigation.kt
@@ -168,7 +168,8 @@ fun MainBottomNavigation(navController: NavHostController) {
)
}
-private val TabItems = listOf(Routes.Home, Routes.Search, Routes.Library, Routes.Friends)
+// Friend activity opens from Home's header (as in Spotify), not from a tab.
+private val TabItems = listOf(Routes.Home, Routes.Search, Routes.Library)
/** The tab shown (also on its sub-pages) and what a tap on a tab does; shared by the bar and the rail. */
private class TabNavigation(private val navController: NavHostController, private val state: androidx.compose.runtime.MutableState<String>, private val currentRoute: String?) {
diff --git a/base/app/src/main/java/com/music/spotui/ui/navigation/MyNavHost.kt b/base/app/src/main/java/com/music/spotui/ui/navigation/MyNavHost.kt
index 630b17e7..b47968c7 100644
--- a/base/app/src/main/java/com/music/spotui/ui/navigation/MyNavHost.kt
+++ b/base/app/src/main/java/com/music/spotui/ui/navigation/MyNavHost.kt
@@ -285,7 +285,7 @@ fun MyNavHost(
}
}
-private val tabRoutes = setOf(Routes.Home.route, Routes.Search.route, Routes.Library.route, Routes.Friends.route)
+private val tabRoutes = setOf(Routes.Home.route, Routes.Search.route, Routes.Library.route)
// Full-height sheets over the current page (the official player / queue).
private val sheetRoutes = setOf(Routes.Player.route, Routes.Queue.route)
diff --git a/base/app/src/main/java/com/music/spotui/ui/screens/HomeScreen.kt b/base/app/src/main/java/com/music/spotui/ui/screens/HomeScreen.kt
index a954eef4..7b284b55 100644
--- a/base/app/src/main/java/com/music/spotui/ui/screens/HomeScreen.kt
+++ b/base/app/src/main/java/com/music/spotui/ui/screens/HomeScreen.kt
@@ -53,6 +53,9 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.layout.ContentScale
import androidx.compose.material.icons.Icons
+import androidx.compose.material3.Icon
+import androidx.compose.material3.IconButton
+import androidx.compose.material.icons.filled.Close
import androidx.compose.material.icons.filled.Extension
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
@@ -310,23 +313,62 @@ private fun HomeHeaderRow(navController: NavController, facet: String, onFacet:
.horizontalScroll(androidx.compose.foundation.rememberScrollState())
.padding(start = 12.dp, end = 8.dp, top = 10.dp, bottom = 10.dp),
) {
- // Spotify's home chips; tapping the selected one goes back to "Tout".
- HomePill(stringResource(R.string.filter_chip_all_label), selected = facet.isEmpty()) { onFacet("") }
- HomePill(stringResource(R.string.recents_content_filter_music), selected = facet == "music-chip") { onFacet("music-chip") }
- if (com.music.spotui.data.api.Features.PODCASTS) {
- HomePill(stringResource(R.string.ad_category_title_podcasts), selected = facet == "podcasts-chip") { onFacet("podcasts-chip") }
- HomePill(stringResource(R.string.audiobooks_title), selected = facet == "audiobooks-chip") { onFacet("audiobooks-chip") }
+ // Spotify's home chips. Once one is picked, as in Spotify: a close chip, the picked one,
+ // and joined to it the chips it opens (Following: only what the user follows).
+ val labels = mapOf(
+ "music-chip" to stringResource(R.string.recents_content_filter_music),
+ "podcasts-chip" to stringResource(R.string.ad_category_title_podcasts),
+ "audiobooks-chip" to stringResource(R.string.audiobooks_title),
+ )
+ if (facet.isEmpty()) {
+ HomePill(stringResource(R.string.filter_chip_all_label), selected = true) {}
+ HomePill(labels.getValue("music-chip")) { onFacet("music-chip") }
+ if (com.music.spotui.data.api.Features.PODCASTS) {
+ HomePill(labels.getValue("podcasts-chip")) { onFacet("podcasts-chip") }
+ HomePill(labels.getValue("audiobooks-chip")) { onFacet("audiobooks-chip") }
+ }
+ } else {
+ val parent = com.music.spotui.data.entity.HomeSubChips.parentOf(facet) ?: facet
+ val subs = com.music.spotui.data.entity.HomeSubChips.byParent[parent].orEmpty()
+ Box(
+ contentAlignment = Alignment.Center,
+ modifier = Modifier.clip(CircleShape).background(tone(0xFF2A2A2A)).clickable { onFacet("") }.padding(8.dp),
+ ) {
+ Icon(androidx.compose.material.icons.Icons.Filled.Close, contentDescription = stringResource(R.string.filter_chip_all_label),
+ tint = AppText, modifier = Modifier.size(18.dp))
+ }
+ Row(horizontalArrangement = Arrangement.spacedBy(2.dp)) {
+ HomePill(labels[parent].orEmpty(), selected = true, shape = if (subs.isEmpty()) RoundedCornerShape(50) else JoinedStart) { onFacet(parent) }
+ subs.forEachIndexed { i, (id, label) ->
+ val shown = remember(id) { androidx.compose.animation.core.MutableTransitionState(false).apply { targetState = true } }
+ androidx.compose.animation.AnimatedVisibility(
+ visibleState = shown,
+ enter = androidx.compose.animation.expandHorizontally(expandFrom = Alignment.Start) + androidx.compose.animation.fadeIn(),
+ ) {
+ HomePill(label, selected = facet == id, shape = if (i == subs.lastIndex) JoinedEnd else RoundedCornerShape(4.dp)) { onFacet(id) }
+ }
+ }
+ }
}
}
+ // Friend activity, out of the tab bar: at the end of the header, as Spotify has it.
+ IconButton(onClick = { navController.navigate(com.music.spotui.ui.navigation.Routes.Friends.route) }) {
+ Icon(androidx.compose.ui.res.painterResource(R.drawable.ic_friends_big), contentDescription = stringResource(R.string.friends_title),
+ tint = AppText, modifier = Modifier.size(24.dp))
+ }
}
}
+/** The left half of two pills joined (a picked chip and the one it opened), and the right one. */
+private val JoinedStart = RoundedCornerShape(topStartPercent = 50, bottomStartPercent = 50, topEndPercent = 15, bottomEndPercent = 15)
+private val JoinedEnd = RoundedCornerShape(topStartPercent = 15, bottomStartPercent = 15, topEndPercent = 50, bottomEndPercent = 50)
+
@Composable
-private fun HomePill(label: String, selected: Boolean = false, onClick: () -> Unit) {
+private fun HomePill(label: String, selected: Boolean = false, shape: androidx.compose.ui.graphics.Shape = RoundedCornerShape(50), onClick: () -> Unit) {
Box(
contentAlignment = Alignment.Center,
modifier = Modifier
- .clip(RoundedCornerShape(50))
+ .clip(shape)
.background(if (selected) com.music.spotui.ui.theme.AppAccent else tone(0xFF2A2A2A))
.clickable(onClick = onClick)
.padding(horizontal = 16.dp, vertical = 8.dp),
diff --git a/base/app/src/main/java/com/music/spotui/ui/screens/SettingsScreen.kt b/base/app/src/main/java/com/music/spotui/ui/screens/SettingsScreen.kt
index f1d48c30..6d6acaec 100644
--- a/base/app/src/main/java/com/music/spotui/ui/screens/SettingsScreen.kt
+++ b/base/app/src/main/java/com/music/spotui/ui/screens/SettingsScreen.kt
@@ -75,7 +75,7 @@ fun SettingsScreen(navController: NavController) {
}
// One tab per group, so the page is no longer one long list.
var tab by androidx.compose.runtime.saveable.rememberSaveable { mutableStateOf(0) }
- val tabs = listOf(R.string.settings_section_playback, R.string.settings_section_downloads, R.string.settings_tab_appearance,
+ val tabs = listOf(R.string.settings_section_playback, R.string.settings_section_lyrics, R.string.settings_section_downloads, R.string.settings_tab_appearance,
R.string.extensions_title, R.string.settings_tab_about, R.string.accounts_title)
androidx.compose.material3.ScrollableTabRow(
selectedTabIndex = tab, containerColor = Color.Transparent, contentColor = AppText, edgePadding = 12.dp,
@@ -107,13 +107,6 @@ fun SettingsScreen(navController: NavController) {
StreamingQualityPicker(title = R.string.quality_streaming_wifi_title)
StreamingQualityPicker(cellular = true, title = R.string.quality_streaming_cell_title)
}
- var canvasWifiOnly by remember { mutableStateOf(com.music.spotui.data.preferences.isCanvasWifiOnly(ctx)) }
- OptionRow(
- label = stringResource(R.string.canvas_wifi_only),
- detail = stringResource(R.string.canvas_wifi_only_detail),
- checked = canvasWifiOnly,
- onChecked = { canvasWifiOnly = it; com.music.spotui.data.preferences.setCanvasWifiOnly(ctx, it) },
- )
OptionRow(
label = stringResource(R.string.settings_autoplay_title),
detail = stringResource(R.string.settings_autoplay_detail),
@@ -135,6 +128,8 @@ fun SettingsScreen(navController: NavController) {
Text(stringResource(R.string.equalizer_title), color = AppText, fontSize = 16.sp)
Text(stringResource(R.string.equalizer_settings_detail), color = AppMuted, fontSize = 12.sp)
}
+ // What keeps the music going and what the headset buttons do.
+ Section(R.string.settings_section_controls)
var keepPlaying by remember { mutableStateOf(app.myspoti.host.android.PlaybackService.keepsPlayingOnClose(ctx)) }
OptionRow(
label = stringResource(R.string.settings_keep_playing_title),
@@ -149,6 +144,8 @@ fun SettingsScreen(navController: NavController) {
checked = headsetSkip,
onChecked = { headsetSkip = it; app.myspoti.host.android.PlaybackService.setSkipsOnEpisodes(ctx, it) },
)
+ // What other devices see of this phone, and a Jam joined here.
+ Section(R.string.settings_section_connect)
// Songs an extension streams, played by Spotify too (unheard): counted there, seen by Connect.
if (com.music.spotui.extensions.Extensions.sources(app.myspoti.extensions.Action.AUDIO_SOURCE).isNotEmpty())
OptionRow(
@@ -157,13 +154,6 @@ fun SettingsScreen(navController: NavController) {
checked = com.music.spotui.data.preferences.ConnectMirrorPref.on,
onChecked = { com.music.spotui.data.preferences.ConnectMirrorPref.set(ctx, it) },
)
- // Live Radio: adds the pinned Library row under Local Files (see com.music.spotui.radio).
- OptionRow(
- label = stringResource(R.string.live_radio_settings_title),
- detail = stringResource(R.string.live_radio_settings_detail),
- checked = com.music.spotui.radio.RadioFeaturePref.on,
- onChecked = { com.music.spotui.radio.RadioFeaturePref.set(ctx, it) },
- )
// Downloaded songs, played from their files online, played by Spotify too (unheard), as an extension's.
OptionRow(
label = stringResource(R.string.settings_download_sync_title),
@@ -171,6 +161,14 @@ fun SettingsScreen(navController: NavController) {
checked = com.music.spotui.data.preferences.DownloadSyncPref.on,
onChecked = { com.music.spotui.data.preferences.DownloadSyncPref.set(ctx, it) },
)
+ Section(R.string.settings_section_library)
+ // Live Radio: adds the pinned Library row under Local Files (see com.music.spotui.radio).
+ OptionRow(
+ label = stringResource(R.string.live_radio_settings_title),
+ detail = stringResource(R.string.live_radio_settings_detail),
+ checked = com.music.spotui.radio.RadioFeaturePref.on,
+ onChecked = { com.music.spotui.radio.RadioFeaturePref.set(ctx, it) },
+ )
// Songs marked "Not interested": skipped by lists, listed here to be shown again.
Column(
Modifier.fillMaxWidth().clickable { navController.navigate(com.music.spotui.ui.navigation.Routes.HiddenSongs.route) }
@@ -179,6 +177,48 @@ fun SettingsScreen(navController: NavController) {
Text(stringResource(R.string.hidden_songs_title), color = AppText, fontSize = 16.sp)
Text(stringResource(R.string.hidden_songs_detail), color = AppMuted, fontSize = 12.sp)
}
+ Divider()
+ SourcesBlock(app.myspoti.extensions.Action.AUDIO_SOURCE, navController)
+ // Podcasts: SponsorBlock (SponsorBlockSettings.kt).
+ SponsorBlockSettings()
+
+ Section(R.string.settings_section_data)
+ OptionRow(
+ label = stringResource(R.string.energy_saver_title),
+ detail = stringResource(R.string.energy_saver_summary),
+ checked = energy.manualSaver,
+ onChecked = app.myspoti.power.EnergySettings::setSaver,
+ )
+ OptionRow(
+ label = stringResource(R.string.data_saver_title),
+ detail = stringResource(R.string.data_saver_summary),
+ checked = com.music.spotui.data.DataSaver.enabled,
+ onChecked = com.music.spotui.data.DataSaver::set,
+ )
+ // Battery optimization off = music and Connect keep going with the screen off.
+ var exempt by remember { androidx.compose.runtime.mutableStateOf(app.myspoti.power.BatteryExemption.isExempt(ctx)) }
+ androidx.lifecycle.compose.LifecycleEventEffect(androidx.lifecycle.Lifecycle.Event.ON_RESUME) {
+ exempt = app.myspoti.power.BatteryExemption.isExempt(ctx)
+ }
+ OptionRow(
+ label = stringResource(R.string.background_playback_title),
+ detail = stringResource(if (exempt) R.string.background_playback_on else R.string.background_playback_off),
+ checked = exempt,
+ onChecked = {
+ if (exempt) ctx.startActivity(android.content.Intent(android.provider.Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS))
+ else app.myspoti.power.BatteryExemption.request(ctx)
+ },
+ )
+ // Samsung's "Sleeping apps" is a second list: the app has to be in Never sleeping apps too.
+ if (app.myspoti.power.BatteryExemption.isSamsung()) Column(
+ Modifier.fillMaxWidth().clickable { app.myspoti.power.BatteryExemption.openAppSettings(ctx) }
+ .padding(horizontal = 20.dp, vertical = 10.dp),
+ ) {
+ Text(stringResource(R.string.background_playback_open), color = AppText, fontSize = 16.sp)
+ Text(stringResource(R.string.background_playback_samsung), color = AppMuted, fontSize = 12.sp)
+ }
+ }
+ if (tab == 1) {
// Lyrics: word by word (karaoke) first, or line by line with Spotify's first.
Section(R.string.settings_section_lyrics)
var wordSync by remember { mutableStateOf(com.music.spotui.data.preferences.isLyricsWordSync(ctx)) }
@@ -221,48 +261,8 @@ fun SettingsScreen(navController: NavController) {
onChecked = { com.music.spotui.data.preferences.LyricsRomanizationPref.set(ctx, it) },
)
LyricsTranslationRow()
- Divider()
- SourcesBlock(app.myspoti.extensions.Action.AUDIO_SOURCE, navController)
- // Podcasts: SponsorBlock (SponsorBlockSettings.kt).
- SponsorBlockSettings()
-
- Section(R.string.settings_section_data)
- OptionRow(
- label = stringResource(R.string.energy_saver_title),
- detail = stringResource(R.string.energy_saver_summary),
- checked = energy.manualSaver,
- onChecked = app.myspoti.power.EnergySettings::setSaver,
- )
- OptionRow(
- label = stringResource(R.string.data_saver_title),
- detail = stringResource(R.string.data_saver_summary),
- checked = com.music.spotui.data.DataSaver.enabled,
- onChecked = com.music.spotui.data.DataSaver::set,
- )
- // Battery optimization off = music and Connect keep going with the screen off.
- var exempt by remember { androidx.compose.runtime.mutableStateOf(app.myspoti.power.BatteryExemption.isExempt(ctx)) }
- androidx.lifecycle.compose.LifecycleEventEffect(androidx.lifecycle.Lifecycle.Event.ON_RESUME) {
- exempt = app.myspoti.power.BatteryExemption.isExempt(ctx)
}
- OptionRow(
- label = stringResource(R.string.background_playback_title),
- detail = stringResource(if (exempt) R.string.background_playback_on else R.string.background_playback_off),
- checked = exempt,
- onChecked = {
- if (exempt) ctx.startActivity(android.content.Intent(android.provider.Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS))
- else app.myspoti.power.BatteryExemption.request(ctx)
- },
- )
- // Samsung's "Sleeping apps" is a second list: the app has to be in Never sleeping apps too.
- if (app.myspoti.power.BatteryExemption.isSamsung()) Column(
- Modifier.fillMaxWidth().clickable { app.myspoti.power.BatteryExemption.openAppSettings(ctx) }
- .padding(horizontal = 20.dp, vertical = 10.dp),
- ) {
- Text(stringResource(R.string.background_playback_open), color = AppText, fontSize = 16.sp)
- Text(stringResource(R.string.background_playback_samsung), color = AppMuted, fontSize = 12.sp)
- }
- }
- if (tab == 1) {
+ if (tab == 2) {
Section(R.string.settings_section_downloads)
// Its role quality takes the place of the app's (kept, and still passed to every extension as `quality`).
val ext = remember(registry) { com.music.spotui.extensions.Extensions.sectionPlacement(app.myspoti.extensions.SettingSection.DOWNLOADS) }
@@ -296,7 +296,7 @@ fun SettingsScreen(navController: NavController) {
StorageRows()
if (com.music.spotui.data.offline.OfflineStore.tracks.isNotEmpty()) RemoveDownloadsRow()
}
- if (tab == 2) {
+ if (tab == 3) {
Section(R.string.settings_section_display)
OptionRow(
@@ -312,6 +312,13 @@ fun SettingsScreen(navController: NavController) {
enabled = !energy.policy.saverEnabled,
onChecked = app.myspoti.power.EnergySettings::setCanvasEnabled,
)
+ var canvasWifiOnly by remember { mutableStateOf(com.music.spotui.data.preferences.isCanvasWifiOnly(ctx)) }
+ OptionRow(
+ label = stringResource(R.string.canvas_wifi_only),
+ detail = stringResource(R.string.canvas_wifi_only_detail),
+ checked = canvasWifiOnly,
+ onChecked = { canvasWifiOnly = it; com.music.spotui.data.preferences.setCanvasWifiOnly(ctx, it) },
+ )
OptionRow(
label = stringResource(R.string.settings_music_video_title),
detail = stringResource(R.string.settings_music_video_detail),
@@ -360,7 +367,7 @@ fun SettingsScreen(navController: NavController) {
OrientationRow()
LanguageRow()
}
- if (tab == 3) {
+ if (tab == 4) {
ExtensionSettingsRows(navController)
// Third-party extensions: lyrics, a song's audio, scripts reacting to the music.
Column(
@@ -371,7 +378,7 @@ fun SettingsScreen(navController: NavController) {
Text(stringResource(R.string.extensions_row_detail), color = AppMuted, fontSize = 12.sp)
}
}
- if (tab == 4) {
+ if (tab == 5) {
Section(R.string.settings_section_app)
AboutRow()
// A18: the launch check can be turned off; the manual check below keeps working.
@@ -406,7 +413,7 @@ fun SettingsScreen(navController: NavController) {
Text(stringResource(R.string.diagnostic_export_detail), color = AppMuted, fontSize = 12.sp)
}
}
- if (tab == 5) {
+ if (tab == 6) {
// The Spotify accounts kept on the phone: switch, add, remove; and signing this one out.
Section(R.string.accounts_title)
com.music.spotui.ui.components.AccountsList()
@@ -536,7 +543,6 @@ private fun AccentRow(look: com.music.spotui.data.preferences.Look) {
@Composable
private fun TransitionsRow() {
val ctx = androidx.compose.ui.platform.LocalContext.current
- val pref = com.music.spotui.data.preferences.CrossfadePref
val transition = com.music.spotui.data.preferences.TransitionPref
val automix = com.music.spotui.automix.AutoMix
val mode = transition.mode
@@ -587,12 +593,9 @@ private fun TransitionsRow() {
if (mode == TransitionMode.AUTOMIX) com.music.spotui.ui.components.autoMixReasonText(automix.whyNot())?.let {
Text(stringResource(it), color = com.music.spotui.ui.theme.AppAccent, fontSize = 12.sp, modifier = Modifier.padding(top = 8.dp))
}
- if (mode == TransitionMode.CROSSFADE) Row(
- horizontalArrangement = androidx.compose.foundation.layout.Arrangement.spacedBy(8.dp),
- modifier = Modifier.padding(top = 10.dp),
- ) {
- for (v in listOf(3, 6, 9, 12)) Chip(stringResource(R.string.settings_crossfade_seconds, v), pref.seconds == v) { pref.set(ctx, v) }
- }
+ // Any length from 1 to 12 s on a slider (it was four fixed choices).
+ if (mode == TransitionMode.CROSSFADE) com.music.spotui.ui.components.CrossfadeSlider(
+ com.music.spotui.ui.theme.AppAccent, AppText, AppMuted, Modifier.padding(top = 12.dp))
}
if (mode == TransitionMode.AUTOMIX) {
OptionRow(stringResource(R.string.settings_automix_on_next), stringResource(R.string.settings_automix_on_next_detail),
diff --git a/base/app/src/main/java/com/music/spotui/ui/screens/StatsScreens.kt b/base/app/src/main/java/com/music/spotui/ui/screens/StatsScreens.kt
index 4a843e06..33038f46 100644
--- a/base/app/src/main/java/com/music/spotui/ui/screens/StatsScreens.kt
+++ b/base/app/src/main/java/com/music/spotui/ui/screens/StatsScreens.kt
@@ -23,6 +23,7 @@ import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
+import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material.icons.filled.EmojiEvents
import androidx.compose.material.icons.filled.Refresh
import androidx.compose.material.icons.outlined.QueueMusic
@@ -268,8 +269,11 @@ fun FriendActivityScreen(navController: NavController) {
}
val now = remember(state) { System.currentTimeMillis() }
Column(Modifier.fillMaxSize().background(AppBackground).statusBarsPadding()) {
- // A tab of its own: no back arrow.
- Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.fillMaxWidth().padding(16.dp, 12.dp, 8.dp, 8.dp)) {
+ // Opened from Home's header (no longer a tab): back to it.
+ Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.fillMaxWidth().padding(4.dp, 12.dp, 8.dp, 8.dp)) {
+ androidx.compose.material3.IconButton(onClick = { navController.popBackStack() }) {
+ Icon(androidx.compose.material.icons.Icons.AutoMirrored.Filled.ArrowBack, stringResource(R.string.accessibility_navigate_back), tint = AppText)
+ }
Text(stringResource(R.string.friends_title), fontWeight = FontWeight.Bold, color = AppText, fontSize = 22.sp, maxLines = 1,
overflow = TextOverflow.Ellipsis, modifier = Modifier.weight(1f))
Icon(Icons.Filled.Refresh, stringResource(R.string.friends_refresh), tint = AppText,
diff --git a/base/app/src/main/java/com/music/spotui/ui/viewmodel/HomeViewModel.kt b/base/app/src/main/java/com/music/spotui/ui/viewmodel/HomeViewModel.kt
index 358c212c..85a78be8 100644
--- a/base/app/src/main/java/com/music/spotui/ui/viewmodel/HomeViewModel.kt
+++ b/base/app/src/main/java/com/music/spotui/ui/viewmodel/HomeViewModel.kt
@@ -58,8 +58,13 @@ class HomeViewModel constructor(private val repository: AppRepository = Graph.re
if (System.currentTimeMillis() - fetchedAt >= STALE_MS) fetchHome()
}
+ /**
+ * The chip [f] tapped: it is picked, or unpicked when it already was: a sub-chip (Following) goes
+ * back to its parent (Music), a top chip back to everything.
+ */
fun selectFacet(f: String) {
- facet.value = if (facet.value == f) "" else f
+ facet.value = if (facet.value != f) f
+ else com.music.spotui.data.entity.HomeSubChips.parentOf(f)?.takeIf { it != f } ?: ""
fetchHome()
}
diff --git a/base/app/src/main/res/values-de/myspoti_strings.xml b/base/app/src/main/res/values-de/myspoti_strings.xml
index 26cfc5b9..66eb7d60 100644
--- a/base/app/src/main/res/values-de/myspoti_strings.xml
+++ b/base/app/src/main/res/values-de/myspoti_strings.xml
@@ -735,6 +735,11 @@
<string name="settings_automix_mobile_data_detail">Songs aus Erweiterungen werden auch über mobile Daten analysiert. Jeder wird dafür ein zweites Mal geladen: etwa so viele Daten wie beim Abspielen. Aus: nur im WLAN.</string>
<string name="playback_speed_note">Tempo %1$s× · tippen für 1×</string>
<string name="jam_start_premium">Einen Jam starten braucht Spotify Premium. Beitreten geht mit dem Link oder QR-Code.</string>
+ <string name="jam_plays_here">Der Jam läuft auf diesem Handy.</string>
+ <string name="jam_plays_on_host">Die Musik läuft auf dem Gerät des Hosts: Dieses Handy steuert sie. Spotify erlaubt nur Premium-Konten, einen Jam auf dem eigenen Handy zu hören.</string>
+ <string name="settings_section_controls">Steuerung und Hintergrund</string>
+ <string name="settings_section_connect">Spotify Connect und Jam</string>
+ <string name="settings_section_library">Bibliothek</string>
<string name="settings_dynamic_color_title">Dynamische Farben (Material You)</string>
<string name="settings_dynamic_color_detail">Die Akzentfarbe des Looks „Klassisch“ kommt von deinem Hintergrundbild. Der Look „Immersiv“ behält die Farben des laufenden Covers.</string>
<string name="settings_system_font_title">Systemschriftart</string>
diff --git a/base/app/src/main/res/values-el/myspoti_strings.xml b/base/app/src/main/res/values-el/myspoti_strings.xml
index 162f9e51..140a859b 100644
--- a/base/app/src/main/res/values-el/myspoti_strings.xml
+++ b/base/app/src/main/res/values-el/myspoti_strings.xml
@@ -735,6 +735,11 @@
<string name="settings_automix_mobile_data_detail">Τα τραγούδια από επεκτάσεις αναλύονται και με δεδομένα κινητής. Το καθένα κατεβαίνει δεύτερη φορά γι\' αυτό: περίπου όσα δεδομένα και η ακρόασή του. Ανενεργό: μόνο σε Wi-Fi.</string>
<string name="playback_speed_note">Ταχύτητα %1$s× · πάτησε για 1×</string>
<string name="jam_start_premium">Η έναρξη Jam απαιτεί Spotify Premium. Μπορείς να μπεις σε ένα με τον σύνδεσμο ή τον κωδικό QR.</string>
+ <string name="jam_plays_here">Το Jam παίζει σε αυτό το τηλέφωνο.</string>
+ <string name="jam_plays_on_host">Η μουσική παίζει στη συσκευή του οικοδεσπότη: αυτό το τηλέφωνο την ελέγχει. Το Spotify επιτρέπει μόνο στους λογαριασμούς Premium να ακούν ένα Jam στο δικό τους τηλέφωνο.</string>
+ <string name="settings_section_controls">Χειρισμός και παρασκήνιο</string>
+ <string name="settings_section_connect">Spotify Connect και Jam</string>
+ <string name="settings_section_library">Βιβλιοθήκη</string>
<string name="settings_dynamic_color_title">Δυναμικά χρώματα (Material You)</string>
<string name="settings_dynamic_color_detail">Το χρώμα έμφασης της εμφάνισης «Κλασική» προέρχεται από την ταπετσαρία σου. Η εμφάνιση «Εμβυθιστική» κρατά τα χρώματα του εξώφυλλου που παίζει.</string>
<string name="settings_system_font_title">Γραμματοσειρά συστήματος</string>
diff --git a/base/app/src/main/res/values-es/myspoti_strings.xml b/base/app/src/main/res/values-es/myspoti_strings.xml
index a50c1369..e540653b 100644
--- a/base/app/src/main/res/values-es/myspoti_strings.xml
+++ b/base/app/src/main/res/values-es/myspoti_strings.xml
@@ -735,6 +735,11 @@
<string name="settings_automix_mobile_data_detail">Las canciones de extensiones también se analizan con datos móviles. Cada una se descarga una segunda vez para ello: más o menos los mismos datos que al escucharla. Desactivado, solo con Wi-Fi.</string>
<string name="playback_speed_note">Velocidad %1$s× · toca para 1×</string>
<string name="jam_start_premium">Iniciar una Jam requiere Spotify Premium. Puedes unirte a una con su enlace o código QR.</string>
+ <string name="jam_plays_here">La Jam suena en este teléfono.</string>
+ <string name="jam_plays_on_host">La música suena en el dispositivo del anfitrión: este teléfono la controla. Spotify solo deja a las cuentas Premium escuchar una Jam en su propio teléfono.</string>
+ <string name="settings_section_controls">Controles y segundo plano</string>
+ <string name="settings_section_connect">Spotify Connect y Jam</string>
+ <string name="settings_section_library">Biblioteca</string>
<string name="settings_dynamic_color_title">Colores dinámicos (Material You)</string>
<string name="settings_dynamic_color_detail">El color de acento del aspecto Clásico viene de tu fondo de pantalla. El aspecto Inmersivo mantiene los colores de la portada en reproducción.</string>
<string name="settings_system_font_title">Fuente del sistema</string>
diff --git a/base/app/src/main/res/values-fr/myspoti_strings.xml b/base/app/src/main/res/values-fr/myspoti_strings.xml
index 41becec5..f83fa4d3 100644
--- a/base/app/src/main/res/values-fr/myspoti_strings.xml
+++ b/base/app/src/main/res/values-fr/myspoti_strings.xml
@@ -740,6 +740,11 @@
<string name="settings_automix_mobile_data_detail">Les morceaux des extensions sont aussi analysés en données mobiles. Chacun est téléchargé une seconde fois pour cela : à peu près autant de données que pour l\'écouter. Désactivé, en Wi-Fi seulement.</string>
<string name="playback_speed_note">Vitesse %1$s× · toucher pour 1×</string>
<string name="jam_start_premium">Lancer un Jam demande Spotify Premium. Tu peux en rejoindre un avec son lien ou son QR code.</string>
+ <string name="jam_plays_here">Le Jam joue sur ce téléphone.</string>
+ <string name="jam_plays_on_host">La musique sort sur l\'appareil de l\'hôte : ce téléphone la contrôle. Spotify réserve l\'écoute d\'un Jam sur son propre téléphone aux comptes Premium.</string>
+ <string name="settings_section_controls">Commandes et arrière-plan</string>
+ <string name="settings_section_connect">Spotify Connect et Jam</string>
+ <string name="settings_section_library">Bibliothèque</string>
<string name="settings_dynamic_color_title">Couleurs dynamiques (Material You)</string>
<string name="settings_dynamic_color_detail">L\'accent du look Classique vient de ton fond d\'écran. Le look Immersif garde les couleurs de la pochette en cours.</string>
<string name="settings_system_font_title">Police du système</string>
diff --git a/base/app/src/main/res/values-it/myspoti_strings.xml b/base/app/src/main/res/values-it/myspoti_strings.xml
index f0a69131..e43cceaa 100644
--- a/base/app/src/main/res/values-it/myspoti_strings.xml
+++ b/base/app/src/main/res/values-it/myspoti_strings.xml
@@ -735,6 +735,11 @@
<string name="settings_automix_mobile_data_detail">I brani delle estensioni vengono analizzati anche con i dati mobili. Ognuno viene scaricato una seconda volta: circa gli stessi dati dell\'ascolto. Disattivato, solo in Wi-Fi.</string>
<string name="playback_speed_note">Velocità %1$s× · tocca per 1×</string>
<string name="jam_start_premium">Avviare una Jam richiede Spotify Premium. Puoi unirti a una con il link o il codice QR.</string>
+ <string name="jam_plays_here">La Jam suona su questo telefono.</string>
+ <string name="jam_plays_on_host">La musica suona sul dispositivo dell\'host: questo telefono la controlla. Spotify consente solo agli account Premium di ascoltare una Jam sul proprio telefono.</string>
+ <string name="settings_section_controls">Controlli e background</string>
+ <string name="settings_section_connect">Spotify Connect e Jam</string>
+ <string name="settings_section_library">Libreria</string>
<string name="settings_dynamic_color_title">Colori dinamici (Material You)</string>
<string name="settings_dynamic_color_detail">Il colore principale dell\'aspetto Classico viene dal tuo sfondo. L\'aspetto Immersivo mantiene i colori della copertina in riproduzione.</string>
<string name="settings_system_font_title">Carattere di sistema</string>
diff --git a/base/app/src/main/res/values-pl/myspoti_strings.xml b/base/app/src/main/res/values-pl/myspoti_strings.xml
index 3ec13d23..a687478d 100644
--- a/base/app/src/main/res/values-pl/myspoti_strings.xml
+++ b/base/app/src/main/res/values-pl/myspoti_strings.xml
@@ -750,6 +750,11 @@
<string name="settings_automix_mobile_data_detail">Utwory z rozszerzeń są analizowane także przez dane mobilne. Każdy jest w tym celu pobierany drugi raz: mniej więcej tyle danych co przy słuchaniu. Wyłączone: tylko przez Wi-Fi.</string>
<string name="playback_speed_note">Prędkość %1$s× · dotknij, aby 1×</string>
<string name="jam_start_premium">Rozpoczęcie Jamu wymaga Spotify Premium. Możesz dołączyć do jednego przez link lub kod QR.</string>
+ <string name="jam_plays_here">Jam gra na tym telefonie.</string>
+ <string name="jam_plays_on_host">Muzyka gra na urządzeniu gospodarza: ten telefon nią steruje. Spotify pozwala słuchać Jamu na własnym telefonie tylko kontom Premium.</string>
+ <string name="settings_section_controls">Sterowanie i tło</string>
+ <string name="settings_section_connect">Spotify Connect i Jam</string>
+ <string name="settings_section_library">Biblioteka</string>
<string name="settings_dynamic_color_title">Dynamiczne kolory (Material You)</string>
<string name="settings_dynamic_color_detail">Kolor akcentu wyglądu Klasycznego pochodzi z tapety. Wygląd Immersyjny zachowuje kolory odtwarzanej okładki.</string>
<string name="settings_system_font_title">Czcionka systemowa</string>
diff --git a/base/app/src/main/res/values-pt-rBR/myspoti_strings.xml b/base/app/src/main/res/values-pt-rBR/myspoti_strings.xml
index 8b4e210d..d9529d66 100644
--- a/base/app/src/main/res/values-pt-rBR/myspoti_strings.xml
+++ b/base/app/src/main/res/values-pt-rBR/myspoti_strings.xml
@@ -714,6 +714,11 @@
<string name="settings_automix_mobile_data_detail">As músicas das extensões também são analisadas com dados móveis. Cada uma é baixada uma segunda vez para isso: mais ou menos os mesmos dados que ao ouvi-la. Desativado, só no Wi-Fi.</string>
<string name="playback_speed_note">Velocidade %1$s× · toque para 1×</string>
<string name="jam_start_premium">Iniciar uma Jam exige Spotify Premium. Você pode entrar em uma pelo link ou QR code.</string>
+ <string name="jam_plays_here">A Jam toca neste celular.</string>
+ <string name="jam_plays_on_host">A música toca no dispositivo do anfitrião: este celular a controla. O Spotify só deixa contas Premium ouvirem uma Jam no próprio celular.</string>
+ <string name="settings_section_controls">Controles e segundo plano</string>
+ <string name="settings_section_connect">Spotify Connect e Jam</string>
+ <string name="settings_section_library">Biblioteca</string>
<string name="settings_dynamic_color_title">Cores dinâmicas (Material You)</string>
<string name="settings_dynamic_color_detail">A cor de destaque do visual Classic vem do seu papel de parede. O visual Immersive mantém as cores da capa tocando.</string>
<string name="settings_system_font_title">Fonte do sistema</string>
diff --git a/base/app/src/main/res/values-pt-rPT/myspoti_strings.xml b/base/app/src/main/res/values-pt-rPT/myspoti_strings.xml
index e79ce355..c20c74aa 100644
--- a/base/app/src/main/res/values-pt-rPT/myspoti_strings.xml
+++ b/base/app/src/main/res/values-pt-rPT/myspoti_strings.xml
@@ -681,6 +681,11 @@
<string name="settings_automix_mobile_data_detail">As músicas das extensões também são analisadas com dados móveis. Cada uma é transferida uma segunda vez para isso: mais ou menos os mesmos dados que ao ouvi-la. Desativado, só em Wi-Fi.</string>
<string name="playback_speed_note">Velocidade %1$s× · toque para 1×</string>
<string name="jam_start_premium">Iniciar uma Jam requer Spotify Premium. Pode juntar-se a uma com a ligação ou o código QR.</string>
+ <string name="jam_plays_here">A Jam toca neste telemóvel.</string>
+ <string name="jam_plays_on_host">A música toca no dispositivo do anfitrião: este telemóvel controla-a. O Spotify só deixa as contas Premium ouvir uma Jam no próprio telemóvel.</string>
+ <string name="settings_section_controls">Controlos e segundo plano</string>
+ <string name="settings_section_connect">Spotify Connect e Jam</string>
+ <string name="settings_section_library">Biblioteca</string>
<string name="settings_dynamic_color_title">Cores dinâmicas (Material You)</string>
<string name="settings_dynamic_color_detail">A cor de destaque do visual Clássico vem do teu fundo de ecrã. O visual Imersivo mantém as cores da capa em reprodução.</string>
<string name="settings_system_font_title">Tipo de letra do sistema</string>
diff --git a/base/app/src/main/res/values-pt/myspoti_strings.xml b/base/app/src/main/res/values-pt/myspoti_strings.xml
index a70296ae..e1685b79 100644
--- a/base/app/src/main/res/values-pt/myspoti_strings.xml
+++ b/base/app/src/main/res/values-pt/myspoti_strings.xml
@@ -735,6 +735,11 @@
<string name="settings_automix_mobile_data_detail">As músicas das extensões também são analisadas com dados móveis. Cada uma é transferida uma segunda vez para isso: mais ou menos os mesmos dados que ao ouvi-la. Desativado, só em Wi-Fi.</string>
<string name="playback_speed_note">Velocidade %1$s× · toque para 1×</string>
<string name="jam_start_premium">Iniciar uma Jam requer Spotify Premium. Pode juntar-se a uma com a ligação ou o código QR.</string>
+ <string name="jam_plays_here">A Jam toca neste telefone.</string>
+ <string name="jam_plays_on_host">A música toca no dispositivo do anfitrião: este telefone controla-a. O Spotify só deixa as contas Premium ouvir uma Jam no próprio telefone.</string>
+ <string name="settings_section_controls">Controlos e segundo plano</string>
+ <string name="settings_section_connect">Spotify Connect e Jam</string>
+ <string name="settings_section_library">Biblioteca</string>
<string name="settings_dynamic_color_title">Cores dinâmicas (Material You)</string>
<string name="settings_dynamic_color_detail">A cor de destaque do visual Clássico vem do teu fundo de ecrã. O visual Imersivo mantém as cores da capa em reprodução.</string>
<string name="settings_system_font_title">Tipo de letra do sistema</string>
diff --git a/base/app/src/main/res/values-ru/myspoti_strings.xml b/base/app/src/main/res/values-ru/myspoti_strings.xml
index 6d73283f..9347d9f2 100644
--- a/base/app/src/main/res/values-ru/myspoti_strings.xml
+++ b/base/app/src/main/res/values-ru/myspoti_strings.xml
@@ -750,6 +750,11 @@
<string name="settings_automix_mobile_data_detail">Треки из расширений анализируются и по мобильной сети. Каждый для этого скачивается второй раз: примерно столько же трафика, сколько при прослушивании. Выключено: только по Wi-Fi.</string>
<string name="playback_speed_note">Скорость %1$s× · нажмите для 1×</string>
<string name="jam_start_premium">Чтобы начать Jam, нужен Spotify Premium. Присоединиться можно по ссылке или QR-коду.</string>
+ <string name="jam_plays_here">Jam играет на этом телефоне.</string>
+ <string name="jam_plays_on_host">Музыка играет на устройстве хоста: этот телефон управляет ею. Spotify позволяет слушать Jam на своём телефоне только аккаунтам Premium.</string>
+ <string name="settings_section_controls">Управление и фон</string>
+ <string name="settings_section_connect">Spotify Connect и Jam</string>
+ <string name="settings_section_library">Медиатека</string>
<string name="settings_dynamic_color_title">Динамические цвета (Material You)</string>
<string name="settings_dynamic_color_detail">Акцентный цвет оформления «Классическое» берётся из обоев. Оформление «Иммерсивное» сохраняет цвета текущей обложки.</string>
<string name="settings_system_font_title">Системный шрифт</string>
diff --git a/base/app/src/main/res/values-zh/myspoti_strings.xml b/base/app/src/main/res/values-zh/myspoti_strings.xml
index 6ff5bf4a..d3a871a3 100644
--- a/base/app/src/main/res/values-zh/myspoti_strings.xml
+++ b/base/app/src/main/res/values-zh/myspoti_strings.xml
@@ -735,6 +735,11 @@
<string name="settings_automix_mobile_data_detail">扩展中的歌曲在移动数据下也会分析。每首歌为此要再下载一次:流量约等于再播放一遍。关闭时仅在 Wi-Fi 下分析。</string>
<string name="playback_speed_note">速度 %1$s× · 点按恢复 1×</string>
<string name="jam_start_premium">发起 Jam 需要 Spotify Premium。你可以通过链接或二维码加入。</string>
+ <string name="jam_plays_here">Jam 正在此手机上播放。</string>
+ <string name="jam_plays_on_host">音乐在主持人的设备上播放:此手机负责控制。Spotify 只允许 Premium 账户在自己的手机上收听 Jam。</string>
+ <string name="settings_section_controls">控制与后台</string>
+ <string name="settings_section_connect">Spotify Connect 与 Jam</string>
+ <string name="settings_section_library">音乐库</string>
<string name="settings_dynamic_color_title">动态取色 (Material You)</string>
<string name="settings_dynamic_color_detail">经典外观的强调色取自你的壁纸。沉浸式外观保留正在播放的封面颜色。</string>
<string name="settings_system_font_title">系统字体</string>
diff --git a/base/app/src/main/res/values/myspoti_strings.xml b/base/app/src/main/res/values/myspoti_strings.xml
index aaa56e3d..53fccc9b 100644
--- a/base/app/src/main/res/values/myspoti_strings.xml
+++ b/base/app/src/main/res/values/myspoti_strings.xml
@@ -742,6 +742,11 @@
<string name="settings_automix_mobile_data_detail">Songs from extensions are analysed on mobile data too. Each is downloaded a second time for it: about as much data again as playing it. Off, on Wi-Fi only.</string>
<string name="playback_speed_note">Speed %1$s× · tap for 1×</string>
<string name="jam_start_premium">Starting a Jam needs Spotify Premium. You can join one with its link or QR code.</string>
+ <string name="jam_plays_here">The Jam plays on this phone.</string>
+ <string name="jam_plays_on_host">The music plays on the host\'s device: this phone controls it. Spotify only lets Premium accounts listen to a Jam on their own phone.</string>
+ <string name="settings_section_controls">Controls and background</string>
+ <string name="settings_section_connect">Spotify Connect and Jam</string>
+ <string name="settings_section_library">Library</string>
<string name="settings_dynamic_color_title">Dynamic colors (Material You)</string>
<string name="settings_dynamic_color_detail">The Classic look\'s accent comes from your wallpaper. The Immersive look keeps the colors of the playing cover.</string>
<string name="settings_system_font_title">System font</string>
diff --git a/docs/api/JAM.md b/docs/api/JAM.md
index 613cee9f..27612215 100644
--- a/docs/api/JAM.md
+++ b/docs/api/JAM.md
@@ -16,6 +16,12 @@ what Myspoti goes through (`SpotifyJam`, `api-spotify/.../SpotifyMore.kt`). Host
| Invite link | `POST url-dispenser/v1/generate-url` | `spotify_uri: spotify:socialsession:<token>`, `custom_data` (`ssp=1`, `app_destination=socialsession`), `link_preview` (title, `https://shareables.scdn.co/publish/socialsession/<token>`), `utm_*` (`utm_medium` `share-link` or `qr`). Answers `shareable_url` (`spotify.link/…`), `share_id`, `full_url` (`open.spotify.com/socialsession/<token>?si=…`). Service: `getShortInviteLink(token, joinSessionUri, qr?)`. |
| Queued by | GraphQL `decorateQueuedByUsers` (`userUris`) | The host names who queued a song (seen when a member added one). |
+Measured on the phone on 2026-11-03 (free account, host on Premium): `LISTEN_AND_CONTROL` answered
+403 `{"code":7,"message":"User not allowed to join session"}`, `CONTROL` 200. The Web Player's join
+dialog offers the same two: "Continue on this device" (`REMOTE`) and "Play from the host's speaker"
+(`IN_PERSON`). Myspoti asks for the first and takes the second when Spotify refuses it, and the Jam
+sheet says where the music plays (`JamSession.listensHere`).
+
Checked from Myspoti's own code on a free account (`host-cdp` JamLiveTest, the desktop app as the
host): `current_or_new` answers 403 `FREE_USER_NOT_ALLOWED` (a free account cannot start a Jam), the
join answers 200 with `CONTROL`. With `local_device_id` set to the page's own Connect device, the