Allow multiple progress notifications

This commit is contained in:
topjohnwu 2018-12-03 02:28:20 -05:00
parent d510224e2a
commit 07bfdf3e4d
3 changed files with 6 additions and 6 deletions

View File

@ -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";
}

View File

@ -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);
});
}

View File

@ -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());
}
}