From d745887310ae896649b11d9044cfbf070b2e5ac9 Mon Sep 17 00:00:00 2001 From: wangqi Date: Tue, 26 Jun 2018 13:39:18 -0700 Subject: Update connection label. Bug: 79878432 Test: manual PiperOrigin-RevId: 202185676 Change-Id: I53c3896a68f9dbed9316360d7f4ad6dd7cbe17ec --- java/com/android/incallui/CallCardPresenter.java | 2 ++ java/com/android/incallui/contactgrid/TopRow.java | 23 ++++++++++++++++++++-- .../incallui/contactgrid/res/values/strings.xml | 2 +- .../incallui/incall/protocol/PrimaryCallState.java | 8 +++++++- 4 files changed, 31 insertions(+), 4 deletions(-) diff --git a/java/com/android/incallui/CallCardPresenter.java b/java/com/android/incallui/CallCardPresenter.java index b9e6744ea..dd1fc4f37 100644 --- a/java/com/android/incallui/CallCardPresenter.java +++ b/java/com/android/incallui/CallCardPresenter.java @@ -469,6 +469,8 @@ public class CallCardPresenter .setSessionModificationState(primary.getVideoTech().getSessionModificationState()) .setDisconnectCause(primary.getDisconnectCause()) .setConnectionLabel(getConnectionLabel()) + .setPrimaryColor( + InCallPresenter.getInstance().getThemeColorManager().getPrimaryColor()) .setSimSuggestionReason(getSimSuggestionReason()) .setConnectionIcon(getCallStateIcon()) .setGatewayNumber(getGatewayNumber()) diff --git a/java/com/android/incallui/contactgrid/TopRow.java b/java/com/android/incallui/contactgrid/TopRow.java index 82a103a61..d242c3a14 100644 --- a/java/com/android/incallui/contactgrid/TopRow.java +++ b/java/com/android/incallui/contactgrid/TopRow.java @@ -21,8 +21,12 @@ import android.graphics.drawable.Drawable; import android.support.annotation.Nullable; import android.telephony.PhoneNumberUtils; import android.text.BidiFormatter; +import android.text.Spannable; +import android.text.SpannableString; +import android.text.Spanned; import android.text.TextDirectionHeuristics; import android.text.TextUtils; +import android.text.style.ForegroundColorSpan; import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; import com.android.incallui.call.state.DialerCallState; @@ -141,8 +145,7 @@ public class TopRow { } else if (state.isWifi() && !TextUtils.isEmpty(state.connectionLabel())) { return state.connectionLabel(); } else if (isAccount(state)) { - return context.getString( - R.string.contact_grid_incoming_via_template, state.connectionLabel()); + return getColoredConnectionLabel(context, state); } else if (state.isWorkCall()) { return context.getString(R.string.contact_grid_incoming_work_call); } else { @@ -150,6 +153,22 @@ public class TopRow { } } + private static Spannable getColoredConnectionLabel(Context context, PrimaryCallState state) { + Assert.isNotNull(state.connectionLabel()); + String label = + context.getString(R.string.contact_grid_incoming_via_template, state.connectionLabel()); + Spannable spannable = new SpannableString(label); + + int start = label.indexOf(state.connectionLabel()); + int end = start + state.connectionLabel().length(); + spannable.setSpan( + new ForegroundColorSpan(state.primaryColor()), + start, + end, + Spanned.SPAN_INCLUSIVE_EXCLUSIVE); + return spannable; + } + private static CharSequence getLabelForIncomingVideo( Context context, @SessionModificationState int sessionModificationState, boolean isWifi) { if (sessionModificationState == SessionModificationState.RECEIVED_UPGRADE_TO_VIDEO_REQUEST) { diff --git a/java/com/android/incallui/contactgrid/res/values/strings.xml b/java/com/android/incallui/contactgrid/res/values/strings.xml index 7c0f5a679..9ee10c327 100644 --- a/java/com/android/incallui/contactgrid/res/values/strings.xml +++ b/java/com/android/incallui/contactgrid/res/values/strings.xml @@ -89,7 +89,7 @@ Work call from - Incoming via %s + Call via %s from Suspected spam caller diff --git a/java/com/android/incallui/incall/protocol/PrimaryCallState.java b/java/com/android/incallui/incall/protocol/PrimaryCallState.java index 423f86875..e07caf1b6 100644 --- a/java/com/android/incallui/incall/protocol/PrimaryCallState.java +++ b/java/com/android/incallui/incall/protocol/PrimaryCallState.java @@ -17,6 +17,7 @@ package com.android.incallui.incall.protocol; import android.graphics.drawable.Drawable; +import android.support.annotation.ColorInt; import android.support.annotation.IntDef; import android.support.annotation.Nullable; import android.telecom.DisconnectCause; @@ -59,6 +60,8 @@ public abstract class PrimaryCallState { @Nullable public abstract String connectionLabel(); + public abstract @ColorInt int primaryColor(); + @Nullable public abstract SuggestionProvider.Reason simSuggestionReason(); @@ -127,7 +130,8 @@ public abstract class PrimaryCallState { .setIsBusinessNumber(false) .setSupportsCallOnHold(true) .setSwapToSecondaryButtonState(ButtonState.NOT_SUPPORT) - .setIsAssistedDialed(false); + .setIsAssistedDialed(false) + .setPrimaryColor(0); } /** Builder class for primary call state info. */ @@ -148,6 +152,8 @@ public abstract class PrimaryCallState { public abstract Builder setConnectionIcon(Drawable connectionIcon); + public abstract Builder setPrimaryColor(@ColorInt int color); + public abstract Builder setGatewayNumber(String gatewayNumber); public abstract Builder setCallSubject(String callSubject); -- cgit v1.2.3