playback: improve queue ui
Make the queue UI follow the liftOnScroll idiom that is already used in the detail views. This also tweaks the edge-to-edge behavior so that this view properly works.
This commit is contained in:
parent
9162246b8b
commit
9ce7dc598d
6 changed files with 48 additions and 18 deletions
|
@ -123,8 +123,8 @@ class HomeFragment : Fragment() {
|
|||
// --- VIEWMODEL SETUP ---
|
||||
|
||||
detailModel.navToItem.observe(viewLifecycleOwner) { item ->
|
||||
// Unless we wait for the AppBarLayout to be done setting up before we navigate,
|
||||
// it might result in the collapsed state being lost for...reasons.
|
||||
// The AppBarLayout bugs out and collapses when we navigate too fast, wait for it
|
||||
// to draw before we continue.
|
||||
binding.homeAppbar.post {
|
||||
when (item) {
|
||||
is Song -> findNavController().navigate(
|
||||
|
|
|
@ -106,7 +106,7 @@ class QueueDragCallback(private val playbackModel: PlaybackViewModel) : ItemTouc
|
|||
if (shouldLift && isCurrentlyActive && actionState == ItemTouchHelper.ACTION_STATE_DRAG) {
|
||||
view.animate()
|
||||
.withStartAction { view.setBackgroundResource(R.color.surface) }
|
||||
.translationZ(view.resources.getDimension(R.dimen.elevation_normal))
|
||||
.translationZ(view.resources.getDimension(R.dimen.elevation_small))
|
||||
.setDuration(100)
|
||||
.setInterpolator(AccelerateDecelerateInterpolator())
|
||||
.start()
|
||||
|
@ -124,7 +124,7 @@ class QueueDragCallback(private val playbackModel: PlaybackViewModel) : ItemTouc
|
|||
val view = viewHolder.itemView
|
||||
|
||||
if (view.translationZ != 0.0f) {
|
||||
viewHolder.itemView.animate()
|
||||
view.animate()
|
||||
.withEndAction { view.setBackgroundResource(android.R.color.transparent) }
|
||||
.translationZ(0.0f)
|
||||
.setDuration(100)
|
||||
|
|
|
@ -36,11 +36,12 @@ import org.oxycblt.auxio.music.BaseModel
|
|||
import org.oxycblt.auxio.music.Header
|
||||
import org.oxycblt.auxio.playback.PlaybackViewModel
|
||||
import org.oxycblt.auxio.util.isEdgeOn
|
||||
import org.oxycblt.auxio.util.isIrregularLandscape
|
||||
|
||||
/**
|
||||
* A [Fragment] that contains both the user queue and the next queue, with the ability to
|
||||
* A [Fragment] that contains both the user queue and the next queue, with the abielity to
|
||||
* edit them as well.
|
||||
* TODO: Edge can be improved here by turning off the landscape checks and simply padding the
|
||||
* root view on the irregular landscape mode [I think]
|
||||
* @author OxygenCobalt
|
||||
*/
|
||||
class QueueFragment : Fragment() {
|
||||
|
@ -108,8 +109,22 @@ class QueueFragment : Fragment() {
|
|||
}
|
||||
|
||||
private fun setupEdgeForQueue(binding: FragmentQueueBinding) {
|
||||
if (isEdgeOn() && !requireActivity().isIrregularLandscape()) {
|
||||
binding.queueToolbar.setOnApplyWindowInsetsListener { v, insets ->
|
||||
if (isEdgeOn()) {
|
||||
// Account for the side navigation bar if required.
|
||||
binding.root.setOnApplyWindowInsetsListener { v, insets ->
|
||||
val right = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
insets.getInsets(WindowInsets.Type.systemBars()).right
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
insets.systemWindowInsetRight
|
||||
}
|
||||
|
||||
v.updatePadding(right = right)
|
||||
|
||||
insets
|
||||
}
|
||||
|
||||
binding.queueAppbar.setOnApplyWindowInsetsListener { v, insets ->
|
||||
val top = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
insets.getInsets(WindowInsets.Type.systemBars()).top
|
||||
} else {
|
||||
|
@ -117,7 +132,7 @@ class QueueFragment : Fragment() {
|
|||
insets.systemWindowInsetTop
|
||||
}
|
||||
|
||||
(v.parent as View).updatePadding(top = top)
|
||||
v.updatePadding(top = top)
|
||||
|
||||
insets
|
||||
}
|
||||
|
@ -141,7 +156,6 @@ class QueueFragment : Fragment() {
|
|||
insets
|
||||
}
|
||||
} else {
|
||||
// Don't even bother if we are in phone landscape or if edge-to-edge is off.
|
||||
binding.root.fitsSystemWindows = true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,26 +4,38 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:context=".playback.queue.QueueFragment">
|
||||
|
||||
<LinearLayout
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:animateLayoutChanges="true"
|
||||
android:background="?attr/colorSurface"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/queue_appbar"
|
||||
android:layout_width="match_parent"
|
||||
android:background="?attr/colorSurface"
|
||||
android:layout_height="wrap_content"
|
||||
app:liftOnScroll="true">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/queue_toolbar"
|
||||
style="@style/Widget.Toolbar.Icon.Down"
|
||||
android:elevation="0dp"
|
||||
app:navigationIcon="@drawable/ic_down"
|
||||
app:title="@string/lbl_queue" />
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/queue_recycler"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:overScrollMode="ifContentScrolls"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"
|
||||
tools:listitem="@layout/item_queue_song" />
|
||||
|
||||
</LinearLayout>
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
</layout>
|
|
@ -27,3 +27,4 @@ Feel free to fork Auxio to add your own feature set however.
|
|||
- Folder View/Grouping [#10]
|
||||
- ReplayGain [#7]
|
||||
- Tag editing [#33]
|
||||
- Specialized queue adding (ex. Play Next) [#44]
|
|
@ -1,3 +1,6 @@
|
|||
**Note:** Auxio is undergoing a major refactor right now. This document may not be fully up to date.
|
||||
It will be revamped when the refactor is complete.
|
||||
|
||||
# Architecture
|
||||
|
||||
This document is designed to provide a simple overview of Auxio's architecture and where code resides/should reside. It will be updated as aspects about Auxio change.
|
||||
|
|
Loading…
Reference in a new issue