From 4fd11a4c2b89efa8a920958bef9aa517dbad10ed Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Wed, 12 Apr 2017 20:54:32 +0200 Subject: [PATCH] show first instead of last message in notification preview --- .../conversations/services/NotificationService.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/services/NotificationService.java b/src/main/java/eu/siacs/conversations/services/NotificationService.java index f4d4b17d0..eb5362eaf 100644 --- a/src/main/java/eu/siacs/conversations/services/NotificationService.java +++ b/src/main/java/eu/siacs/conversations/services/NotificationService.java @@ -217,7 +217,9 @@ public class NotificationService { if (messages != null && messages.size() > 0) { Message last = messages.get(messages.size() - 1); if (last.getStatus() != Message.STATUS_RECEIVED) { - mXmppConnectionService.markRead(last.getConversation(), false); + if (mXmppConnectionService.markRead(last.getConversation(), false)) { + mXmppConnectionService.updateConversationUi(); + } } } } @@ -429,7 +431,7 @@ public class NotificationService { } else { if(messages.get(0).getConversation().getMode() == Conversation.MODE_SINGLE) { builder.setStyle(new NotificationCompat.BigTextStyle().bigText(getMergedBodies(messages))); - builder.setContentText(UIHelper.getMessagePreview(mXmppConnectionService, messages.get((messages.size() - 1))).first); + builder.setContentText(UIHelper.getMessagePreview(mXmppConnectionService, messages.get(0)).first); } else { final NotificationCompat.InboxStyle style = new NotificationCompat.InboxStyle(); SpannableString styledString; @@ -489,11 +491,11 @@ public class NotificationService { private CharSequence getMergedBodies(final ArrayList messages) { final StringBuilder text = new StringBuilder(); - for (int i = 0; i < messages.size(); ++i) { - text.append(UIHelper.getMessagePreview(mXmppConnectionService, messages.get(i)).first); - if (i != messages.size() - 1) { + for(Message message : messages) { + if (text.length() != 0) { text.append("\n"); } + text.append(UIHelper.getMessagePreview(mXmppConnectionService, message).first); } return text.toString(); }