Search in sources :

Example 56 with UserJid

use of com.xabber.android.data.entity.UserJid in project xabber-android by redsolution.

the class RosterManager method getDisplayAuthorName.

public static String getDisplayAuthorName(MessageItem messageItem) {
    UserJid jid = null;
    try {
        jid = UserJid.from(messageItem.getOriginalFrom());
    } catch (UserJid.UserJidCreateException e) {
        e.printStackTrace();
    }
    String author = null;
    if (jid != null) {
        EntityBareJid room = messageItem.getUser().getBareJid().asEntityBareJidIfPossible();
        RoomChat roomChat = null;
        if (room != null)
            roomChat = MUCManager.getInstance().getRoomChat(messageItem.getAccount(), room);
        if (roomChat != null) {
            if (!messageItem.isIncoming())
                author = MUCManager.getInstance().getNickname(messageItem.getAccount(), room).toString();
            else
                author = jid.getJid().getResourceOrEmpty().toString();
        } else {
            if (!messageItem.getAccount().getFullJid().asBareJid().equals(jid.getBareJid()))
                author = RosterManager.getInstance().getNameOrBareJid(messageItem.getAccount(), jid);
            else
                author = AccountManager.getInstance().getNickName(messageItem.getAccount());
        }
    }
    return author;
}
Also used : UserJid(com.xabber.android.data.entity.UserJid) EntityBareJid(org.jxmpp.jid.EntityBareJid) RoomChat(com.xabber.android.data.extension.muc.RoomChat)

Example 57 with UserJid

use of com.xabber.android.data.entity.UserJid in project xabber-android by redsolution.

the class RosterManager method onPreInitialize.

public void onPreInitialize() {
    List<ContactRealm> contacts = RosterCacheManager.loadContacts();
    for (ContactRealm contactRealm : contacts) {
        try {
            AccountJid account = AccountJid.from(contactRealm.getAccount() + "/" + contactRealm.getAccountResource());
            UserJid userJid = UserJid.from(contactRealm.getUser());
            RosterContact contact = RosterContact.getRosterContact(account, userJid, contactRealm.getName());
            for (ContactGroup group : contactRealm.getGroups()) {
                contact.addGroupReference(new RosterGroupReference(new RosterGroup(account, group.getGroupName())));
            }
            rosterContacts.put(contact.getAccount().toString(), contact.getUser().getBareJid().toString(), contact);
            MessageItem lastMessage = contactRealm.getLastMessage();
            if (lastMessage != null) {
                MessageManager.getInstance().getOrCreateChat(contact.getAccount(), contact.getUser(), lastMessage);
            } else
                MessageManager.getInstance().getOrCreateChat(contact.getAccount(), contact.getUser());
        } catch (UserJid.UserJidCreateException e) {
            e.printStackTrace();
        } catch (XmppStringprepException e) {
            e.printStackTrace();
        }
    }
    onContactsChanged(Collections.<RosterContact>emptyList());
}
Also used : MessageItem(com.xabber.android.data.database.messagerealm.MessageItem) ContactRealm(com.xabber.android.data.database.realm.ContactRealm) AccountJid(com.xabber.android.data.entity.AccountJid) UserJid(com.xabber.android.data.entity.UserJid) XmppStringprepException(org.jxmpp.stringprep.XmppStringprepException) ContactGroup(com.xabber.android.data.database.realm.ContactGroup)

Example 58 with UserJid

use of com.xabber.android.data.entity.UserJid in project xabber-android by redsolution.

the class ContactListFragment method onContactAvatarClick.

@Override
public void onContactAvatarClick(int adapterPosition) {
    IFlexible item = adapter.getItem(adapterPosition);
    if (item != null && item instanceof ContactVO) {
        Intent intent;
        AccountJid accountJid = ((ContactVO) item).getAccountJid();
        UserJid userJid = ((ContactVO) item).getUserJid();
        if (MUCManager.getInstance().hasRoom(accountJid, userJid)) {
            intent = ContactActivity.createIntent(getActivity(), accountJid, userJid);
        } else {
            intent = ContactEditActivity.createIntent(getActivity(), accountJid, userJid);
        }
        getActivity().startActivity(intent);
    }
}
Also used : AccountJid(com.xabber.android.data.entity.AccountJid) IFlexible(eu.davidea.flexibleadapter.items.IFlexible) ContactVO(com.xabber.android.presentation.ui.contactlist.viewobjects.ContactVO) UserJid(com.xabber.android.data.entity.UserJid) Intent(android.content.Intent)

Example 59 with UserJid

