theme: re-add black theme on android 12

Re-add the black theme on Android 12. It still has use, unlike the
other theme options made obsolete by dynamic colors.
This commit is contained in:
OxygenCobalt 2021-12-06 06:22:13 -07:00
parent 4b7fa7415c
commit 6b355d6416
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47
6 changed files with 23 additions and 10 deletions

View file

@ -90,12 +90,16 @@ class MainActivity : AppCompatActivity() {
}
private fun setupTheme() {
// We only use Material You theming on Android 12 and above.
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) {
// Update the current accent and theme
val settingsManager = SettingsManager.getInstance()
AppCompatDelegate.setDefaultNightMode(settingsManager.theme)
val settingsManager = SettingsManager.getInstance()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
// Android 12, let dynamic colors be our accent and only enable the black theme option
if (isNight && settingsManager.useBlackTheme) {
setTheme(R.style.Theme_Auxio_Black)
}
} else {
// Below android 12, load the accent and enable theme customization
AppCompatDelegate.setDefaultNightMode(settingsManager.theme)
val newAccent = Accent.set(settingsManager.accent)
// The black theme has a completely separate set of styles since style attributes cannot

View file

@ -145,8 +145,7 @@ class SettingsListFragment : PreferenceFragmentCompat() {
}
}
SettingsManager.KEY_SHOW_COVERS, SettingsManager.KEY_QUALITY_COVERS,
SettingsManager.KEY_ROUND_COVERS -> {
SettingsManager.KEY_SHOW_COVERS, SettingsManager.KEY_QUALITY_COVERS, -> {
onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, _ ->
Coil.imageLoader(requireContext()).apply {
this.memoryCache?.clear()

View file

@ -32,7 +32,7 @@ fun Any.logD(obj: Any) {
}
/**
* Shortcut method for logging [msg] to the debug console., handles debug builds and anonymous objects
* Shortcut method for logging [msg] to the debug console. Handles debug builds and anonymous objects
*/
fun Any.logD(msg: String) {
if (BuildConfig.DEBUG) {
@ -56,7 +56,11 @@ fun Any.logE(msg: String) {
private fun Any.getName(): String = "Auxio.${this::class.simpleName ?: "Anonymous Object"}"
/**
* Nothing to see here.
* I know that this will not stop you, but consider what you are doing with your life, copycats.
* Do you want to live a fulfilling existence on this planet? Or do you want to spend your life
* taking work others did and making it objectively worse so you could arbitrage a fraction of a
* penny on every AdMob impression you get. You could do so many great things if you simply had
* the courage to come up with an idea of your own. Be better.
*/
private fun basedCopyleftNotice() {
if (BuildConfig.APPLICATION_ID != "org.oxycblt.auxio" &&

View file

@ -142,3 +142,4 @@ val WindowInsets.systemBarsCompat: Rect get() {
else -> Rect(0, 0, 0, 0)
}
}

View file

@ -1,5 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Auxio.Black" parent="Theme.Auxio.App">
<item name="colorSurface">@android:color/black</item>
</style>
<style name="Theme.Auxio.Black.Red" parent="Theme.Auxio.Red">
<item name="colorSurface">@android:color/black</item>
</style>

View file

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto">
<PreferenceCategory
app:isPreferenceVisible="@bool/enable_theme_settings"
app:layout="@layout/item_header"
app:title="@string/set_ui">
<org.oxycblt.auxio.settings.pref.IntListPreference
app:defaultValue="@integer/theme_auto"
app:isPreferenceVisible="@bool/enable_theme_settings"
app:entries="@array/entires_theme"
app:entryValues="@array/values_theme"
app:icon="@drawable/ic_day"
@ -15,6 +15,7 @@
app:title="@string/set_theme" />
<Preference
app:isPreferenceVisible="@bool/enable_theme_settings"
app:icon="@drawable/ic_accent"
app:key="auxio_accent"
app:title="@string/set_accent" />