summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
authortwyen <twyen@google.com>2017-10-05 17:34:43 -0700
committerEric Erfanian <erfanian@google.com>2017-10-06 14:56:10 -0700
commitd1d1d0c6726b9501cfb6f19317f9bf4e70e0d1dd (patch)
tree90e5b0820f950a9c8cf4afb6a1721f7420e28992 /java
parent016e53f6ecf5eaaa810025364862f72877ee6c88 (diff)
Tag incoming call notification with SIM label on multi-SIM devices
The label is colorized with the SIM color, if the system UI decides to respect it. screenshot: https://screenshot.googleplex.com/PzkCKdQJ7Wy Bug: 64215023 Test: StatusBarNotifierTest PiperOrigin-RevId: 171234005 Change-Id: I684753b6181bdfe601244d01ab608fcd5d5dc422
Diffstat (limited to 'java')
-rw-r--r--java/com/android/incallui/StatusBarNotifier.java32
-rw-r--r--java/com/android/incallui/res/values/strings.xml2
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] -->