Improve accents

Add a new "Neutral" accent and improve the yellow accent so that its more visible.
This commit is contained in:
OxygenCobalt
2020-12-05 10:42:22 -07:00
parent c44003907a
commit dbd2c022a0
11 changed files with 26 additions and 20 deletions
@@ -21,7 +21,6 @@ import org.oxycblt.auxio.music.MusicStore
import org.oxycblt.auxio.music.Song
import org.oxycblt.auxio.playback.PlaybackViewModel
import org.oxycblt.auxio.ui.accent
import org.oxycblt.auxio.ui.getInactiveAlpha
import org.oxycblt.auxio.ui.getTransparentAccent
import org.oxycblt.auxio.ui.toColor
import kotlin.IllegalArgumentException
@@ -48,9 +47,7 @@ class MainFragment : Fragment() {
val colorActive = accent.first.toColor(requireContext())
val colorInactive = getTransparentAccent(
requireContext(),
accent.first,
getInactiveAlpha(accent.first)
requireContext(), accent.first, 150
)
// Set up the tints for the navigation icons + text
@@ -50,6 +50,9 @@ class QueueFragment : Fragment() {
findNavController().navigateUp()
}
// Since QueueFragment doesn't fit system windows, inset padding needs to be
// artificially applied to the Toolbar so that it fits on the main window AND
// so that the elevation doesn't show on the top.
setOnApplyWindowInsetsListener { _, insets ->
val top = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
insets.getInsets(WindowInsets.Type.systemBars()).top
@@ -285,31 +285,35 @@ class PlaybackStateManager private constructor() {
forceQueueUpdate()
}
fun removeQueueItem(index: Int) {
fun removeQueueItem(index: Int): Boolean {
Log.d(this::class.simpleName, "Removing item ${mQueue[index].name}.")
if (index > mQueue.size || index < 0) {
Log.e(this::class.simpleName, "Index is out of bounds, did not remove queue item.")
return
return false
}
mQueue.removeAt(index)
forceQueueUpdate()
return true
}
fun moveQueueItems(from: Int, to: Int) {
fun moveQueueItems(from: Int, to: Int): Boolean {
try {
val item = mQueue.removeAt(from)
mQueue.add(to, item)
} catch (exception: IndexOutOfBoundsException) {
Log.e(this::class.simpleName, "Indices were out of bounds, did not move queue item")
return
return false
}
forceQueueUpdate()
return true
}
fun addToUserQueue(song: Song) {
@@ -6,7 +6,7 @@ import org.oxycblt.auxio.R
/**
* Convert a string representing a theme entry name to an actual theme int that can be used.
* This is only done because PreferenceFragment does not like int arrays.
* This is only done because PreferenceFragment does not like int arrays for some...reason.
*/
fun String.toThemeInt(): Int {
return when (this) {
@@ -38,7 +38,8 @@ val ACCENTS = arrayOf(
Pair(R.color.deep_orange, R.style.Theme_DeepOrange), // 15
Pair(R.color.brown, R.style.Theme_Brown), // 16
Pair(R.color.grey, R.style.Theme_Gray), // 17
Pair(R.color.blue_grey, R.style.Theme_BlueGrey) // 18
Pair(R.color.blue_grey, R.style.Theme_BlueGrey), // 18
Pair(R.color.control_color, R.style.Theme_Neutral)
)
/**
@@ -55,7 +56,7 @@ private val ACCENT_NAMES = arrayOf(
R.string.color_label_yellow, R.string.color_label_amber,
R.string.color_label_orange, R.string.color_label_deep_orange,
R.string.color_label_brown, R.string.color_label_grey,
R.string.color_label_blue_grey
R.string.color_label_blue_grey, R.string.color_label_neutral
)
/**
@@ -78,14 +79,6 @@ fun getTransparentAccent(context: Context, @ColorRes color: Int, alpha: Int): In
)
}
/**
* Get the inactive alpha of an accent.
*/
@ColorInt
fun getInactiveAlpha(@ColorRes color: Int): Int {
return if (color == R.color.yellow) 100 else 150
}
/**
* Resolve a color.
* @param context [Context] required