Search in sources :

Example 31 with AccountJid

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

the class ChatMessageAdapter method setUpAvatar.

private void setUpAvatar(MessageItem messageItem, IncomingMessage message) {
    if (SettingsManager.chatsShowAvatars()) {
        final AccountJid account = messageItem.getAccount();
        final UserJid user = messageItem.getUser();
        final Resourcepart resource = messageItem.getResource();
        message.avatar.setVisibility(View.VISIBLE);
        message.avatarBackground.setVisibility(View.VISIBLE);
        if ((isMUC && MUCManager.getInstance().getNickname(account, user.getJid().asEntityBareJidIfPossible()).equals(resource))) {
            message.avatar.setImageDrawable(AvatarManager.getInstance().getAccountAvatar(account));
        } else {
            if (isMUC) {
                if (resource.equals(Resourcepart.EMPTY)) {
                    message.avatar.setImageDrawable(AvatarManager.getInstance().getRoomAvatar(user));
                } else {
                    try {
                        message.avatar.setImageDrawable(AvatarManager.getInstance().getUserAvatar(UserJid.from(JidCreate.domainFullFrom(user.getJid().asDomainBareJid(), resource))));
                    } catch (UserJid.UserJidCreateException e) {
                        LogManager.exception(this, e);
                    }
                }
            } else {
                message.avatar.setImageDrawable(AvatarManager.getInstance().getUserAvatar(user));
            }
        }
    } else {
        message.avatar.setVisibility(View.GONE);
        message.avatarBackground.setVisibility(View.GONE);
    }
}
Also used : AccountJid(com.xabber.android.data.entity.AccountJid) UserJid(com.xabber.android.data.entity.UserJid) Resourcepart(org.jxmpp.jid.parts.Resourcepart)

Example 32 with AccountJid

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

the class AccountChooseDialogFragment method onClick.

@Override
public void onClick(DialogInterface dialog, int which) {
    AccountJid account = (AccountJid) adapter.getItem(which);
    OnChooseListener listener = (OnChooseListener) getActivity();
    listener.onChoose(account, user, text);
}
Also used : AccountJid(com.xabber.android.data.entity.AccountJid)

Example 33 with AccountJid

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

the class AccountSyncDialogFragment method onPositiveClick.

private void onPositiveClick(boolean needGoToMainActivity) {
    // set accounts to sync map
    if (!switchSyncAll.isChecked()) {
        Map<String, Boolean> syncState = new HashMap<>();
        for (XMPPAccountSettings account : xmppAccounts) {
            if (account.getStatus() != XMPPAccountSettings.SyncStatus.local) {
                syncState.put(account.getJid(), account.isSynchronization());
            } else if (account.isSynchronization() || XabberAccountManager.getInstance().getAccountSyncState(account.getJid()) != null) {
                syncState.put(account.getJid(), account.isSynchronization());
            }
        }
        XabberAccountManager.getInstance().setAccountSyncState(syncState);
    }
    // update timestamp in accounts if timestamp was changed in dialog
    for (XMPPAccountSettings account : xmppAccounts) {
        AccountJid accountJid = XabberAccountManager.getInstance().getExistingAccount(account.getJid());
        if (accountJid != null)
            AccountManager.getInstance().setTimestamp(accountJid, account.getTimestamp());
    }
    // set sync all
    SettingsManager.setSyncAllAccounts(switchSyncAll.isChecked());
    // callback to sync-request
    ((XabberAccountInfoActivity) getActivity()).onSyncClick(needGoToMainActivity);
}
Also used : HashMap(java.util.HashMap) XMPPAccountSettings(com.xabber.android.data.xaccount.XMPPAccountSettings) AccountJid(com.xabber.android.data.entity.AccountJid) XabberAccountInfoActivity(com.xabber.android.ui.activity.XabberAccountInfoActivity)

Example 34 with AccountJid

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

the class EnterPassDialog method createAccount.

private void createAccount(boolean enabled) {
    try {
        AccountJid accountJid = AccountManager.getInstance().addAccount(jid, edtPass.getText().toString(), token, false, true, true, false, false, enabled);
        AccountManager.getInstance().setColor(accountJid, ColorManager.getInstance().convertColorNameToIndex(color));
        AccountManager.getInstance().setOrder(accountJid, order);
        AccountManager.getInstance().setTimestamp(accountJid, timestamp);
        AccountManager.getInstance().onAccountChanged(accountJid);
    } catch (NetworkException e) {
        Application.getInstance().onError(e);
    }
}
Also used : AccountJid(com.xabber.android.data.entity.AccountJid) NetworkException(com.xabber.android.data.NetworkException)

Example 35 with AccountJid

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

the class AccountActionButtonsAdapter method onChange.

@Override
public void onChange() {
    Collections.sort(accounts);
    for (int index = 0; index < accounts.size(); index++) {
        View view = linearLayout.getChildAt(index);
        final CircleImageView circleImageView = (CircleImageView) view.findViewById(R.id.account_avatar);
        final AccountJid account = accounts.get(index);
        circleImageView.setImageDrawable(AvatarManager.getInstance().getAccountAvatar(account));
        FloatingActionButton backgroundActionButton = (FloatingActionButton) view.findViewById(R.id.fab);
        final AccountPainter accountPainter = ColorManager.getInstance().getAccountPainter();
        backgroundActionButton.setColorNormal(accountPainter.getAccountMainColor(account));
        backgroundActionButton.setColorPressed(accountPainter.getAccountDarkColor(account));
        backgroundActionButton.setColorRipple(accountPainter.getAccountRippleColor(account));
        AccountJid selectedAccount = AccountManager.getInstance().getSelectedAccount();
        int shadowVisibility;
        if (selectedAccount == null) {
            shadowVisibility = View.GONE;
        } else {
            shadowVisibility = View.VISIBLE;
            if (selectedAccount.equals(account)) {
                shadowVisibility = View.GONE;
            }
        }
        view.findViewById(R.id.account_unselected_shadow).setVisibility(shadowVisibility);
        int offlineShadowVisibility;
        AccountItem accountItem = AccountManager.getInstance().getAccount(account);
        StatusMode statusMode = null;
        if (accountItem != null) {
            statusMode = accountItem.getDisplayStatusMode();
        }
        if (statusMode != null && (statusMode == StatusMode.connection || statusMode == StatusMode.unavailable)) {
            offlineShadowVisibility = View.VISIBLE;
        } else {
            offlineShadowVisibility = View.GONE;
        }
        view.findViewById(R.id.account_offline_shadow).setVisibility(offlineShadowVisibility);
    }
}
Also used : CircleImageView(de.hdodenhof.circleimageview.CircleImageView) AccountPainter(com.xabber.android.ui.color.AccountPainter) StatusMode(com.xabber.android.data.account.StatusMode) AccountItem(com.xabber.android.data.account.AccountItem) AccountJid(com.xabber.android.data.entity.AccountJid) FloatingActionButton(com.melnykov.fab.FloatingActionButton) CircleImageView(de.hdodenhof.circleimageview.CircleImageView) View(android.view.View)

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