Example usage for android.telecom PhoneAccount NO_HIGHLIGHT_COLOR

List of usage examples for android.telecom PhoneAccount NO_HIGHLIGHT_COLOR

Introduction

In this page you can find the example usage for android.telecom PhoneAccount NO_HIGHLIGHT_COLOR.

Prototype

int NO_HIGHLIGHT_COLOR

To view the source code for android.telecom PhoneAccount NO_HIGHLIGHT_COLOR.

Click Source Link

Document

Indicating no hightlight color is set.

Usage

From source file:Main.java

/**
 * Extract account color from PhoneAccount object.
 *//*w  ww .ja v a  2s .  c o m*/
public static int getAccountColor(Context context, PhoneAccountHandle accountHandle) {
    TelecomManager telecomManager = (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE);
    final PhoneAccount account = telecomManager.getPhoneAccount(accountHandle);

    // For single-sim devices the PhoneAccount will be NO_HIGHLIGHT_COLOR by default, so it is
    // safe to always use the account highlight color.
    return account == null ? PhoneAccount.NO_HIGHLIGHT_COLOR : account.getHighlightColor();
}

From source file:com.android.dialer.calllog.PhoneCallDetailsHelper.java

/** Fills the call details views with content. */
public void setPhoneCallDetails(PhoneCallDetailsViews views, PhoneCallDetails details) {
    // Display up to a given number of icons.
    views.callTypeIcons.clear();//from  w w  w  .j av a 2  s .co m
    int count = details.callTypes.length;
    boolean isVoicemail = false;
    for (int index = 0; index < count && index < MAX_CALL_TYPE_ICONS; ++index) {
        views.callTypeIcons.add(details.callTypes[index]);
        if (index == 0) {
            isVoicemail = details.callTypes[index] == Calls.VOICEMAIL_TYPE;
        }
    }

    // Show the video icon if the call had video enabled.
    views.callTypeIcons.setShowVideo((details.features & Calls.FEATURES_VIDEO) == Calls.FEATURES_VIDEO);
    views.callTypeIcons.requestLayout();
    views.callTypeIcons.setVisibility(View.VISIBLE);

    // Show the total call count only if there are more than the maximum number of icons.
    final Integer callCount;
    if (count > MAX_CALL_TYPE_ICONS) {
        callCount = count;
    } else {
        callCount = null;
    }

    // Set the call count, location, date and if voicemail, set the duration.
    setDetailText(views, callCount, details);

    // Set the account label if it exists.
    String accountLabel = mCallLogCache.getAccountLabel(details.accountHandle);
    if (!TextUtils.isEmpty(details.viaNumber)) {
        if (!TextUtils.isEmpty(accountLabel)) {
            accountLabel = mResources.getString(R.string.call_log_via_number_phone_account, accountLabel,
                    details.viaNumber);
        } else {
            accountLabel = mResources.getString(R.string.call_log_via_number, details.viaNumber);
        }
    }
    if (!TextUtils.isEmpty(accountLabel)) {
        views.callAccountLabel.setVisibility(View.VISIBLE);
        views.callAccountLabel.setText(accountLabel);
        int color = mCallLogCache.getAccountColor(details.accountHandle);
        if (color == PhoneAccount.NO_HIGHLIGHT_COLOR) {
            int defaultColor = R.color.dialtacts_secondary_text_color;
            views.callAccountLabel.setTextColor(mContext.getResources().getColor(defaultColor));
        } else {
            views.callAccountLabel.setTextColor(color);
        }
    } else {
        views.callAccountLabel.setVisibility(View.GONE);
    }

    final CharSequence nameText;
    final CharSequence displayNumber = details.displayNumber;
    if (TextUtils.isEmpty(details.getPreferredName())) {
        nameText = displayNumber;
        // We have a real phone number as "nameView" so make it always LTR
        views.nameView.setTextDirection(View.TEXT_DIRECTION_LTR);
    } else {
        nameText = details.getPreferredName();
    }

    views.nameView.setText(nameText);

    if (isVoicemail) {
        views.voicemailTranscriptionView
                .setText(TextUtils.isEmpty(details.transcription) ? null : details.transcription);
    }

    // Bold if not read
    Typeface typeface = details.isRead ? Typeface.SANS_SERIF : Typeface.DEFAULT_BOLD;
    views.nameView.setTypeface(typeface);
    views.voicemailTranscriptionView.setTypeface(typeface);
    views.callLocationAndDate.setTypeface(typeface);
    views.callLocationAndDate.setTextColor(ContextCompat.getColor(mContext,
            details.isRead ? R.color.call_log_detail_color : R.color.call_log_unread_text_color));
}