mirror of
https://github.com/YTVanced/VancedManager
synced 2024-11-15 23:35:06 +00:00
small optimizations
This commit is contained in:
parent
555c5e4c5c
commit
542b937a04
10 changed files with 35 additions and 116 deletions
|
@ -14,6 +14,7 @@ import com.vanced.manager.R
|
||||||
import com.vanced.manager.core.App
|
import com.vanced.manager.core.App
|
||||||
import com.vanced.manager.ui.viewmodels.HomeViewModel.Companion.vancedProgress
|
import com.vanced.manager.ui.viewmodels.HomeViewModel.Companion.vancedProgress
|
||||||
import com.vanced.manager.utils.AppUtils.mutableInstall
|
import com.vanced.manager.utils.AppUtils.mutableInstall
|
||||||
|
import com.vanced.manager.utils.AppUtils.vancedRootPkg
|
||||||
import com.vanced.manager.utils.InternetTools
|
import com.vanced.manager.utils.InternetTools
|
||||||
import com.vanced.manager.utils.InternetTools.baseUrl
|
import com.vanced.manager.utils.InternetTools.baseUrl
|
||||||
import com.vanced.manager.utils.InternetTools.getFileNameFromUrl
|
import com.vanced.manager.utils.InternetTools.getFileNameFromUrl
|
||||||
|
@ -46,7 +47,6 @@ object VancedDownloader {
|
||||||
private var count: Int = 0
|
private var count: Int = 0
|
||||||
private var hashUrl = ""
|
private var hashUrl = ""
|
||||||
|
|
||||||
private const val yPkg = "com.google.android.youtube"
|
|
||||||
private var vancedVersionCode = 0
|
private var vancedVersionCode = 0
|
||||||
private var vancedVersion: String? = null
|
private var vancedVersion: String? = null
|
||||||
|
|
||||||
|
@ -150,7 +150,7 @@ object VancedDownloader {
|
||||||
|
|
||||||
private fun downloadStockCheck(context: Context) :Boolean {
|
private fun downloadStockCheck(context: Context) :Boolean {
|
||||||
return try {
|
return try {
|
||||||
getPkgVerCode(yPkg,context.packageManager) != vancedVersionCode
|
getPkgVerCode(vancedRootPkg, context.packageManager) != vancedVersionCode
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ package com.vanced.manager.core.firebase
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import com.google.firebase.messaging.FirebaseMessagingService
|
import com.google.firebase.messaging.FirebaseMessagingService
|
||||||
|
|
||||||
class CloudMessaging: FirebaseMessagingService() {
|
class CloudMessaging : FirebaseMessagingService() {
|
||||||
|
|
||||||
override fun onNewToken(p0: String) {
|
override fun onNewToken(p0: String) {
|
||||||
super.onNewToken(p0)
|
super.onNewToken(p0)
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package com.vanced.manager.model
|
package com.vanced.manager.model
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.pm.PackageManager
|
|
||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
|
@ -9,10 +8,7 @@ import androidx.databinding.ObservableBoolean
|
||||||
import androidx.databinding.ObservableField
|
import androidx.databinding.ObservableField
|
||||||
import androidx.databinding.ObservableInt
|
import androidx.databinding.ObservableInt
|
||||||
import com.beust.klaxon.JsonObject
|
import com.beust.klaxon.JsonObject
|
||||||
import com.vanced.manager.BuildConfig.ENABLE_SIGNATURE_CHECK
|
|
||||||
import com.vanced.manager.R
|
import com.vanced.manager.R
|
||||||
import com.vanced.manager.utils.AppUtils.managerPkg
|
|
||||||
import com.vanced.manager.utils.AppUtils.vancedRootPkg
|
|
||||||
import com.vanced.manager.utils.PackageHelper.isPackageInstalled
|
import com.vanced.manager.utils.PackageHelper.isPackageInstalled
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
@ -33,13 +29,11 @@ open class DataModel(
|
||||||
val buttonTxt = ObservableField<String>()
|
val buttonTxt = ObservableField<String>()
|
||||||
val buttonIcon = ObservableField<Drawable>()
|
val buttonIcon = ObservableField<Drawable>()
|
||||||
val changelog = ObservableField<String>()
|
val changelog = ObservableField<String>()
|
||||||
val isOfficial = ObservableBoolean()
|
|
||||||
|
|
||||||
fun fetch() = CoroutineScope(Dispatchers.IO).launch {
|
fun fetch() = CoroutineScope(Dispatchers.IO).launch {
|
||||||
isAppInstalled.set(isPackageInstalled(appPkg, context.packageManager))
|
isAppInstalled.set(isPackageInstalled(appPkg, context.packageManager))
|
||||||
versionName.set(jsonObject.get()?.string("version")?.removeSuffix("-vanced") ?: context.getString(R.string.unavailable))
|
versionName.set(jsonObject.get()?.string("version")?.removeSuffix("-vanced") ?: context.getString(R.string.unavailable))
|
||||||
installedVersionName.set(getPkgVersionName(isAppInstalled.get(), appPkg))
|
installedVersionName.set(getPkgVersionName(isAppInstalled.get(), appPkg))
|
||||||
isOfficial.set(doSignaturesMatch(managerPkg, appPkg))
|
|
||||||
versionCode.set(jsonObject.get()?.int("versionCode") ?: 0)
|
versionCode.set(jsonObject.get()?.int("versionCode") ?: 0)
|
||||||
installedVersionCode.set(getPkgVersionCode(isAppInstalled.get(), appPkg))
|
installedVersionCode.set(getPkgVersionCode(isAppInstalled.get(), appPkg))
|
||||||
buttonTxt.set(compareInt(installedVersionCode.get(), versionCode.get()))
|
buttonTxt.set(compareInt(installedVersionCode.get(), versionCode.get()))
|
||||||
|
@ -54,24 +48,12 @@ open class DataModel(
|
||||||
private fun getPkgVersionName(toCheck: Boolean, pkg: String): String {
|
private fun getPkgVersionName(toCheck: Boolean, pkg: String): String {
|
||||||
val pm = context.packageManager
|
val pm = context.packageManager
|
||||||
return if (toCheck) {
|
return if (toCheck) {
|
||||||
if (ENABLE_SIGNATURE_CHECK) {
|
pm.getPackageInfo(pkg, 0).versionName.removeSuffix("-vanced")
|
||||||
if (doSignaturesMatch(managerPkg, pkg) || appPkg == vancedRootPkg)
|
|
||||||
pm.getPackageInfo(pkg, 0).versionName.removeSuffix("-vanced")
|
|
||||||
else
|
|
||||||
pm.getPackageInfo(pkg, 0).versionName.removeSuffix("-vanced") + " (${context.getString(R.string.unofficial)})"
|
|
||||||
} else
|
|
||||||
pm.getPackageInfo(pkg, 0).versionName.removeSuffix("-vanced")
|
|
||||||
} else {
|
} else {
|
||||||
context.getString(R.string.unavailable)
|
context.getString(R.string.unavailable)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun doSignaturesMatch(pkg1: String, pkg2: String): Boolean =
|
|
||||||
if (isPackageInstalled(pkg2, context.packageManager))
|
|
||||||
context.packageManager.checkSignatures(pkg1, pkg2) == PackageManager.SIGNATURE_MATCH
|
|
||||||
else
|
|
||||||
true
|
|
||||||
|
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
private fun getPkgVersionCode(toCheck: Boolean, pkg: String): Int {
|
private fun getPkgVersionCode(toCheck: Boolean, pkg: String): Int {
|
||||||
return if (toCheck) {
|
return if (toCheck) {
|
||||||
|
|
|
@ -28,9 +28,6 @@ import com.vanced.manager.utils.InternetTools
|
||||||
import com.vanced.manager.utils.LanguageContextWrapper
|
import com.vanced.manager.utils.LanguageContextWrapper
|
||||||
import com.vanced.manager.utils.PackageHelper
|
import com.vanced.manager.utils.PackageHelper
|
||||||
import com.vanced.manager.utils.ThemeHelper.setFinalTheme
|
import com.vanced.manager.utils.ThemeHelper.setFinalTheme
|
||||||
import kotlinx.coroutines.CoroutineScope
|
|
||||||
import kotlinx.coroutines.Dispatchers
|
|
||||||
import kotlinx.coroutines.launch
|
|
||||||
|
|
||||||
class MainActivity : AppCompatActivity() {
|
class MainActivity : AppCompatActivity() {
|
||||||
|
|
||||||
|
@ -160,10 +157,8 @@ class MainActivity : AppCompatActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkUpdates() {
|
private fun checkUpdates() {
|
||||||
CoroutineScope(Dispatchers.Main).launch {
|
if (InternetTools.isUpdateAvailable(this)) {
|
||||||
if (InternetTools.isUpdateAvailable()) {
|
UpdateCheckFragment().show(supportFragmentManager, "UpdateCheck")
|
||||||
UpdateCheckFragment().show(supportFragmentManager, "UpdateCheck")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,6 @@ object DialogContainer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Easter Egg
|
|
||||||
fun statementFalse(context: Context) {
|
fun statementFalse(context: Context) {
|
||||||
MaterialAlertDialogBuilder(context).apply {
|
MaterialAlertDialogBuilder(context).apply {
|
||||||
setTitle("Wait what?")
|
setTitle("Wait what?")
|
||||||
|
|
|
@ -17,19 +17,13 @@ import androidx.preference.PreferenceManager.getDefaultSharedPreferences
|
||||||
import com.google.android.material.tabs.TabLayout
|
import com.google.android.material.tabs.TabLayout
|
||||||
import com.google.android.material.tabs.TabLayoutMediator
|
import com.google.android.material.tabs.TabLayoutMediator
|
||||||
import com.topjohnwu.superuser.Shell
|
import com.topjohnwu.superuser.Shell
|
||||||
import com.vanced.manager.BuildConfig.ENABLE_SIGNATURE_CHECK
|
|
||||||
import com.vanced.manager.R
|
import com.vanced.manager.R
|
||||||
import com.vanced.manager.adapter.VariantAdapter
|
import com.vanced.manager.adapter.VariantAdapter
|
||||||
import com.vanced.manager.databinding.FragmentHomeBinding
|
import com.vanced.manager.databinding.FragmentHomeBinding
|
||||||
import com.vanced.manager.ui.dialogs.DialogContainer.installAlertBuilder
|
import com.vanced.manager.ui.dialogs.DialogContainer.installAlertBuilder
|
||||||
import com.vanced.manager.ui.dialogs.DialogContainer.showUnofficialAppInstalledDialog
|
|
||||||
import com.vanced.manager.ui.viewmodels.HomeViewModel
|
import com.vanced.manager.ui.viewmodels.HomeViewModel
|
||||||
import com.vanced.manager.ui.viewmodels.HomeViewModelFactory
|
import com.vanced.manager.ui.viewmodels.HomeViewModelFactory
|
||||||
import com.vanced.manager.utils.AppUtils
|
import com.vanced.manager.utils.AppUtils.installing
|
||||||
import com.vanced.manager.utils.AppUtils.microgPkg
|
|
||||||
import com.vanced.manager.utils.AppUtils.musicPkg
|
|
||||||
import com.vanced.manager.utils.AppUtils.vancedPkg
|
|
||||||
import com.vanced.manager.utils.AppUtils.vancedRootPkg
|
|
||||||
|
|
||||||
open class HomeFragment : Fragment() {
|
open class HomeFragment : Fragment() {
|
||||||
|
|
||||||
|
@ -87,19 +81,7 @@ open class HomeFragment : Fragment() {
|
||||||
mainTablayout.getTabAt(if (getDefaultSharedPreferences(requireActivity()).getString("vanced_variant", "nonroot") == "root") 1 else 0)?.select()
|
mainTablayout.getTabAt(if (getDefaultSharedPreferences(requireActivity()).getString("vanced_variant", "nonroot") == "root") 1 else 0)?.select()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ENABLE_SIGNATURE_CHECK) {
|
installing.observe(viewLifecycleOwner, { value ->
|
||||||
if (!viewModel.vanced.get()?.isOfficial?.get()!!)
|
|
||||||
showUnofficialAppInstalledDialog(getString(R.string.vanced), vancedPkg, requireActivity())
|
|
||||||
|
|
||||||
if (!viewModel.music.get()?.isOfficial?.get()!!)
|
|
||||||
showUnofficialAppInstalledDialog(getString(R.string.music), musicPkg, requireActivity())
|
|
||||||
|
|
||||||
if (!viewModel.microg.get()?.isOfficial?.get()!!)
|
|
||||||
showUnofficialAppInstalledDialog(getString(R.string.microg), microgPkg, requireActivity())
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
AppUtils.installing.observe(viewLifecycleOwner, { value ->
|
|
||||||
if (value) hideTab() else showTab()
|
if (value) hideTab() else showTab()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package com.vanced.manager.ui.fragments
|
package com.vanced.manager.ui.fragments
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.graphics.drawable.ColorDrawable
|
import android.graphics.drawable.ColorDrawable
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
|
|
@ -13,12 +13,9 @@ import com.google.android.material.button.MaterialButton
|
||||||
import com.vanced.manager.R
|
import com.vanced.manager.R
|
||||||
import com.vanced.manager.utils.DownloadHelper.downloadManager
|
import com.vanced.manager.utils.DownloadHelper.downloadManager
|
||||||
import com.vanced.manager.utils.InternetTools.isUpdateAvailable
|
import com.vanced.manager.utils.InternetTools.isUpdateAvailable
|
||||||
import kotlinx.coroutines.runBlocking
|
|
||||||
|
|
||||||
class UpdateCheckFragment : DialogFragment() {
|
class UpdateCheckFragment : DialogFragment() {
|
||||||
|
|
||||||
//private var downloadId: Long = 0
|
|
||||||
|
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater, container: ViewGroup?,
|
inflater: LayoutInflater, container: ViewGroup?,
|
||||||
savedInstanceState: Bundle?
|
savedInstanceState: Bundle?
|
||||||
|
@ -31,7 +28,6 @@ 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)
|
||||||
//activity?.registerReceiver(receiver, IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE))
|
|
||||||
checkUpdates()
|
checkUpdates()
|
||||||
view.findViewById<Button>(R.id.update_center_dismiss).setOnClickListener { dismiss() }
|
view.findViewById<Button>(R.id.update_center_dismiss).setOnClickListener { dismiss() }
|
||||||
view.findViewById<MaterialButton>(R.id.update_center_recheck).setOnClickListener{ checkUpdates() }
|
view.findViewById<MaterialButton>(R.id.update_center_recheck).setOnClickListener{ checkUpdates() }
|
||||||
|
@ -39,30 +35,21 @@ class UpdateCheckFragment : DialogFragment() {
|
||||||
downLoadingState(false)
|
downLoadingState(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
override fun onPause() {
|
|
||||||
super.onPause()
|
|
||||||
activity?.unregisterReceiver(receiver)
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
private fun checkUpdates() {
|
private fun checkUpdates() {
|
||||||
val updatebtn = view?.findViewById<Button>(R.id.update_center_update)
|
val updatebtn = view?.findViewById<Button>(R.id.update_center_update)
|
||||||
val checkingTxt = view?.findViewById<TextView>(R.id.update_center_checking)
|
val checkingTxt = view?.findViewById<TextView>(R.id.update_center_checking)
|
||||||
|
|
||||||
runBlocking {
|
if (isUpdateAvailable(requireActivity())) {
|
||||||
if (isUpdateAvailable()) {
|
view?.findViewById<Button>(R.id.update_center_recheck)?.visibility = View.GONE
|
||||||
view?.findViewById<Button>(R.id.update_center_recheck)?.visibility = View.GONE
|
checkingTxt?.text = getString(R.string.update_found)
|
||||||
checkingTxt?.text = getString(R.string.update_found)
|
|
||||||
|
|
||||||
updatebtn?.setOnClickListener {
|
updatebtn?.setOnClickListener {
|
||||||
downLoadingState(true)
|
downLoadingState(true)
|
||||||
downloadManager(false, requireActivity(), view?.findViewById(R.id.update_center_progressbar))
|
downloadManager(false, requireActivity(), view?.findViewById(R.id.update_center_progressbar))
|
||||||
downLoadingState(false)
|
downLoadingState(false)
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
checkingTxt?.text = getString(R.string.update_notfound)
|
checkingTxt?.text = getString(R.string.update_notfound)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun downLoadingState(isDownloading: Boolean) {
|
private fun downLoadingState(isDownloading: Boolean) {
|
||||||
|
@ -76,31 +63,4 @@ class UpdateCheckFragment : DialogFragment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
private val receiver = object : BroadcastReceiver() {
|
|
||||||
override fun onReceive(context: Context?, intent: Intent?) {
|
|
||||||
if (intent?.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1) == downloadId) {
|
|
||||||
activity?.let {
|
|
||||||
val apk = File("${activity?.getExternalFilesDir("apk")}/manager.apk")
|
|
||||||
val uri =
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
|
||||||
FileProvider.getUriForFile(activity!!, "${activity?.packageName}.provider", apk)
|
|
||||||
else
|
|
||||||
Uri.fromFile(apk)
|
|
||||||
|
|
||||||
val mIntent = Intent(Intent.ACTION_VIEW)
|
|
||||||
mIntent.setDataAndType(uri, "application/vnd.android.package-archive")
|
|
||||||
mIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
|
||||||
mIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
|
|
||||||
startActivity(mIntent)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,11 @@ import com.vanced.manager.model.DataModel
|
||||||
import com.vanced.manager.model.ProgressModel
|
import com.vanced.manager.model.ProgressModel
|
||||||
import com.vanced.manager.ui.events.Event
|
import com.vanced.manager.ui.events.Event
|
||||||
import com.vanced.manager.utils.AppUtils.installing
|
import com.vanced.manager.utils.AppUtils.installing
|
||||||
|
import com.vanced.manager.utils.AppUtils.managerPkg
|
||||||
|
import com.vanced.manager.utils.AppUtils.microgPkg
|
||||||
|
import com.vanced.manager.utils.AppUtils.musicPkg
|
||||||
|
import com.vanced.manager.utils.AppUtils.vancedPkg
|
||||||
|
import com.vanced.manager.utils.AppUtils.vancedRootPkg
|
||||||
import com.vanced.manager.utils.InternetTools
|
import com.vanced.manager.utils.InternetTools
|
||||||
import com.vanced.manager.utils.PackageHelper.uninstallApk
|
import com.vanced.manager.utils.PackageHelper.uninstallApk
|
||||||
|
|
||||||
|
@ -128,9 +133,9 @@ open class HomeViewModel(private val activity: Activity): ViewModel() {
|
||||||
Toast.makeText(activity, R.string.installation_wait, Toast.LENGTH_SHORT).show()
|
Toast.makeText(activity, R.string.installation_wait, Toast.LENGTH_SHORT).show()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun uninstallVanced(variant: String) = uninstallApk(if (variant == "root") "com.google.android.youtube" else "com.vanced.android.youtube", activity)
|
fun uninstallVanced(variant: String) = uninstallApk(if (variant == "root") vancedRootPkg else vancedPkg, activity)
|
||||||
fun uninstallMusic() = uninstallApk("com.vanced.android.apps.youtube.music", activity)
|
fun uninstallMusic() = uninstallApk(musicPkg, activity)
|
||||||
fun uninstallMicrog() = uninstallApk("com.mgoogle.android.gms", activity)
|
fun uninstallMicrog() = uninstallApk(microgPkg, activity)
|
||||||
|
|
||||||
fun cancelDownload(downloadId: Int) {
|
fun cancelDownload(downloadId: Int) {
|
||||||
PRDownloader.cancel(downloadId)
|
PRDownloader.cancel(downloadId)
|
||||||
|
@ -151,11 +156,11 @@ open class HomeViewModel(private val activity: Activity): ViewModel() {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
fetching.set(true)
|
fetching.set(true)
|
||||||
vanced.set(DataModel(app.vanced, "com.vanced.android.youtube", activity))
|
vanced.set(DataModel(app.vanced, vancedPkg, activity))
|
||||||
vancedRoot.set(DataModel(app.vanced, "com.google.android.youtube", activity))
|
vancedRoot.set(DataModel(app.vanced, vancedRootPkg, activity))
|
||||||
music.set(DataModel(app.music, "com.vanced.android.apps.youtube.music", activity))
|
music.set(DataModel(app.music, musicPkg, activity))
|
||||||
microg.set(DataModel(app.microg, "com.mgoogle.android.gms", activity))
|
microg.set(DataModel(app.microg, microgPkg, activity))
|
||||||
manager.set(DataModel(app.manager, "com.vanced.manager", activity))
|
manager.set(DataModel(app.manager, managerPkg, activity))
|
||||||
vancedProgress.set(ProgressModel())
|
vancedProgress.set(ProgressModel())
|
||||||
musicProgress.set(ProgressModel())
|
musicProgress.set(ProgressModel())
|
||||||
microgProgress.set(ProgressModel())
|
microgProgress.set(ProgressModel())
|
||||||
|
|
|
@ -9,6 +9,7 @@ import androidx.core.content.ContextCompat
|
||||||
import androidx.preference.PreferenceManager.getDefaultSharedPreferences
|
import androidx.preference.PreferenceManager.getDefaultSharedPreferences
|
||||||
import com.vanced.manager.BuildConfig
|
import com.vanced.manager.BuildConfig
|
||||||
import com.vanced.manager.R
|
import com.vanced.manager.R
|
||||||
|
import com.vanced.manager.core.App
|
||||||
|
|
||||||
object InternetTools {
|
object InternetTools {
|
||||||
|
|
||||||
|
@ -66,16 +67,12 @@ object InternetTools {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun isUpdateAvailable(): Boolean {
|
fun isUpdateAvailable(context: Context): Boolean {
|
||||||
val result = try {
|
val result = (context.applicationContext as App).manager.get()?.int("versionCode") ?: 0
|
||||||
JsonHelper.getJson("https://ytvanced.github.io/VancedBackend/manager.json")?.int("versionCode") ?: 0
|
|
||||||
} catch (e: Exception) {
|
|
||||||
0
|
|
||||||
}
|
|
||||||
|
|
||||||
return result > BuildConfig.VERSION_CODE
|
return result > BuildConfig.VERSION_CODE
|
||||||
}
|
}
|
||||||
|
|
||||||
const val baseUrl = "https://vancedapp.com/api/v1"
|
const val baseUrl = "https://vanced.app/api/v1"
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in a new issue