Native Android client for Spotify, built with Jetpack Compose
Kotlin ad-freeadblockandroidjetpack-composekotlinlyricsmusic-playermusic-videomyspotispotifyspotify-adblockerspotify-clientspotify-connectspotui
Cosmetics: no empty strip under the Classic player without lyrics (#85), tighter mini player lines (#86), readable white on pale cover tints (#75), edge to edge on Android 14 and older (#49)
kota-zoe25217e8e9fa
diff --git a/base/app/src/main/java/app/myspoti/MainActivity.kt b/base/app/src/main/java/app/myspoti/MainActivity.ktindex 81ab68cb..9c9dc878 100644--- a/base/app/src/main/java/app/myspoti/MainActivity.kt+++ b/base/app/src/main/java/app/myspoti/MainActivity.kt@@ -70,6 +70,10 @@ class MainActivity : AppCompatActivity() {override fun onCreate(savedInstanceState: Bundle?) {super.onCreate(savedInstanceState)+ // Edge to edge on every Android version (15+ enforces it, 14 and older do not): the pages draw+ // under the status bar and handle its inset, otherwise a band of the window's colour sits+ // above their gradient on 14 and older.+ androidx.core.view.WindowCompat.setDecorFitsSystemWindows(window, false)// The user's rotation choice (portrait by default); changes are applied from the UI below.requestedOrientation = com.music.spotui.data.preferences.OrientationPref.requested()signedIn = prefs.getBoolean("LoggedIn", false)diff --git a/base/app/src/main/java/com/music/spotui/di/Palette.kt b/base/app/src/main/java/com/music/spotui/di/Palette.ktindex bd40d392..3c9d3f50 100644--- a/base/app/src/main/java/com/music/spotui/di/Palette.kt+++ b/base/app/src/main/java/com/music/spotui/di/Palette.kt@@ -4,6 +4,7 @@ import android.content.Contextimport android.graphics.Bitmapimport android.graphics.drawable.Drawableimport androidx.compose.ui.graphics.Color+import androidx.compose.ui.graphics.luminanceimport androidx.palette.graphics.Paletteimport com.bumptech.glide.Glideimport com.bumptech.glide.request.target.CustomTarget@@ -26,6 +27,24 @@ class Palette {})fun cachedSecond(imageUrl: String): Color? = colors["2|$imageUrl"]fun cachedFirst(imageUrl: String): Color? = colors["1|$imageUrl"]++ /**+ * The first colour carries white text and icons (the mini player, the player's gradient). A+ * cover with no dark swatch gave its dominant colour, a pale yellow or pink the white text+ * vanished on: darkened, same hue, until white reads on it.+ */+ internal fun readableUnderWhite(c: Color): Color {+ var out = c+ var t = 0f+ while (out.luminance() > MAX_TINT_LUMINANCE && t < 0.8f) {+ t += 0.05f+ out = androidx.compose.ui.graphics.lerp(c, Color.Black, t)+ }+ return out+ }++ /** White on a colour of this luminance has a contrast ratio of about 5.5:1. */+ private const val MAX_TINT_LUMINANCE = 0.14f}// fun extractColorFromImageUrl(context: Context, imageUrl: String, onPaletteGenerated: (Palette) -> Unit) {@@ -61,7 +80,7 @@ class Palette {val dominantColor = palette?.let { it.darkVibrantSwatch ?: it.darkMutedSwatch ?: it.dominantSwatch ?: it.vibrantSwatch }?.rgbdominantColor?.let {// Convert RGB color integer to ARGB color integer with full opacity- val argbColor = Color(it or (0xFF shl 24))+ val argbColor = readableUnderWhite(Color(it or (0xFF shl 24)))colors[key] = argbColor; onColorExtracted(argbColor)}}diff --git a/base/app/src/main/java/com/music/spotui/ui/components/AppComponents.kt b/base/app/src/main/java/com/music/spotui/ui/components/AppComponents.ktindex c507ea52..25e21ac4 100644--- a/base/app/src/main/java/com/music/spotui/ui/components/AppComponents.kt+++ b/base/app/src/main/java/com/music/spotui/ui/components/AppComponents.kt@@ -306,11 +306,11 @@ fun MiniPlayer(navController: NavHostController) {val remote = SongPlayer.activeDevice.valueColumn(modifier = Modifier.padding(start = 12.dp, end = 8.dp)) {if (remote == null) {- Text(text = if (adPlaying) stringResource(R.string.ad_playing) else (m.title), color = Color.White, fontSize = 13.sp, fontWeight = FontWeight.Bold, maxLines = 1, overflow = androidx.compose.ui.text.style.TextOverflow.Ellipsis)+ Text(text = if (adPlaying) stringResource(R.string.ad_playing) else (m.title), color = Color.White, fontSize = 13.sp, lineHeight = 15.sp, fontWeight = FontWeight.Bold, maxLines = 1, overflow = androidx.compose.ui.text.style.TextOverflow.Ellipsis)if (!adPlaying) Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.fillMaxWidth()) {// The artist yields the width: the output's name stays whole.Text(- text = m.singer, color = Color.White.copy(alpha = 0.7f), fontSize = 13.sp,+ text = m.singer, color = Color.White.copy(alpha = 0.7f), fontSize = 13.sp, lineHeight = 15.sp,maxLines = 1, overflow = androidx.compose.ui.text.style.TextOverflow.Ellipsis,modifier = Modifier.weight(1f, fill = false),)diff --git a/base/app/src/main/java/com/music/spotui/ui/immersive/player/ImmersiveMiniPlayer.kt b/base/app/src/main/java/com/music/spotui/ui/immersive/player/ImmersiveMiniPlayer.ktindex 25b0fbfb..b3bbeba3 100644--- a/base/app/src/main/java/com/music/spotui/ui/immersive/player/ImmersiveMiniPlayer.kt+++ b/base/app/src/main/java/com/music/spotui/ui/immersive/player/ImmersiveMiniPlayer.kt@@ -119,12 +119,13 @@ fun ImmersiveMiniPlayer(navController: NavController, modifier: Modifier = ModifColumn(Modifier.weight(1f)) {Text(text = if (adPlaying) stringResource(R.string.immersive_player_ad) else title,- style = Immersive.BodyStrong.copy(fontSize = 15.sp),+ // Title and artist set close, as the official mini player: the default line heights left a gap.+ style = Immersive.BodyStrong.copy(fontSize = 15.sp, lineHeight = 19.sp),maxLines = 1,overflow = TextOverflow.Ellipsis,)if (!adPlaying) {- Text(text = singer, style = Immersive.Subhead, maxLines = 1, overflow = TextOverflow.Ellipsis)+ Text(text = singer, style = Immersive.Subhead.copy(lineHeight = 16.sp), maxLines = 1, overflow = TextOverflow.Ellipsis)}}if (buffering) {diff --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 3e11e484..23c2845f 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@@ -211,7 +211,7 @@ private fun shareLyrics(context: Context, title: String, artist: String, line: S}@Composable-private fun rememberLyricsState(vm: LyricsViewModel, title: String, artist: String): LyricsViewModel.State {+internal fun rememberLyricsState(vm: LyricsViewModel, title: String, artist: String): LyricsViewModel.State {// currentTrackId is plain data, not Compose state: the playing item's uri re-runs the load on a skip.val playingUri = SongPlayer.nowPlaying.value.uriLaunchedEffect(title, artist, playingUri, SongPlayer.currentTrackId) {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.ktindex c78cd8e4..5264640e 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@@ -390,6 +390,11 @@ fun PlayerScreen(navController: NavController) {// bar's, to size the page item itself: a LazyColumn item cannot ask for "parent minus x".val pageHeight = maxHeightval statusTop = androidx.compose.foundation.layout.WindowInsets.Companion.statusBars.asPaddingValues().calculateTopPadding()+ // The lyrics card peeks in under the buttons only where it will show (it stays hidden for an+ // ad and for a song without lyrics): otherwise that strip is empty space below the controls.+ // The state is read here too, as the card sits below the page and is not composed to load it.+ val lyricsState = rememberLyricsState(viewModel<com.music.spotui.ui.viewmodel.LyricsViewModel>(), songTitle, songSinger)+ val lyricsPeek = if (adPlaying || lyricsState is com.music.spotui.ui.viewmodel.LyricsViewModel.State.NotFound) 0 else PLAYER_PEEK_DPval pillAboveTitle = canvasUrl != null && !videoOnif (canvasUrl != null && !videoOn) {CanvasVideo(@@ -437,7 +442,7 @@ fun PlayerScreen(navController: NavController) {// The page stops short of the screen's bottom so the lyrics card peeks in under// the buttons, as in the official app (scroll to open it).else Modifier.height(- (pageHeight - statusTop - PLAYER_PEEK_DP.dp).coerceAtLeast(300.dp)+ (pageHeight - statusTop - lyricsPeek.dp).coerceAtLeast(300.dp))).fillMaxWidth(),contentAlignment = Alignment.TopCenter,) {