0
0
Fork 0
mirror of https://github.com/YTVanced/VancedManager synced 2024-12-01 23:37:26 +00:00

bug fixes, improvements

This commit is contained in:
X1nto 2020-06-15 20:56:56 +04:00
parent 80f0ad1e6e
commit 4058b7d70a
15 changed files with 354 additions and 366 deletions

View file

@ -1,7 +1,7 @@
![Signed APK Builder](https://github.com/X1nto/VancedInstaller/workflows/Signed%20APK%20Builder/badge.svg?branch=master) ![Signed APK Builder](https://github.com/X1nto/VancedInstaller/workflows/Signed%20APK%20Builder/badge.svg?branch=master)
# Prelude # Prelude
Hi, my name is Steve Cock, I'm the main UI designer for the upcoming Vanced Manager. When xfileFIN first published Vanced 15.05.54, people were upset because new Vanced used split apk files. The reason for that was pretty simple: Hi, my name is Steve Cock, I'm the main developer for the upcoming Vanced Manager. When xfileFIN first published Vanced 15.05.54, people were upset because new Vanced used split apk files. The reason for that was pretty simple:
1) YouTube itself does that 1) YouTube itself does that
2) Split apk files reduce the size of the downloaded file itself 2) Split apk files reduce the size of the downloaded file itself
@ -9,7 +9,7 @@ No one really thought there would be problems with this format, because installa
## Problems with .apks format ## Problems with .apks format
Main problems with new format were either with device CPU architecture or MemeUI shit with MiUI optimisations. We wrote instructions for VancedHelper but no one used it for troubleshooting. Then some users complained about new format and refused to upgrade to newest version (We don't give a fuck about that) because "I dOn'T WaNT To HaVe OnE MoRE apP To insTalL VanCeD" so we decided to make an installer for Vanced Main problems with new format were either with device CPU architecture or MemeUI shit with MiUI optimisations. We wrote instructions for VancedHelper but no one used it for troubleshooting. Then some users complained about new format and refused to upgrade to newest version (We don't give a fuck about that) because "I dOn'T WaNT To HaVe OnE MoRE apP To insTalL VanCeD" so we decided to make an installer for Vanced
# Vanced Manager # Vanced Manager
Ladies and gentlemen, I'm very proud to introduce the new **Vanced Manager Ui Preview Beta Build 1.0.1™** which only has a UI at the time lol Ladies and gentlemen, I'm very proud to introduce the new **Vanced Manager Beta Build 1.4.0™**
Vanced Manager is an universal utility for installing/updating Vanced and MicroG. It will push notifications once the update is ready and for root users, it can also automatically download and install them (Now that's what I call pwetty epic). Vanced Manager is an universal utility for installing/updating Vanced and MicroG. It will push notifications once the update is ready and for root users, it can also automatically download and install them (Now that's what I call pwetty epic).
Vanced manager comes with a slick UI ~~that was stolen from the new Magisk Manager (I'm very sorry John but I looked at your code for about 100 times).~~ Actually, while UI may look very similar to new Magisk Manager's UI, It's still very different (that's a blatant lie, I know). Vanced manager comes with a slick UI ~~that was stolen from the new Magisk Manager (I'm very sorry John but I looked at your code for about 100 times).~~ Actually, while UI may look very similar to new Magisk Manager's UI, It's still very different (that's a blatant lie, I know).
@ -17,12 +17,12 @@ Main Menu screenshot taken from tablet
![screenshot](https://i.imgur.com/r2jiq7J.png) ![screenshot](https://i.imgur.com/r2jiq7J.png)
Isn't this lovely and beautiful? Isn't this lovely and beautiful?
## Credits ## Credits
### Vanced Manager developers: ### Vanced Manager developers
- MrDodojo (API) - MrDodojo (API)
- Hope (API Integration into the app) - Hope (API Integration into the app)
- moosd (Patcher) - moosd (Patcher)
- X1nto (UX, (maybe I will make installer too idk)) - X1nto (UX, (maybe I will make installer too idk))
### The Vanced Team: ### The Vanced Team
- xfileFIN - xfileFIN
![xfileFIN](https://i.imgur.com/hLdzTVq.png) ![xfileFIN](https://i.imgur.com/hLdzTVq.png)
- KevinX8 - KevinX8

View file

@ -70,17 +70,17 @@
<output-test url="file://$MODULE_DIR$/build/intermediates/javac/debugUnitTest/classes" /> <output-test url="file://$MODULE_DIR$/build/intermediates/javac/debugUnitTest/classes" />
<exclude-output /> <exclude-output />
<content url="file://$MODULE_DIR$"> <content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/build/generated/renderscript_source_output_dir/debug/out" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/kaptKotlin/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/kapt/debug" isTestSource="false" generated="true" /> <sourceFolder url="file://$MODULE_DIR$/build/generated/source/kapt/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/ap_generated_sources/debug/out" isTestSource="false" generated="true" /> <sourceFolder url="file://$MODULE_DIR$/build/generated/ap_generated_sources/debug/out" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/aidl_source_output_dir/debug/out" isTestSource="false" generated="true" /> <sourceFolder url="file://$MODULE_DIR$/build/generated/aidl_source_output_dir/debug/out" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/renderscript_source_output_dir/debug/out" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/kaptKotlin/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" generated="true" /> <sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/kapt/debugAndroidTest" isTestSource="true" generated="true" /> <sourceFolder url="file://$MODULE_DIR$/build/generated/source/kapt/debugAndroidTest" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/ap_generated_sources/debugAndroidTest/out" isTestSource="true" generated="true" /> <sourceFolder url="file://$MODULE_DIR$/build/generated/ap_generated_sources/debugAndroidTest/out" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/aidl_source_output_dir/debugAndroidTest/out" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" /> <sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/aidl_source_output_dir/debugAndroidTest/out" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/renderscript_source_output_dir/debugAndroidTest/out" isTestSource="true" generated="true" /> <sourceFolder url="file://$MODULE_DIR$/build/generated/renderscript_source_output_dir/debugAndroidTest/out" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/debug" type="java-test-resource" generated="true" /> <sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/debug" type="java-test-resource" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/kapt/debugUnitTest" isTestSource="true" generated="true" /> <sourceFolder url="file://$MODULE_DIR$/build/generated/source/kapt/debugUnitTest" isTestSource="true" generated="true" />
@ -135,10 +135,10 @@
<library name="Gradle: kaptGeneratedClasses"> <library name="Gradle: kaptGeneratedClasses">
<CLASSES> <CLASSES>
<root url="file://$MODULE_DIR$/build/tmp/kapt3/classes/debugAndroidTest" /> <root url="file://$MODULE_DIR$/build/tmp/kapt3/classes/debugAndroidTest" />
<root url="file://$MODULE_DIR$/build/tmp/kapt3/classes/debug" />
<root url="file://$MODULE_DIR$/build/tmp/kapt3/classes/debugUnitTest" /> <root url="file://$MODULE_DIR$/build/tmp/kapt3/classes/debugUnitTest" />
<root url="file://$MODULE_DIR$/build/tmp/kapt3/classes/release" />
<root url="file://$MODULE_DIR$/build/tmp/kapt3/classes/releaseUnitTest" /> <root url="file://$MODULE_DIR$/build/tmp/kapt3/classes/releaseUnitTest" />
<root url="file://$MODULE_DIR$/build/tmp/kapt3/classes/release" />
<root url="file://$MODULE_DIR$/build/tmp/kapt3/classes/debug" />
</CLASSES> </CLASSES>
<JAVADOC /> <JAVADOC />
<SOURCES /> <SOURCES />

View file

@ -11,8 +11,8 @@ android {
applicationId "com.vanced.manager" applicationId "com.vanced.manager"
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 29 targetSdkVersion 29
versionCode 6 versionCode 7
versionName "1.2.0 beta" versionName "1.4.0 beta"
vectorDrawables.useSupportLibrary = true vectorDrawables.useSupportLibrary = true
} }
@ -43,7 +43,6 @@ android {
// To inline the bytecode built with JVM target 1.8 into // To inline the bytecode built with JVM target 1.8 into
// bytecode that is being built with JVM target 1.6. (e.g. navArgs) // bytecode that is being built with JVM target 1.6. (e.g. navArgs)
compileOptions { compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8 sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8

View file

@ -19,21 +19,20 @@ import androidx.preference.PreferenceManager
import com.dezlum.codelabs.getjson.GetJson import com.dezlum.codelabs.getjson.GetJson
import com.vanced.manager.core.installer.RootSplitInstallerService import com.vanced.manager.core.installer.RootSplitInstallerService
import com.vanced.manager.ui.MainActivity import com.vanced.manager.ui.MainActivity
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable import io.reactivex.disposables.Disposable
import io.reactivex.rxkotlin.subscribeBy import io.reactivex.rxkotlin.subscribeBy
import io.reactivex.schedulers.Schedulers
import zlc.season.rxdownload4.delete import zlc.season.rxdownload4.delete
import zlc.season.rxdownload4.download import zlc.season.rxdownload4.download
import zlc.season.rxdownload4.file import zlc.season.rxdownload4.file
import zlc.season.rxdownload4.task.Task import zlc.season.rxdownload4.task.Task
import zlc.season.rxdownload4.utils.getFileNameFromUrl import zlc.season.rxdownload4.utils.getFileNameFromUrl
import java.io.File
@SuppressLint("SetTextI18n") @SuppressLint("SetTextI18n")
open class BaseFragment : Fragment() { open class BaseFragment : Fragment() {
private var disposable: Disposable? = null private var disposable: Disposable? = null
private val baseUrl = "https://vanced.app/api/v1/apks/v15.05.54/" private val baseUrl = "https://vanced.app/api/v1/apks/v15.05.54"
fun openUrl(Url: String, color: Int) { fun openUrl(Url: String, color: Int) {
val builder = CustomTabsIntent.Builder() val builder = CustomTabsIntent.Builder()
@ -51,27 +50,39 @@ open class BaseFragment : Fragment() {
} }
} }
@SuppressLint("SdCardPath") fun uninstallApp(pkgName: String) {
fun isRootVancedInstalled(): Boolean { try {
val file = File("/data/data/com.google.android.youtube/shared_prefs/", "youtube_vanced.xml") val uri = Uri.parse("package:$pkgName")
return activity?.packageManager?.let { val uninstall = Intent(Intent.ACTION_DELETE, uri)
isPackageInstalled("com.google.android.youtube", uninstall.flags = Intent.FLAG_ACTIVITY_NEW_TASK
it uninstall.putExtra(Intent.EXTRA_RETURN_RESULT, true)
) startActivityForResult(uninstall, APP_UNINSTALL)
}!! && file.exists() } catch (e: ActivityNotFoundException) {
Toast.makeText(activity, "Failed to uninstall", Toast.LENGTH_SHORT).show()
}
} }
fun downloadArch(loadBar: ProgressBar, dlText: TextView, loadCircle: ProgressBar) { fun downloadSplits(type: String, loadBar: ProgressBar, dlText: TextView, loadCircle: ProgressBar) {
val prefs = activity?.getSharedPreferences("installPrefs", Context.MODE_PRIVATE) val prefs = activity?.getSharedPreferences("installPrefs", Context.MODE_PRIVATE)
prefs?.edit()?.putBoolean("isVancedDownloading", true)?.apply() prefs?.edit()?.putBoolean("isVancedDownloading", true)?.apply()
val variant = PreferenceManager.getDefaultSharedPreferences(activity).getString("vanced_variant", "nonroot") val variant = PreferenceManager.getDefaultSharedPreferences(activity).getString("vanced_variant", "nonroot")
val lang = prefs?.getString("lang", "en")
val theme = prefs?.getString("theme", "dark")
val arch = val arch =
when { when {
Build.SUPPORTED_ABIS.contains("x86") -> "x86" Build.SUPPORTED_ABIS.contains("x86") -> "x86"
Build.SUPPORTED_ABIS.contains("arm64-v8a") -> "arm64_v8a" Build.SUPPORTED_ABIS.contains("arm64-v8a") -> "arm64_v8a"
else -> "armeabi_v7a" else -> "armeabi_v7a"
} }
val url = "$baseUrl/$variant/Config/config.$arch.apk" val url =
when (type) {
"arch" -> "$baseUrl/$variant/Config/config.$arch.apk"
"theme" -> "$baseUrl/$variant/Theme/$theme.apk"
"lang" -> "$baseUrl/$variant/Language/split_config.$lang.apk"
"enlang" -> "$baseUrl/$variant/Language/split_config.en.apk"
else -> throw NotImplementedError("This type of APK is NOT valid. What the hell did you even do?")
}
val task = activity?.cacheDir?.path?.let { val task = activity?.cacheDir?.path?.let {
Task( Task(
url = url, url = url,
@ -84,96 +95,33 @@ open class BaseFragment : Fragment() {
task.delete() task.delete()
disposable = task.download() disposable = task.download()
.observeOn(AndroidSchedulers.mainThread()) .observeOn(Schedulers.single())
.subscribeBy( .subscribeBy(
onNext = { progress -> onNext = { progress ->
activity?.runOnUiThread {
val filename = getFileNameFromUrl(url) val filename = getFileNameFromUrl(url)
loadBar.visibility = View.VISIBLE loadBar.visibility = View.VISIBLE
dlText.visibility = View.VISIBLE dlText.visibility = View.VISIBLE
dlText.text = "Downloading $filename..." dlText.text = "Downloading $filename..."
loadBar.progress = progress.percent().toInt() loadBar.progress = progress.percent().toInt()
}
}, },
onComplete = { onComplete = {
downloadTheme(loadBar, dlText, loadCircle) when (type) {
}, "arch" -> downloadSplits("theme", loadBar, dlText, loadCircle)
onError = { throwable -> "theme" -> downloadSplits("lang", loadBar, dlText, loadCircle)
Toast.makeText(activity, throwable.toString(), Toast.LENGTH_SHORT).show() "lang" -> {
} if (lang == "en" || type == "enlang") {
) activity?.runOnUiThread { loadCircle.visibility = View.VISIBLE }
} if (variant == "root") {
private fun downloadTheme(loadBar: ProgressBar, dlText: TextView, loadCircle: ProgressBar) {
val variant = PreferenceManager.getDefaultSharedPreferences(activity).getString("vanced_variant", "nonroot")
val prefs = activity?.getSharedPreferences("installPrefs", Context.MODE_PRIVATE)
val theme = prefs?.getString("theme", "dark")
val url = "$baseUrl/$variant/Theme/$theme.apk"
val task = activity?.cacheDir?.path?.let {
Task(
url = url,
saveName = getFileNameFromUrl(url),
savePath = it
)
}
if (task?.file()?.exists()!!)
task.delete()
disposable = task.download()
.observeOn(AndroidSchedulers.mainThread())
.subscribeBy(
onNext = { progress ->
val filename = getFileNameFromUrl(url)
dlText.text = "Downloading $filename..."
loadBar.progress = progress.percent().toInt()
},
onComplete = {
downloadLang(loadBar, dlText, loadCircle)
},
onError = { throwable ->
Toast.makeText(activity, throwable.toString(), Toast.LENGTH_SHORT).show()
}
)
}
private fun downloadLang(loadBar: ProgressBar, dlText: TextView, loadCircle: ProgressBar) {
val variant = PreferenceManager.getDefaultSharedPreferences(activity).getString("vanced_variant", "nonroot")
val prefs = activity?.getSharedPreferences("installPrefs", Context.MODE_PRIVATE)
val lang = prefs?.getString("lang", "en")
val url = "$baseUrl/$variant/Language/split_config.$lang.apk"
val task = activity?.cacheDir?.path?.let {
Task(
url = url,
saveName = getFileNameFromUrl(url),
savePath = it
)
}
if (task?.file()?.exists()!!)
task.delete()
disposable = task.download()
.observeOn(AndroidSchedulers.mainThread())
.subscribeBy(
onNext = { progress ->
val filename = getFileNameFromUrl(url)
dlText.text = "Downloading $filename..."
loadBar.progress = progress.percent().toInt()
},
onComplete = {
loadBar.visibility = View.GONE
if (lang != "en")
downloadEn(loadBar, dlText, loadCircle)
else {
dlText.visibility = View.GONE
loadCircle.visibility = View.VISIBLE
prefs.edit()?.putBoolean("isVancedDownloading", false)?.apply()
if (PreferenceManager.getDefaultSharedPreferences(activity).getString("vanced_variant", "nonroot") == "root") {
launchRootInstaller() launchRootInstaller()
} else { } else {
launchInstaller() launchInstaller()
} }
} else {
downloadSplits("enlang", loadBar, dlText, loadCircle)
}
}
} }
}, },
onError = { throwable -> onError = { throwable ->
@ -182,49 +130,6 @@ open class BaseFragment : Fragment() {
) )
} }
private fun downloadEn(loadBar: ProgressBar, dlText: TextView, loadCircle: ProgressBar) {
val variant = PreferenceManager.getDefaultSharedPreferences(activity).getString("vanced_variant", "nonroot")
val prefs = activity?.getSharedPreferences("installPrefs", Context.MODE_PRIVATE)
val url = "$baseUrl/$variant/Language/split_config.en.apk"
val task = activity?.cacheDir?.path?.let {
Task(
url = url,
saveName = getFileNameFromUrl(url),
savePath = it
)
}
if (task?.file()?.exists()!!)
task.delete()
disposable = task
.download()
.observeOn(AndroidSchedulers.mainThread())
.subscribeBy(
onNext = {progress ->
val filename = getFileNameFromUrl(url)
loadBar.visibility = View.VISIBLE
dlText.text = "Downloading $filename..."
loadBar.progress = progress.percent().toInt()
},
onComplete = {
loadBar.visibility = View.GONE
dlText.visibility = View.GONE
loadCircle.visibility = View.VISIBLE
prefs?.edit()?.putBoolean("isVancedDownloading", false)?.apply()
if (PreferenceManager.getDefaultSharedPreferences(activity).getString("vanced_variant", "nonroot") == "root") {
launchRootInstaller()
} else {
launchInstaller()
}
},
onError = { throwable ->
Toast.makeText(requireContext(), throwable.toString(), Toast.LENGTH_SHORT).show()
}
)
}
private fun launchInstaller() { private fun launchInstaller() {
val activity = (activity as MainActivity) val activity = (activity as MainActivity)
activity.installSplitApk() activity.installSplitApk()
@ -234,11 +139,11 @@ open class BaseFragment : Fragment() {
activity?.startService(Intent(activity, RootSplitInstallerService::class.java)) activity?.startService(Intent(activity, RootSplitInstallerService::class.java))
} }
fun installApk(url: String, loadBar: ProgressBar, dlText: TextView) { fun installMicrog(loadBar: ProgressBar?, dlText: TextView?) {
val prefs = activity?.getSharedPreferences("installPrefs", Context.MODE_PRIVATE) val prefs = activity?.getSharedPreferences("installPrefs", Context.MODE_PRIVATE)
prefs?.edit()?.putBoolean("isMicrogDownloading", true)?.apply() prefs?.edit()?.putBoolean("isMicrogDownloading", true)?.apply()
val apkUrl = GetJson().AsJSONObject(url) val apkUrl = GetJson().AsJSONObject("https://x1nto.github.io/VancedFiles/microg.json")
val dwnldUrl = apkUrl.get("url").asString val dwnldUrl = apkUrl.get("url").asString
val task = activity?.filesDir?.path?.let { val task = activity?.filesDir?.path?.let {
Task( Task(
@ -253,19 +158,22 @@ open class BaseFragment : Fragment() {
disposable = task disposable = task
.download() .download()
.observeOn(AndroidSchedulers.mainThread()) .observeOn(Schedulers.newThread())
.subscribeBy( .subscribeBy(
onNext = { progress -> onNext = { progress ->
activity?.runOnUiThread {
val filename = getFileNameFromUrl(dwnldUrl) val filename = getFileNameFromUrl(dwnldUrl)
loadBar.visibility = View.VISIBLE loadBar?.visibility = View.VISIBLE
dlText.visibility = View.VISIBLE dlText?.visibility = View.VISIBLE
dlText.text = "Downloading $filename..." dlText?.text = "Downloading $filename..."
loadBar.progress = progress.percent().toInt() loadBar?.progress = progress.percent().toInt()
}
}, },
onComplete = { onComplete = {
loadBar.visibility = View.GONE activity?.runOnUiThread {
dlText.visibility = View.GONE loadBar?.visibility = View.GONE
dlText?.visibility = View.GONE
}
prefs?.edit()?.putBoolean("isMicrogDownloading", false)?.apply() prefs?.edit()?.putBoolean("isMicrogDownloading", false)?.apply()
val pn = activity?.packageName val pn = activity?.packageName
val apk = task.file() val apk = task.file()
@ -278,7 +186,8 @@ open class BaseFragment : Fragment() {
intent.setDataAndType(uri, "application/vnd.android.package-archive") intent.setDataAndType(uri, "application/vnd.android.package-archive")
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
startActivity(intent) intent.putExtra(Intent.EXTRA_RETURN_RESULT, true)
startActivityForResult(intent, MICROG_INSTALL)
}, },
onError = { throwable -> onError = { throwable ->
Toast.makeText(requireContext(), throwable.toString(), Toast.LENGTH_SHORT) Toast.makeText(requireContext(), throwable.toString(), Toast.LENGTH_SHORT)
@ -287,4 +196,9 @@ open class BaseFragment : Fragment() {
) )
} }
companion object {
const val APP_UNINSTALL = 69
const val MICROG_INSTALL = 420
}
} }

View file

@ -7,7 +7,7 @@ import android.util.Log
import android.view.View import android.view.View
import android.widget.* import android.widget.*
import androidx.navigation.findNavController import androidx.navigation.findNavController
import androidx.preference.PreferenceManager import androidx.preference.PreferenceManager.getDefaultSharedPreferences
import com.google.android.material.button.MaterialButton import com.google.android.material.button.MaterialButton
import com.vanced.manager.R import com.vanced.manager.R
import com.vanced.manager.core.base.BaseFragment import com.vanced.manager.core.base.BaseFragment
@ -15,7 +15,7 @@ import com.vanced.manager.core.installer.StubInstaller
import com.vanced.manager.ui.MainActivity import com.vanced.manager.ui.MainActivity
import com.vanced.manager.utils.MiuiHelper import com.vanced.manager.utils.MiuiHelper
open class Home : BaseFragment() { open class Home : BaseFragment(), View.OnClickListener {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
@ -24,15 +24,44 @@ open class Home : BaseFragment() {
val vancedinstallbtn = view.findViewById<MaterialButton>(R.id.vanced_installbtn) val vancedinstallbtn = view.findViewById<MaterialButton>(R.id.vanced_installbtn)
val signaturebtn = view.findViewById<MaterialButton>(R.id.signature_button) val signaturebtn = view.findViewById<MaterialButton>(R.id.signature_button)
val microgProgress = view.findViewById<ProgressBar>(R.id.microg_progress) vancedinstallbtn.setOnClickListener(this)
microginstallbtn.setOnClickListener(this)
signaturebtn.setOnClickListener(this)
}
override fun onResume() {
super.onResume()
val loadBar = view?.findViewById<ProgressBar>(R.id.vanced_progress)
val dlText = view?.findViewById<TextView>(R.id.vanced_downloading)
val loadCircle = view?.findViewById<ProgressBar>(R.id.vanced_installing)
val prefs = activity?.getSharedPreferences("installPrefs", Context.MODE_PRIVATE)
val isInstalling = prefs?.getBoolean("isInstalling", false)
if (isInstalling!!) {
downloadSplits("arch", loadBar!!, dlText!!, loadCircle!!)
prefs.edit().putBoolean("isInstalling", false).apply()
}
}
override fun onClick(v: View?) {
val microgProgress = view?.findViewById<ProgressBar>(R.id.microg_progress)
val prefs = activity?.getSharedPreferences("installPrefs", Context.MODE_PRIVATE) val prefs = activity?.getSharedPreferences("installPrefs", Context.MODE_PRIVATE)
val isVancedDownloading: Boolean? = prefs?.getBoolean("isVancedDownloading", false) val isVancedDownloading: Boolean? = prefs?.getBoolean("isVancedDownloading", false)
val isMicrogDownloading: Boolean? = prefs?.getBoolean("isMicrogDownloading", false) val isMicrogDownloading: Boolean? = prefs?.getBoolean("isMicrogDownloading", false)
val variant = getDefaultSharedPreferences(activity)
.getString("vanced_variant", "Nonroot")
val vancedPkgName =
if (variant == "Root") {
"com.google.android.youtube"
} else {
"com.vanced.android.youtube"
}
vancedinstallbtn.setOnClickListener { when (v?.id) {
R.id.vanced_installbtn -> {
if (!isVancedDownloading!!) { if (!isVancedDownloading!!) {
val mainActivity = (activity as MainActivity) val mainActivity = (activity as MainActivity)
if (PreferenceManager.getDefaultSharedPreferences(activity).getString("vanced_variant", "Nonroot") == "Root") { if (variant == "Root") {
if (MiuiHelper.isMiui()) { if (MiuiHelper.isMiui()) {
mainActivity.secondMiuiDialog() mainActivity.secondMiuiDialog()
} else } else
@ -48,28 +77,26 @@ open class Home : BaseFragment() {
Log.d("VMCache", "Unable to delete cacheDir") Log.d("VMCache", "Unable to delete cacheDir")
} }
if (prefs.getBoolean("valuesModified", false)) { if (prefs.getBoolean("valuesModified", false)) {
val loadBar = view.findViewById<ProgressBar>(R.id.vanced_progress) val loadBar = view?.findViewById<ProgressBar>(R.id.vanced_progress)
val dlText = view.findViewById<TextView>(R.id.vanced_downloading) val dlText = view?.findViewById<TextView>(R.id.vanced_downloading)
val loadCircle = view.findViewById<ProgressBar>(R.id.vanced_installing) val loadCircle = view?.findViewById<ProgressBar>(R.id.vanced_installing)
downloadArch(loadBar!!, dlText!!, loadCircle!!) downloadSplits("arch", loadBar!!, dlText!!, loadCircle!!)
prefs.edit().putBoolean("isInstalling", false).apply() prefs.edit().putBoolean("isInstalling", false).apply()
} else } else
view.findNavController().navigate(R.id.toInstallThemeFragment) view?.findNavController()?.navigate(R.id.toInstallThemeFragment)
} else { } else {
Toast.makeText(activity, "Please wait until installation finishes", Toast.LENGTH_SHORT).show() Toast.makeText(activity, "Please wait until installation finishes", Toast.LENGTH_SHORT).show()
} }
} }
R.id.microg_installbtn -> {
microginstallbtn.setOnClickListener {
if (!isMicrogDownloading!!) { if (!isMicrogDownloading!!) {
val dlText = view.findViewById<TextView>(R.id.microg_downloading) val dlText = view?.findViewById<TextView>(R.id.microg_downloading)
try { try {
installApk( installMicrog(
"https://x1nto.github.io/VancedFiles/microg.json",
microgProgress, microgProgress,
dlText dlText
) )
} catch (e: Exception) { } catch (e: Exception) {
Toast.makeText(activity, "Unable to start installation", Toast.LENGTH_SHORT).show() Toast.makeText(activity, "Unable to start installation", Toast.LENGTH_SHORT).show()
} }
@ -77,26 +104,14 @@ open class Home : BaseFragment() {
Toast.makeText(activity, "Please wait until installation finishes", Toast.LENGTH_SHORT).show() Toast.makeText(activity, "Please wait until installation finishes", Toast.LENGTH_SHORT).show()
} }
} }
R.id.signature_button -> {
signaturebtn.setOnClickListener { val loadCircle = view?.findViewById<ProgressBar>(R.id.signature_loading)
val loadCircle = view.findViewById<ProgressBar>(R.id.signature_loading) loadCircle?.visibility = View.VISIBLE
loadCircle.visibility = View.VISIBLE
val mIntent = Intent(activity, StubInstaller::class.java) val mIntent = Intent(activity, StubInstaller::class.java)
activity?.startService(mIntent) activity?.startService(mIntent)
} }
R.id.microg_uninstallbtn -> uninstallApp("com.mgoogle.android.gms")
} R.id.vanced_uninstallbtn -> uninstallApp(vancedPkgName)
override fun onResume() {
super.onResume()
val loadBar = view?.findViewById<ProgressBar>(R.id.vanced_progress)
val dlText = view?.findViewById<TextView>(R.id.vanced_downloading)
val loadCircle = view?.findViewById<ProgressBar>(R.id.vanced_installing)
val prefs = activity?.getSharedPreferences("installPrefs", Context.MODE_PRIVATE)
val isInstalling = prefs?.getBoolean("isInstalling", false)
if (isInstalling!!) {
downloadArch(loadBar!!, dlText!!, loadCircle!!)
prefs.edit().putBoolean("isInstalling", false).apply()
} }
} }

View file

@ -12,7 +12,6 @@ import androidx.navigation.findNavController
import androidx.navigation.ui.AppBarConfiguration import androidx.navigation.ui.AppBarConfiguration
import androidx.navigation.ui.setupWithNavController import androidx.navigation.ui.setupWithNavController
import androidx.preference.PreferenceManager import androidx.preference.PreferenceManager
import com.vanced.manager.BR
import com.vanced.manager.R import com.vanced.manager.R
import com.vanced.manager.core.Main import com.vanced.manager.core.Main
import com.vanced.manager.databinding.ActivityMainBinding import com.vanced.manager.databinding.ActivityMainBinding
@ -53,12 +52,12 @@ class MainActivity : Main() {
override fun onReceive(context: Context, intent: Intent) { override fun onReceive(context: Context, intent: Intent) {
when (intent.action) { when (intent.action) {
INSTALL_COMPLETED -> launchVanced() INSTALL_COMPLETED -> launchVanced()
INSTALL_BLOCKED -> alertBuilder(INSTALL_BLOCKED) INSTALL_BLOCKED -> alertBuilder(getString(R.string.installation_blocked))
INSTALL_FAILED -> alertBuilder(INSTALL_FAILED) INSTALL_FAILED -> alertBuilder(getString(R.string.installation_failed))
INSTALL_ABORTED -> alertBuilder(INSTALL_ABORTED) INSTALL_ABORTED -> alertBuilder(getString(R.string.installation_aborted))
INSTALL_STORAGE -> alertBuilder(INSTALL_STORAGE) INSTALL_STORAGE -> alertBuilder(getString(R.string.installation_storage))
INSTALL_CONFLICT -> alertBuilder(INSTALL_CONFLICT) INSTALL_CONFLICT -> alertBuilder(getString(R.string.installation_conflict))
INSTALL_INVALID -> alertBuilder(INSTALL_INVALID) INSTALL_INVALID -> alertBuilder(getString(R.string.installation_invalid))
} }
} }
@ -113,6 +112,11 @@ class MainActivity : Main() {
return false return false
} }
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
}
private fun setDisplayHomeAsUpEnabled(isNeeded: Boolean) { private fun setDisplayHomeAsUpEnabled(isNeeded: Boolean) {
val toolbar: Toolbar = findViewById(R.id.home_toolbar) val toolbar: Toolbar = findViewById(R.id.home_toolbar)
when { when {
@ -124,7 +128,7 @@ class MainActivity : Main() {
private fun alertBuilder(msg: String) { private fun alertBuilder(msg: String) {
AlertDialog.Builder(this) AlertDialog.Builder(this)
.setTitle("Error") .setTitle("Error")
.setMessage("Operation failed because $msg") .setMessage(msg)
.setPositiveButton(getString(R.string.close)) { dialog, _ -> .setPositiveButton(getString(R.string.close)) { dialog, _ ->
run { run {
dialog.dismiss() dialog.dismiss()

View file

@ -1,6 +1,7 @@
package com.vanced.manager.ui.fragments package com.vanced.manager.ui.fragments
import android.animation.ObjectAnimator import android.animation.ObjectAnimator
import android.app.Activity.*
import android.content.BroadcastReceiver import android.content.BroadcastReceiver
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
@ -9,6 +10,7 @@ import android.content.res.ColorStateList
import android.graphics.Color import android.graphics.Color
import android.os.Build import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.util.Log
import android.view.* import android.view.*
import android.widget.ProgressBar import android.widget.ProgressBar
import android.widget.TextView import android.widget.TextView
@ -35,7 +37,6 @@ import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable import io.reactivex.disposables.Disposable
import io.reactivex.schedulers.Schedulers import io.reactivex.schedulers.Schedulers
@Suppress("DEPRECATION")
class HomeFragment : Home() { class HomeFragment : Home() {
private lateinit var sectionPageAdapter: SectionPageAdapter private lateinit var sectionPageAdapter: SectionPageAdapter
@ -62,10 +63,14 @@ class HomeFragment : Home() {
binding.viewModel = viewModel binding.viewModel = viewModel
val variantPref = getDefaultSharedPreferences(activity).getString("vanced_variant", "nonroot") val variantPref = getDefaultSharedPreferences(activity).getString("vanced_variant", "nonroot")
val signatureStatus = getDefaultSharedPreferences(activity).getString("signature_status", "unavailable")
registerReceivers() registerReceivers()
if (variantPref == "root") { if (variantPref == "root") {
attachRootChangelog() attachRootChangelog()
if (signatureStatus != "disabled") {
disableVancedButton(getString(R.string.signature_not_checked))
}
} else } else
attachNonrootChangelog() attachNonrootChangelog()
@ -78,10 +83,10 @@ class HomeFragment : Home() {
private fun initNetworkFun() { private fun initNetworkFun() {
val pm = activity?.packageManager val pm = activity?.packageManager
val variant = getDefaultSharedPreferences(activity).getString("vanced_variant", "nonroot") val variant = getDefaultSharedPreferences(activity).getString("vanced_variant", "Nonroot")
val microgStatus = pm?.let { isPackageInstalled("com.mgoogle.android.gms", it) } val microgStatus = pm?.let { isPackageInstalled("com.mgoogle.android.gms", it) }
val vancedStatus = val vancedStatus =
if (variant == "root") { if (variant == "Root") {
pm?.let { isPackageInstalled("com.google.android.youtube", it) } pm?.let { isPackageInstalled("com.google.android.youtube", it) }
} else { } else {
pm?.let { isPackageInstalled("com.vanced.android.youtube", it) } pm?.let { isPackageInstalled("com.vanced.android.youtube", it) }
@ -110,6 +115,7 @@ class HomeFragment : Home() {
microginstallbtn?.visibility = View.VISIBLE microginstallbtn?.visibility = View.VISIBLE
if (microgStatus!!) { if (microgStatus!!) {
@Suppress("DEPRECATION")
val microgVerCode = val microgVerCode =
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P)
pm.getPackageInfo("com.mgoogle.android.gms", 0).longVersionCode.and(0xFFFFFFFF).toInt() pm.getPackageInfo("com.mgoogle.android.gms", 0).longVersionCode.and(0xFFFFFFFF).toInt()
@ -131,22 +137,20 @@ class HomeFragment : Home() {
} }
} }
} else { } else {
vancedinstallbtn?.isEnabled = false activity?.getString(R.string.no_microg)?.let {
vancedinstallbtn?.backgroundTintList = ColorStateList.valueOf(Color.DKGRAY) disableVancedButton(it)
vancedinstallbtn?.setTextColor(ColorStateList.valueOf(Color.GRAY)) }
vancedinstallbtn?.text = activity?.getString(R.string.no_microg)
vancedinstallbtn?.icon = null
} }
} }
if (vancedStatus!!) { if (vancedStatus!!) {
val vanPkgName = val vanPkgName =
if (variant == "root") { if (variant == "root")
"com.google.android.youtube" "com.google.android.youtube"
} else { else
"com.vanced.android.youtube" "com.vanced.android.youtube"
}
@Suppress("DEPRECATION")
val vancedVerCode = val vancedVerCode =
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
pm?.getPackageInfo( pm?.getPackageInfo(
@ -216,24 +220,49 @@ class HomeFragment : Home() {
} }
} }
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
val tag = "VMUninstall"
when (requestCode) {
MICROG_INSTALL -> {
when (resultCode) {
RESULT_OK -> {
activity?.recreate()
Log.d(tag, "Successfully installed MicroG")
}
RESULT_CANCELED -> Log.d(tag, "Failed to install MicroG, perhaps user canceled request?")
RESULT_FIRST_USER -> Log.d(tag, "What does this even mean?")
}
}
APP_UNINSTALL -> {
when (resultCode) {
RESULT_OK -> {
activity?.recreate()
Log.d(tag, "Successfully uninstalled app")
}
RESULT_CANCELED -> Log.d(tag, "Failed to uninstall app, perhaps user canceled request?")
RESULT_FIRST_USER -> Log.d(tag, "What does this even mean?")
}
}
}
super.onActivityResult(requestCode, resultCode, data)
}
private val broadcastReceiver: BroadcastReceiver = object : BroadcastReceiver() { private val broadcastReceiver: BroadcastReceiver = object : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) { override fun onReceive(context: Context, intent: Intent) {
val statusTxt = view?.findViewById<TextView>(R.id.signature_status) val statusTxt = view?.findViewById<TextView>(R.id.signature_status)
val vancedinstallbtn = view?.findViewById<MaterialButton>(R.id.vanced_installbtn)
val loadCircle = view?.findViewById<ProgressBar>(R.id.signature_loading) val loadCircle = view?.findViewById<ProgressBar>(R.id.signature_loading)
when (intent.action) { when (intent.action) {
SIGNATURE_DISABLED -> { SIGNATURE_DISABLED -> {
loadCircle?.visibility = View.GONE loadCircle?.visibility = View.GONE
statusTxt?.text = "Disabled" statusTxt?.text = getString(R.string.signature_disabled)
statusTxt?.setTextColor(resources.getColor(R.color.Green)) statusTxt?.setTextColor(getColor(R.color.Green))
vancedinstallbtn?.visibility = View.VISIBLE
val mIntent = Intent(activity, RootAppUninstaller::class.java) val mIntent = Intent(activity, RootAppUninstaller::class.java)
mIntent.putExtra("Data", "com.vanced.stub") mIntent.putExtra("Data", "com.vanced.stub")
activity?.startService(mIntent) activity?.startService(mIntent)
} }
SIGNATURE_ENABLED -> { SIGNATURE_ENABLED -> {
statusTxt?.text = "Enabled" statusTxt?.text = getString(R.string.signature_enabled)
statusTxt?.setTextColor(resources.getColor(R.color.Red)) statusTxt?.setTextColor(getColor(R.color.Red))
loadCircle?.visibility = View.GONE loadCircle?.visibility = View.GONE
} }
} }
@ -288,6 +317,23 @@ class HomeFragment : Home() {
super .onCreateOptionsMenu(menu, inflater) super .onCreateOptionsMenu(menu, inflater)
} }
private fun disableVancedButton(txt: String) {
val vancedinstallbtn = view?.findViewById<MaterialButton>(R.id.vanced_installbtn)
vancedinstallbtn?.isEnabled = false
vancedinstallbtn?.backgroundTintList = ColorStateList.valueOf(Color.DKGRAY)
vancedinstallbtn?.setTextColor(ColorStateList.valueOf(Color.GRAY))
vancedinstallbtn?.text = txt
vancedinstallbtn?.icon = null
}
@Suppress("DEPRECATION")
private fun getColor(color: Int): Int {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
resources.getColor(color, activity?.theme)
else
resources.getColor(color)
}
companion object { companion object {
const val SIGNATURE_DISABLED = "Signature verification disabled" const val SIGNATURE_DISABLED = "Signature verification disabled"
const val SIGNATURE_ENABLED = "Signature verification enabled" const val SIGNATURE_ENABLED = "Signature verification enabled"

View file

@ -23,10 +23,10 @@ class ManagerChangelogFragment : Fragment() {
val changelogTxt = view.findViewById<TextView>(R.id.manager_changelog) val changelogTxt = view.findViewById<TextView>(R.id.manager_changelog)
if (GetJson().isConnected(activity)) {
val checkUrl = GetJson().AsJSONObject("https://vanced.app/api/v1/manager.json") val checkUrl = GetJson().AsJSONObject("https://vanced.app/api/v1/manager.json")
val changelog = checkUrl.get("changelog").asString val changelog = checkUrl.get("changelog").asString
if (GetJson().isConnected(activity))
changelogTxt.text = changelog changelogTxt.text = changelog
} }
}
} }

View file

@ -23,10 +23,10 @@ class MicrogChangelogFragment : Fragment() {
val changelogTxt = view.findViewById<TextView>(R.id.microg_changelog) val changelogTxt = view.findViewById<TextView>(R.id.microg_changelog)
if (GetJson().isConnected(activity)) {
val checkUrl = GetJson().AsJSONObject("https://x1nto.github.io/VancedFiles/microg.json") val checkUrl = GetJson().AsJSONObject("https://x1nto.github.io/VancedFiles/microg.json")
val changelog = checkUrl.get("changelog").asString val changelog = checkUrl.get("changelog").asString
if (GetJson().isConnected(activity))
changelogTxt.text = changelog changelogTxt.text = changelog
} }
}
} }

View file

@ -28,14 +28,14 @@ class SettingsFragment : PreferenceFragmentCompat() {
val themeSwitch: ListPreference? = findPreference("theme_mode") val themeSwitch: ListPreference? = findPreference("theme_mode")
themeSwitch?.summary = preferenceScreen.sharedPreferences.getString("theme_mode", "Light") themeSwitch?.summary = preferenceScreen.sharedPreferences.getString("theme_mode", "Light")
themeSwitch?.setOnPreferenceChangeListener { _, _ -> themeSwitch?.setOnPreferenceChangeListener { _, _ ->
activity?.recreate() restartMain()
true true
} }
val accentSwitch: ListPreference? = findPreference("accent_color") val accentSwitch: ListPreference? = findPreference("accent_color")
accentSwitch?.summary = preferenceScreen.sharedPreferences.getString("accent_color", "Blue") accentSwitch?.summary = preferenceScreen.sharedPreferences.getString("accent_color", "Blue")
accentSwitch?.setOnPreferenceChangeListener { _, _ -> accentSwitch?.setOnPreferenceChangeListener { _, _ ->
activity?.recreate() restartMain()
true true
} }
@ -49,8 +49,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
} }
} }
} }
startActivity(Intent(activity, MainActivity::class.java)) restartMain()
activity?.finish()
true true
} }
@ -69,4 +68,9 @@ class SettingsFragment : PreferenceFragmentCompat() {
super .onCreateOptionsMenu(menu, inflater) super .onCreateOptionsMenu(menu, inflater)
} }
fun restartMain() {
startActivity(Intent(activity, MainActivity::class.java))
activity?.finish()
}
} }

View file

@ -23,11 +23,12 @@ class VancedChangelogFragment : Fragment() {
val changelogTxt = view.findViewById<TextView>(R.id.vanced_changelog) val changelogTxt = view.findViewById<TextView>(R.id.vanced_changelog)
if (GetJson().isConnected(activity)) {
val checkUrl = GetJson().AsJSONObject("https://vanced.app/api/v1/changelog/15_05_54.json") val checkUrl = GetJson().AsJSONObject("https://vanced.app/api/v1/changelog/15_05_54.json")
val changelog = checkUrl.get("message").asString val changelog = checkUrl.get("message").asString
if (GetJson().isConnected(activity))
changelogTxt.text = changelog changelogTxt.text = changelog
} }
}
} }

View file

@ -26,7 +26,7 @@ open class HomeViewModel(application: Application): AndroidViewModel(application
} }
} }
val isConnected = GetJson().isConnected(application) private val connected: Boolean = GetJson().isConnected(application)
private val vancedPkgName: String = private val vancedPkgName: String =
if (getDefaultSharedPreferences(application).getString("vanced_variant", "nonroot") == "root") { if (getDefaultSharedPreferences(application).getString("vanced_variant", "nonroot") == "root") {
@ -34,12 +34,13 @@ open class HomeViewModel(application: Application): AndroidViewModel(application
} else { } else {
"com.vanced.android.youtube" "com.vanced.android.youtube"
} }
private val signaturePref = getDefaultSharedPreferences(application).getString("signature_status", "unavailable")
val isMicrogInstalled: Boolean = isPackageInstalled("com.mgoogle.android.gms", application.packageManager) val microgInstalled: Boolean = isPackageInstalled("com.mgoogle.android.gms", application.packageManager)
val isVancedInstalled: Boolean = isPackageInstalled(vancedPkgName, application.packageManager) val vancedInstalled: Boolean = isPackageInstalled(vancedPkgName, application.packageManager)
val vancedInstalledVersion: String = val vancedInstalledVersion: String =
if (isVancedInstalled) { if (vancedInstalled) {
application.packageManager.getPackageInfo(vancedPkgName, 0).versionName application.packageManager.getPackageInfo(vancedPkgName, 0).versionName
} else { } else {
application.getString(R.string.unavailable) application.getString(R.string.unavailable)
@ -47,27 +48,34 @@ open class HomeViewModel(application: Application): AndroidViewModel(application
val microgInstalledVersion: String = val microgInstalledVersion: String =
if (isMicrogInstalled) { if (microgInstalled) {
application.packageManager.getPackageInfo("com.mgoogle.android.gms", 0).versionName application.packageManager.getPackageInfo("com.mgoogle.android.gms", 0).versionName
} else { } else {
application.getString(R.string.unavailable) application.getString(R.string.unavailable)
} }
val vancedVersion: String = val vancedVersion: String =
if (isConnected) if (connected)
GetJson().AsJSONObject("https://vanced.app/api/v1/vanced.json") GetJson().AsJSONObject("https://vanced.app/api/v1/vanced.json")
.get("version").asString .get("version").asString
else else
application.getString(R.string.unavailable) application.getString(R.string.unavailable)
val microgVersion: String = val microgVersion: String =
if (isConnected) if (connected)
GetJson().AsJSONObject("https://vanced.app/api/v1/microg.json") GetJson().AsJSONObject("https://vanced.app/api/v1/microg.json")
.get("version").asString .get("version").asString
else else
application.getString(R.string.unavailable) application.getString(R.string.unavailable)
val isNonrootModeSelected: Boolean = getDefaultSharedPreferences(application).getString("vanced_variant", "nonroot") == "nonroot" val isNonrootModeSelected: Boolean = getDefaultSharedPreferences(application).getString("vanced_variant", "Nonroot") == "Nonroot"
val signatureStatusTxt: String =
when (signaturePref) {
"disabled" -> application.getString(R.string.signature_disabled)
"enabled" -> application.getString(R.string.signature_enabled)
else -> application.getString(R.string.unavailable)
}
fun openMicrogSettings() { fun openMicrogSettings() {
try { try {
@ -83,30 +91,6 @@ open class HomeViewModel(application: Application): AndroidViewModel(application
} }
} }
fun uninstallMicrog() {
try {
val uri = Uri.parse("package:com.mgoogle.android.gms")
val uninstall = Intent(Intent.ACTION_DELETE, uri)
uninstall.flags = Intent.FLAG_ACTIVITY_NEW_TASK
startActivity(getApplication(), uninstall, null)
} catch (e: ActivityNotFoundException) {
Toast.makeText(getApplication(), "Failed to uninstall", Toast.LENGTH_SHORT).show()
}
}
fun uninstallVanced() {
try {
val uri = Uri.parse("package:$vancedPkgName")
val uninstall = Intent(Intent.ACTION_DELETE, uri)
uninstall.flags = Intent.FLAG_ACTIVITY_NEW_TASK
startActivity(getApplication(), uninstall, null)
} catch (e: ActivityNotFoundException) {
Toast.makeText(getApplication(), "Failed to uninstall", Toast.LENGTH_SHORT).show()
}
}
fun openUrl(Url: String) { fun openUrl(Url: String) {
val color: Int = val color: Int =
when (Url) { when (Url) {

View file

@ -64,7 +64,8 @@
android:layout_marginStart="@dimen/stdp" android:layout_marginStart="@dimen/stdp"
android:layout_marginTop="@dimen/stdp" android:layout_marginTop="@dimen/stdp"
android:layout_marginEnd="@dimen/stdp" android:layout_marginEnd="@dimen/stdp"
android:visibility="@{viewModel.nonrootModeSelected ? View.GONE : View.VISIBLE}" /> android:visibility="@{viewModel.nonrootModeSelected ? View.GONE : View.VISIBLE}"
bind:viewModel="@{viewModel}"/>
<include <include
layout="@layout/include_changelogs" layout="@layout/include_changelogs"

View file

@ -1,5 +1,15 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.card.MaterialCardView <layout>
<data>
<variable
name="viewModel"
type="com.vanced.manager.ui.viewmodels.HomeViewModel" />
</data>
<com.google.android.material.card.MaterialCardView
style="@style/MaterialCard" style="@style/MaterialCard"
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
@ -53,7 +63,7 @@
<TextView <TextView
style="@style/AppVer.Bold" style="@style/AppVer.Bold"
android:id="@+id/signature_status" android:id="@+id/signature_status"
android:text="@string/unavailable"/> android:text="@{viewModel.signatureStatusTxt}"/>
</LinearLayout> </LinearLayout>
@ -69,4 +79,5 @@
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView> </com.google.android.material.card.MaterialCardView>
</layout>

View file

@ -15,8 +15,14 @@
<!-- Home Page --> <!-- Home Page -->
<string name="changelogs">Changelogs</string> <string name="changelogs">Changelogs</string>
<string name="install">Install</string> <string name="install">Install</string>
<string name="version_installed">Installed:</string> <string name="installation_aborted">Operation failed because user aborted installation</string>
<string name="installation_blocked">Operation failed because user blocked installation</string>
<string name="installation_conflict">Operation failed because app conflicts with already installed app</string>
<string name="installation_failed">Operation failed because it just failed idk</string>
<string name="installation_invalid">Operation failed because apk files are invalid</string>
<string name="installation_storage">Operation failed because there was an error with storage. Hold up how is that even possible?</string>
<string name="button_installed">Installed</string> <string name="button_installed">Installed</string>
<string name="version_installed">Installed:</string>
<string name="latest">Latest:</string> <string name="latest">Latest:</string>
<string name="loading">Loading…</string> <string name="loading">Loading…</string>
<string name="network_error">Network connection unavailable</string> <string name="network_error">Network connection unavailable</string>
@ -26,6 +32,9 @@
<string name="useful_links">Useful Links</string> <string name="useful_links">Useful Links</string>
<string name="vanced_medias">Vanced on Social Media</string> <string name="vanced_medias">Vanced on Social Media</string>
<string name="website_text">The official website of Vanced</string> <string name="website_text">The official website of Vanced</string>
<string name="signature_disabled">Disabled</string>
<string name="signature_enabled">Enabled</string>
<string name="signature_not_checked">Signature not checked</string>
<string name="support_us">Support us by downloading Brave</string> <string name="support_us">Support us by downloading Brave</string>
<!-- Settings --> <!-- Settings -->