aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de/pixart/messenger')
-rw-r--r--src/main/java/de/pixart/messenger/ui/XmppActivity.java4
-rw-r--r--src/main/java/de/pixart/messenger/ui/util/MucDetailsContextMenuHelper.java21
2 files changed, 15 insertions, 10 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/XmppActivity.java b/src/main/java/de/pixart/messenger/ui/XmppActivity.java
index 4c756b2f6..398cf0e42 100644
--- a/src/main/java/de/pixart/messenger/ui/XmppActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/XmppActivity.java
@@ -666,11 +666,11 @@ public abstract class XmppActivity extends ActionBarActivity {
}
- protected void showAddToRosterDialog(final Conversation conversation) {
+ public void showAddToRosterDialog(final Conversation conversation) {
showAddToRosterDialog(conversation.getContact());
}
- protected void showAddToRosterDialog(final Contact contact) {
+ public void showAddToRosterDialog(final Contact contact) {
if (contact == null) {
return;
}
diff --git a/src/main/java/de/pixart/messenger/ui/util/MucDetailsContextMenuHelper.java b/src/main/java/de/pixart/messenger/ui/util/MucDetailsContextMenuHelper.java
index 9a785b0a7..d6f5c0f2b 100644
--- a/src/main/java/de/pixart/messenger/ui/util/MucDetailsContextMenuHelper.java
+++ b/src/main/java/de/pixart/messenger/ui/util/MucDetailsContextMenuHelper.java
@@ -79,6 +79,7 @@ public final class MucDetailsContextMenuHelper {
if (user != null && user.getRealJid() != null) {
MenuItem showContactDetails = menu.findItem(R.id.action_contact_details);
MenuItem startConversation = menu.findItem(R.id.start_conversation);
+ MenuItem addToRoster = menu.findItem(R.id.add_contact);
MenuItem giveMembership = menu.findItem(R.id.give_membership);
MenuItem removeMembership = menu.findItem(R.id.remove_membership);
MenuItem giveAdminPrivileges = menu.findItem(R.id.give_admin_privileges);
@@ -93,11 +94,13 @@ public final class MucDetailsContextMenuHelper {
MenuItem invite = menu.findItem(R.id.invite);
MenuItem highlightInMuc = menu.findItem(R.id.highlight_in_muc);
startConversation.setVisible(true);
- final Contact contact = user.getContact();
+ final Jid jid = user.getRealJid();
+ final Account account = conversation.getAccount();
+ final Contact contact = jid == null ? null : account.getRoster().getContact(jid);
final User self = conversation.getMucOptions().getSelf();
- if ((contact != null && contact.showInRoster()) || mucOptions.isPrivateAndNonAnonymous()) {
- showContactDetails.setVisible(contact == null || !contact.isSelf());
- }
+ addToRoster.setVisible(contact != null && !contact.showInRoster());
+ showContactDetails.setVisible(contact == null || !contact.isSelf());
+
if ((activity instanceof ConferenceDetailsActivity || activity instanceof MucUsersActivity) && user.getRole() == MucOptions.Role.NONE) {
invite.setVisible(true);
}
@@ -162,12 +165,11 @@ public final class MucDetailsContextMenuHelper {
public static boolean onContextItemSelected(MenuItem item, User user, XmppActivity activity, final String fingerprint) {
final Conversation conversation = user.getConversation();
final XmppConnectionService.OnAffiliationChanged onAffiliationChanged = activity instanceof XmppConnectionService.OnAffiliationChanged ? (XmppConnectionService.OnAffiliationChanged) activity : null;
- Jid jid = user.getRealJid();
+ final Jid jid = user.getRealJid();
+ final Account account = conversation.getAccount();
+ final Contact contact = jid == null ? null : account.getRoster().getContact(jid);
switch (item.getItemId()) {
case R.id.action_contact_details:
- final Jid realJid = user.getRealJid();
- final Account account = conversation.getAccount();
- final Contact contact = realJid == null ? null : account.getRoster().getContact(realJid);
if (contact != null) {
activity.switchToContactDetails(contact, fingerprint);
}
@@ -175,6 +177,9 @@ public final class MucDetailsContextMenuHelper {
case R.id.start_conversation:
startConversation(user, activity);
return true;
+ case R.id.add_contact:
+ activity.showAddToRosterDialog(contact);
+ return true;
case R.id.give_admin_privileges:
activity.xmppConnectionService.changeAffiliationInConference(conversation, jid, MucOptions.Affiliation.ADMIN, onAffiliationChanged);
return true;