From eabedee9444409c9de5f779e5f392440989db52e Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Sat, 7 Apr 2018 23:47:48 +0200 Subject: do not highlight users when not participating --- .../messenger/services/XmppConnectionService.java | 9 +++------ .../pixart/messenger/ui/ConferenceDetailsActivity.java | 2 +- .../de/pixart/messenger/ui/ConversationFragment.java | 18 +++++++++++++----- 3 files changed, 17 insertions(+), 12 deletions(-) (limited to 'src/main/java/de/pixart/messenger') diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java index 5c19a9de2..cfdf14f9a 100644 --- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java +++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java @@ -1853,6 +1853,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); @@ -1978,6 +1979,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) { @@ -3370,12 +3372,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/de/pixart/messenger/ui/ConferenceDetailsActivity.java b/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java index cbcd573b9..b9113458f 100644 --- a/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java @@ -431,6 +431,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers menu.setHeaderTitle(name); MenuItem sendPrivateMessage = menu.findItem(R.id.send_private_message); MenuItem highlightInMuc = menu.findItem(R.id.highlight_in_muc); + highlightInMuc.setVisible(true); if (user.getRealJid() != null) { MenuItem startConversation = menu.findItem(R.id.start_conversation); MenuItem giveMembership = menu.findItem(R.id.give_membership); @@ -477,7 +478,6 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers sendPrivateMessage.setVisible(false); } } - highlightInMuc.setVisible(self.getRole().ranks(MucOptions.Role.PARTICIPANT)); } } diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java index 97e8bb5f0..39534be2d 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java @@ -1139,10 +1139,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(activity, getActivity().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 { @@ -2002,7 +2007,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); @@ -2145,7 +2150,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); -- cgit v1.2.3