Skip to content
This repository has been archived by the owner on Jul 7, 2024. It is now read-only.

Commit

Permalink
Display message when downloaded apk is somehow corrupt
Browse files Browse the repository at this point in the history
  • Loading branch information
wingio committed Oct 30, 2023
1 parent 3efdde3 commit 2acdca5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/java/dev/beefers/vendetta/manager/utils/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<string name="msg_unlocked">You are now a developer</string>
<string name="msg_permission_grant">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.</string>
<string name="msg_change_mirror">Would you like to try again using a download mirror?</string>
<string name="msg_invalid_apk">APK was corrupted, try clearing cache then reinstalling</string>

<string name="group_download">Download APKs</string>
<string name="group_patch">Patching</string>
Expand Down

0 comments on commit 2acdca5

Please sign in to comment.