use of com.xabber.android.data.entity.UserJid in project xabber-android by redsolution.

the class ContactListFragment method onItemContextMenu.

@Override
public void onItemContextMenu(int adapterPosition, ContextMenu menu) {
    IFlexible item = adapter.getItem(adapterPosition);
    if (item != null && item instanceof ContactVO) {
        AccountJid accountJid = ((ContactVO) item).getAccountJid();
        UserJid userJid = ((ContactVO) item).getUserJid();
        AbstractContact abstractContact = RosterManager.getInstance().getAbstractContact(accountJid, userJid);
        ContextMenuHelper.createContactContextMenu(getActivity(), presenter, abstractContact, menu);
        return;
    }
    if (item != null && item instanceof GroupVO) {
        AccountJid accountJid = ((GroupVO) item).getAccountJid();
        ContextMenuHelper.createGroupContextMenu(getActivity(), presenter, accountJid, ((GroupVO) item).getGroupName(), menu);
        return;
    }
}
Also used : AccountJid(com.xabber.android.data.entity.AccountJid) IFlexible(eu.davidea.flexibleadapter.items.IFlexible) ContactVO(com.xabber.android.presentation.ui.contactlist.viewobjects.ContactVO) UserJid(com.xabber.android.data.entity.UserJid) AbstractContact(com.xabber.android.data.roster.AbstractContact) GroupVO(com.xabber.android.presentation.ui.contactlist.viewobjects.GroupVO)

Example 60 with UserJid

use of com.xabber.android.data.entity.UserJid in project xabber-android by redsolution.

the class BlockedListActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    account = getAccount(getIntent());
    if (account == null) {
        finish();
        return;
    }
    setContentView(R.layout.activity_with_toolbar_and_container);
    toolbar = (Toolbar) findViewById(R.id.toolbar_default);
    toolbar.setNavigationIcon(R.drawable.ic_arrow_left_white_24dp);
    toolbar.inflateMenu(R.menu.toolbar_block_list);
    toolbar.setOnMenuItemClickListener(this);
    barPainter = new BarPainter(this, toolbar);
    RecyclerView recyclerView = new RecyclerView(this);
    ((RelativeLayout) findViewById(R.id.fragment_container)).addView(recyclerView);
    adapter = new BlockedListAdapter(account);
    adapter.setListener(this);
    if (savedInstanceState != null) {
        final ArrayList<String> checkedContacts = savedInstanceState.getStringArrayList(SAVED_CHECKED_CONTACTS);
        if (checkedContacts != null) {
            List<UserJid> checkedJids = new ArrayList<>();
            for (String contactString : checkedContacts) {
                try {
                    checkedJids.add(UserJid.from(contactString));
                } catch (UserJid.UserJidCreateException e) {
                    LogManager.exception(this, e);
                }
            }
            adapter.setCheckedContacts(checkedJids);
        }
    }
    previousSize = -1;
    recyclerView.setAdapter(adapter);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
}
Also used : RelativeLayout(android.widget.RelativeLayout) ArrayList(java.util.ArrayList) UserJid(com.xabber.android.data.entity.UserJid) RecyclerView(androidx.recyclerview.widget.RecyclerView) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) BlockedListAdapter(com.xabber.android.ui.adapter.BlockedListAdapter) BarPainter(com.xabber.android.ui.color.BarPainter)

Aggregations

UserJid (com.xabber.android.data.entity.UserJid)67 AccountJid (com.xabber.android.data.entity.AccountJid)43 AbstractChat (com.xabber.android.data.message.AbstractChat)15 ArrayList (java.util.ArrayList)15 Intent (android.content.Intent)9 Jid (org.jxmpp.jid.Jid)9 Presence (org.jivesoftware.smack.packet.Presence)8 XmppStringprepException (org.jxmpp.stringprep.XmppStringprepException)8 AccountItem (com.xabber.android.data.account.AccountItem)7 AbstractContact (com.xabber.android.data.roster.AbstractContact)6 Message (org.jivesoftware.smack.packet.Message)6 Resourcepart (org.jxmpp.jid.parts.Resourcepart)6 NetworkException (com.xabber.android.data.NetworkException)5 IFlexible (eu.davidea.flexibleadapter.items.IFlexible)5 SmackException (org.jivesoftware.smack.SmackException)5 Uri (android.net.Uri)4 ContactVO (com.xabber.android.presentation.ui.contactlist.viewobjects.ContactVO)4 DomainBareJid (org.jxmpp.jid.DomainBareJid)4 TextView (android.widget.TextView)3 MessageItem (com.xabber.android.data.database.messagerealm.MessageItem)3