Implement new extension install methods (#5904)

* Implement new extension install methods

* Fixes

* Resolve feedback

* Keep pending status when waiting to install

* Cancellable installation

* Remove auto error now that we have cancellable job
This commit is contained in:
Ivan Iskandar
2021-09-26 01:31:52 +07:00
committed by GitHub
parent 1ae0d1b5d0
commit b284384f0a
24 changed files with 738 additions and 61 deletions
@@ -36,6 +36,8 @@ import eu.kanade.tachiyomi.util.preference.preferenceCategory
import eu.kanade.tachiyomi.util.preference.summaryRes
import eu.kanade.tachiyomi.util.preference.switchPreference
import eu.kanade.tachiyomi.util.preference.titleRes
import eu.kanade.tachiyomi.util.system.MiuiUtil
import eu.kanade.tachiyomi.util.system.isPackageInstalled
import eu.kanade.tachiyomi.util.system.isTablet
import eu.kanade.tachiyomi.util.system.powerManager
import eu.kanade.tachiyomi.util.system.toast
@@ -187,6 +189,45 @@ class SettingsAdvancedController : SettingsController() {
}
}
preferenceCategory {
titleRes = R.string.label_extensions
listPreference {
key = Keys.extensionInstaller
titleRes = R.string.ext_installer_pref
summary = "%s"
entriesRes = arrayOf(
R.string.ext_installer_legacy,
R.string.ext_installer_packageinstaller,
R.string.ext_installer_shizuku
)
entryValues = PreferenceValues.ExtensionInstaller.values().map { it.name }.toTypedArray()
defaultValue = if (MiuiUtil.isMiui()) {
PreferenceValues.ExtensionInstaller.LEGACY
} else {
PreferenceValues.ExtensionInstaller.PACKAGEINSTALLER
}.name
onChange {
if (it == PreferenceValues.ExtensionInstaller.SHIZUKU.name &&
!context.isPackageInstalled("moe.shizuku.privileged.api")
) {
MaterialAlertDialogBuilder(context)
.setTitle(R.string.ext_installer_shizuku)
.setMessage(R.string.ext_installer_shizuku_unavailable_dialog)
.setPositiveButton(android.R.string.ok) { _, _ ->
openInBrowser("https://shizuku.rikka.app/download")
}
.setNegativeButton(android.R.string.cancel, null)
.show()
false
} else {
true
}
}
}
}
preferenceCategory {
titleRes = R.string.pref_category_display