Native Android client for Spotify, built with Jetpack Compose
Kotlin ad-freeadblockandroidjetpack-composekotlinlyricsmusic-playermusic-videomyspotispotifyspotify-adblockerspotify-clientspotify-connectspotui
Lyrics: a romanization reads apart from a translation, in italics with the translation a little below it, and turns on from the lyrics themselves in both looks, a Romanize chip by the Translate one in Classic and a round toggle by the translation's in Immersive, offered when the lyrics have romanizations
Illumye1b23c95bca53
diff --git a/base/app/src/main/java/com/music/spotui/ui/immersive/lyrics/ImmersiveLyricsPanel.kt b/base/app/src/main/java/com/music/spotui/ui/immersive/lyrics/ImmersiveLyricsPanel.ktindex 39aea1cf..5ec2ff3b 100644--- a/base/app/src/main/java/com/music/spotui/ui/immersive/lyrics/ImmersiveLyricsPanel.kt+++ b/base/app/src/main/java/com/music/spotui/ui/immersive/lyrics/ImmersiveLyricsPanel.kt@@ -13,6 +13,7 @@package com.music.spotui.ui.immersive.lyricsimport androidx.compose.material3.CircularProgressIndicator+import androidx.compose.material.icons.rounded.Abcimport androidx.compose.material.icons.rounded.Translateimport com.music.spotui.ui.components.secondaryClickimport android.os.Build@@ -87,6 +88,7 @@ import androidx.compose.ui.platform.LocalDensityimport androidx.compose.ui.res.stringResourceimport androidx.compose.ui.semantics.contentDescriptionimport androidx.compose.ui.semantics.semantics+import androidx.compose.ui.graphics.vector.ImageVectorimport androidx.compose.ui.text.TextLayoutResultimport androidx.compose.ui.text.TextStyleimport androidx.compose.ui.text.style.TextAlign@@ -198,22 +200,37 @@ fun ImmersiveLyricsPanel(modifier: Modifier = Modifier, contentPadding: PaddingVtranslations = current.translations.takeIf { current.showTranslation },romanizing = LyricsRomanizationPref.on && current.lyrics.hasRomanization,)- // The Classic screen's translation, with its language setting and its service: the- // lyrics are only sent when it is tapped. Not offered for a song already in that language.+ // The romanization, when the lyrics have one, then the Classic screen's translation,+ // with its language setting and its service: the lyrics are only sent when it is+ // tapped. Not offered for a song already in that language.val target = com.music.spotui.ui.components.readerLanguage()- if (!selecting && !LyricsViewModel.sameLanguage(current.sourceLanguage, target)) {+ val canRomanize = current.lyrics.hasRomanization+ val canTranslate = !LyricsViewModel.sameLanguage(current.sourceLanguage, target)+ if (!selecting && (canRomanize || canTranslate)) {val layoutDirection = LocalLayoutDirection.current- TranslateToggle(- on = current.showTranslation,- loading = current.translating && current.translationRequested,- onClick = { vm.toggleTranslation(target) },+ Row(+ horizontalArrangement = Arrangement.spacedBy(8.dp),modifier = Modifier.align(Alignment.TopEnd).padding(top = contentPadding.calculateTopPadding(),end = Immersive.Gutter + contentPadding.calculateEndPadding(layoutDirection),),- )+ ) {+ if (canRomanize) LyricsToggle(+ icon = Icons.Rounded.Abc,+ description = stringResource(R.string.lyrics_romanize),+ on = LyricsRomanizationPref.on,+ onClick = { LyricsRomanizationPref.set(context, !LyricsRomanizationPref.on) },+ )+ if (canTranslate) LyricsToggle(+ icon = Icons.Rounded.Translate,+ description = stringResource(R.string.lyrics_fullscreen_chip_label_translate),+ on = current.showTranslation,+ loading = current.translating && current.translationRequested,+ onClick = { vm.toggleTranslation(target) },+ )+ }}if (selecting) ShareBar(canShare = picked != null,@@ -227,9 +244,16 @@ fun ImmersiveLyricsPanel(modifier: Modifier = Modifier, contentPadding: PaddingV}}-/** A round toggle over the lyrics, lit white while the translation is showing; a spinner while it is fetched. */+/** A round toggle over the lyrics, lit white while what it shows is on; a spinner while that is fetched. */@Composable-private fun TranslateToggle(on: Boolean, loading: Boolean, onClick: () -> Unit, modifier: Modifier = Modifier) {+private fun LyricsToggle(+ icon: ImageVector,+ description: String,+ on: Boolean,+ onClick: () -> Unit,+ modifier: Modifier = Modifier,+ loading: Boolean = false,+) {Box(contentAlignment = Alignment.Center,modifier = modifier@@ -242,8 +266,8 @@ private fun TranslateToggle(on: Boolean, loading: Boolean, onClick: () -> Unit,CircularProgressIndicator(color = Color.White, strokeWidth = 2.dp, modifier = Modifier.size(18.dp))} else {Icon(- Icons.Rounded.Translate,- contentDescription = stringResource(R.string.lyrics_fullscreen_chip_label_translate),+ icon,+ contentDescription = description,tint = if (on) Color.Black else Color.White,modifier = Modifier.size(20.dp),)@@ -801,7 +825,9 @@ private fun PanelRow()}// Under the words, smaller and dimmer, and they take the row's blur and brightness with- // them: the backing vocals, then the romanization, then the translation.+ // them: the backing vocals, then the romanization, then the translation. The romanization+ // in italics and the translation a little apart: one says how the line sounds, the other+ // what it means.val romanized = row.romanization.takeIf { romanizing }if (row.background != null) {PanelBackground(@@ -813,9 +839,9 @@ private fun PanelRow(if (romanized != null) {Text(text = romanized,- style = secondaryStyle(TRANSLATION_STYLE, lane),+ style = secondaryStyle(ROMANIZATION_STYLE, lane),color = Immersive.TextSecondary,- modifier = Modifier.fillMaxWidth().padding(start = GLOW_ROOM, end = GLOW_ROOM, bottom = if (translation != null) 4.dp else GLOW_ROOM),+ modifier = Modifier.fillMaxWidth().padding(start = GLOW_ROOM, end = GLOW_ROOM, bottom = if (translation != null) 10.dp else GLOW_ROOM),)}if (translation != null) {@@ -853,6 +879,9 @@ private fun ShareBar(canShare: Boolean, onCancel: () -> Unit, onShare: () -> Uni/** A translated line: well below the lyric's 30 sp, so the sung words stay the focus. */private val TRANSLATION_STYLE = Immersive.Lyric.copy(fontSize = 18.sp, lineHeight = 24.sp, fontWeight = androidx.compose.ui.text.font.FontWeight.Medium)+/** A romanized line: a translation's size, in italics as a transliteration is set, so the two never read alike. */+private val ROMANIZATION_STYLE = TRANSLATION_STYLE.copy(fontStyle = androidx.compose.ui.text.font.FontStyle.Italic)+/** The backing vocals: a little smaller than a translation, and drawn dimmer still (see [PanelBackground]). */private val BACKGROUND_STYLE = Immersive.Lyric.copy(fontSize = 20.sp, lineHeight = 26.sp, fontWeight = androidx.compose.ui.text.font.FontWeight.Medium)private const val BACKGROUND_ALPHA = 0.7fdiff --git a/base/app/src/main/java/com/music/spotui/ui/screens/LyricsScreen.kt b/base/app/src/main/java/com/music/spotui/ui/screens/LyricsScreen.ktindex ac6db9ef..198b332c 100644--- a/base/app/src/main/java/com/music/spotui/ui/screens/LyricsScreen.kt+++ b/base/app/src/main/java/com/music/spotui/ui/screens/LyricsScreen.kt@@ -57,6 +57,7 @@ import androidx.compose.material.icons.filled.KeyboardArrowDownimport androidx.compose.material.icons.filled.MoreVertimport androidx.compose.material.icons.filled.OpenInFullimport androidx.compose.material.icons.outlined.Lightbulb+import androidx.compose.material.icons.rounded.Abcimport androidx.compose.material3.CircularProgressIndicatorimport androidx.compose.material3.DropdownMenuimport androidx.compose.material3.DropdownMenuItem@@ -98,9 +99,12 @@ import androidx.compose.ui.input.pointer.pointerInputimport androidx.compose.ui.layout.onSizeChangedimport androidx.compose.ui.platform.LocalContextimport androidx.compose.ui.platform.LocalDensity+import androidx.compose.ui.graphics.painter.Painter+import androidx.compose.ui.graphics.vector.rememberVectorPainterimport androidx.compose.ui.res.painterResourceimport androidx.compose.ui.text.SpanStyleimport androidx.compose.ui.text.buildAnnotatedString+import androidx.compose.ui.text.font.FontStyleimport androidx.compose.ui.text.font.FontWeightimport androidx.compose.ui.text.style.TextAlignimport androidx.compose.ui.text.style.TextOverflow@@ -384,7 +388,9 @@ private fun LyricLineText()}// Under the line, smaller and dimmer: its backing vocals, the romanization, the translation.- // They take the line's colour, so they light with it.+ // They take the line's colour, so they light with it. The romanization is set in italics, as a+ // transliteration is, and the translation a little apart: one says how the line sounds, the+ // other what it means.AnimatedVisibility(visible = !line.background.isNullOrBlank(),enter = expandVertically(tween(260)) + fadeIn(tween(260)),@@ -409,6 +415,7 @@ private fun LyricLineText(color = color.copy(alpha = color.alpha * 0.7f),fontSize = 15.sp,fontWeight = FontWeight.Normal,+ fontStyle = FontStyle.Italic,textAlign = align,modifier = Modifier.fillMaxWidth().padding(top = 2.dp),)@@ -424,7 +431,7 @@ private fun LyricLineText(fontSize = 15.sp,fontWeight = FontWeight.Normal,textAlign = align,- modifier = Modifier.fillMaxWidth().padding(top = 2.dp),+ modifier = Modifier.fillMaxWidth().padding(top = if (romanization.isNullOrBlank()) 2.dp else 8.dp),)}}@@ -666,6 +673,9 @@ fun LyricsScreen(translationActive = state.showTranslation,translating = state.translating && state.translationRequested,onTranslate = { vm.toggleTranslation(targetLanguage) },+ showRomanize = l.hasRomanization,+ romanizationActive = LyricsRomanizationPref.on,+ onRomanize = { LyricsRomanizationPref.set(context, !LyricsRomanizationPref.on) },onShare = { shareLyrics(context, title, artist, l.lines.getOrNull(active)?.text) },modifier = Modifier.revealIn(reveal, 0.5f, 16f, span = 0.5f),)@@ -749,7 +759,7 @@ private fun LyricsMenu(}@Composable-private fun LyricsChip(label: String, icon: Int?, active: Boolean, loading: Boolean, palette: LyricsPalette, onClick: () -> Unit) {+private fun LyricsChip(label: String, icon: Painter?, active: Boolean, loading: Boolean, palette: LyricsPalette, onClick: () -> Unit) {Row(verticalAlignment = Alignment.CenterVertically,modifier = Modifier@@ -759,7 +769,7 @@ private fun LyricsChip(label: String, icon: Int?, active: Boolean, loading: Bool.padding(horizontal = 12.dp, vertical = 7.dp),) {if (loading) CircularProgressIndicator(color = palette.highlight, strokeWidth = 2.dp, modifier = Modifier.size(14.dp))- else if (icon != null) Icon(painterResource(icon), contentDescription = null, tint = if (active) palette.background else palette.highlight, modifier = Modifier.size(16.dp))+ else if (icon != null) Icon(icon, contentDescription = null, tint = if (active) palette.background else palette.highlight, modifier = Modifier.size(16.dp))if (loading || icon != null) Spacer(Modifier.width(6.dp))Text(label, color = if (active) palette.background else palette.highlight, fontSize = 13.sp, fontWeight = FontWeight.Bold)}@@ -774,7 +784,7 @@ private fun LyricsSelectionBar(palette: LyricsPalette, canShare: Boolean, onCancLyricsChip(stringResource(R.string.cancel), null, false, false, palette, onCancel)// Nothing picked yet: the chip waits, dimmed.Box(Modifier.graphicsLayer { alpha = if (canShare) 1f else 0.4f }) {- LyricsChip(stringResource(R.string.lyrics_fullscreen_chip_label_share), R.drawable.ic_share, true, false, palette) { if (canShare) onShare() }+ LyricsChip(stringResource(R.string.lyrics_fullscreen_chip_label_share), painterResource(R.drawable.ic_share), true, false, palette) { if (canShare) onShare() }}}}@@ -788,6 +798,9 @@ private fun LyricsControls(translationActive: Boolean,translating: Boolean,onTranslate: () -> Unit,+ showRomanize: Boolean,+ romanizationActive: Boolean,+ onRomanize: () -> Unit,onShare: () -> Unit,modifier: Modifier = Modifier,) {@@ -795,8 +808,9 @@ private fun LyricsControls(val playing = com.music.spotui.di.Graph.currentSongState.playingState.valueColumn(modifier.fillMaxWidth().padding(horizontal = 24.dp).padding(bottom = 8.dp)) {Row(horizontalArrangement = Arrangement.spacedBy(8.dp), modifier = Modifier.padding(bottom = 10.dp)) {- LyricsChip(stringResource(R.string.lyrics_fullscreen_chip_label_share), R.drawable.ic_share, false, false, palette, onShare)- if (showTranslate) LyricsChip(stringResource(R.string.lyrics_fullscreen_chip_label_translate), R.drawable.ic_translate_lyrics, translationActive, translating, palette, onTranslate)+ LyricsChip(stringResource(R.string.lyrics_fullscreen_chip_label_share), painterResource(R.drawable.ic_share), false, false, palette, onShare)+ if (showTranslate) LyricsChip(stringResource(R.string.lyrics_fullscreen_chip_label_translate), painterResource(R.drawable.ic_translate_lyrics), translationActive, translating, palette, onTranslate)+ if (showRomanize) LyricsChip(stringResource(R.string.lyrics_romanize), rememberVectorPainter(Icons.Rounded.Abc), romanizationActive, false, palette, onRomanize)}LyricsSeekBar(progress = { if (durationMs > 0) (position().toFloat() / durationMs).coerceIn(0f, 1f) else 0f },diff --git a/base/app/src/main/res/values-de/myspoti_strings.xml b/base/app/src/main/res/values-de/myspoti_strings.xmlindex 37f277a1..04487b3a 100644--- a/base/app/src/main/res/values-de/myspoti_strings.xml+++ b/base/app/src/main/res/values-de/myspoti_strings.xml@@ -37,6 +37,7 @@<string name="lyrics_select_hint">Tippe auf Zeilen, um auszuwählen, was du teilen möchtest</string><string name="lyrics_select_max">Du kannst bis zu %d Zeilen teilen</string><string name="lyrics_romanization">Romanisierung anzeigen</string>+ <string name="lyrics_romanize">Romanisieren</string><string name="lyrics_other_source">Andere Quelle versuchen</string><string name="lyrics_source_shown">Wird angezeigt</string><string name="lyrics_source_words">Wort für Wort</string>diff --git a/base/app/src/main/res/values-el/myspoti_strings.xml b/base/app/src/main/res/values-el/myspoti_strings.xmlindex 75565e58..7e06ef9d 100644--- a/base/app/src/main/res/values-el/myspoti_strings.xml+++ b/base/app/src/main/res/values-el/myspoti_strings.xml@@ -37,6 +37,7 @@<string name="lyrics_select_hint">Πατήστε στίχους για να επιλέξετε τι θα μοιραστείτε</string><string name="lyrics_select_max">Μπορείτε να μοιραστείτε έως %d στίχους</string><string name="lyrics_romanization">Εμφάνιση ρωμανοποίησης</string>+ <string name="lyrics_romanize">Ρωμανοποίηση</string><string name="lyrics_other_source">Δοκιμή άλλης πηγής</string><string name="lyrics_source_shown">Εμφανίζεται τώρα</string><string name="lyrics_source_words">Λέξη προς λέξη</string>diff --git a/base/app/src/main/res/values-es/myspoti_strings.xml b/base/app/src/main/res/values-es/myspoti_strings.xmlindex 423d098e..c41affa2 100644--- a/base/app/src/main/res/values-es/myspoti_strings.xml+++ b/base/app/src/main/res/values-es/myspoti_strings.xml@@ -37,6 +37,7 @@<string name="lyrics_select_hint">Toca las líneas para elegir lo que quieres compartir</string><string name="lyrics_select_max">Puedes compartir hasta %d líneas</string><string name="lyrics_romanization">Mostrar romanización</string>+ <string name="lyrics_romanize">Romanizar</string><string name="lyrics_other_source">Probar otra fuente</string><string name="lyrics_source_shown">Se muestra ahora</string><string name="lyrics_source_words">Palabra por palabra</string>diff --git a/base/app/src/main/res/values-fr/myspoti_strings.xml b/base/app/src/main/res/values-fr/myspoti_strings.xmlindex 7c8a797a..8279adfb 100644--- a/base/app/src/main/res/values-fr/myspoti_strings.xml+++ b/base/app/src/main/res/values-fr/myspoti_strings.xml@@ -37,6 +37,7 @@<string name="lyrics_select_hint">Touchez des lignes pour choisir ce que vous partagez</string><string name="lyrics_select_max">Vous pouvez partager jusqu\'à %d lignes</string><string name="lyrics_romanization">Afficher la romanisation</string>+ <string name="lyrics_romanize">Romaniser</string><string name="lyrics_other_source">Essayer une autre source</string><string name="lyrics_source_shown">Affichée</string><string name="lyrics_source_words">Mot par mot</string>diff --git a/base/app/src/main/res/values-it/myspoti_strings.xml b/base/app/src/main/res/values-it/myspoti_strings.xmlindex c6ed3412..2c83c95d 100644--- a/base/app/src/main/res/values-it/myspoti_strings.xml+++ b/base/app/src/main/res/values-it/myspoti_strings.xml@@ -37,6 +37,7 @@<string name="lyrics_select_hint">Tocca le righe per scegliere cosa condividere</string><string name="lyrics_select_max">Puoi condividere fino a %d righe</string><string name="lyrics_romanization">Mostra la romanizzazione</string>+ <string name="lyrics_romanize">Romanizza</string><string name="lyrics_other_source">Prova un\'altra fonte</string><string name="lyrics_source_shown">In uso</string><string name="lyrics_source_words">Parola per parola</string>diff --git a/base/app/src/main/res/values-pl/myspoti_strings.xml b/base/app/src/main/res/values-pl/myspoti_strings.xmlindex 4d3f59dd..a5ba7f0c 100644--- a/base/app/src/main/res/values-pl/myspoti_strings.xml+++ b/base/app/src/main/res/values-pl/myspoti_strings.xml@@ -37,6 +37,7 @@<string name="lyrics_select_hint">Stuknij wersy, aby wybrać, co udostępnić</string><string name="lyrics_select_max">Możesz udostępnić maksymalnie %d wersów</string><string name="lyrics_romanization">Pokaż romanizację</string>+ <string name="lyrics_romanize">Romanizacja</string><string name="lyrics_other_source">Spróbuj innego źródła</string><string name="lyrics_source_shown">Wyświetlane teraz</string><string name="lyrics_source_words">Słowo po słowie</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.xmlindex afdcbd9d..e3b345ca 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@@ -36,6 +36,7 @@<string name="lyrics_select_hint">Toque nas linhas para escolher o que partilhar</string><string name="lyrics_select_max">Pode partilhar até %d linhas</string><string name="lyrics_romanization">Mostrar romanização</string>+ <string name="lyrics_romanize">Romanizar</string><string name="lyrics_other_source">Tentar outra fonte</string><string name="lyrics_source_shown">Mostrada agora</string><string name="lyrics_source_words">Palavra a palavra</string>diff --git a/base/app/src/main/res/values-pt/myspoti_strings.xml b/base/app/src/main/res/values-pt/myspoti_strings.xmlindex fff57dfb..15d5bcd6 100644--- a/base/app/src/main/res/values-pt/myspoti_strings.xml+++ b/base/app/src/main/res/values-pt/myspoti_strings.xml@@ -37,6 +37,7 @@<string name="lyrics_select_hint">Toque nas linhas para escolher o que compartilhar</string><string name="lyrics_select_max">Você pode compartilhar até %d linhas</string><string name="lyrics_romanization">Mostrar romanização</string>+ <string name="lyrics_romanize">Romanizar</string><string name="lyrics_other_source">Tentar outra fonte</string><string name="lyrics_source_shown">Mostrada agora</string><string name="lyrics_source_words">Palavra por palavra</string>diff --git a/base/app/src/main/res/values-ru/myspoti_strings.xml b/base/app/src/main/res/values-ru/myspoti_strings.xmlindex 27362f09..d987b20c 100644--- a/base/app/src/main/res/values-ru/myspoti_strings.xml+++ b/base/app/src/main/res/values-ru/myspoti_strings.xml@@ -37,6 +37,7 @@<string name="lyrics_select_hint">Нажимайте на строки, чтобы выбрать, чем поделиться</string><string name="lyrics_select_max">Можно поделиться не более чем %d строками</string><string name="lyrics_romanization">Показать романизацию</string>+ <string name="lyrics_romanize">Романизация</string><string name="lyrics_other_source">Попробовать другой источник</string><string name="lyrics_source_shown">Показан сейчас</string><string name="lyrics_source_words">По словам</string>diff --git a/base/app/src/main/res/values-zh/myspoti_strings.xml b/base/app/src/main/res/values-zh/myspoti_strings.xmlindex 36fcdb96..0e58758c 100644--- a/base/app/src/main/res/values-zh/myspoti_strings.xml+++ b/base/app/src/main/res/values-zh/myspoti_strings.xml@@ -37,6 +37,7 @@<string name="lyrics_select_hint">点按歌词行以选择要分享的内容</string><string name="lyrics_select_max">最多可分享 %d 行</string><string name="lyrics_romanization">显示罗马音</string>+ <string name="lyrics_romanize">罗马音</string><string name="lyrics_other_source">尝试其他来源</string><string name="lyrics_source_shown">当前使用</string><string name="lyrics_source_words">逐字同步</string>diff --git a/base/app/src/main/res/values/myspoti_strings.xml b/base/app/src/main/res/values/myspoti_strings.xmlindex 2c2fce75..754fc723 100644--- a/base/app/src/main/res/values/myspoti_strings.xml+++ b/base/app/src/main/res/values/myspoti_strings.xml@@ -37,6 +37,7 @@<string name="lyrics_select_hint">Tap lines to pick what to share</string><string name="lyrics_select_max">You can share up to %d lines</string><string name="lyrics_romanization">Show romanization</string>+ <string name="lyrics_romanize">Romanize</string><string name="lyrics_other_source">Try another source</string><string name="lyrics_source_shown">Shown now</string><string name="lyrics_source_words">Word by word</string>