diff --git a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java
index 82b6d9bb8..660efbb03 100644
--- a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java
@@ -1285,10 +1285,18 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
public static class MyListFragment extends SwipeRefreshListFragment {
private AdapterView.OnItemClickListener mOnItemClickListener;
- private int mResContextMenu;
+ private int mResContextMenuConference;
+ private int mResContextMenuContact;
- public void setContextMenu(final int res) {
- this.mResContextMenu = res;
+ private boolean itemsFromContacts;
+
+ public void setContextMenu(final int resConference, final int resContact) {
+ this.mResContextMenuConference = resConference;
+ this.mResContextMenuContact = resContact;
+ }
+
+ public void setItemsFromContacts(boolean itemsFromContacts) {
+ this.itemsFromContacts = itemsFromContacts;
}
@Override
@@ -1338,17 +1346,42 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
if (activity == null) {
return;
}
- activity.getMenuInflater().inflate(mResContextMenu, menu);
- final AdapterView.AdapterContextMenuInfo acmi = (AdapterContextMenuInfo) menuInfo;
- if (mResContextMenu == R.menu.conference_context) {
- activity.conference_context_id = acmi.position;
- final Bookmark bookmark = (Bookmark) activity.conferences.get(acmi.position);
+
+ int position;
+
+ if (menuInfo instanceof AdapterContextMenuInfo) {
+ final AdapterView.AdapterContextMenuInfo acmi = (AdapterContextMenuInfo) menuInfo;
+ position = acmi.position;
+ } else {
+ final ExpandableListView.ExpandableListContextMenuInfo acmi = (ExpandableListView.ExpandableListContextMenuInfo) menuInfo;
+ position = (int) acmi.targetView.getTag(R.id.TAG_POSITION);
+ }
+
+ int resContextMenu;
+
+ ListItem item = activity.contacts.get(position);
+ if (itemsFromContacts) {
+ if (item instanceof Bookmark) {
+ resContextMenu = mResContextMenuConference;
+ } else {
+ resContextMenu = mResContextMenuContact;
+ }
+ } else {
+ resContextMenu = mResContextMenuConference;
+ }
+
+ activity.getMenuInflater().inflate(resContextMenu, menu);
+
+
+ if (resContextMenu == R.menu.conference_context) {
+ activity.conference_context_id = position;
+ final Bookmark bookmark = (Bookmark) item;
final Conversation conversation = bookmark.getConversation();
final MenuItem share = menu.findItem(R.id.context_share_uri);
share.setVisible(conversation == null || !conversation.isPrivateAndNonAnonymous());
- } else if (mResContextMenu == R.menu.contact_context) {
- activity.contact_context_id = acmi.position;
- final Contact contact = (Contact) activity.contacts.get(acmi.position);
+ } else if (resContextMenu == R.menu.contact_context) {
+ activity.contact_context_id = position;
+ final Contact contact = (Contact) item;
final MenuItem blockUnblockItem = menu.findItem(R.id.context_contact_block_unblock);
final MenuItem showContactDetailsItem = menu.findItem(R.id.context_contact_details);
final MenuItem deleteContactMenuItem = menu.findItem(R.id.context_delete_contact);
@@ -1463,11 +1496,13 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
final MyListFragment listFragment = new MyListFragment();
if (position == 1) {
listFragment.setListAdapter(mConferenceAdapter);
- listFragment.setContextMenu(R.menu.conference_context);
+ listFragment.setContextMenu(R.menu.conference_context, R.menu.contact_context);
+ listFragment.setItemsFromContacts(false);
listFragment.setOnListItemClickListener((arg0, arg1, p, arg3) -> openConversationForBookmark(p));
} else {
listFragment.setListAdapter(mContactsAdapter);
- listFragment.setContextMenu(R.menu.contact_context);
+ listFragment.setContextMenu(R.menu.conference_context, R.menu.contact_context);
+ listFragment.setItemsFromContacts(true);
listFragment.setOnListItemClickListener((arg0, arg1, p, arg3) -> openConversationForContact(p));
if (QuickConversationsService.isQuicksy()) {
listFragment.setOnRefreshListener(StartConversationActivity.this);
@@ -1772,7 +1807,10 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
@Override
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
ListItem item = getChildsList(groupPosition).get(childPosition);
- return super.getView(super.getPosition(item), convertView, parent);
+ int position = super.getPosition(item);
+ View view = super.getView(super.getPosition(item), convertView, parent);
+ view.setTag(R.id.TAG_POSITION, position);
+ return view;
}
@Override
diff --git a/src/main/res/values/ids.xml b/src/main/res/values/ids.xml
index 4ed99764b..2772a2297 100644
--- a/src/main/res/values/ids.xml
+++ b/src/main/res/values/ids.xml
@@ -5,4 +5,5 @@
+
\ No newline at end of file