0
0
Fork 0
mirror of https://github.com/YTVanced/VancedManager synced 2024-11-02 01:02:39 +00:00

fixed auto updater

This commit is contained in:
X1nto 2020-07-02 18:38:48 +04:00
parent 685c5a61fd
commit ee827937cb
4 changed files with 13 additions and 7 deletions

View file

@ -108,7 +108,7 @@ open class Home : BaseFragment(), View.OnClickListener {
}
else {
writeToVariantPref("nonroot", R.anim.slide_in_left, R.anim.slide_out_right)
Toast.makeText(activity, "Root access not granted", Toast.LENGTH_SHORT).show()
Toast.makeText(activity, activity?.getString(R.string.root_not_granted), Toast.LENGTH_SHORT).show()
}
}
}
@ -120,7 +120,7 @@ open class Home : BaseFragment(), View.OnClickListener {
startActivity(Intent(activity, MainActivity::class.java))
activity?.overridePendingTransition(animIn, animOut)
activity?.finish()
} else Log.d("VMvariant", "$variant is already selected")
} else Log.d("VMVariant", "$variant is already selected")
}
}

View file

@ -1,7 +1,9 @@
package com.vanced.manager.ui.fragments
import android.content.Intent
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.net.Uri
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
@ -20,6 +22,7 @@ import com.google.android.material.button.MaterialButton
import com.vanced.manager.R
import com.vanced.manager.utils.InternetTools.isUpdateAvailable
import com.vanced.manager.utils.PackageHelper.installApp
import java.io.File
class UpdateCheckFragment : DialogFragment() {
@ -60,7 +63,7 @@ class UpdateCheckFragment : DialogFragment() {
}
private fun upgradeManager() {
val dwnldUrl = "https://github.com/VancedManager/releases/latest/download/manager.apk"
val dwnldUrl = GetJson().AsJSONObject("https://x1nto.github.io/VancedFiles/manager.json").get("url").asString
val loadBar = view?.findViewById<ProgressBar>(R.id.update_center_progressbar)
PRDownloader.download(dwnldUrl, activity?.filesDir?.path, "manager.apk")
@ -74,10 +77,10 @@ class UpdateCheckFragment : DialogFragment() {
.start(object : OnDownloadListener{
override fun onDownloadComplete() {
activity?.let {
installApp(
it,
it.filesDir.path + "/manager.apk",
"com.vanced.manager")
val uri = Uri.fromFile(File(activity!!.filesDir.path, "manager.apk"))
val intent = Intent(Intent.ACTION_VIEW)
intent.setDataAndType(uri, "application/vnd.android.package-archive")
startActivity(intent)
}
}

View file

@ -23,6 +23,7 @@ object PackageHelper {
}
}
/*
@Throws(IOException::class)
fun installApp(
context: Context,
@ -48,6 +49,7 @@ object PackageHelper {
outputStream.close()
session.commit(pendingIntent.intentSender)
}
*/
fun uninstallApk(pkg: String, activity: Activity) {
val callbackIntent = Intent(activity.applicationContext, AppUninstallerService::class.java)

View file

@ -35,6 +35,7 @@
<string name="successfully_installed">Successfully installed %1$s</string>
<string name="network_error">Network connection unavailable</string>
<string name="no_microg">No MicroG!</string>
<string name="root_not_granted">Root access not granted</string>
<string name="unavailable">Unavailable</string>
<string name="update">Update</string>
<string name="useful_links">Useful Links</string>