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:
@@ -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,18 +4,29 @@
|
||||
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">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/queue_toolbar"
|
||||
style="@style/Widget.Toolbar.Icon.Down"
|
||||
app:navigationIcon="@drawable/ic_down"
|
||||
app:title="@string/lbl_queue" />
|
||||
<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"
|
||||
@@ -23,7 +34,8 @@
|
||||
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>
|
||||
Reference in New Issue
Block a user