Allow Samsung devices on Android 12+ to use dynamic theme

Since it seems to work fine, regardless of what the Material Components library seems to dictate.
This commit is contained in:
arkon 2022-01-22 14:53:12 -05:00
parent 9984e983b4
commit e3f3686b8a
3 changed files with 8 additions and 4 deletions

View File

@ -6,7 +6,6 @@ import android.os.Environment
import androidx.core.content.edit
import androidx.core.net.toUri
import androidx.preference.PreferenceManager
import com.google.android.material.color.DynamicColors
import com.tfcporciuncula.flow.FlowSharedPreferences
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.database.models.Manga
@ -73,7 +72,7 @@ class PreferencesHelper(val context: Context) {
fun appTheme() = flowPrefs.getEnum(
"pref_app_theme",
if (DynamicColors.isDynamicColorAvailable()) { Values.AppTheme.MONET } else { Values.AppTheme.DEFAULT }
if (DeviceUtil.isDynamicColorAvailable) { Values.AppTheme.MONET } else { Values.AppTheme.DEFAULT }
)
fun themeDarkAmoled() = flowPrefs.getBoolean("pref_theme_dark_amoled_key", false)

View File

@ -5,7 +5,6 @@ import android.os.Bundle
import android.view.View
import androidx.core.app.ActivityCompat
import androidx.preference.PreferenceScreen
import com.google.android.material.color.DynamicColors
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.util.preference.bindTo
import eu.kanade.tachiyomi.util.preference.defaultValue
@ -17,6 +16,7 @@ import eu.kanade.tachiyomi.util.preference.onChange
import eu.kanade.tachiyomi.util.preference.preferenceCategory
import eu.kanade.tachiyomi.util.preference.switchPreference
import eu.kanade.tachiyomi.util.preference.titleRes
import eu.kanade.tachiyomi.util.system.DeviceUtil
import eu.kanade.tachiyomi.util.system.isTablet
import eu.kanade.tachiyomi.widget.preference.ThemesPreference
import java.util.Date
@ -67,7 +67,7 @@ class SettingsAppearanceController : SettingsController() {
val appThemes = Values.AppTheme.values().filter {
val monetFilter = if (it == Values.AppTheme.MONET) {
DynamicColors.isDynamicColorAvailable()
DeviceUtil.isDynamicColorAvailable
} else {
true
}

View File

@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.util.system
import android.annotation.SuppressLint
import android.os.Build
import com.google.android.material.color.DynamicColors
import logcat.LogPriority
object DeviceUtil {
@ -30,6 +31,10 @@ object DeviceUtil {
Build.MANUFACTURER.equals("samsung", ignoreCase = true)
}
val isDynamicColorAvailable by lazy {
DynamicColors.isDynamicColorAvailable() || (isSamsung && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S)
}
@SuppressLint("PrivateApi")
private fun getSystemProperty(key: String?): String? {
return try {