From 5eb67064dd37f61791d529364468448cd77c416a Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 18 May 2019 21:37:09 +0200 Subject: [PATCH] Limit notification group size early To prevent looking up contact info --- app/src/main/java/eu/faircode/email/Core.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/Core.java b/app/src/main/java/eu/faircode/email/Core.java index ddf516f701..07be8d8e12 100644 --- a/app/src/main/java/eu/faircode/email/Core.java +++ b/app/src/main/java/eu/faircode/email/Core.java @@ -112,7 +112,7 @@ import me.leolin.shortcutbadger.ShortcutBadger; import static android.os.Process.THREAD_PRIORITY_BACKGROUND; class Core { - private static final int MAX_NOTIFICATION_COUNT = 20; // per group + private static final int MAX_NOTIFICATION_COUNT = 10; // per group private static final int SYNC_BATCH_SIZE = 20; private static final int DOWNLOAD_BATCH_SIZE = 20; private static final long YIELD_DURATION = 200L; // milliseconds @@ -1741,7 +1741,9 @@ class Core { groupNotifying.put(group, new ArrayList()); } - groupMessages.get(group).add(message); + // This assumes the messages are properly ordered + if (groupMessages.get(group).size() < MAX_NOTIFICATION_COUNT) + groupMessages.get(group).add(message); } // Difference @@ -1760,8 +1762,7 @@ class Core { Log.i("Notify existing=" + id); } else { remove.remove(-id); - if (add.size() < MAX_NOTIFICATION_COUNT) - add.add(id); + add.add(id); Log.i("Notify adding=" + id); } }