diff options
author | Christian Schneppe <christian@pix-art.de> | 2018-11-23 14:25:21 +0100 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2018-11-23 14:25:21 +0100 |
commit | e8f0927a8d64f96bde5917ef12ccb6b7d1fe0f52 (patch) | |
tree | 78875bbab6fd93fae07897ee0b3095c2c16e8382 /src/main | |
parent | 6969b92ac1d58617aca868d4f484b50515a516a5 (diff) |
provide option to reject subscription request when long pressing 'allow'
Diffstat (limited to '')
5 files changed, 34 insertions, 25 deletions
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java index 9d0071af2..9fcb83aa5 100644 --- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java +++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java @@ -2092,11 +2092,7 @@ public class XmppConnectionService extends Service { } else { conversation.endOtrIfNeeded(); 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); @@ -2105,6 +2101,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/de/pixart/messenger/ui/ContactDetailsActivity.java b/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java index 619c2b3f2..9db7ce7c9 100644 --- a/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java @@ -86,7 +86,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/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java index 69aa51918..cebc0f189 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java @@ -2332,25 +2332,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..0a86ef124 100644 --- a/src/main/res/menu/block.xml +++ b/src/main/res/menu/block.xml @@ -1,6 +1,9 @@ <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android"> <item + android:id="@+id/reject" + android:title="@string/reject_request" /> + <item android:id="@+id/block_domain" android:title="@string/block_entire_domain" /> <item diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index d884af1ab..7aeef797f 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -841,5 +841,6 @@ <string name="delete_message_dialog_msg">Are you sure you want to delete this message?\n\n<b>Warning:</b> This will not delete copies of this message that are stored on other devices or servers.</string> <string name="feature_not_implemented">Feature not implemented</string> <string name="device_does_not_support_unknown_source_op">Your device does not support allowing app installs from unknon sources.</string> + <string name="reject_request">Reject request</string> </resources> |