From 07bfdf3e4dba23370c3dd29a05b0656391d5bd5c Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Mon, 3 Dec 2018 02:28:20 -0500 Subject: [PATCH] Allow multiple progress notifications --- app/src/full/java/com/topjohnwu/magisk/Const.java | 2 +- app/src/full/java/com/topjohnwu/magisk/asyncs/PatchAPK.java | 4 ++-- .../topjohnwu/magisk/components/ProgressNotification.java | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/full/java/com/topjohnwu/magisk/Const.java b/app/src/full/java/com/topjohnwu/magisk/Const.java index ecfd4bfbc..65d736241 100644 --- a/app/src/full/java/com/topjohnwu/magisk/Const.java +++ b/app/src/full/java/com/topjohnwu/magisk/Const.java @@ -63,7 +63,7 @@ public class Const { public static final int MAGISK_UPDATE_NOTIFICATION_ID = 4; public static final int APK_UPDATE_NOTIFICATION_ID = 5; public static final int DTBO_NOTIFICATION_ID = 7; - public static final int DOWNLOAD_PROGRESS_ID = 8; + public static final int HIDE_MANAGER_NOTIFICATION_ID = 8; public static final String UPDATE_NOTIFICATION_CHANNEL = "update"; public static final String PROGRESS_NOTIFICATION_CHANNEL = "progress"; } diff --git a/app/src/full/java/com/topjohnwu/magisk/asyncs/PatchAPK.java b/app/src/full/java/com/topjohnwu/magisk/asyncs/PatchAPK.java index 9133774a2..8d73e5e40 100644 --- a/app/src/full/java/com/topjohnwu/magisk/asyncs/PatchAPK.java +++ b/app/src/full/java/com/topjohnwu/magisk/asyncs/PatchAPK.java @@ -133,9 +133,9 @@ public class PatchAPK { NotificationCompat.Builder progress = Notifications.progress(mm.getString(R.string.hide_manager_title)); NotificationManagerCompat mgr = NotificationManagerCompat.from(mm); - mgr.notify(Const.ID.DOWNLOAD_PROGRESS_ID, progress.build()); + mgr.notify(Const.ID.HIDE_MANAGER_NOTIFICATION_ID, progress.build()); boolean b = patchAndHide(); - mgr.cancel(Const.ID.DOWNLOAD_PROGRESS_ID); + mgr.cancel(Const.ID.HIDE_MANAGER_NOTIFICATION_ID); if (!b) Utils.toast(R.string.hide_manager_fail_toast, Toast.LENGTH_LONG); }); } diff --git a/app/src/full/java/com/topjohnwu/magisk/components/ProgressNotification.java b/app/src/full/java/com/topjohnwu/magisk/components/ProgressNotification.java index e597fbe18..5ff81e11d 100644 --- a/app/src/full/java/com/topjohnwu/magisk/components/ProgressNotification.java +++ b/app/src/full/java/com/topjohnwu/magisk/components/ProgressNotification.java @@ -22,8 +22,8 @@ public class ProgressNotification implements DownloadProgressListener { MagiskManager mm = Data.MM(); mgr = NotificationManagerCompat.from(mm); builder = Notifications.progress(title); - mgr.notify(Const.ID.DOWNLOAD_PROGRESS_ID, builder.build()); prevTime = System.currentTimeMillis(); + update(); Utils.toast(mm.getString(R.string.downloading_toast, title), Toast.LENGTH_SHORT); } @@ -44,7 +44,7 @@ public class ProgressNotification implements DownloadProgressListener { } public void update() { - mgr.notify(Const.ID.DOWNLOAD_PROGRESS_ID, builder.build()); + mgr.notify(hashCode(), builder.build()); } public void dlDone() { @@ -64,6 +64,6 @@ public class ProgressNotification implements DownloadProgressListener { } public void dismiss() { - mgr.cancel(Const.ID.DOWNLOAD_PROGRESS_ID); + mgr.cancel(hashCode()); } }