/** * @param account * @return Verbose account name. */ public String getVerboseName(String account) { AccountItem accountItem = getAccount(account); if (accountItem == null) return account; if (accountItem.getConnectionSettings().getProtocol().isOAuth()) { String jid = OAuthManager.getInstance().getAssignedJid(account); AccountProtocol accountProtocol = accountItem.getConnectionSettings().getProtocol(); String name; if (jid == null) { if (hasSameProtocol(account)) name = accountItem.getConnectionSettings().getUserName(); else return application.getString(accountProtocol.getNameResource()); } else { name = Jid.getBareAddress(jid); if (!hasSameBareAddress(jid)) return name; } return application.getString(accountProtocol.getShortResource()) + " - " + name; } else { if (hasSameBareAddress(account)) return account; else return Jid.getBareAddress(account); } }
private AccountManager() { this.application = Application.getInstance(); accountItems = new HashMap<String, AccountItem>(); enabledAccounts = new HashSet<String>(); savedStatuses = new ArrayList<SavedStatus>(); authorizationErrorProvider = new BaseAccountNotificationProvider<AccountAuthorizationError>( R.drawable.ic_stat_auth_failed); passwordRequestProvider = new BaseAccountNotificationProvider<PasswordRequest>(R.drawable.ic_stat_request); TypedArray accountAvatars = application.getResources().obtainTypedArray(R.array.account_avatars); colors = accountAvatars.length(); accountAvatars.recycle(); TypedArray types = application.getResources().obtainTypedArray(R.array.account_types); accountTypes = new ArrayList<AccountType>(); for (int index = 0; index < types.length(); index++) { int id = types.getResourceId(index, 0); TypedArray values = application.getResources().obtainTypedArray(id); AccountProtocol protocol = AccountProtocol.valueOf(values.getString(0)); if (Application.SDK_INT < 8 && protocol == AccountProtocol.wlm) { values.recycle(); continue; } ArrayList<String> servers = new ArrayList<String>(); servers.add(values.getString(9)); for (int i = 10; i < values.length(); i++) servers.add(values.getString(i)); accountTypes.add( new AccountType( id, protocol, values.getString(1), values.getString(2), values.getString(3), values.getDrawable(4), values.getBoolean(5, false), values.getString(6), values.getInt(7, 5222), values.getBoolean(8, false), servers)); values.recycle(); } types.recycle(); away = false; xa = false; }