diff --git a/app/src/main/java/org/oxycblt/auxio/MainFragment.kt b/app/src/main/java/org/oxycblt/auxio/MainFragment.kt index 9dee9473b..a9dd01b37 100644 --- a/app/src/main/java/org/oxycblt/auxio/MainFragment.kt +++ b/app/src/main/java/org/oxycblt/auxio/MainFragment.kt @@ -122,8 +122,7 @@ class MainFragment : logD("Configuring stacked bottom sheets") val playbackSheetBehavior = binding.playbackSheet.coordinatorLayoutBehavior as PlaybackBottomSheetBehavior - // TODO: Use the material handle - unlikelyToBeNull(binding.handleWrapper).setOnClickListener { + unlikelyToBeNull(binding.queueHandleWrapper).setOnClickListener { if (playbackSheetBehavior.state == BackportBottomSheetBehavior.STATE_EXPANDED && queueSheetBehavior.state == BackportBottomSheetBehavior.STATE_COLLAPSED) { // Playback sheet is expanded and queue sheet is collapsed, we can expand it. @@ -515,7 +514,8 @@ class MainFragment : // TODO: Debug why this fails sometimes on the playback sheet // TODO: Add playlist editing to enabled check - // TODO: Can this be split up? + // TODO: Chain these listeners in some way instead of keeping them all here, + // assuming listeners added later have more priority isEnabled = queueSheetBehavior?.state == BackportBottomSheetBehavior.STATE_EXPANDED || diff --git a/app/src/main/java/org/oxycblt/auxio/playback/queue/Queue.kt b/app/src/main/java/org/oxycblt/auxio/playback/queue/Queue.kt index 554d37258..9d9352ef4 100644 --- a/app/src/main/java/org/oxycblt/auxio/playback/queue/Queue.kt +++ b/app/src/main/java/org/oxycblt/auxio/playback/queue/Queue.kt @@ -201,13 +201,15 @@ class EditableQueue : Queue { } /** - * Add [Song]s to the top of the queue. Will start playback if nothing is playing. + * Add [Song]s to the "top" of the queue (right next to the currently playing song). Will start + * playback if nothing is playing. * * @param songs The [Song]s to add. * @return A [Queue.Change] instance that reflects the changes made. */ - fun playNext(songs: List): Queue.Change { + fun addToTop(songs: List): Queue.Change { logD("Adding ${songs.size} songs to the front of the queue") + val insertAt = index + 1 val heapIndices = songs.map(::addSongToHeap) if (shuffledMapping.isNotEmpty()) { // Add the new songs in front of the current index in the shuffled mapping and in front @@ -215,15 +217,14 @@ class EditableQueue : Queue { logD("Must append songs to shuffled mapping") val orderedIndex = orderedMapping.indexOf(shuffledMapping[index]) orderedMapping.addAll(orderedIndex + 1, heapIndices) - shuffledMapping.addAll(index + 1, heapIndices) + shuffledMapping.addAll(insertAt, heapIndices) } else { // Add the new song in front of the current index in the ordered mapping. logD("Only appending songs to ordered mapping") - orderedMapping.addAll(index + 1, heapIndices) + orderedMapping.addAll(insertAt, heapIndices) } check() - return Queue.Change( - Queue.Change.Type.MAPPING, UpdateInstructions.Add(index + 1, songs.size)) + return Queue.Change(Queue.Change.Type.MAPPING, UpdateInstructions.Add(insertAt, songs.size)) } /** @@ -232,9 +233,9 @@ class EditableQueue : Queue { * @param songs The [Song]s to add. * @return A [Queue.Change] instance that reflects the changes made. */ - fun addToQueue(songs: List): Queue.Change { + fun addToBottom(songs: List): Queue.Change { logD("Adding ${songs.size} songs to the back of the queue") - val point = orderedMapping.size + val insertAt = orderedMapping.size val heapIndices = songs.map(::addSongToHeap) // Can simple append the new songs to the end of both mappings. orderedMapping.addAll(heapIndices) @@ -243,7 +244,7 @@ class EditableQueue : Queue { shuffledMapping.addAll(heapIndices) } check() - return Queue.Change(Queue.Change.Type.MAPPING, UpdateInstructions.Add(point, songs.size)) + return Queue.Change(Queue.Change.Type.MAPPING, UpdateInstructions.Add(insertAt, songs.size)) } /** @@ -367,7 +368,7 @@ class EditableQueue : Queue { } } - logD("Serialized heap [max shift=$currentShift]") + logD("Created adjustment mapping [max shift=$currentShift]") heap = savedState.heap.filterNotNull().toMutableList() orderedMapping = diff --git a/app/src/main/java/org/oxycblt/auxio/playback/state/PlaybackStateManager.kt b/app/src/main/java/org/oxycblt/auxio/playback/state/PlaybackStateManager.kt index 58c0e6ed8..4f2dbb5c0 100644 --- a/app/src/main/java/org/oxycblt/auxio/playback/state/PlaybackStateManager.kt +++ b/app/src/main/java/org/oxycblt/auxio/playback/state/PlaybackStateManager.kt @@ -444,7 +444,7 @@ class PlaybackStateManagerImpl @Inject constructor() : PlaybackStateManager { play(songs[0], null, songs, false) } else { logD("Adding ${songs.size} songs to start of queue") - notifyQueueChanged(queue.playNext(songs)) + notifyQueueChanged(queue.addToTop(songs)) } } @@ -455,7 +455,7 @@ class PlaybackStateManagerImpl @Inject constructor() : PlaybackStateManager { play(songs[0], null, songs, false) } else { logD("Adding ${songs.size} songs to end of queue") - notifyQueueChanged(queue.addToQueue(songs)) + notifyQueueChanged(queue.addToBottom(songs)) } } diff --git a/app/src/main/res/drawable/ui_queue_drag_handle.xml b/app/src/main/res/drawable/ui_queue_drag_handle.xml deleted file mode 100644 index 2c907c3d6..000000000 --- a/app/src/main/res/drawable/ui_queue_drag_handle.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_main.xml b/app/src/main/res/layout/fragment_main.xml index abc7469ee..5b2e5c96b 100644 --- a/app/src/main/res/layout/fragment_main.xml +++ b/app/src/main/res/layout/fragment_main.xml @@ -46,20 +46,16 @@ app:layout_behavior="org.oxycblt.auxio.playback.queue.QueueBottomSheetBehavior"> - + android:layout_height="wrap_content" + app:layout_constraintTop_toTopOf="parent" />