From 22a058ff615b902d2fc7464e99f5e865a6f199fa Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Mon, 11 Sep 2017 09:53:14 +0200 Subject: [PATCH] show block menu after long press on allow/add back --- .../ui/ConversationFragment.java | 29 +++++++++++++++---- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index 692b8f69f..bdfc29956 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -954,10 +954,8 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa } }; - private OnClickListener mBlockClickListener = new OnClickListener() { - @Override - public void onClick(final View view) { - final Jid jid = conversation.getJid(); + private void showBlockSubmenu(View view) { + final Jid jid = conversation.getJid(); if (jid.isDomainJid()) { BlockContactDialog.show(activity, conversation); } else { @@ -980,6 +978,12 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa }); popupMenu.show(); } + } + + private OnClickListener mBlockClickListener = new OnClickListener() { + @Override + public void onClick(final View view) { + showBlockSubmenu(view); } }; @@ -995,6 +999,14 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa } }; + private View.OnLongClickListener mLongPressBlockListener = new View.OnLongClickListener() { + @Override + public boolean onLongClick(View v) { + showBlockSubmenu(v); + return true; + } + }; + private OnClickListener mAllowPresenceSubscription = new OnClickListener() { @Override public void onClick(View v) { @@ -1030,9 +1042,9 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa } else if (conversation.isBlocked()) { showSnackbar(R.string.contact_blocked, R.string.unblock, this.mUnblockClickListener); } else if (contact != null && !contact.showInRoster() && contact.getOption(Contact.Options.PENDING_SUBSCRIPTION_REQUEST)) { - showSnackbar(R.string.contact_added_you, R.string.add_back, this.mAddBackClickListener); + showSnackbar(R.string.contact_added_you, R.string.add_back, this.mAddBackClickListener, this.mLongPressBlockListener); } else if (contact != null && contact.getOption(Contact.Options.PENDING_SUBSCRIPTION_REQUEST)) { - showSnackbar(R.string.contact_asks_for_presence_subscription, R.string.allow, this.mAllowPresenceSubscription); + showSnackbar(R.string.contact_asks_for_presence_subscription, R.string.allow, this.mAllowPresenceSubscription, this.mLongPressBlockListener); } else if (mode == Conversation.MODE_MULTI && !conversation.getMucOptions().online() && account.getStatus() == Account.State.ONLINE) { @@ -1384,6 +1396,10 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa } protected void showSnackbar(final int message, final int action, final OnClickListener clickListener) { + showSnackbar(message,action,clickListener,null); + } + + protected void showSnackbar(final int message, final int action, final OnClickListener clickListener, final View.OnLongClickListener longClickListener) { snackbar.setVisibility(View.VISIBLE); snackbar.setOnClickListener(null); snackbarMessage.setText(message); @@ -1393,6 +1409,7 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa snackbarAction.setText(action); } snackbarAction.setOnClickListener(clickListener); + snackbarAction.setOnLongClickListener(longClickListener); } protected void hideSnackbar() {