use of com.xabber.android.data.account.AccountItem in project xabber-android by redsolution.
the class AccountListAdapter method getView.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view;
AccountManager accountManager = AccountManager.getInstance();
if (convertView == null) {
view = getActivity().getLayoutInflater().inflate(R.layout.account_list_item, parent, false);
} else {
view = convertView;
}
final String account = getItem(position);
((ImageView) view.findViewById(R.id.color)).setImageDrawable(new ColorDrawable(ColorManager.getInstance().getAccountPainter().getAccountMainColor(account)));
((ImageView) view.findViewById(R.id.avatar)).setImageDrawable(AvatarManager.getInstance().getAccountAvatar(account));
((TextView) view.findViewById(R.id.name)).setText(accountManager.getVerboseName(account));
SwitchCompat accountSwitch = (SwitchCompat) view.findViewById(R.id.account_switch);
final AccountItem accountItem = accountManager.getAccount(account);
accountSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
AccountManager.getInstance().setEnabled(account, isChecked);
}
});
ConnectionState state;
if (accountItem == null) {
state = ConnectionState.offline;
accountSwitch.setChecked(false);
} else {
state = accountItem.getState();
accountSwitch.setChecked(accountItem.isEnabled());
}
((TextView) view.findViewById(R.id.status)).setText(getActivity().getString(state.getStringId()));
return view;
}
use of com.xabber.android.data.account.AccountItem in project xabber-android by redsolution.
the class PresenceManager method onPacket.
@Override
public void onPacket(ConnectionItem connection, String bareAddress, Stanza stanza) {
if (!(connection instanceof AccountItem)) {
return;
}
if (!(stanza instanceof Presence)) {
return;
}
Presence presence = (Presence) stanza;
if (presence.getType() == Presence.Type.subscribe) {
String account = ((AccountItem) connection).getAccount();
// Subscription request
HashSet<String> set = requestedSubscriptions.get(account);
if (set != null && set.contains(bareAddress)) {
try {
acceptSubscription(account, bareAddress);
} catch (NetworkException e) {
}
subscriptionRequestProvider.remove(account, bareAddress);
} else {
subscriptionRequestProvider.add(new SubscriptionRequest(account, bareAddress), null);
}
}
}
use of com.xabber.android.data.account.AccountItem in project xabber-android by redsolution.
the class AccountList method onCreateContextMenu.
@Override
protected void onCreateContextMenu(ContextMenu menu, String actionWith) {
final AccountItem accountItem = AccountManager.getInstance().getAccount(actionWith);
menu.setHeaderTitle(AccountManager.getInstance().getVerboseName(actionWith));
if (accountItem.isEnabled()) {
menu.add(0, CONTEXT_MENU_STATUS_EDITOR_ID, 0, getResources().getText(R.string.status_editor));
}
menu.add(0, CONTEXT_MENU_VIEW_ACCOUNT_ID, 0, getString(R.string.account_editor));
super.onCreateContextMenu(menu, actionWith);
}
use of com.xabber.android.data.account.AccountItem in project xabber-android by redsolution.
the class GroupedContactAdapter method getAccountView.
private View getAccountView(int position, View convertView, ViewGroup parent) {
final View view;
final ContactListAccountItemViewHolder viewHolder;
if (convertView == null) {
view = layoutInflater.inflate(R.layout.contact_list_account_group_item, parent, false);
viewHolder = new ContactListAccountItemViewHolder(view);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
view.setElevation(accountElevation);
}
view.setTag(viewHolder);
} else {
view = convertView;
viewHolder = (ContactListAccountItemViewHolder) view.getTag();
}
final AccountConfiguration configuration = (AccountConfiguration) getItem(position);
final String account = configuration.getAccount();
viewHolder.statusIcon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onClickListener.onAccountMenuClick(v, account);
}
});
final int level = AccountManager.getInstance().getColorLevel(account);
view.setBackgroundDrawable(new ColorDrawable(accountGroupColors[level]));
viewHolder.name.setText(GroupManager.getInstance().getGroupName(account, configuration.getUser()));
viewHolder.smallRightText.setText(configuration.getOnline() + "/" + configuration.getTotal());
AccountItem accountItem = AccountManager.getInstance().getAccount(account);
String statusText = accountItem.getStatusText().trim();
if (statusText.isEmpty()) {
statusText = activity.getString(accountItem.getDisplayStatusMode().getStringID());
}
viewHolder.secondLineMessage.setText(statusText);
if (SettingsManager.contactsShowAvatars()) {
viewHolder.avatar.setVisibility(View.VISIBLE);
viewHolder.avatar.setImageDrawable(AvatarManager.getInstance().getAccountAvatar(account));
} else {
viewHolder.avatar.setVisibility(View.GONE);
}
viewHolder.avatar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
activity.startActivity(AccountViewer.createAccountInfoIntent(activity, account));
}
});
viewHolder.statusIcon.setImageLevel(accountItem.getDisplayStatusMode().getStatusLevel());
ShowOfflineMode showOfflineMode = configuration.getShowOfflineMode();
if (showOfflineMode == ShowOfflineMode.normal) {
if (SettingsManager.contactsShowOffline()) {
showOfflineMode = ShowOfflineMode.always;
} else {
showOfflineMode = ShowOfflineMode.never;
}
}
viewHolder.smallRightIcon.setImageLevel(showOfflineMode.ordinal());
StatusMode statusMode = AccountManager.getInstance().getAccount(configuration.getAccount()).getDisplayStatusMode();
if (statusMode == StatusMode.unavailable || statusMode == StatusMode.connection) {
viewHolder.offlineShadow.setVisibility(View.VISIBLE);
} else {
viewHolder.offlineShadow.setVisibility(View.GONE);
}
return view;
}
use of com.xabber.android.data.account.AccountItem in project xabber-android by redsolution.
the class ChatContactSettingsFragment method onInflate.
@Override
protected void onInflate(Bundle savedInstanceState) {
addPreferencesFromResource(R.xml.preference_chat_contact);
AccountItem accountItem = mListener.getAccountItem();
if (accountItem.getArchiveMode() == ArchiveMode.server || accountItem.getArchiveMode() == ArchiveMode.dontStore) {
getPreferenceScreen().removePreference(getPreferenceScreen().findPreference(getString(R.string.chat_save_history_key)));
}
}
Aggregations