Cleanup UpdateInfo

This commit is contained in:
topjohnwu
2019-06-16 16:47:30 -07:00
parent 4a3f5dc619
commit bf9ac8252b
19 changed files with 79 additions and 110 deletions
@@ -63,11 +63,11 @@ public class Notifications {
public static void managerUpdate() {
App app = App.self;
String name = Utils.INSTANCE.fmt("MagiskManager v%s(%d)",
Info.remoteManagerVersionString, Info.remoteManagerVersionCode);
Info.remote.getApp().getVersion(), Info.remote.getApp().getVersionCode());
Intent intent = new Intent(app, ClassMap.get(GeneralReceiver.class));
intent.setAction(Const.Key.BROADCAST_MANAGER_UPDATE);
intent.putExtra(Const.Key.INTENT_SET_LINK, Info.managerLink);
intent.putExtra(Const.Key.INTENT_SET_LINK, Info.remote.getApp().getLink());
intent.putExtra(Const.Key.INTENT_SET_NAME, name);
PendingIntent pendingIntent = PendingIntent.getBroadcast(app,
Const.ID.APK_UPDATE_NOTIFICATION_ID, intent, PendingIntent.FLAG_UPDATE_CURRENT);
@@ -57,11 +57,11 @@ internal class InstallMethodDialog(activity: MagiskActivity<*, *>, options: List
private fun downloadOnly(activity: MagiskActivity<*, *>) {
activity.withExternalRW {
onSuccess {
val filename = "Magisk-v${Info.remoteMagiskVersionString}" +
"(${Info.remoteMagiskVersionCode}).zip"
val filename = "Magisk-v${Info.remote.magisk.version}" +
"(${Info.remote.magisk.versionCode}).zip"
val zip = File(Const.EXTERNAL_PATH, filename)
val progress = ProgressNotification(filename)
Networking.get(Info.magiskLink)
Networking.get(Info.remote.magisk.link)
.setDownloadProgressListener(progress)
.setErrorHandler { _, _ -> progress.dlFail() }
.getAsFile(zip) {
@@ -1,7 +1,6 @@
package com.topjohnwu.magisk.view.dialogs
import android.net.Uri
import android.text.TextUtils
import com.topjohnwu.magisk.Info
import com.topjohnwu.magisk.R
import com.topjohnwu.magisk.ui.base.MagiskActivity
@@ -13,8 +12,8 @@ import java.util.*
class MagiskInstallDialog(a: MagiskActivity<*, *>) : CustomAlertDialog(a) {
init {
val filename = "Magisk v${Info.remoteMagiskVersionString}" +
"(${Info.remoteMagiskVersionCode})"
val filename = "Magisk v${Info.remote.magisk.version}" +
"(${Info.remote.magisk.versionCode})"
setTitle(a.getString(R.string.repo_install_title, a.getString(R.string.magisk)))
setMessage(a.getString(R.string.repo_install_msg, filename))
setCancelable(true)
@@ -31,13 +30,13 @@ class MagiskInstallDialog(a: MagiskActivity<*, *>) : CustomAlertDialog(a) {
}
InstallMethodDialog(a, options).show()
}
if (!TextUtils.isEmpty(Info.magiskNoteLink)) {
if (Info.remote.magisk.note.isNotEmpty()) {
setNeutralButton(R.string.release_notes) { _, _ ->
if (Info.magiskNoteLink.contains("forum.xda-developers")) {
if (Info.remote.magisk.note.contains("forum.xda-developers")) {
// Open forum links in browser
Utils.openLink(a, Uri.parse(Info.magiskNoteLink))
Utils.openLink(a, Uri.parse(Info.remote.magisk.note))
} else {
MarkDownWindow.show(a, null, Info.magiskNoteLink)
MarkDownWindow.show(a, null, Info.remote.magisk.note)
}
}
}
@@ -9,15 +9,15 @@ import com.topjohnwu.magisk.view.MarkDownWindow
class ManagerInstallDialog(a: Activity) : CustomAlertDialog(a) {
init {
val name = "MagiskManager v${Info.remoteManagerVersionString}" +
"(${Info.remoteManagerVersionCode})"
val name = "MagiskManager v${Info.remote.app.version}" +
"(${Info.remote.app.versionCode})"
setTitle(a.getString(R.string.repo_install_title, a.getString(R.string.app_name)))
setMessage(a.getString(R.string.repo_install_msg, name))
setCancelable(true)
setPositiveButton(R.string.install) { _, _ -> DownloadApp.upgrade(name) }
if (Info.managerNoteLink.isNotEmpty()) {
if (Info.remote.app.note.isNotEmpty()) {
setNeutralButton(R.string.app_changelog) { _, _ ->
MarkDownWindow.show(a, null, Info.managerNoteLink) }
MarkDownWindow.show(a, null, Info.remote.app.note) }
}
}
}
@@ -4,9 +4,7 @@ import android.app.Activity
import android.app.ProgressDialog
import android.content.Intent
import android.net.Uri
import android.text.TextUtils
import android.widget.Toast
import com.topjohnwu.magisk.ClassMap
import com.topjohnwu.magisk.Const
import com.topjohnwu.magisk.Info
@@ -16,7 +14,6 @@ import com.topjohnwu.magisk.utils.Utils
import com.topjohnwu.magisk.view.ProgressNotification
import com.topjohnwu.net.Networking
import com.topjohnwu.superuser.Shell
import java.io.File
class UninstallDialog(activity: Activity) : CustomAlertDialog(activity) {
@@ -37,11 +34,11 @@ class UninstallDialog(activity: Activity) : CustomAlertDialog(activity) {
}
}
}
if (!TextUtils.isEmpty(Info.uninstallerLink)) {
if (Info.remote.uninstaller.link.isNotEmpty()) {
setPositiveButton(R.string.complete_uninstall) { d, i ->
val zip = File(activity.filesDir, "uninstaller.zip")
val progress = ProgressNotification(zip.name)
Networking.get(Info.uninstallerLink)
Networking.get(Info.remote.uninstaller.link)
.setDownloadProgressListener(progress)
.setErrorHandler { _, _ -> progress.dlFail() }
.getAsFile(zip) { f ->