show warning when trying to highlight users that have left the conference

This commit is contained in:
Daniel Gultsch 2015-07-22 15:57:17 +02:00
parent f7634a85be
commit cd204d5931
3 changed files with 22 additions and 5 deletions

View File

@ -264,6 +264,15 @@ public class MucOptions {
users.add(user); users.add(user);
} }
public boolean isUserInRoom(String name) {
for (int i = 0; i < users.size(); ++i) {
if (users.get(i).getName().equals(name)) {
return true;
}
}
return false;
}
public void processPacket(PresencePacket packet, PgpEngine pgp) { public void processPacket(PresencePacket packet, PgpEngine pgp) {
final Jid from = packet.getFrom(); final Jid from = packet.getFrom();
if (!from.isBareJid()) { if (!from.isBareJid()) {

View File

@ -385,11 +385,11 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
if (message.getStatus() <= Message.STATUS_RECEIVED) { if (message.getStatus() <= Message.STATUS_RECEIVED) {
if (message.getConversation().getMode() == Conversation.MODE_MULTI) { if (message.getConversation().getMode() == Conversation.MODE_MULTI) {
if (message.getCounterpart() != null) { if (message.getCounterpart() != null) {
if (!message.getCounterpart().isBareJid()) { String user = message.getCounterpart().isBareJid() ? message.getCounterpart().toString() : message.getCounterpart().getResourcepart();
highlightInConference(message.getCounterpart().getResourcepart()); if (!message.getConversation().getMucOptions().isUserInRoom(user)) {
} else { Toast.makeText(activity,activity.getString(R.string.user_has_left_conference,user),Toast.LENGTH_SHORT).show();
highlightInConference(message.getCounterpart().toString());
} }
highlightInConference(user);
} }
} else { } else {
activity.switchToContactDetails(message.getContact()); activity.switchToContactDetails(message.getContact());
@ -410,7 +410,14 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
if (message.getStatus() <= Message.STATUS_RECEIVED) { if (message.getStatus() <= Message.STATUS_RECEIVED) {
if (message.getConversation().getMode() == Conversation.MODE_MULTI) { if (message.getConversation().getMode() == Conversation.MODE_MULTI) {
if (message.getCounterpart() != null) { if (message.getCounterpart() != null) {
privateMessageWith(message.getCounterpart()); String user = message.getCounterpart().getResourcepart();
if (user != null) {
if (message.getConversation().getMucOptions().isUserInRoom(user)) {
privateMessageWith(message.getCounterpart());
} else {
Toast.makeText(activity, activity.getString(R.string.user_has_left_conference, user), Toast.LENGTH_SHORT).show();
}
}
} }
} }
} else { } else {

View File

@ -498,4 +498,5 @@
<string name="file_not_found_on_remote_host">File not found on remote server</string> <string name="file_not_found_on_remote_host">File not found on remote server</string>
<string name="search_for_contacts_or_groups">Search for contacts or groups</string> <string name="search_for_contacts_or_groups">Search for contacts or groups</string>
<string name="send_private_message">Send private message</string> <string name="send_private_message">Send private message</string>
<string name="user_has_left_conference">%s has left the conference!</string>
</resources> </resources>