show first instead of last message in notification preview

This commit is contained in:
Daniel Gultsch 2017-04-12 20:54:32 +02:00
parent 4bbf2dab99
commit 4fd11a4c2b
1 changed files with 7 additions and 5 deletions

View File

@ -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<Message> 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();
}