mirror of
https://github.com/TeamVanced/VancedMicroG
synced 2024-11-19 02:29:25 +01:00
Notify after disable/enable app notifications
This commit is contained in:
parent
8585f2ffc7
commit
c268e68b2a
@ -22,8 +22,7 @@ public class StatusNotification {
|
||||
private static boolean notificationExists = false;
|
||||
|
||||
public static void Notify(Context context) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
|
||||
&& NotificationManagerCompat.from(context.getApplicationContext()).areNotificationsEnabled()) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
||||
|
||||
boolean isChannelEnabled = true;
|
||||
@ -38,19 +37,32 @@ public class StatusNotification {
|
||||
|
||||
if (isChannelEnabled) {
|
||||
if (!powerManager.isIgnoringBatteryOptimizations(context.getPackageName())) {
|
||||
if (!notificationExists) {
|
||||
boolean resetNotification = false;
|
||||
|
||||
if (!NotificationManagerCompat.from(context.getApplicationContext()).areNotificationsEnabled()) {
|
||||
resetNotification = true;
|
||||
} else {
|
||||
if (notificationExists && resetNotification) {
|
||||
destroyNotification(context);
|
||||
resetNotification = false;
|
||||
} else {
|
||||
buildStatusNotification(context);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (notificationExists) {
|
||||
destroyNotification(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void destroyNotification(Context context) {
|
||||
((NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE)).cancel(notificationID);
|
||||
notificationChannelID = "";
|
||||
notificationExists = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void buildStatusNotification(Context context) {
|
||||
notificationID = 1;
|
||||
|
Loading…
Reference in New Issue
Block a user