Search in sources :

Example 21 with AccountJid

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

the class VCardManager method onStanza.

@Override
public void onStanza(ConnectionItem connection, Stanza stanza) {
    if (!(connection instanceof AccountItem)) {
        return;
    }
    AccountJid account = connection.getAccount();
    if (stanza instanceof Presence && ((Presence) stanza).getType() != Presence.Type.error) {
        Jid from = stanza.getFrom();
        if (from == null) {
            return;
        }
        Jid addressForVcard = from;
        if (MUCManager.getInstance().hasRoom(account, from.asEntityBareJidIfPossible())) {
            addressForVcard = from;
        }
        // Request vCard for new users
        if (!names.containsKey(addressForVcard)) {
            if (SettingsManager.connectionLoadVCard()) {
                request(account, addressForVcard);
            }
        }
    }
}
Also used : UserJid(com.xabber.android.data.entity.UserJid) AccountJid(com.xabber.android.data.entity.AccountJid) EntityBareJid(org.jxmpp.jid.EntityBareJid) Jid(org.jxmpp.jid.Jid) BareJid(org.jxmpp.jid.BareJid) AccountItem(com.xabber.android.data.account.AccountItem) AccountJid(com.xabber.android.data.entity.AccountJid) Presence(org.jivesoftware.smack.packet.Presence)

Example 22 with AccountJid

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

the class ConferenceSelectFragment method onItemSelected.

@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
    AccountJid newAccount = (AccountJid) accountView.getSelectedItem();
    if (account != null && account.equals(newAccount)) {
        return;
    }
    if (account != null) {
        hostedConferencesAdapter.clear();
    }
    account = newAccount;
    listener.onAccountSelected(account);
    nextButton.setTextColor(ColorManager.getInstance().getAccountPainter().getAccountTextColor(account));
    serverView.setText(getString(R.string.domen_part, account.getFullJid().getDomain().toString()));
    onRequestHostedRoomsClick();
}
Also used : AccountJid(com.xabber.android.data.entity.AccountJid)

Example 23 with AccountJid

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

the class ContactAddFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_contact_add, container, false);
    if (savedInstanceState != null) {
        name = savedInstanceState.getString(SAVED_NAME);
        setAccount((AccountJid) savedInstanceState.getParcelable(SAVED_ACCOUNT));
        setUser((UserJid) savedInstanceState.getParcelable(SAVED_USER));
    } else {
        if (getAccount() == null || getUser() == null) {
            name = null;
        } else {
            name = RosterManager.getInstance().getName(getAccount(), getUser());
            if (getUser().getJid().asBareJid().toString().equals(name)) {
                name = null;
            }
        }
    }
    if (getAccount() == null) {
        Collection<AccountJid> accounts = AccountManager.getInstance().getEnabledAccounts();
        if (accounts.size() == 1) {
            setAccount(accounts.iterator().next());
        }
    }
    setUpAccountView((Spinner) view.findViewById(R.id.contact_account));
    userView = (EditText) view.findViewById(R.id.contact_user);
    nameView = (EditText) view.findViewById(R.id.contact_name);
    if (getUser() != null) {
        userView.setText(getUser().toString());
    }
    if (name != null) {
        nameView.setText(name);
    }
    return view;
}
Also used : AccountJid(com.xabber.android.data.entity.AccountJid) View(android.view.View) AdapterView(android.widget.AdapterView)

Example 24 with AccountJid

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

the class ContactAddFragment method addContact.

@Override
public void addContact() {
    if (getAccount() == null) {
        Toast.makeText(getActivity(), getString(R.string.EMPTY_ACCOUNT), Toast.LENGTH_LONG).show();
        return;
    }
    String contactString = userView.getText().toString();
    if (TextUtils.isEmpty(contactString)) {
        Toast.makeText(getActivity(), getString(R.string.EMPTY_USER_NAME), Toast.LENGTH_LONG).show();
        return;
    }
    UserJid user;
    try {
        user = UserJid.from(contactString);
    } catch (UserJid.UserJidCreateException e) {
        LogManager.exception(this, e);
        return;
    }
    LogManager.i(this, "user: " + user);
    AccountJid account = (AccountJid) accountView.getSelectedItem();
    if (account == null) {
        Toast.makeText(getActivity(), getString(R.string.EMPTY_ACCOUNT), Toast.LENGTH_LONG).show();
        return;
    }
    try {
        RosterManager.getInstance().createContact(account, user, nameView.getText().toString(), getSelected());
        PresenceManager.getInstance().requestSubscription(account, user);
        MessageManager.getInstance().openChat(account, user);
    } catch (SmackException.NotLoggedInException | SmackException.NotConnectedException e) {
        Application.getInstance().onError(R.string.NOT_CONNECTED);
    } catch (XMPPException.XMPPErrorException e) {
        Application.getInstance().onError(R.string.XMPP_EXCEPTION);
    } catch (SmackException.NoResponseException e) {
        Application.getInstance().onError(R.string.CONNECTION_FAILED);
    } catch (NetworkException e) {
        Application.getInstance().onError(e);
    } catch (InterruptedException e) {
        LogManager.exception(this, e);
    }
    getActivity().finish();
}
Also used : SmackException(org.jivesoftware.smack.SmackException) UserJid(com.xabber.android.data.entity.UserJid) AccountJid(com.xabber.android.data.entity.AccountJid) XMPPException(org.jivesoftware.smack.XMPPException) NetworkException(com.xabber.android.data.NetworkException)

Example 25 with AccountJid

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

the class RecentChatFragment 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)

Aggregations

AccountJid (com.xabber.android.data.entity.AccountJid)74 UserJid (com.xabber.android.data.entity.UserJid)38 AccountItem (com.xabber.android.data.account.AccountItem)21 Jid (org.jxmpp.jid.Jid)13 Intent (android.content.Intent)11 ArrayList (java.util.ArrayList)11 View (android.view.View)10 NetworkException (com.xabber.android.data.NetworkException)9 AbstractChat (com.xabber.android.data.message.AbstractChat)7 Message (org.jivesoftware.smack.packet.Message)7 Presence (org.jivesoftware.smack.packet.Presence)7 ExtensionElement (org.jivesoftware.smack.packet.ExtensionElement)6 TextView (android.widget.TextView)5 StatusMode (com.xabber.android.data.account.StatusMode)5 Resourcepart (org.jxmpp.jid.parts.Resourcepart)5 ImageView (android.widget.ImageView)4 AccountManager (com.xabber.android.data.account.AccountManager)4 RosterContact (com.xabber.android.data.roster.RosterContact)4 ContactVO (com.xabber.android.presentation.ui.contactlist.viewobjects.ContactVO)4 BarPainter (com.xabber.android.ui.color.BarPainter)4