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:
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)
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:alpha="0.24" android:color="?attr/colorOnSurface" android:state_enabled="false" />
|
||||
<item android:color="?attr/colorPrimary" android:state_activated="true" />
|
||||
<item android:color="?android:attr/textColorPrimary" />
|
||||
</selector>
|
|
@ -1,6 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:alpha="0.24" android:color="?attr/colorOnSurface" android:state_enabled="false" />
|
||||
<item android:color="?attr/colorPrimary" android:state_activated="true" />
|
||||
<item android:color="?android:attr/textColorSecondary" />
|
||||
</selector>
|
6
app/src/main/res/color/sel_toggleable_primary.xml
Normal file
6
app/src/main/res/color/sel_toggleable_primary.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:color="?attr/colorPrimary" android:state_activated="true" />
|
||||
<item android:color="?android:attr/textColorPrimary" android:alpha="0.5" android:state_enabled="false" />
|
||||
<item android:color="?android:attr/textColorPrimary" />
|
||||
</selector>
|
6
app/src/main/res/color/sel_toggleable_secondary.xml
Normal file
6
app/src/main/res/color/sel_toggleable_secondary.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:color="?android:attr/textColorSecondary" android:state_activated="true" />
|
||||
<item android:color="?android:attr/textColorSecondary" android:alpha="0.5" android:state_enabled="false" />
|
||||
<item android:color="?android:attr/textColorSecondary" />
|
||||
</selector>
|
|
@ -32,7 +32,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground">
|
||||
|
||||
<org.oxycblt.auxio.image.StyledImageView
|
||||
<org.oxycblt.auxio.image.ImageGroup
|
||||
android:id="@+id/song_album_cover"
|
||||
style="@style/Widget.Auxio.Image.Small"
|
||||
android:layout_margin="@dimen/spacing_medium"
|
||||
|
@ -47,6 +47,7 @@
|
|||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/spacing_medium"
|
||||
android:textColor="@color/sel_toggleable_primary"
|
||||
app:layout_constraintBottom_toTopOf="@+id/song_info"
|
||||
app:layout_constraintEnd_toStartOf="@+id/song_drag_handle"
|
||||
app:layout_constraintStart_toEndOf="@+id/song_album_cover"
|
||||
|
@ -60,6 +61,7 @@
|
|||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/spacing_medium"
|
||||
android:textColor="@color/sel_toggleable_secondary"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/song_drag_handle"
|
||||
app:layout_constraintStart_toEndOf="@+id/song_album_cover"
|
||||
|
|
Loading…
Reference in a new issue