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:
OxygenCobalt
2021-08-24 20:04:32 -06:00
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
}
}