mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-22 02:01:48 +01:00
Don't recompute constant device info
This commit is contained in:
parent
09b6a3b41e
commit
448645d83a
@ -326,7 +326,7 @@ class PreferencesHelper(val context: Context) {
|
||||
|
||||
fun extensionInstaller() = flowPrefs.getEnum(
|
||||
Keys.extensionInstaller,
|
||||
if (DeviceUtil.isMiui()) Values.ExtensionInstaller.LEGACY else Values.ExtensionInstaller.PACKAGEINSTALLER
|
||||
if (DeviceUtil.isMiui) Values.ExtensionInstaller.LEGACY else Values.ExtensionInstaller.PACKAGEINSTALLER
|
||||
)
|
||||
|
||||
fun verboseLogging() = prefs.getBoolean(Keys.verboseLogging, false)
|
||||
|
@ -41,7 +41,7 @@ class CloudflareInterceptor(private val context: Context) : Interceptor {
|
||||
private val initWebView by lazy {
|
||||
// Avoid crashes on Samsung devices on Android 12
|
||||
// See https://bugs.chromium.org/p/chromium/issues/detail?id=1279562
|
||||
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.S && DeviceUtil.isSamsung()) {
|
||||
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.S && DeviceUtil.isSamsung) {
|
||||
return@lazy
|
||||
}
|
||||
|
||||
|
@ -215,7 +215,7 @@ class SettingsAdvancedController : SettingsController() {
|
||||
R.string.ext_installer_shizuku,
|
||||
)
|
||||
entryValues = PreferenceValues.ExtensionInstaller.values().map { it.name }.toTypedArray()
|
||||
defaultValue = if (DeviceUtil.isMiui()) {
|
||||
defaultValue = if (DeviceUtil.isMiui) {
|
||||
PreferenceValues.ExtensionInstaller.LEGACY
|
||||
} else {
|
||||
PreferenceValues.ExtensionInstaller.PACKAGEINSTALLER
|
||||
|
@ -62,7 +62,7 @@ class SettingsBackupController : SettingsController() {
|
||||
summaryRes = R.string.pref_create_backup_summ
|
||||
|
||||
onClick {
|
||||
if (DeviceUtil.isMiui() && DeviceUtil.isMiuiOptimizationDisabled()) {
|
||||
if (DeviceUtil.isMiui && DeviceUtil.isMiuiOptimizationDisabled()) {
|
||||
context.toast(R.string.restore_miui_warning, Toast.LENGTH_LONG)
|
||||
}
|
||||
|
||||
@ -81,7 +81,7 @@ class SettingsBackupController : SettingsController() {
|
||||
summaryRes = R.string.pref_restore_backup_summ
|
||||
|
||||
onClick {
|
||||
if (DeviceUtil.isMiui() && DeviceUtil.isMiuiOptimizationDisabled()) {
|
||||
if (DeviceUtil.isMiui && DeviceUtil.isMiuiOptimizationDisabled()) {
|
||||
context.toast(R.string.restore_miui_warning, Toast.LENGTH_LONG)
|
||||
}
|
||||
|
||||
|
@ -3,11 +3,12 @@ package eu.kanade.tachiyomi.util.system
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Build
|
||||
import logcat.LogPriority
|
||||
import java.util.Locale
|
||||
|
||||
object DeviceUtil {
|
||||
|
||||
fun isMiui() = getSystemProperty("ro.miui.ui.version.name")?.isNotEmpty() ?: false
|
||||
val isMiui by lazy {
|
||||
getSystemProperty("ro.miui.ui.version.name")?.isNotEmpty() ?: false
|
||||
}
|
||||
|
||||
@SuppressLint("PrivateApi")
|
||||
fun isMiuiOptimizationDisabled(): Boolean {
|
||||
@ -25,7 +26,9 @@ object DeviceUtil {
|
||||
}
|
||||
}
|
||||
|
||||
fun isSamsung() = Build.MANUFACTURER.lowercase(Locale.ENGLISH) == "samsung"
|
||||
val isSamsung by lazy {
|
||||
Build.MANUFACTURER.equals("samsung", ignoreCase = true)
|
||||
}
|
||||
|
||||
@SuppressLint("PrivateApi")
|
||||
private fun getSystemProperty(key: String?): String? {
|
||||
|
Loading…
Reference in New Issue
Block a user