mirror of
https://github.com/YTVanced/VancedManager
synced 2025-01-05 06:51:00 +00:00
improved MIUI warning
This commit is contained in:
parent
d0e765fa39
commit
26bf0a90d7
6 changed files with 42 additions and 47 deletions
|
@ -155,6 +155,7 @@ class MainActivity : AppCompatActivity() {
|
|||
super.attachBaseContext(Crowdin.wrapContext(LanguageContextWrapper.wrap(newBase)))
|
||||
}
|
||||
|
||||
//I have no idea why the fuck is super method deprecated
|
||||
@Suppress("DEPRECATION")
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
|
@ -198,26 +199,30 @@ class MainActivity : AppCompatActivity() {
|
|||
urldialog.show(this)
|
||||
}
|
||||
|
||||
when {
|
||||
firstLaunch -> {
|
||||
DialogContainer.showSecurityDialog(this)
|
||||
with(FirebaseMessaging.getInstance()) {
|
||||
subscribeToTopic("Vanced-Update")
|
||||
subscribeToTopic("Music-Update")
|
||||
subscribeToTopic("MicroG-Update")
|
||||
}
|
||||
if (firstLaunch) {
|
||||
DialogContainer.showSecurityDialog(this)
|
||||
with(FirebaseMessaging.getInstance()) {
|
||||
subscribeToTopic("Vanced-Update")
|
||||
subscribeToTopic("Music-Update")
|
||||
subscribeToTopic("MicroG-Update")
|
||||
}
|
||||
!prefs.getBoolean("statement", true) -> DialogContainer.statementFalse(this)
|
||||
variant == "root" -> {
|
||||
if (PackageHelper.getPackageVersionName(
|
||||
"com.google.android.youtube",
|
||||
packageManager
|
||||
) == "14.21.54")
|
||||
DialogContainer.basicDialog(
|
||||
getString(R.string.hold_on),
|
||||
getString(R.string.magisk_vanced),
|
||||
this
|
||||
)
|
||||
} else {
|
||||
if (isMiuiOptimizationsEnabled) {
|
||||
DialogContainer.applyAccentMiuiDialog(this)
|
||||
}
|
||||
}
|
||||
|
||||
if (!prefs.getBoolean("statement", true)) {
|
||||
DialogContainer.statementFalse(this)
|
||||
}
|
||||
|
||||
if (variant == "root") {
|
||||
if (PackageHelper.getPackageVersionName("com.google.android.youtube", packageManager) == "14.21.54") {
|
||||
DialogContainer.basicDialog(
|
||||
getString(R.string.hold_on),
|
||||
getString(R.string.magisk_vanced),
|
||||
this
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import androidx.preference.PreferenceManager
|
|||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.vanced.manager.R
|
||||
import com.vanced.manager.utils.applyAccent
|
||||
import com.vanced.manager.utils.isMiui
|
||||
import com.vanced.manager.utils.isMiuiOptimizationsEnabled
|
||||
import com.vanced.manager.utils.openUrl
|
||||
|
||||
object DialogContainer {
|
||||
|
@ -16,15 +16,10 @@ object DialogContainer {
|
|||
setTitle(context.resources.getString(R.string.welcome))
|
||||
setMessage(context.resources.getString(R.string.security_context))
|
||||
setPositiveButton(context.resources.getString(R.string.close)) { dialog, _ ->
|
||||
dialog.dismiss()
|
||||
}
|
||||
setOnDismissListener {
|
||||
if (isMiui()) {
|
||||
applyAccentMiuiDialog(context)
|
||||
}
|
||||
dialog.cancel()
|
||||
}
|
||||
setOnCancelListener {
|
||||
if (isMiui()) {
|
||||
if (isMiuiOptimizationsEnabled) {
|
||||
applyAccentMiuiDialog(context)
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +30,7 @@ object DialogContainer {
|
|||
prefs.edit { putBoolean("firstLaunch", false) }
|
||||
}
|
||||
|
||||
private fun applyAccentMiuiDialog(context: Context) {
|
||||
fun applyAccentMiuiDialog(context: Context) {
|
||||
MaterialAlertDialogBuilder(context).apply {
|
||||
setTitle(context.getString(R.string.miui_one_title))
|
||||
setMessage(context.getString(R.string.miui_one))
|
||||
|
|
|
@ -127,11 +127,13 @@ object AppUtils: CoroutineScope by CoroutineScope(Dispatchers.IO) {
|
|||
status.contains("ModApk_Missing") -> context.getString(R.string.modapk_missing)
|
||||
status.contains("Files_Missing_VA") -> context.getString(R.string.files_missing_va)
|
||||
status.contains("Path_Missing") -> context.getString(R.string.path_missing)
|
||||
else ->
|
||||
if (isMiui())
|
||||
status.contains("INSTALL_FAILED_INTERNAL_ERROR: Permission Denied") -> {
|
||||
if (isMiuiOptimizationsEnabled)
|
||||
context.getString(R.string.installation_miui)
|
||||
else
|
||||
context.getString(R.string.installation_failed)
|
||||
context.getString(R.string.installation_blocked)
|
||||
}
|
||||
else -> context.getString(R.string.installation_failed)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -59,7 +59,7 @@ object DownloadHelper : CoroutineScope by CoroutineScope(Dispatchers.IO) {
|
|||
}
|
||||
} else {
|
||||
onError(response.errorBody().toString())
|
||||
downloadProgress.postValue(0)
|
||||
downloadProgress.postValue(0)
|
||||
log("VMDownloader", "Failed to download file: $url")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,22 +1,15 @@
|
|||
package com.vanced.manager.utils
|
||||
|
||||
import java.io.BufferedReader
|
||||
import java.io.IOException
|
||||
import java.io.InputStreamReader
|
||||
import com.topjohnwu.superuser.Shell
|
||||
|
||||
private const val MIUI_PROP_NAME = "ro.miui.ui.version.name"
|
||||
private const val MIUI_OPTIMIZATIONS_PROP = "persist.sys.miui_optimization"
|
||||
|
||||
fun isMiui(): Boolean = !getSystemProps(MIUI_PROP_NAME).isNullOrEmpty()
|
||||
val isMiuiOptimizationsEnabled get() = getSystemProperty(MIUI_OPTIMIZATIONS_PROP) == "true"
|
||||
|
||||
private fun getSystemProps(propname: String): String? {
|
||||
var input: BufferedReader? = null
|
||||
fun getSystemProperty(propname: String): String? {
|
||||
return try {
|
||||
val process = Runtime.getRuntime().exec("getprop $propname")
|
||||
input = BufferedReader(InputStreamReader(process.inputStream), 1024)
|
||||
input.readLine()
|
||||
} catch (e: IOException) {
|
||||
Shell.sh("getprop $propname").exec().out.joinToString(" ")
|
||||
} catch (e: Exception) {
|
||||
null
|
||||
} finally {
|
||||
input?.close()
|
||||
}
|
||||
}
|
|
@ -81,8 +81,8 @@
|
|||
<string name="guide">Guide</string>
|
||||
<string name="hold_on">Stop!</string>
|
||||
<string name="magisk_vanced">You are using the Magisk/TWRP version of Vanced, which is discontinued and cannot be updated using this app. Please remove it by removing the Magisk module/using TWRP Vanced uninstaller.</string>
|
||||
<string name="miui_one_title">MIUI detected!</string>
|
||||
<string name="miui_one">To install Vanced, you MUST disable MIUI Optimisations in the developer settings. (You can ignore this warning if you are using 20.2.20 or later xiaomi.eu based ROM)</string>
|
||||
<string name="miui_one_title">MIUI Optimizations are enabled!</string>
|
||||
<string name="miui_one">To install Vanced, you MUST disable MIUI Optimizations in the developer settings. (You can ignore this warning if you are using 20.2.20 or later xiaomi.eu based ROM)</string>
|
||||
<string name="error">Error</string>
|
||||
<string name="redownload">Redownload</string>
|
||||
<string name="security_context">Make sure that you downloaded the app from vancedapp.com, the Vanced Discord server, or the Vanced GitHub</string>
|
||||
|
|
Loading…
Reference in a new issue