use of com.xabber.android.data.account.AccountItem in project xabber-android by redsolution.
the class BookmarksManager method cleanCache.
public void cleanCache(AccountJid accountJid) {
AccountItem accountItem = AccountManager.getInstance().getAccount(accountJid);
if (accountItem != null) {
BookmarkManager bookmarkManager = BookmarkManager.getBookmarkManager(accountItem.getConnection());
bookmarkManager.cleanCache();
}
}
use of com.xabber.android.data.account.AccountItem in project xabber-android by redsolution.
the class ContactListDrawerFragment method setupAccountList.
private void setupAccountList() {
List<AccountItem> accountItems = new ArrayList<>();
for (AccountItem accountItem : AccountManager.getInstance().getAllAccountItems()) {
accountItems.add(accountItem);
}
accountListAdapter.setAccountItems(accountItems);
if (accountItems.size() > 1)
ivReorder.setVisibility(View.VISIBLE);
else
ivReorder.setVisibility(View.GONE);
}
use of com.xabber.android.data.account.AccountItem in project xabber-android by redsolution.
the class ContactVcardViewerFragment method fillResourceList.
private void fillResourceList(AccountJid account, Jid bareAddress, List<View> resourcesList) {
final List<Presence> allPresences = RosterManager.getInstance().getPresences(account, bareAddress);
boolean isAccount = account.getFullJid().asBareJid().equals(user.getBareJid());
Resourcepart accountResource = null;
if (isAccount) {
// TODO: probably not the best way to get own resource
AccountItem accountItem = AccountManager.getInstance().getAccount(account);
if (accountItem != null) {
accountResource = accountItem.getConnection().getConfiguration().getResource();
}
}
PresenceManager.sortPresencesByPriority(allPresences);
for (Presence presence : allPresences) {
Jid fromJid = presence.getFrom();
ClientInfo clientInfo = CapabilitiesManager.getInstance().getCachedClientInfo(fromJid);
String client = "";
if (clientInfo == null) {
client = getString(R.string.please_wait);
CapabilitiesManager.getInstance().requestClientInfoByUser(account, fromJid);
} else if (clientInfo == ClientInfo.INVALID_CLIENT_INFO) {
client = getString(R.string.unknown);
} else {
String name = clientInfo.getName();
if (name != null) {
client = name;
}
String type = clientInfo.getType();
if (type != null) {
if (client.isEmpty()) {
client = type;
} else {
client = client + "/" + type;
}
}
}
int priorityValue = presence.getPriority();
String priorityString;
if (priorityValue == Integer.MIN_VALUE) {
priorityString = getString(R.string.account_priority) + ": " + getString(R.string.unknown);
} else {
priorityString = getString(R.string.account_priority) + ": " + priorityValue;
}
if (!client.isEmpty()) {
client = getString(R.string.contact_viewer_client) + ": " + client;
}
Resourcepart resourceOrNull = fromJid.getResourceOrNull();
String resource = getString(R.string.account_resource) + ": " + resourceOrNull;
final StatusMode statusMode = StatusMode.createStatusMode(presence);
String status = presence.getStatus();
if (TextUtils.isEmpty(status)) {
status = getString(statusMode.getStringID());
}
LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
View resourceView = inflater.inflate(R.layout.item_contact_info, xmppItems, false);
resourceView.findViewById(R.id.contact_info_item_secondary);
((TextView) resourceView.findViewById(R.id.contact_info_item_secondary)).setText(client);
((TextView) resourceView.findViewById(R.id.contact_info_item_main)).setText(status);
((TextView) resourceView.findViewById(R.id.contact_info_item_secondary_second_line)).setText(resource);
resourceView.findViewById(R.id.contact_info_item_secondary_second_line).setVisibility(View.VISIBLE);
((TextView) resourceView.findViewById(R.id.contact_info_item_secondary_third_line)).setText(priorityString);
resourceView.findViewById(R.id.contact_info_item_secondary_third_line).setVisibility(View.VISIBLE);
if (isAccount && resourceOrNull != null && resourceOrNull.equals(accountResource)) {
TextView thisDeviceIndicatorTextView = (TextView) resourceView.findViewById(R.id.contact_info_item_secondary_forth_line);
thisDeviceIndicatorTextView.setTextColor(ColorManager.getInstance().getAccountPainter().getAccountSendButtonColor(account));
thisDeviceIndicatorTextView.setText(R.string.contact_viewer_this_device);
thisDeviceIndicatorTextView.setVisibility(View.VISIBLE);
}
ImageView statusIcon = (ImageView) resourceView.findViewById(R.id.contact_info_right_icon);
statusIcon.setVisibility(View.VISIBLE);
statusIcon.setImageResource(R.drawable.ic_status);
statusIcon.setImageLevel(statusMode.getStatusLevel());
resourcesList.add(resourceView);
}
}
use of com.xabber.android.data.account.AccountItem in project xabber-android by redsolution.
the class ContextMenuHelper method setUpAccountMenu.
public static void setUpAccountMenu(final Activity activity, final ContactListPresenter presenter, final AccountJid account, Menu menu) {
final AccountItem accountItem = AccountManager.getInstance().getAccount(account);
if (accountItem == null) {
return;
}
ConnectionState state = accountItem.getState();
if (state == ConnectionState.waiting) {
menu.findItem(R.id.action_reconnect_account).setVisible(true).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
accountItem.disconnect();
AccountManager.getInstance().onAccountChanged(account);
return true;
}
});
}
menu.findItem(R.id.action_edit_account_status).setIntent(StatusEditActivity.createIntent(activity, account));
menu.findItem(R.id.action_edit_account).setIntent(AccountActivity.createIntent(activity, account));
menu.add(R.string.configure_notifications).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
activity.startActivity(CustomNotifySettings.createIntent(activity, account));
return true;
}
});
if (state.isConnected()) {
menu.findItem(R.id.action_add_contact).setVisible(true).setIntent(ContactAddActivity.createIntent(activity, account));
}
if (SettingsManager.contactsShowAccounts()) {
menu.findItem(R.id.action_set_up_offline_contacts).setVisible(true).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
ContextMenuHelper.createOfflineContactsDialog(activity, presenter, account, GroupManager.IS_ACCOUNT).show();
return true;
}
});
}
}
use of com.xabber.android.data.account.AccountItem in project xabber-android by redsolution.
the class AccountHistorySettingsFragment method getValues.
@Override
protected Map<String, Object> getValues() {
Map<String, Object> source = new HashMap<>();
AccountItem accountItem = AccountManager.getInstance().getAccount(this.account);
if (accountItem != null) {
putValue(source, R.string.account_clear_history_on_exit_key, accountItem.isClearHistoryOnExit());
// order of enum fields is very important!
putValue(source, R.string.account_mam_default_behavior_key, accountItem.getMamDefaultBehaviour().ordinal());
putValue(source, R.string.account_mam_sync_key, accountItem.getLoadHistorySettings().ordinal());
}
return source;
}
Aggregations