forked from recloudstream/cloudstream
[hotfix] fix material you theme crashing on a11
This commit is contained in:
parent
af1f8c52ac
commit
91258095a9
2 changed files with 35 additions and 7 deletions
|
@ -166,7 +166,8 @@ object CommonActivity {
|
|||
"Light" -> R.style.LightMode
|
||||
"Amoled" -> R.style.AmoledMode
|
||||
"AmoledLight" -> R.style.AmoledModeLight
|
||||
"Monet" -> R.style.MonetMode
|
||||
"Monet" -> if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S)
|
||||
R.style.MonetMode else R.style.AppTheme
|
||||
else -> R.style.AppTheme
|
||||
}
|
||||
|
||||
|
@ -187,8 +188,10 @@ object CommonActivity {
|
|||
"Banana" -> R.style.OverlayPrimaryColorBanana
|
||||
"Party" -> R.style.OverlayPrimaryColorParty
|
||||
"Pink" -> R.style.OverlayPrimaryColorPink
|
||||
"Monet" -> R.style.OverlayPrimaryColorMonet
|
||||
"Monet2" -> R.style.OverlayPrimaryColorMonetTwo
|
||||
"Monet" -> if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S)
|
||||
R.style.OverlayPrimaryColorMonet else R.style.OverlayPrimaryColorNormal
|
||||
"Monet2" -> if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S)
|
||||
R.style.OverlayPrimaryColorMonetTwo else R.style.OverlayPrimaryColorNormal
|
||||
else -> R.style.OverlayPrimaryColorNormal
|
||||
}
|
||||
act.theme.applyStyle(currentTheme, true)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.lagradost.cloudstream3.ui.settings
|
||||
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
|
@ -83,8 +84,20 @@ class SettingsUI : PreferenceFragmentCompat() {
|
|||
}
|
||||
|
||||
getPref(R.string.app_theme_key)?.setOnPreferenceClickListener {
|
||||
val prefNames = resources.getStringArray(R.array.themes_names)
|
||||
val prefValues = resources.getStringArray(R.array.themes_names_values)
|
||||
val prefNames = resources.getStringArray(R.array.themes_names).toMutableList()
|
||||
val prefValues = resources.getStringArray(R.array.themes_names_values).toMutableList()
|
||||
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) { // remove monet on android 11 and less
|
||||
val toRemove = prefValues
|
||||
.mapIndexed { idx, s -> if (s.startsWith("Monet")) idx else null }
|
||||
.filterNotNull()
|
||||
var offset = 0
|
||||
toRemove.forEach { idx ->
|
||||
prefNames.removeAt(idx - offset)
|
||||
prefValues.removeAt(idx - offset)
|
||||
offset += 1
|
||||
}
|
||||
}
|
||||
|
||||
val currentLayout =
|
||||
settingsManager.getString(getString(R.string.app_theme_key), prefValues.first())
|
||||
|
@ -107,8 +120,20 @@ class SettingsUI : PreferenceFragmentCompat() {
|
|||
return@setOnPreferenceClickListener true
|
||||
}
|
||||
getPref(R.string.primary_color_key)?.setOnPreferenceClickListener {
|
||||
val prefNames = resources.getStringArray(R.array.themes_overlay_names)
|
||||
val prefValues = resources.getStringArray(R.array.themes_overlay_names_values)
|
||||
val prefNames = resources.getStringArray(R.array.themes_overlay_names).toMutableList()
|
||||
val prefValues = resources.getStringArray(R.array.themes_overlay_names_values).toMutableList()
|
||||
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) { // remove monet on android 11 and less
|
||||
val toRemove = prefValues
|
||||
.mapIndexed { idx, s -> if (s.startsWith("Monet")) idx else null }
|
||||
.filterNotNull()
|
||||
var offset = 0
|
||||
toRemove.forEach { idx ->
|
||||
prefNames.removeAt(idx - offset)
|
||||
prefValues.removeAt(idx - offset)
|
||||
offset += 1
|
||||
}
|
||||
}
|
||||
|
||||
val currentLayout =
|
||||
settingsManager.getString(getString(R.string.primary_color_key), prefValues.first())
|
||||
|
|
Loading…
Reference in a new issue