diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 24026ae05..3653ff910 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -1839,11 +1839,7 @@ public class XmppConnectionService extends Service { leaveMuc(conversation); } else { if (conversation.getContact().getOption(Contact.Options.PENDING_SUBSCRIPTION_REQUEST)) { - Log.d(Config.LOGTAG, "Canceling presence request from " + conversation.getJid().toString()); - sendPresencePacket( - conversation.getAccount(), - mPresenceGenerator.stopPresenceUpdatesTo(conversation.getContact()) - ); + stopPresenceUpdatesTo(conversation.getContact()); } } updateConversation(conversation); @@ -1852,6 +1848,12 @@ public class XmppConnectionService extends Service { } } + public void stopPresenceUpdatesTo(Contact contact) { + Log.d(Config.LOGTAG, "Canceling presence request from " + contact.getJid().toString()); + sendPresencePacket(contact.getAccount(), mPresenceGenerator.stopPresenceUpdatesTo(contact)); + contact.resetOption(Contact.Options.PENDING_SUBSCRIPTION_REQUEST); + } + public void createAccount(final Account account) { account.initAccountServices(this); databaseBackend.createAccount(account); diff --git a/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java b/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java index cc1c0a16f..d68cb306a 100644 --- a/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java @@ -77,7 +77,7 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { if (contact.getOption(Contact.Options.PENDING_SUBSCRIPTION_REQUEST)) { - xmppConnectionService.sendPresencePacket(contact.getAccount(), xmppConnectionService.getPresenceGenerator().sendPresenceUpdatesTo(contact)); + xmppConnectionService.stopPresenceUpdatesTo(contact); } else { contact.setOption(Contact.Options.PREEMPTIVE_GRANT); } diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index b39f7ed45..0cdfaaaff 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -2071,25 +2071,28 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke private boolean showBlockSubmenu(View view) { final Jid jid = conversation.getJid(); - if (jid.getLocal() == null) { - BlockContactDialog.show(activity, conversation); - } else { - PopupMenu popupMenu = new PopupMenu(getActivity(), view); - popupMenu.inflate(R.menu.block); - popupMenu.setOnMenuItemClickListener(menuItem -> { - Blockable blockable; - switch (menuItem.getItemId()) { - case R.id.block_domain: - blockable = conversation.getAccount().getRoster().getContact(Jid.ofDomain(jid.getDomain())); - break; - default: - blockable = conversation; - } - BlockContactDialog.show(activity, blockable); - return true; - }); - popupMenu.show(); - } + final boolean showReject = !conversation.isWithStranger() && conversation.getContact().getOption(Contact.Options.PENDING_SUBSCRIPTION_REQUEST); + PopupMenu popupMenu = new PopupMenu(getActivity(), view); + popupMenu.inflate(R.menu.block); + popupMenu.getMenu().findItem(R.id.block_contact).setVisible(jid.getLocal() != null); + popupMenu.getMenu().findItem(R.id.reject).setVisible(showReject); + popupMenu.setOnMenuItemClickListener(menuItem -> { + Blockable blockable; + switch (menuItem.getItemId()) { + case R.id.reject: + activity.xmppConnectionService.stopPresenceUpdatesTo(conversation.getContact()); + updateSnackBar(conversation); + return true; + case R.id.block_domain: + blockable = conversation.getAccount().getRoster().getContact(Jid.ofDomain(jid.getDomain())); + break; + default: + blockable = conversation; + } + BlockContactDialog.show(activity, blockable); + return true; + }); + popupMenu.show(); return true; } diff --git a/src/main/res/menu/block.xml b/src/main/res/menu/block.xml index 1256f7142..04adad9d9 100644 --- a/src/main/res/menu/block.xml +++ b/src/main/res/menu/block.xml @@ -1,5 +1,8 @@