diff options
author | Christian Schneppe <christian@pix-art.de> | 2016-08-31 21:37:19 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2016-08-31 21:37:19 +0200 |
commit | 6d9adf1ba4afa602926147ec69da01bf6826aefa (patch) | |
tree | b2182219eea84a0d0f0ae80ded2e39938ad498bc /src/main/java/de/pixart/messenger/services/NotificationService.java | |
parent | 87049340caf3c000de6ed46589e13cf9948127f6 (diff) |
fix multiple notifications and added unread messages as summary
Diffstat (limited to '')
-rw-r--r-- | src/main/java/de/pixart/messenger/services/NotificationService.java | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/main/java/de/pixart/messenger/services/NotificationService.java b/src/main/java/de/pixart/messenger/services/NotificationService.java index c2e62fbd6..9c5f46282 100644 --- a/src/main/java/de/pixart/messenger/services/NotificationService.java +++ b/src/main/java/de/pixart/messenger/services/NotificationService.java @@ -159,6 +159,7 @@ public class NotificationService { } if (this.mIsInForeground && isScreenOn) { mXmppConnectionService.vibrate(); + return; } synchronized (notifications) { pushToStack(message); @@ -223,20 +224,26 @@ 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); notificationManager.notify(NOTIFICATION_ID, mBuilder.build()); - for(Map.Entry<String,ArrayList<Message>> entry : notifications.entrySet()) { - Builder singleBuilder = buildSingleConversations(entry.getValue()); - singleBuilder.setGroup(CONVERSATIONS_GROUP); - modifyForSoundVibrationAndLight(singleBuilder,notify,preferences); - notificationManager.notify(entry.getKey(), NOTIFICATION_ID ,singleBuilder.build()); - } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + for (Map.Entry<String, ArrayList<Message>> entry : notifications.entrySet()) { + Log.d(Config.LOGTAG, "Notification: Received notification for Android N"); + Builder singleBuilder = buildSingleConversations(entry.getValue()); + singleBuilder.setGroup(CONVERSATIONS_GROUP); + modifyForSoundVibrationAndLight(singleBuilder, notify, preferences); + notificationManager.notify(entry.getKey(), NOTIFICATION_ID, singleBuilder.build()); + } + } } + mBuilder.setNumber(mXmppConnectionService.unreadCount()); } } @@ -269,10 +276,13 @@ public class NotificationService { final Builder mBuilder = new NotificationCompat.Builder( mXmppConnectionService); final NotificationCompat.InboxStyle style = new NotificationCompat.InboxStyle(); + Integer Unread = mXmppConnectionService.unreadCount(); + String SummaryText = mXmppConnectionService.getString(R.string.unread_messages) + " " + Unread.toString(); style.setBigContentTitle(notifications.size() + " " + mXmppConnectionService .getString(R.string.unread_conversations)); + style.setSummaryText(SummaryText); final StringBuilder names = new StringBuilder(); Conversation conversation = null; for (final ArrayList<Message> messages : notifications.values()) { |