Unofficial YouTube Music / Spotify Premium client for Android, built in Liquid Glass. Audio effects, Spotify Connect, listening history, 8 languages. Rust core on librespot.
Kotlin alternativeandroidandroid-applicationclientglassmorphisminnertubelibrespotliquid-glassspotifyspotify-connectspotifyapiyoutube-musicyoutube-playerytdlnis
Let the cover's light run on its own
Lelonio828b34f8fbb7
diff --git a/app/src/main/java/dev/lelonio/square/data/PreferencesStore.kt b/app/src/main/java/dev/lelonio/square/data/PreferencesStore.ktindex 394f633..7bac56c 100644--- a/app/src/main/java/dev/lelonio/square/data/PreferencesStore.kt+++ b/app/src/main/java/dev/lelonio/square/data/PreferencesStore.kt@@ -27,22 +27,6 @@ class PreferencesStore(context: Context) {prefs.edit().putString(KEY_TRACK_SORT, value).apply()}- private val _coverAura = MutableStateFlow(prefs.getBoolean(KEY_COVER_AURA, false))-- /**- * Whether a track with no Canvas gets the animation made from its cover.- *- * A taste rather than a property of a song, so it is remembered: whoever- * turns it on wants it on for the next track without one too, and for the- * next time they open the app.- */- val coverAura: StateFlow<Boolean> = _coverAura.asStateFlow()-- fun setCoverAura(on: Boolean) {- _coverAura.value = on- prefs.edit().putBoolean(KEY_COVER_AURA, on).apply()- }-/*** This phone's Connect id, made once and kept for good.*@@ -135,7 +119,6 @@ class PreferencesStore(context: Context) {private companion object {const val FILE_NAME = "square_preferences"const val KEY_TRACK_SORT = "track_sort"- const val KEY_COVER_AURA = "cover_aura"const val KEY_DEVICE_ID = "device_id"const val KEY_ONBOARDED = "onboarded"const val KEY_PLAYER_OPEN = "player_open"diff --git a/app/src/main/java/dev/lelonio/square/ui/MainViewModel.kt b/app/src/main/java/dev/lelonio/square/ui/MainViewModel.ktindex 701e804..6048ab7 100644--- a/app/src/main/java/dev/lelonio/square/ui/MainViewModel.kt+++ b/app/src/main/java/dev/lelonio/square/ui/MainViewModel.kt@@ -1082,11 +1082,6 @@ class MainViewModel(app: Application) : AndroidViewModel(app) {.getOrDefault(emptyList())}- /** The colour animation for tracks with no Canvas; see PreferencesStore. */- val coverAura: StateFlow<Boolean> get() = container.preferences.coverAura-- fun setCoverAura(on: Boolean) = container.preferences.setCoverAura(on)-/** How the detail screen sorts its tracks; remembered between visits. */val trackSort: StateFlow<String?> get() = container.preferences.trackSortdiff --git a/app/src/main/java/dev/lelonio/square/ui/SquareApp.kt b/app/src/main/java/dev/lelonio/square/ui/SquareApp.ktindex d07ef61..e5c58a0 100644--- a/app/src/main/java/dev/lelonio/square/ui/SquareApp.kt+++ b/app/src/main/java/dev/lelonio/square/ui/SquareApp.kt@@ -304,7 +304,6 @@ fun SquareApp(val playlistOrder by viewModel.playlistOrder.collectAsStateWithLifecycle()val pinnedPlaylists by viewModel.pinnedPlaylists.collectAsStateWithLifecycle()val likedTracks by viewModel.likedTracks.collectAsStateWithLifecycle()- val coverAura by viewModel.coverAura.collectAsStateWithLifecycle()val devices by viewModel.devices.collectAsStateWithLifecycle()val addToPlaylist by viewModel.addToPlaylist.collectAsStateWithLifecycle()val trackSort by viewModel.trackSort.collectAsStateWithLifecycle()@@ -982,8 +981,6 @@ fun SquareApp(playback.mediaId in inPlaylists,inLikedSongs = playback.mediaId != null &&playback.mediaId in likedTracks,- auraOn = coverAura,- onToggleAura = { viewModel.setCoverAura(!coverAura) },// Spotify's own radio, and only where Spotify// can answer: the station is a context on its// access point and means nothing anywhere else.diff --git a/app/src/main/java/dev/lelonio/square/ui/player/CoverAura.kt b/app/src/main/java/dev/lelonio/square/ui/player/CoverAura.ktindex 572ef98..8e089d4 100644--- a/app/src/main/java/dev/lelonio/square/ui/player/CoverAura.kt+++ b/app/src/main/java/dev/lelonio/square/ui/player/CoverAura.kt@@ -83,14 +83,14 @@ fun CoverAura(// and the whole thing is put out of focus afterwards..blur(BLUR),) {- // The bed: wide, soft, and the only part that is meant to be looked at+ // The bed: wide, soft, and the only part meant to be looked at// directly. Everything after this is for the glass.repeat(3) { index ->val color = colors[index % colors.size]val angle = turn * DRIFT[index] + index * (TAU / 3f)val centre = Offset(x = size.width * (0.5f + 0.34f * cos(angle)),- y = size.height * (0.42f + 0.30f * sin(angle * 0.8f)),+ y = size.height * (0.42f + 0.30f * sin(angle * 2f)),)val radius = size.maxDimension * 0.62fdrawCircle(@@ -108,13 +108,14 @@ fun CoverAura(// the abrupt side is the whole point: that is the edge the panes bend.repeat(2) { index ->val color = colors[(index + 1) % colors.size]- val sweep = turn * BEAM[index] + index * 1.7f- rotate(degrees = (sweep * 18f) + index * 40f - 20f) {+ val angle = turn * BEAM[index] + index * 1.7f+ rotate(degrees = 20f * sin(angle) + index * 40f - 20f) {beam(color = color,- // Travels across and wraps, so a beam is always crossing- // rather than all of them arriving together.- offset = ((sweep * 0.18f + index * 0.5f) % 1f),+ // Swung rather than wrapped. A band that travels and starts+ // again jumps at the moment it wraps, and the whole loop was+ // built so there is no such moment.+ offset = 0.5f + 0.42f * sin(angle * 0.5f + index),)}}@@ -127,7 +128,7 @@ fun CoverAura(val angle = turn * CAUSTIC[index] + index * 2.1fval centre = Offset(x = size.width * (0.5f + 0.40f * sin(angle)),- y = size.height * (0.45f + 0.34f * cos(angle * 1.3f)),+ y = size.height * (0.45f + 0.34f * cos(angle * 2f)),)val radius = size.minDimension * 0.10fdrawCircle(@@ -187,11 +188,22 @@ private fun DrawScope.beam(color: Color, offset: Float) {private val BLUR = 48.dp/** A full turn of the slowest element. Minutes, not seconds. */-private const val CYCLE_MS = 42_000+private const val CYCLE_MS = 60_000-/** Deliberately not in simple ratios, so nothing lines up twice the same way. */-private val DRIFT = floatArrayOf(1f, 0.61f, 1.37f)-private val BEAM = floatArrayOf(0.83f, 1.19f)-private val CAUSTIC = floatArrayOf(1.11f, 0.74f, 1.53f)+/**+ * Whole turns per cycle, and whole numbers on purpose.+ *+ * Everything here is a sine or a cosine of the phase times one of these, so at+ * the end of a cycle every element is exactly where it began and the loop has+ * no seam: there is no moment where the animation can be seen restarting.+ * Fractions would have looked freer and shown a jump every forty seconds.+ *+ * They are different from one another, and paired with the doubled vertical+ * terms above, so the paths are lissajous curves rather than circles and the+ * three never trace the same shape.+ */+private val DRIFT = floatArrayOf(1f, 2f, 3f)+private val BEAM = floatArrayOf(2f, 3f)+private val CAUSTIC = floatArrayOf(3f, 2f, 4f)private const val TAU = (2 * Math.PI).toFloat()diff --git a/app/src/main/java/dev/lelonio/square/ui/player/PlayerScreen.kt b/app/src/main/java/dev/lelonio/square/ui/player/PlayerScreen.ktindex 2d5c214..06c3edb 100644--- a/app/src/main/java/dev/lelonio/square/ui/player/PlayerScreen.kt+++ b/app/src/main/java/dev/lelonio/square/ui/player/PlayerScreen.kt@@ -101,7 +101,6 @@ import com.adamglin.phosphoricons.regular.YoutubeLogoimport com.adamglin.phosphoricons.regular.Repeatimport com.adamglin.phosphoricons.regular.RepeatOnceimport com.adamglin.phosphoricons.regular.Shuffle-import com.adamglin.phosphoricons.regular.Sparkleimport kotlin.math.abs/**@@ -120,12 +119,6 @@ private const val CANVAS_SWIPE_FOLLOW = 0.35f*/private const val PAUSED_DIM = 0.55f-/**- * How long a track is given to produce a Canvas before the app decides it has- * none. Long enough to cover a slow lookup, short enough not to feel withheld.- */-private const val AURA_OFFER_DELAY_MS = 1_600L-/*** The player, as a liquid-glass prototype.*@@ -208,14 +201,6 @@ fun PlayerScreen(* mark: a heart, the way every Spotify client says it.*/inLikedSongs: Boolean = false,- /**- * The colour animation for tracks with no Canvas, and its switch.- *- * Held outside this screen: it is remembered between sessions, and it used- * to be lost the moment the player was folded down to the bar.- */- auraOn: Boolean = false,- onToggleAura: () -> Unit = {},/** Starts a station from the current track; null where there is none. */onRadio: (() -> Unit)? = null,/** The playlist picker's state, shown in the panel rather than as a sheet. */@@ -297,23 +282,9 @@ fun PlayerScreen(LaunchedEffect(videoOn) { if (!videoOn) ambient = null }val auraColors by dev.lelonio.square.ui.theme.rememberArtworkPalette(- state.artworkUrl.takeIf { auraOn && canvas == null },+ state.artworkUrl.takeIf { canvas == null },)- // A Canvas is known about a moment after the track starts, not with it, so- // "this song has no clip" is only true once the app has waited for one. Put- // on screen immediately, the button appeared on every track and took itself- // away again half a second later.- var offerAura by remember { mutableStateOf(false) }- LaunchedEffect(state.mediaId, canvas) {- if (canvas != null) {- offerAura = false- return@LaunchedEffect- }- kotlinx.coroutines.delay(AURA_OFFER_DELAY_MS)- offerAura = true- }-Box(Modifier.fillMaxSize()) {Box(Modifier@@ -345,7 +316,7 @@ fun PlayerScreen(// The stand-in for a Canvas, for the tracks that have none, and// only when it has been asked for. In the same layer as the light// above and for the same reason.- if (canvas == null && auraOn) {+ if (canvas == null) {CoverAura(colors = auraColors, playing = state.isPlaying)}@@ -539,46 +510,14 @@ fun PlayerScreen(Modifier.fillMaxSize(),contentAlignment = Alignment.Center,) {- Column(- horizontalAlignment = Alignment.CenterHorizontally,- ) {- Cover(- state,- panel,- onNext,- onPrevious,- sharedScope,- animatedScope,- )- // Under the picture and almost against- // it, because it is about the picture:- // this is a switch for how the screen- // looks, not one of the per-track- // actions in the capsule below. Inside- // this slot rather than under it, so it- // goes away by itself whenever the- // lyrics or the effects take the space.- AnimatedVisibility(- visible = canvas == null && offerAura,- enter = fadeIn(tween(260)),- exit = fadeOut(tween(160)),- ) {- RoundGlassButton(- backdrop = glassBackdrop,- size = 28.dp,- onClick = onToggleAura,- modifier = Modifier.padding(top = 8.dp),- ) {- Icon(- PhosphorIcons.Regular.Sparkle,- contentDescription =- stringResource(R.string.cover_aura),- tint = panelTint(auraOn),- modifier = Modifier.size(14.dp),- )- }- }- }+ Cover(+ state,+ panel,+ onNext,+ onPrevious,+ sharedScope,+ animatedScope,+ )}// The picture in the cover's place rather thandiff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xmlindex 15145a7..c3698dd 100644--- a/app/src/main/res/values-de/strings.xml+++ b/app/src/main/res/values-de/strings.xml@@ -234,6 +234,5 @@<string name="pinned">Angeheftet</string><string name="pin">Oben anheften</string><string name="unpin">Lösen</string>- <string name="cover_aura">Farbanimation</string><string name="radio">Radio</string></resources>diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xmlindex 5bdb560..e41bb8c 100644--- a/app/src/main/res/values-es/strings.xml+++ b/app/src/main/res/values-es/strings.xml@@ -234,6 +234,5 @@<string name="pinned">Fijada</string><string name="pin">Fijar arriba</string><string name="unpin">Quitar de arriba</string>- <string name="cover_aura">Animación de color</string><string name="radio">Radio</string></resources>diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xmlindex 85383d0..9829ced 100644--- a/app/src/main/res/values-fr/strings.xml+++ b/app/src/main/res/values-fr/strings.xml@@ -234,6 +234,5 @@<string name="pinned">Épinglée</string><string name="pin">Épingler en haut</string><string name="unpin">Désépingler</string>- <string name="cover_aura">Animation colorée</string><string name="radio">Radio</string></resources>diff --git a/app/src/main/res/values-hi/strings.xml b/app/src/main/res/values-hi/strings.xmlindex b4e5cb2..de31016 100644--- a/app/src/main/res/values-hi/strings.xml+++ b/app/src/main/res/values-hi/strings.xml@@ -249,6 +249,5 @@<string name="pinned">पिन किया</string><string name="pin">ऊपर पिन करें</string><string name="unpin">पिन हटाएँ</string>- <string name="cover_aura">रंगों की एनिमेशन</string><string name="radio">रेडियो</string></resources>diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xmlindex 285ed66..ee6fa17 100644--- a/app/src/main/res/values-it/strings.xml+++ b/app/src/main/res/values-it/strings.xml@@ -235,6 +235,5 @@<string name="pinned">Fissata</string><string name="pin">Fissa in alto</string><string name="unpin">Togli dall\'alto</string>- <string name="cover_aura">Animazione a colori</string><string name="radio">Radio</string></resources>diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xmlindex 52a2a4d..bba4f3f 100644--- a/app/src/main/res/values-pt/strings.xml+++ b/app/src/main/res/values-pt/strings.xml@@ -234,6 +234,5 @@<string name="pinned">Fixada</string><string name="pin">Fixar no topo</string><string name="unpin">Desafixar</string>- <string name="cover_aura">Animação de cores</string><string name="radio">Rádio</string></resources>diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xmlindex 8569119..c397c4f 100644--- a/app/src/main/res/values-tr/strings.xml+++ b/app/src/main/res/values-tr/strings.xml@@ -249,6 +249,5 @@<string name="pinned">Sabitlendi</string><string name="pin">Yukarı sabitle</string><string name="unpin">Sabitlemeyi kaldır</string>- <string name="cover_aura">Renk animasyonu</string><string name="radio">Radyo</string></resources>diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xmlindex 3c87f19..8ba1bf5 100644--- a/app/src/main/res/values/strings.xml+++ b/app/src/main/res/values/strings.xml@@ -255,6 +255,5 @@<string name="pinned">Pinned</string><string name="pin">Pin to the top</string><string name="unpin">Unpin</string>- <string name="cover_aura">Colour animation</string><string name="radio">Radio</string></resources>