mark all sent messages up to a marker as displayed

This commit is contained in:
Daniel Gultsch 2015-03-01 14:15:40 +01:00
parent d318af098d
commit ff86fa6049
2 changed files with 21 additions and 15 deletions

View file

@ -402,14 +402,19 @@ public class MessageParser extends AbstractParser implements
Element event = packet.findChild("event",
"http://jabber.org/protocol/pubsub#event");
parseEvent(event, from, account);
} else if (from != null
&& packet.hasChild("displayed", "urn:xmpp:chat-markers:0")) {
} else if (from != null && packet.hasChild("displayed", "urn:xmpp:chat-markers:0")) {
String id = packet
.findChild("displayed", "urn:xmpp:chat-markers:0")
.getAttribute("id");
updateLastseen(packet, account, true);
mXmppConnectionService.markMessage(account, from.toBareJid(),
id, Message.STATUS_SEND_DISPLAYED);
final Message displayedMessage = mXmppConnectionService.markMessage(account, from.toBareJid(), id, Message.STATUS_SEND_DISPLAYED);
Message message = displayedMessage.prev();
while(message != null
&& message.getStatus() == Message.STATUS_SEND_RECEIVED
&& message.getTimeSent() < displayedMessage.getTimeSent()) {
mXmppConnectionService.markMessage(message,Message.STATUS_SEND_DISPLAYED);
message = message.prev();
}
} else if (from != null
&& packet.hasChild("received", "urn:xmpp:chat-markers:0")) {
String id = packet.findChild("received", "urn:xmpp:chat-markers:0")

View file

@ -2013,19 +2013,20 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
}
}
public boolean markMessage(final Account account, final Jid recipient, final String uuid,
final int status) {
public Message markMessage(final Account account, final Jid recipient, final String uuid, final int status) {
if (uuid == null) {
return false;
} else {
for (Conversation conversation : getConversations()) {
if (conversation.getJid().equals(recipient)
&& conversation.getAccount().equals(account)) {
return markMessage(conversation, uuid, status);
}
}
return false;
return null;
}
for (Conversation conversation : getConversations()) {
if (conversation.getJid().equals(recipient) && conversation.getAccount() == account) {
final Message message = conversation.findSentMessageWithUuid(uuid);
if (message != null) {
markMessage(message, status);
}
return message;
}
}
return null;
}
public boolean markMessage(Conversation conversation, String uuid,