From 4cd01428eda8aa6b1438e6f98474255afbe97d91 Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 8 Jan 2023 15:04:06 -0500 Subject: [PATCH] Only show MIUI extension warning on MIUI >= 13 Related to #8834 --- .../kanade/presentation/browse/ExtensionsScreen.kt | 2 +- .../eu/kanade/tachiyomi/util/system/DeviceUtil.kt | 14 ++++++++++++++ i18n/src/main/res/values/strings.xml | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/kanade/presentation/browse/ExtensionsScreen.kt b/app/src/main/java/eu/kanade/presentation/browse/ExtensionsScreen.kt index a6df8ab6e3..e3893a2fec 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/ExtensionsScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/ExtensionsScreen.kt @@ -123,7 +123,7 @@ private fun ExtensionContent( onClickUpdateAll: () -> Unit, ) { var trustState by remember { mutableStateOf(null) } - val showMiuiWarning = DeviceUtil.isMiui && !DeviceUtil.isMiuiOptimizationDisabled() + val showMiuiWarning = DeviceUtil.isMiui && DeviceUtil.miuiMajorVersion >= 13 && !DeviceUtil.isMiuiOptimizationDisabled() val uriHandler = LocalUriHandler.current FastScrollLazyColumn( diff --git a/core/src/main/java/eu/kanade/tachiyomi/util/system/DeviceUtil.kt b/core/src/main/java/eu/kanade/tachiyomi/util/system/DeviceUtil.kt index aaae076d87..5926d04507 100644 --- a/core/src/main/java/eu/kanade/tachiyomi/util/system/DeviceUtil.kt +++ b/core/src/main/java/eu/kanade/tachiyomi/util/system/DeviceUtil.kt @@ -10,6 +10,20 @@ object DeviceUtil { getSystemProperty("ro.miui.ui.version.name")?.isNotEmpty() ?: false } + /** + * Extracts the MIUI major version code from a string like "V12.5.3.0.QFGMIXM". + * + * @return MIUI major version code (e.g., 13) or -1 if can't be parsed. + */ + val miuiMajorVersion by lazy { + if (!isMiui) return@lazy -1 + + Build.VERSION.INCREMENTAL + .substringBefore('.') + .trimStart('V') + .toIntOrNull() ?: -1 + } + @SuppressLint("PrivateApi") fun isMiuiOptimizationDisabled(): Boolean { val sysProp = getSystemProperty("persist.sys.miui_optimization") diff --git a/i18n/src/main/res/values/strings.xml b/i18n/src/main/res/values/strings.xml index 598ba1e5ed..f9489a1eb8 100644 --- a/i18n/src/main/res/values/strings.xml +++ b/i18n/src/main/res/values/strings.xml @@ -305,7 +305,7 @@ Shizuku Shizuku is not running Install and start Shizuku to use Shizuku as extension installer. - Installing extensions may not work if MIUI Optimization is enabled. Try disabling it or installing from the website instead. + Installing extensions may not work if MIUI Optimization is enabled. Try disabling it or tap here to download from the website instead. Fullscreen