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", Element event = packet.findChild("event",
"http://jabber.org/protocol/pubsub#event"); "http://jabber.org/protocol/pubsub#event");
parseEvent(event, from, account); parseEvent(event, from, account);
} else if (from != null } else if (from != null && packet.hasChild("displayed", "urn:xmpp:chat-markers:0")) {
&& packet.hasChild("displayed", "urn:xmpp:chat-markers:0")) {
String id = packet String id = packet
.findChild("displayed", "urn:xmpp:chat-markers:0") .findChild("displayed", "urn:xmpp:chat-markers:0")
.getAttribute("id"); .getAttribute("id");
updateLastseen(packet, account, true); updateLastseen(packet, account, true);
mXmppConnectionService.markMessage(account, from.toBareJid(), final Message displayedMessage = mXmppConnectionService.markMessage(account, from.toBareJid(), id, Message.STATUS_SEND_DISPLAYED);
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 } else if (from != null
&& packet.hasChild("received", "urn:xmpp:chat-markers:0")) { && packet.hasChild("received", "urn:xmpp:chat-markers:0")) {
String id = packet.findChild("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, public Message markMessage(final Account account, final Jid recipient, final String uuid, final int status) {
final int status) {
if (uuid == null) { if (uuid == null) {
return false; return null;
} else { }
for (Conversation conversation : getConversations()) { for (Conversation conversation : getConversations()) {
if (conversation.getJid().equals(recipient) if (conversation.getJid().equals(recipient) && conversation.getAccount() == account) {
&& conversation.getAccount().equals(account)) { final Message message = conversation.findSentMessageWithUuid(uuid);
return markMessage(conversation, uuid, status); if (message != null) {
markMessage(message, status);
}
return message;
} }
} }
return false; return null;
}
} }
public boolean markMessage(Conversation conversation, String uuid, public boolean markMessage(Conversation conversation, String uuid,