From 44b969e0b6bf395686044ea5492459cbd202297f Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Sun, 30 Dec 2018 01:06:31 +0800 Subject: [PATCH] Minor notification changes --- .../topjohnwu/magisk/components/Notifications.java | 5 ++--- .../magisk/components/ProgressNotification.java | 12 +++++------- .../magisk/services/DownloadModuleService.java | 1 - 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/app/src/full/java/com/topjohnwu/magisk/components/Notifications.java b/app/src/full/java/com/topjohnwu/magisk/components/Notifications.java index bdbc196d0..dee202316 100644 --- a/app/src/full/java/com/topjohnwu/magisk/components/Notifications.java +++ b/app/src/full/java/com/topjohnwu/magisk/components/Notifications.java @@ -22,6 +22,8 @@ import androidx.core.app.TaskStackBuilder; public class Notifications { + public static NotificationManagerCompat mgr = NotificationManagerCompat.from(App.self); + public static void setup(Context c) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { NotificationManager mgr = c.getSystemService(NotificationManager.class); @@ -55,7 +57,6 @@ public class Notifications { .setAutoCancel(true) .setContentIntent(pendingIntent); - NotificationManagerCompat mgr = NotificationManagerCompat.from(app); mgr.notify(Const.ID.MAGISK_UPDATE_NOTIFICATION_ID, builder.build()); } @@ -79,7 +80,6 @@ public class Notifications { .setAutoCancel(true) .setContentIntent(pendingIntent); - NotificationManagerCompat mgr = NotificationManagerCompat.from(app); mgr.notify(Const.ID.APK_UPDATE_NOTIFICATION_ID, builder.build()); } @@ -98,7 +98,6 @@ public class Notifications { .setVibrate(new long[]{0, 100, 100, 100}) .addAction(R.drawable.ic_refresh, app.getString(R.string.reboot), pendingIntent); - NotificationManagerCompat mgr = NotificationManagerCompat.from(app); mgr.notify(Const.ID.DTBO_NOTIFICATION_ID, builder.build()); } 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 0f792a23f..2c397c435 100644 --- a/app/src/full/java/com/topjohnwu/magisk/components/ProgressNotification.java +++ b/app/src/full/java/com/topjohnwu/magisk/components/ProgressNotification.java @@ -9,16 +9,14 @@ import com.topjohnwu.magisk.R; import com.topjohnwu.net.DownloadProgressListener; import androidx.core.app.NotificationCompat; -import androidx.core.app.NotificationManagerCompat; public class ProgressNotification implements DownloadProgressListener { - private NotificationManagerCompat mgr; + private NotificationCompat.Builder builder; private Notification notification; private long prevTime; public ProgressNotification(String title) { - mgr = NotificationManagerCompat.from(App.self); builder = Notifications.progress(title); prevTime = System.currentTimeMillis(); update(); @@ -47,13 +45,13 @@ public class ProgressNotification implements DownloadProgressListener { public void update() { notification = builder.build(); - mgr.notify(hashCode(), notification); + Notifications.mgr.notify(hashCode(), notification); } private void lastUpdate() { notification = builder.build(); - mgr.cancel(hashCode()); - mgr.notify(notification.hashCode(), notification); + Notifications.mgr.cancel(hashCode()); + Notifications.mgr.notify(notification.hashCode(), notification); } public void dlDone() { @@ -73,6 +71,6 @@ public class ProgressNotification implements DownloadProgressListener { } public void dismiss() { - mgr.cancel(hashCode()); + Notifications.mgr.cancel(hashCode()); } } diff --git a/app/src/full/java/com/topjohnwu/magisk/services/DownloadModuleService.java b/app/src/full/java/com/topjohnwu/magisk/services/DownloadModuleService.java index 7c7e25b0b..2528c11dd 100644 --- a/app/src/full/java/com/topjohnwu/magisk/services/DownloadModuleService.java +++ b/app/src/full/java/com/topjohnwu/magisk/services/DownloadModuleService.java @@ -72,7 +72,6 @@ public class DownloadModuleService extends Service { .putExtra(Const.Key.FLASH_ACTION, Const.Value.FLASH_ZIP); startActivity(intent); } else { - progress.getNotificationBuilder().setContentTitle(output.getName()); progress.dlDone(); } } catch (Exception e) {