diff options
author | zachh <zachh@google.com> | 2018-01-26 10:56:46 -0800 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-01-26 12:13:04 -0800 |
commit | 03b13198537df025febb842db7f95794a1faad8f (patch) | |
tree | 2e013c45154e63429d9c4db817d07d3e79a06658 /java/com/android/dialer/calllogutils/CallLogEntryText.java | |
parent | 268aed51f835788ef44329db50b62b34215b9203 (diff) |
Added number presentation to AnnotatedCallLog.
Updated the new call log UI to properly show text based on the presentation.
Bug: 70989592
Test: unit
PiperOrigin-RevId: 183414195
Change-Id: I2123f37cd3c733060125b6e894c1a80be4193ad6
Diffstat (limited to 'java/com/android/dialer/calllogutils/CallLogEntryText.java')
-rw-r--r-- | java/com/android/dialer/calllogutils/CallLogEntryText.java | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/java/com/android/dialer/calllogutils/CallLogEntryText.java b/java/com/android/dialer/calllogutils/CallLogEntryText.java index aa45a697a..49f5e42ca 100644 --- a/java/com/android/dialer/calllogutils/CallLogEntryText.java +++ b/java/com/android/dialer/calllogutils/CallLogEntryText.java @@ -21,6 +21,7 @@ import android.provider.CallLog.Calls; import android.text.TextUtils; import com.android.dialer.calllog.model.CoalescedRow; import com.android.dialer.time.Clock; +import com.google.common.base.Optional; import com.google.common.collect.Collections2; import java.util.ArrayList; import java.util.List; @@ -40,16 +41,25 @@ public final class CallLogEntryText { * following the primary text.) */ public static CharSequence buildPrimaryText(Context context, CoalescedRow row) { - StringBuilder primaryText = new StringBuilder(); + // Always prefer the presentation name, like "Restricted". + Optional<String> presentationName = + PhoneNumberDisplayUtil.getNameForPresentation(context, row.numberPresentation()); + if (presentationName.isPresent()) { + return presentationName.get(); + } + + // Otherwise prefer the name. if (!TextUtils.isEmpty(row.numberAttributes().getName())) { - primaryText.append(row.numberAttributes().getName()); - } else if (!TextUtils.isEmpty(row.formattedNumber())) { - primaryText.append(row.formattedNumber()); - } else { - // TODO(zachh): Handle CallLog.Calls.PRESENTATION_*, including Verizon restricted numbers. - primaryText.append(context.getText(R.string.new_call_log_unknown)); + return row.numberAttributes().getName(); + } + + // Otherwise prefer the formatted number. + if (!TextUtils.isEmpty(row.formattedNumber())) { + return row.formattedNumber(); } - return primaryText.toString(); + + // If there's no formatted number, just return "Unknown". + return context.getText(R.string.new_call_log_unknown); } /** @@ -112,6 +122,14 @@ public final class CallLogEntryText { components.add(getNumberTypeLabel(context, row)); + // If there's a presentation name, we showed it in the primary text and shouldn't show any name + // or number here. + Optional<String> presentationName = + PhoneNumberDisplayUtil.getNameForPresentation(context, row.numberPresentation()); + if (presentationName.isPresent()) { + return joinSecondaryTextComponents(components); + } + if (TextUtils.isEmpty(row.numberAttributes().getName())) { // If the name is empty the number is shown as the primary text and there's nothing to add. return joinSecondaryTextComponents(components); |