Add queue drawer deck-shuffle button

This commit is contained in:
jay
2026-11-28 16:17:07 -05:00
parent 6001741e10
commit 501f8934f0
4 changed files with 31 additions and 2 deletions
@@ -131,6 +131,7 @@ class MainFragment :
// --- QUEUE SHEET SETUP ---
binding.queueClear.setOnClickListener { queueModel.clearQueue() }
binding.queueShuffle.setOnClickListener { queueModel.shuffleDeck() }
elevationNormal = binding.context.getDimen(MR.dimen.m3_sys_elevation_level1)
@@ -234,7 +235,7 @@ class MainFragment :
collectImmediately(listModel.selected, selectionBackCallback::invalidateEnabled)
collectImmediately(playbackModel.song, ::updateSong)
collectImmediately(playbackModel.openPanel.flow, ::handlePanel)
collectImmediately(queueModel.queue, ::updateQueueClearButton)
collectImmediately(queueModel.queue, ::updateQueueButtons)
}
override fun onStart() {
@@ -656,8 +657,11 @@ class MainFragment :
}
}
private fun updateQueueClearButton(queue: List<Song>) {
private fun updateQueueButtons(queue: List<Song>) {
requireBinding().queueClear.isVisible = queue.isNotEmpty()
// Shuffling fewer than two waiting entries cannot change anything.
val waiting = queue.size - if (queueModel.index.value == 0) 1 else 0
requireBinding().queueShuffle.isVisible = waiting >= 2
}
private fun tryClosePlaybackPanel() {
@@ -167,6 +167,12 @@ class QueueViewModel @Inject constructor(private val playbackManager: PlaybackSt
playbackManager.clearQueue()
}
/** Randomly reorder the waiting deck songs; the playing row keeps its place. */
fun shuffleDeck() {
L.d("Shuffling the deck")
playbackManager.shuffleDeck()
}
/** Republish the drawer rows from the manager's deck state. */
private fun republish() {
val rows = listOfNotNull(playbackManager.deckCurrent) + playbackManager.deck
@@ -114,6 +114,14 @@
android:gravity="center_vertical"
android:orientation="horizontal">
<com.google.android.material.button.MaterialButton
android:id="@+id/queue_shuffle"
style="@style/Widget.Auxio.Button.TextButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/lbl_shuffle"
android:visibility="gone" />
<TextView
android:layout_width="0dp"
android:layout_height="64dp"
+11
View File
@@ -126,6 +126,17 @@
app:layout_constraintEnd_toEndOf="@+id/queue_handle"
app:layout_constraintStart_toStartOf="parent" />
<com.google.android.material.button.MaterialButton
android:id="@+id/queue_shuffle"
style="@style/Widget.Auxio.Button.TextButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/lbl_shuffle"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.button.MaterialButton
android:id="@+id/queue_clear"
style="@style/Widget.Auxio.Button.TextButton"