From 6836130fdac5fbd94d289cdb3c4aabfef50af3c4 Mon Sep 17 00:00:00 2001 From: Viktor De Pasquale Date: Tue, 9 Jul 2019 20:02:20 +0200 Subject: [PATCH] Added overloaded method call for progress notification so it accepts foreign context --- .../topjohnwu/magisk/view/Notifications.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/topjohnwu/magisk/view/Notifications.java b/app/src/main/java/com/topjohnwu/magisk/view/Notifications.java index 9cd0eac4a..d642bdd7b 100644 --- a/app/src/main/java/com/topjohnwu/magisk/view/Notifications.java +++ b/app/src/main/java/com/topjohnwu/magisk/view/Notifications.java @@ -7,10 +7,6 @@ import android.content.Context; import android.content.Intent; import android.os.Build; -import androidx.core.app.NotificationCompat; -import androidx.core.app.NotificationManagerCompat; -import androidx.core.app.TaskStackBuilder; - import com.topjohnwu.magisk.App; import com.topjohnwu.magisk.ClassMap; import com.topjohnwu.magisk.Const; @@ -20,6 +16,10 @@ import com.topjohnwu.magisk.model.receiver.GeneralReceiver; import com.topjohnwu.magisk.ui.SplashActivity; import com.topjohnwu.magisk.utils.Utils; +import androidx.core.app.NotificationCompat; +import androidx.core.app.NotificationManagerCompat; +import androidx.core.app.TaskStackBuilder; + public class Notifications { public static NotificationManagerCompat mgr = NotificationManagerCompat.from(App.self); @@ -101,9 +101,12 @@ public class Notifications { mgr.notify(Const.ID.DTBO_NOTIFICATION_ID, builder.build()); } - public static NotificationCompat.Builder progress(String title) { - App app = App.self; - NotificationCompat.Builder builder = new NotificationCompat.Builder(app, Const.ID.PROGRESS_NOTIFICATION_CHANNEL); + public static NotificationCompat.Builder progress(CharSequence title) { + return progress(App.self, title); + } + + public static NotificationCompat.Builder progress(Context context, CharSequence title) { + NotificationCompat.Builder builder = new NotificationCompat.Builder(context, Const.ID.PROGRESS_NOTIFICATION_CHANNEL); builder.setPriority(NotificationCompat.PRIORITY_LOW) .setSmallIcon(android.R.drawable.stat_sys_download) .setContentTitle(title)