diff --git a/app/build.gradle b/app/build.gradle index 1cc60bd16..4fa4b728d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -71,6 +71,7 @@ dependencies { implementation "androidx.recyclerview:recyclerview:1.2.1" implementation "androidx.constraintlayout:constraintlayout:2.1.0" implementation "androidx.dynamicanimation:dynamicanimation:1.0.0" + implementation "androidx.viewpager2:viewpager2:1.1.0-beta01" // Lifecycle def lifecycle_version = "2.3.1" diff --git a/app/src/main/java/org/oxycblt/auxio/playback/queue/QueueDragCallback.kt b/app/src/main/java/org/oxycblt/auxio/playback/queue/QueueDragCallback.kt index 6036fab3c..1aff33fde 100644 --- a/app/src/main/java/org/oxycblt/auxio/playback/queue/QueueDragCallback.kt +++ b/app/src/main/java/org/oxycblt/auxio/playback/queue/QueueDragCallback.kt @@ -32,8 +32,8 @@ import kotlin.math.min import kotlin.math.sign /** - * The Drag callback used by the queue recyclerview. Delivers updates to [PlaybackViewModel] - * and [QueueAdapter] simultaneously. + * A highly customized [ItemTouchHelper.Callback] that handles queue item moving, removal, and some + * of the UI magic that makes up the queue UI. * @author OxygenCobalt */ class QueueDragCallback( @@ -104,9 +104,8 @@ class QueueDragCallback( ) { // The material design page on elevation has a cool example of draggable items elevating // themselves when being dragged. Too bad google's implementation of this doesn't even - // work :^). To emulate it on my own, I check if this child is in a drag state and - // then animate an elevation change. This animation also changes the background so that - // the item will actually draw over. + // work! To emulate it on my own, I check if this child is in a drag state and then animate + // an elevation change. // TODO: Maybe restrict the item from being drawn over the recycler bounds? // Seems like its possible with enough UI magic @@ -114,7 +113,6 @@ class QueueDragCallback( if (shouldLift && isCurrentlyActive && actionState == ItemTouchHelper.ACTION_STATE_DRAG) { view.animate() - .withStartAction { view.setBackgroundResource(R.color.surface) } .translationZ(view.resources.getDimension(R.dimen.elevation_small)) .setDuration(100) .setInterpolator(AccelerateDecelerateInterpolator()) @@ -123,18 +121,16 @@ class QueueDragCallback( shouldLift = false } - super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive) + view.translationX = dX + view.translationY = dY } override fun clearView(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder) { - // When an elevated item is cleared, we reset the elevation using another animation - // and set the background to null again so a seam doesn't show up in further actions. - + // When an elevated item is cleared, we reset the elevation using another animation. val view = viewHolder.itemView if (view.translationZ != 0.0f) { view.animate() - .withEndAction { view.setBackgroundResource(android.R.color.transparent) } .translationZ(0.0f) .setDuration(100) .setInterpolator(AccelerateDecelerateInterpolator()) @@ -143,7 +139,8 @@ class QueueDragCallback( shouldLift = true - super.clearView(recyclerView, viewHolder) + view.translationX = 0f + view.translationY = 0f } override fun onMove( diff --git a/app/src/main/res/layout/item_queue_song.xml b/app/src/main/res/layout/item_queue_song.xml index d8223ca94..50ea63a26 100644 --- a/app/src/main/res/layout/item_queue_song.xml +++ b/app/src/main/res/layout/item_queue_song.xml @@ -13,7 +13,8 @@ + android:layout_height="wrap_content" + android:background="?attr/colorSurface"> Auxio - %1$s / %2$s - %1$s / %2$s / %3$s + %1$s • %2$s + %1$s • %2$s • %3$s %1$s, %2$s <b>%1$s</b>: %2$s \ No newline at end of file diff --git a/build.gradle b/build.gradle index 94aef2075..54cd59d55 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = "1.5.21" + ext.kotlin_version = '1.5.30' ext.navigation_version = "2.3.5" repositories {