Search in sources :

Example 71 with AccountJid

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

the class GroupVO method convert.

public static GroupVO convert(GroupConfiguration configuration, boolean firstInAccount, GroupClickListener listener) {
    String name = GroupManager.getInstance().getGroupName(configuration.getAccount(), configuration.getGroup());
    boolean showOfflineShadow = false;
    int accountColorIndicator;
    int accountColorIndicatorBack;
    boolean expanded;
    int offlineIndicatorLevel;
    AccountJid account = configuration.getAccount();
    if (account == null || account == GroupManager.NO_ACCOUNT) {
        accountColorIndicator = ColorManager.getInstance().getAccountPainter().getDefaultMainColor();
        accountColorIndicatorBack = ColorManager.getInstance().getAccountPainter().getDefaultIndicatorBackColor();
    } else {
        accountColorIndicator = ColorManager.getInstance().getAccountPainter().getAccountMainColor(account);
        accountColorIndicatorBack = ColorManager.getInstance().getAccountPainter().getAccountIndicatorBackColor(account);
    }
    expanded = configuration.isExpanded();
    offlineIndicatorLevel = configuration.getShowOfflineMode().ordinal();
    if (!name.equals(RECENT_CHATS_TITLE))
        name = String.format("%s (%d/%d)", name, configuration.getOnline(), configuration.getTotal());
    AccountItem accountItem = AccountManager.getInstance().getAccount(configuration.getAccount());
    if (accountItem != null) {
        StatusMode statusMode = accountItem.getDisplayStatusMode();
        if (statusMode == StatusMode.unavailable || statusMode == StatusMode.connection)
            showOfflineShadow = true;
    }
    return new GroupVO(accountColorIndicator, accountColorIndicatorBack, showOfflineShadow, name, expanded, offlineIndicatorLevel, configuration.getGroup(), configuration.getAccount(), firstInAccount, listener);
}
Also used : StatusMode(com.xabber.android.data.account.StatusMode) AccountItem(com.xabber.android.data.account.AccountItem) AccountJid(com.xabber.android.data.entity.AccountJid)

Example 72 with AccountJid

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

the class AccountManager method getEnabledAccounts.

/**
 * @return List of enabled accounts.
 */
public Collection<AccountJid> getEnabledAccounts() {
    List<AccountJid> enabledAccounts = new ArrayList<>();
    for (AccountItem accountItem : accountItems.values()) {
        if (accountItem.isEnabled()) {
            AccountJid accountJid = accountItem.getAccount();
            accountJid.setOrder(accountItem.getOrder());
            enabledAccounts.add(accountJid);
        }
    }
    return Collections.unmodifiableCollection(enabledAccounts);
}
Also used : AccountJid(com.xabber.android.data.entity.AccountJid) ArrayList(java.util.ArrayList)

Example 73 with AccountJid

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

the class AccountManager method getSelectedAccount.

/**
 * @return Selected account to show contacts. <code>null</code> if
 * <ul>
 * <li>there is no selected account,</li>
 * <li>selected account does not exists or disabled,</li>
 * <li>Group by account is enabled.</li>
 * </ul>
 */
public AccountJid getSelectedAccount() {
    if (SettingsManager.contactsShowAccounts()) {
        return null;
    }
    if (TextUtils.isEmpty(SettingsManager.contactsSelectedAccount())) {
        return null;
    }
    AccountJid selected;
    try {
        selected = AccountJid.from(SettingsManager.contactsSelectedAccount());
    } catch (XmppStringprepException e) {
        LogManager.exception(this, e);
        return null;
    }
    AccountItem selectedAccountItem = accountItems.get(selected);
    if (selectedAccountItem != null && selectedAccountItem.isEnabled()) {
        return selected;
    }
    return null;
}
Also used : AccountJid(com.xabber.android.data.entity.AccountJid) XmppStringprepException(org.jxmpp.stringprep.XmppStringprepException)

Example 74 with AccountJid

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

the class ConnectionManager method connectAll.

public void connectAll() {
    LogManager.i(LOG_TAG, "connectAll");
    AccountManager accountManager = AccountManager.getInstance();
    for (AccountJid account : accountManager.getEnabledAccounts()) {
        ReconnectionManager.getInstance().requestReconnect(account);
    }
}
Also used : AccountJid(com.xabber.android.data.entity.AccountJid) AccountManager(com.xabber.android.data.account.AccountManager)

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