queue: use mdc drag handle
Use a real mdc drag handle on the queue sheet. The accessibility functions won't even be enabled, but that would need to be communicated in a special way anyway.
This commit is contained in:
parent
d97eaf67b9
commit
40af4adc51
5 changed files with 24 additions and 36 deletions
|
@ -122,8 +122,7 @@ class MainFragment :
|
||||||
logD("Configuring stacked bottom sheets")
|
logD("Configuring stacked bottom sheets")
|
||||||
val playbackSheetBehavior =
|
val playbackSheetBehavior =
|
||||||
binding.playbackSheet.coordinatorLayoutBehavior as PlaybackBottomSheetBehavior
|
binding.playbackSheet.coordinatorLayoutBehavior as PlaybackBottomSheetBehavior
|
||||||
// TODO: Use the material handle
|
unlikelyToBeNull(binding.queueHandleWrapper).setOnClickListener {
|
||||||
unlikelyToBeNull(binding.handleWrapper).setOnClickListener {
|
|
||||||
if (playbackSheetBehavior.state == BackportBottomSheetBehavior.STATE_EXPANDED &&
|
if (playbackSheetBehavior.state == BackportBottomSheetBehavior.STATE_EXPANDED &&
|
||||||
queueSheetBehavior.state == BackportBottomSheetBehavior.STATE_COLLAPSED) {
|
queueSheetBehavior.state == BackportBottomSheetBehavior.STATE_COLLAPSED) {
|
||||||
// Playback sheet is expanded and queue sheet is collapsed, we can expand it.
|
// 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: Debug why this fails sometimes on the playback sheet
|
||||||
// TODO: Add playlist editing to enabled check
|
// 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 =
|
isEnabled =
|
||||||
queueSheetBehavior?.state == BackportBottomSheetBehavior.STATE_EXPANDED ||
|
queueSheetBehavior?.state == BackportBottomSheetBehavior.STATE_EXPANDED ||
|
||||||
|
|
|
@ -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.
|
* @param songs The [Song]s to add.
|
||||||
* @return A [Queue.Change] instance that reflects the changes made.
|
* @return A [Queue.Change] instance that reflects the changes made.
|
||||||
*/
|
*/
|
||||||
fun playNext(songs: List<Song>): Queue.Change {
|
fun addToTop(songs: List<Song>): Queue.Change {
|
||||||
logD("Adding ${songs.size} songs to the front of the queue")
|
logD("Adding ${songs.size} songs to the front of the queue")
|
||||||
|
val insertAt = index + 1
|
||||||
val heapIndices = songs.map(::addSongToHeap)
|
val heapIndices = songs.map(::addSongToHeap)
|
||||||
if (shuffledMapping.isNotEmpty()) {
|
if (shuffledMapping.isNotEmpty()) {
|
||||||
// Add the new songs in front of the current index in the shuffled mapping and in front
|
// 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")
|
logD("Must append songs to shuffled mapping")
|
||||||
val orderedIndex = orderedMapping.indexOf(shuffledMapping[index])
|
val orderedIndex = orderedMapping.indexOf(shuffledMapping[index])
|
||||||
orderedMapping.addAll(orderedIndex + 1, heapIndices)
|
orderedMapping.addAll(orderedIndex + 1, heapIndices)
|
||||||
shuffledMapping.addAll(index + 1, heapIndices)
|
shuffledMapping.addAll(insertAt, heapIndices)
|
||||||
} else {
|
} else {
|
||||||
// Add the new song in front of the current index in the ordered mapping.
|
// Add the new song in front of the current index in the ordered mapping.
|
||||||
logD("Only appending songs to ordered mapping")
|
logD("Only appending songs to ordered mapping")
|
||||||
orderedMapping.addAll(index + 1, heapIndices)
|
orderedMapping.addAll(insertAt, heapIndices)
|
||||||
}
|
}
|
||||||
check()
|
check()
|
||||||
return Queue.Change(
|
return Queue.Change(Queue.Change.Type.MAPPING, UpdateInstructions.Add(insertAt, songs.size))
|
||||||
Queue.Change.Type.MAPPING, UpdateInstructions.Add(index + 1, songs.size))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -232,9 +233,9 @@ class EditableQueue : Queue {
|
||||||
* @param songs The [Song]s to add.
|
* @param songs The [Song]s to add.
|
||||||
* @return A [Queue.Change] instance that reflects the changes made.
|
* @return A [Queue.Change] instance that reflects the changes made.
|
||||||
*/
|
*/
|
||||||
fun addToQueue(songs: List<Song>): Queue.Change {
|
fun addToBottom(songs: List<Song>): Queue.Change {
|
||||||
logD("Adding ${songs.size} songs to the back of the queue")
|
logD("Adding ${songs.size} songs to the back of the queue")
|
||||||
val point = orderedMapping.size
|
val insertAt = orderedMapping.size
|
||||||
val heapIndices = songs.map(::addSongToHeap)
|
val heapIndices = songs.map(::addSongToHeap)
|
||||||
// Can simple append the new songs to the end of both mappings.
|
// Can simple append the new songs to the end of both mappings.
|
||||||
orderedMapping.addAll(heapIndices)
|
orderedMapping.addAll(heapIndices)
|
||||||
|
@ -243,7 +244,7 @@ class EditableQueue : Queue {
|
||||||
shuffledMapping.addAll(heapIndices)
|
shuffledMapping.addAll(heapIndices)
|
||||||
}
|
}
|
||||||
check()
|
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()
|
heap = savedState.heap.filterNotNull().toMutableList()
|
||||||
orderedMapping =
|
orderedMapping =
|
||||||
|
|
|
@ -444,7 +444,7 @@ class PlaybackStateManagerImpl @Inject constructor() : PlaybackStateManager {
|
||||||
play(songs[0], null, songs, false)
|
play(songs[0], null, songs, false)
|
||||||
} else {
|
} else {
|
||||||
logD("Adding ${songs.size} songs to start of queue")
|
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)
|
play(songs[0], null, songs, false)
|
||||||
} else {
|
} else {
|
||||||
logD("Adding ${songs.size} songs to end of queue")
|
logD("Adding ${songs.size} songs to end of queue")
|
||||||
notifyQueueChanged(queue.addToQueue(songs))
|
notifyQueueChanged(queue.addToBottom(songs))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:shape="rectangle">
|
|
||||||
<size
|
|
||||||
android:width="32dp"
|
|
||||||
android:height="4dp" />
|
|
||||||
<corners android:radius="2dp" />
|
|
||||||
<solid android:color="#FFF" />
|
|
||||||
</shape>
|
|
|
@ -46,20 +46,16 @@
|
||||||
app:layout_behavior="org.oxycblt.auxio.playback.queue.QueueBottomSheetBehavior">
|
app:layout_behavior="org.oxycblt.auxio.playback.queue.QueueBottomSheetBehavior">
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:id="@+id/handle_wrapper"
|
android:id="@+id/queue_handle_wrapper"
|
||||||
|
android:contentDescription="@string/desc_queue_bar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/size_bottom_sheet_bar">
|
android:layout_height="@dimen/size_bottom_sheet_bar">
|
||||||
|
|
||||||
<ImageView
|
<com.google.android.material.bottomsheet.BottomSheetDragHandleView
|
||||||
android:id="@+id/handle"
|
android:id="@+id/queue_handle"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/size_btn"
|
android:layout_height="wrap_content"
|
||||||
android:contentDescription="@string/desc_queue_bar"
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
android:paddingBottom="@dimen/spacing_mid_large"
|
|
||||||
android:scaleType="center"
|
|
||||||
android:src="@drawable/ui_queue_drag_handle"
|
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
|
||||||
app:tint="?attr/colorOnSurfaceVariant" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/queue_title"
|
android:id="@+id/queue_title"
|
||||||
|
@ -68,8 +64,8 @@
|
||||||
android:text="@string/lbl_queue"
|
android:text="@string/lbl_queue"
|
||||||
android:textAppearance="@style/TextAppearance.Auxio.LabelLarge"
|
android:textAppearance="@style/TextAppearance.Auxio.LabelLarge"
|
||||||
android:textColor="?attr/colorOnSurfaceVariant"
|
android:textColor="?attr/colorOnSurfaceVariant"
|
||||||
app:layout_constraintBottom_toBottomOf="@+id/handle"
|
app:layout_constraintBottom_toBottomOf="@+id/queue_handle"
|
||||||
app:layout_constraintEnd_toEndOf="@+id/handle"
|
app:layout_constraintEnd_toEndOf="@+id/queue_handle"
|
||||||
app:layout_constraintStart_toStartOf="parent" />
|
app:layout_constraintStart_toStartOf="parent" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
Loading…
Reference in a new issue