Add warning for MIUI users when trying to install extensions with MIUI Optimization enabled

miui sucks so much
This commit is contained in:
Jays2Kings 2021-07-10 14:30:55 -04:00
parent b92a93a8f3
commit 248d57600c
2 changed files with 18 additions and 2 deletions

View File

@ -1,6 +1,7 @@
package eu.kanade.tachiyomi.ui.extension package eu.kanade.tachiyomi.ui.extension
import android.content.pm.PackageInstaller import android.content.pm.PackageInstaller
import android.widget.Toast
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.database.DatabaseHelper import eu.kanade.tachiyomi.data.database.DatabaseHelper
import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.database.models.Manga
@ -18,7 +19,9 @@ import eu.kanade.tachiyomi.ui.migration.MangaItem
import eu.kanade.tachiyomi.ui.migration.SelectionHeader import eu.kanade.tachiyomi.ui.migration.SelectionHeader
import eu.kanade.tachiyomi.ui.migration.SourceItem import eu.kanade.tachiyomi.ui.migration.SourceItem
import eu.kanade.tachiyomi.util.system.LocaleHelper import eu.kanade.tachiyomi.util.system.LocaleHelper
import eu.kanade.tachiyomi.util.system.MiuiUtil
import eu.kanade.tachiyomi.util.system.executeOnIO import eu.kanade.tachiyomi.util.system.executeOnIO
import eu.kanade.tachiyomi.util.system.toast
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async import kotlinx.coroutines.async
import kotlinx.coroutines.awaitAll import kotlinx.coroutines.awaitAll
@ -241,11 +244,23 @@ class ExtensionBottomPresenter(
} }
fun installExtension(extension: Extension.Available) { fun installExtension(extension: Extension.Available) {
extensionManager.installExtension(extension).subscribeToInstallUpdate(extension) if (isNotMIUIOptimized()) {
extensionManager.installExtension(extension).subscribeToInstallUpdate(extension)
}
} }
fun updateExtension(extension: Extension.Installed) { fun updateExtension(extension: Extension.Installed) {
extensionManager.updateExtension(extension).subscribeToInstallUpdate(extension) if (isNotMIUIOptimized()) {
extensionManager.updateExtension(extension).subscribeToInstallUpdate(extension)
}
}
fun isNotMIUIOptimized(): Boolean {
if (MiuiUtil.isMiui() && !MiuiUtil.isMiuiOptimizationDisabled()) {
preferences.context.toast(R.string.extensions_miui_warning, Toast.LENGTH_LONG)
return false
}
return true
} }
private fun Observable<ExtensionIntallInfo>.subscribeToInstallUpdate(extension: Extension) { private fun Observable<ExtensionIntallInfo>.subscribeToInstallUpdate(extension: Extension) {

View File

@ -303,6 +303,7 @@
<string name="language_">Language: %1$s</string> <string name="language_">Language: %1$s</string>
<string name="nsfw_short">18+</string> <string name="nsfw_short">18+</string>
<string name="unofficial">Unofficial</string> <string name="unofficial">Unofficial</string>
<string name="extensions_miui_warning">MIUI Optimization must be disabled to install extensions.</string>
<string name="may_contain_nsfw">May contain NSFW (18+) content</string> <string name="may_contain_nsfw">May contain NSFW (18+) content</string>
<string name="app_info">App info</string> <string name="app_info">App info</string>
<string name="_must_be_enabled_first">%1$s must be enabled first</string> <string name="_must_be_enabled_first">%1$s must be enabled first</string>