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
Redesign the queue with sections, drag to reorder, swipe to remove and multi-select
Lelonio695290e596c8
diff --git a/app/build.gradle.kts b/app/build.gradle.ktsindex 47c58f9..e328ff0 100644--- a/app/build.gradle.kts+++ b/app/build.gradle.kts@@ -195,6 +195,7 @@ dependencies {implementation(libs.androidx.profileinstaller)implementation(libs.androidx.activity.compose)implementation(libs.androidx.browser)+ implementation(libs.reorderable)implementation(libs.androidx.security.crypto)implementation(libs.androidx.lifecycle.runtime.compose)implementation(libs.androidx.lifecycle.viewmodel.compose)diff --git a/app/src/main/java/dev/lelonio/square/ui/SquareApp.kt b/app/src/main/java/dev/lelonio/square/ui/SquareApp.ktindex e602ee5..26ddc7d 100644--- a/app/src/main/java/dev/lelonio/square/ui/SquareApp.kt+++ b/app/src/main/java/dev/lelonio/square/ui/SquareApp.kt@@ -524,6 +524,48 @@ fun SquareApp(player?.playbackParameters = params}}+ // What was last taken out of the queue, each with the place it had, kept+ // for a few seconds so it can be put back where it was.+ var queueUndo by remember {+ mutableStateOf<List<Pair<Int, androidx.media3.common.MediaItem>>?>(null)+ }+ LaunchedEffect(queueUndo) {+ if (queueUndo != null) {+ kotlinx.coroutines.delay(5_000)+ queueUndo = null+ }+ }+ val queueActions = dev.lelonio.square.ui.player.QueueActions(+ onPlay = { player?.seekTo(it, 0L) },+ onRemove = { indices ->+ player?.let { p ->+ // From the last up, so each index still points at its track.+ val taken = indices.distinct().sortedDescending()+ .filter { it in 0 until p.mediaItemCount }+ .map { it to p.getMediaItemAt(it) }+ taken.forEach { (at, _) -> p.removeMediaItem(at) }+ if (taken.isNotEmpty()) queueUndo = taken.reversed()+ }+ },+ onMove = { from, to -> player?.moveMediaItem(from, to) },+ onPlayNext = { indices ->+ player?.let { p ->+ // In their order, each just after the one moved before it.+ // Every one comes after the playing track, so moving one+ // leaves the places of those still to move as they were.+ val after = p.currentMediaItemIndex + 1+ indices.distinct().sorted().forEachIndexed { k, at -> p.moveMediaItem(at, after + k) }+ }+ },+ onUndo = queueUndo?.let { taken ->+ {+ // From the first down, so each goes back to the place it had.+ player?.let { p -> taken.forEach { (at, item) -> p.addMediaItem(minOf(at, p.mediaItemCount), item) } }+ queueUndo = null+ }+ },+ editable = remote == null,+ )// The playing record's own artwork, asked for once per track and cached.val nowPlayingArt by viewModel.nowPlayingArt.collectAsStateWithLifecycle()val nowPlayingArtPending by viewModel.nowPlayingArtPending.collectAsStateWithLifecycle()@@ -2945,7 +2987,7 @@ fun SquareApp(creditsLoading = creditsLoading,onWantCredits = viewModel::loadCredits,onPlayQueueItem = { player?.seekTo(it, 0L) },- onRemoveQueueItem = { player?.removeMediaItem(it) },+ queueActions = queueActions,reverb = reverb,// Speed and pitch are set as a pair because// PlaybackParameters carries both; changing onediff --git a/app/src/main/java/dev/lelonio/square/ui/player/DismissibleScreen.kt b/app/src/main/java/dev/lelonio/square/ui/player/DismissibleScreen.ktindex 1e852ab..443bdad 100644--- a/app/src/main/java/dev/lelonio/square/ui/player/DismissibleScreen.kt+++ b/app/src/main/java/dev/lelonio/square/ui/player/DismissibleScreen.kt@@ -3,6 +3,10 @@ package dev.lelonio.square.ui.playerimport androidx.compose.foundation.gestures.detectVerticalDragGesturesimport androidx.compose.foundation.layout.Boximport androidx.compose.runtime.Composable+import androidx.compose.runtime.CompositionLocalProvider+import androidx.compose.runtime.MutableState+import androidx.compose.runtime.mutableStateOf+import androidx.compose.runtime.staticCompositionLocalOfimport androidx.compose.runtime.rememberimport androidx.compose.ui.Modifierimport androidx.compose.ui.geometry.Offset@@ -32,7 +36,8 @@ import androidx.compose.ui.unit.dp* child fight over the same vertical axis; nested scroll gives a defined order —* the list gets the drag first, and only what it cannot use reaches this. So a* downward drag scrolls the content until it hits the top, and from there the- * same continuous movement closes the screen. The pointer input below covers the+ * same continuous movement used to close the screen; now only a drag that starts+ * at the top does, see onPostScroll. The pointer input below covers the* parts that do not scroll at all.*/@Composable@@ -49,14 +54,16 @@ fun DismissibleScreen(// Plain vars in a remembered holder rather than state: nothing recomposes on// them, they only have to survive between drag events.val travel = remember { Travel() }+ val lock = remember { mutableStateOf(false) }fun reset() {travel.distance = 0ftravel.fired = false+ travel.scrolled = null}fun drag(amount: Float) {- if (travel.fired) return+ if (travel.fired || lock.value) return// Upward movement gives the accumulated distance back instead of going// negative, so a drag that wanders up and down does not close the player// on its total rather than its extent.@@ -82,7 +89,14 @@ fun DismissibleScreen(): Offset {// Only what the content could not use: at the top of the scroll// this is the whole drag, anywhere else it is nothing.- if (available.y > 0) {+ // Decided on the gesture's first movement: if that moved the+ // content, the gesture is a scroll to the end, and reaching the+ // top does not turn it into a close. Scrolling up the queue to+ // what was already played closed the player as soon as the list+ // ran out, in the same movement. Only a drag that starts with+ // the content already at the top closes it.+ if (travel.scrolled == null) travel.scrolled = consumed.y != 0f+ if (available.y > 0 && !lock.value && travel.scrolled == false) {drag(available.y)return Offset(0f, available.y)}@@ -110,13 +124,21 @@ fun DismissibleScreen(}},) {- content()+ CompositionLocalProvider(LocalDismissLock provides lock) { content() }}}+/**+ * Set by whatever inside takes a downward drag for its own, such as a queue row+ * being moved by its handle: while it holds, dragging down does not close.+ */+val LocalDismissLock = staticCompositionLocalOf<MutableState<Boolean>> { mutableStateOf(false) }+private class Travel {var distance = 0fvar fired = false+ /** Whether this gesture began by scrolling the content; null before it moves. */+ var scrolled: Boolean? = null}private val DISMISS_THRESHOLD = 110.dpdiff --git a/app/src/main/java/dev/lelonio/square/ui/player/PlayerPanel.kt b/app/src/main/java/dev/lelonio/square/ui/player/PlayerPanel.ktindex 06f59cd..0f8aac4 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@@ -265,111 +265,12 @@ data class QueueEntry(/** Already heard: shown above the playing track, dimmed. */val played: Boolean = false,val recommended: Boolean = false,+ /** Put in the queue by hand, as "play next": the "Next in queue" section. */+ val queued: Boolean = false,+ /** The playlist or album it came from, for the "Next from" heading. */+ val contextLabel: String = "",)-@Composable-internal fun QueueList(- queue: List<QueueEntry>,- onPlay: (Int) -> Unit,- /** Takes a track out of the queue; absent for the one playing. */- onRemove: (Int) -> Unit,-) {- if (queue.isEmpty()) {- EmptyPanel(stringResource(R.string.queue_empty))- return- }-- // Opens on the playing track, with what was heard above it out of view:- // history for whoever scrolls up, and the next songs where they always- // were for everyone else. Back to it on every change of song, as the list- // used to start there by having nothing before it.- val heard = queue.count { it.played }- val listState = rememberLazyListState(- initialFirstVisibleItemIndex = if (heard > 0) heard + 1 else 0,- )- val playingUri = queue.firstOrNull { it.isCurrent }?.uri- LaunchedEffect(playingUri, heard) {- listState.scrollToItem(if (heard > 0) heard + 1 else 0)- }-- LazyColumn(Modifier.padding(vertical = 8.dp), state = listState) {- if (heard > 0) {- item(key = "history-heading") {- Text(- stringResource(R.string.queue_history),- style = MaterialTheme.typography.labelLarge,- color = GlassInkDim,- modifier = Modifier.padding(start = 18.dp, top = 6.dp, bottom = 4.dp),- )- }- }- // Keyed on the track, not on where it sits.- //- // With the index as the key, taking one out renumbered every row below- // it — as far as the list is concerned each of those became a different- // item, so nothing could be animated and the queue jumped. Keyed on the- // track itself, the row that went is the only one that changes and the- // rest slide up into the gap.- itemsIndexed(- queue,- key = { at, entry -> "${entry.uri}-$at-${entry.title}" },- ) { _, entry ->- Row(- Modifier- .fillMaxWidth()- .animateItem()- .clickable { onPlay(entry.index) }- .padding(horizontal = 18.dp, vertical = 8.dp),- verticalAlignment = Alignment.CenterVertically,- ) {- Column(Modifier.weight(1f)) {- Text(- entry.title,- style = MaterialTheme.typography.titleMedium,- color = when {- entry.isCurrent -> GlassInk- entry.played -> GlassInk.copy(alpha = 0.45f)- else -> GlassInk.copy(alpha = 0.85f)- },- maxLines = 1,- overflow = TextOverflow.Ellipsis,- )- Row(verticalAlignment = Alignment.CenterVertically) {- if (entry.recommended) Icon(- PhosphorIcons.Regular.Sparkle,- contentDescription = stringResource(R.string.smart_shuffle),- tint = GlassInkDim,- modifier = Modifier.padding(end = 4.dp).size(12.dp),- )- Text(- entry.artist,- style = MaterialTheme.typography.bodySmall,- color = GlassInkDim,- maxLines = 1,- overflow = TextOverflow.Ellipsis,- )- }- }-- // Not on the track being played: taking that one out is a- // different act — it is a skip — and it already has a button.- if (!entry.isCurrent && !entry.played) {- Icon(- PhosphorIcons.Regular.X,- contentDescription = stringResource(R.string.remove_from_queue),- tint = GlassInkDim,- modifier = Modifier- .clip(RoundedCornerShape(50))- .pressable({ onRemove(entry.index) }, pressedScale = 0.86f)- .padding(10.dp)- .size(16.dp),- )- }- }- }- }-}-/*** Tempo, pitch and reverb.*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 2ccb588..e78e072 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@@ -236,8 +236,8 @@ fun PlayerScreen(/** Asked for when the credits panel is opened, and not before. */onWantCredits: (String?) -> Unit,onPlayQueueItem: (Int) -> Unit,- /** Drops one track out of the queue, by index. */- onRemoveQueueItem: (Int) -> Unit,+ /** Reordering, removing and the rest of what the queue sheet does. */+ queueActions: QueueActions,/** The music video for this track, when the catalogue has one. */videoFileId: String? = null,/** Whether the listener has asked to watch rather than listen. */@@ -1107,7 +1107,7 @@ fun PlayerScreen(}Stage.QUEUE -> Box(Modifier.fillMaxSize()) {- QueueList(queue, onPlayQueueItem, onRemoveQueueItem)+ QueueList(queue, queueActions)}Stage.DEVICES -> Box(diff --git a/app/src/main/java/dev/lelonio/square/ui/player/PlayerState.kt b/app/src/main/java/dev/lelonio/square/ui/player/PlayerState.ktindex 2e541ce..4233b56 100644--- a/app/src/main/java/dev/lelonio/square/ui/player/PlayerState.kt+++ b/app/src/main/java/dev/lelonio/square/ui/player/PlayerState.kt@@ -313,6 +313,8 @@ fun rememberQueue(player: Player?): State<List<QueueEntry>> {isCurrent = index == current,played = index < current,recommended = metadata.extras?.getBoolean(dev.lelonio.square.data.SmartShuffle.RECOMMENDED) == true,+ queued = metadata.extras?.getBoolean(dev.lelonio.square.ui.EXTRA_PLAY_NEXT) == true,+ contextLabel = metadata.extras?.getString(dev.lelonio.square.ui.EXTRA_CONTEXT_LABEL).orEmpty(),)}}diff --git a/app/src/main/java/dev/lelonio/square/ui/player/QueueList.kt b/app/src/main/java/dev/lelonio/square/ui/player/QueueList.ktnew file mode 100644index 0000000..e3a89bb--- /dev/null+++ b/app/src/main/java/dev/lelonio/square/ui/player/QueueList.kt@@ -0,0 +1,490 @@+package dev.lelonio.square.ui.player++import androidx.compose.animation.AnimatedVisibility+import androidx.compose.animation.core.animateFloatAsState+import androidx.compose.animation.fadeIn+import androidx.compose.animation.fadeOut+import androidx.compose.animation.slideInVertically+import androidx.compose.animation.slideOutVertically+import androidx.compose.foundation.ExperimentalFoundationApi+import androidx.compose.foundation.background+import androidx.compose.foundation.clickable+import androidx.compose.foundation.combinedClickable+import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.Row+import androidx.compose.foundation.layout.fillMaxHeight+import androidx.compose.foundation.layout.fillMaxSize+import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.layout.size+import androidx.compose.foundation.layout.width+import androidx.compose.foundation.lazy.LazyColumn+import androidx.compose.foundation.lazy.items+import androidx.compose.foundation.lazy.rememberLazyListState+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.SwipeToDismissBox+import androidx.compose.material3.SwipeToDismissBoxValue+import androidx.compose.material3.Text+import androidx.compose.material3.rememberSwipeToDismissBoxState+import androidx.compose.runtime.Composable+import androidx.compose.runtime.DisposableEffect+import androidx.compose.runtime.LaunchedEffect+import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableStateOf+import androidx.compose.runtime.remember+import androidx.compose.runtime.setValue+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.draw.clip+import androidx.compose.ui.hapticfeedback.HapticFeedbackType+import androidx.compose.ui.platform.LocalDensity+import androidx.compose.ui.platform.LocalHapticFeedback+import androidx.compose.ui.res.pluralStringResource+import androidx.compose.ui.res.stringResource+import androidx.compose.ui.text.font.FontWeight+import androidx.compose.ui.text.style.TextOverflow+import androidx.compose.ui.unit.dp+import com.adamglin.PhosphorIcons+import com.adamglin.phosphoricons.Bold+import com.adamglin.phosphoricons.Regular+import com.adamglin.phosphoricons.bold.Check+import com.adamglin.phosphoricons.regular.DotsSixVertical+import com.adamglin.phosphoricons.regular.Sparkle+import com.adamglin.phosphoricons.regular.Trash+import com.adamglin.phosphoricons.regular.X+import dev.lelonio.square.R+import dev.lelonio.square.ui.glass.pressable+import sh.calvin.reorderable.ReorderableItem+import sh.calvin.reorderable.rememberReorderableLazyListState++/** What the queue can do to the player; see SquareApp, which holds the player. */+class QueueActions(+ val onPlay: (Int) -> Unit,+ /** Player indices, in any order. */+ val onRemove: (List<Int>) -> Unit,+ /** From one player index to another. */+ val onMove: (Int, Int) -> Unit,+ /** Player indices, moved to just after the playing track, in their order. */+ val onPlayNext: (List<Int>) -> Unit,+ /** Puts back what was last taken out, while that is still possible. */+ val onUndo: (() -> Unit)? = null,+ /**+ * False while another device is playing: its queue is shown, and Spotify+ * does not let it be rearranged from here.+ */+ val editable: Boolean = true,+)++/**+ * The queue, as the big streaming apps have it.+ *+ * What was heard, above, for whoever scrolls up; the track playing; what was+ * queued by hand, with a way to clear it; and what follows from the playlist+ * or album. Every upcoming track can be dragged by its handle, swiped away,+ * or long-pressed to select several and move or remove them together.+ *+ * Rows are keyed on the track and how many times it has come before, never on+ * where they sit: keyed on the position, every change to the queue made every+ * row below it a new one, and the list drew the old and the new over each+ * other while it animated between them.+ */+@OptIn(ExperimentalFoundationApi::class)+@Composable+internal fun QueueList(queue: List<QueueEntry>, actions: QueueActions) {+ if (queue.isEmpty()) {+ EmptyPanel(stringResource(R.string.queue_empty))+ return+ }++ val occurrences = remember(queue) {+ val seen = HashMap<String, Int>()+ queue.map { entry ->+ val n = seen[entry.uri] ?: 0+ seen[entry.uri] = n + 1+ n+ }+ }+ fun keyOf(position: Int) = "${queue[position].uri}#${occurrences[position]}"++ val currentPosition = queue.indexOfFirst { it.isCurrent }+ val history = queue.filter { it.played }+ val current = queue.getOrNull(currentPosition)++ // The upcoming tracks as this screen holds them while one is being+ // dragged: moved here at every step, given to the player once on release.+ var upcoming by remember(queue) {+ mutableStateOf(+ queue.indices.filter { it > currentPosition && !queue[it].played }.map { keyOf(it) to queue[it] },+ )+ }+ var dragging by remember { mutableStateOf<String?>(null) }+ var selected by remember(queue) { mutableStateOf(emptySet<String>()) }+ val selecting = selected.isNotEmpty()+ val haptics = LocalHapticFeedback.current+ val dismissLock = LocalDismissLock.current+ // Closed mid-drag, the sheet would otherwise stay unable to close.+ DisposableEffect(Unit) { onDispose { dismissLock.value = false } }++ val listState = rememberLazyListState(+ initialFirstVisibleItemIndex = if (history.isNotEmpty()) history.size + 1 else 0,+ )+ LaunchedEffect(current?.uri, history.size) {+ listState.scrollToItem(if (history.isNotEmpty()) history.size + 1 else 0)+ }+ val reorder = rememberReorderableLazyListState(listState) { from, to ->+ val fromAt = upcoming.indexOfFirst { it.first == from.key }+ val toAt = upcoming.indexOfFirst { it.first == to.key }+ // Only among the upcoming tracks: headings, the playing track and the+ // history are not places a track can be dropped.+ if (fromAt < 0 || toAt < 0) return@rememberReorderableLazyListState+ upcoming = upcoming.toMutableList().apply { add(toAt, removeAt(fromAt)) }+ }++ // Where the upcoming tracks begin in the player's own order.+ val firstUpcomingIndex = (current?.index ?: -1) + 1+ val queuedCount = upcoming.count { it.second.queued }+ val contextLabel = upcoming.firstOrNull { !it.second.queued }?.second?.contextLabel+ ?: current?.contextLabel.orEmpty()++ Box(Modifier.fillMaxSize()) {+ LazyColumn(Modifier.padding(vertical = 8.dp), state = listState) {+ if (history.isNotEmpty()) {+ item(key = "history-heading") { Heading(stringResource(R.string.queue_history)) }+ items(queue.indices.filter { queue[it].played }, key = { "played:" + keyOf(it) }) { at ->+ TrackRow(queue[at], actions, selected = false, selecting = false, onLongPress = null, trailing = {})+ }+ }++ if (current != null) {+ item(key = "now-heading") { Heading(stringResource(R.string.queue_now_playing)) }+ item(key = "now:" + keyOf(currentPosition)) {+ TrackRow(current, actions, selected = false, selecting = false, onLongPress = null, trailing = {})+ }+ }++ upcoming.forEachIndexed { position, (key, entry) ->+ // A heading where a section starts: the hand-queued tracks+ // first, then what follows from the playlist.+ val previous = upcoming.getOrNull(position - 1)?.second+ if (entry.queued && (previous == null || !previous.queued)) {+ item(key = "queued-heading-$position") {+ Heading(+ stringResource(R.string.queue_next_in_queue),+ action = if (actions.editable && !selecting) stringResource(R.string.queue_clear) else null,+ onAction = {+ actions.onRemove(+ upcoming.mapIndexedNotNull { at, (_, it) ->+ (firstUpcomingIndex + at).takeIf { _ -> it.queued }+ },+ )+ },+ )+ }+ }+ if (!entry.queued && (previous == null || previous.queued)) {+ item(key = "context-heading-$position") {+ Heading(+ if (contextLabel.isNotEmpty()) {+ stringResource(R.string.queue_next_from, contextLabel)+ } else {+ stringResource(R.string.queue_next_up)+ },+ )+ }+ }+ item(key = key) {+ ReorderableItem(reorder, key = key) { isDragging ->+ // Lifted on a tinted card of its own: a shadow under a+ // see-through row drew a dark box behind its text.+ val lift by animateFloatAsState(if (isDragging) 1f else 0f, label = "queue lift")+ SwipeAway(+ enabled = actions.editable && !selecting && dragging == null,+ onSwiped = { actions.onRemove(listOf(entry.index)) },+ ) {+ TrackRow(+ entry = entry,+ actions = actions,+ selected = key in selected,+ selecting = selecting,+ modifier = Modifier+ .padding(horizontal = (8 * lift).dp)+ .clip(RoundedCornerShape(14.dp))+ .background(GlassInk.copy(alpha = 0.14f * lift)),+ onLongPress = if (actions.editable) {+ {+ haptics.performHapticFeedback(HapticFeedbackType.LongPress)+ selected = selected + key+ }+ } else {+ null+ },+ onToggle = { selected = if (key in selected) selected - key else selected + key },+ trailing = {+ if (actions.editable && !selecting) {+ Icon(+ PhosphorIcons.Regular.DotsSixVertical,+ contentDescription = stringResource(R.string.queue_reorder),+ tint = GlassInkDim,+ modifier = Modifier+ .draggableHandle(+ onDragStarted = {+ haptics.performHapticFeedback(HapticFeedbackType.LongPress)+ dragging = key+ dismissLock.value = true+ },+ onDragStopped = {+ val now = upcoming.indexOfFirst { it.first == key }+ dragging = null+ dismissLock.value = false+ if (now >= 0 && now != position) {+ actions.onMove(entry.index, firstUpcomingIndex + now)+ }+ },+ )+ .padding(10.dp)+ .size(20.dp),+ )+ }+ },+ )+ }+ }+ }+ }++ // Room for the bars that float over the bottom of the list.+ item(key = "end") { Box(Modifier.padding(bottom = if (selecting || actions.onUndo != null) 72.dp else 8.dp)) }+ }++ // Several selected: what can be done to them all at once.+ AnimatedVisibility(+ visible = selecting,+ enter = slideInVertically { it } + fadeIn(),+ exit = slideOutVertically { it } + fadeOut(),+ modifier = Modifier.align(Alignment.BottomCenter),+ ) {+ val indices = upcoming.mapIndexedNotNull { at, (key, _) ->+ (firstUpcomingIndex + at).takeIf { key in selected }+ }+ ActionBar(+ label = pluralStringResource(R.plurals.queue_selected, selected.size, selected.size),+ actions = listOf(+ stringResource(R.string.queue_play_next) to {+ actions.onPlayNext(indices)+ selected = emptySet()+ },+ stringResource(R.string.queue_remove) to {+ actions.onRemove(indices)+ selected = emptySet()+ },+ stringResource(R.string.cancel) to { selected = emptySet() },+ ),+ )+ }++ // Taken out by mistake: put back, for a few seconds.+ AnimatedVisibility(+ visible = !selecting && actions.onUndo != null,+ enter = slideInVertically { it } + fadeIn(),+ exit = slideOutVertically { it } + fadeOut(),+ modifier = Modifier.align(Alignment.BottomCenter),+ ) {+ ActionBar(+ label = stringResource(R.string.queue_removed),+ actions = listOf(stringResource(R.string.queue_undo) to { actions.onUndo?.invoke(); Unit }),+ )+ }+ }+}++@Composable+private fun Heading(text: String, action: String? = null, onAction: () -> Unit = {}) {+ Row(+ Modifier+ .fillMaxWidth()+ .padding(start = 18.dp, end = 8.dp, top = 12.dp, bottom = 4.dp),+ verticalAlignment = Alignment.CenterVertically,+ ) {+ Text(+ text,+ style = MaterialTheme.typography.labelLarge,+ color = GlassInkDim,+ maxLines = 1,+ overflow = TextOverflow.Ellipsis,+ modifier = Modifier.weight(1f),+ )+ if (action != null) {+ Text(+ action,+ style = MaterialTheme.typography.labelLarge,+ fontWeight = FontWeight.SemiBold,+ color = GlassInk,+ modifier = Modifier+ .clip(RoundedCornerShape(50))+ .clickable(onClick = onAction)+ .padding(horizontal = 10.dp, vertical = 4.dp),+ )+ }+ }+}++@OptIn(ExperimentalFoundationApi::class)+@Composable+private fun TrackRow(+ entry: QueueEntry,+ actions: QueueActions,+ selected: Boolean,+ selecting: Boolean,+ onLongPress: (() -> Unit)?,+ modifier: Modifier = Modifier,+ onToggle: () -> Unit = {},+ trailing: @Composable () -> Unit,+) {+ Row(+ modifier+ .fillMaxWidth()+ .background(if (selected) GlassInk.copy(alpha = 0.12f) else androidx.compose.ui.graphics.Color.Transparent)+ .combinedClickable(+ onClick = { if (selecting) onToggle() else actions.onPlay(entry.index) },+ onLongClick = onLongPress,+ )+ .padding(start = 18.dp, end = 6.dp, top = 6.dp, bottom = 6.dp),+ verticalAlignment = Alignment.CenterVertically,+ ) {+ if (selecting) {+ Box(+ Modifier+ .padding(end = 12.dp)+ .size(20.dp)+ .clip(CircleShape)+ .background(if (selected) GlassInk else GlassInk.copy(alpha = 0.15f)),+ contentAlignment = Alignment.Center,+ ) {+ if (selected) {+ Icon(+ PhosphorIcons.Bold.Check,+ contentDescription = null,+ tint = androidx.compose.ui.graphics.Color.Black,+ modifier = Modifier.size(12.dp),+ )+ }+ }+ }+ Column(Modifier.weight(1f)) {+ Text(+ entry.title,+ style = MaterialTheme.typography.titleMedium,+ color = when {+ entry.isCurrent -> GlassInk+ entry.played -> GlassInk.copy(alpha = 0.45f)+ else -> GlassInk.copy(alpha = 0.85f)+ },+ fontWeight = if (entry.isCurrent) FontWeight.SemiBold else null,+ maxLines = 1,+ overflow = TextOverflow.Ellipsis,+ )+ Row(verticalAlignment = Alignment.CenterVertically) {+ if (entry.recommended) {+ Icon(+ PhosphorIcons.Regular.Sparkle,+ contentDescription = stringResource(R.string.smart_shuffle),+ tint = GlassInkDim,+ modifier = Modifier.padding(end = 4.dp).size(12.dp),+ )+ }+ Text(+ entry.artist,+ style = MaterialTheme.typography.bodySmall,+ color = GlassInkDim,+ maxLines = 1,+ overflow = TextOverflow.Ellipsis,+ )+ }+ }+ trailing()+ }+}++/** Swiped towards the start, a row goes, over a red ground with a bin on it. */+@Composable+private fun SwipeAway(enabled: Boolean, onSwiped: () -> Unit, content: @Composable () -> Unit) {+ val state = rememberSwipeToDismissBoxState()+ SwipeToDismissBox(+ state = state,+ enableDismissFromStartToEnd = false,+ enableDismissFromEndToStart = enabled,+ gesturesEnabled = enabled,+ onDismiss = { value -> if (value == SwipeToDismissBoxValue.EndToStart) onSwiped() },+ backgroundContent = {+ // Only where the row has moved off: the rows are see-through, over+ // the glass, so a ground behind the whole row showed through it+ // before it was ever swiped.+ val revealed = with(LocalDensity.current) {+ (-(runCatching { state.requireOffset() }.getOrDefault(0f))).coerceAtLeast(0f).toDp()+ }+ Box(Modifier.fillMaxSize()) {+ if (revealed > 0.dp) {+ Box(+ Modifier+ .align(Alignment.CenterEnd)+ .fillMaxHeight()+ .width(revealed)+ .background(MaterialTheme.colorScheme.error.copy(alpha = 0.85f)),+ contentAlignment = Alignment.Center,+ ) {+ if (revealed > 44.dp) {+ Icon(+ PhosphorIcons.Regular.Trash,+ contentDescription = stringResource(R.string.remove_from_queue),+ tint = androidx.compose.ui.graphics.Color.White,+ modifier = Modifier.size(20.dp),+ )+ }+ }+ }+ }+ },+ ) { content() }+}++@Composable+private fun ActionBar(label: String, actions: List<Pair<String, () -> Unit>>) {+ Row(+ Modifier+ .padding(horizontal = 14.dp, vertical = 10.dp)+ .fillMaxWidth()+ .clip(RoundedCornerShape(22.dp))+ .background(GlassInk.copy(alpha = 0.92f))+ .padding(start = 16.dp, end = 6.dp, top = 6.dp, bottom = 6.dp),+ verticalAlignment = Alignment.CenterVertically,+ horizontalArrangement = Arrangement.spacedBy(2.dp),+ ) {+ val ground = MaterialTheme.colorScheme.surface+ Text(+ label,+ style = MaterialTheme.typography.bodyMedium,+ fontWeight = FontWeight.SemiBold,+ color = ground,+ maxLines = 1,+ overflow = TextOverflow.Ellipsis,+ modifier = Modifier.weight(1f),+ )+ actions.forEach { (text, onClick) ->+ Text(+ text,+ style = MaterialTheme.typography.labelLarge,+ fontWeight = FontWeight.SemiBold,+ color = ground,+ modifier = Modifier+ .clip(RoundedCornerShape(50))+ .pressable(onClick, pressedScale = 0.94f)+ .padding(horizontal = 10.dp, vertical = 8.dp),+ )+ }+ }+}diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xmlindex c408726..5ace5b6 100644--- a/app/src/main/res/values-de/strings.xml+++ b/app/src/main/res/values-de/strings.xml@@ -519,4 +519,18 @@<string name="telegram_community">Telegram-Community</string><string name="login_in_progress">Anmeldung bei Spotify läuft…</string><string name="login_channel">Anmeldung</string>+ <string name="queue_now_playing">Läuft gerade</string>+ <string name="queue_next_in_queue">Als Nächstes in der Warteschlange</string>+ <string name="queue_next_from">Als Nächstes aus: %1$s</string>+ <string name="queue_next_up">Als Nächstes</string>+ <string name="queue_clear">Leeren</string>+ <string name="queue_play_next">Als Nächstes abspielen</string>+ <string name="queue_remove">Entfernen</string>+ <string name="queue_removed">Aus der Warteschlange entfernt</string>+ <string name="queue_undo">Rückgängig</string>+ <string name="queue_reorder">Zum Sortieren ziehen</string>+ <plurals name="queue_selected">+ <item quantity="one">%1$d ausgewählt</item>+ <item quantity="other">%1$d ausgewählt</item>+ </plurals></resources>diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xmlindex 9b3cc3c..283ece9 100644--- a/app/src/main/res/values-es/strings.xml+++ b/app/src/main/res/values-es/strings.xml@@ -525,4 +525,18 @@<string name="telegram_community">Comunidad de Telegram</string><string name="login_in_progress">Iniciando sesión en Spotify…</string><string name="login_channel">Inicio de sesión</string>+ <string name="queue_now_playing">Sonando ahora</string>+ <string name="queue_next_in_queue">Siguientes en la cola</string>+ <string name="queue_next_from">A continuación de: %1$s</string>+ <string name="queue_next_up">A continuación</string>+ <string name="queue_clear">Vaciar</string>+ <string name="queue_play_next">Reproducir después</string>+ <string name="queue_remove">Quitar</string>+ <string name="queue_removed">Quitado de la cola</string>+ <string name="queue_undo">Deshacer</string>+ <string name="queue_reorder">Arrastra para reordenar</string>+ <plurals name="queue_selected">+ <item quantity="one">%1$d seleccionada</item>+ <item quantity="other">%1$d seleccionadas</item>+ </plurals></resources>diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xmlindex d44d425..4df0ab7 100644--- a/app/src/main/res/values-fr/strings.xml+++ b/app/src/main/res/values-fr/strings.xml@@ -519,4 +519,18 @@<string name="telegram_community">Communauté Telegram</string><string name="login_in_progress">Connexion à Spotify en cours…</string><string name="login_channel">Connexion</string>+ <string name="queue_now_playing">En cours de lecture</string>+ <string name="queue_next_in_queue">Ensuite dans la file</string>+ <string name="queue_next_from">Ensuite, de : %1$s</string>+ <string name="queue_next_up">Ensuite</string>+ <string name="queue_clear">Vider</string>+ <string name="queue_play_next">Lire ensuite</string>+ <string name="queue_remove">Retirer</string>+ <string name="queue_removed">Retiré de la file</string>+ <string name="queue_undo">Annuler</string>+ <string name="queue_reorder">Faire glisser pour réordonner</string>+ <plurals name="queue_selected">+ <item quantity="one">%1$d sélectionné</item>+ <item quantity="other">%1$d sélectionnés</item>+ </plurals></resources>diff --git a/app/src/main/res/values-hi/strings.xml b/app/src/main/res/values-hi/strings.xmlindex 3feb62f..4211030 100644--- a/app/src/main/res/values-hi/strings.xml+++ b/app/src/main/res/values-hi/strings.xml@@ -534,4 +534,18 @@<string name="telegram_community">Telegram समुदाय</string><string name="login_in_progress">Spotify में साइन इन हो रहा है…</string><string name="login_channel">साइन इन</string>+ <string name="queue_now_playing">अभी चल रहा है</string>+ <string name="queue_next_in_queue">कतार में आगे</string>+ <string name="queue_next_from">आगे, यहाँ से: %1$s</string>+ <string name="queue_next_up">आगे</string>+ <string name="queue_clear">खाली करें</string>+ <string name="queue_play_next">इसके बाद चलाएँ</string>+ <string name="queue_remove">हटाएँ</string>+ <string name="queue_removed">कतार से हटाया गया</string>+ <string name="queue_undo">पूर्ववत करें</string>+ <string name="queue_reorder">क्रम बदलने के लिए खींचें</string>+ <plurals name="queue_selected">+ <item quantity="one">%1$d चुना गया</item>+ <item quantity="other">%1$d चुने गए</item>+ </plurals></resources>diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xmlindex d339811..8093bcb 100644--- a/app/src/main/res/values-it/strings.xml+++ b/app/src/main/res/values-it/strings.xml@@ -556,4 +556,18 @@<string name="telegram_community">Community Telegram</string><string name="login_in_progress">Accesso a Spotify in corso…</string><string name="login_channel">Accesso</string>+ <string name="queue_now_playing">In riproduzione</string>+ <string name="queue_next_in_queue">Prossimi in coda</string>+ <string name="queue_next_from">Successivi da: %1$s</string>+ <string name="queue_next_up">Successivi</string>+ <string name="queue_clear">Svuota</string>+ <string name="queue_play_next">Riproduci dopo</string>+ <string name="queue_remove">Rimuovi</string>+ <string name="queue_removed">Rimosso dalla coda</string>+ <string name="queue_undo">Annulla</string>+ <string name="queue_reorder">Trascina per riordinare</string>+ <plurals name="queue_selected">+ <item quantity="one">%1$d selezionato</item>+ <item quantity="other">%1$d selezionati</item>+ </plurals></resources>diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xmlindex 5ac4018..3e0ed62 100644--- a/app/src/main/res/values-pt/strings.xml+++ b/app/src/main/res/values-pt/strings.xml@@ -519,4 +519,18 @@<string name="telegram_community">Comunidade do Telegram</string><string name="login_in_progress">Entrando no Spotify…</string><string name="login_channel">Entrar</string>+ <string name="queue_now_playing">Tocando agora</string>+ <string name="queue_next_in_queue">Próximas na fila</string>+ <string name="queue_next_from">A seguir de: %1$s</string>+ <string name="queue_next_up">A seguir</string>+ <string name="queue_clear">Limpar</string>+ <string name="queue_play_next">Tocar em seguida</string>+ <string name="queue_remove">Remover</string>+ <string name="queue_removed">Removida da fila</string>+ <string name="queue_undo">Desfazer</string>+ <string name="queue_reorder">Arraste para reordenar</string>+ <plurals name="queue_selected">+ <item quantity="one">%1$d selecionada</item>+ <item quantity="other">%1$d selecionadas</item>+ </plurals></resources>diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xmlindex 108bd58..2bc685b 100644--- a/app/src/main/res/values-ru/strings.xml+++ b/app/src/main/res/values-ru/strings.xml@@ -546,4 +546,20 @@<string name="telegram_community">Сообщество Telegram</string><string name="login_in_progress">Вход в Spotify…</string><string name="login_channel">Вход</string>+ <string name="queue_now_playing">Сейчас играет</string>+ <string name="queue_next_in_queue">Далее в очереди</string>+ <string name="queue_next_from">Далее из: %1$s</string>+ <string name="queue_next_up">Далее</string>+ <string name="queue_clear">Очистить</string>+ <string name="queue_play_next">Воспроизвести следующим</string>+ <string name="queue_remove">Удалить</string>+ <string name="queue_removed">Удалено из очереди</string>+ <string name="queue_undo">Отменить</string>+ <string name="queue_reorder">Перетащите, чтобы изменить порядок</string>+ <plurals name="queue_selected">+ <item quantity="one">Выбран %1$d</item>+ <item quantity="few">Выбрано %1$d</item>+ <item quantity="many">Выбрано %1$d</item>+ <item quantity="other">Выбрано %1$d</item>+ </plurals></resources>diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xmlindex 916176b..ac93f12 100644--- a/app/src/main/res/values-tr/strings.xml+++ b/app/src/main/res/values-tr/strings.xml@@ -532,4 +532,18 @@<string name="telegram_community">Telegram topluluğu</string><string name="login_in_progress">Spotify’da oturum açılıyor…</string><string name="login_channel">Oturum açma</string>+ <string name="queue_now_playing">Şimdi çalıyor</string>+ <string name="queue_next_in_queue">Sıradaki</string>+ <string name="queue_next_from">Sıradaki, şuradan: %1$s</string>+ <string name="queue_next_up">Sıradaki</string>+ <string name="queue_clear">Temizle</string>+ <string name="queue_play_next">Sonra çal</string>+ <string name="queue_remove">Kaldır</string>+ <string name="queue_removed">Sıradan kaldırıldı</string>+ <string name="queue_undo">Geri al</string>+ <string name="queue_reorder">Sıralamak için sürükle</string>+ <plurals name="queue_selected">+ <item quantity="one">%1$d seçildi</item>+ <item quantity="other">%1$d seçildi</item>+ </plurals></resources>diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xmlindex bf506ac..d002b33 100644--- a/app/src/main/res/values/strings.xml+++ b/app/src/main/res/values/strings.xml@@ -583,4 +583,18 @@<string name="telegram_community">Telegram community</string><string name="login_in_progress">Signing in to Spotify…</string><string name="login_channel">Signing in</string>+ <string name="queue_now_playing">Now playing</string>+ <string name="queue_next_in_queue">Next in queue</string>+ <string name="queue_next_from">Next from: %1$s</string>+ <string name="queue_next_up">Next up</string>+ <string name="queue_clear">Clear</string>+ <string name="queue_play_next">Play next</string>+ <string name="queue_remove">Remove</string>+ <string name="queue_removed">Removed from the queue</string>+ <string name="queue_undo">Undo</string>+ <string name="queue_reorder">Drag to reorder</string>+ <plurals name="queue_selected">+ <item quantity="one">%1$d selected</item>+ <item quantity="other">%1$d selected</item>+ </plurals></resources>diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.tomlindex 36af3b5..14267dc 100644--- a/gradle/libs.versions.toml+++ b/gradle/libs.versions.toml@@ -15,6 +15,7 @@ androidx-profileinstaller = { module = "androidx.profileinstaller:profileinstallandroidx-core-ktx = { module = "androidx.core:core-ktx", version = "1.15.0" }androidx-activity-compose = { module = "androidx.activity:activity-compose", version = "1.9.3" }androidx-browser = { module = "androidx.browser:browser", version = "1.8.0" }+reorderable = { module = "sh.calvin.reorderable:reorderable", version = "3.1.0" }androidx-security-crypto = { module = "androidx.security:security-crypto", version = "1.1.0-alpha06" }androidx-lifecycle-runtime-compose = { module = "androidx.lifecycle:lifecycle-runtime-compose", version.ref = "lifecycle" }androidx-lifecycle-viewmodel-compose = { module = "androidx.lifecycle:lifecycle-viewmodel-compose", version.ref = "lifecycle" }