0
0
Fork 0
mirror of https://github.com/YTVanced/VancedManager synced 2024-11-10 12:55:06 +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)
# 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
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
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
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 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)
Isn't this lovely and beautiful?
## Credits
### Vanced Manager developers:
### Vanced Manager developers
- MrDodojo (API)
- Hope (API Integration into the app)
- moosd (Patcher)
- X1nto (UX, (maybe I will make installer too idk))
### The Vanced Team:
### The Vanced Team
- xfileFIN
![xfileFIN](https://i.imgur.com/hLdzTVq.png)
- KevinX8

View file

@ -70,17 +70,17 @@
<output-test url="file://$MODULE_DIR$/build/intermediates/javac/debugUnitTest/classes" />
<exclude-output />
<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/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/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/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/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/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/res/rs/androidTest/debug" type="java-test-resource" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/kapt/debugUnitTest" isTestSource="true" generated="true" />
@ -135,10 +135,10 @@
<library name="Gradle: kaptGeneratedClasses">
<CLASSES>
<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/release" />
<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>
<JAVADOC />
<SOURCES />

View file

@ -11,8 +11,8 @@ android {
applicationId "com.vanced.manager"
minSdkVersion 21
targetSdkVersion 29
versionCode 6
versionName "1.2.0 beta"
versionCode 7
versionName "1.4.0 beta"
vectorDrawables.useSupportLibrary = true
}
@ -43,7 +43,6 @@ android {
// To inline the bytecode built with JVM target 1.8 into
// bytecode that is being built with JVM target 1.6. (e.g. navArgs)
compileOptions {
sourceCompatibility 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.vanced.manager.core.installer.RootSplitInstallerService
import com.vanced.manager.ui.MainActivity
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable
import io.reactivex.rxkotlin.subscribeBy
import io.reactivex.schedulers.Schedulers
import zlc.season.rxdownload4.delete
import zlc.season.rxdownload4.download
import zlc.season.rxdownload4.file
import zlc.season.rxdownload4.task.Task
import zlc.season.rxdownload4.utils.getFileNameFromUrl
import java.io.File
@SuppressLint("SetTextI18n")
open class BaseFragment : Fragment() {
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) {
val builder = CustomTabsIntent.Builder()
@ -51,32 +50,44 @@ open class BaseFragment : Fragment() {
}
}
@SuppressLint("SdCardPath")
fun isRootVancedInstalled(): Boolean {
val file = File("/data/data/com.google.android.youtube/shared_prefs/", "youtube_vanced.xml")
return activity?.packageManager?.let {
isPackageInstalled("com.google.android.youtube",
it
)
}!! && file.exists()
fun uninstallApp(pkgName: String) {
try {
val uri = Uri.parse("package:$pkgName")
val uninstall = Intent(Intent.ACTION_DELETE, uri)
uninstall.flags = Intent.FLAG_ACTIVITY_NEW_TASK
uninstall.putExtra(Intent.EXTRA_RETURN_RESULT, true)
startActivityForResult(uninstall, APP_UNINSTALL)
} 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)
prefs?.edit()?.putBoolean("isVancedDownloading", true)?.apply()
val variant = PreferenceManager.getDefaultSharedPreferences(activity).getString("vanced_variant", "nonroot")
val lang = prefs?.getString("lang", "en")
val theme = prefs?.getString("theme", "dark")
val arch =
when {
Build.SUPPORTED_ABIS.contains("x86") -> "x86"
Build.SUPPORTED_ABIS.contains("arm64-v8a") -> "arm64_v8a"
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 {
Task(
url = url,
saveName = getFileNameFromUrl(url),
savePath = it
Task(
url = url,
saveName = getFileNameFromUrl(url),
savePath = it
)
}
@ -84,95 +95,32 @@ open class BaseFragment : Fragment() {
task.delete()
disposable = task.download()
.observeOn(AndroidSchedulers.mainThread())
.observeOn(Schedulers.single())
.subscribeBy(
onNext = { progress ->
val filename = getFileNameFromUrl(url)
loadBar.visibility = View.VISIBLE
dlText.visibility = View.VISIBLE
dlText.text = "Downloading $filename..."
loadBar.progress = progress.percent().toInt()
activity?.runOnUiThread {
val filename = getFileNameFromUrl(url)
loadBar.visibility = View.VISIBLE
dlText.visibility = View.VISIBLE
dlText.text = "Downloading $filename..."
loadBar.progress = progress.percent().toInt()
}
},
onComplete = {
downloadTheme(loadBar, dlText, loadCircle)
},
onError = { throwable ->
Toast.makeText(activity, throwable.toString(), Toast.LENGTH_SHORT).show()
}
)
}
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()
} else {
launchInstaller()
when (type) {
"arch" -> downloadSplits("theme", loadBar, dlText, loadCircle)
"theme" -> downloadSplits("lang", loadBar, dlText, loadCircle)
"lang" -> {
if (lang == "en" || type == "enlang") {
activity?.runOnUiThread { loadCircle.visibility = View.VISIBLE }
if (variant == "root") {
launchRootInstaller()
} else {
launchInstaller()
}
} else {
downloadSplits("enlang", loadBar, dlText, loadCircle)
}
}
}
},
@ -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() {
val activity = (activity as MainActivity)
activity.installSplitApk()
@ -234,11 +139,11 @@ open class BaseFragment : Fragment() {
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)
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 task = activity?.filesDir?.path?.let {
Task(
@ -253,19 +158,22 @@ open class BaseFragment : Fragment() {
disposable = task
.download()
.observeOn(AndroidSchedulers.mainThread())
.observeOn(Schedulers.newThread())
.subscribeBy(
onNext = { progress ->
val filename = getFileNameFromUrl(dwnldUrl)
loadBar.visibility = View.VISIBLE
dlText.visibility = View.VISIBLE
dlText.text = "Downloading $filename..."
loadBar.progress = progress.percent().toInt()
activity?.runOnUiThread {
val filename = getFileNameFromUrl(dwnldUrl)
loadBar?.visibility = View.VISIBLE
dlText?.visibility = View.VISIBLE
dlText?.text = "Downloading $filename..."
loadBar?.progress = progress.percent().toInt()
}
},
onComplete = {
loadBar.visibility = View.GONE
dlText.visibility = View.GONE
activity?.runOnUiThread {
loadBar?.visibility = View.GONE
dlText?.visibility = View.GONE
}
prefs?.edit()?.putBoolean("isMicrogDownloading", false)?.apply()
val pn = activity?.packageName
val apk = task.file()
@ -278,7 +186,8 @@ open class BaseFragment : Fragment() {
intent.setDataAndType(uri, "application/vnd.android.package-archive")
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
startActivity(intent)
intent.putExtra(Intent.EXTRA_RETURN_RESULT, true)
startActivityForResult(intent, MICROG_INSTALL)
},
onError = { throwable ->
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.widget.*
import androidx.navigation.findNavController
import androidx.preference.PreferenceManager
import androidx.preference.PreferenceManager.getDefaultSharedPreferences
import com.google.android.material.button.MaterialButton
import com.vanced.manager.R
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.utils.MiuiHelper
open class Home : BaseFragment() {
open class Home : BaseFragment(), View.OnClickListener {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
@ -24,66 +24,9 @@ open class Home : BaseFragment() {
val vancedinstallbtn = view.findViewById<MaterialButton>(R.id.vanced_installbtn)
val signaturebtn = view.findViewById<MaterialButton>(R.id.signature_button)
val microgProgress = view.findViewById<ProgressBar>(R.id.microg_progress)
val prefs = activity?.getSharedPreferences("installPrefs", Context.MODE_PRIVATE)
val isVancedDownloading: Boolean? = prefs?.getBoolean("isVancedDownloading", false)
val isMicrogDownloading: Boolean? = prefs?.getBoolean("isMicrogDownloading", false)
vancedinstallbtn.setOnClickListener {
if (!isVancedDownloading!!) {
val mainActivity = (activity as MainActivity)
if (PreferenceManager.getDefaultSharedPreferences(activity).getString("vanced_variant", "Nonroot") == "Root") {
if (MiuiHelper.isMiui()) {
mainActivity.secondMiuiDialog()
} else
mainActivity.rootModeDetected()
} else {
if (MiuiHelper.isMiui()) {
mainActivity.secondMiuiDialog()
}
}
try {
activity?.cacheDir?.deleteRecursively()
} catch (e: Exception) {
Log.d("VMCache", "Unable to delete cacheDir")
}
if (prefs.getBoolean("valuesModified", false)) {
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)
downloadArch(loadBar!!, dlText!!, loadCircle!!)
prefs.edit().putBoolean("isInstalling", false).apply()
} else
view.findNavController().navigate(R.id.toInstallThemeFragment)
} else {
Toast.makeText(activity, "Please wait until installation finishes", Toast.LENGTH_SHORT).show()
}
}
microginstallbtn.setOnClickListener {
if (!isMicrogDownloading!!) {
val dlText = view.findViewById<TextView>(R.id.microg_downloading)
try {
installApk(
"https://x1nto.github.io/VancedFiles/microg.json",
microgProgress,
dlText
)
} catch (e: Exception) {
Toast.makeText(activity, "Unable to start installation", Toast.LENGTH_SHORT).show()
}
} else {
Toast.makeText(activity, "Please wait until installation finishes", Toast.LENGTH_SHORT).show()
}
}
signaturebtn.setOnClickListener {
val loadCircle = view.findViewById<ProgressBar>(R.id.signature_loading)
loadCircle.visibility = View.VISIBLE
val mIntent = Intent(activity, StubInstaller::class.java)
activity?.startService(mIntent)
}
vancedinstallbtn.setOnClickListener(this)
microginstallbtn.setOnClickListener(this)
signaturebtn.setOnClickListener(this)
}
@ -95,9 +38,81 @@ open class Home : BaseFragment() {
val prefs = activity?.getSharedPreferences("installPrefs", Context.MODE_PRIVATE)
val isInstalling = prefs?.getBoolean("isInstalling", false)
if (isInstalling!!) {
downloadArch(loadBar!!, dlText!!, loadCircle!!)
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 isVancedDownloading: Boolean? = prefs?.getBoolean("isVancedDownloading", 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"
}
when (v?.id) {
R.id.vanced_installbtn -> {
if (!isVancedDownloading!!) {
val mainActivity = (activity as MainActivity)
if (variant == "Root") {
if (MiuiHelper.isMiui()) {
mainActivity.secondMiuiDialog()
} else
mainActivity.rootModeDetected()
} else {
if (MiuiHelper.isMiui()) {
mainActivity.secondMiuiDialog()
}
}
try {
activity?.cacheDir?.deleteRecursively()
} catch (e: Exception) {
Log.d("VMCache", "Unable to delete cacheDir")
}
if (prefs.getBoolean("valuesModified", false)) {
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)
downloadSplits("arch", loadBar!!, dlText!!, loadCircle!!)
prefs.edit().putBoolean("isInstalling", false).apply()
} else
view?.findNavController()?.navigate(R.id.toInstallThemeFragment)
} else {
Toast.makeText(activity, "Please wait until installation finishes", Toast.LENGTH_SHORT).show()
}
}
R.id.microg_installbtn -> {
if (!isMicrogDownloading!!) {
val dlText = view?.findViewById<TextView>(R.id.microg_downloading)
try {
installMicrog(
microgProgress,
dlText
)
} catch (e: Exception) {
Toast.makeText(activity, "Unable to start installation", Toast.LENGTH_SHORT).show()
}
} else {
Toast.makeText(activity, "Please wait until installation finishes", Toast.LENGTH_SHORT).show()
}
}
R.id.signature_button -> {
val loadCircle = view?.findViewById<ProgressBar>(R.id.signature_loading)
loadCircle?.visibility = View.VISIBLE
val mIntent = Intent(activity, StubInstaller::class.java)
activity?.startService(mIntent)
}
R.id.microg_uninstallbtn -> uninstallApp("com.mgoogle.android.gms")
R.id.vanced_uninstallbtn -> uninstallApp(vancedPkgName)
}
}
}

View file

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

View file

@ -1,6 +1,7 @@
package com.vanced.manager.ui.fragments
import android.animation.ObjectAnimator
import android.app.Activity.*
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
@ -9,6 +10,7 @@ import android.content.res.ColorStateList
import android.graphics.Color
import android.os.Build
import android.os.Bundle
import android.util.Log
import android.view.*
import android.widget.ProgressBar
import android.widget.TextView
@ -35,7 +37,6 @@ import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable
import io.reactivex.schedulers.Schedulers
@Suppress("DEPRECATION")
class HomeFragment : Home() {
private lateinit var sectionPageAdapter: SectionPageAdapter
@ -62,10 +63,14 @@ class HomeFragment : Home() {
binding.viewModel = viewModel
val variantPref = getDefaultSharedPreferences(activity).getString("vanced_variant", "nonroot")
val signatureStatus = getDefaultSharedPreferences(activity).getString("signature_status", "unavailable")
registerReceivers()
if (variantPref == "root") {
attachRootChangelog()
if (signatureStatus != "disabled") {
disableVancedButton(getString(R.string.signature_not_checked))
}
} else
attachNonrootChangelog()
@ -78,10 +83,10 @@ class HomeFragment : Home() {
private fun initNetworkFun() {
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 vancedStatus =
if (variant == "root") {
if (variant == "Root") {
pm?.let { isPackageInstalled("com.google.android.youtube", it) }
} else {
pm?.let { isPackageInstalled("com.vanced.android.youtube", it) }
@ -110,6 +115,7 @@ class HomeFragment : Home() {
microginstallbtn?.visibility = View.VISIBLE
if (microgStatus!!) {
@Suppress("DEPRECATION")
val microgVerCode =
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P)
pm.getPackageInfo("com.mgoogle.android.gms", 0).longVersionCode.and(0xFFFFFFFF).toInt()
@ -131,22 +137,20 @@ class HomeFragment : Home() {
}
}
} else {
vancedinstallbtn?.isEnabled = false
vancedinstallbtn?.backgroundTintList = ColorStateList.valueOf(Color.DKGRAY)
vancedinstallbtn?.setTextColor(ColorStateList.valueOf(Color.GRAY))
vancedinstallbtn?.text = activity?.getString(R.string.no_microg)
vancedinstallbtn?.icon = null
activity?.getString(R.string.no_microg)?.let {
disableVancedButton(it)
}
}
}
if (vancedStatus!!) {
val vanPkgName =
if (variant == "root") {
if (variant == "root")
"com.google.android.youtube"
} else {
"com.vanced.android.youtube"
}
else
"com.vanced.android.youtube"
@Suppress("DEPRECATION")
val vancedVerCode =
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
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() {
override fun onReceive(context: Context, intent: Intent) {
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)
when (intent.action) {
SIGNATURE_DISABLED -> {
loadCircle?.visibility = View.GONE
statusTxt?.text = "Disabled"
statusTxt?.setTextColor(resources.getColor(R.color.Green))
vancedinstallbtn?.visibility = View.VISIBLE
statusTxt?.text = getString(R.string.signature_disabled)
statusTxt?.setTextColor(getColor(R.color.Green))
val mIntent = Intent(activity, RootAppUninstaller::class.java)
mIntent.putExtra("Data", "com.vanced.stub")
activity?.startService(mIntent)
}
SIGNATURE_ENABLED -> {
statusTxt?.text = "Enabled"
statusTxt?.setTextColor(resources.getColor(R.color.Red))
statusTxt?.text = getString(R.string.signature_enabled)
statusTxt?.setTextColor(getColor(R.color.Red))
loadCircle?.visibility = View.GONE
}
}
@ -288,6 +317,23 @@ class HomeFragment : Home() {
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 {
const val SIGNATURE_DISABLED = "Signature verification disabled"
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 checkUrl = GetJson().AsJSONObject("https://vanced.app/api/v1/manager.json")
val changelog = checkUrl.get("changelog").asString
if (GetJson().isConnected(activity))
if (GetJson().isConnected(activity)) {
val checkUrl = GetJson().AsJSONObject("https://vanced.app/api/v1/manager.json")
val changelog = checkUrl.get("changelog").asString
changelogTxt.text = changelog
}
}
}

View file

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

View file

@ -28,14 +28,14 @@ class SettingsFragment : PreferenceFragmentCompat() {
val themeSwitch: ListPreference? = findPreference("theme_mode")
themeSwitch?.summary = preferenceScreen.sharedPreferences.getString("theme_mode", "Light")
themeSwitch?.setOnPreferenceChangeListener { _, _ ->
activity?.recreate()
restartMain()
true
}
val accentSwitch: ListPreference? = findPreference("accent_color")
accentSwitch?.summary = preferenceScreen.sharedPreferences.getString("accent_color", "Blue")
accentSwitch?.setOnPreferenceChangeListener { _, _ ->
activity?.recreate()
restartMain()
true
}
@ -49,8 +49,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
}
}
}
startActivity(Intent(activity, MainActivity::class.java))
activity?.finish()
restartMain()
true
}
@ -69,4 +68,9 @@ class SettingsFragment : PreferenceFragmentCompat() {
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 checkUrl = GetJson().AsJSONObject("https://vanced.app/api/v1/changelog/15_05_54.json")
val changelog = checkUrl.get("message").asString
if (GetJson().isConnected(activity))
if (GetJson().isConnected(activity)) {
val checkUrl = GetJson().AsJSONObject("https://vanced.app/api/v1/changelog/15_05_54.json")
val changelog = checkUrl.get("message").asString
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 =
if (getDefaultSharedPreferences(application).getString("vanced_variant", "nonroot") == "root") {
@ -34,12 +34,13 @@ open class HomeViewModel(application: Application): AndroidViewModel(application
} else {
"com.vanced.android.youtube"
}
private val signaturePref = getDefaultSharedPreferences(application).getString("signature_status", "unavailable")
val isMicrogInstalled: Boolean = isPackageInstalled("com.mgoogle.android.gms", application.packageManager)
val isVancedInstalled: Boolean = isPackageInstalled(vancedPkgName, application.packageManager)
val microgInstalled: Boolean = isPackageInstalled("com.mgoogle.android.gms", application.packageManager)
val vancedInstalled: Boolean = isPackageInstalled(vancedPkgName, application.packageManager)
val vancedInstalledVersion: String =
if (isVancedInstalled) {
if (vancedInstalled) {
application.packageManager.getPackageInfo(vancedPkgName, 0).versionName
} else {
application.getString(R.string.unavailable)
@ -47,27 +48,34 @@ open class HomeViewModel(application: Application): AndroidViewModel(application
val microgInstalledVersion: String =
if (isMicrogInstalled) {
if (microgInstalled) {
application.packageManager.getPackageInfo("com.mgoogle.android.gms", 0).versionName
} else {
application.getString(R.string.unavailable)
}
val vancedVersion: String =
if (isConnected)
if (connected)
GetJson().AsJSONObject("https://vanced.app/api/v1/vanced.json")
.get("version").asString
else
application.getString(R.string.unavailable)
val microgVersion: String =
if (isConnected)
if (connected)
GetJson().AsJSONObject("https://vanced.app/api/v1/microg.json")
.get("version").asString
else
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() {
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) {
val color: Int =
when (Url) {

View file

@ -64,7 +64,8 @@
android:layout_marginStart="@dimen/stdp"
android:layout_marginTop="@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
layout="@layout/include_changelogs"

View file

@ -1,72 +1,83 @@
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.card.MaterialCardView
style="@style/MaterialCard"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<layout>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<data>
<ImageView
android:id="@+id/signature_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/ic_security_black_24dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@id/signature_barrier"/>
<variable
name="viewModel"
type="com.vanced.manager.ui.viewmodels.HomeViewModel" />
<TextView
style="@style/TextAppTitle"
android:id="@+id/signature_title"
android:text="Signature Verification"
app:layout_constraintStart_toEndOf="@id/signature_icon"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@id/signature_barrier"/>
</data>
<com.google.android.material.button.MaterialButton
style="@style/ButtonStyle"
android:id="@+id/signature_button"
android:text="Check"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.card.MaterialCardView
style="@style/MaterialCard"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<androidx.constraintlayout.widget.Barrier
android:id="@+id/signature_barrier"
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:constraint_referenced_ids="signature_button"
app:barrierDirection="bottom"/>
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/signature_status_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/signature_barrier">
<ImageView
android:id="@+id/signature_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/ic_security_black_24dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@id/signature_barrier"/>
<TextView
style="@style/AppVer"
android:text="status:" />
style="@style/TextAppTitle"
android:id="@+id/signature_title"
android:text="Signature Verification"
app:layout_constraintStart_toEndOf="@id/signature_icon"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@id/signature_barrier"/>
<TextView
style="@style/AppVer.Bold"
android:id="@+id/signature_status"
android:text="@string/unavailable"/>
<com.google.android.material.button.MaterialButton
style="@style/ButtonStyle"
android:id="@+id/signature_button"
android:text="Check"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</LinearLayout>
<androidx.constraintlayout.widget.Barrier
android:id="@+id/signature_barrier"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:constraint_referenced_ids="signature_button"
app:barrierDirection="bottom"/>
<ProgressBar
android:id="@+id/signature_loading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
app:layout_constraintTop_toBottomOf="@id/signature_status_layout"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
tools:visibility="visible" />
<LinearLayout
android:id="@+id/signature_status_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/signature_barrier">
</androidx.constraintlayout.widget.ConstraintLayout>
<TextView
style="@style/AppVer"
android:text="status:" />
</com.google.android.material.card.MaterialCardView>
<TextView
style="@style/AppVer.Bold"
android:id="@+id/signature_status"
android:text="@{viewModel.signatureStatusTxt}"/>
</LinearLayout>
<ProgressBar
android:id="@+id/signature_loading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
app:layout_constraintTop_toBottomOf="@id/signature_status_layout"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
tools:visibility="visible" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
</layout>

View file

@ -15,8 +15,14 @@
<!-- Home Page -->
<string name="changelogs">Changelogs</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="version_installed">Installed:</string>
<string name="latest">Latest:</string>
<string name="loading">Loading…</string>
<string name="network_error">Network connection unavailable</string>
@ -26,6 +32,9 @@
<string name="useful_links">Useful Links</string>
<string name="vanced_medias">Vanced on Social Media</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>
<!-- Settings -->