Search in sources :

Example 6 with StatusMode

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;
}
Also used : StatusMode(com.xabber.android.data.account.StatusMode) ColorDrawable(android.graphics.drawable.ColorDrawable) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView)

Example 7 with StatusMode

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());
}
Also used : StatusMode(com.xabber.android.data.account.StatusMode)

Example 8 with StatusMode

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);
}
Also used : StatusMode(com.xabber.android.data.account.StatusMode) ListView(android.widget.ListView) AccountItem(com.xabber.android.data.account.AccountItem) LayoutInflater(android.view.LayoutInflater) StatusEditorAdapter(com.xabber.android.ui.adapter.StatusEditorAdapter) Intent(android.content.Intent) StatusModeAdapter(com.xabber.android.ui.adapter.StatusModeAdapter) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) Toolbar(android.support.v7.widget.Toolbar) BarPainter(com.xabber.android.ui.color.BarPainter)

Example 9 with StatusMode

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;
}
Also used : StatusMode(com.xabber.android.data.account.StatusMode) ColorDrawable(android.graphics.drawable.ColorDrawable) AccountItem(com.xabber.android.data.account.AccountItem) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView)

Example 10 with StatusMode

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);
    }
}
Also used : CircleImageView(de.hdodenhof.circleimageview.CircleImageView) AccountPainter(com.xabber.android.ui.color.AccountPainter) StatusMode(com.xabber.android.data.account.StatusMode) FloatingActionButton(com.melnykov.fab.FloatingActionButton) CircleImageView(de.hdodenhof.circleimageview.CircleImageView) View(android.view.View)

Aggregations

StatusMode (com.xabber.android.data.account.StatusMode)11 View (android.view.View)6 ImageView (android.widget.ImageView)5 TextView (android.widget.TextView)5 ColorDrawable (android.graphics.drawable.ColorDrawable)3 RecyclerView (android.support.v7.widget.RecyclerView)3 AccountItem (com.xabber.android.data.account.AccountItem)3 LayoutInflater (android.view.LayoutInflater)2 Intent (android.content.Intent)1 SharedPreferences (android.content.SharedPreferences)1 Toolbar (android.support.v7.widget.Toolbar)1 AdapterView (android.widget.AdapterView)1 ListView (android.widget.ListView)1 FloatingActionButton (com.melnykov.fab.FloatingActionButton)1 ClientInfo (com.xabber.android.data.extension.capability.ClientInfo)1 ShowOfflineMode (com.xabber.android.data.roster.ShowOfflineMode)1 StatusEditorAdapter (com.xabber.android.ui.adapter.StatusEditorAdapter)1 StatusModeAdapter (com.xabber.android.ui.adapter.StatusModeAdapter)1 AccountPainter (com.xabber.android.ui.color.AccountPainter)1 BarPainter (com.xabber.android.ui.color.BarPainter)1