mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-25 09:57:39 +00:00
Minor notification changes
This commit is contained in:
parent
176e470497
commit
44b969e0b6
@ -22,6 +22,8 @@ import androidx.core.app.TaskStackBuilder;
|
|||||||
|
|
||||||
public class Notifications {
|
public class Notifications {
|
||||||
|
|
||||||
|
public static NotificationManagerCompat mgr = NotificationManagerCompat.from(App.self);
|
||||||
|
|
||||||
public static void setup(Context c) {
|
public static void setup(Context c) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
NotificationManager mgr = c.getSystemService(NotificationManager.class);
|
NotificationManager mgr = c.getSystemService(NotificationManager.class);
|
||||||
@ -55,7 +57,6 @@ public class Notifications {
|
|||||||
.setAutoCancel(true)
|
.setAutoCancel(true)
|
||||||
.setContentIntent(pendingIntent);
|
.setContentIntent(pendingIntent);
|
||||||
|
|
||||||
NotificationManagerCompat mgr = NotificationManagerCompat.from(app);
|
|
||||||
mgr.notify(Const.ID.MAGISK_UPDATE_NOTIFICATION_ID, builder.build());
|
mgr.notify(Const.ID.MAGISK_UPDATE_NOTIFICATION_ID, builder.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,7 +80,6 @@ public class Notifications {
|
|||||||
.setAutoCancel(true)
|
.setAutoCancel(true)
|
||||||
.setContentIntent(pendingIntent);
|
.setContentIntent(pendingIntent);
|
||||||
|
|
||||||
NotificationManagerCompat mgr = NotificationManagerCompat.from(app);
|
|
||||||
mgr.notify(Const.ID.APK_UPDATE_NOTIFICATION_ID, builder.build());
|
mgr.notify(Const.ID.APK_UPDATE_NOTIFICATION_ID, builder.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,7 +98,6 @@ public class Notifications {
|
|||||||
.setVibrate(new long[]{0, 100, 100, 100})
|
.setVibrate(new long[]{0, 100, 100, 100})
|
||||||
.addAction(R.drawable.ic_refresh, app.getString(R.string.reboot), pendingIntent);
|
.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());
|
mgr.notify(Const.ID.DTBO_NOTIFICATION_ID, builder.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,16 +9,14 @@ import com.topjohnwu.magisk.R;
|
|||||||
import com.topjohnwu.net.DownloadProgressListener;
|
import com.topjohnwu.net.DownloadProgressListener;
|
||||||
|
|
||||||
import androidx.core.app.NotificationCompat;
|
import androidx.core.app.NotificationCompat;
|
||||||
import androidx.core.app.NotificationManagerCompat;
|
|
||||||
|
|
||||||
public class ProgressNotification implements DownloadProgressListener {
|
public class ProgressNotification implements DownloadProgressListener {
|
||||||
private NotificationManagerCompat mgr;
|
|
||||||
private NotificationCompat.Builder builder;
|
private NotificationCompat.Builder builder;
|
||||||
private Notification notification;
|
private Notification notification;
|
||||||
private long prevTime;
|
private long prevTime;
|
||||||
|
|
||||||
public ProgressNotification(String title) {
|
public ProgressNotification(String title) {
|
||||||
mgr = NotificationManagerCompat.from(App.self);
|
|
||||||
builder = Notifications.progress(title);
|
builder = Notifications.progress(title);
|
||||||
prevTime = System.currentTimeMillis();
|
prevTime = System.currentTimeMillis();
|
||||||
update();
|
update();
|
||||||
@ -47,13 +45,13 @@ public class ProgressNotification implements DownloadProgressListener {
|
|||||||
|
|
||||||
public void update() {
|
public void update() {
|
||||||
notification = builder.build();
|
notification = builder.build();
|
||||||
mgr.notify(hashCode(), notification);
|
Notifications.mgr.notify(hashCode(), notification);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void lastUpdate() {
|
private void lastUpdate() {
|
||||||
notification = builder.build();
|
notification = builder.build();
|
||||||
mgr.cancel(hashCode());
|
Notifications.mgr.cancel(hashCode());
|
||||||
mgr.notify(notification.hashCode(), notification);
|
Notifications.mgr.notify(notification.hashCode(), notification);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dlDone() {
|
public void dlDone() {
|
||||||
@ -73,6 +71,6 @@ public class ProgressNotification implements DownloadProgressListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void dismiss() {
|
public void dismiss() {
|
||||||
mgr.cancel(hashCode());
|
Notifications.mgr.cancel(hashCode());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,6 @@ public class DownloadModuleService extends Service {
|
|||||||
.putExtra(Const.Key.FLASH_ACTION, Const.Value.FLASH_ZIP);
|
.putExtra(Const.Key.FLASH_ACTION, Const.Value.FLASH_ZIP);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
} else {
|
} else {
|
||||||
progress.getNotificationBuilder().setContentTitle(output.getName());
|
|
||||||
progress.dlDone();
|
progress.dlDone();
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user