bug fixes

This commit is contained in:
X1nto 2020-06-20 19:11:24 +04:00
parent aed77c09cd
commit 4d60373c89
9 changed files with 74 additions and 34 deletions

View File

@ -72,15 +72,15 @@
<content url="file://$MODULE_DIR$"> <content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/build/generated/renderscript_source_output_dir/debug/out" isTestSource="false" generated="true" /> <sourceFolder url="file://$MODULE_DIR$/build/generated/renderscript_source_output_dir/debug/out" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/kaptKotlin/debug" isTestSource="false" generated="true" /> <sourceFolder url="file://$MODULE_DIR$/build/generated/source/kaptKotlin/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/aidl_source_output_dir/debug/out" isTestSource="false" generated="true" /> <sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/kapt/debug" isTestSource="false" generated="true" /> <sourceFolder url="file://$MODULE_DIR$/build/generated/source/kapt/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/ap_generated_sources/debug/out" isTestSource="false" generated="true" /> <sourceFolder url="file://$MODULE_DIR$/build/generated/ap_generated_sources/debug/out" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" /> <sourceFolder url="file://$MODULE_DIR$/build/generated/aidl_source_output_dir/debug/out" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" generated="true" /> <sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/ap_generated_sources/debugAndroidTest/out" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/aidl_source_output_dir/debugAndroidTest/out" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/kapt/debugAndroidTest" isTestSource="true" generated="true" /> <sourceFolder url="file://$MODULE_DIR$/build/generated/source/kapt/debugAndroidTest" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/ap_generated_sources/debugAndroidTest/out" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/aidl_source_output_dir/debugAndroidTest/out" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/renderscript_source_output_dir/debugAndroidTest/out" isTestSource="true" generated="true" /> <sourceFolder url="file://$MODULE_DIR$/build/generated/renderscript_source_output_dir/debugAndroidTest/out" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/debug" type="java-test-resource" generated="true" /> <sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/debug" type="java-test-resource" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/kapt/debugUnitTest" isTestSource="true" generated="true" /> <sourceFolder url="file://$MODULE_DIR$/build/generated/source/kapt/debugUnitTest" isTestSource="true" generated="true" />

View File

@ -10,11 +10,14 @@
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application <application
android:allowBackup="false"
android:fullBackupContent="false"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:label="@string/app_name" android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true"
android:usesCleartextTraffic="true" android:usesCleartextTraffic="true"
android:theme="@style/LightTheme.Blue"
tools:ignore="UnusedAttribute"> tools:ignore="UnusedAttribute">
<activity <activity

View File

