From 4617e5ec5678787653ff008bcd3945999461a0fb Mon Sep 17 00:00:00 2001 From: rushiiMachine <33725716+rushiiMachine@users.noreply.github.com> Date: Fri, 12 Jan 2024 14:54:27 -0800 Subject: [PATCH] feat(InstallService): translatable install error messages --- .../manager/installer/service/InstallService.kt | 17 ++++++++++++++++- app/src/main/res/values/strings.xml | 9 +++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/aliucord/manager/installer/service/InstallService.kt b/app/src/main/kotlin/com/aliucord/manager/installer/service/InstallService.kt index 3ca0eb6..fb58c2d 100644 --- a/app/src/main/kotlin/com/aliucord/manager/installer/service/InstallService.kt +++ b/app/src/main/kotlin/com/aliucord/manager/installer/service/InstallService.kt @@ -10,6 +10,16 @@ import com.aliucord.manager.R import com.aliucord.manager.util.showToast class InstallService : Service() { + private val errorMessages = mapOf( + PackageInstaller.STATUS_FAILURE to R.string.install_error_unknown, + PackageInstaller.STATUS_FAILURE_BLOCKED to R.string.install_error_blocked, + PackageInstaller.STATUS_FAILURE_INVALID to R.string.install_error_invalid, + PackageInstaller.STATUS_FAILURE_CONFLICT to R.string.install_error_conflict, + PackageInstaller.STATUS_FAILURE_STORAGE to R.string.install_error_storage, + PackageInstaller.STATUS_FAILURE_INCOMPATIBLE to R.string.install_error_incompatible, + PackageInstaller.STATUS_FAILURE_TIMEOUT to R.string.install_error_timeout + ) + override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int { when (val statusCode = intent.getIntExtra(PackageInstaller.EXTRA_STATUS, -999)) { PackageInstaller.STATUS_PENDING_USER_ACTION -> { @@ -25,7 +35,12 @@ class InstallService : Service() { else -> { Log.i(BuildConfig.TAG, "Install failed with error code $statusCode") - showToast(R.string.installer_failed, statusCode) + + if (errorMessages[statusCode] != null) { + showToast(errorMessages[statusCode]!!) + } else { + showToast(R.string.install_error_code, statusCode) + } } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c239733..c2df6c6 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -107,6 +107,15 @@ Installation failed with error %o Please uninstall your current version of Aliucord in order to continue! + Failed to install (Unknown reason) + Failed to install (error code %d) + Installation was blocked + One or more APKs were invalid or corrupt + Conflicts with an existing app, usually due to mismatched signatures + Not enough available storage to install + Application is incompatible with this device + Installation timed out + Download APKs Download Libraries Patch APKs