diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2016-05-16 14:10:40 +0200 |
---|---|---|
committer | Daniel Gultsch <daniel@gultsch.de> | 2016-05-16 19:58:36 +0200 |
commit | 8d0693ed6a46ea45844f4d8319f5d051ec256756 (patch) | |
tree | aa9bc6af5d9832fe5d84adad3e8889ff5074a84c /src/main/java/eu/siacs/conversations/ui | |
parent | d7c5264ad0d74b043fd81e1120401b3b9bf91c66 (diff) |
keep conference members in memory and show them in conference details
Diffstat (limited to '')
3 files changed, 29 insertions, 34 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java b/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java index c806a03e4..bca1c1baa 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java @@ -1,6 +1,5 @@ package eu.siacs.conversations.ui; -import android.annotation.TargetApi; import android.app.AlertDialog; import android.app.PendingIntent; import android.content.ActivityNotFoundException; @@ -8,7 +7,6 @@ import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.IntentSender.SendIntentException; -import android.os.Build; import android.os.Bundle; import android.view.ContextMenu; import android.view.LayoutInflater; @@ -365,13 +363,13 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers final Contact contact = user.getContact(); if (contact != null) { name = contact.getDisplayName(); - } else if (user.getJid() != null){ - name = user.getJid().toBareJid().toString(); + } else if (user.getRealJid() != null){ + name = user.getRealJid().toBareJid().toString(); } else { name = user.getName(); } menu.setHeaderTitle(name); - if (user.getJid() != null) { + if (user.getRealJid() != null) { MenuItem showContactDetails = menu.findItem(R.id.action_contact_details); MenuItem startConversation = menu.findItem(R.id.start_conversation); MenuItem giveMembership = menu.findItem(R.id.give_membership); @@ -424,22 +422,22 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers startConversation(mSelectedUser); return true; case R.id.give_admin_privileges: - xmppConnectionService.changeAffiliationInConference(mConversation,mSelectedUser.getJid(), MucOptions.Affiliation.ADMIN,this); + xmppConnectionService.changeAffiliationInConference(mConversation,mSelectedUser.getRealJid(), MucOptions.Affiliation.ADMIN,this); return true; case R.id.give_membership: - xmppConnectionService.changeAffiliationInConference(mConversation,mSelectedUser.getJid(), MucOptions.Affiliation.MEMBER,this); + xmppConnectionService.changeAffiliationInConference(mConversation,mSelectedUser.getRealJid(), MucOptions.Affiliation.MEMBER,this); return true; case R.id.remove_membership: - xmppConnectionService.changeAffiliationInConference(mConversation,mSelectedUser.getJid(), MucOptions.Affiliation.NONE,this); + xmppConnectionService.changeAffiliationInConference(mConversation,mSelectedUser.getRealJid(), MucOptions.Affiliation.NONE,this); return true; case R.id.remove_admin_privileges: - xmppConnectionService.changeAffiliationInConference(mConversation,mSelectedUser.getJid(), MucOptions.Affiliation.MEMBER,this); + xmppConnectionService.changeAffiliationInConference(mConversation,mSelectedUser.getRealJid(), MucOptions.Affiliation.MEMBER,this); return true; case R.id.remove_from_room: removeFromRoom(mSelectedUser); return true; case R.id.ban_from_conference: - xmppConnectionService.changeAffiliationInConference(mConversation,mSelectedUser.getJid(), MucOptions.Affiliation.OUTCAST,this); + xmppConnectionService.changeAffiliationInConference(mConversation,mSelectedUser.getRealJid(), MucOptions.Affiliation.OUTCAST,this); xmppConnectionService.changeRoleInConference(mConversation,mSelectedUser.getName(), MucOptions.Role.NONE,this); return true; case R.id.send_private_message: @@ -452,7 +450,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers private void removeFromRoom(final User user) { if (mConversation.getMucOptions().membersOnly()) { - xmppConnectionService.changeAffiliationInConference(mConversation,user.getJid(), MucOptions.Affiliation.NONE,this); + xmppConnectionService.changeAffiliationInConference(mConversation,user.getRealJid(), MucOptions.Affiliation.NONE,this); xmppConnectionService.changeRoleInConference(mConversation,mSelectedUser.getName(), MucOptions.Role.NONE,ConferenceDetailsActivity.this); } else { AlertDialog.Builder builder = new AlertDialog.Builder(this); @@ -462,7 +460,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers builder.setPositiveButton(R.string.ban_now,new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - xmppConnectionService.changeAffiliationInConference(mConversation,user.getJid(), MucOptions.Affiliation.OUTCAST,ConferenceDetailsActivity.this); + xmppConnectionService.changeAffiliationInConference(mConversation,user.getRealJid(), MucOptions.Affiliation.OUTCAST,ConferenceDetailsActivity.this); xmppConnectionService.changeRoleInConference(mConversation,mSelectedUser.getName(), MucOptions.Role.NONE,ConferenceDetailsActivity.this); } }); @@ -471,8 +469,8 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers } protected void startConversation(User user) { - if (user.getJid() != null) { - Conversation conversation = xmppConnectionService.findOrCreateConversation(this.mConversation.getAccount(),user.getJid().toBareJid(),false); + if (user.getRealJid() != null) { + Conversation conversation = xmppConnectionService.findOrCreateConversation(this.mConversation.getAccount(),user.getRealJid().toBareJid(),false); switchToConversation(conversation); } } @@ -577,8 +575,8 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers final ArrayList<User> users = mucOptions.getUsers(); Collections.sort(users,new Comparator<User>() { @Override - public int compare(User lhs, User rhs) { - return lhs.getName().compareToIgnoreCase(rhs.getName()); + public int compare(User l, User r) { + return l.getName() == null || r.getName() == null ? 0 : l.getName().compareToIgnoreCase(r.getName()); } }); for (final User user : users) { @@ -607,11 +605,12 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers tvKey.setText(OpenPgpUtils.convertKeyIdToHex(user.getPgpKeyId())); } Contact contact = user.getContact(); + String name = user.getName(); if (contact != null) { tvDisplayName.setText(contact.getDisplayName()); - tvStatus.setText(user.getName() + " \u2022 " + getStatus(user)); + tvStatus.setText((name != null ? name+ " \u2022 " : "") + getStatus(user)); } else { - tvDisplayName.setText(user.getName()); + tvDisplayName.setText(name == null ? "" : name); tvStatus.setText(getStatus(user)); } @@ -657,7 +656,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers @Override public void onAffiliationChangedSuccessful(Jid jid) { - + refreshUi(); } @Override diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index 1c1fcb75d..f1352780a 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -461,12 +461,12 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa public void onContactPictureClicked(Message message) { if (message.getStatus() <= Message.STATUS_RECEIVED) { if (message.getConversation().getMode() == Conversation.MODE_MULTI) { - if (message.getCounterpart() != null) { - String user = message.getCounterpart().isBareJid() ? message.getCounterpart().toString() : message.getCounterpart().getResourcepart(); + Jid user = message.getCounterpart(); + if (user != null && !user.isBareJid()) { if (!message.getConversation().getMucOptions().isUserInRoom(user)) { - Toast.makeText(activity,activity.getString(R.string.user_has_left_conference,user),Toast.LENGTH_SHORT).show(); + Toast.makeText(activity,activity.getString(R.string.user_has_left_conference,user.getResourcepart()),Toast.LENGTH_SHORT).show(); } - highlightInConference(user); + highlightInConference(user.getResourcepart()); } } else { if (!message.getContact().isSelf()) { @@ -495,14 +495,12 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa public void onContactPictureLongClicked(Message message) { if (message.getStatus() <= Message.STATUS_RECEIVED) { if (message.getConversation().getMode() == Conversation.MODE_MULTI) { - if (message.getCounterpart() != null) { - 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(); - } + Jid user = message.getCounterpart(); + if (user != null && !user.isBareJid()) { + if (message.getConversation().getMucOptions().isUserInRoom(user)) { + privateMessageWith(user); + } else { + Toast.makeText(activity, activity.getString(R.string.user_has_left_conference, user.getResourcepart()), Toast.LENGTH_SHORT).show(); } } } diff --git a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java index 5ce74824a..e963ef4c7 100644 --- a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java @@ -42,7 +42,6 @@ import android.preference.PreferenceManager; import android.text.InputType; import android.util.DisplayMetrics; import android.util.Log; -import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.inputmethod.InputMethodManager; @@ -68,7 +67,6 @@ import java.util.ArrayList; import java.util.Hashtable; import java.util.List; import java.util.concurrent.RejectedExecutionException; -import java.util.concurrent.RunnableFuture; import eu.siacs.conversations.Config; import eu.siacs.conversations.R; @@ -481,7 +479,7 @@ public abstract class XmppActivity extends Activity { List<String> contacts = new ArrayList<>(); if (conversation.getMode() == Conversation.MODE_MULTI) { for (MucOptions.User user : conversation.getMucOptions().getUsers()) { - Jid jid = user.getJid(); + Jid jid = user.getRealJid(); if (jid != null) { contacts.add(jid.toBareJid().toString()); } |