diff --git a/src/eu/siacs/conversations/parser/MessageParser.java b/src/eu/siacs/conversations/parser/MessageParser.java index c8718edb0..e09dd0c5b 100644 --- a/src/eu/siacs/conversations/parser/MessageParser.java +++ b/src/eu/siacs/conversations/parser/MessageParser.java @@ -1,6 +1,7 @@ package eu.siacs.conversations.parser; import android.os.SystemClock; +import android.util.Log; import net.java.otr4j.session.Session; import net.java.otr4j.session.SessionStatus; import eu.siacs.conversations.Config; @@ -202,10 +203,24 @@ public class MessageParser extends AbstractParser implements return null; } Element message = forwarded.findChild("message"); - if ((message == null) || (!message.hasChild("body"))) { + if (message == null) { + return null; + } + if (!message.hasChild("body")) { if (status == Message.STATUS_RECEIVED && message.getAttribute("from") != null) { parseNonMessage(message, account); + } else if (status == Message.STATUS_SEND + && message.hasChild("displayed", "urn:xmpp:chat-markers:0")) { + String to = message.getAttribute("to"); + if (to != null) { + Conversation conversation = mXmppConnectionService.find( + mXmppConnectionService.getConversations(), account, + to.split("/")[0]); + if (conversation != null) { + mXmppConnectionService.markRead(conversation, false); + } + } } return null; } @@ -419,7 +434,8 @@ public class MessageParser extends AbstractParser implements lastCarbonMessageReceived = SystemClock .elapsedRealtime(); notify = false; - mXmppConnectionService.markRead(message.getConversation()); + mXmppConnectionService.markRead( + message.getConversation(), false); } else { message.markUnread(); } @@ -436,7 +452,8 @@ public class MessageParser extends AbstractParser implements || NotificationService .wasHighlightedOrPrivate(message); } else { - mXmppConnectionService.markRead(message.getConversation()); + mXmppConnectionService.markRead(message.getConversation(), + false); lastCarbonMessageReceived = SystemClock.elapsedRealtime(); notify = false; } diff --git a/src/eu/siacs/conversations/services/XmppConnectionService.java b/src/eu/siacs/conversations/services/XmppConnectionService.java index ea2b59038..557a625b0 100644 --- a/src/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/eu/siacs/conversations/services/XmppConnectionService.java @@ -1631,16 +1631,19 @@ public class XmppConnectionService extends Service { return null; } - public void markRead(Conversation conversation) { + public void markRead(Conversation conversation, boolean calledByUi) { conversation.markRead(); mNotificationService.clear(conversation); String id = conversation.popLatestMarkableMessageId(); - if (confirmMessages() && id != null) { + if (confirmMessages() && id != null && calledByUi) { Account account = conversation.getAccount(); String to = conversation.getContactJid(); this.sendMessagePacket(conversation.getAccount(), mMessageGenerator.confirm(account, to, id)); } + if (!calledByUi) { + updateConversationUi(); + } } public void failWaitingOtrMessages(Conversation conversation) { diff --git a/src/eu/siacs/conversations/ui/ConversationActivity.java b/src/eu/siacs/conversations/ui/ConversationActivity.java index 03cf753d3..0c67beff9 100644 --- a/src/eu/siacs/conversations/ui/ConversationActivity.java +++ b/src/eu/siacs/conversations/ui/ConversationActivity.java @@ -156,7 +156,7 @@ public class ConversationActivity extends XmppActivity implements openConversation(getSelectedConversation()); if (!getSelectedConversation().isRead()) { xmppConnectionService - .markRead(getSelectedConversation()); + .markRead(getSelectedConversation(),true); listView.invalidateViews(); } } diff --git a/src/eu/siacs/conversations/ui/ConversationFragment.java b/src/eu/siacs/conversations/ui/ConversationFragment.java index 064b00be4..34c68e00b 100644 --- a/src/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/eu/siacs/conversations/ui/ConversationFragment.java @@ -494,7 +494,7 @@ public class ConversationFragment extends Fragment { getActivity().invalidateOptionsMenu(); updateChatMsgHint(); if (!activity.shouldPaneBeOpen()) { - activity.xmppConnectionService.markRead(conversation); + activity.xmppConnectionService.markRead(conversation,true); activity.updateConversationList(); } this.updateSendButton();