Skip to content

Unofficial YouTube Music / Spotify Premium client for Android, built in Liquid Glass. Audio effects, Spotify Connect, listening history, 8 languages. Rust core on librespot.

A sleep timer, YouTube Music's own New and Radio, and a way out of a sign-in page

Lelonioa9a2a8b0272b
diff --git a/app/src/main/java/dev/lelonio/square/backend/MusicBackend.kt b/app/src/main/java/dev/lelonio/square/backend/MusicBackend.kt
index 3bcf6bc..5a597e4 100644
--- a/app/src/main/java/dev/lelonio/square/backend/MusicBackend.kt
+++ b/app/src/main/java/dev/lelonio/square/backend/MusicBackend.kt
@@ -128,6 +128,19 @@ interface MusicBackend {
*/
suspend fun homeFeed(cursor: String? = null, params: String? = null): HomeFeed = HomeFeed()
+ /**
+ * What is new, as the service itself lays it out: its rows, under its own
+ * titles, for the New tab.
+ *
+ * Empty by default. Spotify's tab is assembled elsewhere, out of the
+ * gateway's browse pages; this is for a source whose page can be read as it
+ * comes.
+ */
+ suspend fun newRows(): List<HomeRow> = emptyList()
+
+ /** The same for the Radio tab: the service's own stations and mood lists. */
+ suspend fun radioRows(): List<HomeRow> = emptyList()
+
/**
* The albums the account has saved, for the library's own shelf of them.
*
diff --git a/app/src/main/java/dev/lelonio/square/backend/youtube/YouTubeBackend.kt b/app/src/main/java/dev/lelonio/square/backend/youtube/YouTubeBackend.kt
index 4e38068..43bc333 100644
--- a/app/src/main/java/dev/lelonio/square/backend/youtube/YouTubeBackend.kt
+++ b/app/src/main/java/dev/lelonio/square/backend/youtube/YouTubeBackend.kt
@@ -36,6 +36,7 @@ import dev.lelonio.square.backend.HomeChip
import dev.lelonio.square.backend.HomeFeed
import dev.lelonio.square.backend.HomeRow
import kotlinx.coroutines.async
+import kotlinx.coroutines.awaitAll
import kotlinx.coroutines.coroutineScope
/**
@@ -244,23 +245,88 @@ class YouTubeBackend(private val account: YouTubeAccount) : MusicBackend {
)
}
- private fun toHomeRow(section: HomePage.Section): HomeRow {
- val songs = section.items.filterIsInstance<SongItem>()
+ private fun toHomeRow(section: HomePage.Section): HomeRow =
+ rowOf(section.title, section.items, section.label)
+
+ private fun rowOf(title: String, items: List<YTItem>, strapline: String? = null): HomeRow {
+ val songs = items.filterIsInstance<SongItem>()
// An episode plays like a song and is listed like one; the only
// difference the queue would notice is its length.
- val episodes = section.items.filterIsInstance<EpisodeItem>()
+ val episodes = items.filterIsInstance<EpisodeItem>()
return HomeRow(
- title = section.title,
- strapline = section.label,
+ title = title,
+ strapline = strapline,
tracks = songs.map(::toCatalogTrack) + episodes.map(::toCatalogTrack),
// Everything that is not a song opens something: an album, a
// playlist, an artist. They travel as one list because the row
// draws them identically.
- items = section.items.filterNot { it is SongItem || it is EpisodeItem }
+ items = items.filterNot { it is SongItem || it is EpisodeItem }
.mapNotNull(::toCatalogPlaylist),
)
}
+ /**
+ * The New tab: YouTube Music's own page of new releases, then its charts.
+ *
+ * Both are the same for anyone in the country, signed in or not, which is
+ * what a tab of what came out should be. Read side by side, and either can
+ * fail without taking the other with it. Titled by YouTube, in the phone's
+ * language: renaming them would be this app pretending it chose them.
+ */
+ override suspend fun newRows(): List<HomeRow> = withContext(Dispatchers.IO) {
+ coroutineScope {
+ val releases = async {
+ runCatching { YouTube.browse(NEW_RELEASES_BROWSE_ID, null).getOrThrow() }
+ .onFailure { android.util.Log.w(LOG_TAG, "new releases unavailable: $it") }
+ .getOrNull()
+ ?.items.orEmpty()
+ .mapNotNull { section -> section.title?.let { rowOf(it, section.items) } }
+ }
+ val charts = async {
+ runCatching { YouTube.getChartsPage().getOrThrow() }
+ .onFailure { android.util.Log.w(LOG_TAG, "charts unavailable: $it") }
+ .getOrNull()
+ ?.sections.orEmpty()
+ .map { rowOf(it.title, it.items) }
+ }
+ (releases.await() + charts.await())
+ .filterNot { it.isEmpty }
+ // The charts page repeats the new albums under the same name.
+ .distinctBy { it.title }
+ }
+ }
+
+ /**
+ * The Radio tab: YouTube Music's moods and genres, a row of lists each.
+ *
+ * What the service itself files as stations to put on, rather than records
+ * to look at, and there to read without an account. A handful from each
+ * group rather than all of them: every mood is its own request, and the
+ * tab should arrive in one breath rather than trickle in over twenty.
+ */
+ override suspend fun radioRows(): List<HomeRow> = withContext(Dispatchers.IO) {
+ val groups = runCatching { YouTube.moodAndGenres().getOrThrow() }
+ .onFailure { android.util.Log.w(LOG_TAG, "moods unavailable: $it") }
+ .getOrNull()
+ .orEmpty()
+ val picks = groups.flatMap { group ->
+ group.items.take(RADIO_PER_GROUP).map { mood -> group.title to mood }
+ }
+ coroutineScope {
+ picks.map { (group, mood) ->
+ async {
+ runCatching {
+ YouTube.browse(mood.endpoint.browseId, mood.endpoint.params).getOrThrow()
+ }
+ .getOrNull()
+ ?.items
+ ?.firstOrNull { it.items.isNotEmpty() }
+ ?.let { rowOf(mood.title, it.items, strapline = group) }
+ }
+ }.awaitAll().filterNotNull().filterNot { it.isEmpty }
+ }
+ }
+
private fun toCatalogPlaylist(item: YTItem): CatalogPlaylist? {
val uri = when (item) {
is AlbumItem -> "$PLAYLIST_PREFIX${item.playlistId}"
@@ -401,6 +467,10 @@ class YouTubeBackend(private val account: YouTubeAccount) : MusicBackend {
private const val LIKED_PLAYLISTS_BROWSE_ID = "FEmusic_liked_playlists"
private const val SAVED_ALBUMS_BROWSE_ID = "FEmusic_liked_albums"
private const val FOLLOWED_ARTISTS_BROWSE_ID = "FEmusic_library_corpus_track_artists"
+ private const val NEW_RELEASES_BROWSE_ID = "FEmusic_new_releases"
+
+ /** How many moods, and how many genres, the Radio tab reads. */
+ private const val RADIO_PER_GROUP = 5
/** The `list=` id of a playlist URL. */
private fun playlistIdOf(url: String?): String? =
diff --git a/app/src/main/java/dev/lelonio/square/playback/PlaybackService.kt b/app/src/main/java/dev/lelonio/square/playback/PlaybackService.kt
index 915697d..b6ad864 100644
--- a/app/src/main/java/dev/lelonio/square/playback/PlaybackService.kt
+++ b/app/src/main/java/dev/lelonio/square/playback/PlaybackService.kt
@@ -60,6 +60,33 @@ class PlaybackService : MediaLibraryService() {
}
}
+ /** The countdown that is running, if one is; see SleepTimer. */
+ private var sleepJob: kotlinx.coroutines.Job? = null
+
+ /**
+ * The end of a sleep timer: down to silence, then paused.
+ *
+ * Falling asleep to music and being cut off mid-bar is the one thing a
+ * sleep timer should not do. Where the player cannot be turned down, which
+ * is Spotify's own engine, it pauses, which is still the promise kept.
+ *
+ * The volume is put back once it is paused, so pressing play afterwards is
+ * not silent.
+ */
+ private suspend fun fadeOutAndPause() {
+ if (!player.isCommandAvailable(androidx.media3.common.Player.COMMAND_SET_VOLUME)) {
+ player.pause()
+ return
+ }
+ val was = player.volume
+ repeat(SLEEP_FADE_STEPS) { step ->
+ player.volume = was * (1f - (step + 1f) / SLEEP_FADE_STEPS)
+ kotlinx.coroutines.delay(SLEEP_FADE_MS / SLEEP_FADE_STEPS)
+ }
+ player.pause()
+ player.volume = was
+ }
+
private var autoplayInFlight = false
private var lastAutoplayTrackUri: String? = null
@@ -73,6 +100,17 @@ class PlaybackService : MediaLibraryService() {
reason: Int,
) {
redrawButtons()
+ // A sleep timer set to the end of the track, at the moment the
+ // track ends. Not faded: the next one has already started, and
+ // fading it in to fade it out would play a second of a song
+ // nobody asked to hear.
+ if (SleepTimer.atTrackEnd.value &&
+ reason == androidx.media3.common.Player.MEDIA_ITEM_TRANSITION_REASON_AUTO
+ ) {
+ SleepTimer.cancel()
+ player.pause()
+ return
+ }
maybeTriggerAutoplay(mediaItem)
}
@@ -243,6 +281,21 @@ class PlaybackService : MediaLibraryService() {
}
}
+ // The sleep timer runs here rather than on the screen that set it; see
+ // SleepTimer.
+ scope.launch {
+ SleepTimer.endsAt.collect { deadline ->
+ sleepJob?.cancel()
+ if (deadline == null) return@collect
+ sleepJob = scope.launch {
+ val wait = deadline - android.os.SystemClock.elapsedRealtime()
+ if (wait > 0) kotlinx.coroutines.delay(wait)
+ fadeOutAndPause()
+ SleepTimer.cancel()
+ }
+ }
+ }
+
// Already read by the application object, and harmless twice: `load`
// returns at once once the file is open.
AudioEffects.load(this)
@@ -1486,6 +1539,10 @@ class PlaybackService : MediaLibraryService() {
companion object {
private const val TAG = "PlaybackService"
+ /** How long the music takes to go quiet at the end of a sleep timer. */
+ private const val SLEEP_FADE_MS = 6_000L
+ private const val SLEEP_FADE_STEPS = 60
+
/** Maximum upcoming tracks to buffer in queue for autoplay. */
private const val AUTOPLAY_QUEUE_CAP = 10
diff --git a/app/src/main/java/dev/lelonio/square/playback/SleepTimer.kt b/app/src/main/java/dev/lelonio/square/playback/SleepTimer.kt
new file mode 100644
index 0000000..55ce3cc
--- /dev/null
+++ b/app/src/main/java/dev/lelonio/square/playback/SleepTimer.kt
@@ -0,0 +1,64 @@
+package dev.lelonio.square.playback
+
+import android.os.SystemClock
+import kotlinx.coroutines.flow.MutableStateFlow
+import kotlinx.coroutines.flow.StateFlow
+import kotlinx.coroutines.flow.asStateFlow
+
+/**
+ * When the music is to stop on its own.
+ *
+ * Held here rather than on the screen that sets it: what stops the music is
+ * the service, which outlives every screen, and a countdown that lived in the
+ * player's panel would be one that only ran while somebody was watching it.
+ * The same reason OfflineMode is an object.
+ *
+ * Two kinds, because they answer two different questions. A deadline is "I am
+ * going to sleep now"; the end of the track is "let this one finish". Asking
+ * for either clears the other, since holding both would leave the listener
+ * guessing which one stops the music.
+ *
+ * The deadline is on the clock that counts while the phone sleeps and does not
+ * move when the time of day does: a timer set for twenty minutes is twenty
+ * minutes whatever the phone thinks the hour is.
+ */
+object SleepTimer {
+
+ private val _endsAt = MutableStateFlow<Long?>(null)
+
+ /** Elapsed realtime, in milliseconds, at which playback stops. */
+ val endsAt: StateFlow<Long?> = _endsAt.asStateFlow()
+
+ private val _minutes = MutableStateFlow<Int?>(null)
+
+ /** What was asked for, so the row can show which length is running. */
+ val minutes: StateFlow<Int?> = _minutes.asStateFlow()
+
+ private val _atTrackEnd = MutableStateFlow(false)
+
+ /** Stop when the track that is playing ends, rather than at a time. */
+ val atTrackEnd: StateFlow<Boolean> = _atTrackEnd.asStateFlow()
+
+ fun inMinutes(minutes: Int) {
+ _atTrackEnd.value = false
+ _minutes.value = minutes
+ _endsAt.value = SystemClock.elapsedRealtime() + minutes * 60_000L
+ }
+
+ fun atEndOfTrack() {
+ _minutes.value = null
+ _endsAt.value = null
+ _atTrackEnd.value = true
+ }
+
+ fun cancel() {
+ _minutes.value = null
+ _endsAt.value = null
+ _atTrackEnd.value = false
+ }
+
+ /** How long is left, or null when nothing is set. Never negative. */
+ fun remaining(): Long? = _endsAt.value?.let {
+ (it - SystemClock.elapsedRealtime()).coerceAtLeast(0L)
+ }
+}
diff --git a/app/src/main/java/dev/lelonio/square/ui/MainViewModel.kt b/app/src/main/java/dev/lelonio/square/ui/MainViewModel.kt
index f0a410c..829423f 100644
--- a/app/src/main/java/dev/lelonio/square/ui/MainViewModel.kt
+++ b/app/src/main/java/dev/lelonio/square/ui/MainViewModel.kt
@@ -268,8 +268,16 @@ class MainViewModel(app: Application) : AndroidViewModel(app) {
private var inFlight: Job? = null
private var playlistJob: Job? = null
+ // Signed out is a Spotify state. The other source works without an account
+ // and has its library loading from the start, and reading only Spotify's
+ // login here put a Spotify sign-in button on the YouTube Music library until
+ // the first refresh replaced it, or for good when that refresh never came.
private val _state = MutableStateFlow<UiState>(
- if (container.spotifySignedIn) UiState.Connecting else UiState.LoggedOut,
+ when {
+ container.activeBackend.id != BackendId.SPOTIFY -> UiState.Loading
+ container.spotifySignedIn -> UiState.Connecting
+ else -> UiState.LoggedOut
+ },
)
val state: StateFlow<UiState> = _state.asStateFlow()
@@ -429,6 +437,44 @@ class MainViewModel(app: Application) : AndroidViewModel(app) {
val youtubeHome: StateFlow<YouTubeHomeState> = _youtubeHome.asStateFlow()
private var youtubeHomeJob: Job? = null
+ /** One of the other two tabs when the source is not Spotify; see [MusicBackend.newRows]. */
+ data class SourceRowsState(
+ val rows: List<HomeRow> = emptyList(),
+ val loading: Boolean = false,
+ )
+
+ private val _sourceNew = MutableStateFlow(SourceRowsState())
+ val sourceNew: StateFlow<SourceRowsState> = _sourceNew.asStateFlow()
+ private val _sourceRadio = MutableStateFlow(SourceRowsState())
+ val sourceRadio: StateFlow<SourceRowsState> = _sourceRadio.asStateFlow()
+ private var sourceNewJob: Job? = null
+ private var sourceRadioJob: Job? = null
+
+ /**
+ * The New tab for a source that lays its own out. Read once a session: it
+ * is the same page for anyone in the country and moves once a week.
+ */
+ fun loadSourceNew() {
+ if (container.activeBackend.id == BackendId.SPOTIFY) return
+ if (sourceNewJob?.isActive == true || _sourceNew.value.rows.isNotEmpty()) return
+ _sourceNew.value = _sourceNew.value.copy(loading = true)
+ sourceNewJob = viewModelScope.launch {
+ val rows = runCatching { container.activeBackend.newRows() }.getOrDefault(emptyList())
+ _sourceNew.value = SourceRowsState(rows = rows, loading = false)
+ }
+ }
+
+ /** And the Radio tab; see [loadSourceNew]. */
+ fun loadSourceRadio() {
+ if (container.activeBackend.id == BackendId.SPOTIFY) return
+ if (sourceRadioJob?.isActive == true || _sourceRadio.value.rows.isNotEmpty()) return
+ _sourceRadio.value = _sourceRadio.value.copy(loading = true)
+ sourceRadioJob = viewModelScope.launch {
+ val rows = runCatching { container.activeBackend.radioRows() }.getOrDefault(emptyList())
+ _sourceRadio.value = SourceRowsState(rows = rows, loading = false)
+ }
+ }
+
/**
* Loads it, once per sign-in state.
*
@@ -1816,6 +1862,13 @@ class MainViewModel(app: Application) : AndroidViewModel(app) {
viewModelScope.launch { container.contextCache.clear() }
_playlist.value = PlaylistState()
_feed.value = FeedState()
+ // Signed out of Spotify while playing from somewhere else leaves that
+ // source exactly as usable as it was: its library is read again rather
+ // than replaced with a screen asking to sign in to Spotify.
+ if (container.activeBackend.id != BackendId.SPOTIFY) {
+ refresh()
+ return
+ }
_state.value = UiState.LoggedOut
}
@@ -1829,6 +1882,10 @@ class MainViewModel(app: Application) : AndroidViewModel(app) {
_feed.value = FeedState()
_search.value = SearchState()
_youtubeHome.value = YouTubeHomeState()
+ sourceNewJob?.cancel()
+ sourceRadioJob?.cancel()
+ _sourceNew.value = SourceRowsState()
+ _sourceRadio.value = SourceRowsState()
_state.value = UiState.Loading
if (container.activeBackend.id == BackendId.SPOTIFY && container.spotifySignedIn) {
PlaybackService.connect(getApplication())
diff --git a/app/src/main/java/dev/lelonio/square/ui/SquareApp.kt b/app/src/main/java/dev/lelonio/square/ui/SquareApp.kt
index e61fe6f..c853283 100644
--- a/app/src/main/java/dev/lelonio/square/ui/SquareApp.kt
+++ b/app/src/main/java/dev/lelonio/square/ui/SquareApp.kt
@@ -819,6 +819,13 @@ fun SquareApp(
val backendChosen by preferences.backendChosen.collectAsStateWithLifecycle()
val backend by preferences.backend.collectAsStateWithLifecycle()
val youtubeHome by viewModel.youtubeHome.collectAsStateWithLifecycle()
+ val sourceNew by viewModel.sourceNew.collectAsStateWithLifecycle()
+ val sourceRadio by viewModel.sourceRadio.collectAsStateWithLifecycle()
+ // Whether YouTube Music knows whose it is, for the pages that suggest
+ // signing in when it does not.
+ val youtubeAccountName by remember(context) {
+ (context.applicationContext as dev.lelonio.square.SquareApplication).youtubeAccount.accountName
+ }.collectAsStateWithLifecycle()
// What is kept on the phone. Read here rather than inside the pages that
// draw it, because the same answer is wanted by the playlist button, the
// track rows and the track menu, and one collection is one recomposition.
@@ -1512,6 +1519,11 @@ fun SquareApp(
},
onPickYouTubeChip = viewModel::selectYouTubeChip,
onLoadMoreYouTube = viewModel::loadMoreYouTubeHome,
+ youtubeSignedIn = youtubeAccountName != null,
+ onYouTubeSignIn = { showYouTubeLogin = true },
+ onUseYouTube = {
+ preferences.setBackend(dev.lelonio.square.backend.BackendId.YOUTUBE_MUSIC)
+ },
onOpenSettings = { navController.navigate(Routes.SETTINGS) },
friends = friends,
onOpenFriends = {
@@ -1525,6 +1537,24 @@ fun SquareApp(
}
composable(Routes.NEW) {
+ // A source that lays out its own page of what is new
+ // gets that page; the one below is built out of
+ // Spotify's gateway and has nothing to show for any
+ // other catalogue.
+ if (backend != dev.lelonio.square.backend.BackendId.SPOTIFY) {
+ LaunchedEffect(backend) { viewModel.loadSourceNew() }
+ dev.lelonio.square.ui.home.SourceRowsPage(
+ title = newLabel,
+ rows = sourceNew.rows,
+ loading = sourceNew.loading,
+ contentPadding = listPadding,
+ onPlay = { tracks, index ->
+ onPlay(tracks, index, null, false, newLabel, 0L)
+ },
+ onOpen = { navController.openPlaylist(viewModel, it) },
+ )
+ return@composable
+ }
LaunchedEffect(Unit) {
viewModel.loadNewPage()
viewModel.loadBrowse()
@@ -1554,6 +1584,21 @@ fun SquareApp(
}
composable(Routes.RADIO) {
+ // The same for the stations; see the New tab above.
+ if (backend != dev.lelonio.square.backend.BackendId.SPOTIFY) {
+ LaunchedEffect(backend) { viewModel.loadSourceRadio() }
+ dev.lelonio.square.ui.home.SourceRowsPage(
+ title = stringResource(R.string.tab_radio),
+ rows = sourceRadio.rows,
+ loading = sourceRadio.loading,
+ contentPadding = listPadding,
+ onPlay = { tracks, index ->
+ onPlay(tracks, index, null, false, radioLabel, 0L)
+ },
+ onOpen = { navController.openPlaylist(viewModel, it) },
+ )
+ return@composable
+ }
LaunchedEffect(Unit) { viewModel.loadBrowse() }
RadioScreen(
seeds = radioSeeds,
@@ -1665,6 +1710,13 @@ fun SquareApp(
artists = followedArtists,
albums = savedAlbums,
onRetryOnline = viewModel::retryOnline,
+ signInHint = backend == dev.lelonio.square.backend.BackendId.YOUTUBE_MUSIC &&
+ youtubeAccountName == null,
+ onSignIn = { showYouTubeLogin = true },
+ onUseYouTube = {
+ preferences.setBackend(dev.lelonio.square.backend.BackendId.YOUTUBE_MUSIC)
+ },
+ onOpenSettings = { navController.navigate(Routes.SETTINGS) },
onOpenArtist = { artist ->
viewModel.openContext(
artist.uri,
@@ -3378,7 +3430,7 @@ fun SquareApp(
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(16.dp),
) {
- dev.lelonio.square.ui.components.AppIcon(84.dp)
+ dev.lelonio.square.ui.components.AppGlyph(64.dp)
dev.lelonio.square.ui.components.SquareWordmark(height = 28.dp)
// Which source is being opened, named and marked:
// the whole point of the wait is that the app is
diff --git a/app/src/main/java/dev/lelonio/square/ui/components/SignInHint.kt b/app/src/main/java/dev/lelonio/square/ui/components/SignInHint.kt
new file mode 100644
index 0000000..d7bd3ce
--- /dev/null
+++ b/app/src/main/java/dev/lelonio/square/ui/components/SignInHint.kt
@@ -0,0 +1,101 @@
+package dev.lelonio.square.ui.components
+
+import androidx.compose.foundation.background
+import androidx.compose.foundation.border
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.shape.CircleShape
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.material3.Icon
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.Text
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.draw.clip
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.res.stringResource
+import androidx.compose.ui.text.font.FontWeight
+import androidx.compose.ui.unit.dp
+import com.adamglin.PhosphorIcons
+import com.adamglin.phosphoricons.Fill
+import com.adamglin.phosphoricons.fill.YoutubeLogo
+import dev.lelonio.square.R
+import dev.lelonio.square.ui.glass.pressable
+import dev.lelonio.square.ui.theme.Ink
+import dev.lelonio.square.ui.theme.lightPage
+import dev.lelonio.square.ui.theme.pageGround
+
+/**
+ * What signing in to YouTube Music would add, where its absence shows.
+ *
+ * The source works without an account, and nothing here says otherwise: this
+ * is not a wall in front of the page but a card at the top of it. It sits on
+ * the pages that are thinner for the lack of one, the home page and the
+ * library, and says what arrives: the listener's own lists and mixes, and a
+ * home made for them rather than for the country.
+ *
+ * Drawn like an unlit filter chip, a shade off the ground with a hairline, and
+ * its one action in ink, so it reads as part of the page in either theme.
+ */
+@Composable
+fun SignInHint(onSignIn: () -> Unit, modifier: Modifier = Modifier) {
+ val shape = RoundedCornerShape(20.dp)
+ Column(
+ modifier
+ .fillMaxWidth()
+ .clip(shape)
+ .background(if (lightPage()) Color.White else Ink.copy(alpha = 0.07f))
+ .border(1.dp, Ink.copy(alpha = if (lightPage()) 0.07f else 0.09f), shape)
+ .padding(16.dp),
+ ) {
+ Row(verticalAlignment = Alignment.Top) {
+ Box(
+ Modifier
+ .size(36.dp)
+ .clip(CircleShape)
+ .background(Ink.copy(alpha = 0.06f)),
+ contentAlignment = Alignment.Center,
+ ) {
+ Icon(
+ PhosphorIcons.Fill.YoutubeLogo,
+ contentDescription = null,
+ tint = Ink,
+ modifier = Modifier.size(20.dp),
+ )
+ }
+ Text(
+ stringResource(R.string.youtube_sign_in_hint),
+ style = MaterialTheme.typography.bodyMedium,
+ color = Ink.copy(alpha = 0.8f),
+ modifier = Modifier
+ .weight(1f)
+ .padding(start = 12.dp, top = 1.dp),
+ )
+ }
+ Box(
+ Modifier
+ .padding(top = 14.dp)
+ .align(Alignment.End)
+ .pressable(onSignIn, pressedScale = 0.96f)
+ .height(38.dp)
+ .clip(CircleShape)
+ .background(Ink)
+ .padding(horizontal = 18.dp),
+ contentAlignment = Alignment.Center,
+ ) {
+ Text(
+ stringResource(R.string.youtube_sign_in),
+ style = MaterialTheme.typography.bodyMedium,
+ fontWeight = FontWeight.SemiBold,
+ color = pageGround(),
+ maxLines = 1,
+ )
+ }
+ }
+}
diff --git a/app/src/main/java/dev/lelonio/square/ui/components/SignedOutOptions.kt b/app/src/main/java/dev/lelonio/square/ui/components/SignedOutOptions.kt
new file mode 100644
index 0000000..f964691
--- /dev/null
+++ b/app/src/main/java/dev/lelonio/square/ui/components/SignedOutOptions.kt
@@ -0,0 +1,51 @@
+package dev.lelonio.square.ui.components
+
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.shape.CircleShape
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.Text
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.draw.clip
+import androidx.compose.ui.res.stringResource
+import androidx.compose.ui.text.font.FontWeight
+import androidx.compose.ui.unit.dp
+import dev.lelonio.square.R
+import dev.lelonio.square.ui.glass.pressable
+import dev.lelonio.square.ui.theme.InkDim
+
+/**
+ * The ways out of a page that only asks to sign in to Spotify.
+ *
+ * Signed out, that page has no header and so no way into the settings, which
+ * is where the source is chosen and the guide is shown again. Someone who
+ * picked Spotify by mistake, or skipped the guide meaning to come back to it,
+ * was left with one button leading to a service they may not have. These are
+ * the other two answers, quieter than the sign-in so it stays the obvious one.
+ */
+@Composable
+fun SignedOutOptions(onUseYouTube: () -> Unit, onOpenSettings: () -> Unit) {
+ Column(
+ horizontalAlignment = Alignment.CenterHorizontally,
+ modifier = Modifier.padding(top = 2.dp),
+ ) {
+ QuietLink(stringResource(R.string.use_youtube_music), onUseYouTube)
+ QuietLink(stringResource(R.string.settings), onOpenSettings)
+ }
+}
+
+@Composable
+private fun QuietLink(text: String, onClick: () -> Unit) {
+ Text(
+ text,
+ style = MaterialTheme.typography.bodyMedium,
+ fontWeight = FontWeight.SemiBold,
+ color = InkDim,
+ modifier = Modifier
+ .clip(CircleShape)
+ .pressable(onClick, shape = CircleShape)
+ .padding(horizontal = 16.dp, vertical = 10.dp),
+ )
+}
diff --git a/app/src/main/java/dev/lelonio/square/ui/components/Wordmark.kt b/app/src/main/java/dev/lelonio/square/ui/components/Wordmark.kt
index 5788b3a..bb5560c 100644
--- a/app/src/main/java/dev/lelonio/square/ui/components/Wordmark.kt
+++ b/app/src/main/java/dev/lelonio/square/ui/components/Wordmark.kt
@@ -4,18 +4,15 @@ import androidx.compose.foundation.Canvas
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Box
import androidx.compose.ui.draw.drawBehind
-import androidx.compose.foundation.Image
import androidx.compose.material3.Icon
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
-import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
-import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Path
import androidx.compose.ui.graphics.StrokeCap
@@ -212,20 +209,6 @@ fun AppGlyph(size: Dp, modifier: Modifier = Modifier, tint: Color = Ink) {
)
}
-@Composable
-fun AppIcon(size: Dp, modifier: Modifier = Modifier) {
- Image(
- // The adaptive icon's foreground, which is a plain PNG per density —
- // `ic_launcher` itself is the adaptive XML, which painterResource
- // cannot load.
- painter = painterResource(R.mipmap.ic_launcher_foreground),
- contentDescription = null,
- modifier = modifier
- .size(size)
- .clip(RoundedCornerShape(size * 0.26f)),
- )
-}
-
/** S Q U A R E, as polylines on the grid described in [SquareWordmark]. */
private val GLYPHS: List<List<List<Pair<Float, Float>>>> = listOf(
// S
diff --git a/app/src/main/java/dev/lelonio/square/ui/home/HomeScreen.kt b/app/src/main/java/dev/lelonio/square/ui/home/HomeScreen.kt
index 6e2235a..9cc76d3 100644
--- a/app/src/main/java/dev/lelonio/square/ui/home/HomeScreen.kt
+++ b/app/src/main/java/dev/lelonio/square/ui/home/HomeScreen.kt
@@ -52,6 +52,7 @@ import androidx.compose.ui.graphics.CompositingStrategy
import androidx.compose.ui.graphics.TransformOrigin
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.res.stringResource
+import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.Dp
@@ -75,7 +76,7 @@ import dev.lelonio.square.data.CatalogTrack
import dev.lelonio.square.data.SearchItem
import dev.lelonio.square.data.sortedByRecentlyOpened
import dev.lelonio.square.ui.MainViewModel
-import dev.lelonio.square.ui.components.AppIcon
+import dev.lelonio.square.ui.components.AppGlyph
import dev.lelonio.square.ui.components.AppLockup
import dev.lelonio.square.ui.components.Artwork
import dev.lelonio.square.ui.components.SquareWordmark
@@ -158,6 +159,11 @@ fun HomeScreen(
onPickYouTubeChip: (dev.lelonio.square.backend.HomeChip?) -> Unit = {},
/** Called from the bottom of the page: the next shelves, if there are any. */
onLoadMoreYouTube: () -> Unit = {},
+ /** Whether a Google account is signed in; the page suggests one otherwise. */
+ youtubeSignedIn: Boolean = true,
+ onYouTubeSignIn: () -> Unit = {},
+ /** Signed out of Spotify: play from the other source instead. */
+ onUseYouTube: () -> Unit = {},
/**
* Spotify's own personalised shelves, empty when the gateway said nothing.
*
@@ -180,13 +186,15 @@ fun HomeScreen(
onOpenSettings = onOpenSettings,
onPickChip = onPickYouTubeChip,
onLoadMore = onLoadMoreYouTube,
+ signedIn = youtubeSignedIn,
+ onSignIn = onYouTubeSignIn,
)
return
}
when (state) {
MainViewModel.UiState.LoggedOut -> Centered {
- AppIcon(84.dp)
+ AppGlyph(64.dp)
SquareWordmark(height = 28.dp)
Text(
stringResource(R.string.unofficial_client),
@@ -196,6 +204,7 @@ fun HomeScreen(
modifier = Modifier.padding(horizontal = 40.dp),
)
GlassAction(stringResource(R.string.log_in_with_spotify), backdrop, onLogIn)
+ dev.lelonio.square.ui.components.SignedOutOptions(onUseYouTube, onOpenSettings)
}
MainViewModel.UiState.Connecting,
@@ -1250,6 +1259,8 @@ private fun YouTubeHome(
onOpenSettings: () -> Unit,
onPickChip: (dev.lelonio.square.backend.HomeChip?) -> Unit,
onLoadMore: () -> Unit,
+ signedIn: Boolean,
+ onSignIn: () -> Unit,
) {
val empty = home.rows.isEmpty() && recent.isEmpty()
if (empty) {
@@ -1258,7 +1269,7 @@ private fun YouTubeHome(
if (home.loading) {
CircularProgressIndicator(color = Ink, strokeWidth = 2.dp)
} else {
- AppIcon(84.dp)
+ AppGlyph(64.dp)
SquareWordmark(height = 28.dp)
Text(
stringResource(R.string.youtube_home_empty),
@@ -1329,6 +1340,17 @@ private fun YouTubeHome(
bottom = contentPadding.calculateBottomPadding(),
),
) {
+ // First, above the page it would change: signed out, this is the
+ // country's home rather than the listener's.
+ if (!signedIn) {
+ item(key = "sign-in") {
+ dev.lelonio.square.ui.components.SignInHint(
+ onSignIn = onSignIn,
+ modifier = Modifier.padding(start = 20.dp, end = 20.dp, top = 12.dp, bottom = 4.dp),
+ )
+ }
+ }
+
// YouTube's own filters, where it sent any: each is a page in its own
// right rather than a sieve over this one.
if (home.chips.isNotEmpty()) {
@@ -1418,6 +1440,81 @@ private fun YouTubeHome(
}
}
+/**
+ * One of the other tabs, for a source that lays its own pages out.
+ *
+ * The rows as the service sent them, drawn the way its home page is: a long
+ * shelf of songs as quick picks, a short one as tiles, and everything else as
+ * covers to open. New and Radio are both this page; what differs is which rows
+ * the source was asked for. See MusicBackend.newRows.
+ */
+@Composable
+fun SourceRowsPage(
+ title: String,
+ rows: List<dev.lelonio.square.backend.HomeRow>,
+ loading: Boolean,
+ contentPadding: PaddingValues,
+ onPlay: (List<CatalogTrack>, Int) -> Unit,
+ onOpen: (CatalogPlaylist) -> Unit,
+) {
+ if (rows.isEmpty()) {
+ Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
+ if (loading) {
+ CircularProgressIndicator(color = Ink, strokeWidth = 2.dp)
+ } else {
+ Text(
+ stringResource(R.string.nothing_here),
+ style = MaterialTheme.typography.bodyMedium,
+ color = InkDim,
+ )
+ }
+ }
+ return
+ }
+
+ LazyColumn(
+ contentPadding = PaddingValues(
+ top = contentPadding.calculateTopPadding() + 8.dp,
+ bottom = contentPadding.calculateBottomPadding() + 24.dp,
+ ),
+ ) {
+ item(key = "title") {
+ Text(
+ title,
+ style = MaterialTheme.typography.displaySmall,
+ fontWeight = FontWeight.Bold,
+ modifier = Modifier.padding(start = 20.dp, top = 6.dp),
+ )
+ }
+
+ rows.forEachIndexed { index, row ->
+ item(key = "head-$index-${row.title}") { Heading(row.title, row.strapline) }
+ if (row.tracks.isNotEmpty()) {
+ item(key = "tracks-$index-${row.title}") {
+ if (row.tracks.size >= QUICK_PICK_MINIMUM) {
+ QuickPicks(row.tracks) { i -> onPlay(row.tracks, i) }
+ } else {
+ TrackRow(row.tracks) { i -> onPlay(row.tracks, i) }
+ }
+ }
+ }
+ if (row.items.isNotEmpty()) {
+ item(key = "items-$index-${row.title}") {
+ LazyRow(
+ contentPadding = PaddingValues(horizontal = 20.dp),
+ horizontalArrangement = Arrangement.spacedBy(12.dp),
+ modifier = Modifier.padding(top = 14.dp),
+ ) {
+ items(row.items, key = { it.uri }) { entry ->
+ PlaylistTile(entry) { onOpen(entry) }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
/**
* The YouTube page's header.
*
diff --git a/app/src/main/java/dev/lelonio/square/ui/library/LibraryScreen.kt b/app/src/main/java/dev/lelonio/square/ui/library/LibraryScreen.kt
index 2a422aa..890a872 100644
--- a/app/src/main/java/dev/lelonio/square/ui/library/LibraryScreen.kt
+++ b/app/src/main/java/dev/lelonio/square/ui/library/LibraryScreen.kt
@@ -136,11 +136,24 @@ fun LibraryScreen(
albums: List<CatalogPlaylist> = emptyList(),
/** Tries the servers again from the offline banner; null hides the button. */
onRetryOnline: (suspend () -> Boolean)? = null,
+ /**
+ * Suggest signing in to the source's account: the library is the page an
+ * account fills, so it is the first place its absence shows.
+ */
+ signInHint: Boolean = false,
+ onSignIn: () -> Unit = {},
+ /** Signed out of Spotify: the other source, and the settings; see SignedOutOptions. */
+ onUseYouTube: () -> Unit = {},
+ onOpenSettings: () -> Unit = {},
backdrop: Backdrop,
) {
when (state) {
+ // The same page the home tab shows signed out, mark and all: the two
+ // are one state reached from two tabs, and a plain title here made
+ // them read as two different apps.
MainViewModel.UiState.LoggedOut -> Centered {
- Text(stringResource(R.string.app_name), style = MaterialTheme.typography.displayLarge)
+ dev.lelonio.square.ui.components.AppGlyph(64.dp)
+ dev.lelonio.square.ui.components.SquareWordmark(height = 28.dp)
Text(
stringResource(R.string.unofficial_client),
style = MaterialTheme.typography.bodyMedium,
@@ -149,6 +162,7 @@ fun LibraryScreen(
modifier = Modifier.padding(horizontal = 40.dp),
)
GlassAction(stringResource(R.string.log_in_with_spotify), backdrop, onLogIn)
+ dev.lelonio.square.ui.components.SignedOutOptions(onUseYouTube, onOpenSettings)
}
MainViewModel.UiState.Connecting,
@@ -316,6 +330,12 @@ fun LibraryScreen(
dev.lelonio.square.ui.components.OfflineNotice(onRetry = onRetryOnline)
}
+ if (signInHint) {
+ item(span = { GridItemSpan(maxLineSpan) }, key = "sign-in") {
+ dev.lelonio.square.ui.components.SignInHint(onSignIn = onSignIn)
+ }
+ }
+
if (artists.isNotEmpty() && filter == Filter.ALL) {
item(span = { GridItemSpan(maxLineSpan) }, key = "artists") {
ArtistShelf(artists, onOpenArtist)
@@ -365,6 +385,15 @@ fun LibraryScreen(
dev.lelonio.square.ui.components.OfflineNotice(onRetry = onRetryOnline)
}
+ if (signInHint) {
+ item(key = "sign-in") {
+ dev.lelonio.square.ui.components.SignInHint(
+ onSignIn = onSignIn,
+ modifier = Modifier.padding(horizontal = 20.dp, vertical = 6.dp),
+ )
+ }
+ }
+
if (artists.isNotEmpty() && filter == Filter.ALL) {
item(key = "artists") { ArtistShelf(artists, onOpenArtist) }
}
diff --git a/app/src/main/java/dev/lelonio/square/ui/onboarding/BackendChoiceScreen.kt b/app/src/main/java/dev/lelonio/square/ui/onboarding/BackendChoiceScreen.kt
index e0fdfa6..9e9a370 100644
--- a/app/src/main/java/dev/lelonio/square/ui/onboarding/BackendChoiceScreen.kt
+++ b/app/src/main/java/dev/lelonio/square/ui/onboarding/BackendChoiceScreen.kt
@@ -35,7 +35,7 @@ import com.adamglin.phosphoricons.fill.YoutubeLogo
import com.adamglin.phosphoricons.regular.CaretRight
import dev.lelonio.square.R
import dev.lelonio.square.backend.BackendId
-import dev.lelonio.square.ui.components.AppIcon
+import dev.lelonio.square.ui.components.AppGlyph
import dev.lelonio.square.ui.components.SquareWordmark
import dev.lelonio.square.ui.glass.pressable
import dev.lelonio.square.ui.theme.Ink
@@ -74,7 +74,7 @@ fun BackendChoiceScreen(onChoose: (BackendId) -> Unit) {
) {
Column {
Spacer(Modifier.height(8.dp))
- AppIcon(72.dp)
+ AppGlyph(56.dp)
Spacer(Modifier.height(20.dp))
SquareWordmark(height = 24.dp)
StepHeader(stringResource(R.string.backend_choice_title))
diff --git a/app/src/main/java/dev/lelonio/square/ui/onboarding/OnboardingScreen.kt b/app/src/main/java/dev/lelonio/square/ui/onboarding/OnboardingScreen.kt
index 9e05571..805a1e9 100644
--- a/app/src/main/java/dev/lelonio/square/ui/onboarding/OnboardingScreen.kt
+++ b/app/src/main/java/dev/lelonio/square/ui/onboarding/OnboardingScreen.kt
@@ -45,7 +45,7 @@ import com.adamglin.phosphoricons.regular.ArrowUpRight
import dev.lelonio.square.R
import dev.lelonio.square.data.AppLanguages
import dev.lelonio.square.ui.MainViewModel
-import dev.lelonio.square.ui.components.AppIcon
+import dev.lelonio.square.ui.components.AppGlyph
import dev.lelonio.square.ui.components.FilterChip
import dev.lelonio.square.ui.components.SquareWordmark
import dev.lelonio.square.ui.theme.Ink
@@ -156,7 +156,7 @@ private fun stepOf(index: Int): String = stringResource(R.string.onboarding_step
@Composable
private fun Welcome(language: String, onLanguage: (String) -> Unit) {
Spacer(Modifier.height(20.dp))
- AppIcon(88.dp)
+ AppGlyph(64.dp)
Spacer(Modifier.height(22.dp))
SquareWordmark(height = 28.dp)
ProseText(stringResource(R.string.onboarding_welcome_1))
@@ -315,7 +315,7 @@ private fun ClientId(
@Composable
private fun Done() {
Spacer(Modifier.height(20.dp))
- AppIcon(72.dp)
+ AppGlyph(56.dp)
StepHeader(stringResource(R.string.onboarding_done_title))
ProseText(stringResource(R.string.onboarding_done_1))
ProseText(stringResource(R.string.onboarding_done_2))
diff --git a/app/src/main/java/dev/lelonio/square/ui/player/PlayerPanel.kt b/app/src/main/java/dev/lelonio/square/ui/player/PlayerPanel.kt
index fb8e24f..96438e8 100644
--- a/app/src/main/java/dev/lelonio/square/ui/player/PlayerPanel.kt
+++ b/app/src/main/java/dev/lelonio/square/ui/player/PlayerPanel.kt
@@ -407,9 +407,113 @@ internal fun EffectsPanel(
onChange = onReverb,
onReset = { onReverb(0f) },
)
+
+ SleepTimerRow()
}
}
+/**
+ * When to stop, under the things that change how it sounds.
+ *
+ * Here rather than in the settings because it is about the song playing now,
+ * like everything else in this panel, and because it is set from bed. What it
+ * sets lives in the service; see SleepTimer.
+ */
+@Composable
+private fun SleepTimerRow() {
+ val endsAt by dev.lelonio.square.playback.SleepTimer.endsAt.collectAsStateWithLifecycle()
+ val chosen by dev.lelonio.square.playback.SleepTimer.minutes.collectAsStateWithLifecycle()
+ val atTrackEnd by dev.lelonio.square.playback.SleepTimer.atTrackEnd.collectAsStateWithLifecycle()
+
+ // Read once a second while something is running, and not at all otherwise:
+ // a clock nobody set should cost nothing.
+ var left by remember { mutableStateOf(dev.lelonio.square.playback.SleepTimer.remaining()) }
+ LaunchedEffect(endsAt) {
+ while (endsAt != null) {
+ left = dev.lelonio.square.playback.SleepTimer.remaining()
+ kotlinx.coroutines.delay(1_000)
+ }
+ left = null
+ }
+
+ Text(
+ stringResource(R.string.sleep_timer),
+ style = MaterialTheme.typography.labelLarge,
+ color = GlassInkDim,
+ modifier = Modifier.padding(top = 24.dp, bottom = 8.dp),
+ )
+
+ Row(
+ Modifier
+ .fillMaxWidth()
+ .horizontalScroll(rememberScrollState()),
+ horizontalArrangement = Arrangement.spacedBy(8.dp),
+ verticalAlignment = Alignment.CenterVertically,
+ ) {
+ SleepChip(
+ label = stringResource(R.string.off),
+ selected = endsAt == null && !atTrackEnd,
+ onClick = { dev.lelonio.square.playback.SleepTimer.cancel() },
+ )
+ SleepLengths.forEach { minutes ->
+ SleepChip(
+ label = stringResource(R.string.sleep_timer_minutes, minutes),
+ selected = chosen == minutes,
+ onClick = { dev.lelonio.square.playback.SleepTimer.inMinutes(minutes) },
+ )
+ }
+ SleepChip(
+ label = stringResource(R.string.sleep_timer_track_end),
+ selected = atTrackEnd,
+ onClick = { dev.lelonio.square.playback.SleepTimer.atEndOfTrack() },
+ )
+ }
+
+ // What the chosen chip means, in words and counting down: a lit chip says
+ // which length was asked for, not how much of it is left.
+ val running = left
+ if (atTrackEnd || running != null) {
+ Text(
+ if (atTrackEnd) {
+ stringResource(R.string.sleep_timer_track_end_active)
+ } else {
+ stringResource(
+ R.string.sleep_timer_left,
+ dev.lelonio.square.ui.library.formatDuration(running ?: 0L),
+ )
+ },
+ style = MaterialTheme.typography.bodySmall,
+ color = GlassInkDim,
+ modifier = Modifier.padding(top = 10.dp),
+ )
+ }
+}
+
+/** A chip of the timer row, drawn like the preset chips above it. */
+@Composable
+private fun SleepChip(label: String, selected: Boolean, onClick: () -> Unit) {
+ Text(
+ label,
+ style = MaterialTheme.typography.bodySmall,
+ maxLines = 1,
+ color = if (selected) GlassInk else GlassInkDim,
+ modifier = Modifier
+ .clip(RoundedCornerShape(50))
+ .background(
+ if (selected) {
+ MaterialTheme.colorScheme.primary
+ } else {
+ MaterialTheme.colorScheme.background
+ },
+ )
+ .pressable(onClick, pressedScale = 0.94f)
+ .padding(horizontal = 14.dp, vertical = 8.dp),
+ )
+}
+
+/** The lengths offered, which are the ones every player offers. */
+private val SleepLengths = listOf(5, 15, 30, 45, 60)
+
/**
* The preset chips.
*
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.kt
index a5b6157..edfb19e 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
@@ -161,6 +161,9 @@ private const val PAUSED_DIM = 0.55f
* Matched to the clip's own fade below: the two are one movement, and a
* handover where each half runs at its own speed is visible as a dip.
*/
+/** How far the picture behind an open panel goes down. */
+private const val PANEL_DIM = 0.26f
+
private const val CANVAS_HANDOVER = 500
/** The shape the catalogue files an extended cover in: three by four. */
@@ -411,6 +414,16 @@ fun PlayerScreen(
label = "canvasBlur",
)
+ // And a little darker with it. Blur takes the detail out of what is behind
+ // a panel but not the light: on a bright sleeve the words of a lyric sat on
+ // a white glow. A clip has a dimmer of its own below, for the same reason
+ // and on the same signal.
+ val panelDim by animateFloatAsState(
+ targetValue = if (panelOpen) PANEL_DIM else 0f,
+ animationSpec = tween(320),
+ label = "panelDim",
+ )
+
// The video's own light, sampled by the stage below and spread over the
// whole screen from here — the way an ambient television lights the wall
// behind it rather than just its own frame. Null whenever no video is
@@ -736,6 +749,18 @@ fun PlayerScreen(
)
}
}
+
+ // The panel's own shade over the picture, inside the recorded layer
+ // so the glass above refracts what the reader sees rather than the
+ // bright original. Not over a Canvas: that one is darkened by the
+ // gradient above, which already answers an open panel.
+ if (panelDim > 0f && canvas == null) {
+ Box(
+ Modifier
+ .fillMaxSize()
+ .background(Color.Black.copy(alpha = panelDim)),
+ )
+ }
}
CompositionLocalProvider(LocalContentColor provides GlassInk) {
diff --git a/app/src/main/java/dev/lelonio/square/ui/settings/SettingsScreen.kt b/app/src/main/java/dev/lelonio/square/ui/settings/SettingsScreen.kt
index 660c8f6..ffb2b97 100644
--- a/app/src/main/java/dev/lelonio/square/ui/settings/SettingsScreen.kt
+++ b/app/src/main/java/dev/lelonio/square/ui/settings/SettingsScreen.kt
@@ -407,7 +407,10 @@ fun SettingsScreen(
}
}
- if (ready != null && open == SettingsPage.Account) {
+ // Spotify's sign-out, so only while Spotify is the source. On YouTube
+ // Music the account section above has its own, and this one signed the
+ // app out of Spotify from a page about a Google account.
+ if (ready != null && open == SettingsPage.Account && showSpotify) {
item("logout") {
Section(null) {
ActionRow(stringResource(R.string.log_out), destructive = true, onClick = onLogOut)
diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml
index e0d3030..2350b00 100644
--- a/app/src/main/res/values-de/strings.xml
+++ b/app/src/main/res/values-de/strings.xml
@@ -132,6 +132,11 @@
<string name="speed">Tempo</string>
<string name="pitch">Tonhöhe</string>
<string name="reverb">Hall</string>
+ <string name="sleep_timer">Sleep-Timer</string>
+ <string name="sleep_timer_minutes">%1$d Min.</string>
+ <string name="sleep_timer_track_end">Ende des Titels</string>
+ <string name="sleep_timer_left">Stoppt in %1$s</string>
+ <string name="sleep_timer_track_end_active">Stoppt am Ende dieses Titels</string>
<string name="save_preset">Voreinstellung speichern</string>
<string name="delete_preset">%1$s löschen</string>
<string name="shuffle_play">Zufallswiedergabe</string>
@@ -260,6 +265,8 @@
<string name="popular_playlists">Beliebte Playlists</string>
<string name="youtube_account">YouTube-Konto</string>
<string name="youtube_sign_in">Mit Google anmelden</string>
+ <string name="use_youtube_music">Mit YouTube Music hören</string>
+ <string name="youtube_sign_in_hint">Melde dich mit deinem Google-Konto an, um deine Bibliothek, deine Mixe und Empfehlungen für dich zu bekommen.</string>
<string name="youtube_channel">Kanal</string>
<string name="youtube_session_expired">Sitzung abgelaufen</string>
<string name="youtube_sign_in_again">Erneut anmelden</string>
diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml
index 4aed557..3efa57a 100644
--- a/app/src/main/res/values-es/strings.xml
+++ b/app/src/main/res/values-es/strings.xml
@@ -132,6 +132,11 @@
<string name="speed">Velocidad</string>
<string name="pitch">Tono</string>
<string name="reverb">Reverberación</string>
+ <string name="sleep_timer">Temporizador</string>
+ <string name="sleep_timer_minutes">%1$d min</string>
+ <string name="sleep_timer_track_end">Fin de la canción</string>
+ <string name="sleep_timer_left">Se para en %1$s</string>
+ <string name="sleep_timer_track_end_active">Se para al final de la canción</string>
<string name="save_preset">Guardar ajuste</string>
<string name="delete_preset">Eliminar %1$s</string>
<string name="shuffle_play">Reproducción aleatoria</string>
@@ -260,6 +265,8 @@
<string name="popular_playlists">Listas populares</string>
<string name="youtube_account">Cuenta de YouTube</string>
<string name="youtube_sign_in">Iniciar sesión con Google</string>
+ <string name="use_youtube_music">Escuchar desde YouTube Music</string>
+ <string name="youtube_sign_in_hint">Inicia sesión con tu cuenta de Google para traer tu biblioteca, tus mixes y recomendaciones hechas para ti.</string>
<string name="youtube_channel">Canal</string>
<string name="youtube_session_expired">Sesión caducada</string>
<string name="youtube_sign_in_again">Vuelve a acceder</string>
diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml
index 5d827d7..02ee43c 100644
--- a/app/src/main/res/values-fr/strings.xml
+++ b/app/src/main/res/values-fr/strings.xml
@@ -132,6 +132,11 @@
<string name="speed">Vitesse</string>
<string name="pitch">Hauteur</string>
<string name="reverb">Réverbération</string>
+ <string name="sleep_timer">Minuteur</string>
+ <string name="sleep_timer_minutes">%1$d min</string>
+ <string name="sleep_timer_track_end">Fin du morceau</string>
+ <string name="sleep_timer_left">S\'arrête dans %1$s</string>
+ <string name="sleep_timer_track_end_active">S\'arrête à la fin du morceau</string>
<string name="save_preset">Enregistrer le préréglage</string>
<string name="delete_preset">Supprimer %1$s</string>
<string name="shuffle_play">Lecture aléatoire</string>
@@ -260,6 +265,8 @@
<string name="popular_playlists">Playlists populaires</string>
<string name="youtube_account">Compte YouTube</string>
<string name="youtube_sign_in">Se connecter avec Google</string>
+ <string name="use_youtube_music">Écouter avec YouTube Music</string>
+ <string name="youtube_sign_in_hint">Connectez-vous avec votre compte Google pour retrouver votre bibliothèque, vos mix et des recommandations faites pour vous.</string>
<string name="youtube_channel">Chaîne</string>
<string name="youtube_session_expired">Session expirée</string>
<string name="youtube_sign_in_again">Se reconnecter</string>
diff --git a/app/src/main/res/values-hi/strings.xml b/app/src/main/res/values-hi/strings.xml
index 3f389a2..0aefc61 100644
--- a/app/src/main/res/values-hi/strings.xml
+++ b/app/src/main/res/values-hi/strings.xml
@@ -142,6 +142,11 @@
<string name="speed">गति</string>
<string name="pitch">पिच</string>
<string name="reverb">रीवर्ब</string>
+ <string name="sleep_timer">स्लीप टाइमर</string>
+ <string name="sleep_timer_minutes">%1$d मिनट</string>
+ <string name="sleep_timer_track_end">गाने के अंत में</string>
+ <string name="sleep_timer_left">%1$s में रुकेगा</string>
+ <string name="sleep_timer_track_end_active">इस गाने के अंत में रुकेगा</string>
<string name="save_preset">प्रीसेट सहेजें</string>
<string name="delete_preset">%1$s मिटाएँ</string>
<string name="shuffle_play">शफ़ल</string>
@@ -275,6 +280,8 @@
<string name="popular_playlists">लोकप्रिय प्लेलिस्ट</string>
<string name="youtube_account">YouTube खाता</string>
<string name="youtube_sign_in">Google से साइन इन करें</string>
+ <string name="use_youtube_music">YouTube Music से सुनें</string>
+ <string name="youtube_sign_in_hint">अपनी लाइब्रेरी, अपने मिक्स और आपके लिए बनी सिफ़ारिशें पाने के लिए अपने Google खाते से साइन इन करें।</string>
<string name="youtube_channel">चैनल</string>
<string name="youtube_session_expired">सत्र समाप्त हो गया</string>
<string name="youtube_sign_in_again">फिर से साइन इन करें</string>
diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml
index 968ca4f..f7153fa 100644
--- a/app/src/main/res/values-it/strings.xml
+++ b/app/src/main/res/values-it/strings.xml
@@ -133,6 +133,11 @@
<string name="speed">Velocità</string>
<string name="pitch">Tonalità</string>
<string name="reverb">Riverbero</string>
+ <string name="sleep_timer">Timer di spegnimento</string>
+ <string name="sleep_timer_minutes">%1$d min</string>
+ <string name="sleep_timer_track_end">Fine del brano</string>
+ <string name="sleep_timer_left">Si ferma tra %1$s</string>
+ <string name="sleep_timer_track_end_active">Si ferma alla fine del brano</string>
<string name="save_preset">Salva preimpostazione</string>
<string name="delete_preset">Elimina %1$s</string>
<string name="shuffle_play">Riproduzione casuale</string>
@@ -261,6 +266,8 @@
<string name="popular_playlists">Playlist popolari</string>
<string name="youtube_account">Account YouTube</string>
<string name="youtube_sign_in">Accedi con Google</string>
+ <string name="use_youtube_music">Ascolta da YouTube Music</string>
+ <string name="youtube_sign_in_hint">Accedi con il tuo account Google per avere la tua libreria, i tuoi mix e consigli fatti per te.</string>
<string name="youtube_channel">Canale</string>
<string name="youtube_session_expired">Sessione scaduta</string>
<string name="youtube_sign_in_again">Accedi di nuovo</string>
diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml
index 5e7209c..facb518 100644
--- a/app/src/main/res/values-pt/strings.xml
+++ b/app/src/main/res/values-pt/strings.xml
@@ -132,6 +132,11 @@
<string name="speed">Velocidade</string>
<string name="pitch">Tom</string>
<string name="reverb">Reverb</string>
+ <string name="sleep_timer">Temporizador</string>
+ <string name="sleep_timer_minutes">%1$d min</string>
+ <string name="sleep_timer_track_end">Fim da música</string>
+ <string name="sleep_timer_left">Para em %1$s</string>
+ <string name="sleep_timer_track_end_active">Para no fim desta música</string>
<string name="save_preset">Salvar predefinição</string>
<string name="delete_preset">Excluir %1$s</string>
<string name="shuffle_play">Reprodução aleatória</string>
@@ -260,6 +265,8 @@
<string name="popular_playlists">Playlists populares</string>
<string name="youtube_account">Conta YouTube</string>
<string name="youtube_sign_in">Iniciar sessão com Google</string>
+ <string name="use_youtube_music">Ouvir no YouTube Music</string>
+ <string name="youtube_sign_in_hint">Entre com a sua conta Google para trazer a sua biblioteca, os seus mixes e recomendações feitas para si.</string>
<string name="youtube_channel">Canal</string>
<string name="youtube_session_expired">Sessão expirada</string>
<string name="youtube_sign_in_again">Iniciar sessão de novo</string>
diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml
index e80f00e..51a8468 100644
--- a/app/src/main/res/values-tr/strings.xml
+++ b/app/src/main/res/values-tr/strings.xml
@@ -142,6 +142,11 @@
<string name="speed">Hız</string>
<string name="pitch">Perde</string>
<string name="reverb">Yankı</string>
+ <string name="sleep_timer">Uyku zamanlayıcı</string>
+ <string name="sleep_timer_minutes">%1$d dk</string>
+ <string name="sleep_timer_track_end">Parça sonu</string>
+ <string name="sleep_timer_left">%1$s sonra durur</string>
+ <string name="sleep_timer_track_end_active">Bu parçanın sonunda durur</string>
<string name="save_preset">Ön ayarı kaydet</string>
<string name="delete_preset">%1$s ön ayarını sil</string>
<string name="shuffle_play">Karıştır</string>
@@ -275,6 +280,8 @@
<string name="popular_playlists">Popüler çalma listeleri</string>
<string name="youtube_account">YouTube hesabı</string>
<string name="youtube_sign_in">Google ile giriş yap</string>
+ <string name="use_youtube_music">YouTube Music ile dinle</string>
+ <string name="youtube_sign_in_hint">Kitaplığın, mikslerin ve sana özel öneriler için Google hesabınla giriş yap.</string>
<string name="youtube_channel">Kanal</string>
<string name="youtube_session_expired">Oturum sona erdi</string>
<string name="youtube_sign_in_again">Yeniden giriş yap</string>
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 08d4c6c..0b48f8d 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -148,6 +148,11 @@
<string name="speed">Speed</string>
<string name="pitch">Pitch</string>
<string name="reverb">Reverb</string>
+ <string name="sleep_timer">Sleep timer</string>
+ <string name="sleep_timer_minutes">%1$d min</string>
+ <string name="sleep_timer_track_end">End of track</string>
+ <string name="sleep_timer_left">Stops in %1$s</string>
+ <string name="sleep_timer_track_end_active">Stops at the end of this track</string>
<string name="save_preset">Save preset</string>
<string name="delete_preset">Delete %1$s</string>
<string name="shuffle_play">Shuffle</string>
@@ -281,6 +286,8 @@
<string name="popular_playlists">Popular playlists</string>
<string name="youtube_account">YouTube account</string>
<string name="youtube_sign_in">Sign in with Google</string>
+ <string name="use_youtube_music">Listen on YouTube Music instead</string>
+ <string name="youtube_sign_in_hint">Sign in with your Google account to bring in your library, your mixes and recommendations made for you.</string>
<string name="youtube_channel">Channel</string>
<string name="youtube_session_expired">Session expired</string>
<string name="youtube_sign_in_again">Sign in again</string>