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$">
<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/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/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/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/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/res/rs/androidTest/debug" type="java-test-resource" 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" />
<application
android:allowBackup="false"
android:fullBackupContent="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:usesCleartextTraffic="true"
android:theme="@style/LightTheme.Blue"
tools:ignore="UnusedAttribute">
<activity

View File

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

View File

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

View File

@ -1,7 +1,6 @@
package com.vanced.manager.core.installer
import android.app.Activity
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Build
@ -14,21 +13,21 @@ import zlc.season.rxdownload4.utils.getFileNameFromUrl
object MicrogInstaller {
fun installMicrog(context: Context) {
fun installMicrog(activity: Activity) {
val apkUrl = GetJson().AsJSONObject("https://x1nto.github.io/VancedFiles/microg.json")
val dwnldUrl = apkUrl.get("url").asString
val task = context.filesDir?.path?.let {
val task = activity.filesDir?.path?.let {
Task(
url = dwnldUrl,
saveName = getFileNameFromUrl(dwnldUrl),
savePath = it
)
}
val pn = context.packageName
val pn = activity.packageName
val apk = task?.file()
val uri =
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
Uri.fromFile(apk)
val mIntent = Intent(Intent.ACTION_VIEW)
@ -36,7 +35,7 @@ object MicrogInstaller {
mIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
mIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
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.view.*
import android.widget.ProgressBar
import android.widget.TextView
import android.widget.Toast
import androidx.core.animation.addListener
import androidx.databinding.DataBindingUtil
@ -29,6 +30,7 @@ import com.vanced.manager.R
import com.vanced.manager.adapter.SectionPageAdapter
import com.vanced.manager.adapter.SectionPageRootAdapter
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.databinding.FragmentHomeBinding
import com.vanced.manager.ui.MainActivity
@ -63,11 +65,11 @@ class HomeFragment : Home() {
val viewModel: HomeViewModel by viewModels()
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")
registerReceivers()
if (variantPref == "Root") {
if (variantPref == "noot") {
attachRootChangelog()
} else
attachNonrootChangelog()
@ -81,7 +83,7 @@ class HomeFragment : Home() {
private fun initNetworkFun() {
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 vancedStatus =
if (variant == "Root") {
@ -108,7 +110,7 @@ class HomeFragment : Home() {
GetJson().AsJSONObject("https://vanced.app/api/v1/microg.json")
.get("versionCode").asInt
if (variant == "Nonroot") {
if (variant == "nonroot") {
val microginstallbtn =
view?.findViewById<MaterialButton>(R.id.microg_installbtn)
microginstallbtn?.visibility = View.VISIBLE
@ -142,7 +144,7 @@ class HomeFragment : Home() {
if (vancedStatus!!) {
val vanPkgName =
if (variant == "Root")
if (variant == "root")
"com.google.android.youtube"
else
"com.vanced.android.youtube"
@ -196,7 +198,7 @@ class HomeFragment : Home() {
start()
}
} else {
if (variant == "Nonroot") {
if (variant == "nonroot") {
view?.findViewById<MaterialButton>(R.id.microg_installbtn)?.visibility = View.INVISIBLE
}
@ -246,26 +248,43 @@ class HomeFragment : Home() {
val mIntent = Intent(activity, RootAppUninstaller::class.java)
mIntent.putExtra("Data", "com.vanced.stub")
activity?.startService(mIntent)
//activity?.recreate()
activity?.recreate()
}
SIGNATURE_ENABLED -> {
activity?.runOnUiThread {
viewModel.signatureStatusTxt.value = getString(R.string.signature_enabled)
}
//activity?.recreate()
activity?.recreate()
}
MICROG_DOWNLOADING -> {
val progress = intent.getIntExtra("microgProgress", 0)
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?.progress = progress
}
VANCED_DOWNLOADING -> {
val progress = intent.getIntExtra("vancedProgress", 0)
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?.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 -> {
val error = intent.getStringExtra("DownloadError") as String
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 {
LocalBroadcastManager.getInstance(it).registerReceiver(broadcastReceiver, IntentFilter(
DOWNLOAD_ERROR
@ -361,6 +392,8 @@ class HomeFragment : Home() {
const val SIGNATURE_ENABLED = "Signature verification enabled"
const val VANCED_DOWNLOADING = "Vanced 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"
}

View File

@ -10,7 +10,6 @@ import androidx.browser.customtabs.CustomTabsIntent
import androidx.core.content.ContextCompat
import androidx.core.content.ContextCompat.startActivity
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.preference.PreferenceManager.getDefaultSharedPreferences
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 vancedPkgName: String =
if (getDefaultSharedPreferences(application).getString("vanced_variant", "Nonroot") == "Root") {
if (getDefaultSharedPreferences(application).getString("vanced_variant", "nonroot") == "root") {
"com.google.android.youtube"
} else {
"com.vanced.android.youtube"
@ -61,9 +60,9 @@ open class HomeViewModel(application: Application): AndroidViewModel(application
else
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()
fun openMicrogSettings() {

View File

@ -20,15 +20,15 @@ object PackageHelper {
}
}
fun uninstallApp(pkgName: String, context: Context) {
fun uninstallApp(pkgName: String, activity: Activity) {
try {
val uri = Uri.parse("package:$pkgName")
val uninstall = Intent(Intent.ACTION_DELETE, uri)
uninstall.flags = Intent.FLAG_ACTIVITY_NEW_TASK
uninstall.putExtra(Intent.EXTRA_RETURN_RESULT, true)
Activity().startActivityForResult(uninstall, BaseFragment.APP_UNINSTALL)
activity.startActivityForResult(uninstall, BaseFragment.APP_UNINSTALL)
} 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 name="vanced_variant">
<item>Non-root</item>
<item>Nonroot</item>
<item>Root</item>
</string-array>
<string-array name="vanced_variant_values">
<item>Nonroot</item>
<item>Root</item>
<item>nonroot</item>
<item>root</item>
</string-array>
<string-array name="syke">