use of com.xabber.android.data.account.StatusMode in project xabber-android by redsolution.
the class GroupedContactAdapter method getAccountBottomSeparatorView.
private View getAccountBottomSeparatorView(View view, int position) {
final ContactListAdapter.AccountBottomSeparator accountBottomSeparator = (ContactListAdapter.AccountBottomSeparator) getItem(position);
final int level = AccountManager.getInstance().getColorLevel(accountBottomSeparator.getAccount());
View bottomLayer = view.findViewById(R.id.bottom_layer);
View topLayer = view.findViewById(R.id.top_layer);
bottomLayer.setBackgroundDrawable(new ColorDrawable(accountSubgroupColors[level]));
topLayer.setBackgroundDrawable(new ColorDrawable(accountSubgroupColors[level]));
StatusMode statusMode = AccountManager.getInstance().getAccount(accountBottomSeparator.getAccount()).getDisplayStatusMode();
View offlineShadowBottom = view.findViewById(R.id.offline_shadow_top);
View offlineShadowTop = view.findViewById(R.id.offline_shadow_bottom);
if (statusMode == StatusMode.unavailable || statusMode == StatusMode.connection) {
offlineShadowBottom.setVisibility(View.VISIBLE);
offlineShadowTop.setVisibility(View.VISIBLE);
} else {
offlineShadowBottom.setVisibility(View.GONE);
offlineShadowTop.setVisibility(View.GONE);
}
return view;
}
use of com.xabber.android.data.account.StatusMode in project xabber-android by redsolution.
the class StatusEditor method onSaveInstanceState.
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
StatusMode statusMode = (StatusMode) statusModeView.getSelectedItem();
outState.putString(SAVED_MODE, statusMode.name());
outState.putString(SAVED_TEXT, statusTextView.getText().toString());
}
use of com.xabber.android.data.account.StatusMode in project xabber-android by redsolution.
the class StatusEditor method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (isFinishing()) {
return;
}
actionWithItem = null;
setContentView(R.layout.status_editor);
Toolbar toolbar = (Toolbar) findViewById(R.id.top_toolbar);
toolbar.setNavigationIcon(R.drawable.ic_clear_white_24dp);
setTitle(null);
setSupportActionBar(toolbar);
Intent intent = getIntent();
account = StatusEditor.getAccount(intent);
BarPainter barPainter = new BarPainter(this, toolbar);
if (account != null) {
barPainter.updateWithAccountName(account);
} else {
barPainter.setDefaultColor();
}
ListView listView = getListView();
listView.setOnItemClickListener(this);
registerForContextMenu(listView);
adapter = new StatusEditorAdapter(this);
View footerView = ((LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.status_history_footer, null, false);
footerView.findViewById(R.id.clear_status_history_button).setOnClickListener(this);
listView.addFooterView(footerView);
setListAdapter(adapter);
statusTextView = (EditText) findViewById(R.id.status_text);
statusModeView = (Spinner) findViewById(R.id.status_icon);
statusModeView.setAdapter(new StatusModeAdapter(this));
savedStatusesTextView = findViewById(R.id.saved_statuses_textview);
StatusMode statusMode;
String statusText;
if (savedInstanceState == null) {
if (account == null) {
statusMode = SettingsManager.statusMode();
statusText = SettingsManager.statusText();
} else {
AccountItem accountItem = AccountManager.getInstance().getAccount(account);
if (accountItem == null) {
Application.getInstance().onError(R.string.NO_SUCH_ACCOUNT);
finish();
return;
}
statusMode = accountItem.getFactualStatusMode();
statusText = accountItem.getStatusText();
}
} else {
statusMode = StatusMode.valueOf(savedInstanceState.getString(SAVED_MODE));
statusText = savedInstanceState.getString(SAVED_TEXT);
}
showStatus(statusMode, statusText);
}
use of com.xabber.android.data.account.StatusMode in project xabber-android by redsolution.
the class GroupedContactAdapter method getGroupView.
private View getGroupView(int position, View convertView, ViewGroup parent) {
final View view;
final GroupViewHolder viewHolder;
if (convertView == null) {
view = layoutInflater.inflate(R.layout.base_group_item, parent, false);
viewHolder = new GroupViewHolder(view);
view.setTag(viewHolder);
} else {
view = convertView;
viewHolder = (GroupViewHolder) view.getTag();
}
final GroupConfiguration configuration = (GroupConfiguration) getItem(position);
final int level = AccountManager.getInstance().getColorLevel(configuration.getAccount());
final String name = GroupManager.getInstance().getGroupName(configuration.getAccount(), configuration.getUser());
viewHolder.indicator.setImageLevel(configuration.isExpanded() ? 1 : 0);
viewHolder.groupOfflineIndicator.setImageLevel(configuration.getShowOfflineMode().ordinal());
int color;
viewHolder.groupOfflineIndicator.setVisibility(View.GONE);
viewHolder.offlineShadow.setVisibility(View.GONE);
if (configuration.getUser().equals(GroupManager.ACTIVE_CHATS)) {
color = activeChatsColor;
viewHolder.name.setText(name);
} else {
viewHolder.name.setText(String.format("%s (%d/%d)", name, configuration.getOnline(), configuration.getTotal()));
color = accountSubgroupColors[level];
viewHolder.groupOfflineIndicator.setVisibility(View.VISIBLE);
AccountItem accountItem = AccountManager.getInstance().getAccount(configuration.getAccount());
if (accountItem != null) {
StatusMode statusMode = accountItem.getDisplayStatusMode();
if (statusMode == StatusMode.unavailable || statusMode == StatusMode.connection) {
viewHolder.offlineShadow.setVisibility(View.VISIBLE);
}
}
}
view.setBackgroundDrawable(new ColorDrawable(color));
return view;
}
use of com.xabber.android.data.account.StatusMode in project xabber-android by redsolution.
the class AccountActionButtonsAdapter method onChange.
@Override
public void onChange() {
for (int index = 0; index < accounts.size(); index++) {
View view = linearLayout.getChildAt(index);
final CircleImageView circleImageView = (CircleImageView) view.findViewById(R.id.account_avatar);
final String account = accounts.get(index);
circleImageView.setImageDrawable(AvatarManager.getInstance().getAccountAvatar(account));
FloatingActionButton backgroundActionButton = (FloatingActionButton) view.findViewById(R.id.fab);
final AccountPainter accountPainter = ColorManager.getInstance().getAccountPainter();
backgroundActionButton.setColorNormal(accountPainter.getAccountMainColor(account));
backgroundActionButton.setColorPressed(accountPainter.getAccountDarkColor(account));
backgroundActionButton.setColorRipple(accountPainter.getAccountRippleColor(account));
String selectedAccount = AccountManager.getInstance().getSelectedAccount();
int shadowVisibility;
if (selectedAccount == null) {
shadowVisibility = View.GONE;
} else {
shadowVisibility = View.VISIBLE;
if (selectedAccount.equalsIgnoreCase(account)) {
shadowVisibility = View.GONE;
}
}
view.findViewById(R.id.account_unselected_shadow).setVisibility(shadowVisibility);
StatusMode statusMode = AccountManager.getInstance().getAccount(account).getDisplayStatusMode();
int offlineShadowVisibility;
if (statusMode == StatusMode.connection || statusMode == StatusMode.unavailable) {
offlineShadowVisibility = View.VISIBLE;
} else {
offlineShadowVisibility = View.GONE;
}
view.findViewById(R.id.account_offline_shadow).setVisibility(offlineShadowVisibility);
}
}
Aggregations