Skip to content

Native Android client for Spotify, built with Jetpack Compose

Clickable links in descriptions (Spotify links open in the app), one tap per artist in the player, every HTML entity decoded in bios and audiobook descriptions (ideas from the SpotiFusion fork)

kota-zob4e801e03c8b
diff --git a/base/api-spotify/src/main/kotlin/app/myspoti/spotify/HtmlText.kt b/base/api-spotify/src/main/kotlin/app/myspoti/spotify/HtmlText.kt
new file mode 100644
index 00000000..92d559d7
--- /dev/null
+++ b/base/api-spotify/src/main/kotlin/app/myspoti/spotify/HtmlText.kt
@@ -0,0 +1,54 @@
+package app.myspoti.spotify
+
+/**
+ * Spotify sends some descriptions (artist biographies, audiobooks) as small HTML snippets. This is
+ * the pure-Kotlin counterpart of Android's `Html.fromHtml(...).toString()`, which this module cannot
+ * use: line breaks keep their place, other tags go, and entities are decoded.
+ */
+fun stripHtml(html: String): String =
+ decodeHtmlEntities(
+ html.replace(Regex("<br\\s*/?>|</p\\s*>|</div\\s*>|</li\\s*>", RegexOption.IGNORE_CASE), "\n")
+ .replace(Regex("<[^>]+>"), ""),
+ ).replace(Regex("\n{3,}"), "\n\n").trim()
+
+private val ENTITY = Regex("&(#[xX][0-9a-fA-F]{1,6}|#[0-9]{1,7}|[A-Za-z][A-Za-z0-9]{1,9});")
+
+/** `&amp;`, `&eacute;`, `&#39;`, `&#x1F3B5;`... decoded in one pass (so `&amp;lt;` becomes `&lt;`). An unknown or invalid entity stays as written. */
+fun decodeHtmlEntities(text: String): String {
+ if ('&' !in text) return text
+ return ENTITY.replace(text) { m ->
+ val body = m.groupValues[1]
+ if (body[0] == '#') {
+ val code = if (body[1] == 'x' || body[1] == 'X') body.substring(2).toIntOrNull(16) else body.substring(1).toIntOrNull()
+ if (code != null && code in 1..0x10FFFF && code !in 0xD800..0xDFFF) String(Character.toChars(code)) else m.value
+ } else NAMED[body]?.let { String(Character.toChars(it)) } ?: m.value
+ }
+}
+
+// HTML 4's named entities: the Latin-1 block in code point order from U+00A0, then the rest.
+private val LATIN1 = ("nbsp iexcl cent pound curren yen brvbar sect uml copy ordf laquo not shy reg macr deg plusmn sup2 sup3 acute micro " +
+ "para middot cedil sup1 ordm raquo frac14 frac12 frac34 iquest Agrave Aacute Acirc Atilde Auml Aring AElig Ccedil Egrave Eacute " +
+ "Ecirc Euml Igrave Iacute Icirc Iuml ETH Ntilde Ograve Oacute Ocirc Otilde Ouml times Oslash Ugrave Uacute Ucirc Uuml Yacute THORN " +
+ "szlig agrave aacute acirc atilde auml aring aelig ccedil egrave eacute ecirc euml igrave iacute icirc iuml eth ntilde ograve oacute " +
+ "ocirc otilde ouml divide oslash ugrave uacute ucirc uuml yacute thorn yuml").split(' ')
+private val GREEK_UPPER = "Alpha Beta Gamma Delta Epsilon Zeta Eta Theta Iota Kappa Lambda Mu Nu Xi Omicron Pi Rho".split(' ')
+private val GREEK_UPPER_2 = "Sigma Tau Upsilon Phi Chi Psi Omega".split(' ')
+private val GREEK_LOWER = "alpha beta gamma delta epsilon zeta eta theta iota kappa lambda mu nu xi omicron pi rho sigmaf sigma tau upsilon phi chi psi omega".split(' ')
+
+private val NAMED: Map<String, Int> = buildMap {
+ put("quot", 34); put("amp", 38); put("apos", 39); put("lt", 60); put("gt", 62)
+ LATIN1.forEachIndexed { i, n -> put(n, 0xA0 + i) }
+ GREEK_UPPER.forEachIndexed { i, n -> put(n, 913 + i) }
+ GREEK_UPPER_2.forEachIndexed { i, n -> put(n, 931 + i) }
+ GREEK_LOWER.forEachIndexed { i, n -> put(n, 945 + i) }
+ putAll(mapOf(
+ "OElig" to 338, "oelig" to 339, "Scaron" to 352, "scaron" to 353, "Yuml" to 376, "fnof" to 402, "circ" to 710, "tilde" to 732,
+ "ensp" to 8194, "emsp" to 8195, "thinsp" to 8201, "zwnj" to 8204, "zwj" to 8205, "lrm" to 8206, "rlm" to 8207,
+ "ndash" to 8211, "mdash" to 8212, "lsquo" to 8216, "rsquo" to 8217, "sbquo" to 8218, "ldquo" to 8220, "rdquo" to 8221,
+ "bdquo" to 8222, "dagger" to 8224, "Dagger" to 8225, "bull" to 8226, "hellip" to 8230, "permil" to 8240, "prime" to 8242,
+ "Prime" to 8243, "lsaquo" to 8249, "rsaquo" to 8250, "oline" to 8254, "frasl" to 8260, "euro" to 8364, "trade" to 8482,
+ "larr" to 8592, "uarr" to 8593, "rarr" to 8594, "darr" to 8595, "harr" to 8596, "minus" to 8722, "infin" to 8734,
+ "asymp" to 8776, "ne" to 8800, "equiv" to 8801, "le" to 8804, "ge" to 8805, "radic" to 8730, "sum" to 8721, "part" to 8706,
+ "spades" to 9824, "clubs" to 9827, "hearts" to 9829, "diams" to 9830, "loz" to 9674, "thetasym" to 977, "upsih" to 978, "piv" to 982,
+ ))
+}
diff --git a/base/api-spotify/src/main/kotlin/app/myspoti/spotify/SpotifyContent.kt b/base/api-spotify/src/main/kotlin/app/myspoti/spotify/SpotifyContent.kt
index a24f29bc..b8ede51c 100644
--- a/base/api-spotify/src/main/kotlin/app/myspoti/spotify/SpotifyContent.kt
+++ b/base/api-spotify/src/main/kotlin/app/myspoti/spotify/SpotifyContent.kt
@@ -156,7 +156,7 @@ class SpotifyCatalog(private val gql: Gql, private val http: app.myspoti.spotify
?: throw GqlException("queryArtistOverview", "bad artist")
return app.myspoti.api.ArtistPage(
artist = base,
- biography = a.str("profile.biography.text")?.let { stripTags(it) },
+ biography = a.str("profile.biography.text")?.let { stripHtml(it) },
headerImages = images(a.list("headerImage.data.sources")),
topTracks = a.list("discography.topTracks.items").mapNotNull { row ->
track(row.at("track"), row.str("uid"))?.let { app.myspoti.api.TopTrack(it, row.long("track.playcount")) }
@@ -167,8 +167,6 @@ class SpotifyCatalog(private val gql: Gql, private val http: app.myspoti.spotify
)
}
- private fun stripTags(html: String) = html.replace(Regex("<[^>]+>"), "").replace("&amp;", "&").replace("&quot;", "\"").replace("&#39;", "'").trim()
-
override suspend fun discography(uri: Uri, offset: Int, limit: Int): Page<Album> {
val all = gql.query("queryArtistDiscographyAll", vars("uri" to uri, "offset" to offset, "limit" to limit, "order" to "DATE_DESC"))
.entity("data.artistUnion", "queryArtistDiscographyAll").at("discography.all")
diff --git a/base/api-spotify/src/test/kotlin/app/myspoti/spotify/HtmlTextTest.kt b/base/api-spotify/src/test/kotlin/app/myspoti/spotify/HtmlTextTest.kt
new file mode 100644
index 00000000..393f490f
--- /dev/null
+++ b/base/api-spotify/src/test/kotlin/app/myspoti/spotify/HtmlTextTest.kt
@@ -0,0 +1,41 @@
+package app.myspoti.spotify
+
+import org.junit.jupiter.api.Assertions.assertEquals
+import org.junit.jupiter.api.Test
+
+/** Biographies and audiobook descriptions arrive as small HTML snippets. */
+class HtmlTextTest {
+ @Test fun `the basic entities`() {
+ assertEquals("Tom & Jerry say \"hi\" it's <ok>", decodeHtmlEntities("Tom &amp; Jerry say &quot;hi&quot; it&apos;s &lt;ok&gt;"))
+ }
+
+ @Test fun `decimal and hex entities`() {
+ assertEquals("it's ’ 🎵 🎵", decodeHtmlEntities("it&#39;s &#8217; &#x1F3B5; &#127925;"))
+ assertEquals("A", decodeHtmlEntities("&#x41;"))
+ }
+
+ @Test fun `named entities of the Latin-1 block, Greek and punctuation`() {
+ assertEquals("café ñ ÿ À ©", decodeHtmlEntities("caf&eacute; &ntilde; &yuml; &Agrave; &copy;"))
+ assertEquals("a–b — … “q” € Ωω", decodeHtmlEntities("a&ndash;b &mdash; &hellip; &ldquo;q&rdquo; &euro; &Omega;&omega;"))
+ assertEquals(" ", decodeHtmlEntities("&nbsp;"))
+ }
+
+ @Test fun `decoded once, unknown or invalid ones left as written`() {
+ assertEquals("&lt; and &#38;", decodeHtmlEntities("&amp;lt; and &amp;#38;"))
+ assertEquals("&bogus; &#0; &#xD800; &#1114112; AT&T; &", decodeHtmlEntities("&bogus; &#0; &#xD800; &#1114112; AT&T; &"))
+ assertEquals("no entity", decodeHtmlEntities("no entity"))
+ }
+
+ @Test fun `the table lines up with Latin-1`() {
+ assertEquals(" ¡¢", decodeHtmlEntities("&nbsp;&iexcl;&cent;"))
+ assertEquals("ÿ", decodeHtmlEntities("&yuml;"))
+ assertEquals("÷", decodeHtmlEntities("&divide;"))
+ assertEquals("ςσ", decodeHtmlEntities("&sigmaf;&sigma;"))
+ assertEquals("Σ", decodeHtmlEntities("&Sigma;"))
+ }
+
+ @Test fun `tags go, line breaks stay`() {
+ assertEquals("Born in Paris & raised in <Lyon>.\n\nSecond line", stripHtml("<p>Born in <a href=\"spotify:artist:x\">Paris</a> &amp; raised in &lt;Lyon&gt;.</p><br/>\n<br>Second line"))
+ assertEquals("Tyler, The Creator", stripHtml(" <b>Tyler, The Creator</b> "))
+ }
+}
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 40378a10..31826b15 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
@@ -500,7 +500,7 @@ class Api constructor(
publisher = head?.publisher?.takeIf { it.isNotBlank() }
?: book?.authors?.joinToString(", ").orEmpty(),
coverUri = cover,
- description = head?.description ?: book?.description.orEmpty(),
+ description = head?.description ?: book?.description?.let { app.myspoti.spotify.stripHtml(it) }.orEmpty(),
rating = head?.rating ?: 0.0,
saved = head?.saved == true,
authors = book?.authors.orEmpty(),
diff --git a/base/app/src/main/java/com/music/spotui/ui/components/ArtistChooser.kt b/base/app/src/main/java/com/music/spotui/ui/components/ArtistChooser.kt
index 0c7a3e89..c3f7db6e 100644
--- a/base/app/src/main/java/com/music/spotui/ui/components/ArtistChooser.kt
+++ b/base/app/src/main/java/com/music/spotui/ui/components/ArtistChooser.kt
@@ -22,6 +22,8 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.produceState
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.rememberUpdatedState
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
@@ -29,7 +31,11 @@ import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.stringResource
+import androidx.compose.ui.text.AnnotatedString
+import androidx.compose.ui.text.LinkAnnotation
+import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.font.FontWeight
+import androidx.compose.ui.text.withLink
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
@@ -126,3 +132,40 @@ fun ArtistChooserHost(navController: NavHostController) {
}
}
}
+
+/**
+ * The artist line of a song ([line], as shown) with each artist its own tap target, which calls
+ * [open] with that artist: the song's real artists (name and uri, see [ArtistChooser.artistsOf]),
+ * never the line cut at its commas ("Tyler, The Creator" is one artist). Null until they are
+ * known, or when they are not what the line shows (a crossfade's outgoing song, an extension's
+ * credit): the line is then a plain text, opened as before.
+ */
+@Composable
+fun rememberArtistCredit(trackId: String, line: String, open: (ArtistRef) -> Unit): AnnotatedString? {
+ val artists by produceState<List<ArtistRef>?>(null, trackId) {
+ value = if (trackId.isBlank()) null else ArtistChooser.artistsOf(trackId, "").takeIf { list -> list.isNotEmpty() && list.all { it.uri.isNotBlank() } }
+ }
+ val onOpen by rememberUpdatedState(open)
+ return remember(artists, line) {
+ val list = artists ?: return@remember null
+ // Each name, in order, with only separators between them.
+ var at = 0
+ val starts = IntArray(list.size)
+ for ((i, a) in list.withIndex()) {
+ val found = line.indexOf(a.name, at)
+ if (found < 0 || line.substring(at, found).any { it != ',' && it != '&' && it != '/' && !it.isWhitespace() }) return@remember null
+ starts[i] = found
+ at = found + a.name.length
+ }
+ if (line.substring(at).any { it != ',' && it != '&' && it != '/' && !it.isWhitespace() }) return@remember null
+ buildAnnotatedString {
+ var last = 0
+ for ((i, a) in list.withIndex()) {
+ append(line.substring(last, starts[i]))
+ withLink(LinkAnnotation.Clickable("artist", null) { onOpen(a) }) { append(a.name) }
+ last = starts[i] + a.name.length
+ }
+ append(line.substring(last))
+ }
+ }
+}
diff --git a/base/app/src/main/java/com/music/spotui/ui/components/LinkedText.kt b/base/app/src/main/java/com/music/spotui/ui/components/LinkedText.kt
new file mode 100644
index 00000000..42852f50
--- /dev/null
+++ b/base/app/src/main/java/com/music/spotui/ui/components/LinkedText.kt
@@ -0,0 +1,77 @@
+package com.music.spotui.ui.components
+
+import android.content.Intent
+import android.net.Uri
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.remember
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.platform.LocalContext
+import androidx.compose.ui.text.AnnotatedString
+import androidx.compose.ui.text.LinkAnnotation
+import androidx.compose.ui.text.SpanStyle
+import androidx.compose.ui.text.TextLinkStyles
+import androidx.compose.ui.text.buildAnnotatedString
+import androidx.compose.ui.text.style.TextDecoration
+import androidx.compose.ui.text.withLink
+import com.music.spotui.data.api.InviteLinks
+
+/**
+ * Descriptions (show, episode, audiobook, artist bio, playlist) with their links made tappable.
+ * Same text, same layout: the [AnnotatedString] goes to the page's own `Text`, so lines, "more"
+ * toggles and truncation stay as they were. A Spotify link (open.spotify.com/…, spotify:…) to a
+ * playlist, album, artist or show opens its page in the app; any other link opens in the browser.
+ */
+private val LINK = Regex(
+ """(?:https?://|www\.)[^\s<>"']+|spotify:(?:playlist|album|artist|show|track|episode):[A-Za-z0-9]{22}""",
+ RegexOption.IGNORE_CASE,
+)
+private val PAGE_LINK = Regex(
+ """(?:open|www|play)\.spotify\.com/(?:intl-[a-z-]+/)?(playlist|album|artist|show)/([A-Za-z0-9]{22})""",
+ RegexOption.IGNORE_CASE,
+)
+private val URI = Regex("""spotify:(playlist|album|artist|show|track|episode):([A-Za-z0-9]{22})""", RegexOption.IGNORE_CASE)
+
+/** [text] with every link in it tappable, in [linkColor] and underlined. */
+@Composable
+fun rememberLinkedText(text: String, linkColor: Color): AnnotatedString {
+ val context = LocalContext.current
+ return remember(text, linkColor) {
+ if (!LINK.containsMatchIn(text)) return@remember AnnotatedString(text)
+ val styles = TextLinkStyles(SpanStyle(color = linkColor, textDecoration = TextDecoration.Underline))
+ buildAnnotatedString {
+ var last = 0
+ for (hit in LINK.findAll(text)) {
+ // Sentence punctuation after a link is not part of it.
+ val link = hit.value.trimEnd('.', ',', ';', ':', '!', '?', ')', ']')
+ append(text.substring(last, hit.range.first))
+ withLink(LinkAnnotation.Clickable("link", styles) { openDescriptionLink(context, link) }) { append(link) }
+ last = hit.range.first + link.length
+ }
+ append(text.substring(last))
+ }
+ }
+}
+
+/** A tapped link: a Spotify list / artist / show page or invitation in the app, anything else in the browser. */
+fun openDescriptionLink(context: android.content.Context, link: String) {
+ val spotify = link.contains("spotify.com", ignoreCase = true) || link.contains("spotify.link", ignoreCase = true) || link.startsWith("spotify:", ignoreCase = true)
+ if (spotify) {
+ // A collaborative-playlist invitation, a Blend invitation or a short link.
+ if (link.startsWith("http", ignoreCase = true) && InviteLinks.handle(link)) return
+ val uri = URI.find(link)?.let { "spotify:${it.groupValues[1].lowercase()}:${it.groupValues[2]}" }
+ ?: PAGE_LINK.find(link)?.let { "spotify:${it.groupValues[1].lowercase()}:${it.groupValues[2]}" }
+ if (uri != null && uri.substringAfter(':').substringBefore(':') in setOf("playlist", "album", "artist", "show")) {
+ InviteLinks.page.value = uri
+ return
+ }
+ }
+ // A song or an episode (spotify: uri) has no page here: its web address opens instead.
+ val web = when {
+ link.startsWith("spotify:", ignoreCase = true) -> URI.find(link)?.let { "https://open.spotify.com/${it.groupValues[1].lowercase()}/${it.groupValues[2]}" }
+ link.startsWith("www.", ignoreCase = true) -> "https://$link"
+ else -> link
+ } ?: return
+ runCatching {
+ context.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(web)).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK))
+ }
+}
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 40e8e854..fb40ac29 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
@@ -360,7 +360,7 @@ fun ImmersiveEpisodeScreen(navController: NavController, episodeId: String, fall
Modifier.fillMaxWidth().animateContentSize(spring(stiffness = Spring.StiffnessMediumLow)).padding(Immersive.Gutter),
) {
Text(
- ep.description, style = Immersive.Body.copy(color = Immersive.Text.copy(alpha = 0.8f)),
+ com.music.spotui.ui.components.rememberLinkedText(ep.description, Immersive.Accent), style = Immersive.Body.copy(color = Immersive.Text.copy(alpha = 0.8f)),
maxLines = if (expanded) Int.MAX_VALUE else 4, overflow = TextOverflow.Ellipsis,
)
Text(
diff --git a/base/app/src/main/java/com/music/spotui/ui/immersive/player/ImmersivePlayer.kt b/base/app/src/main/java/com/music/spotui/ui/immersive/player/ImmersivePlayer.kt
index ef084fee..d6baa27c 100644
--- a/base/app/src/main/java/com/music/spotui/ui/immersive/player/ImmersivePlayer.kt
+++ b/base/app/src/main/java/com/music/spotui/ui/immersive/player/ImmersivePlayer.kt
@@ -480,8 +480,10 @@ private fun RowScope.PlayerCredits(
}
}
if (!state.adPlaying) {
+ // One tap per artist when the song's artists are known; the whole line otherwise.
+ val credit = com.music.spotui.ui.components.rememberArtistCredit(state.trackId, state.artist) { a -> actions.openArtistRef(a) }
Text(
- text = state.artist,
+ text = credit ?: androidx.compose.ui.text.AnnotatedString(state.artist),
style = Immersive.Title.copy(fontSize = 20.sp, lineHeight = lineH, fontWeight = FontWeight.W500),
color = tint.copy(alpha = 0.55f),
maxLines = 1,
diff --git a/base/app/src/main/java/com/music/spotui/ui/immersive/player/PlayerBridge.kt b/base/app/src/main/java/com/music/spotui/ui/immersive/player/PlayerBridge.kt
index c9e61f20..4f635adb 100644
--- a/base/app/src/main/java/com/music/spotui/ui/immersive/player/PlayerBridge.kt
+++ b/base/app/src/main/java/com/music/spotui/ui/immersive/player/PlayerBridge.kt
@@ -49,6 +49,8 @@ object ImmersiveRepeat {
data class ImmersivePlayerState(
val title: String = "",
val artist: String = "",
+ /** The Spotify id of the track behind [title] and [artist] (blank for other songs): their artists are looked up from it. */
+ val trackId: String = "",
val album: String = "",
val coverUrl: String = "",
val playing: Boolean = false,
@@ -93,6 +95,8 @@ class ImmersivePlayerActions(
val openAlbum: () -> Unit = {},
/** Opens the artist of the playing track (a choice first when there are several). */
val openArtist: () -> Unit = {},
+ /** Opens one artist of the credit line directly. */
+ val openArtistRef: (app.myspoti.api.ArtistRef) -> Unit = {},
/** Closes the player (PlayerSheet.close()). */
val close: () -> Unit = {},
)
@@ -143,6 +147,7 @@ fun rememberImmersivePlayer(navController: NavController): ImmersivePlayerBridge
val state = ImmersivePlayerState(
title = outgoing?.song?.title ?: title,
artist = outgoing?.song?.artist ?: singer,
+ trackId = com.music.spotui.ui.viewmodel.confirmedTrackIdForDisplay(np.uri, songId),
album = album,
coverUrl = app.myspoti.host.android.Covers.large(cover),
playing = playing,
@@ -215,6 +220,7 @@ fun rememberImmersivePlayer(navController: NavController): ImmersivePlayerBridge
openArtist = {
vm.goToArtist(SongPlayer.currentTrackId, vm.currentSongSinger.value) { route -> navController.navigate(route) }
},
+ openArtistRef = { a -> navController.navigate(com.music.spotui.ui.components.ArtistChooser.routeOf(a)) },
close = { PlayerSheet.close() },
)
}
diff --git a/base/app/src/main/java/com/music/spotui/ui/immersive/screens/ImmersiveContextScreen.kt b/base/app/src/main/java/com/music/spotui/ui/immersive/screens/ImmersiveContextScreen.kt
index 415cac92..0641ace8 100644
--- a/base/app/src/main/java/com/music/spotui/ui/immersive/screens/ImmersiveContextScreen.kt
+++ b/base/app/src/main/java/com/music/spotui/ui/immersive/screens/ImmersiveContextScreen.kt
@@ -672,7 +672,7 @@ private fun ContextHeader(
if (p.description.isNotBlank()) {
Spacer(Modifier.height(6.dp))
Text(
- text = p.description,
+ text = com.music.spotui.ui.components.rememberLinkedText(p.description, Immersive.Accent),
style = Immersive.Subhead,
textAlign = TextAlign.Center,
maxLines = 3,
diff --git a/base/app/src/main/java/com/music/spotui/ui/immersive/screens/ImmersiveContextScreenParts.kt b/base/app/src/main/java/com/music/spotui/ui/immersive/screens/ImmersiveContextScreenParts.kt
index 3dff1f77..736aea80 100644
--- a/base/app/src/main/java/com/music/spotui/ui/immersive/screens/ImmersiveContextScreenParts.kt
+++ b/base/app/src/main/java/com/music/spotui/ui/immersive/screens/ImmersiveContextScreenParts.kt
@@ -159,7 +159,7 @@ internal fun ImmersiveAboutText(
var clipped by remember(text) { mutableStateOf(false) }
Column(modifier) {
Text(
- text = text,
+ text = com.music.spotui.ui.components.rememberLinkedText(text, Immersive.Accent),
style = Immersive.Body.copy(color = Immersive.TextSecondary),
maxLines = if (expanded) Int.MAX_VALUE else maxLines,
overflow = TextOverflow.Ellipsis,
diff --git a/base/app/src/main/java/com/music/spotui/ui/screens/ArtistScreen.kt b/base/app/src/main/java/com/music/spotui/ui/screens/ArtistScreen.kt
index 0e24435b..350268c3 100644
--- a/base/app/src/main/java/com/music/spotui/ui/screens/ArtistScreen.kt
+++ b/base/app/src/main/java/com/music/spotui/ui/screens/ArtistScreen.kt
@@ -4,6 +4,7 @@ import com.music.spotui.ui.components.widePressable
import com.music.spotui.ui.components.wideClickable
import com.music.spotui.ui.theme.tone
import com.music.spotui.ui.theme.AppText
+import com.music.spotui.ui.theme.AppAccent
import com.music.spotui.ui.theme.AppMuted
import com.music.spotui.ui.components.SkeletonKind
@@ -499,7 +500,7 @@ private fun ArtistOverviewContent(
)
}
Text(
- text = overview.biography.orEmpty(),
+ text = com.music.spotui.ui.components.rememberLinkedText(overview.biography.orEmpty(), AppAccent),
color = AppMuted,
fontSize = 13.sp,
modifier = Modifier.padding(14.dp, 4.dp, 14.dp, 16.dp),
diff --git a/base/app/src/main/java/com/music/spotui/ui/screens/ContextScreen.kt b/base/app/src/main/java/com/music/spotui/ui/screens/ContextScreen.kt
index 2526f36f..e0285bfc 100644
--- a/base/app/src/main/java/com/music/spotui/ui/screens/ContextScreen.kt
+++ b/base/app/src/main/java/com/music/spotui/ui/screens/ContextScreen.kt
@@ -761,7 +761,7 @@ private fun ContextContent(navController: NavController, vm: ContextViewModel, p
com.music.spotui.ui.components.FitText(p.name, fontSize = 26.sp, minSize = 18.sp, fontWeight = FontWeight.Bold, maxLines = 2)
if (p.description.isNotBlank()) {
Spacer(Modifier.height(8.dp))
- Text(p.description, color = AppText.copy(alpha = 0.7f), fontSize = 14.sp, maxLines = 3, overflow = TextOverflow.Ellipsis)
+ Text(com.music.spotui.ui.components.rememberLinkedText(p.description, com.music.spotui.ui.theme.AppAccent), color = AppText.copy(alpha = 0.7f), fontSize = 14.sp, maxLines = 3, overflow = TextOverflow.Ellipsis)
}
val crew = vm.members.value
if (crew.size > 1) {
diff --git a/base/app/src/main/java/com/music/spotui/ui/screens/EpisodeScreen.kt b/base/app/src/main/java/com/music/spotui/ui/screens/EpisodeScreen.kt
index 0d2e0aa2..a7f807ac 100644
--- a/base/app/src/main/java/com/music/spotui/ui/screens/EpisodeScreen.kt
+++ b/base/app/src/main/java/com/music/spotui/ui/screens/EpisodeScreen.kt
@@ -264,7 +264,7 @@ fun EpisodeScreen(navController: NavController, episodeId: String, fallbackName:
if (ep.description.isNotBlank()) item {
Column(Modifier.fillMaxWidth().animateContentSize(androidx.compose.animation.core.tween(250)).padding(16.dp)) {
Text(
- text = ep.description,
+ text = com.music.spotui.ui.components.rememberLinkedText(ep.description, AppAccent),
color = AppText.copy(alpha = 0.78f),
fontSize = 14.sp,
maxLines = if (expanded) Int.MAX_VALUE else 4,
diff --git a/base/app/src/main/java/com/music/spotui/ui/screens/PlayerScreen.kt b/base/app/src/main/java/com/music/spotui/ui/screens/PlayerScreen.kt
index 63e256c6..d682d659 100644
--- a/base/app/src/main/java/com/music/spotui/ui/screens/PlayerScreen.kt
+++ b/base/app/src/main/java/com/music/spotui/ui/screens/PlayerScreen.kt
@@ -641,6 +641,10 @@ fun PlayerScreen(navController: NavController) {
navController.navigate(route)
}
},
+ // One tap per artist: each name opens that artist, not the choice.
+ artistCredit = com.music.spotui.ui.components.rememberArtistCredit(displayedTrackId, outgoing?.artist ?: songSinger) { a ->
+ navController.navigate(com.music.spotui.ui.components.ArtistChooser.routeOf(a))
+ },
)
// Seek bar: follows the finger while dragging, seeks once on release.
@@ -1065,6 +1069,8 @@ fun PlayerInfo(
/** The track behind the +: with it, the + opens "Saved in" once the track is saved. */
likeSong: (() -> SongsModel)? = null,
onArtistClick: (() -> Unit)? = null,
+ /** The artist line with each artist its own tap target (rememberArtistCredit), when known. */
+ artistCredit: androidx.compose.ui.text.AnnotatedString? = null,
onTitleClick: (() -> Unit)? = null,
/** T4: an ad break is on: what the caller passes is the song from before it, not what plays. */
adPlaying: Boolean = false,
@@ -1113,7 +1119,7 @@ fun PlayerInfo(
Spacer(modifier = Modifier.width(6.dp))
}
Text(
- text = songSinger,
+ text = artistCredit ?: androidx.compose.ui.text.AnnotatedString(songSinger),
color = Color.White.copy(alpha = 0.7f),
fontSize = 16.sp,
maxLines = 1,
diff --git a/base/app/src/main/java/com/music/spotui/ui/screens/ShowScreen.kt b/base/app/src/main/java/com/music/spotui/ui/screens/ShowScreen.kt
index 23f276cc..fe4a264f 100644
--- a/base/app/src/main/java/com/music/spotui/ui/screens/ShowScreen.kt
+++ b/base/app/src/main/java/com/music/spotui/ui/screens/ShowScreen.kt
@@ -351,7 +351,7 @@ private fun About(show: PodcastModel?) {
val narrators = show?.narrators.orEmpty().joinToString(", ")
Column(Modifier.fillMaxWidth().padding(16.dp)) {
Text(
- text = show?.description.orEmpty(),
+ text = com.music.spotui.ui.components.rememberLinkedText(show?.description.orEmpty(), AppAccent),
color = AppText.copy(alpha = 0.75f),
fontSize = 14.sp,
)