From 33c901987a7010754fc1eddcc1933bfd63458322 Mon Sep 17 00:00:00 2001 From: maxwelb Date: Wed, 21 Mar 2018 13:00:28 -0700 Subject: Display "Emergency number" in the call log for emergency numbers This CL updates the call log to show "Emergency number" for call log rows from numbers that PhoneNumberUtils.isEmergencyNumber considers to be emergency numbers. Bug: 66926712 Test: Manual, see above PiperOrigin-RevId: 189953302 Change-Id: Ibaae243ead8b918a26f6058164316e042a4f82fd --- .../dialer/app/calllog/PhoneCallDetailsHelper.java | 54 +++++++++------------- .../android/dialer/theme/res/values/strings.xml | 3 ++ java/com/android/incallui/CallerInfo.java | 2 +- java/com/android/incallui/res/values/strings.xml | 3 -- 4 files changed, 26 insertions(+), 36 deletions(-) (limited to 'java') diff --git a/java/com/android/dialer/app/calllog/PhoneCallDetailsHelper.java b/java/com/android/dialer/app/calllog/PhoneCallDetailsHelper.java index b88a959ed..096488a39 100644 --- a/java/com/android/dialer/app/calllog/PhoneCallDetailsHelper.java +++ b/java/com/android/dialer/app/calllog/PhoneCallDetailsHelper.java @@ -27,6 +27,7 @@ import android.provider.ContactsContract.CommonDataKinds.Phone; import android.support.v4.content.ContextCompat; import android.telecom.PhoneAccount; import android.telecom.PhoneAccountHandle; +import android.telephony.PhoneNumberUtils; import android.text.SpannableString; import android.text.TextUtils; import android.text.format.DateUtils; @@ -199,20 +200,7 @@ public class PhoneCallDetailsHelper views.callAccountLabel.setVisibility(View.GONE); } - final CharSequence nameText; - final CharSequence displayNumber = details.displayNumber; - if (TextUtils.isEmpty(details.getPreferredName())) { - nameText = displayNumber; - // We have a real phone number as "nameView" so make it always LTR - views.nameView.setTextDirection(View.TEXT_DIRECTION_LTR); - } else { - nameText = details.getPreferredName(); - // "nameView" is updated from phone number to contact name after number matching. - // Since TextDirection remains at View.TEXT_DIRECTION_LTR, initialize it. - views.nameView.setTextDirection(View.TEXT_DIRECTION_INHERIT); - } - - views.nameView.setText(nameText); + setNameView(views, details); if (isVoicemail) { int relevantLinkTypes = Linkify.EMAIL_ADDRESSES | Linkify.PHONE_NUMBERS | Linkify.WEB_URLS; @@ -282,6 +270,26 @@ public class PhoneCallDetailsHelper details.isRead ? R.color.call_log_detail_color : R.color.call_log_unread_text_color)); } + private void setNameView(PhoneCallDetailsViews views, PhoneCallDetails details) { + if (!TextUtils.isEmpty(details.getPreferredName())) { + views.nameView.setText(details.getPreferredName()); + // "nameView" is updated from phone number to contact name after number matching. + // Since TextDirection remains at View.TEXT_DIRECTION_LTR, initialize it. + views.nameView.setTextDirection(View.TEXT_DIRECTION_INHERIT); + return; + } + + if (PhoneNumberUtils.isEmergencyNumber(details.number.toString())) { + views.nameView.setText(R.string.emergency_number); + views.nameView.setTextDirection(View.TEXT_DIRECTION_INHERIT); + return; + } + + views.nameView.setText(details.displayNumber); + // We have a real phone number as "nameView" so make it always LTR + views.nameView.setTextDirection(View.TEXT_DIRECTION_LTR); + } + private boolean shouldShowTranscriptionRating( int transcriptionState, PhoneAccountHandle account) { if (transcriptionState != VoicemailCompat.TRANSCRIPTION_AVAILABLE) { @@ -548,24 +556,6 @@ public class PhoneCallDetailsHelper return currentYear != calendar.get(Calendar.YEAR); } - /** Sets the text of the header view for the details page of a phone call. */ - public void setCallDetailsHeader(TextView nameView, PhoneCallDetails details) { - final CharSequence nameText; - if (!TextUtils.isEmpty(details.namePrimary)) { - nameText = details.namePrimary; - } else if (!TextUtils.isEmpty(details.displayNumber)) { - nameText = details.displayNumber; - } else { - nameText = resources.getString(R.string.unknown); - } - - nameView.setText(nameText); - } - - public void setCurrentTimeForTest(long currentTimeMillis) { - currentTimeMillisForTest = currentTimeMillis; - } - /** * Returns the current time in milliseconds since the epoch. * diff --git a/java/com/android/dialer/theme/res/values/strings.xml b/java/com/android/dialer/theme/res/values/strings.xml index 6194751ef..bab05ed41 100644 --- a/java/com/android/dialer/theme/res/values/strings.xml +++ b/java/com/android/dialer/theme/res/values/strings.xml @@ -26,6 +26,9 @@ Payphone + + Emergency number + Phone diff --git a/java/com/android/incallui/CallerInfo.java b/java/com/android/incallui/CallerInfo.java index fd9855f24..0aedea531 100644 --- a/java/com/android/incallui/CallerInfo.java +++ b/java/com/android/incallui/CallerInfo.java @@ -485,7 +485,7 @@ public class CallerInfo { * @return this instance. */ /* package */ CallerInfo markAsEmergency(Context context) { - name = context.getString(R.string.emergency_call_dialog_number_for_display); + name = context.getString(R.string.emergency_number); phoneNumber = null; isEmergency = true; diff --git a/java/com/android/incallui/res/values/strings.xml b/java/com/android/incallui/res/values/strings.xml index af6125366..15cd2e02d 100644 --- a/java/com/android/incallui/res/values/strings.xml +++ b/java/com/android/incallui/res/values/strings.xml @@ -172,9 +172,6 @@ Manage conference call - - Emergency number - via %s -- cgit v1.2.3