From 22d98bd1626391df86d29f5daeaf51462ea7b46a Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Mon, 12 Mar 2018 16:00:02 +0100 Subject: [PATCH] do not highlight users when not participating. fixes #2865 --- .../services/XmppConnectionService.java | 9 +++------ .../conversations/ui/ConversationFragment.java | 18 +++++++++++++----- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 457e4a0ba..181979ad1 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -1663,6 +1663,7 @@ public class XmppConnectionService extends Service { return conversation; } conversation = databaseBackend.findConversation(account, jid); + Log.d(Config.LOGTAG,"loaded from db: "+conversation.getNextMessage()); final boolean loadMessagesFromDb; if (conversation != null) { conversation.setStatus(Conversation.STATUS_AVAILABLE); @@ -1732,6 +1733,7 @@ public class XmppConnectionService extends Service { public void archiveConversation(Conversation conversation) { getNotificationService().clear(conversation); conversation.setStatus(Conversation.STATUS_ARCHIVED); + conversation.setNextMessage(null); synchronized (this.conversations) { getMessageArchiveService().kill(conversation); if (conversation.getMode() == Conversation.MODE_MULTI) { @@ -3028,12 +3030,7 @@ public class XmppConnectionService extends Service { } public void updateConversation(final Conversation conversation) { - mDatabaseWriterExecutor.execute(new Runnable() { - @Override - public void run() { - databaseBackend.updateConversation(conversation); - } - }); + mDatabaseWriterExecutor.execute(() -> databaseBackend.updateConversation(conversation)); } private void reconnectAccount(final Account account, final boolean force, final boolean interactive) { diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index e2cdb26f3..d072762e5 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -876,10 +876,15 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke if (message.getConversation().getMode() == Conversation.MODE_MULTI) { Jid user = message.getCounterpart(); if (user != null && !user.isBareJid()) { - if (!message.getConversation().getMucOptions().isUserInRoom(user)) { - Toast.makeText(getActivity(), activity.getString(R.string.user_has_left_conference, user.getResource()), Toast.LENGTH_SHORT).show(); + final MucOptions mucOptions = message.getConversation().getMucOptions(); + if (mucOptions.participating() || message.getConversation().getNextCounterpart() != null) { + if (!mucOptions.isUserInRoom(user)) { + Toast.makeText(getActivity(), activity.getString(R.string.user_has_left_conference, user.getResource()), Toast.LENGTH_SHORT).show(); + } + highlightInConference(user.getResource()); + } else { + Toast.makeText(getActivity(),R.string.you_are_not_participating, Toast.LENGTH_SHORT).show(); } - highlightInConference(user.getResource()); } return; } else { @@ -1732,7 +1737,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke } if (this.conversation != null) { final String msg = this.binding.textinput.getText().toString(); - if (this.conversation.setNextMessage(msg)) { + if (this.conversation.getStatus() != Conversation.STATUS_ARCHIVED && this.conversation.setNextMessage(msg)) { this.activity.xmppConnectionService.updateConversation(this.conversation); } updateChatState(this.conversation, msg); @@ -1867,7 +1872,10 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke //do nothing } } else { - highlightInConference(nick); + final MucOptions mucOptions = conversation.getMucOptions(); + if (mucOptions.participating() || conversation.getNextCounterpart() != null) { + highlightInConference(nick); + } } } else { appendText(text);