diff options
author | twyen <twyen@google.com> | 2017-10-06 23:39:59 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-10-06 23:39:59 +0000 |
commit | 0429052242e3ee4475442f884a553dfcb795a938 (patch) | |
tree | 1a1b42bc1e08b690af866a9d99fce8818ed4e13e | |
parent | 5f5edeff754d1160b9b49cb5054678debff49597 (diff) | |
parent | 087329e9256f56b5ba8252fd7c0d5b468797cb96 (diff) |
Merge "Tag incoming call notification with SIM label on multi-SIM devices"
am: 087329e925
Change-Id: Ib5b5b782cdbd1867491d2098df22338c8d89dab6
-rw-r--r-- | java/com/android/incallui/StatusBarNotifier.java | 32 | ||||
-rw-r--r-- | java/com/android/incallui/res/values/strings.xml | 2 |
2 files changed, 30 insertions, 4 deletions
diff --git a/java/com/android/incallui/StatusBarNotifier.java b/java/com/android/incallui/StatusBarNotifier.java index 86ad9ffe5..6ddba1613 100644 --- a/java/com/android/incallui/StatusBarNotifier.java +++ b/java/com/android/incallui/StatusBarNotifier.java @@ -299,7 +299,7 @@ public class StatusBarNotifier // Check if data has changed; if nothing is different, don't issue another notification. final int iconResId = getIconToDisplay(call); Bitmap largeIcon = getLargeIconToDisplay(mContext, contactInfo, call); - final String content = getContentString(call, contactInfo.userType); + final CharSequence content = getContentString(call, contactInfo.userType); final String contentTitle = getContentTitle(contactInfo, call); final boolean isVideoUpgradeRequest = @@ -329,7 +329,7 @@ public class StatusBarNotifier if (!checkForChangeAndSaveData( iconResId, - content, + content.toString(), largeIcon, contentTitle, callState, @@ -681,7 +681,7 @@ public class StatusBarNotifier } /** Returns the message to use with the notification. */ - private String getContentString(DialerCall call, @UserType long userType) { + private CharSequence getContentString(DialerCall call, @UserType long userType) { boolean isIncomingOrWaiting = call.getState() == DialerCall.State.INCOMING || call.getState() == DialerCall.State.CALL_WAITING; @@ -709,7 +709,8 @@ public class StatusBarNotifier resId = getECIncomingCallText(call.getEnrichedCallSession()); } else if (call.hasProperty(Details.PROPERTY_WIFI)) { resId = R.string.notification_incoming_call_wifi_template; - + } else if (call.getAccountHandle() != null && hasMultiplePhoneAccounts()) { + return getMultiSimIncomingText(call); } else { resId = R.string.notification_incoming_call; } @@ -812,6 +813,24 @@ public class StatusBarNotifier return resId; } + private CharSequence getMultiSimIncomingText(DialerCall call) { + PhoneAccount phoneAccount = + mContext.getSystemService(TelecomManager.class).getPhoneAccount(call.getAccountHandle()); + SpannableString string = + new SpannableString( + mContext.getString( + R.string.notification_incoming_call_mutli_sim, phoneAccount.getLabel())); + int accountStart = string.toString().lastIndexOf(phoneAccount.getLabel().toString()); + int accountEnd = accountStart + phoneAccount.getLabel().length(); + + string.setSpan( + new ForegroundColorSpan(phoneAccount.getHighlightColor()), + accountStart, + accountEnd, + Spannable.SPAN_INCLUSIVE_EXCLUSIVE); + return string; + } + /** Gets the most relevant call to display in the notification. */ private DialerCall getCallToShow(CallList callList) { if (callList == null) { @@ -1022,6 +1041,11 @@ public class StatusBarNotifier mStatusBarCallListener = listener; } + @SuppressWarnings("MissingPermission") + private boolean hasMultiplePhoneAccounts() { + return mContext.getSystemService(TelecomManager.class).getCallCapablePhoneAccounts().size() > 1; + } + @Override public void onAudioStateChanged(CallAudioState audioState) { if (CallList.getInstance().getActiveOrBackgroundCall() == null) { diff --git a/java/com/android/incallui/res/values/strings.xml b/java/com/android/incallui/res/values/strings.xml index 74b3ef80b..afadbf828 100644 --- a/java/com/android/incallui/res/values/strings.xml +++ b/java/com/android/incallui/res/values/strings.xml @@ -65,6 +65,8 @@ <string name="notification_on_hold">On hold</string> <!-- The "label" of the in-call Notification for an incoming ringing call. [CHAR LIMIT=60] --> <string name="notification_incoming_call">Incoming call</string> + <!-- The "label" of the in-call Notification for an incoming ringing call on a device with multiple SIMs. [CHAR LIMIT=60] --> + <string name="notification_incoming_call_mutli_sim">Incoming call via <xliff:g id="sim_label" example="SIM 1">%1$s</xliff:g></string> <!-- The "label" of the in-call Notification for an incoming ringing call. [CHAR LIMIT=50] --> <string name="notification_incoming_call_with_photo">Incoming call with photo</string> <!-- The "label" of the in-call Notification for an incoming ringing call. [CHAR LIMIT=50] --> |