diff options
author | Android Dialer <noreply@google.com> | 2018-06-27 13:13:29 -0700 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2018-06-27 13:13:29 -0700 |
commit | 95194792e7f479979bef3290165952480a97af58 (patch) | |
tree | 3a32e17e1d9c79e8306119d817fd7964fbef82d1 /java/com/android/incallui/contactgrid/TopRow.java | |
parent | 9f15322971cf09dfed32517a575db887ca180f02 (diff) | |
parent | cd5228be7f4f00d3972343c5c30ca6faebf86986 (diff) |
Merge changes I0f1ed20a,Ia68d3b13,I72047d59,Ieff3c7fb,I53c3896a, ... am: 1b4ec7b954
am: cd5228be7f
Change-Id: I47f0dcffa5d58cf182bfd59a01ef8baac9e69204
Diffstat (limited to 'java/com/android/incallui/contactgrid/TopRow.java')
-rw-r--r-- | java/com/android/incallui/contactgrid/TopRow.java | 23 |
1 files changed, 21 insertions, 2 deletions
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) { |