Commit 2b502e9a authored by topjohnwu's avatar topjohnwu

Small reorganization

parent 59141f9b
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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()
......
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;
......
......@@ -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);
......
......@@ -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)
......
......@@ -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;
......
......@@ -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))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment