mirror of
https://github.com/YTVanced/VancedManager
synced 2024-11-22 19:25:11 +00:00
fixed issues
This commit is contained in:
parent
7d25d5a89f
commit
f44249f462
19 changed files with 143 additions and 124 deletions
|
@ -9,10 +9,7 @@ import com.crowdin.platform.data.remote.NetworkType
|
|||
import com.downloader.PRDownloader
|
||||
import com.vanced.manager.utils.InternetTools.baseUrl
|
||||
import com.vanced.manager.utils.JsonHelper.getJson
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.*
|
||||
|
||||
open class App: Application() {
|
||||
|
||||
|
@ -22,24 +19,21 @@ open class App: Application() {
|
|||
var manager: JsonObject? = null
|
||||
|
||||
override fun onCreate() {
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
loadJsonAsync().await()
|
||||
super.onCreate()
|
||||
PRDownloader.initialize(this@App)
|
||||
|
||||
Crowdin.init(this@App,
|
||||
CrowdinConfig.Builder()
|
||||
.withDistributionHash("36c51aed3180a4f43073d28j4s6")
|
||||
.withNetworkType(NetworkType.WIFI)
|
||||
.build()
|
||||
)
|
||||
}
|
||||
loadJsonAsync()
|
||||
super.onCreate()
|
||||
PRDownloader.initialize(this)
|
||||
|
||||
Crowdin.init(this,
|
||||
CrowdinConfig.Builder()
|
||||
.withDistributionHash("36c51aed3180a4f43073d28j4s6")
|
||||
.withNetworkType(NetworkType.WIFI)
|
||||
.build()
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
fun loadJsonAsync() = CoroutineScope(Dispatchers.IO).async {
|
||||
val latest = getJson("$baseUrl/latest.json")
|
||||
fun loadJsonAsync() {
|
||||
val latest = runBlocking { getJson("$baseUrl/latest.json") }
|
||||
vanced = latest.obj("vanced")
|
||||
music = latest.obj("music")
|
||||
microg = latest.obj("microg")
|
||||
|
|
|
@ -7,7 +7,7 @@ import com.downloader.OnDownloadListener
|
|||
import com.downloader.PRDownloader
|
||||
import com.vanced.manager.R
|
||||
import com.vanced.manager.ui.viewmodels.HomeViewModel.Companion.microgProgress
|
||||
import com.vanced.manager.utils.AppUtils.installing
|
||||
import com.vanced.manager.utils.AppUtils.mutableInstall
|
||||
import com.vanced.manager.utils.InternetTools.getFileNameFromUrl
|
||||
import com.vanced.manager.utils.InternetTools.getJsonString
|
||||
import com.vanced.manager.utils.PackageHelper.install
|
||||
|
@ -28,7 +28,7 @@ object MicrogDownloader {
|
|||
PRDownloader.download(url, context.getExternalFilesDir("apk")?.path, "microg.apk")
|
||||
.build()
|
||||
.setOnStartOrResumeListener {
|
||||
installing = true
|
||||
mutableInstall.value = true
|
||||
microgProgress.get()?.downloadingFile?.set(context.getString(R.string.downloading_file, getFileNameFromUrl(url)))
|
||||
microgProgress.get()?.showDownloadBar?.set(true)
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ object MicrogDownloader {
|
|||
}
|
||||
|
||||
override fun onError(error: Error?) {
|
||||
installing = false
|
||||
mutableInstall.value = false
|
||||
microgProgress.get()?.showDownloadBar?.set(false)
|
||||
Toast.makeText(context, context.getString(R.string.error_downloading, "microG"), Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import com.downloader.OnDownloadListener
|
|||
import com.downloader.PRDownloader
|
||||
import com.vanced.manager.R
|
||||
import com.vanced.manager.ui.viewmodels.HomeViewModel.Companion.musicProgress
|
||||
import com.vanced.manager.utils.AppUtils.installing
|
||||
import com.vanced.manager.utils.AppUtils.mutableInstall
|
||||
import com.vanced.manager.utils.InternetTools.getFileNameFromUrl
|
||||
import com.vanced.manager.utils.InternetTools.getJsonString
|
||||
import com.vanced.manager.utils.PackageHelper.install
|
||||
|
@ -29,7 +29,7 @@ object MusicDownloader {
|
|||
PRDownloader.download(url, context.getExternalFilesDir("apk")?.path, "music.apk")
|
||||
.build()
|
||||
.setOnStartOrResumeListener {
|
||||
installing = true
|
||||
mutableInstall.value = true
|
||||
musicProgress.get()?.downloadingFile?.set(context.getString(R.string.downloading_file, getFileNameFromUrl(url)))
|
||||
musicProgress.get()?.showDownloadBar?.set(true)
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ object MusicDownloader {
|
|||
}
|
||||
|
||||
override fun onError(error: Error?) {
|
||||
installing = false
|
||||
mutableInstall.value = false
|
||||
musicProgress.get()?.showDownloadBar?.set(false)
|
||||
Toast.makeText(context, context.getString(R.string.error_downloading, "Music"), Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
|
|
|
@ -5,12 +5,15 @@ import android.content.SharedPreferences
|
|||
import android.os.Build
|
||||
import android.widget.Toast
|
||||
import androidx.preference.PreferenceManager
|
||||
import androidx.preference.PreferenceManager.getDefaultSharedPreferences
|
||||
import com.downloader.Error
|
||||
import com.downloader.OnDownloadListener
|
||||
import com.downloader.PRDownloader
|
||||
import com.vanced.manager.R
|
||||
import com.vanced.manager.core.App
|
||||
import com.vanced.manager.ui.viewmodels.HomeViewModel.Companion.vancedProgress
|
||||
import com.vanced.manager.utils.AppUtils.installing
|
||||
import com.vanced.manager.utils.AppUtils.mutableInstall
|
||||
import com.vanced.manager.utils.InternetTools
|
||||
import com.vanced.manager.utils.InternetTools.baseUrl
|
||||
import com.vanced.manager.utils.InternetTools.getFileNameFromUrl
|
||||
|
@ -53,7 +56,7 @@ object VancedDownloader {
|
|||
fun downloadVanced(context: Context) {
|
||||
//registerReceiver(receiver, IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE))
|
||||
File(context.getExternalFilesDir("apks")?.path as String).deleteRecursively()
|
||||
defPrefs = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
defPrefs = getDefaultSharedPreferences(context)
|
||||
installUrl = defPrefs.getString("install_url", baseUrl)
|
||||
prefs = context.getSharedPreferences("installPrefs", Context.MODE_PRIVATE)
|
||||
variant = defPrefs.getString("vanced_variant", "nonroot")
|
||||
|
@ -68,7 +71,8 @@ object VancedDownloader {
|
|||
Build.SUPPORTED_ABIS.contains("arm64-v8a") -> "arm64_v8a"
|
||||
else -> "armeabi_v7a"
|
||||
}
|
||||
vancedVersionCode = runBlocking { InternetTools.getJsonInt("vanced.json", "versionCode", context) }
|
||||
val app = context.applicationContext as App
|
||||
vancedVersionCode = app.vanced?.int("versionCode") ?: 0
|
||||
downloadSplits(context)
|
||||
}
|
||||
|
||||
|
@ -94,7 +98,7 @@ object VancedDownloader {
|
|||
.download(url, context.getExternalFilesDir("apks")?.path, getFileNameFromUrl(url))
|
||||
.build()
|
||||
.setOnStartOrResumeListener {
|
||||
installing = true
|
||||
mutableInstall.value = true
|
||||
vancedProgress.get()?.downloadingFile?.set(context.getString(R.string.downloading_file, getFileNameFromUrl(url)))
|
||||
vancedProgress.get()?.showDownloadBar?.set(true)
|
||||
}
|
||||
|
@ -136,7 +140,7 @@ object VancedDownloader {
|
|||
else
|
||||
prepareInstall(variant!!, context)
|
||||
} else {
|
||||
installing = false
|
||||
mutableInstall.value = false
|
||||
vancedProgress.get()?.showDownloadBar?.set(false)
|
||||
Toast.makeText(context, context.getString(R.string.error_downloading, "Vanced"), Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
|
@ -158,8 +162,6 @@ object VancedDownloader {
|
|||
}
|
||||
|
||||
private fun validateTheme(context: Context): Boolean {
|
||||
val prefs = context.getSharedPreferences("installPrefs", Context.MODE_PRIVATE)
|
||||
val theme = prefs?.getString("theme", "dark")
|
||||
val themeS = context.getExternalFilesDir("apks")?.path + "/${theme}.apk"
|
||||
val themeF = File(themeS)
|
||||
runBlocking { getSha256(theme!!, context) }
|
||||
|
|
|
@ -7,13 +7,14 @@ import android.os.IBinder
|
|||
import android.util.Log
|
||||
import com.vanced.manager.ui.viewmodels.HomeViewModel.Companion.microgProgress
|
||||
import com.vanced.manager.ui.viewmodels.HomeViewModel.Companion.musicProgress
|
||||
import com.vanced.manager.utils.AppUtils.installing
|
||||
import com.vanced.manager.utils.AppUtils.mutableInstall
|
||||
import com.vanced.manager.utils.AppUtils.sendFailure
|
||||
import com.vanced.manager.utils.AppUtils.sendRefresh
|
||||
|
||||
class AppInstallerService: Service() {
|
||||
|
||||
override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int {
|
||||
val app = intent.getStringExtra("app")
|
||||
when (intent.getIntExtra(PackageInstaller.EXTRA_STATUS, -999)) {
|
||||
PackageInstaller.STATUS_PENDING_USER_ACTION -> {
|
||||
Log.d(TAG, "Requesting user confirmation for installation")
|
||||
|
@ -27,11 +28,14 @@ class AppInstallerService: Service() {
|
|||
}
|
||||
PackageInstaller.STATUS_SUCCESS -> {
|
||||
Log.d(TAG, "Installation succeed")
|
||||
if (intent.getStringExtra("app") == "microg") microgProgress.get()?.showInstallCircle?.set(false) else musicProgress.get()?.showInstallCircle?.set(false)
|
||||
installing = false
|
||||
if (app == "microg") microgProgress.get()?.showInstallCircle?.set(false) else musicProgress.get()?.showInstallCircle?.set(false)
|
||||
mutableInstall.postValue(false)
|
||||
sendRefresh(this)
|
||||
}
|
||||
else -> sendFailure(intent.getIntExtra(PackageInstaller.EXTRA_STATUS, -999), this)
|
||||
else -> {
|
||||
sendFailure(intent.getIntExtra(PackageInstaller.EXTRA_STATUS, -999), this)
|
||||
if (app == "microg") microgProgress.get()?.showInstallCircle?.set(false) else musicProgress.get()?.showInstallCircle?.set(false)
|
||||
}
|
||||
}
|
||||
stopSelf()
|
||||
return START_NOT_STICKY
|
||||
|
|
|
@ -6,7 +6,7 @@ import android.content.pm.PackageInstaller
|
|||
import android.os.IBinder
|
||||
import android.util.Log
|
||||
import com.vanced.manager.ui.viewmodels.HomeViewModel.Companion.vancedProgress
|
||||
import com.vanced.manager.utils.AppUtils.installing
|
||||
import com.vanced.manager.utils.AppUtils.mutableInstall
|
||||
import com.vanced.manager.utils.AppUtils.sendFailure
|
||||
import com.vanced.manager.utils.AppUtils.sendRefresh
|
||||
|
||||
|
@ -26,11 +26,13 @@ class SplitInstallerService: Service() {
|
|||
PackageInstaller.STATUS_SUCCESS -> {
|
||||
Log.d(TAG, "Installation succeed")
|
||||
vancedProgress.get()?.showInstallCircle?.set(false)
|
||||
installing = false
|
||||
mutableInstall.postValue(false)
|
||||
sendRefresh(this)
|
||||
}
|
||||
else -> sendFailure(intent.getIntExtra(PackageInstaller.EXTRA_STATUS, -999), this)
|
||||
|
||||
else -> {
|
||||
sendFailure(intent.getIntExtra(PackageInstaller.EXTRA_STATUS, -999), this)
|
||||
vancedProgress.get()?.showInstallCircle?.set(false)
|
||||
}
|
||||
}
|
||||
stopSelf()
|
||||
return START_NOT_STICKY
|
||||
|
|
|
@ -10,6 +10,9 @@ import androidx.databinding.ObservableInt
|
|||
import com.beust.klaxon.JsonObject
|
||||
import com.vanced.manager.R
|
||||
import com.vanced.manager.utils.PackageHelper.isPackageInstalled
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
open class DataModel(
|
||||
private val jsonObject: JsonObject?,
|
||||
|
@ -35,7 +38,7 @@ open class DataModel(
|
|||
val buttonIcon = ObservableField<Drawable>()
|
||||
val changelog = ObservableField<String>()
|
||||
|
||||
fun fetch() {
|
||||
fun fetch() = CoroutineScope(Dispatchers.IO).launch {
|
||||
isAppInstalled.set(isPackageInstalled(appPkg, context.packageManager))
|
||||
versionName.set(jsonObject?.string("version")?.removeSuffix("-vanced") ?: context.getString(R.string.unavailable))
|
||||
installedVersionName.set(getPkgVersionName(isAppInstalled.get(), appPkg))
|
||||
|
|
|
@ -9,7 +9,7 @@ open class ProgressModel {
|
|||
val downloadProgress = ObservableInt()
|
||||
val downloadingFile = ObservableField<String>()
|
||||
val showInstallCircle = ObservableBoolean()
|
||||
var showDownloadBar = ObservableBoolean()
|
||||
val showDownloadBar = ObservableBoolean()
|
||||
|
||||
init {
|
||||
downloadProgress.set(0)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.vanced.manager.ui
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.MenuItem
|
||||
|
@ -29,7 +30,7 @@ import kotlinx.coroutines.launch
|
|||
|
||||
class MainActivity : AppCompatActivity() {
|
||||
|
||||
private lateinit var binding: ActivityMainBinding
|
||||
lateinit var binding: ActivityMainBinding
|
||||
|
||||
private val loadingObserver = object : LoadingStateListener {
|
||||
val tag = "VMLocalisation"
|
||||
|
@ -79,7 +80,6 @@ class MainActivity : AppCompatActivity() {
|
|||
lifecycleOwner = this@MainActivity
|
||||
setSupportActionBar(homeToolbar)
|
||||
mainViewpager.adapter = VariantAdapter(this@MainActivity)
|
||||
mainViewpager.isUserInputEnabled = false
|
||||
TabLayoutMediator(mainTablayout, mainViewpager) { tab, position ->
|
||||
tab.text = if (position == 1) "root" else "nonroot"
|
||||
}.attach()
|
||||
|
@ -110,10 +110,12 @@ class MainActivity : AppCompatActivity() {
|
|||
binding.mainTablayout.addOnTabSelectedListener(tabListener)
|
||||
}
|
||||
|
||||
override fun recreate() {
|
||||
startActivity(Intent(this, MainActivity::class.java))
|
||||
finish()
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
if (installing) {
|
||||
return false
|
||||
}
|
||||
when (item.itemId) {
|
||||
android.R.id.home -> {
|
||||
return false
|
||||
|
|
|
@ -18,6 +18,7 @@ import com.vanced.manager.ui.viewmodels.AboutViewModel
|
|||
class AboutFragment : Fragment() {
|
||||
|
||||
private lateinit var binding: FragmentAboutBinding
|
||||
private val viewModel: AboutViewModel by viewModels()
|
||||
private var count = 0
|
||||
private var startMillSec: Long = 0
|
||||
|
||||
|
@ -27,6 +28,7 @@ class AboutFragment : Fragment() {
|
|||
): View? {
|
||||
requireActivity().title = getString(R.string.title_about)
|
||||
binding = DataBindingUtil.inflate(inflater, R.layout.fragment_about, container, false)
|
||||
binding.viewModel = viewModel
|
||||
return binding.root
|
||||
}
|
||||
|
||||
|
@ -35,10 +37,6 @@ class AboutFragment : Fragment() {
|
|||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
val viewModel: AboutViewModel by viewModels()
|
||||
binding.viewModel = viewModel
|
||||
|
||||
|
||||
view.setOnTouchListener { _, event: MotionEvent ->
|
||||
|
||||
val eventAction = event.action
|
||||
|
|
|
@ -8,7 +8,6 @@ import android.widget.Toast
|
|||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.lifecycle.Observer
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
||||
import androidx.navigation.findNavController
|
||||
import com.google.android.material.tabs.TabLayout
|
||||
|
@ -17,10 +16,8 @@ import com.vanced.manager.R
|
|||
import com.vanced.manager.adapter.ChangelogAdapter
|
||||
import com.vanced.manager.databinding.FragmentHomeBinding
|
||||
import com.vanced.manager.ui.dialogs.DialogContainer.installAlertBuilder
|
||||
import com.vanced.manager.ui.events.Event
|
||||
import com.vanced.manager.ui.viewmodels.HomeViewModel
|
||||
import com.vanced.manager.ui.viewmodels.HomeViewModelFactory
|
||||
import com.vanced.manager.utils.AppUtils.installing
|
||||
|
||||
open class HomeFragment : Fragment(), View.OnClickListener {
|
||||
|
||||
|
@ -46,7 +43,7 @@ open class HomeFragment : Fragment(), View.OnClickListener {
|
|||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
viewModel.navigateDestination.observe(viewLifecycleOwner, Observer<Event<Int>> {
|
||||
viewModel.navigateDestination.observe(viewLifecycleOwner, {
|
||||
val content = it.getContentIfNotHandled()
|
||||
if(content != null){
|
||||
view.findNavController().navigate(content)
|
||||
|
@ -126,15 +123,7 @@ open class HomeFragment : Fragment(), View.OnClickListener {
|
|||
private val broadcastReceiver: BroadcastReceiver = object : BroadcastReceiver() {
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
when (intent.action) {
|
||||
INSTALL_FAILED -> {
|
||||
with(binding) {
|
||||
includeMicrogLayout.microgInstalling.visibility = View.GONE
|
||||
includeVancedLayout.vancedInstalling.visibility = View.GONE
|
||||
includeMusicLayout.musicInstalling.visibility = View.GONE
|
||||
}
|
||||
installAlertBuilder(intent.getStringExtra("errorMsg") as String, requireActivity())
|
||||
installing = false
|
||||
}
|
||||
INSTALL_FAILED -> installAlertBuilder(intent.getStringExtra("errorMsg") as String, requireActivity())
|
||||
REFRESH_HOME -> viewModel.fetchData()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,12 +17,15 @@ import com.google.android.material.appbar.MaterialToolbar
|
|||
import com.google.android.material.tabs.TabLayout
|
||||
import com.vanced.manager.R
|
||||
import com.vanced.manager.databinding.FragmentMainBinding
|
||||
import com.vanced.manager.ui.MainActivity
|
||||
import com.vanced.manager.utils.AppUtils.installing
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
class MainFragment : Fragment() {
|
||||
|
||||
private lateinit var binding: FragmentMainBinding
|
||||
private lateinit var navHost: NavController
|
||||
private lateinit var act: MainActivity
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
|
@ -37,6 +40,7 @@ class MainFragment : Fragment() {
|
|||
super.onViewCreated(view, savedInstanceState)
|
||||
val navHostFragment = childFragmentManager.findFragmentById(R.id.nav_host) as NavHostFragment
|
||||
navHost = navHostFragment.navController
|
||||
act = requireActivity() as MainActivity
|
||||
|
||||
val callback = object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
|
@ -45,38 +49,54 @@ class MainFragment : Fragment() {
|
|||
}
|
||||
}
|
||||
}
|
||||
requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner, callback)
|
||||
act.onBackPressedDispatcher.addCallback(viewLifecycleOwner, callback)
|
||||
|
||||
val tabLayout = requireActivity().findViewById<TabLayout>(R.id.main_tablayout)
|
||||
val tabLayout = act.binding.mainTablayout
|
||||
|
||||
installing.observe(viewLifecycleOwner, { value ->
|
||||
if (value)
|
||||
hideTab(tabLayout)
|
||||
else
|
||||
showTab(tabLayout)
|
||||
})
|
||||
|
||||
navHost.addOnDestinationChangedListener { _, currFrag: NavDestination, _ ->
|
||||
setDisplayHomeAsUpEnabled(currFrag.id != R.id.home_fragment)
|
||||
with (requireActivity()) {
|
||||
val tabHide = AnimationUtils.loadAnimation(this, R.anim.tablayout_exit)
|
||||
val tabShow = AnimationUtils.loadAnimation(this, R.anim.tablayout_enter)
|
||||
if (currFrag.id != R.id.home_fragment) {
|
||||
if (tabLayout.visibility != View.GONE) {
|
||||
tabLayout.startAnimation(tabHide)
|
||||
tabLayout.visibility = View.GONE
|
||||
}
|
||||
} else {
|
||||
if (tabLayout.visibility != View.VISIBLE) {
|
||||
tabLayout.visibility = View.VISIBLE
|
||||
tabLayout.startAnimation(tabShow)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (currFrag.id != R.id.home_fragment)
|
||||
hideTab(tabLayout)
|
||||
else
|
||||
showTab(tabLayout)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun hideTab(tabLayout: TabLayout) {
|
||||
val tabHide = AnimationUtils.loadAnimation(act, R.anim.tablayout_exit)
|
||||
if (tabLayout.visibility != View.GONE) {
|
||||
tabLayout.startAnimation(tabHide)
|
||||
tabLayout.visibility = View.GONE
|
||||
}
|
||||
act.binding.mainViewpager.isUserInputEnabled = false
|
||||
}
|
||||
|
||||
private fun showTab(tabLayout: TabLayout) {
|
||||
val tabShow = AnimationUtils.loadAnimation(act, R.anim.tablayout_enter)
|
||||
if (tabLayout.visibility != View.VISIBLE) {
|
||||
tabLayout.visibility = View.VISIBLE
|
||||
tabLayout.startAnimation(tabShow)
|
||||
}
|
||||
act.binding.mainViewpager.isUserInputEnabled = true
|
||||
}
|
||||
|
||||
private fun setDisplayHomeAsUpEnabled(isNeeded: Boolean) {
|
||||
with(requireActivity()) {
|
||||
findViewById<MaterialToolbar>(R.id.home_toolbar).navigationIcon = if (isNeeded) ContextCompat.getDrawable(this, R.drawable.ic_keyboard_backspace_black_24dp) else null
|
||||
}
|
||||
act.binding.homeToolbar.navigationIcon = if (isNeeded) ContextCompat.getDrawable(act, R.drawable.ic_keyboard_backspace_black_24dp) else null
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
if (installing.value!!)
|
||||
return false
|
||||
|
||||
when (item.itemId) {
|
||||
android.R.id.home -> {
|
||||
requireActivity().onBackPressedDispatcher.onBackPressed()
|
||||
|
|
|
@ -5,7 +5,6 @@ import android.content.ActivityNotFoundException
|
|||
import android.content.ComponentName
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.util.Log
|
||||
import android.widget.Toast
|
||||
import androidx.core.content.ContextCompat.startActivity
|
||||
import androidx.databinding.ObservableBoolean
|
||||
|
@ -25,9 +24,8 @@ import com.vanced.manager.ui.events.Event
|
|||
import com.vanced.manager.utils.AppUtils.installing
|
||||
import com.vanced.manager.utils.InternetTools
|
||||
import com.vanced.manager.utils.PackageHelper.uninstallApk
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.runBlocking
|
||||
|
||||
open class HomeViewModel(application: Application, val variant: String): AndroidViewModel(application) {
|
||||
|
||||
|
@ -46,9 +44,9 @@ open class HomeViewModel(application: Application, val variant: String): Android
|
|||
|
||||
val navigateDestination : LiveData<Event<Int>> = _navigateDestination
|
||||
|
||||
fun fetchData() = CoroutineScope(Dispatchers.IO).launch {
|
||||
fun fetchData() {
|
||||
fetching.set(true)
|
||||
managerApp.loadJsonAsync().await()
|
||||
managerApp.loadJsonAsync()
|
||||
vanced.get()?.fetch()
|
||||
music.get()?.fetch()
|
||||
microg.get()?.fetch()
|
||||
|
@ -96,7 +94,7 @@ open class HomeViewModel(application: Application, val variant: String): Android
|
|||
}
|
||||
|
||||
fun installVanced() {
|
||||
if (!installing) {
|
||||
if (!installing.value!!) {
|
||||
if (!fetching.get()) {
|
||||
if (variant == "nonroot" && !microg.get()?.isAppInstalled?.get()!!) {
|
||||
microgToast.show()
|
||||
|
@ -113,7 +111,7 @@ open class HomeViewModel(application: Application, val variant: String): Android
|
|||
}
|
||||
|
||||
fun installMusic() {
|
||||
if (!installing) {
|
||||
if (!installing.value!!) {
|
||||
if (!fetching.get()) {
|
||||
if (!microg.get()?.isAppInstalled?.get()!!) {
|
||||
microgToast.show()
|
||||
|
@ -126,7 +124,7 @@ open class HomeViewModel(application: Application, val variant: String): Android
|
|||
}
|
||||
|
||||
fun installMicrog() {
|
||||
if (!installing)
|
||||
if (!installing.value!!)
|
||||
downloadMicrog(getApplication())
|
||||
else
|
||||
Toast.makeText(getApplication(), R.string.installation_wait, Toast.LENGTH_SHORT).show()
|
||||
|
@ -151,7 +149,6 @@ open class HomeViewModel(application: Application, val variant: String): Android
|
|||
vancedProgress.set(ProgressModel())
|
||||
musicProgress.set(ProgressModel())
|
||||
microgProgress.set(ProgressModel())
|
||||
Log.d("Test", variant)
|
||||
fetching.set(false)
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@ package com.vanced.manager.utils
|
|||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageInstaller
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
||||
import com.vanced.manager.R
|
||||
import com.vanced.manager.ui.fragments.HomeFragment
|
||||
|
@ -13,7 +15,12 @@ import kotlinx.coroutines.launch
|
|||
|
||||
object AppUtils {
|
||||
|
||||
var installing = false
|
||||
val mutableInstall = MutableLiveData<Boolean>()
|
||||
val installing: LiveData<Boolean> = mutableInstall
|
||||
|
||||
init {
|
||||
mutableInstall.value = false
|
||||
}
|
||||
|
||||
fun sendRefresh(context: Context) {
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
|
@ -23,6 +30,7 @@ object AppUtils {
|
|||
}
|
||||
|
||||
fun sendFailure(status: Int, context: Context) {
|
||||
mutableInstall.value = false
|
||||
//Delay error broadcast until activity (and fragment) get back to the screen
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
delay(500)
|
||||
|
|
|
@ -8,15 +8,16 @@ import android.content.pm.PackageInstaller
|
|||
import android.content.pm.PackageManager
|
||||
import android.os.Build
|
||||
import android.util.Log
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
||||
import androidx.preference.PreferenceManager.getDefaultSharedPreferences
|
||||
import com.topjohnwu.superuser.Shell
|
||||
import com.topjohnwu.superuser.io.SuFile
|
||||
import com.vanced.manager.BuildConfig
|
||||
import com.vanced.manager.core.App
|
||||
import com.vanced.manager.core.installer.AppInstallerService
|
||||
import com.vanced.manager.core.installer.AppUninstallerService
|
||||
import com.vanced.manager.core.installer.SplitInstallerService
|
||||
import com.vanced.manager.ui.fragments.HomeFragment
|
||||
import com.vanced.manager.ui.viewmodels.HomeViewModel.Companion.vancedProgress
|
||||
import com.vanced.manager.utils.AppUtils.mutableInstall
|
||||
import com.vanced.manager.utils.AppUtils.sendFailure
|
||||
import com.vanced.manager.utils.AppUtils.sendRefresh
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
|
@ -204,31 +205,30 @@ object PackageHelper {
|
|||
)
|
||||
|
||||
Shell.getShell {
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
val vancedVersionCode = InternetTools.getJsonInt("vanced.json", "versionCode", context)
|
||||
val apkFilesPath = context.getExternalFilesDir("apks")?.path
|
||||
val fileInfoList = apkFilesPath?.let { it1 -> getFileInfoList(it1) }
|
||||
if (fileInfoList != null) {
|
||||
var modApk: FileInfo? = null
|
||||
for (file in fileInfoList) {
|
||||
if (file.name == "dark.apk" || file.name == "black.apk") {
|
||||
modApk = file
|
||||
}
|
||||
val vancedVersionCode = (context.applicationContext as App).vanced?.int("versionCode") ?: 0
|
||||
val apkFilesPath = context.getExternalFilesDir("apks")?.path
|
||||
val fileInfoList = apkFilesPath?.let { it1 -> getFileInfoList(it1) }
|
||||
if (fileInfoList != null) {
|
||||
var modApk: FileInfo? = null
|
||||
for (file in fileInfoList) {
|
||||
if (file.name == "dark.apk" || file.name == "black.apk") {
|
||||
modApk = file
|
||||
}
|
||||
if (modApk != null) {
|
||||
if (overwriteBase(modApk, fileInfoList, vancedVersionCode, context)) {
|
||||
sendRefresh(context)
|
||||
vancedProgress.get()?.showInstallCircle?.set(false)
|
||||
}
|
||||
}
|
||||
else {
|
||||
sendFailure(listOf("ModApk_Missing").toMutableList(), context)
|
||||
}
|
||||
if (modApk != null) {
|
||||
if (overwriteBase(modApk, fileInfoList, vancedVersionCode, context)) {
|
||||
sendRefresh(context)
|
||||
vancedProgress.get()?.showInstallCircle?.set(false)
|
||||
mutableInstall.value = false
|
||||
}
|
||||
}
|
||||
else {
|
||||
sendFailure(listOf("Files_Missing_VA").toMutableList(), context)
|
||||
sendFailure(listOf("ModApk_Missing").toMutableList(), context)
|
||||
}
|
||||
}
|
||||
else {
|
||||
sendFailure(listOf("Files_Missing_VA").toMutableList(), context)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -244,7 +244,7 @@ object PackageHelper {
|
|||
sessionId = Integer.parseInt(sessionIdMatcher.group(1)!!)
|
||||
}
|
||||
apkFiles.forEach { apkFile ->
|
||||
if(apkFile.name != "black.apk" && apkFile.name != "dark.apk" && apkFile.name != "hash.json") {
|
||||
if (apkFile.name != "black.apk" && apkFile.name != "dark.apk" && apkFile.name != "hash.json") {
|
||||
Log.d("AppLog", "installing APK : ${apkFile.name} ${apkFile.fileSize} ")
|
||||
val command = arrayOf("su", "-c", "pm", "install-write", "-S", "${apkFile.fileSize}", "$sessionId", apkFile.name)
|
||||
val process: Process = Runtime.getRuntime().exec(command)
|
||||
|
@ -268,6 +268,7 @@ object PackageHelper {
|
|||
return true
|
||||
} else
|
||||
sendFailure(installResult.out, context)
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
|
@ -357,7 +358,8 @@ object PackageHelper {
|
|||
private fun linkVanced(apkFPath: String, path: String): Boolean
|
||||
{
|
||||
Shell.su("am force-stop $yPkg").exec()
|
||||
val umountv = Shell.su("""for i in ${'$'}(ls /data/app/ | grep com.google.android.youtube | tr " "); do umount -l "/data/app/${"$"}i/base.apk"; done """)
|
||||
val umountv = Shell.su("""for i in ${'$'}(ls /data/app/ | grep com.google.android.youtube | tr " "); do umount -l "/data/app/${"$"}i/base.apk"; done """).exec()
|
||||
Log.d("umountTest", Shell.su("grep com.google.android.youtube").exec().out.joinToString(" "))
|
||||
val response = Shell.su("""su -mm -c "mount -o bind $apkFPath $path"""").exec()
|
||||
Thread.sleep(500)
|
||||
return response.isSuccess
|
||||
|
|
|
@ -46,6 +46,8 @@
|
|||
<string name="link_title">Use Chrome Custom Tabs</string>
|
||||
<string name="link_custom_tabs">Links will open in Chrome Custom Tabs</string>
|
||||
<string name="link_external_browser">Links will open in an External Browser</string>
|
||||
<string name="new_installer_title">Use the new root installer (Experimental)</string>
|
||||
<string name="new_installer_summary">This installer does not depend on Signature Verification status. WARNING: Vanced may disappear after reboot if you install it using this</string>
|
||||
<string name="theme">Theme</string>
|
||||
<string name="theme_follow">Follow System</string>
|
||||
<string name="theme_dark">Dark Theme</string>
|
||||
|
|
|
@ -73,8 +73,4 @@
|
|||
|
||||
</PreferenceCategory>
|
||||
|
||||
<Preference
|
||||
android:key="open_about"
|
||||
android:title="@string/title_about" />
|
||||
|
||||
</PreferenceScreen>
|
|
@ -1,18 +1,18 @@
|
|||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
buildscript {
|
||||
ext.kotlin_version = '1.3.72'
|
||||
ext.kotlin_version = '1.4.10'
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:4.0.1'
|
||||
classpath 'com.android.tools.build:gradle:4.1.0-rc03'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath 'com.google.gms:google-services:4.3.3'
|
||||
classpath 'com.google.firebase:perf-plugin:1.3.1'
|
||||
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.2.0'
|
||||
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.3.0'
|
||||
classpath 'androidx.navigation:navigation-safe-args-gradle-plugin:2.3.0'
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
|
|
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,6 +1,6 @@
|
|||
#Tue Jun 30 22:45:27 BST 2020
|
||||
#Sat Sep 19 22:19:33 GET 2020
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-all.zip
|
||||
|
|
Loading…
Reference in a new issue