aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2017-09-17 20:25:58 +0200
committerChristian Schneppe <christian@pix-art.de>2017-09-17 20:27:27 +0200
commit814b5443205e1755ecd76dac0a7f37e89b3d1137 (patch)
treed8f459df7efcb2abfc72265be066eb5870c6dfe8 /src/main/java
parent9522577e5ba97fa52277a5d7ba9163687743ba24 (diff)
show block menu after long press on allow/add back
Diffstat (limited to '')
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConversationFragment.java67
1 files changed, 42 insertions, 25 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
index 7832470a4..29862861c 100644
--- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
+++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
@@ -975,32 +975,36 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
}
};
+ private void showBlockSubmenu(View view) {
+ final Jid jid = conversation.getJid();
+ if (jid.isDomainJid()) {
+ BlockContactDialog.show(activity, conversation);
+ } else {
+ PopupMenu popupMenu = new PopupMenu(activity, view);
+ popupMenu.inflate(R.menu.block);
+ popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
+ @Override
+ public boolean onMenuItemClick(MenuItem menuItem) {
+ Blockable blockable;
+ switch (menuItem.getItemId()) {
+ case R.id.block_domain:
+ blockable = conversation.getAccount().getRoster().getContact(jid.toDomainJid());
+ break;
+ default:
+ blockable = conversation;
+ }
+ BlockContactDialog.show(activity, blockable);
+ return true;
+ }
+ });
+ popupMenu.show();
+ }
+ }
+
private OnClickListener mBlockClickListener = new OnClickListener() {
@Override
public void onClick(final View view) {
- final Jid jid = conversation.getJid();
- if (jid.isDomainJid()) {
- BlockContactDialog.show(activity, conversation);
- } else {
- PopupMenu popupMenu = new PopupMenu(activity, view);
- popupMenu.inflate(R.menu.block);
- popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
- @Override
- public boolean onMenuItemClick(MenuItem menuItem) {
- Blockable blockable;
- switch (menuItem.getItemId()) {
- case R.id.block_domain:
- blockable = conversation.getAccount().getRoster().getContact(jid.toDomainJid());
- break;
- default:
- blockable = conversation;
- }
- BlockContactDialog.show(activity, blockable);
- return true;
- }
- });
- popupMenu.show();
- }
+ showBlockSubmenu(view);
}
};
@@ -1016,6 +1020,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) {
@@ -1051,9 +1063,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.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.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) {
@@ -1355,6 +1367,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);
@@ -1364,6 +1380,7 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
snackbarAction.setText(action);
}
snackbarAction.setOnClickListener(clickListener);
+ snackbarAction.setOnLongClickListener(longClickListener);
}
protected void hideSnackbar() {