From fc2dc9a5e5dbd33f7cadcc58a668a7ffecc53d1e Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 15 Jul 2021 15:28:27 +0200 Subject: [PATCH] Android 12: notification ID --- .../main/java/eu/faircode/email/ActivityCompose.java | 2 +- app/src/main/java/eu/faircode/email/Core.java | 10 +++++----- .../main/java/eu/faircode/email/FragmentAccount.java | 4 ++-- .../main/java/eu/faircode/email/FragmentFolders.java | 4 ++-- .../main/java/eu/faircode/email/FragmentMessages.java | 2 +- app/src/main/java/eu/faircode/email/FragmentPop.java | 4 ++-- app/src/main/java/eu/faircode/email/ServiceSend.java | 6 +++--- .../java/eu/faircode/email/ServiceSynchronize.java | 10 +++++----- app/src/main/java/eu/faircode/email/ServiceUI.java | 2 +- 9 files changed, 22 insertions(+), 22 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ActivityCompose.java b/app/src/main/java/eu/faircode/email/ActivityCompose.java index b3cd3da04c..6df8c7b788 100644 --- a/app/src/main/java/eu/faircode/email/ActivityCompose.java +++ b/app/src/main/java/eu/faircode/email/ActivityCompose.java @@ -313,7 +313,7 @@ public class ActivityCompose extends ActivityBase implements FragmentManager.OnB ServiceSynchronize.eval(context, "outbox/drafts"); NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); - nm.cancel("send:" + id, 1); + nm.cancel("send:" + id, 10); return message.id; } diff --git a/app/src/main/java/eu/faircode/email/Core.java b/app/src/main/java/eu/faircode/email/Core.java index 333d55d8dd..7fe6e2047e 100644 --- a/app/src/main/java/eu/faircode/email/Core.java +++ b/app/src/main/java/eu/faircode/email/Core.java @@ -207,7 +207,7 @@ class Core { if (EntityOperation.HEADERS.equals(op.name) || EntityOperation.RAW.equals(op.name)) - nm.cancel(op.name + ":" + op.message, 1); + nm.cancel(op.name + ":" + op.message, 10); if (!Objects.equals(folder.id, op.folder)) throw new IllegalArgumentException("Invalid folder=" + folder.id + "/" + op.folder); @@ -628,7 +628,7 @@ class Core { if (title != null) { NotificationCompat.Builder builder = getNotificationError(context, "warning", title, ex); - nm.notify(op.name + ":" + op.message, 1, builder.build()); + nm.notify(op.name + ":" + op.message, 10, builder.build()); } } else { @@ -4075,7 +4075,7 @@ class Core { for (Long id : remove) { String tag = "unseen." + group + "." + Math.abs(id); EntityLog.log(context, "Notify cancel tag=" + tag + " id=" + id); - nm.cancel(tag, 1); + nm.cancel(tag, 10); data.groupNotifying.get(group).remove(id); db.message().setMessageNotifying(Math.abs(id), 0); @@ -4084,7 +4084,7 @@ class Core { if (notifications.size() == 0) { String tag = "unseen." + group + "." + 0; EntityLog.log(context, "Notify cancel tag=" + tag); - nm.cancel(tag, 1); + nm.cancel(tag, 10); } for (Long id : add) { @@ -4114,7 +4114,7 @@ class Core { : " channel=" + notification.getChannelId()) + " sort=" + notification.getSortKey()); try { - nm.notify(tag, 1, notification); + nm.notify(tag, 10, notification); // https://github.com/leolin310148/ShortcutBadger/wiki/Xiaomi-Device-Support if (id == 0 && badge && Helper.isXiaomi()) ShortcutBadger.applyNotification(context, notification, current); diff --git a/app/src/main/java/eu/faircode/email/FragmentAccount.java b/app/src/main/java/eu/faircode/email/FragmentAccount.java index c1a033f5da..44d2d50c0d 100644 --- a/app/src/main/java/eu/faircode/email/FragmentAccount.java +++ b/app/src/main/java/eu/faircode/email/FragmentAccount.java @@ -1266,8 +1266,8 @@ public class FragmentAccount extends FragmentBase { if (!synchronize) { NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); - nm.cancel("receive:" + account.id, 1); - nm.cancel("alert:" + account.id, 1); + nm.cancel("receive:" + account.id, 10); + nm.cancel("alert:" + account.id, 10); } args.putBoolean("saved", true); diff --git a/app/src/main/java/eu/faircode/email/FragmentFolders.java b/app/src/main/java/eu/faircode/email/FragmentFolders.java index bc0cfdffaa..8194a007eb 100644 --- a/app/src/main/java/eu/faircode/email/FragmentFolders.java +++ b/app/src/main/java/eu/faircode/email/FragmentFolders.java @@ -917,7 +917,7 @@ public class FragmentFolders extends FragmentBase { if (now - last > EXPORT_PROGRESS_INTERVAL) { last = now; builder.setProgress(ids.size(), i, false); - nm.notify("export", 1, builder.build()); + nm.notify("export", 10, builder.build()); } long id = ids.get(i); @@ -990,7 +990,7 @@ public class FragmentFolders extends FragmentBase { Log.e(ex); } } finally { - nm.cancel("export", 1); + nm.cancel("export", 10); } return null; diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index 365adc3372..247ada1b75 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -7546,7 +7546,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. ServiceSynchronize.eval(context, "delete"); NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); - nm.cancel("send:" + id, 1); + nm.cancel("send:" + id, 10); return null; } diff --git a/app/src/main/java/eu/faircode/email/FragmentPop.java b/app/src/main/java/eu/faircode/email/FragmentPop.java index 264fa381a8..b234a75c16 100644 --- a/app/src/main/java/eu/faircode/email/FragmentPop.java +++ b/app/src/main/java/eu/faircode/email/FragmentPop.java @@ -624,8 +624,8 @@ public class FragmentPop extends FragmentBase { if (!synchronize) { NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); - nm.cancel("receive:" + account.id, 1); - nm.cancel("alert:" + account.id, 1); + nm.cancel("receive:" + account.id, 10); + nm.cancel("alert:" + account.id, 10); } args.putBoolean("saved", true); diff --git a/app/src/main/java/eu/faircode/email/ServiceSend.java b/app/src/main/java/eu/faircode/email/ServiceSend.java index 3bc146c6b0..eeba663d13 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSend.java +++ b/app/src/main/java/eu/faircode/email/ServiceSend.java @@ -419,7 +419,7 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar try { int tries_left = (unrecoverable ? 0 : RETRY_MAX - op.tries); NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); - nm.notify("send:" + message.id, 1, getNotificationError( + nm.notify("send:" + message.id, 10, getNotificationError( MessageHelper.formatAddressesShort(message.to), ex, tries_left).build()); } catch (Throwable ex1) { Log.w(ex1); @@ -473,7 +473,7 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar } db.message().setMessageError(message.id, null); - nm.cancel("send:" + message.id, 1); + nm.cancel("send:" + message.id, 10); if (message.ui_snoozed == null) EntityOperation.queue(this, message, EntityOperation.SEND); @@ -735,7 +735,7 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar } NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); - nm.cancel("send:" + message.id, 1); + nm.cancel("send:" + message.id, 10); // Check sent message if (sid != null) { diff --git a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java index d2f9654c34..bd2a52c75b 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java +++ b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java @@ -1240,7 +1240,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences if (!ConnectionHelper.isMaxConnections(message)) try { NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); - nm.notify("alert:" + account.id, 1, + nm.notify("alert:" + account.id, 10, getNotificationAlert(account.name, message).build()); } catch (Throwable ex) { Log.w(ex); @@ -1272,7 +1272,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences try { state.setBackoff(2 * CONNECT_BACKOFF_ALARM_MAX * 60); NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); - nm.notify("receive:" + account.id, 1, + nm.notify("receive:" + account.id, 10, Core.getNotificationError(this, "error", account.name, ex) .build()); } catch (Throwable ex1) { @@ -1933,8 +1933,8 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences db.account().setAccountWarning(account.id, capIdle ? null : getString(R.string.title_no_idle)); NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); - nm.cancel("receive:" + account.id, 1); - nm.cancel("alert:" + account.id, 1); + nm.cancel("receive:" + account.id, 10); + nm.cancel("alert:" + account.id, 10); // Schedule keep alive alarm Intent intent = new Intent(this, ServiceSynchronize.class); @@ -1992,7 +1992,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences .format(account.last_connected)), ex); try { NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); - nm.notify("receive:" + account.id, 1, + nm.notify("receive:" + account.id, 10, Core.getNotificationError(this, "warning", account.name, warning) .build()); } catch (Throwable ex1) { diff --git a/app/src/main/java/eu/faircode/email/ServiceUI.java b/app/src/main/java/eu/faircode/email/ServiceUI.java index 5260f53f41..47d341f590 100644 --- a/app/src/main/java/eu/faircode/email/ServiceUI.java +++ b/app/src/main/java/eu/faircode/email/ServiceUI.java @@ -194,7 +194,7 @@ public class ServiceUI extends IntentService { String tag = "unseen." + group + ":" + id; NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); - nm.cancel(tag, 1); + nm.cancel(tag, 10); } private void onMove(long id, String folderType) {