mirror of
https://github.com/YTVanced/VancedManager
synced 2024-11-27 13:33:00 +00:00
Fixed bugs and improved performance
This commit is contained in:
parent
7b628da170
commit
c95a0eaf2b
21 changed files with 112 additions and 137 deletions
|
@ -67,7 +67,7 @@ dependencies {
|
||||||
implementation 'androidx.activity:activity:1.1.0'
|
implementation 'androidx.activity:activity:1.1.0'
|
||||||
implementation 'androidx.appcompat:appcompat:1.2.0'
|
implementation 'androidx.appcompat:appcompat:1.2.0'
|
||||||
implementation 'androidx.browser:browser:1.2.0'
|
implementation 'androidx.browser:browser:1.2.0'
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.0'
|
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
|
||||||
implementation 'androidx.core:core-ktx:1.3.1'
|
implementation 'androidx.core:core-ktx:1.3.1'
|
||||||
implementation 'androidx.fragment:fragment-ktx:1.2.5'
|
implementation 'androidx.fragment:fragment-ktx:1.2.5'
|
||||||
implementation 'androidx.lifecycle:lifecycle-livedata-core-ktx:2.2.0'
|
implementation 'androidx.lifecycle:lifecycle-livedata-core-ktx:2.2.0'
|
||||||
|
|
|
@ -7,6 +7,7 @@ import com.crowdin.platform.Crowdin
|
||||||
import com.crowdin.platform.CrowdinConfig
|
import com.crowdin.platform.CrowdinConfig
|
||||||
import com.crowdin.platform.data.remote.NetworkType
|
import com.crowdin.platform.data.remote.NetworkType
|
||||||
import com.downloader.PRDownloader
|
import com.downloader.PRDownloader
|
||||||
|
import com.vanced.manager.utils.InternetTools.baseUrl
|
||||||
import com.vanced.manager.utils.JsonHelper.getJson
|
import com.vanced.manager.utils.JsonHelper.getJson
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
@ -14,33 +15,31 @@ import kotlinx.coroutines.launch
|
||||||
|
|
||||||
open class App: Application() {
|
open class App: Application() {
|
||||||
|
|
||||||
lateinit var vanced : JsonObject
|
var vanced: JsonObject? = null
|
||||||
lateinit var music: JsonObject
|
var music: JsonObject? = null
|
||||||
lateinit var microg: JsonObject
|
var microg: JsonObject? = null
|
||||||
lateinit var manager: JsonObject
|
var manager: JsonObject? = null
|
||||||
|
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
loadJson()
|
loadJson()
|
||||||
super.onCreate()
|
super.onCreate()
|
||||||
PRDownloader.initialize(this)
|
PRDownloader.initialize(this)
|
||||||
|
|
||||||
//if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
|
|
||||||
Crowdin.init(this,
|
Crowdin.init(this,
|
||||||
CrowdinConfig.Builder()
|
CrowdinConfig.Builder()
|
||||||
.withDistributionHash("36c51aed3180a4f43073d28j4s6")
|
.withDistributionHash("36c51aed3180a4f43073d28j4s6")
|
||||||
.withNetworkType(NetworkType.WIFI)
|
.withNetworkType(NetworkType.WIFI)
|
||||||
.build()
|
.build()
|
||||||
)
|
)
|
||||||
//}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun loadJson() = CoroutineScope(Dispatchers.IO).launch {
|
fun loadJson() = CoroutineScope(Dispatchers.IO).launch {
|
||||||
val latest = getJson("https://vanced.app/api/v1/latest.json")
|
val latest = getJson("$baseUrl/latest.json")
|
||||||
vanced = latest.obj("vanced")!!
|
vanced = latest.obj("vanced")
|
||||||
music = latest.obj("music")!!
|
music = latest.obj("music")
|
||||||
microg = latest.obj("microg")!!
|
microg = latest.obj("microg")
|
||||||
manager = latest.obj("manager")!!
|
manager = latest.obj("manager")
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onConfigurationChanged(newConfig: Configuration) {
|
override fun onConfigurationChanged(newConfig: Configuration) {
|
||||||
|
|
|
@ -29,21 +29,22 @@ object MicrogDownloader {
|
||||||
.build()
|
.build()
|
||||||
.setOnStartOrResumeListener {
|
.setOnStartOrResumeListener {
|
||||||
installing = true
|
installing = true
|
||||||
microgProgress.get()?.setDownloadingFile(getFileNameFromUrl(url))
|
microgProgress.get()?.downloadingFile?.set(context.getString(R.string.downloading_file, getFileNameFromUrl(url)))
|
||||||
microgProgress.get()?.showDownloadBar = true
|
microgProgress.get()?.showDownloadBar?.set(true)
|
||||||
}
|
}
|
||||||
.setOnProgressListener { progress ->
|
.setOnProgressListener { progress ->
|
||||||
microgProgress.get()?.setDownloadProgress((progress.currentBytes * 100 / progress.totalBytes).toInt())
|
microgProgress.get()?.downloadProgress?.set((progress.currentBytes * 100 / progress.totalBytes).toInt())
|
||||||
}
|
}
|
||||||
.start(object : OnDownloadListener {
|
.start(object : OnDownloadListener {
|
||||||
override fun onDownloadComplete() {
|
override fun onDownloadComplete() {
|
||||||
install("microg", "${context.getExternalFilesDir("apk")}/microg.apk", context)
|
install("microg", "${context.getExternalFilesDir("apk")}/microg.apk", context)
|
||||||
microgProgress.get()?.showDownloadBar = false
|
microgProgress.get()?.showDownloadBar?.set(false)
|
||||||
microgProgress.get()?.showInstallCircle = true
|
microgProgress.get()?.showInstallCircle?.set(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onError(error: Error?) {
|
override fun onError(error: Error?) {
|
||||||
installing = false
|
installing = false
|
||||||
|
microgProgress.get()?.showDownloadBar?.set(false)
|
||||||
Toast.makeText(context, context.getString(R.string.error_downloading, "microG"), Toast.LENGTH_SHORT).show()
|
Toast.makeText(context, context.getString(R.string.error_downloading, "microG"), Toast.LENGTH_SHORT).show()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -30,21 +30,22 @@ object MusicDownloader {
|
||||||
.build()
|
.build()
|
||||||
.setOnStartOrResumeListener {
|
.setOnStartOrResumeListener {
|
||||||
installing = true
|
installing = true
|
||||||
musicProgress.get()?.setDownloadingFile(getFileNameFromUrl(url))
|
musicProgress.get()?.downloadingFile?.set(context.getString(R.string.downloading_file, getFileNameFromUrl(url)))
|
||||||
musicProgress.get()?.showDownloadBar = true
|
musicProgress.get()?.showDownloadBar?.set(true)
|
||||||
}
|
}
|
||||||
.setOnProgressListener { progress ->
|
.setOnProgressListener { progress ->
|
||||||
musicProgress.get()?.setDownloadProgress((progress.currentBytes * 100 / progress.totalBytes).toInt())
|
musicProgress.get()?.downloadProgress?.set((progress.currentBytes * 100 / progress.totalBytes).toInt())
|
||||||
}
|
}
|
||||||
.start(object : OnDownloadListener {
|
.start(object : OnDownloadListener {
|
||||||
override fun onDownloadComplete() {
|
override fun onDownloadComplete() {
|
||||||
install("music", "${context.getExternalFilesDir("apk")}/music.apk", context)
|
install("music", "${context.getExternalFilesDir("apk")}/music.apk", context)
|
||||||
musicProgress.get()?.showDownloadBar = false
|
musicProgress.get()?.showDownloadBar?.set(false)
|
||||||
musicProgress.get()?.showInstallCircle = true
|
musicProgress.get()?.showInstallCircle?.set(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onError(error: Error?) {
|
override fun onError(error: Error?) {
|
||||||
installing = false
|
installing = false
|
||||||
|
musicProgress.get()?.showDownloadBar?.set(false)
|
||||||
Toast.makeText(context, context.getString(R.string.error_downloading, "Music"), Toast.LENGTH_SHORT).show()
|
Toast.makeText(context, context.getString(R.string.error_downloading, "Music"), Toast.LENGTH_SHORT).show()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -37,7 +37,7 @@ object VancedDownloader {
|
||||||
private var variant: String? = null
|
private var variant: String? = null
|
||||||
private var theme: String? = null
|
private var theme: String? = null
|
||||||
private var lang: Array<String>? = null
|
private var lang: Array<String>? = null
|
||||||
private var newInstaller: Boolean? = null
|
//private var newInstaller: Boolean? = null
|
||||||
|
|
||||||
private lateinit var themePath: String
|
private lateinit var themePath: String
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ object VancedDownloader {
|
||||||
theme = prefs.getString("theme", "dark")
|
theme = prefs.getString("theme", "dark")
|
||||||
themePath = "$installUrl/apks/v$vancedVersion/$variant/Theme"
|
themePath = "$installUrl/apks/v$vancedVersion/$variant/Theme"
|
||||||
hashUrl = "apks/v$vancedVersion/$variant/Theme/hash.json"
|
hashUrl = "apks/v$vancedVersion/$variant/Theme/hash.json"
|
||||||
newInstaller = defPrefs.getBoolean("new_installer", false)
|
//newInstaller = defPrefs.getBoolean("new_installer", false)
|
||||||
arch =
|
arch =
|
||||||
when {
|
when {
|
||||||
Build.SUPPORTED_ABIS.contains("x86") -> "x86"
|
Build.SUPPORTED_ABIS.contains("x86") -> "x86"
|
||||||
|
@ -95,17 +95,17 @@ object VancedDownloader {
|
||||||
.build()
|
.build()
|
||||||
.setOnStartOrResumeListener {
|
.setOnStartOrResumeListener {
|
||||||
installing = true
|
installing = true
|
||||||
vancedProgress.get()?.setDownloadingFile(getFileNameFromUrl(url))
|
vancedProgress.get()?.downloadingFile?.set(context.getString(R.string.downloading_file, getFileNameFromUrl(url)))
|
||||||
vancedProgress.get()?.showDownloadBar = true
|
vancedProgress.get()?.showDownloadBar?.set(true)
|
||||||
}
|
}
|
||||||
.setOnProgressListener { progress ->
|
.setOnProgressListener { progress ->
|
||||||
vancedProgress.get()?.setDownloadProgress((progress.currentBytes * 100 / progress.totalBytes).toInt())
|
vancedProgress.get()?.downloadProgress?.set((progress.currentBytes * 100 / progress.totalBytes).toInt())
|
||||||
}
|
}
|
||||||
.start(object : OnDownloadListener {
|
.start(object : OnDownloadListener {
|
||||||
override fun onDownloadComplete() {
|
override fun onDownloadComplete() {
|
||||||
when (type) {
|
when (type) {
|
||||||
"theme" ->
|
"theme" ->
|
||||||
if (variant == "root" && newInstaller == true) {
|
if (variant == "root") {
|
||||||
if (validateTheme(context)) {
|
if (validateTheme(context)) {
|
||||||
if(downloadStockCheck(context))
|
if(downloadStockCheck(context))
|
||||||
downloadSplits(context, "arch")
|
downloadSplits(context, "arch")
|
||||||
|
@ -115,7 +115,7 @@ object VancedDownloader {
|
||||||
downloadSplits(context, "theme")
|
downloadSplits(context, "theme")
|
||||||
} else
|
} else
|
||||||
downloadSplits(context, "arch")
|
downloadSplits(context, "arch")
|
||||||
"arch" -> if (variant == "root" && newInstaller == true) downloadSplits(context, "stock") else downloadSplits(context, "lang")
|
"arch" -> if (variant == "root") downloadSplits(context, "stock") else downloadSplits(context, "lang")
|
||||||
"stock" -> downloadSplits(context, "dpi")
|
"stock" -> downloadSplits(context, "dpi")
|
||||||
"dpi" -> downloadSplits(context, "lang")
|
"dpi" -> downloadSplits(context, "lang")
|
||||||
"lang" -> {
|
"lang" -> {
|
||||||
|
@ -137,6 +137,7 @@ object VancedDownloader {
|
||||||
prepareInstall(variant!!, context)
|
prepareInstall(variant!!, context)
|
||||||
} else {
|
} else {
|
||||||
installing = false
|
installing = false
|
||||||
|
vancedProgress.get()?.showDownloadBar?.set(false)
|
||||||
Toast.makeText(context, context.getString(R.string.error_downloading, "Vanced"), Toast.LENGTH_SHORT).show()
|
Toast.makeText(context, context.getString(R.string.error_downloading, "Vanced"), Toast.LENGTH_SHORT).show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -194,8 +195,8 @@ object VancedDownloader {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private fun prepareInstall(variant: String, context: Context) {
|
private fun prepareInstall(variant: String, context: Context) {
|
||||||
vancedProgress.get()?.showDownloadBar = false
|
vancedProgress.get()?.showDownloadBar?.set(false)
|
||||||
vancedProgress.get()?.showInstallCircle = true
|
vancedProgress.get()?.showInstallCircle?.set(true)
|
||||||
if (variant == "root")
|
if (variant == "root")
|
||||||
installVancedRoot(context)
|
installVancedRoot(context)
|
||||||
else
|
else
|
||||||
|
|
|
@ -8,6 +8,7 @@ import android.util.Log
|
||||||
import com.vanced.manager.ui.viewmodels.HomeViewModel.Companion.microgProgress
|
import com.vanced.manager.ui.viewmodels.HomeViewModel.Companion.microgProgress
|
||||||
import com.vanced.manager.ui.viewmodels.HomeViewModel.Companion.musicProgress
|
import com.vanced.manager.ui.viewmodels.HomeViewModel.Companion.musicProgress
|
||||||
import com.vanced.manager.utils.AppUtils.sendFailure
|
import com.vanced.manager.utils.AppUtils.sendFailure
|
||||||
|
import com.vanced.manager.utils.AppUtils.sendRefresh
|
||||||
|
|
||||||
class AppInstallerService: Service() {
|
class AppInstallerService: Service() {
|
||||||
|
|
||||||
|
@ -25,7 +26,8 @@ class AppInstallerService: Service() {
|
||||||
}
|
}
|
||||||
PackageInstaller.STATUS_SUCCESS -> {
|
PackageInstaller.STATUS_SUCCESS -> {
|
||||||
Log.d(TAG, "Installation succeed")
|
Log.d(TAG, "Installation succeed")
|
||||||
if (intent.getStringExtra("app") == "microg") microgProgress.get()?.showInstallCircle = false else musicProgress.get()?.showInstallCircle = false
|
if (intent.getStringExtra("app") == "microg") microgProgress.get()?.showInstallCircle?.set(false) else musicProgress.get()?.showInstallCircle?.set(false)
|
||||||
|
sendRefresh(this)
|
||||||
}
|
}
|
||||||
else -> sendFailure(intent.getIntExtra(PackageInstaller.EXTRA_STATUS, -999), this)
|
else -> sendFailure(intent.getIntExtra(PackageInstaller.EXTRA_STATUS, -999), this)
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ class SplitInstallerService: Service() {
|
||||||
}
|
}
|
||||||
PackageInstaller.STATUS_SUCCESS -> {
|
PackageInstaller.STATUS_SUCCESS -> {
|
||||||
Log.d(TAG, "Installation succeed")
|
Log.d(TAG, "Installation succeed")
|
||||||
vancedProgress.get()?.showInstallCircle = false
|
vancedProgress.get()?.showInstallCircle?.set(false)
|
||||||
sendRefresh(this)
|
sendRefresh(this)
|
||||||
}
|
}
|
||||||
else -> sendFailure(intent.getIntExtra(PackageInstaller.EXTRA_STATUS, -999), this)
|
else -> sendFailure(intent.getIntExtra(PackageInstaller.EXTRA_STATUS, -999), this)
|
||||||
|
|
|
@ -4,60 +4,46 @@ import android.content.Context
|
||||||
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
|
||||||
|
import androidx.databinding.ObservableBoolean
|
||||||
|
import androidx.databinding.ObservableField
|
||||||
|
import androidx.databinding.ObservableInt
|
||||||
import com.beust.klaxon.JsonObject
|
import com.beust.klaxon.JsonObject
|
||||||
import com.vanced.manager.R
|
import com.vanced.manager.R
|
||||||
import com.vanced.manager.utils.InternetTools.baseUrl
|
|
||||||
import com.vanced.manager.utils.InternetTools.getObjectFromJson
|
|
||||||
import com.vanced.manager.utils.PackageHelper.isPackageInstalled
|
import com.vanced.manager.utils.PackageHelper.isPackageInstalled
|
||||||
import kotlinx.coroutines.Dispatchers
|
|
||||||
import kotlinx.coroutines.runBlocking
|
|
||||||
|
|
||||||
open class DataModel(
|
open class DataModel(
|
||||||
private val jsonObject: JsonObject,
|
jsonObject: JsonObject?,
|
||||||
variant: String = "nonroot",
|
variant: String = "nonroot",
|
||||||
|
app: String,
|
||||||
private val context: Context
|
private val context: Context
|
||||||
) {
|
) {
|
||||||
|
|
||||||
private val appPkg =
|
private val appPkg =
|
||||||
when (jsonObject.toString()) {
|
when (app) {
|
||||||
"vanced" -> if (variant == "root") "com.google.android.youtube" else "com.vanced.android.youtube"
|
"vanced" -> if (variant == "root") "com.google.android.youtube" else "com.vanced.android.youtube"
|
||||||
"microg" -> "com.mgoogle.android.gms"
|
"microg" -> "com.mgoogle.android.gms"
|
||||||
else -> "com.vanced.android.apps.youtube.music"
|
else -> "com.vanced.android.apps.youtube.music"
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
private val versionCode = ObservableInt()
|
||||||
private var versionName: String = ""
|
private val installedVersionCode = ObservableInt()
|
||||||
private var installedVersionName: String = ""
|
|
||||||
private var changelog: String = ""
|
|
||||||
|
|
||||||
private var versionCode: Int = 0
|
val isAppInstalled = ObservableBoolean()
|
||||||
private var installedVersionCode: Int = 0
|
val versionName = ObservableField<String>()
|
||||||
*/
|
val installedVersionName = ObservableField<String>()
|
||||||
|
val buttonTxt = ObservableField<String>()
|
||||||
|
val buttonIcon = ObservableField<Drawable>()
|
||||||
|
val changelog = ObservableField<String>()
|
||||||
|
|
||||||
open fun isAppInstalled(): Boolean = isPackageInstalled(appPkg, context.packageManager)
|
init {
|
||||||
|
isAppInstalled.set(isPackageInstalled(appPkg, context.packageManager))
|
||||||
open fun getVersionName(): String = jsonObject.string("version")!!
|
versionName.set(jsonObject?.string("version")?.removeSuffix("-vanced") ?: context.getString(R.string.unavailable))
|
||||||
|
installedVersionName.set(getPkgVersionName(isAppInstalled.get(), appPkg))
|
||||||
open fun getVersionCode(): Int = jsonObject.int("versionCode")!!
|
versionCode.set(jsonObject?.int("versionCode")?: 0)
|
||||||
|
installedVersionCode.set(getPkgVersionCode(isAppInstalled.get(), appPkg))
|
||||||
open fun getInstalledVersionName(): String = runBlocking(Dispatchers.IO) {
|
buttonTxt.set(compareInt(installedVersionCode.get(), versionCode.get()))
|
||||||
getPkgVersionName(isAppInstalled(), appPkg)
|
buttonIcon.set(compareIntDrawable(installedVersionCode.get(), versionCode.get()))
|
||||||
}
|
changelog.set(jsonObject?.string("changelog") ?: context.getString(R.string.unavailable))
|
||||||
|
|
||||||
open fun getInstalledVersionCode(): Int = runBlocking(Dispatchers.IO) {
|
|
||||||
getPkgVersionCode(isAppInstalled(), appPkg)
|
|
||||||
}
|
|
||||||
|
|
||||||
open fun getButtonTxt(): String = compareInt(getInstalledVersionCode(), getVersionCode())
|
|
||||||
|
|
||||||
open fun getButtonIcon(): Drawable? = compareIntDrawable(getInstalledVersionCode(), getVersionCode())
|
|
||||||
|
|
||||||
open fun getChangelog(): String = runBlocking(Dispatchers.IO) {
|
|
||||||
when (jsonObject.toString()) {
|
|
||||||
"vanced" -> getObjectFromJson("$baseUrl/changelog/${getVersionName().replace('.', '_')}.json", "message")
|
|
||||||
"music" -> jsonObject.string("changelog")!!
|
|
||||||
else -> getObjectFromJson("https://ytvanced.github.io/VancedBackend/$jsonObject.json", "changelog")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getPkgVersionName(toCheck: Boolean, pkg: String): String {
|
private fun getPkgVersionName(toCheck: Boolean, pkg: String): String {
|
||||||
|
|
|
@ -1,27 +1,21 @@
|
||||||
package com.vanced.manager.model
|
package com.vanced.manager.model
|
||||||
|
|
||||||
|
import androidx.databinding.ObservableBoolean
|
||||||
|
import androidx.databinding.ObservableField
|
||||||
|
import androidx.databinding.ObservableInt
|
||||||
|
|
||||||
open class ProgressModel {
|
open class ProgressModel {
|
||||||
|
|
||||||
private var downloadProgress = 0
|
val downloadProgress = ObservableInt()
|
||||||
private var downloadingFile = ""
|
val downloadingFile = ObservableField<String>()
|
||||||
|
val showInstallCircle = ObservableBoolean()
|
||||||
|
var showDownloadBar = ObservableBoolean()
|
||||||
|
|
||||||
var showInstallCircle = false
|
init {
|
||||||
var showDownloadBar = false
|
downloadProgress.set(0)
|
||||||
|
downloadingFile.set("")
|
||||||
open fun getDownloadProgress(): Int {
|
showInstallCircle.set(false)
|
||||||
return downloadProgress
|
showDownloadBar.set(false)
|
||||||
}
|
|
||||||
|
|
||||||
open fun setDownloadProgress(progress: Int) {
|
|
||||||
downloadProgress = progress
|
|
||||||
}
|
|
||||||
|
|
||||||
open fun getDownloadingFile(): String {
|
|
||||||
return downloadingFile
|
|
||||||
}
|
|
||||||
|
|
||||||
open fun setDownloadingFile(file: String) {
|
|
||||||
downloadingFile = file
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,17 +57,17 @@ open class HomeFragment : Fragment(), View.OnClickListener {
|
||||||
includeChangelogsLayout.changelogButton.setOnClickListener(this@HomeFragment)
|
includeChangelogsLayout.changelogButton.setOnClickListener(this@HomeFragment)
|
||||||
|
|
||||||
includeVancedLayout.vancedCard.setOnLongClickListener {
|
includeVancedLayout.vancedCard.setOnLongClickListener {
|
||||||
versionToast("Vanced", viewModel?.vanced?.get()?.getInstalledVersionName()!!)
|
versionToast("Vanced", viewModel?.vanced?.get()?.installedVersionName?.get()!!)
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
includeMusicLayout.musicCard.setOnLongClickListener {
|
includeMusicLayout.musicCard.setOnLongClickListener {
|
||||||
versionToast("Music", viewModel?.music?.get()?.getInstalledVersionName()!!)
|
versionToast("Music", viewModel?.music?.get()?.installedVersionName?.get()!!)
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
includeMicrogLayout.microgCard.setOnLongClickListener {
|
includeMicrogLayout.microgCard.setOnLongClickListener {
|
||||||
versionToast("MicroG", viewModel?.microg?.get()?.getInstalledVersionName()!!)
|
versionToast("MicroG", viewModel?.microg?.get()?.installedVersionName?.get()!!)
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,7 @@ open class HomeFragment : Fragment(), View.OnClickListener {
|
||||||
installAlertBuilder(intent.getStringExtra("errorMsg") as String, requireActivity())
|
installAlertBuilder(intent.getStringExtra("errorMsg") as String, requireActivity())
|
||||||
installing = false
|
installing = false
|
||||||
}
|
}
|
||||||
REFRESH_HOME -> viewModel.fetchData(false)
|
REFRESH_HOME -> viewModel.fetchData()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,13 +11,11 @@ import android.widget.LinearLayout
|
||||||
import androidx.core.content.res.ResourcesCompat
|
import androidx.core.content.res.ResourcesCompat
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.navigation.findNavController
|
import androidx.navigation.findNavController
|
||||||
import androidx.preference.PreferenceManager
|
|
||||||
import com.google.android.material.button.MaterialButton
|
import com.google.android.material.button.MaterialButton
|
||||||
import com.google.android.material.checkbox.MaterialCheckBox
|
import com.google.android.material.checkbox.MaterialCheckBox
|
||||||
import com.vanced.manager.R
|
import com.vanced.manager.R
|
||||||
|
import com.vanced.manager.core.App
|
||||||
import com.vanced.manager.core.downloader.VancedDownloader.downloadVanced
|
import com.vanced.manager.core.downloader.VancedDownloader.downloadVanced
|
||||||
import com.vanced.manager.utils.InternetTools.baseUrl
|
|
||||||
import com.vanced.manager.utils.InternetTools.getArrayFromJson
|
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
@ -38,9 +36,8 @@ class VancedLanguageSelectionFragment : Fragment() {
|
||||||
@ExperimentalStdlibApi
|
@ExperimentalStdlibApi
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
CoroutineScope(Dispatchers.IO).launch {
|
val app = activity?.application as App
|
||||||
langs = getArrayFromJson("${PreferenceManager.getDefaultSharedPreferences(requireActivity()).getString("install_url", baseUrl)}/vanced.json", "langs")
|
langs = app.vanced?.array<String>("langs")?.value ?: mutableListOf("null")
|
||||||
}
|
|
||||||
loadBoxes(view.findViewById(R.id.lang_button_ll))
|
loadBoxes(view.findViewById(R.id.lang_button_ll))
|
||||||
view.findViewById<MaterialButton>(R.id.vanced_install_finish).setOnClickListener {
|
view.findViewById<MaterialButton>(R.id.vanced_install_finish).setOnClickListener {
|
||||||
val chosenLangs = mutableListOf("en")
|
val chosenLangs = mutableListOf("en")
|
||||||
|
|
|
@ -27,6 +27,7 @@ import com.vanced.manager.utils.PackageHelper.uninstallApk
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
import okhttp3.internal.wait
|
||||||
|
|
||||||
open class HomeViewModel(application: Application): AndroidViewModel(application) {
|
open class HomeViewModel(application: Application): AndroidViewModel(application) {
|
||||||
|
|
||||||
|
@ -46,15 +47,11 @@ open class HomeViewModel(application: Application): AndroidViewModel(application
|
||||||
|
|
||||||
val navigateDestination : LiveData<Event<Int>> = _navigateDestination
|
val navigateDestination : LiveData<Event<Int>> = _navigateDestination
|
||||||
|
|
||||||
fun fetchData(firstInit: Boolean) {
|
fun fetchData() {
|
||||||
CoroutineScope(Dispatchers.IO).launch {
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
fetching.set(true)
|
fetching.set(true)
|
||||||
if (!firstInit) managerApp.loadJson()
|
managerApp.loadJson()
|
||||||
Crowdin.forceUpdate(getApplication())
|
Crowdin.forceUpdate(getApplication())
|
||||||
vanced.set(DataModel(managerApp.vanced, variant, app))
|
|
||||||
microg.set(DataModel(managerApp.microg, context = app))
|
|
||||||
music.set(DataModel(managerApp.music, context = app))
|
|
||||||
manager.set(DataModel(managerApp.manager, context = app))
|
|
||||||
fetching.set(false)
|
fetching.set(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -100,7 +97,7 @@ open class HomeViewModel(application: Application): AndroidViewModel(application
|
||||||
fun installVanced() {
|
fun installVanced() {
|
||||||
if (!installing) {
|
if (!installing) {
|
||||||
if (!fetching.get()) {
|
if (!fetching.get()) {
|
||||||
if (variant == "nonroot" && !microg.get()?.isAppInstalled()!!) {
|
if (variant == "nonroot" && !microg.get()?.isAppInstalled?.get()!!) {
|
||||||
microgToast.show()
|
microgToast.show()
|
||||||
} else {
|
} else {
|
||||||
if (app.getSharedPreferences("installPrefs", Context.MODE_PRIVATE).getBoolean("valuesModified", false)) {
|
if (app.getSharedPreferences("installPrefs", Context.MODE_PRIVATE).getBoolean("valuesModified", false)) {
|
||||||
|
@ -117,7 +114,7 @@ open class HomeViewModel(application: Application): AndroidViewModel(application
|
||||||
fun installMusic() {
|
fun installMusic() {
|
||||||
if (!installing) {
|
if (!installing) {
|
||||||
if (!fetching.get()) {
|
if (!fetching.get()) {
|
||||||
if (!microg.get()?.isAppInstalled()!!) {
|
if (!microg.get()?.isAppInstalled?.get()!!) {
|
||||||
microgToast.show()
|
microgToast.show()
|
||||||
} else {
|
} else {
|
||||||
downloadMusic(getApplication())
|
downloadMusic(getApplication())
|
||||||
|
@ -145,8 +142,17 @@ open class HomeViewModel(application: Application): AndroidViewModel(application
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
fetching.set(true)
|
||||||
|
while (managerApp.manager == null)
|
||||||
|
this.wait()
|
||||||
|
vanced.set(DataModel(managerApp.vanced, variant, "vanced", app))
|
||||||
|
microg.set(DataModel(managerApp.microg, app = "microg", context = app))
|
||||||
|
music.set(DataModel(managerApp.music, app = "music", context = app))
|
||||||
|
manager.set(DataModel(managerApp.manager, app = "manager", context = app))
|
||||||
|
vancedProgress.set(ProgressModel())
|
||||||
|
musicProgress.set(ProgressModel())
|
||||||
|
microgProgress.set(ProgressModel())
|
||||||
fetching.set(false)
|
fetching.set(false)
|
||||||
fetchData(true)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ object PackageHelper {
|
||||||
val pendingIntent = PendingIntent.getService(context, 0, callbackIntent, 0)
|
val pendingIntent = PendingIntent.getService(context, 0, callbackIntent, 0)
|
||||||
val packageInstaller = context.packageManager.packageInstaller
|
val packageInstaller = context.packageManager.packageInstaller
|
||||||
val params = PackageInstaller.SessionParams(PackageInstaller.SessionParams.MODE_FULL_INSTALL)
|
val params = PackageInstaller.SessionParams(PackageInstaller.SessionParams.MODE_FULL_INSTALL)
|
||||||
params.setAppPackageName(if (app == "microg") "com.mgoogle.android.gms" else "com.vanced.android.music")
|
params.setAppPackageName(if (app == "microg") "com.mgoogle.android.gms" else "com.vanced.android.apps.youtube.music")
|
||||||
val sessionId = packageInstaller.createSession(params)
|
val sessionId = packageInstaller.createSession(params)
|
||||||
val session = packageInstaller.openSession(sessionId)
|
val session = packageInstaller.openSession(sessionId)
|
||||||
val inputStream: InputStream = FileInputStream(path)
|
val inputStream: InputStream = FileInputStream(path)
|
||||||
|
|
|
@ -7,8 +7,7 @@
|
||||||
android:id="@+id/container"
|
android:id="@+id/container"
|
||||||
android:background="?colorSurface"
|
android:background="?colorSurface"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent">
|
||||||
android:animateLayoutChanges="true">
|
|
||||||
|
|
||||||
<com.google.android.material.appbar.AppBarLayout
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
android:id="@+id/home_appbar"
|
android:id="@+id/home_appbar"
|
||||||
|
|
|
@ -18,12 +18,11 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
bind:refreshing="@{viewModel.fetching}"
|
bind:refreshing="@{viewModel.fetching}"
|
||||||
bind:onRefreshListener="@{()-> viewModel.fetchData(false)}">
|
bind:onRefreshListener="@{()-> viewModel.fetchData()}">
|
||||||
|
|
||||||
<androidx.core.widget.NestedScrollView
|
<androidx.core.widget.NestedScrollView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:animateLayoutChanges="true"
|
|
||||||
android:fillViewport="true"
|
android:fillViewport="true"
|
||||||
android:scrollbars="none">
|
android:scrollbars="none">
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<layout
|
<layout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
xmlns:tools="http://schemas.android.com/tools">
|
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<FrameLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
@ -13,13 +12,9 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:id="@+id/nav_host"
|
android:id="@+id/nav_host"
|
||||||
android:name="androidx.navigation.fragment.NavHostFragment"
|
android:name="androidx.navigation.fragment.NavHostFragment"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:defaultNavHost="true"
|
app:defaultNavHost="true"
|
||||||
app:navGraph="@navigation/mobile_navigation" />
|
app:navGraph="@navigation/mobile_navigation" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
</layout>
|
</layout>
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="1dp"
|
android:layout_marginStart="1dp"
|
||||||
android:layout_marginEnd="1dp"
|
android:layout_marginEnd="1dp"
|
||||||
android:animateLayoutChanges="true"
|
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:animateLayoutChanges="true"
|
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:animateLayoutChanges="true"
|
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
|
|
@ -15,8 +15,7 @@
|
||||||
<com.google.android.material.card.MaterialCardView
|
<com.google.android.material.card.MaterialCardView
|
||||||
style="@style/MaterialCard"
|
style="@style/MaterialCard"
|
||||||
app:contentPaddingTop="2dp"
|
app:contentPaddingTop="2dp"
|
||||||
app:contentPaddingBottom="8dp"
|
app:contentPaddingBottom="8dp">
|
||||||
android:animateLayoutChanges="true">
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:animateLayoutChanges="true"
|
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
|
Loading…
Reference in a new issue