diff --git a/src/main/java/eu/siacs/conversations/services/NotificationService.java b/src/main/java/eu/siacs/conversations/services/NotificationService.java index 00738fa1c..2b3b3ad99 100644 --- a/src/main/java/eu/siacs/conversations/services/NotificationService.java +++ b/src/main/java/eu/siacs/conversations/services/NotificationService.java @@ -225,12 +225,11 @@ public class NotificationService { } synchronized (notifications) { markAsReadIfHasDirectReply(conversation); - //TODO: only update if something actually got removed? - notifications.remove(conversation.getUuid()); - final NotificationManagerCompat notificationManager = NotificationManagerCompat.from(mXmppConnectionService); - //TODO on later androids (that have multiple Conversations) maybe canceling is enough + update summary notification - notificationManager.cancel(conversation.getUuid(), NOTIFICATION_ID); - updateNotification(false); + if (notifications.remove(conversation.getUuid()) != null) { + final NotificationManagerCompat notificationManager = NotificationManagerCompat.from(mXmppConnectionService); + notificationManager.cancel(conversation.getUuid(), NOTIFICATION_ID); + updateNotification(false, true); + } } } @@ -254,6 +253,10 @@ public class NotificationService { } public void updateNotification(final boolean notify) { + updateNotification(notify, false); + } + + public void updateNotification(final boolean notify, boolean summaryOnly) { final NotificationManagerCompat notificationManager = NotificationManagerCompat.from(mXmppConnectionService); final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(mXmppConnectionService); @@ -271,11 +274,13 @@ public class NotificationService { } else { mBuilder = buildMultipleConversation(); modifyForSoundVibrationAndLight(mBuilder, notify, preferences); - for(Map.Entry> entry : notifications.entrySet()) { - Builder singleBuilder = buildSingleConversations(entry.getValue()); - singleBuilder.setGroup(CONVERSATIONS_GROUP); - setNotificationColor(singleBuilder); - notificationManager.notify(entry.getKey(), NOTIFICATION_ID ,singleBuilder.build()); + if (!summaryOnly) { + for (Map.Entry> entry : notifications.entrySet()) { + Builder singleBuilder = buildSingleConversations(entry.getValue()); + singleBuilder.setGroup(CONVERSATIONS_GROUP); + setNotificationColor(singleBuilder); + notificationManager.notify(entry.getKey(), NOTIFICATION_ID, singleBuilder.build()); + } } notificationManager.notify(NOTIFICATION_ID, mBuilder.build()); }