diff options
author | Eric Erfanian <erfanian@google.com> | 2017-06-08 00:59:55 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-06-08 00:59:55 +0000 |
commit | c67d658e7daa453fe9ad9fd1a37f81eaf2048c44 (patch) | |
tree | b9bbc285430ffb5363a70eb27e382c38f5a85b7a /java/com/android/incallui/contactgrid/TopRow.java | |
parent | 75233ff03785f24789b32039ac2c208805b7e506 (diff) | |
parent | 274b6d320edb3c33e7b3a95c43a811829486a777 (diff) |
Update AOSP Dialer source from internal google3 repository at cl/158012278. am: 91ce7d2a47
am: 274b6d320e
Change-Id: Iecf4325f314bf6c3324187e6406c8aae4675dd63
Diffstat (limited to 'java/com/android/incallui/contactgrid/TopRow.java')
-rw-r--r-- | java/com/android/incallui/contactgrid/TopRow.java | 52 |
1 files changed, 45 insertions, 7 deletions
diff --git a/java/com/android/incallui/contactgrid/TopRow.java b/java/com/android/incallui/contactgrid/TopRow.java index 8c3d6b004..ab003570f 100644 --- a/java/com/android/incallui/contactgrid/TopRow.java +++ b/java/com/android/incallui/contactgrid/TopRow.java @@ -19,10 +19,14 @@ package com.android.incallui.contactgrid; import android.content.Context; import android.graphics.drawable.Drawable; import android.support.annotation.Nullable; +import android.telephony.PhoneNumberUtils; +import android.text.BidiFormatter; +import android.text.TextDirectionHeuristics; import android.text.TextUtils; import com.android.dialer.common.Assert; import com.android.incallui.call.DialerCall.State; import com.android.incallui.incall.protocol.PrimaryCallState; +import com.android.incallui.incall.protocol.PrimaryInfo; import com.android.incallui.videotech.utils.SessionModificationState; import com.android.incallui.videotech.utils.VideoUtils; @@ -55,7 +59,7 @@ public class TopRow { private TopRow() {} - public static Info getInfo(Context context, PrimaryCallState state) { + public static Info getInfo(Context context, PrimaryCallState state, PrimaryInfo primaryInfo) { CharSequence label = null; Drawable icon = state.connectionIcon; boolean labelIsSingleLine = true; @@ -73,6 +77,11 @@ public class TopRow { labelIsSingleLine = false; } else { label = getLabelForIncoming(context, state); + // Show phone number if it's not displayed in name (center row) or location field (bottom + // row). + if (shouldShowNumber(primaryInfo)) { + label = TextUtils.concat(label, " ", spanDisplayNumber(primaryInfo.number)); + } } } else if (VideoUtils.hasSentVideoUpgradeRequest(state.sessionModificationState) || VideoUtils.hasReceivedVideoUpgradeRequest(state.sessionModificationState)) { @@ -85,6 +94,8 @@ public class TopRow { label = getLabelForDialing(context, state); } else if (state.state == State.ACTIVE && state.isRemotelyHeld) { label = context.getString(R.string.incall_remotely_held); + } else if (state.state == State.ACTIVE && shouldShowNumber(primaryInfo)) { + label = spanDisplayNumber(primaryInfo.number); } else { // Video calling... // [Wi-Fi icon] Starbucks Wi-Fi @@ -94,9 +105,27 @@ public class TopRow { return new Info(label, icon, labelIsSingleLine); } + private static CharSequence spanDisplayNumber(String displayNumber) { + return PhoneNumberUtils.createTtsSpannable( + BidiFormatter.getInstance().unicodeWrap(displayNumber, TextDirectionHeuristics.LTR)); + } + + private static boolean shouldShowNumber(PrimaryInfo primaryInfo) { + if (primaryInfo.nameIsNumber) { + return false; + } + if (primaryInfo.location == null) { + return false; + } + if (TextUtils.isEmpty(primaryInfo.number)) { + return false; + } + return true; + } + private static CharSequence getLabelForIncoming(Context context, PrimaryCallState state) { if (state.isVideoCall) { - return getLabelForIncomingVideo(context, state.isWifi); + return getLabelForIncomingVideo(context, state.sessionModificationState, state.isWifi); } else if (state.isWifi && !TextUtils.isEmpty(state.connectionLabel)) { return state.connectionLabel; } else if (isAccount(state)) { @@ -108,11 +137,20 @@ public class TopRow { } } - private static CharSequence getLabelForIncomingVideo(Context context, boolean isWifi) { - if (isWifi) { - return context.getString(R.string.contact_grid_incoming_wifi_video_call); + private static CharSequence getLabelForIncomingVideo( + Context context, @SessionModificationState int sessionModificationState, boolean isWifi) { + if (sessionModificationState == SessionModificationState.RECEIVED_UPGRADE_TO_VIDEO_REQUEST) { + if (isWifi) { + return context.getString(R.string.contact_grid_incoming_wifi_video_request); + } else { + return context.getString(R.string.contact_grid_incoming_video_request); + } } else { - return context.getString(R.string.contact_grid_incoming_video_call); + if (isWifi) { + return context.getString(R.string.contact_grid_incoming_wifi_video_call); + } else { + return context.getString(R.string.contact_grid_incoming_video_call); + } } } @@ -154,7 +192,7 @@ public class TopRow { case SessionModificationState.UPGRADE_TO_VIDEO_REQUEST_TIMED_OUT: return context.getString(R.string.incall_video_call_request_timed_out); case SessionModificationState.RECEIVED_UPGRADE_TO_VIDEO_REQUEST: - return getLabelForIncomingVideo(context, state.isWifi); + return getLabelForIncomingVideo(context, state.sessionModificationState, state.isWifi); case SessionModificationState.NO_REQUEST: default: Assert.fail(); |