From 2b502e9a0f73a006ac38ef7ecc3cf64f9d95d291 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Mon, 3 Dec 2018 01:44:13 -0500 Subject: [PATCH] Small reorganization --- .../java/com/topjohnwu/magisk/SplashActivity.java | 2 +- .../com/topjohnwu/magisk/asyncs/CheckUpdates.java | 2 +- .../topjohnwu/magisk/asyncs/DownloadModule.java | 8 ++++---- .../magisk/components/InstallMethodDialog.java | 2 +- .../{utils => components}/Notifications.java | 3 ++- ...tionProgress.java => ProgressNotification.java} | 5 ++--- .../magisk/components/UninstallDialog.java | 2 +- .../topjohnwu/magisk/services/OnBootService.java | 2 +- .../topjohnwu/magisk/utils/DlInstallManager.java | 14 +++++++------- 9 files changed, 20 insertions(+), 20 deletions(-) rename app/src/full/java/com/topjohnwu/magisk/{utils => components}/Notifications.java (98%) rename app/src/full/java/com/topjohnwu/magisk/components/{NotificationProgress.java => ProgressNotification.java} (92%) diff --git a/app/src/full/java/com/topjohnwu/magisk/SplashActivity.java b/app/src/full/java/com/topjohnwu/magisk/SplashActivity.java index f551521bf..8ea1adb26 100644 --- a/app/src/full/java/com/topjohnwu/magisk/SplashActivity.java +++ b/app/src/full/java/com/topjohnwu/magisk/SplashActivity.java @@ -8,10 +8,10 @@ import android.text.TextUtils; import com.topjohnwu.magisk.asyncs.CheckUpdates; import com.topjohnwu.magisk.asyncs.UpdateRepos; import com.topjohnwu.magisk.components.BaseActivity; +import com.topjohnwu.magisk.components.Notifications; import com.topjohnwu.magisk.receivers.ShortcutReceiver; import com.topjohnwu.magisk.utils.Download; import com.topjohnwu.magisk.utils.LocaleManager; -import com.topjohnwu.magisk.utils.Notifications; import com.topjohnwu.magisk.utils.RootUtils; import com.topjohnwu.magisk.utils.Utils; import com.topjohnwu.superuser.Shell; diff --git a/app/src/full/java/com/topjohnwu/magisk/asyncs/CheckUpdates.java b/app/src/full/java/com/topjohnwu/magisk/asyncs/CheckUpdates.java index f7ef578de..92458d615 100644 --- a/app/src/full/java/com/topjohnwu/magisk/asyncs/CheckUpdates.java +++ b/app/src/full/java/com/topjohnwu/magisk/asyncs/CheckUpdates.java @@ -5,7 +5,7 @@ import android.os.AsyncTask; import com.topjohnwu.magisk.BuildConfig; import com.topjohnwu.magisk.Const; import com.topjohnwu.magisk.Data; -import com.topjohnwu.magisk.utils.Notifications; +import com.topjohnwu.magisk.components.Notifications; import com.topjohnwu.magisk.utils.Topic; import com.topjohnwu.magisk.utils.Utils; diff --git a/app/src/full/java/com/topjohnwu/magisk/asyncs/DownloadModule.java b/app/src/full/java/com/topjohnwu/magisk/asyncs/DownloadModule.java index 3d7160fdf..5b8cb4b60 100644 --- a/app/src/full/java/com/topjohnwu/magisk/asyncs/DownloadModule.java +++ b/app/src/full/java/com/topjohnwu/magisk/asyncs/DownloadModule.java @@ -11,7 +11,7 @@ import com.topjohnwu.magisk.FlashActivity; import com.topjohnwu.magisk.MagiskManager; import com.topjohnwu.magisk.R; import com.topjohnwu.magisk.components.BaseActivity; -import com.topjohnwu.magisk.components.NotificationProgress; +import com.topjohnwu.magisk.components.ProgressNotification; import com.topjohnwu.magisk.container.Repo; import com.topjohnwu.magisk.utils.WebService; import com.topjohnwu.magisk.utils.ZipUtils; @@ -39,7 +39,7 @@ public class DownloadModule { private static void dlProcessInstall(Repo repo, boolean install) { File output = new File(Const.EXTERNAL_PATH, repo.getDownloadFilename()); - NotificationProgress progress = new NotificationProgress(output.getName()); + ProgressNotification progress = new ProgressNotification(output.getName()); try { MagiskManager mm = Data.MM(); File temp1 = new File(mm.getCacheDir(), "temp.zip"); @@ -96,9 +96,9 @@ public class DownloadModule { private long totalBytes; private long bytesDownloaded; - private NotificationProgress progress; + private ProgressNotification progress; - protected ProgressInputStream(InputStream in, long size, NotificationProgress p) { + protected ProgressInputStream(InputStream in, long size, ProgressNotification p) { super(in); totalBytes = size; progress = p; diff --git a/app/src/full/java/com/topjohnwu/magisk/components/InstallMethodDialog.java b/app/src/full/java/com/topjohnwu/magisk/components/InstallMethodDialog.java index c72f79b86..f6b6e36d4 100644 --- a/app/src/full/java/com/topjohnwu/magisk/components/InstallMethodDialog.java +++ b/app/src/full/java/com/topjohnwu/magisk/components/InstallMethodDialog.java @@ -67,7 +67,7 @@ class InstallMethodDialog extends AlertDialog.Builder { a.runWithPermission(new String[] {Manifest.permission.WRITE_EXTERNAL_STORAGE}, () -> { String filename = Utils.fmt("Magisk-v%s(%d).zip", Data.remoteMagiskVersionString, Data.remoteMagiskVersionCode); - NotificationProgress progress = new NotificationProgress(filename); + ProgressNotification progress = new ProgressNotification(filename); AndroidNetworking .download(Data.magiskLink, Const.EXTERNAL_PATH.getPath(), filename) .build() diff --git a/app/src/full/java/com/topjohnwu/magisk/utils/Notifications.java b/app/src/full/java/com/topjohnwu/magisk/components/Notifications.java similarity index 98% rename from app/src/full/java/com/topjohnwu/magisk/utils/Notifications.java rename to app/src/full/java/com/topjohnwu/magisk/components/Notifications.java index c6f6bed56..244c2b4c8 100644 --- a/app/src/full/java/com/topjohnwu/magisk/utils/Notifications.java +++ b/app/src/full/java/com/topjohnwu/magisk/components/Notifications.java @@ -1,4 +1,4 @@ -package com.topjohnwu.magisk.utils; +package com.topjohnwu.magisk.components; import android.app.NotificationChannel; import android.app.NotificationManager; @@ -13,6 +13,7 @@ import com.topjohnwu.magisk.MagiskManager; import com.topjohnwu.magisk.R; import com.topjohnwu.magisk.SplashActivity; import com.topjohnwu.magisk.receivers.GeneralReceiver; +import com.topjohnwu.magisk.utils.Utils; import androidx.core.app.NotificationCompat; import androidx.core.app.NotificationManagerCompat; diff --git a/app/src/full/java/com/topjohnwu/magisk/components/NotificationProgress.java b/app/src/full/java/com/topjohnwu/magisk/components/ProgressNotification.java similarity index 92% rename from app/src/full/java/com/topjohnwu/magisk/components/NotificationProgress.java rename to app/src/full/java/com/topjohnwu/magisk/components/ProgressNotification.java index d7b353467..5c3ad5441 100644 --- a/app/src/full/java/com/topjohnwu/magisk/components/NotificationProgress.java +++ b/app/src/full/java/com/topjohnwu/magisk/components/ProgressNotification.java @@ -7,19 +7,18 @@ import com.topjohnwu.magisk.Const; import com.topjohnwu.magisk.Data; import com.topjohnwu.magisk.MagiskManager; import com.topjohnwu.magisk.R; -import com.topjohnwu.magisk.utils.Notifications; import com.topjohnwu.magisk.utils.Utils; import androidx.core.app.NotificationCompat; import androidx.core.app.NotificationManagerCompat; -public class NotificationProgress implements DownloadProgressListener { +public class ProgressNotification implements DownloadProgressListener { private NotificationManagerCompat mgr; private NotificationCompat.Builder builder; private long prevTime; - public NotificationProgress(String title) { + public ProgressNotification(String title) { MagiskManager mm = Data.MM(); mgr = NotificationManagerCompat.from(mm); builder = Notifications.progress(title); diff --git a/app/src/full/java/com/topjohnwu/magisk/components/UninstallDialog.java b/app/src/full/java/com/topjohnwu/magisk/components/UninstallDialog.java index 3d6fa4e43..97092061f 100644 --- a/app/src/full/java/com/topjohnwu/magisk/components/UninstallDialog.java +++ b/app/src/full/java/com/topjohnwu/magisk/components/UninstallDialog.java @@ -43,7 +43,7 @@ public class UninstallDialog extends CustomAlertDialog { if (!TextUtils.isEmpty(Data.uninstallerLink)) { setPositiveButton(R.string.complete_uninstall, (d, i) -> { File zip = new File(activity.getFilesDir(), "uninstaller.zip"); - NotificationProgress progress = new NotificationProgress(zip.getName()); + ProgressNotification progress = new ProgressNotification(zip.getName()); AndroidNetworking.download(Data.uninstallerLink, zip.getParent(), zip.getName()) .build() .setDownloadProgressListener(progress) diff --git a/app/src/full/java/com/topjohnwu/magisk/services/OnBootService.java b/app/src/full/java/com/topjohnwu/magisk/services/OnBootService.java index c85ec99ee..1605cfc33 100644 --- a/app/src/full/java/com/topjohnwu/magisk/services/OnBootService.java +++ b/app/src/full/java/com/topjohnwu/magisk/services/OnBootService.java @@ -5,7 +5,7 @@ import android.content.Intent; import com.topjohnwu.magisk.Const; import com.topjohnwu.magisk.Data; -import com.topjohnwu.magisk.utils.Notifications; +import com.topjohnwu.magisk.components.Notifications; import com.topjohnwu.superuser.Shell; import com.topjohnwu.superuser.ShellUtils; diff --git a/app/src/full/java/com/topjohnwu/magisk/utils/DlInstallManager.java b/app/src/full/java/com/topjohnwu/magisk/utils/DlInstallManager.java index 201d1b04c..d4f1d4158 100644 --- a/app/src/full/java/com/topjohnwu/magisk/utils/DlInstallManager.java +++ b/app/src/full/java/com/topjohnwu/magisk/utils/DlInstallManager.java @@ -10,7 +10,7 @@ import com.topjohnwu.magisk.Data; import com.topjohnwu.magisk.MagiskManager; import com.topjohnwu.magisk.R; import com.topjohnwu.magisk.asyncs.PatchAPK; -import com.topjohnwu.magisk.components.NotificationProgress; +import com.topjohnwu.magisk.components.ProgressNotification; import com.topjohnwu.superuser.ShellUtils; import com.topjohnwu.utils.JarMap; import com.topjohnwu.utils.SignAPK; @@ -34,7 +34,7 @@ public class DlInstallManager { public static void dlInstall(String name, ManagerDownloadListener listener) { MagiskManager mm = Data.MM(); File apk = new File(mm.getFilesDir(), "manager.apk"); - NotificationProgress progress = new NotificationProgress(name); + ProgressNotification progress = new ProgressNotification(name); listener.setInstances(apk, progress); AndroidNetworking .download(Data.managerLink, apk.getParent(), apk.getName()) @@ -46,14 +46,14 @@ public class DlInstallManager { public abstract static class ManagerDownloadListener implements DownloadListener { private File apk; - private NotificationProgress progress; + private ProgressNotification progress; - private void setInstances(File apk, NotificationProgress progress) { + private void setInstances(File apk, ProgressNotification progress) { this.apk = apk; this.progress = progress; } - public abstract void onDownloadComplete(File apk, NotificationProgress progress); + public abstract void onDownloadComplete(File apk, ProgressNotification progress); @Override public final void onDownloadComplete() { @@ -69,7 +69,7 @@ public class DlInstallManager { private static class PatchPackageName extends ManagerDownloadListener { @Override - public void onDownloadComplete(File apk, NotificationProgress progress) { + public void onDownloadComplete(File apk, ProgressNotification progress) { File patched = apk; MagiskManager mm = Data.MM(); if (!mm.getPackageName().equals(BuildConfig.APPLICATION_ID)) { @@ -95,7 +95,7 @@ public class DlInstallManager { private static class RestoreManager extends ManagerDownloadListener { @Override - public void onDownloadComplete(File apk, NotificationProgress progress) { + public void onDownloadComplete(File apk, ProgressNotification progress) { progress.dismiss(); Data.exportPrefs(); if (ShellUtils.fastCmdResult("pm install " + apk))