diff --git a/app/src/main/java/dev/beefers/vendetta/manager/ui/viewmodel/installer/InstallerViewModel.kt b/app/src/main/java/dev/beefers/vendetta/manager/ui/viewmodel/installer/InstallerViewModel.kt index 4fcc541f..af299751 100644 --- a/app/src/main/java/dev/beefers/vendetta/manager/ui/viewmodel/installer/InstallerViewModel.kt +++ b/app/src/main/java/dev/beefers/vendetta/manager/ui/viewmodel/installer/InstallerViewModel.kt @@ -27,6 +27,7 @@ import dev.beefers.vendetta.manager.installer.util.installApks import dev.beefers.vendetta.manager.utils.DiscordVersion import dev.beefers.vendetta.manager.utils.copyText import dev.beefers.vendetta.manager.utils.isMiui +import dev.beefers.vendetta.manager.utils.mainThread import dev.beefers.vendetta.manager.utils.showToast import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.cancel @@ -431,6 +432,10 @@ class InstallerViewModel( } catch (e: Throwable) { steps[step]!!.status = InstallStatus.UNSUCCESSFUL + if(e.message?.contains("InvalidArchive") == true) mainThread { + context.showToast(R.string.msg_invalid_apk) + } + logger.e("\nFailed on step ${step.name}\n") logger.e(e.stackTraceToString()) if(step.group == InstallStepGroup.DL) failedOnDownload = true diff --git a/app/src/main/java/dev/beefers/vendetta/manager/utils/Utils.kt b/app/src/main/java/dev/beefers/vendetta/manager/utils/Utils.kt index 21ee1a0f..47542496 100644 --- a/app/src/main/java/dev/beefers/vendetta/manager/utils/Utils.kt +++ b/app/src/main/java/dev/beefers/vendetta/manager/utils/Utils.kt @@ -4,6 +4,8 @@ import android.content.ClipData import android.content.ClipboardManager import android.content.Context import android.graphics.Bitmap +import android.os.Handler +import android.os.Looper import android.widget.Toast import androidx.annotation.DrawableRes import androidx.annotation.StringRes @@ -13,6 +15,12 @@ import java.io.BufferedReader import java.io.IOException import java.io.InputStreamReader +val mainThread = Handler(Looper.getMainLooper()) + +fun mainThread(block: () -> Unit) { + mainThread.post(block) +} + fun Context.copyText(text: String) { val clipboardManager = getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ec3f51b4..61623469 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -13,6 +13,7 @@ You are now a developer In order for Vendetta Manager to function, file permissions are required. Since shared data is stored in ~/Vendetta, permissions are required in order to access it. Would you like to try again using a download mirror? + APK was corrupted, try clearing cache then reinstalling Download APKs Patching