accent: simplify accents
Simplify the accent scheme: - Light Blue was re-generated to be a weird darker-on-light-mode lighter-on-dark-mode blue that looked really similar to how blue-grey turned out. These have been merged into a new color scheme called deep blue. - Deep Orange and Red were too similar after being re-generated, so they have been merged to become a simple red accent.
This commit is contained in:
@@ -18,13 +18,7 @@
|
||||
|
||||
package org.oxycblt.auxio.accent
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.res.ColorStateList
|
||||
import android.text.Spanned
|
||||
import androidx.core.text.HtmlCompat
|
||||
import org.oxycblt.auxio.R
|
||||
import org.oxycblt.auxio.util.resolveStateList
|
||||
|
||||
val ACCENT_PRIMARY_COLORS = arrayOf(
|
||||
R.color.red_primary,
|
||||
@@ -41,10 +35,8 @@ val ACCENT_PRIMARY_COLORS = arrayOf(
|
||||
R.color.lime_primary,
|
||||
R.color.yellow_primary,
|
||||
R.color.orange_primary,
|
||||
R.color.deep_orange_primary,
|
||||
R.color.brown_primary,
|
||||
R.color.grey_primary,
|
||||
R.color.blue_grey_primary
|
||||
)
|
||||
|
||||
val ACCENT_THEMES = arrayOf(
|
||||
@@ -62,10 +54,8 @@ val ACCENT_THEMES = arrayOf(
|
||||
R.style.Theme_Auxio_Lime,
|
||||
R.style.Theme_Auxio_Yellow,
|
||||
R.style.Theme_Auxio_Orange,
|
||||
R.style.Theme_Auxio_DeepOrange,
|
||||
R.style.Theme_Auxio_Brown,
|
||||
R.style.Theme_Auxio_Grey,
|
||||
R.style.Theme_Auxio_BlueGrey
|
||||
)
|
||||
|
||||
val ACCENT_BLACK_THEMES = arrayOf(
|
||||
@@ -83,10 +73,8 @@ val ACCENT_BLACK_THEMES = arrayOf(
|
||||
R.style.Theme_Auxio_Black_Lime,
|
||||
R.style.Theme_Auxio_Black_Yellow,
|
||||
R.style.Theme_Auxio_Black_Orange,
|
||||
R.style.Theme_Auxio_Black_DeepOrange,
|
||||
R.style.Theme_Auxio_Black_Brown,
|
||||
R.style.Theme_Auxio_Black_Grey,
|
||||
R.style.Theme_Auxio_Black_BlueGrey
|
||||
)
|
||||
|
||||
val ACCENT_NAMES = arrayOf(
|
||||
@@ -104,44 +92,23 @@ val ACCENT_NAMES = arrayOf(
|
||||
R.string.clr_lime,
|
||||
R.string.clr_yellow,
|
||||
R.string.clr_orange,
|
||||
R.string.clr_deep_orange,
|
||||
R.string.clr_brown,
|
||||
R.string.clr_grey,
|
||||
R.string.clr_blue_grey
|
||||
)
|
||||
|
||||
/**
|
||||
* The data object for an accent.
|
||||
* @property color The primary color resource for this accent
|
||||
* @property name The name of this accent
|
||||
* @property theme The theme resource for this accent
|
||||
* @property blackTheme The black theme resource for this accent
|
||||
* @property name The name of this accent
|
||||
* @property primary The primary color resource for this accent
|
||||
* @author OxygenCobalt
|
||||
*/
|
||||
data class Accent(val index: Int) {
|
||||
val color: Int get() = ACCENT_PRIMARY_COLORS[index]
|
||||
val name: Int get() = ACCENT_NAMES[index]
|
||||
val theme: Int get() = ACCENT_THEMES[index]
|
||||
val blackTheme: Int get() = ACCENT_BLACK_THEMES[index]
|
||||
val name: Int get() = ACCENT_NAMES[index]
|
||||
|
||||
/**
|
||||
* Get a [ColorStateList] of the accent
|
||||
*/
|
||||
fun getStateList(context: Context) = color.resolveStateList(context)
|
||||
|
||||
/**
|
||||
* Get the name (in bold) and the hex value of a accent.
|
||||
*/
|
||||
@SuppressLint("ResourceType")
|
||||
fun getDetailedSummary(context: Context): Spanned {
|
||||
val name = context.getString(name)
|
||||
val hex = context.getString(color).uppercase()
|
||||
|
||||
return HtmlCompat.fromHtml(
|
||||
context.getString(R.string.fmt_accent_desc, name, hex),
|
||||
HtmlCompat.FROM_HTML_MODE_COMPACT
|
||||
)
|
||||
}
|
||||
val primary: Int get() = ACCENT_PRIMARY_COLORS[index]
|
||||
|
||||
companion object {
|
||||
@Volatile
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.oxycblt.auxio.R
|
||||
import org.oxycblt.auxio.databinding.ItemAccentBinding
|
||||
import org.oxycblt.auxio.util.inflater
|
||||
import org.oxycblt.auxio.util.resolveAttr
|
||||
import org.oxycblt.auxio.util.resolveColor
|
||||
import org.oxycblt.auxio.util.resolveStateList
|
||||
|
||||
/**
|
||||
@@ -62,8 +63,8 @@ class AccentAdapter(
|
||||
setSelected(accent == curAccent)
|
||||
|
||||
binding.accent.apply {
|
||||
backgroundTintList = ColorStateList.valueOf(accent.primary.resolveColor(context))
|
||||
contentDescription = context.getString(accent.name)
|
||||
backgroundTintList = accent.getStateList(context)
|
||||
TooltipCompat.setTooltipText(this, contentDescription)
|
||||
}
|
||||
|
||||
|
||||
@@ -56,8 +56,8 @@ fun handleThemeCompat(prefs: SharedPreferences): Int {
|
||||
}
|
||||
|
||||
fun handleAccentCompat(prefs: SharedPreferences): Accent {
|
||||
if (prefs.contains(OldKeys.KEY_ACCENT)) {
|
||||
var accent = prefs.getInt(OldKeys.KEY_ACCENT, 5)
|
||||
if (prefs.contains(OldKeys.KEY_ACCENT1)) {
|
||||
var accent = prefs.getInt(OldKeys.KEY_ACCENT1, 5)
|
||||
|
||||
// Correct any accents over yellow to their correct positions
|
||||
if (accent > 12) {
|
||||
@@ -74,15 +74,42 @@ fun handleAccentCompat(prefs: SharedPreferences): Accent {
|
||||
accent = ACCENT_PRIMARY_COLORS.lastIndex
|
||||
}
|
||||
|
||||
// Move this to the [also legacy] ACCENT2 field. This makes it easier to convert in the
|
||||
// next step.
|
||||
prefs.edit {
|
||||
putInt(SettingsManager.KEY_ACCENT, accent)
|
||||
remove(OldKeys.KEY_ACCENT)
|
||||
putInt(OldKeys.KEY_ACCENT2, accent)
|
||||
remove(OldKeys.KEY_ACCENT1)
|
||||
apply()
|
||||
}
|
||||
|
||||
return Accent(accent)
|
||||
}
|
||||
|
||||
if (prefs.contains(OldKeys.KEY_ACCENT2)) {
|
||||
var accent = prefs.getInt(OldKeys.KEY_ACCENT2, 5)
|
||||
|
||||
// Blue grey was merged with Light Blue in 2.0.0
|
||||
if (accent >= 17) {
|
||||
accent = 6
|
||||
}
|
||||
|
||||
// Deep Orange was merged with red in 2.0.0
|
||||
if (accent == 14) {
|
||||
accent = 0
|
||||
}
|
||||
|
||||
// Correct accents beyond deep orange (Brown/Grey)
|
||||
if (accent > 14) {
|
||||
accent--
|
||||
}
|
||||
|
||||
prefs.edit {
|
||||
putInt(SettingsManager.KEY_ACCENT, accent)
|
||||
remove(OldKeys.KEY_ACCENT2)
|
||||
apply()
|
||||
}
|
||||
}
|
||||
|
||||
return Accent(prefs.getInt(SettingsManager.KEY_ACCENT, 5))
|
||||
}
|
||||
|
||||
@@ -119,7 +146,8 @@ private fun SharedPreferences.getStringOrNull(key: String): String? = getString(
|
||||
* Cache of the old keys used in Auxio.
|
||||
*/
|
||||
private object OldKeys {
|
||||
const val KEY_ACCENT = "KEY_ACCENT"
|
||||
const val KEY_ACCENT1 = "KEY_ACCENT"
|
||||
const val KEY_ACCENT2 = "KEY_ACCENT2"
|
||||
const val KEY_THEME = "KEY_THEME"
|
||||
const val KEY_SONG_PLAYBACK_MODE = "KEY_SONG_PLAY_MODE"
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package org.oxycblt.auxio.settings
|
||||
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.annotation.DrawableRes
|
||||
@@ -32,7 +31,6 @@ import androidx.preference.children
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import coil.Coil
|
||||
import org.oxycblt.auxio.R
|
||||
import org.oxycblt.auxio.accent.Accent
|
||||
import org.oxycblt.auxio.accent.AccentDialog
|
||||
import org.oxycblt.auxio.excluded.ExcludedDialog
|
||||
import org.oxycblt.auxio.playback.PlaybackViewModel
|
||||
@@ -91,6 +89,10 @@ class SettingsListFragment : PreferenceFragmentCompat() {
|
||||
* Recursively call [handlePreference] on a preference.
|
||||
*/
|
||||
private fun recursivelyHandleChildren(preference: Preference) {
|
||||
if (!preference.isVisible) {
|
||||
return
|
||||
}
|
||||
|
||||
if (preference is PreferenceCategory) {
|
||||
// If this preference is a category of its own, handle its own children
|
||||
preference.children.forEach { pref ->
|
||||
@@ -108,8 +110,6 @@ class SettingsListFragment : PreferenceFragmentCompat() {
|
||||
pref.apply {
|
||||
when (key) {
|
||||
SettingsManager.KEY_THEME -> {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) return
|
||||
|
||||
setIcon(AppCompatDelegate.getDefaultNightMode().toThemeIcon())
|
||||
|
||||
onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, value ->
|
||||
@@ -120,8 +120,6 @@ class SettingsListFragment : PreferenceFragmentCompat() {
|
||||
}
|
||||
|
||||
SettingsManager.KEY_BLACK_THEME -> {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) return
|
||||
|
||||
onPreferenceClickListener = Preference.OnPreferenceClickListener {
|
||||
if (requireContext().isNight) {
|
||||
requireActivity().recreate()
|
||||
@@ -132,14 +130,12 @@ class SettingsListFragment : PreferenceFragmentCompat() {
|
||||
}
|
||||
|
||||
SettingsManager.KEY_ACCENT -> {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) return
|
||||
|
||||
onPreferenceClickListener = Preference.OnPreferenceClickListener {
|
||||
AccentDialog().show(childFragmentManager, AccentDialog.TAG)
|
||||
true
|
||||
}
|
||||
|
||||
summary = Accent.get().getDetailedSummary(context)
|
||||
summary = context.getString(settingsManager.accent.name)
|
||||
}
|
||||
|
||||
SettingsManager.KEY_LIB_TABS -> {
|
||||
|
||||
@@ -251,7 +251,7 @@ class SettingsManager private constructor(context: Context) :
|
||||
companion object {
|
||||
const val KEY_THEME = "KEY_THEME2"
|
||||
const val KEY_BLACK_THEME = "KEY_BLACK_THEME"
|
||||
const val KEY_ACCENT = "KEY_ACCENT2"
|
||||
const val KEY_ACCENT = "KEY_ACCENT3"
|
||||
|
||||
const val KEY_LIB_TABS = "KEY_LIB_TABS"
|
||||
const val KEY_SHOW_COVERS = "KEY_SHOW_COVERS"
|
||||
|
||||
Reference in New Issue
Block a user