Search in sources :

Example 1 with Blockable

use of eu.siacs.conversations.entities.Blockable in project Conversations by siacs.

the class ConversationFragment method showBlockSubmenu.

private boolean showBlockSubmenu(View view) {
    final Jid jid = conversation.getJid();
    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.getDomain());
                break;
            default:
                blockable = conversation;
        }
        BlockContactDialog.show(activity, blockable);
        return true;
    });
    popupMenu.show();
    return true;
}
Also used : Jid(eu.siacs.conversations.xmpp.Jid) PopupMenu(android.widget.PopupMenu) Blockable(eu.siacs.conversations.entities.Blockable)

Example 2 with Blockable

use of eu.siacs.conversations.entities.Blockable in project Conversations by siacs.

the class BlocklistActivity method showEnterJidDialog.

protected void showEnterJidDialog() {
    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    Fragment prev = getSupportFragmentManager().findFragmentByTag("dialog");
    if (prev != null) {
        ft.remove(prev);
    }
    ft.addToBackStack(null);
    EnterJidDialog dialog = EnterJidDialog.newInstance(null, getString(R.string.block_jabber_id), getString(R.string.block), null, account.getJid().asBareJid().toEscapedString(), true, false);
    dialog.setOnEnterJidDialogPositiveListener((accountJid, contactJid) -> {
        Blockable blockable = new RawBlockable(account, contactJid);
        if (xmppConnectionService.sendBlockRequest(blockable, false)) {
            Toast.makeText(BlocklistActivity.this, R.string.corresponding_conversations_closed, Toast.LENGTH_SHORT).show();
        }
        return true;
    });
    dialog.show(ft, "dialog");
}
Also used : FragmentTransaction(androidx.fragment.app.FragmentTransaction) RawBlockable(eu.siacs.conversations.entities.RawBlockable) Fragment(androidx.fragment.app.Fragment) RawBlockable(eu.siacs.conversations.entities.RawBlockable) Blockable(eu.siacs.conversations.entities.Blockable)

Aggregations

Blockable (eu.siacs.conversations.entities.Blockable)2 PopupMenu (android.widget.PopupMenu)1 Fragment (androidx.fragment.app.Fragment)1 FragmentTransaction (androidx.fragment.app.FragmentTransaction)1 RawBlockable (eu.siacs.conversations.entities.RawBlockable)1 Jid (eu.siacs.conversations.xmpp.Jid)1