From fefe2d244dadda234e051e148540f005aa837d9c Mon Sep 17 00:00:00 2001 From: OxygenCobalt Date: Mon, 1 Mar 2021 19:24:37 -0700 Subject: [PATCH] Add tooltips to accent picker Add tooltips to the accent picker that align with the content description. --- .../playback/state/PlaybackStateManager.kt | 22 ++++++++++--------- .../auxio/settings/ui/AccentAdapter.kt | 13 ++++++----- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/org/oxycblt/auxio/playback/state/PlaybackStateManager.kt b/app/src/main/java/org/oxycblt/auxio/playback/state/PlaybackStateManager.kt index f9ded9c7d..774d8292e 100644 --- a/app/src/main/java/org/oxycblt/auxio/playback/state/PlaybackStateManager.kt +++ b/app/src/main/java/org/oxycblt/auxio/playback/state/PlaybackStateManager.kt @@ -396,7 +396,7 @@ class PlaybackStateManager private constructor() { logD("Removing item ${mUserQueue[index].name}.") if (index > mUserQueue.size || index < 0) { - logE("Index is out of bounds, did not remove queue item.") + logE("Index is out of bounds, did not remove user queue item.") return } @@ -411,7 +411,7 @@ class PlaybackStateManager private constructor() { */ fun moveUserQueueItems(from: Int, to: Int) { if (from > mUserQueue.size || from < 0 || to > mUserQueue.size || to < 0) { - logE("Indices were out of bounds, did not move queue item") + logE("Indices were out of bounds, did not move user queue item") return } @@ -713,16 +713,18 @@ class PlaybackStateManager private constructor() { * @param queueItems The list of [QueueItem]s to unpack. */ private fun unpackQueue(queueItems: List) { + // When unpacking, first traverse albums and then traverse album songs to reduce + // the amount of useless comparisons in large queues. queueItems.forEach { item -> - // Traverse albums and then album songs instead of just the songs, as its faster. - musicStore.albums.find { it.name == item.albumName } - ?.songs?.find { it.name == item.songName }?.let { - if (item.isUserQueue) { - mUserQueue.add(it) - } else { - mQueue.add(it) - } + musicStore.albums.find { it.name == item.albumName }?.songs?.find { + it.name == item.songName + }?.let { + if (item.isUserQueue) { + mUserQueue.add(it) + } else { + mQueue.add(it) } + } } // When done, get a more accurate index to prevent issues with queue songs that were saved diff --git a/app/src/main/java/org/oxycblt/auxio/settings/ui/AccentAdapter.kt b/app/src/main/java/org/oxycblt/auxio/settings/ui/AccentAdapter.kt index cb2cc2d80..05bf0656d 100644 --- a/app/src/main/java/org/oxycblt/auxio/settings/ui/AccentAdapter.kt +++ b/app/src/main/java/org/oxycblt/auxio/settings/ui/AccentAdapter.kt @@ -1,6 +1,7 @@ package org.oxycblt.auxio.settings.ui import android.view.ViewGroup +import androidx.appcompat.widget.TooltipCompat import androidx.recyclerview.widget.RecyclerView import org.oxycblt.auxio.R import org.oxycblt.auxio.databinding.ItemAccentBinding @@ -33,11 +34,7 @@ class AccentAdapter( fun bind(accent: Accent) { binding.accent.apply { - contentDescription = accent.getDetailedSummary(context) - - setOnClickListener { - doOnAccentConfirm(accent) - } + contentDescription = context.getString(accent.name) imageTintList = if (accent == Accent.get()) { isEnabled = false @@ -50,6 +47,12 @@ class AccentAdapter( } backgroundTintList = accent.getStateList(context) + + TooltipCompat.setTooltipText(this, contentDescription) + + setOnClickListener { + doOnAccentConfirm(accent) + } } } }