@ -50,11 +50,14 @@ class MicrogDownloadService: Service() {
val intent = Intent(HomeFragment.MICROG_DOWNLOADING) val intent = Intent(HomeFragment.MICROG_DOWNLOADING)
intent.action = HomeFragment.MICROG_DOWNLOADING intent.action = HomeFragment.MICROG_DOWNLOADING
intent.putExtra("microgProgress", progress.percent().toInt()) intent.putExtra("microgProgress", progress.percent().toInt())
intent.putExtra("fileName", "Downloading ${getFileNameFromUrl(dwnldUrl)}...")
LocalBroadcastManager.getInstance(this).sendBroadcast(intent) LocalBroadcastManager.getInstance(this).sendBroadcast(intent)
}, },
onComplete = { onComplete = {
val intent = Intent(HomeFragment.MICROG_DOWNLOADED)
intent.action = HomeFragment.MICROG_DOWNLOADED
LocalBroadcastManager.getInstance(this).sendBroadcast(intent)
prefs?.edit()?.putBoolean("isMicrogDownloading", false)?.apply() prefs?.edit()?.putBoolean("isMicrogDownloading", false)?.apply()
installMicrog(this)
}, },
onError = { throwable -> onError = { throwable ->
val intent = Intent(HomeFragment.DOWNLOAD_ERROR) val intent = Intent(HomeFragment.DOWNLOAD_ERROR)

View File

@ -24,17 +24,16 @@ class VancedDownloadService: Service() {
private var disposable: Disposable? = null private var disposable: Disposable? = null
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
downloadSplits("arch") downloadSplits()
return START_NOT_STICKY return START_NOT_STICKY
} }
private fun downloadSplits( private fun downloadSplits(
type: String type: String = "arch"
) { ) {
val prefs = getSharedPreferences("installPrefs", Context.MODE_PRIVATE) val prefs = getSharedPreferences("installPrefs", Context.MODE_PRIVATE)
prefs?.edit()?.putBoolean("isVancedDownloading", true)?.apply() prefs?.edit()?.putBoolean("isVancedDownloading", true)?.apply()
val variant = PreferenceManager.getDefaultSharedPreferences(this) val variant = PreferenceManager.getDefaultSharedPreferences(this).getString("vanced_variant", "nonroot")
.getString("vanced_variant", "nonroot")
val lang = prefs?.getString("lang", "en") val lang = prefs?.getString("lang", "en")
val theme = prefs?.getString("theme", "dark") val theme = prefs?.getString("theme", "dark")
val arch = val arch =
@ -70,9 +69,13 @@ class VancedDownloadService: Service() {
val intent = Intent(HomeFragment.VANCED_DOWNLOADING) val intent = Intent(HomeFragment.VANCED_DOWNLOADING)
intent.action = HomeFragment.VANCED_DOWNLOADING intent.action = HomeFragment.VANCED_DOWNLOADING
intent.putExtra("vancedProgress", progress.percent().toInt()) intent.putExtra("vancedProgress", progress.percent().toInt())
intent.putExtra("fileName", "Downloading ${getFileNameFromUrl(url)}...")
LocalBroadcastManager.getInstance(this).sendBroadcast(intent) LocalBroadcastManager.getInstance(this).sendBroadcast(intent)
}, },
onComplete = { onComplete = {
val intent = Intent(HomeFragment.MICROG_DOWNLOADED)
intent.action = HomeFragment.MICROG_DOWNLOADED
LocalBroadcastManager.getInstance(this).sendBroadcast(intent)
when (type) { when (type) {
"arch" -> downloadSplits("theme") "arch" -> downloadSplits("theme")
"theme" -> downloadSplits("lang") "theme" -> downloadSplits("lang")

View File

@ -1,7 +1,6 @@
package com.vanced.manager.core.installer package com.vanced.manager.core.installer
import android.app.Activity import android.app.Activity
import android.content.Context
import android.content.Intent import android.content.Intent
import android.net.Uri import android.net.Uri
import android.os.Build import android.os.Build
@ -14,21 +13,21 @@ import zlc.season.rxdownload4.utils.getFileNameFromUrl
object MicrogInstaller { object MicrogInstaller {
fun installMicrog(context: Context) { fun installMicrog(activity: Activity) {
val apkUrl = GetJson().AsJSONObject("https://x1nto.github.io/VancedFiles/microg.json") val apkUrl = GetJson().AsJSONObject("https://x1nto.github.io/VancedFiles/microg.json")
val dwnldUrl = apkUrl.get("url").asString val dwnldUrl = apkUrl.get("url").asString
val task = context.filesDir?.path?.let { val task = activity.filesDir?.path?.let {
Task( Task(
url = dwnldUrl, url = dwnldUrl,
saveName = getFileNameFromUrl(dwnldUrl), saveName = getFileNameFromUrl(dwnldUrl),
savePath = it savePath = it
) )
} }
val pn = context.packageName val pn = activity.packageName
val apk = task?.file() val apk = task?.file()
val uri = val uri =
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
context.let { FileProvider.getUriForFile(it, "$pn.provider", apk!!) } activity.let { FileProvider.getUriForFile(it, "$pn.provider", apk!!) }
} else } else
Uri.fromFile(apk) Uri.fromFile(apk)
val mIntent = Intent(Intent.ACTION_VIEW) val mIntent = Intent(Intent.ACTION_VIEW)
@ -36,7 +35,7 @@ object MicrogInstaller {
mIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) mIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
mIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) mIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
mIntent.putExtra(Intent.EXTRA_RETURN_RESULT, true) mIntent.putExtra(Intent.EXTRA_RETURN_RESULT, true)
Activity().startActivityForResult(mIntent, BaseFragment.MICROG_INSTALL) activity.startActivityForResult(mIntent, BaseFragment.MICROG_INSTALL)
} }
} }

View File

@ -12,6 +12,7 @@ import android.os.Bundle
import android.util.Log import android.util.Log
import android.view.* import android.view.*
import android.widget.ProgressBar import android.widget.ProgressBar
import android.widget.TextView
import android.widget.Toast import android.widget.Toast
import androidx.core.animation.addListener import androidx.core.animation.addListener
import androidx.databinding.DataBindingUtil import androidx.databinding.DataBindingUtil
@ -29,6 +30,7 @@ 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.MicrogInstaller.installMicrog
import com.vanced.manager.core.installer.RootAppUninstaller import com.vanced.manager.core.installer.RootAppUninstaller
import com.vanced.manager.databinding.FragmentHomeBinding import com.vanced.manager.databinding.FragmentHomeBinding
import com.vanced.manager.ui.MainActivity import com.vanced.manager.ui.MainActivity
@ -63,11 +65,11 @@ class HomeFragment : Home() {
val viewModel: HomeViewModel by viewModels() val viewModel: HomeViewModel by viewModels()
binding.viewModel = viewModel binding.viewModel = viewModel
val variantPref = getDefaultSharedPreferences(activity).getString("vanced_variant", "Nonroot") val variantPref = getDefaultSharedPreferences(activity).getString("vanced_variant", "nonroot")
//val signatureStatus = getDefaultSharedPreferences(activity).getString("signature_status", "unavailable") //val signatureStatus = getDefaultSharedPreferences(activity).getString("signature_status", "unavailable")
registerReceivers() registerReceivers()
if (variantPref == "Root") { if (variantPref == "noot") {
attachRootChangelog() attachRootChangelog()
} else } else
attachNonrootChangelog() attachNonrootChangelog()
@ -81,7 +83,7 @@ class HomeFragment : Home() {
private fun initNetworkFun() { private fun initNetworkFun() {
val pm = activity?.packageManager val pm = activity?.packageManager
val variant = getDefaultSharedPreferences(activity).getString("vanced_variant", "Nonroot") val variant = getDefaultSharedPreferences(activity).getString("vanced_variant", "nonroot")
val microgStatus = pm?.let { isPackageInstalled("com.mgoogle.android.gms", it) } val microgStatus = pm?.let { isPackageInstalled("com.mgoogle.android.gms", it) }
val vancedStatus = val vancedStatus =
if (variant == "Root") { if (variant == "Root") {
@ -108,7 +110,7 @@ class HomeFragment : Home() {
GetJson().AsJSONObject("https://vanced.app/api/v1/microg.json") GetJson().AsJSONObject("https://vanced.app/api/v1/microg.json")
.get("versionCode").asInt .get("versionCode").asInt
if (variant == "Nonroot") { if (variant == "nonroot") {
val microginstallbtn = val microginstallbtn =
view?.findViewById<MaterialButton>(R.id.microg_installbtn) view?.findViewById<MaterialButton>(R.id.microg_installbtn)
microginstallbtn?.visibility = View.VISIBLE microginstallbtn?.visibility = View.VISIBLE
@ -142,7 +144,7 @@ class HomeFragment : Home() {
if (vancedStatus!!) { if (vancedStatus!!) {
val vanPkgName = val vanPkgName =
if (variant == "Root") if (variant == "root")
"com.google.android.youtube" "com.google.android.youtube"
else else
"com.vanced.android.youtube" "com.vanced.android.youtube"
@ -196,7 +198,7 @@ class HomeFragment : Home() {
start() start()
} }
} else { } else {
if (variant == "Nonroot") { if (variant == "nonroot") {
view?.findViewById<MaterialButton>(R.id.microg_installbtn)?.visibility = View.INVISIBLE view?.findViewById<MaterialButton>(R.id.microg_installbtn)?.visibility = View.INVISIBLE
} }
@ -246,26 +248,43 @@ class HomeFragment : Home() {
val mIntent = Intent(activity, RootAppUninstaller::class.java) val mIntent = Intent(activity, RootAppUninstaller::class.java)
mIntent.putExtra("Data", "com.vanced.stub") mIntent.putExtra("Data", "com.vanced.stub")
activity?.startService(mIntent) activity?.startService(mIntent)
//activity?.recreate() activity?.recreate()
} }
SIGNATURE_ENABLED -> { SIGNATURE_ENABLED -> {
activity?.runOnUiThread { activity?.runOnUiThread {
viewModel.signatureStatusTxt.value = getString(R.string.signature_enabled) viewModel.signatureStatusTxt.value = getString(R.string.signature_enabled)
} }
//activity?.recreate() 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)
val downloadTxt = intent.getStringExtra("fileName")
val txt = view?.findViewById<TextView>(R.id.microg_downloading)
txt?.visibility = View.VISIBLE
txt?.text = downloadTxt
progressbar?.visibility = View.VISIBLE progressbar?.visibility = View.VISIBLE
progressbar?.progress = progress progressbar?.progress = progress
} }
VANCED_DOWNLOADING -> { VANCED_DOWNLOADING -> {
val progress = intent.getIntExtra("vancedProgress", 0) val progress = intent.getIntExtra("vancedProgress", 0)
val progressbar = view?.findViewById<ProgressBar>(R.id.vanced_progress) val progressbar = view?.findViewById<ProgressBar>(R.id.vanced_progress)
val downloadTxt = intent.getStringExtra("fileName")
val txt = view?.findViewById<TextView>(R.id.vanced_downloading)
txt?.visibility = View.VISIBLE
txt?.text = downloadTxt
progressbar?.visibility = View.VISIBLE progressbar?.visibility = View.VISIBLE
progressbar?.progress = progress progressbar?.progress = progress
} }
MICROG_DOWNLOADED -> {
view?.findViewById<TextView>(R.id.microg_downloading)?.visibility = View.GONE
view?.findViewById<ProgressBar>(R.id.microg_progress)?.visibility = View.GONE
activity?.let { installMicrog(it) }
}
VANCED_DOWNLOADED -> {
view?.findViewById<TextView>(R.id.vanced_downloading)?.visibility = View.GONE
view?.findViewById<ProgressBar>(R.id.vanced_progress)?.visibility = View.GONE
}
DOWNLOAD_ERROR -> { DOWNLOAD_ERROR -> {
val error = intent.getStringExtra("DownloadError") as String val error = intent.getStringExtra("DownloadError") as String
Toast.makeText(activity, error, Toast.LENGTH_SHORT).show() Toast.makeText(activity, error, Toast.LENGTH_SHORT).show()
@ -299,6 +318,18 @@ class HomeFragment : Home() {
) )
) )
} }
activity?.let {
LocalBroadcastManager.getInstance(it).registerReceiver(broadcastReceiver, IntentFilter(
VANCED_DOWNLOADED
)
)
}
activity?.let {
LocalBroadcastManager.getInstance(it).registerReceiver(broadcastReceiver, IntentFilter(
MICROG_DOWNLOADED
)
)
}
activity?.let { activity?.let {
LocalBroadcastManager.getInstance(it).registerReceiver(broadcastReceiver, IntentFilter( LocalBroadcastManager.getInstance(it).registerReceiver(broadcastReceiver, IntentFilter(
DOWNLOAD_ERROR DOWNLOAD_ERROR
@ -361,6 +392,8 @@ class HomeFragment : Home() {
const val SIGNATURE_ENABLED = "Signature verification enabled" 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 MICROG_DOWNLOADED = "MicroG downloaded"
const val DOWNLOAD_ERROR = "Error occurred" const val DOWNLOAD_ERROR = "Error occurred"
} }

View File

@ -10,7 +10,6 @@ import androidx.browser.customtabs.CustomTabsIntent
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.core.content.ContextCompat.startActivity import androidx.core.content.ContextCompat.startActivity
import androidx.lifecycle.AndroidViewModel import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import androidx.preference.PreferenceManager.getDefaultSharedPreferences import androidx.preference.PreferenceManager.getDefaultSharedPreferences
import com.dezlum.codelabs.getjson.GetJson import com.dezlum.codelabs.getjson.GetJson
@ -22,7 +21,7 @@ open class HomeViewModel(application: Application): AndroidViewModel(application
private val connected: Boolean = GetJson().isConnected(application) private val connected: Boolean = GetJson().isConnected(application)
private val vancedPkgName: String = private val vancedPkgName: String =
if (getDefaultSharedPreferences(application).getString("vanced_variant", "Nonroot") == "Root") { if (getDefaultSharedPreferences(application).getString("vanced_variant", "nonroot") == "root") {
"com.google.android.youtube" "com.google.android.youtube"
} else { } else {
"com.vanced.android.youtube" "com.vanced.android.youtube"
@ -61,9 +60,9 @@ open class HomeViewModel(application: Application): AndroidViewModel(application
else else
application.getString(R.string.unavailable) application.getString(R.string.unavailable)
val isNonrootModeSelected: Boolean = getDefaultSharedPreferences(application).getString("vanced_variant", "Nonroot") == "Nonroot" val isNonrootModeSelected: Boolean = getDefaultSharedPreferences(application).getString("vanced_variant", "nonroot") == "nonroot"
val signatureString = application.getString(R.string.unavailable) private val signatureString = application.getString(R.string.unavailable)
val signatureStatusTxt: MutableLiveData<String> = MutableLiveData() val signatureStatusTxt: MutableLiveData<String> = MutableLiveData()
fun openMicrogSettings() { fun openMicrogSettings() {

View File

@ -20,15 +20,15 @@ object PackageHelper {
} }
} }
fun uninstallApp(pkgName: String, context: Context) { fun uninstallApp(pkgName: String, activity: Activity) {
try { try {
val uri = Uri.parse("package:$pkgName") val uri = Uri.parse("package:$pkgName")
val uninstall = Intent(Intent.ACTION_DELETE, uri) val uninstall = Intent(Intent.ACTION_DELETE, uri)
uninstall.flags = Intent.FLAG_ACTIVITY_NEW_TASK uninstall.flags = Intent.FLAG_ACTIVITY_NEW_TASK
uninstall.putExtra(Intent.EXTRA_RETURN_RESULT, true) uninstall.putExtra(Intent.EXTRA_RETURN_RESULT, true)
Activity().startActivityForResult(uninstall, BaseFragment.APP_UNINSTALL) activity.startActivityForResult(uninstall, BaseFragment.APP_UNINSTALL)
} catch (e: ActivityNotFoundException) { } catch (e: ActivityNotFoundException) {
Toast.makeText(context, "Failed to uninstall", Toast.LENGTH_SHORT).show() Toast.makeText(activity, "Failed to uninstall", Toast.LENGTH_SHORT).show()
} }
} }
} }

View File

@ -30,13 +30,13 @@
</string-array> </string-array>
<string-array name="vanced_variant"> <string-array name="vanced_variant">
<item>Non-root</item> <item>Nonroot</item>
<item>Root</item> <item>Root</item>
</string-array> </string-array>
<string-array name="vanced_variant_values"> <string-array name="vanced_variant_values">
<item>Nonroot</item> <item>nonroot</item>
<item>Root</item> <item>root</item>
</string-array> </string-array>
<string-array name="syke"> <string-array name="syke">