mirror of
https://github.com/YTVanced/VancedManager
synced 2024-11-23 19:55:11 +00:00
removed signature checker, cleanup and bug fixes
This commit is contained in:
parent
7117352591
commit
1815d7b157
25 changed files with 122 additions and 446 deletions
|
@ -58,8 +58,6 @@
|
||||||
|
|
||||||
<service android:name=".core.installer.SplitInstallerService" />
|
<service android:name=".core.installer.SplitInstallerService" />
|
||||||
<service android:name=".core.installer.RootSplitInstallerService" />
|
<service android:name=".core.installer.RootSplitInstallerService" />
|
||||||
<service android:name=".core.installer.StubInstaller" />
|
|
||||||
<service android:name=".core.installer.RootAppUninstaller" />
|
|
||||||
<service android:name=".core.installer.AppUninstallerService" />
|
<service android:name=".core.installer.AppUninstallerService" />
|
||||||
<service android:name=".core.installer.AppInstallerService" />
|
<service android:name=".core.installer.AppInstallerService" />
|
||||||
<service android:name=".core.downloader.VancedDownloadService" />
|
<service android:name=".core.downloader.VancedDownloadService" />
|
||||||
|
|
Binary file not shown.
|
@ -3,11 +3,16 @@ package com.vanced.manager.core
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
import android.widget.Toast
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
|
import com.dezlum.codelabs.getjson.GetJson
|
||||||
import com.vanced.manager.ui.dialogs.DialogContainer.showSecurityDialog
|
import com.vanced.manager.ui.dialogs.DialogContainer.showSecurityDialog
|
||||||
import com.vanced.manager.ui.dialogs.DialogContainer.statementFalse
|
import com.vanced.manager.ui.dialogs.DialogContainer.statementFalse
|
||||||
|
import com.vanced.manager.ui.fragments.UpdateCheckFragment
|
||||||
|
import com.vanced.manager.utils.InternetTools
|
||||||
|
import com.vanced.manager.R
|
||||||
|
import com.vanced.manager.ui.dialogs.DialogContainer.showRootDialog
|
||||||
|
|
||||||
// This activity will NOT be used in manifest
|
// This activity will NOT be used in manifest
|
||||||
// since MainActivity will extend it
|
// since MainActivity will extend it
|
||||||
|
@ -17,19 +22,21 @@ open class Main: AppCompatActivity() {
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
|
checkUpdates()
|
||||||
|
|
||||||
val prefs = PreferenceManager.getDefaultSharedPreferences(this)
|
val prefs = PreferenceManager.getDefaultSharedPreferences(this)
|
||||||
val firstStart = prefs.getBoolean("firstStart", true)
|
val firstStart = prefs.getBoolean("firstStart", true)
|
||||||
val isUpgrading = prefs.getBoolean("isUpgrading", false)
|
val isUpgrading = prefs.getBoolean("isUpgrading", false)
|
||||||
|
val variant = prefs.getString("vanced_variant", "nonroot")
|
||||||
|
val shouldShowRootDialog = prefs.getBoolean("show_root_dialog", true)
|
||||||
|
|
||||||
//Easter Egg
|
|
||||||
val falseStatement = prefs.getBoolean("statement", true)
|
val falseStatement = prefs.getBoolean("statement", true)
|
||||||
|
|
||||||
when {
|
when {
|
||||||
firstStart -> showSecurityDialog(this)
|
firstStart -> showSecurityDialog(this)
|
||||||
!falseStatement -> statementFalse(this)
|
!falseStatement -> statementFalse(this)
|
||||||
isUpgrading -> {
|
isUpgrading -> prefs.edit().putBoolean("isUpgrading", false).apply()
|
||||||
prefs.edit().putBoolean("isUpgrading", false).apply()
|
variant == "root" && shouldShowRootDialog -> showRootDialog(this)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -38,12 +45,16 @@ open class Main: AppCompatActivity() {
|
||||||
getSharedPreferences("installPrefs", Context.MODE_PRIVATE).edit().putBoolean("isInstalling", false).apply()
|
getSharedPreferences("installPrefs", Context.MODE_PRIVATE).edit().putBoolean("isInstalling", false).apply()
|
||||||
getSharedPreferences("installPrefs", Context.MODE_PRIVATE).edit().putBoolean("isVancedDownloading", false).apply()
|
getSharedPreferences("installPrefs", Context.MODE_PRIVATE).edit().putBoolean("isVancedDownloading", false).apply()
|
||||||
getSharedPreferences("installPrefs", Context.MODE_PRIVATE).edit().putBoolean("isMicrogDownloading", false).apply()
|
getSharedPreferences("installPrefs", Context.MODE_PRIVATE).edit().putBoolean("isMicrogDownloading", false).apply()
|
||||||
try {
|
|
||||||
cacheDir.deleteRecursively()
|
|
||||||
} catch (e: Exception) {
|
|
||||||
Log.d("VMCache", "Unable to delete cacheDir")
|
|
||||||
}
|
|
||||||
super.onPause()
|
super.onPause()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun checkUpdates() {
|
||||||
|
val checkPrefs = PreferenceManager.getDefaultSharedPreferences(this).getBoolean("auto_check_update", false)
|
||||||
|
if (checkPrefs) {
|
||||||
|
if (GetJson().isConnected(this) && InternetTools.isUpdateAvailable()) {
|
||||||
|
UpdateCheckFragment().show(supportFragmentManager, "Update")
|
||||||
|
} else Toast.makeText(this, getString(R.string.update_notfound), Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -13,14 +13,14 @@ import com.downloader.OnStartOrResumeListener
|
||||||
import com.downloader.PRDownloader
|
import com.downloader.PRDownloader
|
||||||
import com.vanced.manager.ui.fragments.HomeFragment
|
import com.vanced.manager.ui.fragments.HomeFragment
|
||||||
import com.vanced.manager.utils.InternetTools.getFileNameFromUrl
|
import com.vanced.manager.utils.InternetTools.getFileNameFromUrl
|
||||||
import java.lang.IllegalStateException
|
import java.util.concurrent.ExecutionException
|
||||||
|
|
||||||
class MicrogDownloadService: Service() {
|
class MicrogDownloadService: Service() {
|
||||||
|
|
||||||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
||||||
try {
|
try {
|
||||||
downloadMicrog()
|
downloadMicrog()
|
||||||
} catch (e: IllegalStateException) {
|
} catch (e: ExecutionException) {
|
||||||
Toast.makeText(this, "Unable to download Vanced", Toast.LENGTH_SHORT).show()
|
Toast.makeText(this, "Unable to download Vanced", Toast.LENGTH_SHORT).show()
|
||||||
}
|
}
|
||||||
stopSelf()
|
stopSelf()
|
||||||
|
|
|
@ -15,14 +15,14 @@ import com.vanced.manager.core.installer.RootSplitInstallerService
|
||||||
import com.vanced.manager.core.installer.SplitInstaller
|
import com.vanced.manager.core.installer.SplitInstaller
|
||||||
import com.vanced.manager.ui.fragments.HomeFragment
|
import com.vanced.manager.ui.fragments.HomeFragment
|
||||||
import com.vanced.manager.utils.InternetTools.getFileNameFromUrl
|
import com.vanced.manager.utils.InternetTools.getFileNameFromUrl
|
||||||
import java.lang.IllegalStateException
|
import java.util.concurrent.ExecutionException
|
||||||
|
|
||||||
class VancedDownloadService: Service() {
|
class VancedDownloadService: Service() {
|
||||||
|
|
||||||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
||||||
try {
|
try {
|
||||||
downloadSplits()
|
downloadSplits()
|
||||||
} catch (e: IllegalStateException) {
|
} catch (e: ExecutionException) {
|
||||||
Toast.makeText(this, "Unable to download Vanced", Toast.LENGTH_SHORT).show()
|
Toast.makeText(this, "Unable to download Vanced", Toast.LENGTH_SHORT).show()
|
||||||
}
|
}
|
||||||
stopSelf()
|
stopSelf()
|
||||||
|
|
|
@ -2,12 +2,10 @@ package com.vanced.manager.core.fragments
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.pm.PackageManager
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.*
|
import android.widget.*
|
||||||
import androidx.fragment.app.viewModels
|
|
||||||
import androidx.navigation.findNavController
|
import androidx.navigation.findNavController
|
||||||
import androidx.preference.PreferenceManager.getDefaultSharedPreferences
|
import androidx.preference.PreferenceManager.getDefaultSharedPreferences
|
||||||
import com.google.android.material.button.MaterialButton
|
import com.google.android.material.button.MaterialButton
|
||||||
|
@ -16,10 +14,8 @@ import com.vanced.manager.R
|
||||||
import com.vanced.manager.core.base.BaseFragment
|
import com.vanced.manager.core.base.BaseFragment
|
||||||
import com.vanced.manager.core.downloader.MicrogDownloadService
|
import com.vanced.manager.core.downloader.MicrogDownloadService
|
||||||
import com.vanced.manager.core.downloader.VancedDownloadService
|
import com.vanced.manager.core.downloader.VancedDownloadService
|
||||||
import com.vanced.manager.core.installer.StubInstaller
|
|
||||||
import com.vanced.manager.ui.MainActivity
|
import com.vanced.manager.ui.MainActivity
|
||||||
import com.vanced.manager.ui.dialogs.DialogContainer.secondMiuiDialog
|
import com.vanced.manager.ui.dialogs.DialogContainer.secondMiuiDialog
|
||||||
import com.vanced.manager.ui.viewmodels.HomeViewModel
|
|
||||||
import com.vanced.manager.utils.MiuiHelper
|
import com.vanced.manager.utils.MiuiHelper
|
||||||
import com.vanced.manager.utils.PackageHelper.uninstallApk
|
import com.vanced.manager.utils.PackageHelper.uninstallApk
|
||||||
|
|
||||||
|
@ -30,17 +26,13 @@ open class Home : BaseFragment(), View.OnClickListener {
|
||||||
|
|
||||||
val microginstallbtn = view.findViewById<MaterialButton>(R.id.microg_installbtn)
|
val microginstallbtn = view.findViewById<MaterialButton>(R.id.microg_installbtn)
|
||||||
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 microguninstallbtn = view.findViewById<ImageView>(R.id.microg_uninstallbtn)
|
val microguninstallbtn = view.findViewById<ImageView>(R.id.microg_uninstallbtn)
|
||||||
val vanceduninstallbtn = view.findViewById<ImageView>(R.id.vanced_uninstallbtn)
|
val vanceduninstallbtn = view.findViewById<ImageView>(R.id.vanced_uninstallbtn)
|
||||||
val rootswitch = view.findViewById<MaterialButton>(R.id.root_switch)
|
val rootswitch = view.findViewById<MaterialButton>(R.id.root_switch)
|
||||||
val nonrootswitch = view.findViewById<MaterialButton>(R.id.nonroot_switch)
|
val nonrootswitch = view.findViewById<MaterialButton>(R.id.nonroot_switch)
|
||||||
|
|
||||||
//val variantPref = getDefaultSharedPreferences(activity).getString("vanced_variant", "nonroot")
|
|
||||||
|
|
||||||
vancedinstallbtn.setOnClickListener(this)
|
vancedinstallbtn.setOnClickListener(this)
|
||||||
microginstallbtn.setOnClickListener(this)
|
microginstallbtn.setOnClickListener(this)
|
||||||
signaturebtn.setOnClickListener(this)
|
|
||||||
microguninstallbtn.setOnClickListener(this)
|
microguninstallbtn.setOnClickListener(this)
|
||||||
vanceduninstallbtn.setOnClickListener(this)
|
vanceduninstallbtn.setOnClickListener(this)
|
||||||
rootswitch.setOnClickListener(this)
|
rootswitch.setOnClickListener(this)
|
||||||
|
@ -62,8 +54,7 @@ open class Home : BaseFragment(), View.OnClickListener {
|
||||||
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)
|
val variant = getDefaultSharedPreferences(activity).getString("vanced_variant", "nonroot")
|
||||||
.getString("vanced_variant", "nonroot")
|
|
||||||
val vancedPkgName =
|
val vancedPkgName =
|
||||||
if (variant == "root") {
|
if (variant == "root") {
|
||||||
"com.google.android.youtube"
|
"com.google.android.youtube"
|
||||||
|
@ -113,37 +104,6 @@ open class Home : BaseFragment(), View.OnClickListener {
|
||||||
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 -> {
|
|
||||||
val viewModel: HomeViewModel by viewModels()
|
|
||||||
val loadCircle = view?.findViewById<ProgressBar>(R.id.signature_loading)
|
|
||||||
loadCircle?.visibility = View.VISIBLE
|
|
||||||
//val intent = Intent(activity, StubInstaller::class.java)
|
|
||||||
//activity?.startService(intent)
|
|
||||||
val checkSig = activity?.packageManager?.checkSignatures("com.vanced.manager", "com.android.systemui")
|
|
||||||
if (checkSig == PackageManager.SIGNATURE_MATCH) {
|
|
||||||
activity?.runOnUiThread {
|
|
||||||
viewModel.signatureStatusTxt.value = getString(R.string.signature_disabled)
|
|
||||||
viewModel.vancedInstallButtonTxt.value = viewModel.compareInt(
|
|
||||||
viewModel.vancedVersionCode,
|
|
||||||
viewModel.vancedInstalledVersionCode,
|
|
||||||
viewModel.getApplication()
|
|
||||||
)
|
|
||||||
viewModel.vancedInstallButtonIcon.value = viewModel.compareIntDrawable(
|
|
||||||
viewModel.vancedVersionCode,
|
|
||||||
viewModel.vancedInstalledVersionCode,
|
|
||||||
viewModel.getApplication()
|
|
||||||
)
|
|
||||||
activity?.recreate()
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
activity?.runOnUiThread {
|
|
||||||
viewModel.signatureStatusTxt.value = getString(R.string.signature_enabled)
|
|
||||||
viewModel.vancedInstallButtonTxt.value = getString(R.string.signature_disable)
|
|
||||||
viewModel.vancedInstallButtonIcon.value = null
|
|
||||||
activity?.recreate()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
R.id.microg_uninstallbtn -> activity?.let { uninstallApk("com.mgoogle.android.gms", it) }
|
R.id.microg_uninstallbtn -> activity?.let { uninstallApk("com.mgoogle.android.gms", it) }
|
||||||
R.id.vanced_uninstallbtn -> activity?.let { uninstallApk(vancedPkgName, it) }
|
R.id.vanced_uninstallbtn -> activity?.let { uninstallApk(vancedPkgName, it) }
|
||||||
R.id.nonroot_switch -> writeToVariantPref("nonroot", R.anim.slide_in_left, R.anim.slide_out_right)
|
R.id.nonroot_switch -> writeToVariantPref("nonroot", R.anim.slide_in_left, R.anim.slide_out_right)
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
package com.vanced.manager.core.installer
|
|
||||||
|
|
||||||
import android.app.Service
|
|
||||||
import android.content.Intent
|
|
||||||
import android.os.Bundle
|
|
||||||
import android.os.IBinder
|
|
||||||
import android.util.Log
|
|
||||||
import com.topjohnwu.superuser.Shell
|
|
||||||
|
|
||||||
class RootAppUninstaller: Service() {
|
|
||||||
|
|
||||||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
|
||||||
val serviceData: Bundle? = intent?.extras
|
|
||||||
val data = serviceData?.get("Data")
|
|
||||||
val uninstall = Shell.su("pm uninstall $data").exec()
|
|
||||||
if (uninstall.isSuccess) {
|
|
||||||
Log.d("VMUninstall", "Succesfully uninstalled $data")
|
|
||||||
} else {
|
|
||||||
Log.d("VMUninstall", "Failed to uninstall $data")
|
|
||||||
}
|
|
||||||
stopSelf()
|
|
||||||
return START_NOT_STICKY
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onBind(intent: Intent?): IBinder? {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,57 +0,0 @@
|
||||||
package com.vanced.manager.core.installer
|
|
||||||
|
|
||||||
import android.app.Service
|
|
||||||
import android.content.Intent
|
|
||||||
import android.os.IBinder
|
|
||||||
import android.util.Log
|
|
||||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
|
||||||
import com.topjohnwu.superuser.Shell
|
|
||||||
import com.vanced.manager.ui.fragments.HomeFragment
|
|
||||||
import java.io.*
|
|
||||||
|
|
||||||
class StubInstaller: Service() {
|
|
||||||
|
|
||||||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
|
||||||
val apkFile = File(filesDir, "stub.apk")
|
|
||||||
if (!apkFile.exists()) {
|
|
||||||
copyStub()
|
|
||||||
}
|
|
||||||
Log.d("VMpath", apkFile.absolutePath)
|
|
||||||
Log.d("AppLog", "Installing stub...")
|
|
||||||
val installResult = Shell.su("pm install ${apkFile.absolutePath}").exec()
|
|
||||||
Log.d("AppLog", "succeeded installing?${installResult.isSuccess}")
|
|
||||||
if (installResult.isSuccess) {
|
|
||||||
val mIntent = Intent(HomeFragment.SIGNATURE_DISABLED)
|
|
||||||
mIntent.action = HomeFragment.SIGNATURE_DISABLED
|
|
||||||
LocalBroadcastManager.getInstance(this).sendBroadcast(mIntent)
|
|
||||||
} else {
|
|
||||||
val mIntent = Intent(HomeFragment.SIGNATURE_ENABLED)
|
|
||||||
mIntent.action = HomeFragment.SIGNATURE_ENABLED
|
|
||||||
LocalBroadcastManager.getInstance(this).sendBroadcast(mIntent)
|
|
||||||
}
|
|
||||||
|
|
||||||
return START_STICKY
|
|
||||||
}
|
|
||||||
|
|
||||||
@Throws(IOException::class)
|
|
||||||
private fun copyStub() {
|
|
||||||
try {
|
|
||||||
val stubName = "stub.apk"
|
|
||||||
val inAsset = assets.open(stubName)
|
|
||||||
val outFile = File(filesDir, stubName)
|
|
||||||
val outAsset: OutputStream = FileOutputStream(outFile)
|
|
||||||
val buffer = ByteArray(1024)
|
|
||||||
var read: Int
|
|
||||||
while (inAsset.read(buffer).also { read = it } != -1) {
|
|
||||||
outAsset.write(buffer, 0, read)
|
|
||||||
}
|
|
||||||
} catch (e: IOException) {
|
|
||||||
Log.d("VMStub", "Failed to copy stub")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onBind(intent: Intent?): IBinder? {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -85,8 +85,6 @@ class MainActivity : Main() {
|
||||||
|
|
||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
val navHost = findNavController(R.id.bottom_nav_host)
|
val navHost = findNavController(R.id.bottom_nav_host)
|
||||||
val prefs = PreferenceManager.getDefaultSharedPreferences(this)
|
|
||||||
val devSettings = prefs.getBoolean("devSettings", false)
|
|
||||||
when (item.itemId) {
|
when (item.itemId) {
|
||||||
android.R.id.home -> {
|
android.R.id.home -> {
|
||||||
onBackPressed()
|
onBackPressed()
|
||||||
|
@ -100,17 +98,9 @@ class MainActivity : Main() {
|
||||||
navHost.navigate(R.id.action_settingsFragment)
|
navHost.navigate(R.id.action_settingsFragment)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
R.id.secret_settings -> {
|
|
||||||
navHost.navigate(R.id.toSecretSettingsFragment)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
R.id.dev_settings -> {
|
R.id.dev_settings -> {
|
||||||
return if (devSettings) {
|
navHost.navigate(R.id.toDevSettingsFragment)
|
||||||
navHost.navigate(R.id.toDevSettingsFragment)
|
return true
|
||||||
true
|
|
||||||
} else
|
|
||||||
false
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else -> super.onOptionsItemSelected(item)
|
else -> super.onOptionsItemSelected(item)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,33 +0,0 @@
|
||||||
package com.vanced.manager.ui.core
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.util.AttributeSet
|
|
||||||
import com.google.android.material.card.MaterialCardView
|
|
||||||
|
|
||||||
open class SlidingCardView: MaterialCardView {
|
|
||||||
|
|
||||||
constructor(context: Context?) : super(context)
|
|
||||||
constructor(context: Context?, attrs: AttributeSet?) : super(
|
|
||||||
context,
|
|
||||||
attrs
|
|
||||||
)
|
|
||||||
|
|
||||||
var yFraction: Float
|
|
||||||
get() {
|
|
||||||
val height = height
|
|
||||||
return if (height != 0)
|
|
||||||
y / height
|
|
||||||
else
|
|
||||||
y
|
|
||||||
}
|
|
||||||
set(yFraction) {
|
|
||||||
val height = height
|
|
||||||
val newHeight =
|
|
||||||
if (height > 0)
|
|
||||||
yFraction * height
|
|
||||||
else
|
|
||||||
(-9999).toFloat()
|
|
||||||
y = newHeight
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -26,7 +26,7 @@ open class SlidingConstraintLayout : ConstraintLayout {
|
||||||
if (width > 0)
|
if (width > 0)
|
||||||
xFraction * width
|
xFraction * width
|
||||||
else
|
else
|
||||||
(-9999).toFloat()
|
(1).toFloat()
|
||||||
x = newWidth
|
x = newWidth
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -26,7 +26,7 @@ open class SlidingLinearLayout: LinearLayout {
|
||||||
if (height > 0)
|
if (height > 0)
|
||||||
yFraction * height
|
yFraction * height
|
||||||
else
|
else
|
||||||
(-9999).toFloat()
|
(1).toFloat()
|
||||||
y = newHeight
|
y = newHeight
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ open class SlidingNestedScrollView : NestedScrollView {
|
||||||
if (width > 0)
|
if (width > 0)
|
||||||
xFraction * width
|
xFraction * width
|
||||||
else
|
else
|
||||||
(-9999).toFloat()
|
(1).toFloat()
|
||||||
x = newWidth
|
x = newWidth
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
package com.vanced.manager.ui.dialogs
|
package com.vanced.manager.ui.dialogs
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
import android.content.ComponentName
|
import android.content.ComponentName
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
@ -39,11 +40,23 @@ object DialogContainer {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun showRootDialog(activity: Activity) {
|
||||||
|
AlertDialog.Builder(activity)
|
||||||
|
.setTitle(activity.getString(R.string.miui_two_title))
|
||||||
|
.setMessage(activity.getString(R.string.miui_two))
|
||||||
|
.setPositiveButton(activity.getString(R.string.button_dismiss)) { dialog, _ ->
|
||||||
|
dialog.dismiss()
|
||||||
|
PreferenceManager.getDefaultSharedPreferences(activity).edit().putBoolean("show_root_dialog", false).apply()
|
||||||
|
}
|
||||||
|
.create()
|
||||||
|
.show()
|
||||||
|
}
|
||||||
|
|
||||||
fun secondMiuiDialog(context: Context) {
|
fun secondMiuiDialog(context: Context) {
|
||||||
AlertDialog.Builder(context)
|
AlertDialog.Builder(context)
|
||||||
.setTitle(context.getString(R.string.miui_two_title))
|
.setTitle(context.getString(R.string.miui_two_title))
|
||||||
.setMessage(context.getString(R.string.miui_two))
|
.setMessage(context.getString(R.string.miui_two))
|
||||||
.setPositiveButton("Fine") { dialog, _ -> dialog.dismiss() }
|
.setPositiveButton(context.getString(R.string.button_fine)) { dialog, _ -> dialog.dismiss() }
|
||||||
.create()
|
.create()
|
||||||
.show()
|
.show()
|
||||||
}
|
}
|
||||||
|
@ -105,7 +118,7 @@ object DialogContainer {
|
||||||
activity.finish()
|
activity.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.setNegativeButton("Cancel") { dialog, _ ->
|
.setNegativeButton(activity.getString(R.string.close)) { dialog, _ ->
|
||||||
run {
|
run {
|
||||||
dialog.dismiss()
|
dialog.dismiss()
|
||||||
activity.restartActivity()
|
activity.restartActivity()
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package com.vanced.manager.ui.fragments
|
package com.vanced.manager.ui.fragments
|
||||||
|
|
||||||
import android.animation.LayoutTransition
|
|
||||||
import android.content.BroadcastReceiver
|
import android.content.BroadcastReceiver
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
@ -25,7 +24,6 @@ import com.vanced.manager.R
|
||||||
import com.vanced.manager.adapter.SectionPageAdapter
|
import com.vanced.manager.adapter.SectionPageAdapter
|
||||||
import com.vanced.manager.adapter.SectionPageRootAdapter
|
import com.vanced.manager.adapter.SectionPageRootAdapter
|
||||||
import com.vanced.manager.core.fragments.Home
|
import com.vanced.manager.core.fragments.Home
|
||||||
import com.vanced.manager.core.installer.RootAppUninstaller
|
|
||||||
import com.vanced.manager.databinding.FragmentHomeBinding
|
import com.vanced.manager.databinding.FragmentHomeBinding
|
||||||
import com.vanced.manager.ui.viewmodels.HomeViewModel
|
import com.vanced.manager.ui.viewmodels.HomeViewModel
|
||||||
import com.vanced.manager.utils.PackageHelper.installApp
|
import com.vanced.manager.utils.PackageHelper.installApp
|
||||||
|
@ -54,16 +52,9 @@ class HomeFragment : Home() {
|
||||||
val variantPref = getDefaultSharedPreferences(activity).getString("vanced_variant", "nonroot")
|
val variantPref = getDefaultSharedPreferences(activity).getString("vanced_variant", "nonroot")
|
||||||
registerReceivers()
|
registerReceivers()
|
||||||
|
|
||||||
if (variantPref == "root") {
|
if (variantPref == "root")
|
||||||
attachRootChangelog()
|
attachRootChangelog()
|
||||||
if (viewModel.signatureStatusTxt.value != getString(R.string.signature_disabled)) {
|
else {
|
||||||
when (viewModel.signatureStatusTxt.value) {
|
|
||||||
getString(R.string.unavailable) -> disableVancedButton()
|
|
||||||
getString(R.string.signature_enabled) -> disableVancedButton()
|
|
||||||
else -> throw NotImplementedError("Error handling status")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
attachNonrootChangelog()
|
attachNonrootChangelog()
|
||||||
if (!viewModel.microgInstalled) {
|
if (!viewModel.microgInstalled) {
|
||||||
disableVancedButton()
|
disableVancedButton()
|
||||||
|
@ -71,7 +62,7 @@ class HomeFragment : Home() {
|
||||||
}
|
}
|
||||||
|
|
||||||
view.findViewById<ImageButton>(R.id.changelog_button).setOnClickListener {
|
view.findViewById<ImageButton>(R.id.changelog_button).setOnClickListener {
|
||||||
cardExpandCollapse()
|
cardExpandCollapse()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,23 +90,7 @@ class HomeFragment : Home() {
|
||||||
|
|
||||||
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 viewModel: HomeViewModel by viewModels()
|
|
||||||
when (intent.action) {
|
when (intent.action) {
|
||||||
SIGNATURE_DISABLED -> {
|
|
||||||
activity?.runOnUiThread {
|
|
||||||
viewModel.signatureStatusTxt.value = getString(R.string.signature_disabled)
|
|
||||||
}
|
|
||||||
val mIntent = Intent(activity, RootAppUninstaller::class.java)
|
|
||||||
mIntent.putExtra("Data", "com.vanced.stub")
|
|
||||||
activity?.startService(mIntent)
|
|
||||||
activity?.recreate()
|
|
||||||
}
|
|
||||||
SIGNATURE_ENABLED -> {
|
|
||||||
activity?.runOnUiThread {
|
|
||||||
viewModel.signatureStatusTxt.value = getString(R.string.signature_enabled)
|
|
||||||
}
|
|
||||||
activity?.recreate()
|
|
||||||
}
|
|
||||||
MICROG_DOWNLOADING -> {
|
MICROG_DOWNLOADING -> {
|
||||||
val progress = intent.getIntExtra("microgProgress", 0)
|
val progress = intent.getIntExtra("microgProgress", 0)
|
||||||
val progressbar = view?.findViewById<ProgressBar>(R.id.microg_progress)
|
val progressbar = view?.findViewById<ProgressBar>(R.id.microg_progress)
|
||||||
|
@ -139,8 +114,7 @@ class HomeFragment : Home() {
|
||||||
MICROG_DOWNLOADED -> {
|
MICROG_DOWNLOADED -> {
|
||||||
view?.findViewById<TextView>(R.id.microg_downloading)?.visibility = View.GONE
|
view?.findViewById<TextView>(R.id.microg_downloading)?.visibility = View.GONE
|
||||||
view?.findViewById<ProgressBar>(R.id.microg_progress)?.visibility = View.GONE
|
view?.findViewById<ProgressBar>(R.id.microg_progress)?.visibility = View.GONE
|
||||||
view?.findViewById<ProgressBar>(R.id.microg_installing)?.visibility =
|
view?.findViewById<ProgressBar>(R.id.microg_installing)?.visibility = View.VISIBLE
|
||||||
View.VISIBLE
|
|
||||||
activity?.let { installApp(it, it.filesDir.path + "/microg.apk", "com.mgoogle.android.gms") }
|
activity?.let { installApp(it, it.filesDir.path + "/microg.apk", "com.mgoogle.android.gms") }
|
||||||
}
|
}
|
||||||
VANCED_DOWNLOADED -> {
|
VANCED_DOWNLOADED -> {
|
||||||
|
@ -159,8 +133,6 @@ class HomeFragment : Home() {
|
||||||
|
|
||||||
private fun registerReceivers() {
|
private fun registerReceivers() {
|
||||||
val intentFilter = IntentFilter()
|
val intentFilter = IntentFilter()
|
||||||
intentFilter.addAction(SIGNATURE_DISABLED)
|
|
||||||
intentFilter.addAction(SIGNATURE_ENABLED)
|
|
||||||
intentFilter.addAction(VANCED_DOWNLOADING)
|
intentFilter.addAction(VANCED_DOWNLOADING)
|
||||||
intentFilter.addAction(MICROG_DOWNLOADING)
|
intentFilter.addAction(MICROG_DOWNLOADING)
|
||||||
intentFilter.addAction(VANCED_DOWNLOADED)
|
intentFilter.addAction(VANCED_DOWNLOADED)
|
||||||
|
@ -214,8 +186,6 @@ class HomeFragment : Home() {
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val SIGNATURE_DISABLED = "Signature verification disabled"
|
|
||||||
const val SIGNATURE_ENABLED = "Signature verification enabled"
|
|
||||||
const val VANCED_DOWNLOADING = "Vanced downloading"
|
const val VANCED_DOWNLOADING = "Vanced downloading"
|
||||||
const val MICROG_DOWNLOADING = "MicroG downloading"
|
const val MICROG_DOWNLOADING = "MicroG downloading"
|
||||||
const val VANCED_DOWNLOADED = "Vanced downloaded"
|
const val VANCED_DOWNLOADED = "Vanced downloaded"
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
package com.vanced.manager.ui.fragments
|
|
||||||
|
|
||||||
import android.os.Bundle
|
|
||||||
import android.view.Menu
|
|
||||||
import android.view.MenuInflater
|
|
||||||
import androidx.preference.PreferenceFragmentCompat
|
|
||||||
import androidx.preference.PreferenceManager
|
|
||||||
import com.vanced.manager.R
|
|
||||||
|
|
||||||
class SecretSettingsFragment : PreferenceFragmentCompat() {
|
|
||||||
|
|
||||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
|
||||||
setPreferencesFromResource(R.xml.secret_settings, rootKey)
|
|
||||||
activity?.title = "Secret Settings"
|
|
||||||
setHasOptionsMenu(true)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
|
||||||
inflater.inflate(R.menu.dev_settings_menu, menu)
|
|
||||||
super .onCreateOptionsMenu(menu, inflater)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -7,6 +7,7 @@ import android.view.MenuInflater
|
||||||
import androidx.preference.ListPreference
|
import androidx.preference.ListPreference
|
||||||
import androidx.preference.Preference
|
import androidx.preference.Preference
|
||||||
import androidx.preference.PreferenceFragmentCompat
|
import androidx.preference.PreferenceFragmentCompat
|
||||||
|
import androidx.preference.PreferenceManager
|
||||||
import com.vanced.manager.R
|
import com.vanced.manager.R
|
||||||
import com.vanced.manager.ui.MainActivity
|
import com.vanced.manager.ui.MainActivity
|
||||||
|
|
||||||
|
@ -19,6 +20,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
||||||
activity?.title = getString(R.string.title_settings)
|
activity?.title = getString(R.string.title_settings)
|
||||||
setHasOptionsMenu(true)
|
setHasOptionsMenu(true)
|
||||||
|
|
||||||
|
/*
|
||||||
val updateCheck: Preference? = findPreference("update_check")
|
val updateCheck: Preference? = findPreference("update_check")
|
||||||
updateCheck?.setOnPreferenceClickListener {
|
updateCheck?.setOnPreferenceClickListener {
|
||||||
val fm = childFragmentManager.beginTransaction()
|
val fm = childFragmentManager.beginTransaction()
|
||||||
|
@ -27,6 +29,8 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
val themeSwitch: ListPreference? = findPreference("theme_mode")
|
val themeSwitch: ListPreference? = findPreference("theme_mode")
|
||||||
themeSwitch?.summary =
|
themeSwitch?.summary =
|
||||||
preferenceScreen.sharedPreferences.getString("theme_mode", "Follow System")
|
preferenceScreen.sharedPreferences.getString("theme_mode", "Follow System")
|
||||||
|
@ -42,6 +46,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
val chosenPrefs: Preference? = findPreference("vanced_chosen_modes")
|
val chosenPrefs: Preference? = findPreference("vanced_chosen_modes")
|
||||||
chosenPrefs?.setOnPreferenceClickListener {
|
chosenPrefs?.setOnPreferenceClickListener {
|
||||||
val fm = childFragmentManager.beginTransaction()
|
val fm = childFragmentManager.beginTransaction()
|
||||||
|
@ -50,10 +55,15 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||||
inflater.inflate(R.menu.secret_settings_menu, menu)
|
val devSettings = PreferenceManager.getDefaultSharedPreferences(activity).getBoolean("devSettings", false)
|
||||||
|
if (devSettings) {
|
||||||
|
inflater.inflate(R.menu.dev_settings_menu, menu)
|
||||||
|
}
|
||||||
super .onCreateOptionsMenu(menu, inflater)
|
super .onCreateOptionsMenu(menu, inflater)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,9 +17,11 @@ import androidx.preference.PreferenceManager
|
||||||
import com.downloader.Error
|
import com.downloader.Error
|
||||||
import com.downloader.OnDownloadListener
|
import com.downloader.OnDownloadListener
|
||||||
import com.downloader.PRDownloader
|
import com.downloader.PRDownloader
|
||||||
|
import com.google.android.material.button.MaterialButton
|
||||||
import com.vanced.manager.BuildConfig
|
import com.vanced.manager.BuildConfig
|
||||||
|
|
||||||
import com.vanced.manager.R
|
import com.vanced.manager.R
|
||||||
|
import com.vanced.manager.utils.InternetTools.isUpdateAvailable
|
||||||
import com.vanced.manager.utils.PackageHelper.installApp
|
import com.vanced.manager.utils.PackageHelper.installApp
|
||||||
|
|
||||||
class UpdateCheckFragment : DialogFragment() {
|
class UpdateCheckFragment : DialogFragment() {
|
||||||
|
@ -36,47 +38,40 @@ class UpdateCheckFragment : DialogFragment() {
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
checkUpdates()
|
||||||
val closebtn = view.findViewById<Button>(R.id.update_center_dismiss)
|
view.findViewById<Button>(R.id.update_center_dismiss).setOnClickListener { dismiss() }
|
||||||
val updatebtn = view.findViewById<Button>(R.id.update_center_update)
|
view.findViewById<MaterialButton>(R.id.update_center_recheck).setOnClickListener{ checkUpdates() }
|
||||||
val recheckbtn = view.findViewById<Button>(R.id.update_center_recheck)
|
|
||||||
val checkingTxt = view.findViewById<TextView>(R.id.update_center_checking)
|
|
||||||
val loadBar = view.findViewById<ProgressBar>(R.id.update_center_progressbar)
|
|
||||||
|
|
||||||
closebtn.setOnClickListener { dismiss() }
|
|
||||||
|
|
||||||
if (GetJson().isConnected(requireContext())) {
|
|
||||||
val checkUrl = GetJson().AsJSONObject("https://vanced.app/api/v1/manager.json")
|
|
||||||
val remoteVersion = checkUrl.get("versionCode").asInt
|
|
||||||
|
|
||||||
if (remoteVersion > BuildConfig.VERSION_CODE) {
|
|
||||||
|
|
||||||
recheckbtn.visibility = View.GONE
|
|
||||||
checkingTxt.text = getString(R.string.update_found)
|
|
||||||
|
|
||||||
updatebtn.setOnClickListener {
|
|
||||||
upgradeManager(loadBar)
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
checkingTxt.text = getString(R.string.update_notfound)
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
checkingTxt.text = getString(R.string.network_error)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun upgradeManager(loadBar: ProgressBar) {
|
private fun checkUpdates() {
|
||||||
|
val updatebtn = view?.findViewById<Button>(R.id.update_center_update)
|
||||||
|
val checkingTxt = view?.findViewById<TextView>(R.id.update_center_checking)
|
||||||
|
if (GetJson().isConnected(requireContext())) {
|
||||||
|
|
||||||
|
if (isUpdateAvailable()) {
|
||||||
|
view?.findViewById<Button>(R.id.update_center_recheck)?.visibility = View.GONE
|
||||||
|
checkingTxt?.text = getString(R.string.update_found)
|
||||||
|
|
||||||
|
updatebtn?.setOnClickListener {
|
||||||
|
upgradeManager()
|
||||||
|
}
|
||||||
|
} else checkingTxt?.text = getString(R.string.update_notfound)
|
||||||
|
|
||||||
|
} else {
|
||||||
|
checkingTxt?.text = getString(R.string.network_error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun upgradeManager() {
|
||||||
val dwnldUrl = "https://github.com/VancedManager/releases/latest/download/manager.apk"
|
val dwnldUrl = "https://github.com/VancedManager/releases/latest/download/manager.apk"
|
||||||
|
val loadBar = view?.findViewById<ProgressBar>(R.id.update_center_progressbar)
|
||||||
|
|
||||||
PRDownloader.download(dwnldUrl, activity?.filesDir?.path, "manager.apk")
|
PRDownloader.download(dwnldUrl, activity?.filesDir?.path, "manager.apk")
|
||||||
.build()
|
.build()
|
||||||
.setOnProgressListener { progress ->
|
.setOnProgressListener { progress ->
|
||||||
val mProgress = progress.currentBytes * 100 / progress.totalBytes
|
val mProgress = progress.currentBytes * 100 / progress.totalBytes
|
||||||
loadBar.visibility = View.VISIBLE
|
loadBar?.visibility = View.VISIBLE
|
||||||
loadBar.progress = mProgress.toInt()
|
loadBar?.progress = mProgress.toInt()
|
||||||
|
|
||||||
}
|
}
|
||||||
.start(object : OnDownloadListener{
|
.start(object : OnDownloadListener{
|
||||||
|
|
|
@ -58,9 +58,6 @@ class HomeViewModel(application: Application): AndroidViewModel(application) {
|
||||||
|
|
||||||
val nonrootModeSelected: Boolean = variant == "nonroot"
|
val nonrootModeSelected: Boolean = variant == "nonroot"
|
||||||
|
|
||||||
private val signatureString = application.getString(R.string.unavailable)
|
|
||||||
val signatureStatusTxt: MutableLiveData<String> = MutableLiveData()
|
|
||||||
|
|
||||||
fun openMicrogSettings() {
|
fun openMicrogSettings() {
|
||||||
try {
|
try {
|
||||||
val intent = Intent()
|
val intent = Intent()
|
||||||
|
@ -111,7 +108,7 @@ class HomeViewModel(application: Application): AndroidViewModel(application) {
|
||||||
} else 0
|
} else 0
|
||||||
}
|
}
|
||||||
|
|
||||||
fun compareInt(int1: Int, int2: Int, application: Application): String {
|
private fun compareInt(int1: Int, int2: Int, application: Application): String {
|
||||||
return if (connected)
|
return if (connected)
|
||||||
when {
|
when {
|
||||||
int1 > int2 -> application.getString(R.string.update)
|
int1 > int2 -> application.getString(R.string.update)
|
||||||
|
@ -120,7 +117,7 @@ class HomeViewModel(application: Application): AndroidViewModel(application) {
|
||||||
} else application.getString(R.string.install)
|
} else application.getString(R.string.install)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun compareIntDrawable(int1: Int, int2: Int, application: Application): Drawable? {
|
private fun compareIntDrawable(int1: Int, int2: Int, application: Application): Drawable? {
|
||||||
return if (connected)
|
return if (connected)
|
||||||
when {
|
when {
|
||||||
int1 > int2 -> application.getDrawable(R.drawable.ic_cloud_upload_black_24dp)
|
int1 > int2 -> application.getDrawable(R.drawable.ic_cloud_upload_black_24dp)
|
||||||
|
@ -131,7 +128,6 @@ class HomeViewModel(application: Application): AndroidViewModel(application) {
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
signatureStatusTxt.value = signatureString
|
|
||||||
vancedVersion.value = displayJsonString("vanced.json","version", application)
|
vancedVersion.value = displayJsonString("vanced.json","version", application)
|
||||||
microgVersion.value = displayJsonString("microg.json","version", application)
|
microgVersion.value = displayJsonString("microg.json","version", application)
|
||||||
vancedInstalledVersion.value = getPkgInfo(vancedInstalled, vancedPkgName, application)
|
vancedInstalledVersion.value = getPkgInfo(vancedInstalled, vancedPkgName, application)
|
||||||
|
@ -142,12 +138,9 @@ class HomeViewModel(application: Application): AndroidViewModel(application) {
|
||||||
compareIntDrawable(vancedInstalledVersionCode, vancedVersionCode, application)
|
compareIntDrawable(vancedInstalledVersionCode, vancedVersionCode, application)
|
||||||
else
|
else
|
||||||
null
|
null
|
||||||
} else {
|
} else
|
||||||
if (signatureStatusTxt.value == application.getString(R.string.signature_disabled))
|
compareIntDrawable(vancedInstalledVersionCode, vancedVersionCode, application)
|
||||||
compareIntDrawable(vancedInstalledVersionCode, vancedVersionCode, application)
|
|
||||||
else
|
|
||||||
null
|
|
||||||
}
|
|
||||||
vancedInstallButtonTxt.value =
|
vancedInstallButtonTxt.value =
|
||||||
if (variant == "nonroot") {
|
if (variant == "nonroot") {
|
||||||
if (microgInstalled) {
|
if (microgInstalled) {
|
||||||
|
@ -155,15 +148,8 @@ class HomeViewModel(application: Application): AndroidViewModel(application) {
|
||||||
} else {
|
} else {
|
||||||
application.getString(R.string.no_microg)
|
application.getString(R.string.no_microg)
|
||||||
}
|
}
|
||||||
} else {
|
} else
|
||||||
when (signatureStatusTxt.value) {
|
compareInt(vancedInstalledVersionCode, vancedVersionCode, application)
|
||||||
application.getString(R.string.unavailable) -> application.getString(R.string.signature_not_checked)
|
|
||||||
application.getString(R.string.signature_enabled) -> application.getString(R.string.signature_disable)
|
|
||||||
application.getString(R.string.signature_disabled) -> compareInt(vancedInstalledVersionCode, vancedVersionCode, application)
|
|
||||||
else -> throw NotImplementedError("Error handling status")
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,11 @@ package com.vanced.manager.utils
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
|
import android.view.View
|
||||||
import androidx.browser.customtabs.CustomTabsIntent
|
import androidx.browser.customtabs.CustomTabsIntent
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import com.dezlum.codelabs.getjson.GetJson
|
import com.dezlum.codelabs.getjson.GetJson
|
||||||
|
import com.vanced.manager.BuildConfig
|
||||||
import com.vanced.manager.R
|
import com.vanced.manager.R
|
||||||
import java.lang.IllegalStateException
|
import java.lang.IllegalStateException
|
||||||
|
|
||||||
|
@ -41,5 +43,12 @@ object InternetTools {
|
||||||
} else 0
|
} else 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun isUpdateAvailable(): Boolean {
|
||||||
|
val checkUrl = GetJson().AsJSONObject("https://vanced.app/api/v1/manager.json")
|
||||||
|
val remoteVersion = checkUrl.get("versionCode").asInt
|
||||||
|
|
||||||
|
return remoteVersion > BuildConfig.VERSION_CODE
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,8 +29,8 @@
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginEnd="@dimen/stdp"
|
android:layout_marginEnd="25dp"
|
||||||
android:layout_marginStart="@dimen/stdp"
|
android:layout_marginStart="25dp"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
|
@ -99,17 +99,6 @@
|
||||||
android:visibility="@{viewModel.nonrootModeSelected ? View.VISIBLE : View.GONE}"
|
android:visibility="@{viewModel.nonrootModeSelected ? View.VISIBLE : View.GONE}"
|
||||||
bind:viewModel="@{viewModel}"/>
|
bind:viewModel="@{viewModel}"/>
|
||||||
|
|
||||||
<include
|
|
||||||
android:id="@+id/home_signature_wrapper"
|
|
||||||
layout="@layout/include_signature_verification"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginStart="@dimen/stdp"
|
|
||||||
android:layout_marginTop="@dimen/stdp"
|
|
||||||
android:layout_marginEnd="@dimen/stdp"
|
|
||||||
android:visibility="@{viewModel.nonrootModeSelected ? View.GONE : View.VISIBLE}"
|
|
||||||
bind:viewModel="@{viewModel}"/>
|
|
||||||
|
|
||||||
<include
|
<include
|
||||||
layout="@layout/include_changelogs"
|
layout="@layout/include_changelogs"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
|
@ -1,85 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<layout>
|
|
||||||
|
|
||||||
<data>
|
|
||||||
|
|
||||||
<variable
|
|
||||||
name="viewModel"
|
|
||||||
type="com.vanced.manager.ui.viewmodels.HomeViewModel" />
|
|
||||||
|
|
||||||
</data>
|
|
||||||
|
|
||||||
<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.ConstraintLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:animateLayoutChanges="true">
|
|
||||||
|
|
||||||
<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/TextAppTitle"
|
|
||||||
android:id="@+id/signature_title"
|
|
||||||
android:text="@string/signature_verification"
|
|
||||||
app:layout_constraintStart_toEndOf="@id/signature_icon"
|
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
|
||||||
app:layout_constraintBottom_toTopOf="@id/signature_barrier"/>
|
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
|
||||||
style="@style/ButtonStyle"
|
|
||||||
android:id="@+id/signature_button"
|
|
||||||
android:text="@string/check"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
|
|
||||||
<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"/>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/signature_status_layout"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/signature_barrier">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
style="@style/AppVer"
|
|
||||||
android:text="@string/signature_status" />
|
|
||||||
|
|
||||||
<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>
|
|
|
@ -9,10 +9,13 @@
|
||||||
<string name="title_home">Home</string>
|
<string name="title_home">Home</string>
|
||||||
<string name="title_install">Install</string>
|
<string name="title_install">Install</string>
|
||||||
<string name="title_settings">Settings</string>
|
<string name="title_settings">Settings</string>
|
||||||
|
<string name="button_dismiss">Dismiss</string>
|
||||||
|
<string name="button_fine">Fine</string>
|
||||||
|
|
||||||
<!-- Home Page -->
|
<!-- Home Page -->
|
||||||
<string name="changelogs">Changelogs</string>
|
<string name="changelogs">Changelogs</string>
|
||||||
<string name="check">Check</string>
|
<string name="check">Check</string>
|
||||||
|
<string name="disable_signature">Root mode detected! In order for manager to install Vanced correctly, please make sure you disabled signature verification.</string>
|
||||||
<string name="failed_uninstall">Failed to uninstall package: </string>
|
<string name="failed_uninstall">Failed to uninstall package: </string>
|
||||||
<string name="install">Install</string>
|
<string name="install">Install</string>
|
||||||
<string name="installation_aborted">Operation failed because user aborted installation</string>
|
<string name="installation_aborted">Operation failed because user aborted installation</string>
|
||||||
|
@ -21,6 +24,7 @@
|
||||||
<string name="installation_failed">Operation failed because it just failed idk</string>
|
<string name="installation_failed">Operation failed because it just failed idk</string>
|
||||||
<string name="installation_incompatible">Operation failed because app is incompatible with your device</string>
|
<string name="installation_incompatible">Operation failed because app is incompatible with your device</string>
|
||||||
<string name="installation_invalid">Operation failed because apk files are invalid</string>
|
<string name="installation_invalid">Operation failed because apk files are invalid</string>
|
||||||
|
<string name="installation_signature">Unexpected error occurred while installing Vanced. Did you disable signature verification?</string>
|
||||||
<string name="installation_storage">Operation failed because there was an error with storage. Hold up how is that even possible?</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="version_installed">Installed:</string>
|
||||||
|
@ -33,12 +37,6 @@
|
||||||
<string name="update">Update</string>
|
<string name="update">Update</string>
|
||||||
<string name="useful_links">Useful Links</string>
|
<string name="useful_links">Useful Links</string>
|
||||||
<string name="website_text">Website</string>
|
<string name="website_text">Website</string>
|
||||||
<string name="signature_disable">Disable Sig.</string>
|
|
||||||
<string name="signature_disabled">Disabled</string>
|
|
||||||
<string name="signature_enabled">Enabled</string>
|
|
||||||
<string name="signature_status">status:</string>
|
|
||||||
<string name="signature_verification">Sig. Verification</string>
|
|
||||||
<string name="signature_not_checked">Check signature</string>
|
|
||||||
<string name="support_us">Support us!</string>
|
<string name="support_us">Support us!</string>
|
||||||
|
|
||||||
<!-- Settings -->
|
<!-- Settings -->
|
||||||
|
@ -52,6 +50,7 @@
|
||||||
<string name="check_updates">Check for updates</string>
|
<string name="check_updates">Check for updates</string>
|
||||||
<string name="category_interface">Interface</string>
|
<string name="category_interface">Interface</string>
|
||||||
<string name="category_manager">Manager</string>
|
<string name="category_manager">Manager</string>
|
||||||
|
<string name="chosen_install_values">Chosen Installation values</string>
|
||||||
<string name="theme">Theme</string>
|
<string name="theme">Theme</string>
|
||||||
<string name="theme_follow">Follow System</string>
|
<string name="theme_follow">Follow System</string>
|
||||||
<string name="theme_dark">Dark Theme</string>
|
<string name="theme_dark">Dark Theme</string>
|
||||||
|
|
|
@ -11,7 +11,13 @@
|
||||||
<Preference
|
<Preference
|
||||||
android:key="update_check"
|
android:key="update_check"
|
||||||
android:title="@string/check_updates"
|
android:title="@string/check_updates"
|
||||||
android:icon="@drawable/ic_cloud_upload_black_24dp"/>
|
android:icon="@drawable/ic_cloud_upload_black_24dp"
|
||||||
|
android:fragment="com.vanced.manager.ui.fragments.UpdateCheckFragment"/>
|
||||||
|
|
||||||
|
<SwitchPreference
|
||||||
|
android:title="Auto-Check updates"
|
||||||
|
android:key="auto_check_update"
|
||||||
|
android:summary="Check manager updates on app startup" />
|
||||||
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:title="@string/push_notifications"
|
android:title="@string/push_notifications"
|
||||||
|
@ -51,8 +57,9 @@
|
||||||
app:iconSpaceReserved="false">
|
app:iconSpaceReserved="false">
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:title="Chosen Installation values"
|
android:title="@string/chosen_install_values"
|
||||||
android:key="vanced_chosen_modes" />
|
android:key="vanced_chosen_modes"
|
||||||
|
android:fragment="com.vanced.manager.ui.fragments.ChosenPreferenceDialogFragment"/>
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
|
|
@ -1,33 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<PreferenceScreen
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android" >
|
|
||||||
|
|
||||||
<SwitchPreference
|
|
||||||
android:key="ss_switch"
|
|
||||||
android:title="Useless Switch"
|
|
||||||
android:summaryOff="This switch does nothing"
|
|
||||||
android:summaryOn="You're just wasting your time"/>
|
|
||||||
|
|
||||||
<CheckBoxPreference
|
|
||||||
android:key="ss_checkbox"
|
|
||||||
android:title="Useless Checkbox"
|
|
||||||
android:summaryOff="This doesn't do anything either"
|
|
||||||
android:summaryOn="Dude just stop" />
|
|
||||||
|
|
||||||
<DropDownPreference
|
|
||||||
android:key="ss_syke"
|
|
||||||
android:title="Ok this one is quite useful"
|
|
||||||
android:entries="@array/syke"
|
|
||||||
android:entryValues="@array/syke" />
|
|
||||||
|
|
||||||
<SeekBarPreference
|
|
||||||
android:key="ss_speed"
|
|
||||||
android:title="Vanced Manager Speed Controller" />
|
|
||||||
|
|
||||||
<ListPreference
|
|
||||||
android:key="ss_yomama"
|
|
||||||
android:title="This one is cool"
|
|
||||||
android:entries="@array/yomama"
|
|
||||||
android:entryValues="@array/yomama" />
|
|
||||||
|
|
||||||
</PreferenceScreen>
|
|
Loading…
Reference in a new issue