Show Material You as accent color on Android 12+

This commit is contained in:
Bnyro 2022-12-05 19:14:42 +01:00
parent 5bbd699ba3
commit c1f6b442d3

View File

@ -1,9 +1,11 @@
package com.github.libretube.ui.preferences package com.github.libretube.ui.preferences
import android.os.Build
import android.os.Bundle import android.os.Bundle
import androidx.preference.ListPreference import androidx.preference.ListPreference
import androidx.preference.Preference import androidx.preference.Preference
import androidx.preference.SwitchPreferenceCompat import androidx.preference.SwitchPreferenceCompat
import com.github.libretube.BuildConfig
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.constants.PreferenceKeys import com.github.libretube.constants.PreferenceKeys
import com.github.libretube.ui.adapters.IconsSheetAdapter import com.github.libretube.ui.adapters.IconsSheetAdapter
@ -78,16 +80,17 @@ class AppearanceSettings : BasePreferenceFragment() {
} }
} }
// remove material you from accent color option if not available /**
* Remove material you from accent color option if not available
*/
private fun updateAccentColorValues(pref: ListPreference) { private fun updateAccentColorValues(pref: ListPreference) {
val dynamicColorsAvailable = DynamicColors.isDynamicColorAvailable() if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) {
if (!dynamicColorsAvailable) { pref.entries = pref.entries.toMutableList().apply {
val entries = pref.entries.toMutableList() removeFirst()
entries -= entries[0] }.toTypedArray()
pref.entries = entries.toTypedArray() pref.entryValues = pref.entryValues.toMutableList().apply {
val values = pref.entryValues.toMutableList() removeFirst()
values -= values[0] }.toTypedArray()
pref.entryValues = values.toTypedArray()
} }
} }
} }