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

View file

@ -217,7 +217,9 @@ public class NotificationService {
if (messages != null && messages.size() > 0) { if (messages != null && messages.size() > 0) {
Message last = messages.get(messages.size() - 1); Message last = messages.get(messages.size() - 1);
if (last.getStatus() != Message.STATUS_RECEIVED) { 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 { } else {
if(messages.get(0).getConversation().getMode() == Conversation.MODE_SINGLE) { if(messages.get(0).getConversation().getMode() == Conversation.MODE_SINGLE) {
builder.setStyle(new NotificationCompat.BigTextStyle().bigText(getMergedBodies(messages))); 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 { } else {
final NotificationCompat.InboxStyle style = new NotificationCompat.InboxStyle(); final NotificationCompat.InboxStyle style = new NotificationCompat.InboxStyle();
SpannableString styledString; SpannableString styledString;
@ -489,11 +491,11 @@ public class NotificationService {
private CharSequence getMergedBodies(final ArrayList<Message> messages) { private CharSequence getMergedBodies(final ArrayList<Message> messages) {
final StringBuilder text = new StringBuilder(); final StringBuilder text = new StringBuilder();
for (int i = 0; i < messages.size(); ++i) { for(Message message : messages) {
text.append(UIHelper.getMessagePreview(mXmppConnectionService, messages.get(i)).first); if (text.length() != 0) {
if (i != messages.size() - 1) {
text.append("\n"); text.append("\n");
} }
text.append(UIHelper.getMessagePreview(mXmppConnectionService, message).first);
} }
return text.toString(); return text.toString();
} }