diff options
author | Christian Schneppe <christian.schneppe@pix-art.de> | 2019-10-27 01:09:46 +0200 |
---|---|---|
committer | Christian Schneppe <christian.schneppe@pix-art.de> | 2019-10-27 01:09:46 +0200 |
commit | 6929196af092405997cbdb27186171dfe8ed6d42 (patch) | |
tree | 4695b347f9faa7bb9b2bee3f6c68cf67260eb270 /src | |
parent | 131102939ce9065ee655c691ba8350d78aaaa913 (diff) |
add user to roster on avatar long press
Diffstat (limited to '')
3 files changed, 20 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; diff --git a/src/main/res/menu/muc_details_context.xml b/src/main/res/menu/muc_details_context.xml index 22d99268f..71b9d4bfb 100644 --- a/src/main/res/menu/muc_details_context.xml +++ b/src/main/res/menu/muc_details_context.xml @@ -12,6 +12,11 @@ android:title="@string/highlight_in_muc" android:visible="false" /> <item + android:id="@+id/add_contact" + android:orderInCategory="100" + android:title="@string/add_to_contact_list" + android:visible="false" /> + <item android:id="@+id/start_conversation" android:orderInCategory="100" android:title="@string/start_conversation" |