aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/de/pixart/messenger/services/NotificationService.java27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/main/java/de/pixart/messenger/services/NotificationService.java b/src/main/java/de/pixart/messenger/services/NotificationService.java
index 5d33e2b27..985af31c2 100644
--- a/src/main/java/de/pixart/messenger/services/NotificationService.java
+++ b/src/main/java/de/pixart/messenger/services/NotificationService.java
@@ -235,10 +235,11 @@ public class NotificationService {
}
synchronized (notifications) {
markAsReadIfHasDirectReply(conversation);
- notifications.remove(conversation.getUuid());
- final NotificationManagerCompat notificationManager = NotificationManagerCompat.from(mXmppConnectionService);
- 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);
+ }
}
}
@@ -262,6 +263,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);
@@ -273,19 +278,19 @@ public class NotificationService {
}
final Builder mBuilder;
if (notifications.size() == 1 && Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
- Log.d(Config.LOGTAG, "Notification: Received 1 single notification and using device < Android N");
mBuilder = buildSingleConversations(notifications.values().iterator().next());
modifyForSoundVibrationAndLight(mBuilder, notify, preferences);
notificationManager.notify(NOTIFICATION_ID, mBuilder.build());
} else {
- Log.d(Config.LOGTAG, "Notification: Received multiple notification or using Android N");
mBuilder = buildMultipleConversation();
modifyForSoundVibrationAndLight(mBuilder, notify, preferences);
- for (Map.Entry<String, ArrayList<Message>> 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<String, ArrayList<Message>> 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());
}