mirror of
https://github.com/YTVanced/VancedManager
synced 2024-11-25 20:55:12 +00:00
added magisk version checking
This commit is contained in:
parent
eefd85536f
commit
92c4b2a5c6
7 changed files with 32 additions and 102 deletions
|
@ -8,11 +8,13 @@ import androidx.appcompat.app.AppCompatActivity
|
|||
import androidx.preference.PreferenceManager
|
||||
import com.dezlum.codelabs.getjson.GetJson
|
||||
import com.vanced.manager.R
|
||||
import com.vanced.manager.ui.dialogs.DialogContainer.basicDialog
|
||||
import com.vanced.manager.ui.dialogs.DialogContainer.showRootDialog
|
||||
import com.vanced.manager.ui.dialogs.DialogContainer.showSecurityDialog
|
||||
import com.vanced.manager.ui.dialogs.DialogContainer.statementFalse
|
||||
import com.vanced.manager.ui.fragments.UpdateCheckFragment
|
||||
import com.vanced.manager.utils.InternetTools.isUpdateAvailable
|
||||
import com.vanced.manager.utils.PackageHelper.getPackageVersionName
|
||||
|
||||
// This activity will NOT be used in manifest
|
||||
// since MainActivity will extend it
|
||||
|
@ -29,7 +31,13 @@ open class Main: AppCompatActivity() {
|
|||
when {
|
||||
prefs.getBoolean("firstStart", true) -> showSecurityDialog(this)
|
||||
!prefs.getBoolean("statement", true) -> statementFalse(this)
|
||||
variant == "root" && showRootDialog -> showRootDialog(this)
|
||||
variant == "root" -> {
|
||||
if (showRootDialog)
|
||||
showRootDialog(this)
|
||||
|
||||
if (getPackageVersionName("com.google.android.youtube", packageManager) == "14.21.54")
|
||||
basicDialog(getString(R.string.hold_on), getString(R.string.magisk_vanced), this)
|
||||
}
|
||||
}
|
||||
|
||||
checkUpdates()
|
||||
|
|
|
@ -81,22 +81,14 @@ open class Home : BaseFragment(), View.OnClickListener {
|
|||
view?.findNavController()?.navigate(R.id.toInstallThemeFragment)
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(
|
||||
activity,
|
||||
"Please wait until installation finishes",
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
Toast.makeText(activity, activity?.getString(R.string.installation_wait), Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
R.id.microg_installbtn -> {
|
||||
if (!isMicrogDownloading!!) {
|
||||
try {
|
||||
activity?.startService(Intent(activity, MicrogDownloadService::class.java))
|
||||
} catch (e: Exception) {
|
||||
Toast.makeText(activity, "Unable to start installation", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
activity?.startService(Intent(activity, MicrogDownloadService::class.java))
|
||||
} else {
|
||||
Toast.makeText(activity, "Please wait until installation finishes", Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(activity, activity?.getString(R.string.installation_wait), Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
R.id.microg_uninstallbtn -> activity?.let { uninstallApk("com.mgoogle.android.gms", it) }
|
||||
|
@ -105,8 +97,7 @@ open class Home : BaseFragment(), View.OnClickListener {
|
|||
R.id.root_switch ->
|
||||
if (Shell.rootAccess()) {
|
||||
writeToVariantPref("root", R.anim.slide_in_right, R.anim.slide_out_left)
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
writeToVariantPref("nonroot", R.anim.slide_in_left, R.anim.slide_out_right)
|
||||
Toast.makeText(activity, activity?.getString(R.string.root_not_granted), Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
|
@ -120,7 +111,8 @@ open class Home : BaseFragment(), View.OnClickListener {
|
|||
startActivity(Intent(activity, MainActivity::class.java))
|
||||
activity?.overridePendingTransition(animIn, animOut)
|
||||
activity?.finish()
|
||||
} else Log.d("VMVariant", "$variant is already selected")
|
||||
} else
|
||||
Log.d("VMVariant", "$variant is already selected")
|
||||
}
|
||||
|
||||
}
|
|
@ -69,7 +69,7 @@ class MainActivity : Main() {
|
|||
restartActivity()
|
||||
Log.d("VMpm", "test")
|
||||
}
|
||||
APP_NOT_UNINSTALLED -> installAlertBuilder(getString(R.string.failed_uninstall) + intent.getStringExtra("pkgName"), this@MainActivity)
|
||||
APP_NOT_UNINSTALLED -> installAlertBuilder(getString(R.string.failed_uninstall, intent.getStringExtra("pkgName")), this@MainActivity)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -106,6 +106,15 @@ object DialogContainer {
|
|||
.show()
|
||||
}
|
||||
|
||||
fun basicDialog(title: String, msg: String, activity: Activity) {
|
||||
AlertDialog.Builder(activity)
|
||||
.setTitle(title)
|
||||
.setMessage(msg)
|
||||
.setPositiveButton(activity.getString(R.string.close)) { dialog, _ -> dialog.dismiss() }
|
||||
.create()
|
||||
.show()
|
||||
}
|
||||
|
||||
fun launchVanced(activity: MainActivity) {
|
||||
val intent = Intent()
|
||||
intent.component =
|
||||
|
|
|
@ -17,33 +17,12 @@ object PackageHelper {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@Throws(IOException::class)
|
||||
fun installApp(
|
||||
context: Context,
|
||||
path: String,
|
||||
pkg: String?
|
||||
) {
|
||||
val callbackIntent = Intent(context.applicationContext, AppInstallerService::class.java)
|
||||
val pendingIntent = PendingIntent.getService(context.applicationContext, 0, callbackIntent, 0)
|
||||
val packageInstaller = context.packageManager.packageInstaller
|
||||
val params = SessionParams(SessionParams.MODE_FULL_INSTALL)
|
||||
params.setAppPackageName(pkg)
|
||||
val sessionId = packageInstaller.createSession(params)
|
||||
val session = packageInstaller.openSession(sessionId)
|
||||
val inputStream: InputStream = FileInputStream(path)
|
||||
val outputStream = session.openWrite("install", 0, -1)
|
||||
val buffer = ByteArray(65536)
|
||||
var c: Int
|
||||
while (inputStream.read(buffer).also { c = it } != -1) {
|
||||
outputStream.write(buffer, 0, c)
|
||||
}
|
||||
session.fsync(outputStream)
|
||||
inputStream.close()
|
||||
outputStream.close()
|
||||
session.commit(pendingIntent.intentSender)
|
||||
fun getPackageVersionName(packageName: String, packageManager: PackageManager): String {
|
||||
return if (isPackageInstalled(packageName, packageManager))
|
||||
packageManager.getPackageInfo(packageName, 0).versionName
|
||||
else
|
||||
""
|
||||
}
|
||||
*/
|
||||
|
||||
fun uninstallApk(pkg: String, activity: Activity) {
|
||||
val callbackIntent = Intent(activity.applicationContext, AppUninstallerService::class.java)
|
||||
|
|
|
@ -1,60 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<resources>
|
||||
|
||||
<!-- Global Strings -->
|
||||
<string name="close">Fermer</string>
|
||||
<string name="welcome">Bienvenue</string>
|
||||
|
||||
<!-- Main Activity -->
|
||||
<string name="title_about">À propos</string>
|
||||
<string name="title_home">Accueil</string>
|
||||
<string name="title_install">Installer</string>
|
||||
<string name="title_settings">Paramètres</string>
|
||||
|
||||
<!-- Home Page -->
|
||||
<string name="changelogs">Journal des modifications</string>
|
||||
<string name="install">Installer</string>
|
||||
<string name="version_installed">Version installée:</string>
|
||||
<string name="latest">Dernière version:</string>
|
||||
<string name="loading">Chargement…</string>
|
||||
<string name="network_error">Connection réseau indisponible</string>
|
||||
<string name="update">Mettre à jour</string>
|
||||
<string name="useful_links">Liens utiles</string>
|
||||
<string name="website_text">Le site web officiel de Vanced</string>
|
||||
<string name="support_us">Supporte nous en téléchargeant Brave</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="accent_color">Couleur d\'accentuation</string>
|
||||
<string name="accent_color_summary">Choisis ta couleur d\'accentuation préférée</string>
|
||||
<string name="accent_blue">Bleu</string>
|
||||
<string name="accent_green">Vert</string>
|
||||
<string name="accent_red">Rouge</string>
|
||||
<string name="accent_yellow">Jaune</string>
|
||||
<string name="check_updates">Vérifier les mises à jour</string>
|
||||
<string name="category_interface">Interface</string>
|
||||
<string name="category_manager">Gestion</string>
|
||||
<string name="theme">Thème</string>
|
||||
<string name="theme_dark">Thème sombre</string>
|
||||
<string name="theme_light">Thème clair</string>
|
||||
<string name="theme_summary">Choisis ton thème préféré</string>
|
||||
<string name="push_notifications">Notifications</string>
|
||||
<string name="push_notifications_summary">Recevoir des notifications quand une nouvelle version est disponible</string>
|
||||
<string name="re_check">Revérifier</string>
|
||||
<string name="update_center">Centre de mise à jour</string>
|
||||
|
||||
<!-- Install Page -->
|
||||
<string name="choose_preferred_language">Choisir votre langue préférée pour Vanced</string>
|
||||
<string name="choose_preferred_language_note">Note: si vous installer autre chose que l\'anglais, l\'anglais sera toujours installé en langue additionnelle</string>
|
||||
<string name="choose_preferred_theme">Choisis le thème de Vanced</string>
|
||||
<string name="finish">Terminer</string>
|
||||
<string name="install_light_black">Clair + Sombre</string>
|
||||
<string name="install_light_dark">Clair + Noir</string>
|
||||
<string name="next">Suivant</string>
|
||||
|
||||
<!-- About Page -->
|
||||
<string name="sources">Sources</string>
|
||||
<string name="vanced_team">Équipe Vanced</string>
|
||||
<string name="security_context">Assurez-vous d\'avoir téléchargé l\'application sur vanced.app, le serveur Discord de Vanced ou sur le github officiel.</string>
|
||||
<string name="theme_follow">Suivre le paramètre système</string>
|
||||
|
||||
</resources>
|
|
@ -28,6 +28,7 @@
|
|||
<string name="installation_signature">Unexpected error occurred while installing Vanced. Did you disable signature verification?</string>
|
||||
<string name="installation_miui">Unexpected error occurred while installing Vanced. Did you disable MIUI Optimisations?</string>
|
||||
<string name="installation_storage">Operation failed because there was an error with storage.</string>
|
||||
<string name="installation_wait">Please wait until installation finishes</string>
|
||||
<string name="button_reinstall">Reinstall</string>
|
||||
<string name="version_installed">Installed:</string>
|
||||
<string name="latest">Latest:</string>
|
||||
|
@ -73,6 +74,7 @@
|
|||
<string name="button_dismiss">Dismiss</string>
|
||||
<string name="guide">Guide</string>
|
||||
<string name="hold_on">Hold on!</string>
|
||||
<string name="magisk_vanced">Looks like you\'re using Magisk version of Vanced. Magisk version is discontinued and manager won\'t be able to update/uninstall it. Please remove module before using manager</string>
|
||||
<string name="miui_one_title">Detected MIUI user!</string>
|
||||
<string name="miui_one">Hey! Looks like you\'re an MIUI user. in order to properly use Vanced Manager, you will have to disable MiUI optimisations in developer settings. However, if you are on 20.2.20 ROM (Or later) that\'s based on xiaomi.eu, you can safely ignore this warning.</string>
|
||||
<string name="error">Error</string>
|
||||
|
|
Loading…
Reference in a new issue