Search in sources :

Example 1 with RawBlockable

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

the class AvatarService method get.

public Bitmap get(ListItem item, int size, boolean cachedOnly) {
    if (item instanceof RawBlockable) {
        return get(item.getDisplayName(), item.getJid().toEscapedString(), size, cachedOnly);
    } else if (item instanceof Contact) {
        return get((Contact) item, size, cachedOnly);
    } else if (item instanceof Bookmark) {
        Bookmark bookmark = (Bookmark) item;
        if (bookmark.getConversation() != null) {
            return get(bookmark.getConversation(), size, cachedOnly);
        } else {
            Jid jid = bookmark.getJid();
            Account account = bookmark.getAccount();
            Contact contact = jid == null ? null : account.getRoster().getContact(jid);
            if (contact != null && contact.getAvatarFilename() != null) {
                return get(contact, size, cachedOnly);
            }
            String seed = jid != null ? jid.asBareJid().toString() : null;
            return get(bookmark.getDisplayName(), seed, size, cachedOnly);
        }
    } else {
        String seed = item.getJid() != null ? item.getJid().asBareJid().toString() : null;
        return get(item.getDisplayName(), seed, size, cachedOnly);
    }
}
Also used : Account(eu.siacs.conversations.entities.Account) Bookmark(eu.siacs.conversations.entities.Bookmark) Jid(eu.siacs.conversations.xmpp.Jid) RawBlockable(eu.siacs.conversations.entities.RawBlockable) Contact(eu.siacs.conversations.entities.Contact)

Example 2 with RawBlockable

use of eu.siacs.conversations.entities.RawBlockable 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)

Example 3 with RawBlockable

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

the class BlocklistActivity method filterContacts.

@Override
protected void filterContacts(final String needle) {
    getListItems().clear();
    if (account != null) {
        for (final Jid jid : account.getBlocklist()) {
            ListItem item;
            if (jid.isFullJid()) {
                item = new RawBlockable(account, jid);
            } else {
                item = account.getRoster().getContact(jid);
            }
            if (item.match(this, needle)) {
                getListItems().add(item);
            }
        }
        Collections.sort(getListItems());
    }
    getListItemAdapter().notifyDataSetChanged();
}
Also used : Jid(eu.siacs.conversations.xmpp.Jid) RawBlockable(eu.siacs.conversations.entities.RawBlockable) ListItem(eu.siacs.conversations.entities.ListItem)

Aggregations

RawBlockable (eu.siacs.conversations.entities.RawBlockable)3 Jid (eu.siacs.conversations.xmpp.Jid)2 Fragment (androidx.fragment.app.Fragment)1 FragmentTransaction (androidx.fragment.app.FragmentTransaction)1 Account (eu.siacs.conversations.entities.Account)1 Blockable (eu.siacs.conversations.entities.Blockable)1 Bookmark (eu.siacs.conversations.entities.Bookmark)1 Contact (eu.siacs.conversations.entities.Contact)1 ListItem (eu.siacs.conversations.entities.ListItem)1