provide option to reject subscription request when long pressing 'allow'
This commit is contained in:
parent
4f22859acf
commit
cf18bd08fc
|
@ -1839,11 +1839,7 @@ public class XmppConnectionService extends Service {
|
||||||
leaveMuc(conversation);
|
leaveMuc(conversation);
|
||||||
} else {
|
} else {
|
||||||
if (conversation.getContact().getOption(Contact.Options.PENDING_SUBSCRIPTION_REQUEST)) {
|
if (conversation.getContact().getOption(Contact.Options.PENDING_SUBSCRIPTION_REQUEST)) {
|
||||||
Log.d(Config.LOGTAG, "Canceling presence request from " + conversation.getJid().toString());
|
stopPresenceUpdatesTo(conversation.getContact());
|
||||||
sendPresencePacket(
|
|
||||||
conversation.getAccount(),
|
|
||||||
mPresenceGenerator.stopPresenceUpdatesTo(conversation.getContact())
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateConversation(conversation);
|
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) {
|
public void createAccount(final Account account) {
|
||||||
account.initAccountServices(this);
|
account.initAccountServices(this);
|
||||||
databaseBackend.createAccount(account);
|
databaseBackend.createAccount(account);
|
||||||
|
|
|
@ -77,7 +77,7 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
if (isChecked) {
|
if (isChecked) {
|
||||||
if (contact.getOption(Contact.Options.PENDING_SUBSCRIPTION_REQUEST)) {
|
if (contact.getOption(Contact.Options.PENDING_SUBSCRIPTION_REQUEST)) {
|
||||||
xmppConnectionService.sendPresencePacket(contact.getAccount(), xmppConnectionService.getPresenceGenerator().sendPresenceUpdatesTo(contact));
|
xmppConnectionService.stopPresenceUpdatesTo(contact);
|
||||||
} else {
|
} else {
|
||||||
contact.setOption(Contact.Options.PREEMPTIVE_GRANT);
|
contact.setOption(Contact.Options.PREEMPTIVE_GRANT);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2071,25 +2071,28 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
||||||
|
|
||||||
private boolean showBlockSubmenu(View view) {
|
private boolean showBlockSubmenu(View view) {
|
||||||
final Jid jid = conversation.getJid();
|
final Jid jid = conversation.getJid();
|
||||||
if (jid.getLocal() == null) {
|
final boolean showReject = !conversation.isWithStranger() && conversation.getContact().getOption(Contact.Options.PENDING_SUBSCRIPTION_REQUEST);
|
||||||
BlockContactDialog.show(activity, conversation);
|
PopupMenu popupMenu = new PopupMenu(getActivity(), view);
|
||||||
} else {
|
popupMenu.inflate(R.menu.block);
|
||||||
PopupMenu popupMenu = new PopupMenu(getActivity(), view);
|
popupMenu.getMenu().findItem(R.id.block_contact).setVisible(jid.getLocal() != null);
|
||||||
popupMenu.inflate(R.menu.block);
|
popupMenu.getMenu().findItem(R.id.reject).setVisible(showReject);
|
||||||
popupMenu.setOnMenuItemClickListener(menuItem -> {
|
popupMenu.setOnMenuItemClickListener(menuItem -> {
|
||||||
Blockable blockable;
|
Blockable blockable;
|
||||||
switch (menuItem.getItemId()) {
|
switch (menuItem.getItemId()) {
|
||||||
case R.id.block_domain:
|
case R.id.reject:
|
||||||
blockable = conversation.getAccount().getRoster().getContact(Jid.ofDomain(jid.getDomain()));
|
activity.xmppConnectionService.stopPresenceUpdatesTo(conversation.getContact());
|
||||||
break;
|
updateSnackBar(conversation);
|
||||||
default:
|
return true;
|
||||||
blockable = conversation;
|
case R.id.block_domain:
|
||||||
}
|
blockable = conversation.getAccount().getRoster().getContact(Jid.ofDomain(jid.getDomain()));
|
||||||
BlockContactDialog.show(activity, blockable);
|
break;
|
||||||
return true;
|
default:
|
||||||
});
|
blockable = conversation;
|
||||||
popupMenu.show();
|
}
|
||||||
}
|
BlockContactDialog.show(activity, blockable);
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
popupMenu.show();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item
|
||||||
|
android:id="@+id/reject"
|
||||||
|
android:title="@string/reject_request"/>
|
||||||
<item
|
<item
|
||||||
android:id="@+id/block_domain"
|
android:id="@+id/block_domain"
|
||||||
android:title="@string/block_entire_domain" />
|
android:title="@string/block_entire_domain" />
|
||||||
|
|
|
@ -797,4 +797,5 @@
|
||||||
<string name="your_name">Your name</string>
|
<string name="your_name">Your name</string>
|
||||||
<string name="enter_your_name">Enter your name</string>
|
<string name="enter_your_name">Enter your name</string>
|
||||||
<string name="no_name_set_instructions">Use the edit button to set your name.</string>
|
<string name="no_name_set_instructions">Use the edit button to set your name.</string>
|
||||||
|
<string name="reject_request">Reject request</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in a new issue