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 ---
|
// --- VIEWMODEL SETUP ---
|
||||||
|
|
||||||
detailModel.navToItem.observe(viewLifecycleOwner) { item ->
|
detailModel.navToItem.observe(viewLifecycleOwner) { item ->
|
||||||
// Unless we wait for the AppBarLayout to be done setting up before we navigate,
|
// The AppBarLayout bugs out and collapses when we navigate too fast, wait for it
|
||||||
// it might result in the collapsed state being lost for...reasons.
|
// to draw before we continue.
|
||||||
binding.homeAppbar.post {
|
binding.homeAppbar.post {
|
||||||
when (item) {
|
when (item) {
|
||||||
is Song -> findNavController().navigate(
|
is Song -> findNavController().navigate(
|
||||||
|
|
|
@ -106,7 +106,7 @@ class QueueDragCallback(private val playbackModel: PlaybackViewModel) : ItemTouc
|
||||||
if (shouldLift && isCurrentlyActive && actionState == ItemTouchHelper.ACTION_STATE_DRAG) {
|
if (shouldLift && isCurrentlyActive && actionState == ItemTouchHelper.ACTION_STATE_DRAG) {
|
||||||
view.animate()
|
view.animate()
|
||||||
.withStartAction { view.setBackgroundResource(R.color.surface) }
|
.withStartAction { view.setBackgroundResource(R.color.surface) }
|
||||||
.translationZ(view.resources.getDimension(R.dimen.elevation_normal))
|
.translationZ(view.resources.getDimension(R.dimen.elevation_small))
|
||||||
.setDuration(100)
|
.setDuration(100)
|
||||||
.setInterpolator(AccelerateDecelerateInterpolator())
|
.setInterpolator(AccelerateDecelerateInterpolator())
|
||||||
.start()
|
.start()
|
||||||
|
@ -124,7 +124,7 @@ class QueueDragCallback(private val playbackModel: PlaybackViewModel) : ItemTouc
|
||||||
val view = viewHolder.itemView
|
val view = viewHolder.itemView
|
||||||
|
|
||||||
if (view.translationZ != 0.0f) {
|
if (view.translationZ != 0.0f) {
|
||||||
viewHolder.itemView.animate()
|
view.animate()
|
||||||
.withEndAction { view.setBackgroundResource(android.R.color.transparent) }
|
.withEndAction { view.setBackgroundResource(android.R.color.transparent) }
|
||||||
.translationZ(0.0f)
|
.translationZ(0.0f)
|
||||||
.setDuration(100)
|
.setDuration(100)
|
||||||
|
|
|
@ -36,11 +36,12 @@ import org.oxycblt.auxio.music.BaseModel
|
||||||
import org.oxycblt.auxio.music.Header
|
import org.oxycblt.auxio.music.Header
|
||||||
import org.oxycblt.auxio.playback.PlaybackViewModel
|
import org.oxycblt.auxio.playback.PlaybackViewModel
|
||||||
import org.oxycblt.auxio.util.isEdgeOn
|
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.
|
* 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
|
* @author OxygenCobalt
|
||||||
*/
|
*/
|
||||||
class QueueFragment : Fragment() {
|
class QueueFragment : Fragment() {
|
||||||
|
@ -108,8 +109,22 @@ class QueueFragment : Fragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupEdgeForQueue(binding: FragmentQueueBinding) {
|
private fun setupEdgeForQueue(binding: FragmentQueueBinding) {
|
||||||
if (isEdgeOn() && !requireActivity().isIrregularLandscape()) {
|
if (isEdgeOn()) {
|
||||||
binding.queueToolbar.setOnApplyWindowInsetsListener { v, insets ->
|
// 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) {
|
val top = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||||
insets.getInsets(WindowInsets.Type.systemBars()).top
|
insets.getInsets(WindowInsets.Type.systemBars()).top
|
||||||
} else {
|
} else {
|
||||||
|
@ -117,7 +132,7 @@ class QueueFragment : Fragment() {
|
||||||
insets.systemWindowInsetTop
|
insets.systemWindowInsetTop
|
||||||
}
|
}
|
||||||
|
|
||||||
(v.parent as View).updatePadding(top = top)
|
v.updatePadding(top = top)
|
||||||
|
|
||||||
insets
|
insets
|
||||||
}
|
}
|
||||||
|
@ -141,7 +156,6 @@ class QueueFragment : Fragment() {
|
||||||
insets
|
insets
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Don't even bother if we are in phone landscape or if edge-to-edge is off.
|
|
||||||
binding.root.fitsSystemWindows = true
|
binding.root.fitsSystemWindows = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,18 +4,29 @@
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
tools:context=".playback.queue.QueueFragment">
|
tools:context=".playback.queue.QueueFragment">
|
||||||
|
|
||||||
<LinearLayout
|
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:animateLayoutChanges="true"
|
android:animateLayoutChanges="true"
|
||||||
android:background="?attr/colorSurface"
|
android:background="?attr/colorSurface"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<androidx.appcompat.widget.Toolbar
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
android:id="@+id/queue_toolbar"
|
android:id="@+id/queue_appbar"
|
||||||
style="@style/Widget.Toolbar.Icon.Down"
|
android:layout_width="match_parent"
|
||||||
app:navigationIcon="@drawable/ic_down"
|
android:background="?attr/colorSurface"
|
||||||
app:title="@string/lbl_queue" />
|
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
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/queue_recycler"
|
android:id="@+id/queue_recycler"
|
||||||
|
@ -23,7 +34,8 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:overScrollMode="ifContentScrolls"
|
android:overScrollMode="ifContentScrolls"
|
||||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||||
|
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"
|
||||||
tools:listitem="@layout/item_queue_song" />
|
tools:listitem="@layout/item_queue_song" />
|
||||||
|
|
||||||
</LinearLayout>
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
</layout>
|
</layout>
|
|
@ -26,4 +26,5 @@ Feel free to fork Auxio to add your own feature set however.
|
||||||
- Recently added list [#18]
|
- Recently added list [#18]
|
||||||
- Folder View/Grouping [#10]
|
- Folder View/Grouping [#10]
|
||||||
- ReplayGain [#7]
|
- ReplayGain [#7]
|
||||||
- Tag editing [#33]
|
- 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
|
# 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.
|
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