use of com.xabber.android.data.account.StatusMode 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.StatusMode in project xabber-android by redsolution.
the class StatusModeAdapter method updateView.
private void updateView(int position, View view) {
StatusMode statusMode = (StatusMode) getItem(position);
((ImageView) view.findViewById(R.id.icon)).setImageLevel(statusMode.getStatusLevel());
((TextView) view.findViewById(R.id.name)).setText(statusMode.getStringID());
}
use of com.xabber.android.data.account.StatusMode in project xabber-android by redsolution.
the class StatusEditor method changeStatus.
private void changeStatus() {
StatusMode statusMode = (StatusMode) statusModeView.getSelectedItem();
String statusText = statusTextView.getText().toString();
setStatus(statusMode, statusText);
finish();
}
use of com.xabber.android.data.account.StatusMode in project xabber-android by redsolution.
the class SettingsManager method onMigrate.
@Override
public void onMigrate(int toVersion) {
switch(toVersion) {
case 32:
setBoolean(R.string.chats_show_status_change_key, false);
break;
case 40:
String value;
try {
if (getBoolean(R.string.chats_show_status_change_key, false))
value = Application.getInstance().getString(R.string.chats_show_status_change_always_value);
else
value = Application.getInstance().getString(R.string.chats_show_status_change_muc_value);
} catch (ClassCastException e) {
value = Application.getInstance().getString(R.string.chats_show_status_change_default);
}
setString(R.string.chats_show_status_change_key, value);
break;
case 45:
setBoolean(R.string.chats_show_avatars_key, "message".equals(getString(R.string.chats_show_avatars_key, "")));
break;
case 65:
SharedPreferences settings = Application.getInstance().getSharedPreferences("accounts", Context.MODE_PRIVATE);
int statusModeIndex = settings.getInt("status_mode", StatusMode.available.ordinal());
StatusMode statusMode = StatusMode.values()[statusModeIndex];
setString(R.string.status_mode_key, statusMode.name());
String statusText = settings.getString("status_text", "");
setString(R.string.status_text_key, statusText);
break;
default:
break;
}
}
use of com.xabber.android.data.account.StatusMode in project xabber-android by redsolution.
the class ContactVcardViewerFragment method fillResourceList.
private void fillResourceList(String account, String bareAddress, List<View> resourcesList) {
final List<Presence> allPresences = RosterManager.getInstance().getPresences(account, bareAddress);
for (Presence presence : allPresences) {
String user = presence.getFrom();
ClientInfo clientInfo = CapabilitiesManager.getInstance().getClientInfo(account, user);
String client = "";
if (clientInfo == null) {
CapabilitiesManager.getInstance().request(account, user);
client = getString(R.string.please_wait);
} else if (clientInfo == CapabilitiesManager.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;
}
String label = "";
if (!client.isEmpty()) {
label = getString(R.string.contact_viewer_client) + ": " + client + ", ";
}
label += priorityString;
String resource = getString(R.string.account_resource) + ": " + Jid.getResource(user);
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.contact_info_item, xmppItems, false);
((TextView) resourceView.findViewById(R.id.contact_info_item_secondary)).setText(label);
((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);
ImageView statusIcon = (ImageView) resourceView.findViewById(R.id.contact_info_right_icon);
statusIcon.setVisibility(View.VISIBLE);
statusIcon.setImageDrawable(getResources().getDrawable(R.drawable.ic_status));
statusIcon.setImageLevel(statusMode.getStatusLevel());
resourcesList.add(resourceView);
}
}
Aggregations