mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-22 16:41:51 +01:00
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:
parent
9984e983b4
commit
e3f3686b8a
@ -6,7 +6,6 @@ import android.os.Environment
|
|||||||
import androidx.core.content.edit
|
import androidx.core.content.edit
|
||||||
import androidx.core.net.toUri
|
import androidx.core.net.toUri
|
||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
import com.google.android.material.color.DynamicColors
|
|
||||||
import com.tfcporciuncula.flow.FlowSharedPreferences
|
import com.tfcporciuncula.flow.FlowSharedPreferences
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
@ -73,7 +72,7 @@ class PreferencesHelper(val context: Context) {
|
|||||||
|
|
||||||
fun appTheme() = flowPrefs.getEnum(
|
fun appTheme() = flowPrefs.getEnum(
|
||||||
"pref_app_theme",
|
"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)
|
fun themeDarkAmoled() = flowPrefs.getBoolean("pref_theme_dark_amoled_key", false)
|
||||||
|
@ -5,7 +5,6 @@ import android.os.Bundle
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.core.app.ActivityCompat
|
import androidx.core.app.ActivityCompat
|
||||||
import androidx.preference.PreferenceScreen
|
import androidx.preference.PreferenceScreen
|
||||||
import com.google.android.material.color.DynamicColors
|
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.util.preference.bindTo
|
import eu.kanade.tachiyomi.util.preference.bindTo
|
||||||
import eu.kanade.tachiyomi.util.preference.defaultValue
|
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.preferenceCategory
|
||||||
import eu.kanade.tachiyomi.util.preference.switchPreference
|
import eu.kanade.tachiyomi.util.preference.switchPreference
|
||||||
import eu.kanade.tachiyomi.util.preference.titleRes
|
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.util.system.isTablet
|
||||||
import eu.kanade.tachiyomi.widget.preference.ThemesPreference
|
import eu.kanade.tachiyomi.widget.preference.ThemesPreference
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
@ -67,7 +67,7 @@ class SettingsAppearanceController : SettingsController() {
|
|||||||
|
|
||||||
val appThemes = Values.AppTheme.values().filter {
|
val appThemes = Values.AppTheme.values().filter {
|
||||||
val monetFilter = if (it == Values.AppTheme.MONET) {
|
val monetFilter = if (it == Values.AppTheme.MONET) {
|
||||||
DynamicColors.isDynamicColorAvailable()
|
DeviceUtil.isDynamicColorAvailable
|
||||||
} else {
|
} else {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.util.system
|
|||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
|
import com.google.android.material.color.DynamicColors
|
||||||
import logcat.LogPriority
|
import logcat.LogPriority
|
||||||
|
|
||||||
object DeviceUtil {
|
object DeviceUtil {
|
||||||
@ -30,6 +31,10 @@ object DeviceUtil {
|
|||||||
Build.MANUFACTURER.equals("samsung", ignoreCase = true)
|
Build.MANUFACTURER.equals("samsung", ignoreCase = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val isDynamicColorAvailable by lazy {
|
||||||
|
DynamicColors.isDynamicColorAvailable() || (isSamsung && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S)
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressLint("PrivateApi")
|
@SuppressLint("PrivateApi")
|
||||||
private fun getSystemProperty(key: String?): String? {
|
private fun getSystemProperty(key: String?): String? {
|
||||||
return try {
|
return try {
|
||||||
|
Loading…
Reference in New Issue
Block a user