From 10d6f10fde71bff80aff8afa8d9666610f13c30b Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 9 Dec 2018 19:33:55 +0100 Subject: [PATCH] Added notification logging --- .../java/eu/faircode/email/ServiceSynchronize.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java index 6834440e88..db6fe41ca6 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java +++ b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java @@ -188,7 +188,7 @@ public class ServiceSynchronize extends LifecycleService { @Override public void run() { try { - NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); + Log.i(Helper.TAG, "Notification messages=" + messages.size()); Widget.update(ServiceSynchronize.this, messages.size()); @@ -220,15 +220,23 @@ public class ServiceSynchronize extends LifecycleService { Integer id = (int) notification.extras.getLong("id", 0); if (id != 0) { all.add(id); - if (removed.contains(id)) + if (removed.contains(id)) { removed.remove(id); - else { + Log.i(Helper.TAG, "Notification removing=" + id); + } else { removed.remove(Integer.valueOf(-id)); added.add(id); + Log.i(Helper.TAG, "Notification adding=" + id); } } } + Log.i(Helper.TAG, "Notification account=" + account + + " notifications=" + notifications.size() + + " all=" + all.size() + " added=" + added.size() + " removed=" + removed.size()); + + NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); + if (notifications.size() == 0 || (Build.VERSION.SDK_INT < Build.VERSION_CODES.O && added.size() > 0)) nm.cancel("unseen:" + account, 0);