From aea664a0eca8c6f4c2c7113563d7bb5201787c61 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Wed, 9 Dec 2015 10:26:30 +0100 Subject: [PATCH] show sender name for notications in conferences. fixes #1581 --- .../services/NotificationService.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/main/java/eu/siacs/conversations/services/NotificationService.java b/src/main/java/eu/siacs/conversations/services/NotificationService.java index b54e54826..03ab6f633 100644 --- a/src/main/java/eu/siacs/conversations/services/NotificationService.java +++ b/src/main/java/eu/siacs/conversations/services/NotificationService.java @@ -276,6 +276,8 @@ public class NotificationService { Message message; if ((message = getImage(messages)) != null) { modifyForImage(mBuilder, message, messages, notify); + } else if (conversation.getMode() == Conversation.MODE_MULTI) { + modifyForConference(mBuilder, conversation, messages, notify); } else { modifyForTextOnly(mBuilder, messages, notify); } @@ -336,6 +338,21 @@ public class NotificationService { } } + private void modifyForConference(Builder builder, Conversation conversation, List messages, boolean notify) { + final Message first = messages.get(0); + final Message last = messages.get(messages.size() - 1); + final NotificationCompat.InboxStyle style = new NotificationCompat.InboxStyle(); + style.setBigContentTitle(conversation.getName()); + for(Message message : messages) { + style.addLine(Html.fromHtml(""+UIHelper.getMessageDisplayName(message)+" "+UIHelper.getMessagePreview(mXmppConnectionService,message).first)); + } + builder.setContentText(UIHelper.getMessageDisplayName(first)+ ": " +UIHelper.getMessagePreview(mXmppConnectionService, messages.get(0)).first); + builder.setStyle(style); + if (notify) { + builder.setTicker(UIHelper.getMessageDisplayName(last) + ": " + UIHelper.getMessagePreview(mXmppConnectionService,last).first); + } + } + private Message getImage(final Iterable messages) { for (final Message message : messages) { if (message.getType() != Message.TYPE_TEXT