From 257516643f261ff3d4cb1a257a059bf9b352e35e Mon Sep 17 00:00:00 2001 From: OxygenCobalt Date: Sun, 31 Jul 2022 17:21:10 -0600 Subject: [PATCH] queue: indicate playing item in list Indicate the currently playing item in the queue list. The item is still disabled, however it's also simultaniously activated now, which allows it to indicate that it is playing. --- .../org/oxycblt/auxio/image/ImageGroup.kt | 7 +++++ .../auxio/playback/PlaybackSheetBehavior.kt | 4 +-- .../auxio/playback/queue/QueueAdapter.kt | 27 ++++++++++++------- .../auxio/playback/queue/QueueDragCallback.kt | 2 +- .../main/res/color/sel_accented_primary.xml | 1 - .../main/res/color/sel_accented_secondary.xml | 1 - .../main/res/color/sel_toggleable_primary.xml | 6 +++++ .../res/color/sel_toggleable_secondary.xml | 6 +++++ app/src/main/res/layout/item_queue_song.xml | 4 ++- 9 files changed, 41 insertions(+), 17 deletions(-) create mode 100644 app/src/main/res/color/sel_toggleable_primary.xml create mode 100644 app/src/main/res/color/sel_toggleable_secondary.xml diff --git a/app/src/main/java/org/oxycblt/auxio/image/ImageGroup.kt b/app/src/main/java/org/oxycblt/auxio/image/ImageGroup.kt index ea77eb442..b1a99b46f 100644 --- a/app/src/main/java/org/oxycblt/auxio/image/ImageGroup.kt +++ b/app/src/main/java/org/oxycblt/auxio/image/ImageGroup.kt @@ -101,12 +101,19 @@ constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr invalidateIndicator() } + override fun setEnabled(enabled: Boolean) { + super.setEnabled(enabled) + invalidateIndicator() + } + private fun invalidateIndicator() { if (isActivated) { + alpha = 1f indicator.alpha = 1f customView?.alpha = 0f inner.alpha = 0f } else { + alpha = if (isEnabled) 1f else 0.5f indicator.alpha = 0f customView?.alpha = 1f inner.alpha = 1f diff --git a/app/src/main/java/org/oxycblt/auxio/playback/PlaybackSheetBehavior.kt b/app/src/main/java/org/oxycblt/auxio/playback/PlaybackSheetBehavior.kt index 9a1a204bf..387707d35 100644 --- a/app/src/main/java/org/oxycblt/auxio/playback/PlaybackSheetBehavior.kt +++ b/app/src/main/java/org/oxycblt/auxio/playback/PlaybackSheetBehavior.kt @@ -33,8 +33,6 @@ import org.oxycblt.auxio.util.systemGestureInsetsCompat * The coordinator layout behavior used for the playback sheet, hacking in the many fixes required * to make bottom sheets like this work. * @author OxygenCobalt - * - * TODO: Implement hiding because I have to */ class PlaybackSheetBehavior(context: Context, attributeSet: AttributeSet?) : AuxioSheetBehavior(context, attributeSet) { @@ -69,7 +67,7 @@ class PlaybackSheetBehavior(context: Context, attributeSet: AttributeS } // Note: This is an extension to Auxio's vendored BottomSheetBehavior - override fun enableHidingGestures() = true + override fun enableHidingGestures() = false fun hideSafe() { if (state != STATE_HIDDEN) { diff --git a/app/src/main/java/org/oxycblt/auxio/playback/queue/QueueAdapter.kt b/app/src/main/java/org/oxycblt/auxio/playback/queue/QueueAdapter.kt index df57685f2..ae70ca67a 100644 --- a/app/src/main/java/org/oxycblt/auxio/playback/queue/QueueAdapter.kt +++ b/app/src/main/java/org/oxycblt/auxio/playback/queue/QueueAdapter.kt @@ -49,7 +49,8 @@ class QueueAdapter(listener: QueueItemListener) : super.onBindViewHolder(viewHolder, position, payload) } - viewHolder.isPrevious = position <= currentIndex + viewHolder.isEnabled = position > currentIndex + viewHolder.isActivated = position == currentIndex } fun updateIndex(index: Int) { @@ -89,16 +90,24 @@ private constructor( MaterialShapeDrawable.createWithElevationOverlay(binding.root.context).apply { fillColor = binding.context.getAttrColorSafe(R.attr.colorSurface).stateList elevation = binding.context.getDimenSafe(R.dimen.elevation_normal) * 5 + alpha = 0 } - var isPrevious: Boolean - get() = binding.songDragHandle.alpha == 0.5f + var isEnabled: Boolean + get() = binding.songAlbumCover.isEnabled set(value) { - val alpha = if (value) 0.5f else 1f - binding.songAlbumCover.alpha = alpha - binding.songName.alpha = alpha - binding.songInfo.alpha = alpha - binding.songDragHandle.alpha = alpha + // Don't want to disable clicking, just indicate the body and handle is disabled + binding.songAlbumCover.isEnabled = value + binding.songName.isEnabled = value + binding.songInfo.isEnabled = value + binding.songDragHandle.isEnabled = value + } + + var isActivated: Boolean + get() = binding.interactBody.isActivated + set(value) { + // Activation does not affect clicking, make everything activated. + binding.interactBody.setActivated(value) } init { @@ -110,8 +119,6 @@ private constructor( elevation = binding.context.getDimenSafe(R.dimen.elevation_normal) }, backgroundDrawable)) - - backgroundDrawable.alpha = 0 } @SuppressLint("ClickableViewAccessibility") 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 95020ba7c..360a2a72f 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 @@ -40,7 +40,7 @@ class QueueDragCallback(private val playbackModel: QueueViewModel) : ItemTouchHe viewHolder: RecyclerView.ViewHolder ): Int { val queueHolder = viewHolder as QueueSongViewHolder - return if (!queueHolder.isPrevious) { + return if (queueHolder.isEnabled) { makeFlag( ItemTouchHelper.ACTION_STATE_DRAG, ItemTouchHelper.UP or ItemTouchHelper.DOWN) or makeFlag(ItemTouchHelper.ACTION_STATE_SWIPE, ItemTouchHelper.START) diff --git a/app/src/main/res/color/sel_accented_primary.xml b/app/src/main/res/color/sel_accented_primary.xml index 824dece22..e72a8e2ec 100644 --- a/app/src/main/res/color/sel_accented_primary.xml +++ b/app/src/main/res/color/sel_accented_primary.xml @@ -1,6 +1,5 @@ - \ No newline at end of file diff --git a/app/src/main/res/color/sel_accented_secondary.xml b/app/src/main/res/color/sel_accented_secondary.xml index 6402899ee..105bf5c7a 100644 --- a/app/src/main/res/color/sel_accented_secondary.xml +++ b/app/src/main/res/color/sel_accented_secondary.xml @@ -1,6 +1,5 @@ - \ No newline at end of file diff --git a/app/src/main/res/color/sel_toggleable_primary.xml b/app/src/main/res/color/sel_toggleable_primary.xml new file mode 100644 index 000000000..6e06c2444 --- /dev/null +++ b/app/src/main/res/color/sel_toggleable_primary.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/color/sel_toggleable_secondary.xml b/app/src/main/res/color/sel_toggleable_secondary.xml new file mode 100644 index 000000000..94963e77a --- /dev/null +++ b/app/src/main/res/color/sel_toggleable_secondary.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_queue_song.xml b/app/src/main/res/layout/item_queue_song.xml index 4dd05ada7..e1ed7bf20 100644 --- a/app/src/main/res/layout/item_queue_song.xml +++ b/app/src/main/res/layout/item_queue_song.xml @@ -32,7 +32,7 @@ android:layout_height="wrap_content" android:background="?attr/selectableItemBackground"> -