Fix: Don't hide update dialog on Miui
This commit is contained in:
parent
fbbcbea4ec
commit
9e3f4a0b0d
4 changed files with 37 additions and 6 deletions
|
@ -14,8 +14,8 @@ android {
|
||||||
applicationId = "dev.beefers.vendetta.manager"
|
applicationId = "dev.beefers.vendetta.manager"
|
||||||
minSdk = 24
|
minSdk = 24
|
||||||
targetSdk = 33
|
targetSdk = 33
|
||||||
versionCode = 1071
|
versionCode = 1072
|
||||||
versionName = "1.0.71"
|
versionName = "1.0.72"
|
||||||
|
|
||||||
buildConfigField("String", "GIT_BRANCH", "\"${getCurrentBranch()}\"")
|
buildConfigField("String", "GIT_BRANCH", "\"${getCurrentBranch()}\"")
|
||||||
buildConfigField("String", "GIT_COMMIT", "\"${getLatestCommit()}\"")
|
buildConfigField("String", "GIT_COMMIT", "\"${getLatestCommit()}\"")
|
||||||
|
|
|
@ -26,6 +26,7 @@ import dev.beefers.vendetta.manager.installer.util.installApks
|
||||||
import dev.beefers.vendetta.manager.installer.util.Signer
|
import dev.beefers.vendetta.manager.installer.util.Signer
|
||||||
import dev.beefers.vendetta.manager.utils.DiscordVersion
|
import dev.beefers.vendetta.manager.utils.DiscordVersion
|
||||||
import dev.beefers.vendetta.manager.utils.copyText
|
import dev.beefers.vendetta.manager.utils.copyText
|
||||||
|
import dev.beefers.vendetta.manager.utils.isMiui
|
||||||
import dev.beefers.vendetta.manager.utils.showToast
|
import dev.beefers.vendetta.manager.utils.showToast
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
@ -46,7 +47,7 @@ class InstallerViewModel(
|
||||||
private val installationRunning = AtomicBoolean(false)
|
private val installationRunning = AtomicBoolean(false)
|
||||||
private val cacheDir = context.externalCacheDir!!
|
private val cacheDir = context.externalCacheDir!!
|
||||||
private var debugInfo = """
|
private var debugInfo = """
|
||||||
Vendetta Manager ${BuildConfig.VERSION_NAME}
|
Vendetta Manager v${BuildConfig.VERSION_NAME}
|
||||||
Built from commit ${BuildConfig.GIT_COMMIT} on ${BuildConfig.GIT_BRANCH} ${if (BuildConfig.GIT_LOCAL_CHANGES || BuildConfig.GIT_LOCAL_COMMITS) "(Changes Present)" else ""}
|
Built from commit ${BuildConfig.GIT_COMMIT} on ${BuildConfig.GIT_BRANCH} ${if (BuildConfig.GIT_LOCAL_CHANGES || BuildConfig.GIT_LOCAL_COMMITS) "(Changes Present)" else ""}
|
||||||
|
|
||||||
Running Android ${Build.VERSION.RELEASE}, API level ${Build.VERSION.SDK_INT}
|
Running Android ${Build.VERSION.RELEASE}, API level ${Build.VERSION.SDK_INT}
|
||||||
|
@ -375,7 +376,7 @@ class InstallerViewModel(
|
||||||
files.add(lspatchedDir.resolve(name))
|
files.add(lspatchedDir.resolve(name))
|
||||||
}
|
}
|
||||||
logger.i("Installing apks")
|
logger.i("Installing apks")
|
||||||
context.installApks(true, *files.toTypedArray())
|
context.installApks(silent = !isMiui, *files.toTypedArray())
|
||||||
isFinished = true
|
isFinished = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ import dev.beefers.vendetta.manager.installer.util.installApks
|
||||||
import dev.beefers.vendetta.manager.network.dto.Release
|
import dev.beefers.vendetta.manager.network.dto.Release
|
||||||
import dev.beefers.vendetta.manager.network.utils.dataOrNull
|
import dev.beefers.vendetta.manager.network.utils.dataOrNull
|
||||||
import dev.beefers.vendetta.manager.network.utils.ifSuccessful
|
import dev.beefers.vendetta.manager.network.utils.ifSuccessful
|
||||||
|
import dev.beefers.vendetta.manager.utils.isMiui
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
|
@ -58,7 +59,7 @@ class MainViewModel(
|
||||||
isUpdating = true
|
isUpdating = true
|
||||||
downloadManager.downloadUpdate(update)
|
downloadManager.downloadUpdate(update)
|
||||||
isUpdating = false
|
isUpdating = false
|
||||||
context.installApks(false, update)
|
context.installApks(silent = !isMiui, update)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,9 @@ import androidx.annotation.DrawableRes
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
import androidx.core.graphics.drawable.toBitmap
|
import androidx.core.graphics.drawable.toBitmap
|
||||||
import dev.beefers.vendetta.manager.BuildConfig
|
import dev.beefers.vendetta.manager.BuildConfig
|
||||||
|
import java.io.BufferedReader
|
||||||
|
import java.io.IOException
|
||||||
|
import java.io.InputStreamReader
|
||||||
|
|
||||||
fun Context.copyText(text: String) {
|
fun Context.copyText(text: String) {
|
||||||
val clipboardManager = getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
val clipboardManager = getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
||||||
|
@ -45,4 +48,30 @@ fun Context.getBitmap(@DrawableRes icon: Int, size: Int): Bitmap {
|
||||||
}
|
}
|
||||||
|
|
||||||
return bitmap
|
return bitmap
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Thanks to https://gist.github.com/Muyangmin/e8ec1002c930d8df3df46b306d03315d
|
||||||
|
fun getSystemProp(prop: String): String? {
|
||||||
|
val line: String
|
||||||
|
var input = null as BufferedReader?
|
||||||
|
try {
|
||||||
|
val proc = Runtime.getRuntime().exec("getprop $prop")
|
||||||
|
input = BufferedReader(InputStreamReader(proc.inputStream), 1024)
|
||||||
|
line = input.readLine()
|
||||||
|
input.close()
|
||||||
|
} catch (e: IOException) {
|
||||||
|
return null
|
||||||
|
} finally {
|
||||||
|
input?.let {
|
||||||
|
try {
|
||||||
|
input.close()
|
||||||
|
} catch (e: IOException) {
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return line
|
||||||
|
}
|
||||||
|
|
||||||
|
val isMiui: Boolean
|
||||||
|
get() = getSystemProp("ro.miui.ui.version.name")?.isNotEmpty() ?: false
|
Loading…
Reference in a new issue