Merge pull request #2249 from Bnyro/my

Show Material You as accent color on Android 12+
This commit is contained in:
Bnyro 2022-12-05 19:15:29 +01:00 committed by GitHub
commit 5312e007f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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()
} }
} }
} }