Search in sources :

Example 1 with StatusMode

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

Example 2 with StatusMode

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

Example 3 with StatusMode

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

Example 4 with StatusMode

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

Example 5 with StatusMode

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);
    }
}
Also used : StatusMode(com.xabber.android.data.account.StatusMode) LayoutInflater(android.view.LayoutInflater) Presence(org.jivesoftware.smack.packet.Presence) TextView(android.widget.TextView) ClientInfo(com.xabber.android.data.extension.capability.ClientInfo) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView)

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