ui: make default accent dynamic on api 31
Make the default accent the dynamic accent on API 31. This is to make Auxio's Material You support obvious to the user.
This commit is contained in:
@@ -81,8 +81,7 @@ fun handleAccentCompat(prefs: SharedPreferences): Accent {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Default accent on android 12 should be dynamic colors
|
||||
return Accent.from(prefs.getInt(SettingsManager.KEY_ACCENT, 5))
|
||||
return Accent.from(prefs.getInt(SettingsManager.KEY_ACCENT, Accent.DEFAULT))
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.oxycblt.auxio.ui.accent
|
||||
|
||||
import android.os.Build
|
||||
import org.oxycblt.auxio.R
|
||||
import org.oxycblt.auxio.util.logW
|
||||
import org.oxycblt.auxio.util.logEOrThrow
|
||||
|
||||
private val ACCENT_NAMES =
|
||||
intArrayOf(
|
||||
@@ -131,13 +131,20 @@ class Accent private constructor(val index: Int) {
|
||||
companion object {
|
||||
fun from(index: Int): Accent {
|
||||
if (index > (MAX - 1)) {
|
||||
logW("Account outside of bounds [idx: $index, max: $MAX]")
|
||||
logEOrThrow("Account outside of bounds [idx: $index, max: $MAX]")
|
||||
return Accent(5)
|
||||
}
|
||||
|
||||
return Accent(index)
|
||||
}
|
||||
|
||||
val DEFAULT =
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
ACCENT_THEMES.lastIndex
|
||||
} else {
|
||||
5
|
||||
}
|
||||
|
||||
/**
|
||||
* The maximum amount of accents that are valid. This excludes the dynamic accent on
|
||||
* versions that do not support it.
|
||||
|
||||
Reference in New Issue
Block a user