Skip to content

Native Android client for Spotify, built with Jetpack Compose

Merge branch 'refs/heads/feat/source-pipelines-next' into claude/discord-messages-review-72e44d

kota-zo3a3fc84f34b5
diff --cc base/app/src/main/java/com/music/spotui/di/SongPlayer.kt
index 99c204b0,754371cc..26336039
--- a/base/app/src/main/java/com/music/spotui/di/SongPlayer.kt
+++ b/base/app/src/main/java/com/music/spotui/di/SongPlayer.kt
@@@ -1053,9 -1073,10 +1096,10 @@@ object SongPlayer
if (ctx != null) {
val sent = order?.takeIf { ctx == contextUri }
playedOrder = ctx to sent
- if (com.music.spotui.ui.screens.SmartShuffle.on.value != ctx) { plainOrder = ctx to sent; smartPlayed = null }
+ if (com.music.spotui.ui.screens.SmartShuffle.on.value != ctx) { plainOrder = ctx to AppShuffle.unshuffled(ctx, sent); smartPlayed = null }
else if (sent != null) smartPlayed = ctx
}
+ playedByHand = itemUri
markPending(if (episodeId != null) "" else trackId, itemUri)
transport { isLatest ->
playChecked(itemUri, isLatest) {
diff --cc base/app/src/main/java/com/music/spotui/ui/immersive/lyrics/ImmersiveLyricsPanel.kt
index 66de1617,2d35dac0..39aea1cf
--- 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
@@@ -12,6 -12,6 +12,8 @@@
*/
package com.music.spotui.ui.immersive.lyrics
++import androidx.compose.material3.CircularProgressIndicator
++import androidx.compose.material.icons.rounded.Translate
import com.music.spotui.ui.components.secondaryClick
import android.os.Build
import androidx.compose.animation.animateColorAsState
@@@ -180,28 -188,19 +190,36 @@@ fun ImmersiveLyricsPanel(modifier: Modi
is LyricsViewModel.State.Loaded -> {
// A new track, or new lyrics for it, starts the list over: its scroll position and
// handover state belong to the lines they were made for.
- val target = com.music.spotui.ui.components.readerLanguage()
- Box(modifier) {
- key(trackKey, System.identityHashCode(current.lyrics)) {
+ key(trackKey, System.identityHashCode(current.lyrics)) {
+ Box(modifier) {
+ // The translation the song options sheet turned on, line for line with the source's.
LyricsList(
- current.lyrics, trackKey, Modifier.fillMaxSize(), contentPadding,
- translations = if (current.showTranslation) current.translations else null,
+ current.lyrics, trackKey, Modifier.fillMaxSize(), contentPadding, vm,
+ translations = 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.
- if (!LyricsViewModel.sameLanguage(current.sourceLanguage, target)) {
- val layoutDirection = LocalLayoutDirection.current
- TranslateToggle(
- on = current.showTranslation,
- loading = current.translating && current.translationRequested,
- onClick = { vm.toggleTranslation(target) },
- modifier = Modifier
- .align(Alignment.TopEnd)
- .padding(
- top = contentPadding.calculateTopPadding(),
- end = Immersive.Gutter + contentPadding.calculateEndPadding(layoutDirection),
- ),
++ // 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 layoutDirection = LocalLayoutDirection.current
++ TranslateToggle(
++ on = current.showTranslation,
++ loading = current.translating && current.translationRequested,
++ onClick = { vm.toggleTranslation(target) },
++ modifier = Modifier
++ .align(Alignment.TopEnd)
++ .padding(
++ top = contentPadding.calculateTopPadding(),
++ end = Immersive.Gutter + contentPadding.calculateEndPadding(layoutDirection),
++ ),
++ )
++ }
+ if (selecting) ShareBar(
+ canShare = picked != null,
+ onCancel = { vm.stopSelecting() },
+ onShare = { picked?.let { shareLyricLines(context, current.lyrics, it, title, artist); vm.stopSelecting() } },
+ modifier = Modifier.align(Alignment.BottomCenter).padding(contentPadding).padding(horizontal = Immersive.Gutter),
)
}
}
diff --cc base/app/src/main/java/com/music/spotui/ui/immersive/player/PlayerBridge.kt
index 8c766661,4f635adb..d83433c3
--- 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
@@@ -27,7 -27,7 +27,6 @@@ import app.myspoti.engine.
import com.music.spotui.data.entity.SongsModel
import com.music.spotui.di.SongPlayer
import com.music.spotui.ui.navigation.PlayerSheet
--import com.music.spotui.ui.navigation.albumRoute
import com.music.spotui.ui.screens.SmartShuffle
import com.music.spotui.ui.screens.nowPlayingSong
import com.music.spotui.ui.viewmodel.PlayerViewModel
@@@ -213,10 -212,10 +212,7 @@@ fun rememberImmersivePlayer(navControll
if (on) Toast.makeText(context, context.getString(R.string.immersive_player_added_to_liked), Toast.LENGTH_SHORT).show()
},
openAlbum = {
-- val albumId = SongPlayer.nowPlaying.value.albumUri.substringAfterLast(":")
-- if (albumId.isNotBlank()) {
-- navController.navigate(albumRoute(vm.currentSongAlbum.value, vm.currentSongSinger.value, albumId))
-- }
++ com.music.spotui.ui.screens.openNowPlayingAlbum(vm, vm.currentSongSinger.value, smartScope) { navController.navigate(it) }
},
openArtist = {
vm.goToArtist(SongPlayer.currentTrackId, vm.currentSongSinger.value) { route -> navController.navigate(route) }
diff --cc base/app/src/main/java/com/music/spotui/ui/immersive/player/PlayerControls.kt
index f4222dc8,f6db1a2a..ae797cd3
--- a/base/app/src/main/java/com/music/spotui/ui/immersive/player/PlayerControls.kt
+++ b/base/app/src/main/java/com/music/spotui/ui/immersive/player/PlayerControls.kt
@@@ -518,35 -519,32 +520,37 @@@ internal fun PlayerActionRow
},
) {
Pill {
- PillSegment(
- icon = if (smartEnabled) Icons.Rounded.AutoAwesome else Icons.Rounded.Shuffle,
- contentDescription = stringResource(
- when {
- smartEnabled -> R.string.smart_shuffle_title
- shuffleEnabled -> R.string.immersive_player_shuffle_on
- else -> R.string.immersive_player_shuffle_off
+ if (modes) {
+ PillSegment(
+ icon = if (smartEnabled) Icons.Rounded.AutoAwesome else Icons.Rounded.Shuffle,
+ contentDescription = stringResource(
+ when {
+ smartEnabled -> R.string.smart_shuffle_title
+ shuffleEnabled -> R.string.immersive_player_shuffle_on
+ else -> R.string.immersive_player_shuffle_off
+ },
+ ),
+ onClick = onToggleShuffle,
+ highlighted = shuffleEnabled,
+ )
+ PillDivider()
+ PillSegment(
- icon = if (repeatMode == ImmersiveRepeat.ONE) Icons.Rounded.RepeatOne else Icons.Rounded.Repeat,
++ icon = when (repeatMode) {
++ ImmersiveRepeat.ONE -> Icons.Rounded.RepeatOne
++ ImmersiveRepeat.ONCE -> RepeatIcons.once
++ else -> Icons.Rounded.Repeat
+ },
- ),
- onClick = onToggleShuffle,
- highlighted = shuffleEnabled,
- )
- PillDivider()
- PillSegment(
- icon = when (repeatMode) {
- ImmersiveRepeat.ONE -> Icons.Rounded.RepeatOne
- ImmersiveRepeat.ONCE -> RepeatIcons.once
- else -> Icons.Rounded.Repeat
- },
- contentDescription = when (repeatMode) {
- ImmersiveRepeat.ONE -> stringResource(R.string.immersive_player_repeat_one)
- ImmersiveRepeat.ONCE -> stringResource(R.string.immersive_player_repeat_once)
- ImmersiveRepeat.ALL -> stringResource(R.string.immersive_player_repeat_all)
- else -> stringResource(R.string.immersive_player_repeat_off)
- },
- onClick = onCycleRepeat,
- highlighted = repeatMode != ImmersiveRepeat.OFF,
- )
- PillDivider()
+ contentDescription = when (repeatMode) {
+ ImmersiveRepeat.ONE -> stringResource(R.string.immersive_player_repeat_one)
++ ImmersiveRepeat.ONCE -> stringResource(R.string.immersive_player_repeat_once)
+ ImmersiveRepeat.ALL -> stringResource(R.string.immersive_player_repeat_all)
+ else -> stringResource(R.string.immersive_player_repeat_off)
+ },
+ onClick = onCycleRepeat,
+ highlighted = repeatMode != ImmersiveRepeat.OFF,
+ )
+ PillDivider()
+ }
PillSegment(
icon = Icons.Rounded.Devices,
contentDescription = stringResource(R.string.immersive_player_devices),
diff --cc base/app/src/main/java/com/music/spotui/ui/screens/LyricsScreen.kt
index d54b7a56,385b8090..ac6db9ef
--- 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
@@@ -569,8 -653,14 +653,13 @@@ fun LyricsScreen
}
}
}
- val sameLanguage = state.sourceLanguage?.substringBefore('-')
- ?.equals(targetLanguage.substringBefore('-'), ignoreCase = true) == true
+ val sameLanguage = LyricsViewModel.sameLanguage(state.sourceLanguage, targetLanguage)
- LyricsControls(
+ if (selecting) LyricsSelectionBar(
+ palette = palette,
+ canShare = picked != null,
+ onCancel = { vm.stopSelecting() },
+ onShare = { picked?.let { shareLyricLines(context, l, it, title, artist); vm.stopSelecting() } },
+ ) else LyricsControls(
palette = palette,
position = position,
showTranslate = state.translationChecked && !sameLanguage,
diff --cc base/app/src/main/java/com/music/spotui/ui/screens/PlayerScreen.kt
index feb41dee,1ab3f337..0bc6b249
--- 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
@@@ -623,23 -623,23 +623,7 @@@ fun PlayerScreen(navController: NavCont
onLikeClick = { playerViewModel.updateLikeState(!isLiked.value) },
likeSong = { nowPlayingSong(playerViewModel) },
adPlaying = adPlaying,
-- onTitleClick = {
-- // A radio's tracks may come without their album: asked from the track, else
-- // by the album's name (the album page resolves it).
-- val albumId = np.albumUri.substringAfterLast(":").ifBlank { nowPlayingSong(playerViewModel).albumId }
-- val albumName = playerViewModel.currentSongAlbum.value
-- if (albumId.isNotBlank()) navController.navigate(albumRoute(albumName, songSinger, albumId))
-- else {
-- val trackId = SongPlayer.currentTrackId
-- titleScope.launch {
-- val resolved = if (trackId.isBlank()) "" else kotlinx.coroutines.withContext(kotlinx.coroutines.Dispatchers.IO) {
-- runCatching { app.myspoti.host.android.MyspotiRuntime.api.catalog.track("spotify:track:$trackId").album?.uri }
-- .getOrNull()?.substringAfterLast(":").orEmpty()
-- }
-- if (resolved.isNotBlank() || albumName.isNotBlank()) navController.navigate(albumRoute(albumName, songSinger, resolved))
-- }
-- }
-- },
++ onTitleClick = { openNowPlayingAlbum(playerViewModel, songSinger, titleScope) { navController.navigate(it) } },
onArtistClick = {
playerViewModel.goToArtist(SongPlayer.currentTrackId, songSinger) { route ->
navController.navigate(route)
@@@ -1561,6 -1560,6 +1545,24 @@@ fun PlayerOptionsSheet
}
++/**
++ * Opens the album of the track that plays, for both looks. A radio's tracks may come without
++ * their album: asked from the track, else by the album's name (the album page resolves it).
++ */
++fun openNowPlayingAlbum(playerViewModel: PlayerViewModel, singer: String, scope: kotlinx.coroutines.CoroutineScope, navigate: (String) -> Unit) {
++ val albumId = nowPlayingSong(playerViewModel).albumId
++ val albumName = playerViewModel.currentSongAlbum.value
++ if (albumId.isNotBlank()) { navigate(albumRoute(albumName, singer, albumId)); return }
++ val trackId = SongPlayer.currentTrackId
++ scope.launch {
++ val resolved = if (trackId.isBlank()) "" else kotlinx.coroutines.withContext(kotlinx.coroutines.Dispatchers.IO) {
++ runCatching { app.myspoti.host.android.MyspotiRuntime.api.catalog.track("spotify:track:$trackId").album?.uri }
++ .getOrNull()?.substringAfterLast(":").orEmpty()
++ }
++ if (resolved.isNotBlank() || albumName.isNotBlank()) navigate(albumRoute(albumName, singer, resolved))
++ }
++}
++
/** The track that plays, as Spotify reports it (the local queue may not have it). */
fun nowPlayingSong(playerViewModel: PlayerViewModel): SongsModel {
val np = SongPlayer.nowPlaying.value
diff --cc base/app/src/main/res/values-pt/myspoti_strings.xml
index f4385222,d1ab2944..fdd5ccd0
--- a/base/app/src/main/res/values-pt/myspoti_strings.xml
+++ b/base/app/src/main/res/values-pt/myspoti_strings.xml
@@@ -6,14 -6,13 +6,14 @@@
<string name="welcome_rotate_lyrics">com letras palavra por palavra.</string>
<string name="welcome_rotate_clips">com os clipes oficiais.</string>
<string name="welcome_rotate_offline">offline, com extensões.</string>
- <string name="welcome_login">Iniciar sessão com o Spotify</string>
- <string name="welcome_privacy">Inicias sessão na página oficial do Spotify. O Myspoti nunca vê a tua palavra-passe.</string>
- <string name="remove_from_liked">Remover das Músicas apreciadas</string>
+ <string name="welcome_login">Entrar com o Spotify</string>
+ <string name="welcome_privacy">Você entra na página oficial do Spotify. O Myspoti nunca vê a sua senha.</string>
+ <string name="remove_from_liked">Remover das Músicas curtidas</string>
<string name="repeat_on">Repetir: ativado</string>
- <string name="repeat_one">Repetir uma</string>
+ <string name="repeat_one">Repetir uma música</string>
+ <string name="repeat_once">Repetir uma vez</string>
<string name="repeat_off">Repetir: desativado</string>
- <string name="headphones">Auscultadores</string>
+ <string name="headphones">Fones de ouvido</string>
<string name="listen_on">Ouvir em</string>
<string name="no_devices">Nenhum dispositivo encontrado</string>
<string name="sleep_minutes">%1$d minutos</string>
@@@ -40,16 -47,14 +48,16 @@@
<string name="home_retry">Tentar novamente</string>
<string name="home_empty">Ainda não há nada para mostrar.</string>
<string name="spotify_account">Conta Spotify</string>
- <string name="spotify_user">Utilizador Spotify</string>
+ <string name="spotify_user">Usuário Spotify</string>
<string name="list_view">Mostrar em lista</string>
- <string name="grid_view">Mostrar em grelha</string>
- <string name="library_error">Não foi possível carregar a tua Biblioteca</string>
- <string name="library_empty">A tua Biblioteca está vazia</string>
+ <string name="grid_view">Mostrar em grade</string>
+ <string name="library_error">Não foi possível carregar sua Biblioteca</string>
+ <string name="library_empty">Sua Biblioteca está vazia</string>
<string name="background_playback_title">Reprodução em segundo plano</string>
- <string name="background_playback_on">A otimização da bateria está desativada: a música e o Spotify Connect continuam com o ecrã desligado.</string>
- <string name="background_playback_off">Desativa a otimização da bateria para que o Android não pause a app em segundo plano.</string>
+ <string name="background_playback_on">A otimização da bateria está desativada: a música e o Spotify Connect continuam com a tela desligada.</string>
+ <string name="background_playback_off">Desative a otimização da bateria para que o Android não pause o app em segundo plano.</string>
+ <string name="background_playback_samsung">A Samsung ainda pode colocar o Myspoti em suspensão com a tela desligada. Adicione-o a “Apps que nunca entram em suspensão”: Configurações &gt; Bateria &gt; Limites de uso em segundo plano.</string>
+ <string name="background_playback_open">Abrir configurações do app</string>
<plurals name="local_files_count">
<item quantity="one">%d faixa</item>
<item quantity="other">%d faixas</item>
@@@ -112,22 -118,19 +121,22 @@@
<string name="about_github">Código-fonte</string>
<string name="about_github_detail">Versões, issues e código no GitHub</string>
<string name="about_free">Gratuito, de código aberto e sem anúncios. Não afiliado ao Spotify.</string>
- <string name="library_reorder_hint">Mantém uma playlist carregada e arrasta-a para a mover</string>
- <string name="library_reorder_reset">Repor a ordem do Spotify</string>
+ <string name="library_reorder_hint">Segure uma playlist e arraste-a para movê-la</string>
+ <string name="library_reorder_reset">Restaurar a ordem do Spotify</string>
<string name="song_radio_failed">Não foi possível abrir a rádio desta música</string>
<string name="song_radio_name">Rádio de %1$s</string>
- <string name="local_files_find_hint">Procurar em Ficheiros locais</string>
- <string name="data_saver_title">Poupança de dados</string>
- <string name="data_saver_summary">Em dados móveis, o Myspoti não usa dados: só tocam as músicas transferidas e os Ficheiros locais</string>
- <string name="data_saver_blocked">Poupança de dados: em dados móveis, só tocam as músicas transferidas e os Ficheiros locais</string>
- <string name="new_releases_followed">De artistas que segues</string>
+ <string name="local_files_find_hint">Procurar em Arquivos locais</string>
+ <string name="data_saver_title">Economia de dados</string>
+ <string name="data_saver_summary">Em dados móveis, o Myspoti não usa dados: só tocam as músicas baixadas e os Arquivos locais</string>
+ <string name="data_saver_blocked">Economia de dados: em dados móveis, só tocam as músicas baixadas e os Arquivos locais</string>
+ <string name="new_releases_followed">De artistas que você segue</string>
<string name="new_releases_latest">Últimos lançamentos</string>
- <string name="your_episodes_title">Os teus episódios</string>
- <string name="your_episodes_empty">Os episódios que guardares aparecem aqui.</string>
+ <string name="your_episodes_title">Seus episódios</string>
+ <string name="your_episodes_empty">Os episódios que você salvar aparecem aqui.</string>
+ <string name="new_episodes_title">Novos episódios</string>
+ <string name="new_episodes_subtitle">Dos programas que você segue</string>
+ <string name="new_episodes_empty">Todos os episódios recentes dos programas que você segue já foram reproduzidos.</string>
- <string name="recap_title">O teu resumo</string>
+ <string name="recap_title">Seu resumo</string>
<string name="recap_month">30 dias</string>
<string name="recap_year">12 meses</string>
<string name="recap_all">Desde sempre</string>
@@@ -307,14 -310,11 +316,14 @@@
<item quantity="one">%1$d música de %2$s</item>
<item quantity="other">%1$d músicas de %2$s</item>
</plurals>
- <string name="share_link">Partilhar ligação</string>
- <string name="share_as_image">Partilhar como imagem</string>
+ <string name="share_link">Compartilhar link</string>
+ <string name="share_as_image">Compartilhar como imagem</string>
<string name="settings_autoplay_title">Reprodução automática</string>
- <string name="settings_autoplay_detail">Quando a tua música acabar, continua com músicas semelhantes</string>
+ <string name="settings_autoplay_detail">Quando sua música acabar, continua com músicas semelhantes</string>
+ <string name="myspoti_shuffle_title">Aleatório do Myspoti</string>
+ <string name="myspoti_shuffle_detail">Com o modo aleatório ativado, uma playlist, um álbum ou as Músicas apreciadas tocam cada música uma vez, em ordem aleatória, antes de recomeçar. Desativado: o modo aleatório do Spotify. Uma conta gratuita pode manter o modo aleatório do Spotify em algumas listas.</string>
+ <string name="myspoti_shuffle_imposed">O Spotify mantém o próprio modo aleatório nesta lista para a sua conta: o aleatório do Myspoti fica desativado nela.</string>
- <string name="settings_rotation_title">Rotação do ecrã</string>
+ <string name="settings_rotation_title">Rotação da tela</string>
<string name="settings_rotation_portrait">Retrato</string>
<string name="settings_rotation_auto">Automática</string>
<string name="settings_rotation_landscape">Paisagem</string>