ui: redefine activation meaning

Redefine the meaning of activation across the app to align with the SDK
documentation.

According to the documentation:
- Activation -> A permanent kind of selection initiated by the user.
This means playback states, item selection, etc.
- Selection -> A transient kind of selection that can be added or
removed without user input. This includes things such as playing
indicators.

Redefine usages of selection and activation across the app to align
with this.
This commit is contained in:
Alexander Capehart
2022-11-22 12:43:51 -07:00
parent a4cc27d85e
commit df6d80176d
25 changed files with 42 additions and 52 deletions
@@ -197,7 +197,7 @@ private class AlbumSongViewHolder private constructor(private val binding: ItemA
}
override fun updateIndicator(isActive: Boolean, isPlaying: Boolean) {
binding.root.isActivated = isActive
binding.root.isSelected = isActive
binding.songTrackBg.isPlaying = isPlaying
}
@@ -165,7 +165,7 @@ private class ArtistAlbumViewHolder private constructor(private val binding: Ite
}
override fun updateIndicator(isActive: Boolean, isPlaying: Boolean) {
binding.root.isActivated = isActive
binding.root.isSelected = isActive
binding.parentImage.isPlaying = isPlaying
}
@@ -194,7 +194,7 @@ private class ArtistSongViewHolder private constructor(private val binding: Item
}
override fun updateIndicator(isActive: Boolean, isPlaying: Boolean) {
binding.root.isActivated = isActive
binding.root.isSelected = isActive
binding.songAlbumCover.isPlaying = isPlaying
}
@@ -115,8 +115,7 @@ constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr
override fun setActivated(activated: Boolean) {
super.setActivated(activated)
invalidateAlpha()
invalidatePlayingIndicator()
invalidateSelectionIndicator()
}
override fun setEnabled(enabled: Boolean) {
@@ -127,7 +126,8 @@ constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr
override fun setSelected(selected: Boolean) {
super.setSelected(selected)
invalidateSelectionIndicator()
invalidateAlpha()
invalidatePlayingIndicator()
}
var isPlaying: Boolean
@@ -137,11 +137,11 @@ constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr
}
private fun invalidateAlpha() {
alpha = if (isActivated || isEnabled) 1f else 0.5f
alpha = if (isSelected || isEnabled) 1f else 0.5f
}
private fun invalidatePlayingIndicator() {
if (isActivated) {
if (isSelected) {
customView?.alpha = 0f
inner.alpha = 0f
playingIndicator.alpha = 1f
@@ -153,7 +153,7 @@ constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr
}
private fun invalidateSelectionIndicator() {
selectionIndicator.alpha = if (isSelected) 1f else 0f
selectionIndicator.alpha = if (isActivated) 1f else 0f
}
fun bind(song: Song) {
@@ -84,7 +84,7 @@ class PlaybackBarFragment : ViewBindingFragment<FragmentPlaybackBarBinding>() {
ActionMode.REPEAT -> {
binding.playbackSecondaryAction.apply {
contentDescription = getString(R.string.desc_change_repeat)
iconTint = context.getColorCompat(R.color.sel_accented)
iconTint = context.getColorCompat(R.color.sel_activatable_icon)
setOnClickListener { playbackModel.incrementRepeatMode() }
collectImmediately(playbackModel.repeatMode, ::updateRepeat)
}
@@ -93,7 +93,7 @@ class PlaybackBarFragment : ViewBindingFragment<FragmentPlaybackBarBinding>() {
binding.playbackSecondaryAction.apply {
setIconResource(R.drawable.sel_shuffle_state_24)
contentDescription = getString(R.string.desc_shuffle)
iconTint = context.getColorCompat(R.color.sel_accented)
iconTint = context.getColorCompat(R.color.sel_activatable_icon)
setOnClickListener { playbackModel.invertShuffled() }
collectImmediately(playbackModel.isShuffled, ::updateShuffled)
}
@@ -165,7 +165,7 @@ class QueueSongViewHolder private constructor(private val binding: ItemQueueSong
}
override fun updateIndicator(isActive: Boolean, isPlaying: Boolean) {
binding.interactBody.isActivated = isActive
binding.interactBody.isSelected = isActive
binding.songAlbumCover.isPlaying = isPlaying
}
@@ -70,7 +70,7 @@ constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
// Sanity check 2: Ensure that this value is within the duration and will not crash
// the app, and that the user is not currently seeking (which would cause the SeekBar
// to jump around).
if (from <= durationDs && !isActivated) {
if (from <= durationDs && !isSelected) {
binding.seekBarSlider.value = from.toFloat()
// We would want to keep this in the callback, but the callback only fires when
@@ -106,13 +106,13 @@ constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
logD("Starting seek mode")
// User has begun seeking, place the SeekBar into a "Suspended" mode in which no
// position updates are sent and is indicated by the position value turning accented.
isActivated = true
isSelected = true
}
override fun onStopTrackingTouch(slider: Slider) {
logD("Confirming seek")
// End of seek event, send off new value to callback.
isActivated = false
isSelected = false
callback?.seekTo(slider.value.toLong())
}
@@ -47,7 +47,7 @@ class SongViewHolder private constructor(private val binding: ItemSongBinding) :
}
override fun updateIndicator(isActive: Boolean, isPlaying: Boolean) {
binding.root.isActivated = isActive
binding.root.isSelected = isActive
binding.songAlbumCover.isPlaying = isPlaying
}
@@ -80,7 +80,7 @@ class AlbumViewHolder private constructor(private val binding: ItemParentBinding
}
override fun updateIndicator(isActive: Boolean, isPlaying: Boolean) {
binding.root.isActivated = isActive
binding.root.isSelected = isActive
binding.parentImage.isPlaying = isPlaying
}
@@ -126,7 +126,7 @@ class ArtistViewHolder private constructor(private val binding: ItemParentBindin
}
override fun updateIndicator(isActive: Boolean, isPlaying: Boolean) {
binding.root.isActivated = isActive
binding.root.isSelected = isActive
binding.parentImage.isPlaying = isPlaying
}
@@ -165,7 +165,7 @@ class GenreViewHolder private constructor(private val binding: ItemParentBinding
}
override fun updateIndicator(isActive: Boolean, isPlaying: Boolean) {
binding.root.isActivated = isActive
binding.root.isSelected = isActive
binding.parentImage.isPlaying = isPlaying
}