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.
This commit is contained in:
OxygenCobalt
2022-07-31 17:21:10 -06:00
parent f5542c65ba
commit 257516643f
9 changed files with 41 additions and 17 deletions
@@ -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
@@ -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<V : View>(context: Context, attributeSet: AttributeSet?) :
AuxioSheetBehavior<V>(context, attributeSet) {
@@ -69,7 +67,7 @@ class PlaybackSheetBehavior<V : View>(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) {
@@ -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")
@@ -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)