From 0874af841f7e23357ceb2bb8825180b111d613b4 Mon Sep 17 00:00:00 2001 From: twyen Date: Wed, 24 Jan 2018 16:48:49 -0800 Subject: Show Icon and label for blocked numbers CallLogPhoto.getPhotoUri() returns a URI to a drawable so it will be easier to transition into glide. Meanwhile ContactPhotoManager will just show the drawable directly. Bug: 70989547 Test: Unit tests PiperOrigin-RevId: 183163818 Change-Id: I4ee4ff98782e35d2be03dfe14f8bf3dfd6ded074 --- .../dialer/calllogutils/CallLogEntryText.java | 50 ++++++++++++++-------- .../dialer/calllogutils/res/values/strings.xml | 3 ++ 2 files changed, 34 insertions(+), 19 deletions(-) (limited to 'java/com/android/dialer/calllogutils') diff --git a/java/com/android/dialer/calllogutils/CallLogEntryText.java b/java/com/android/dialer/calllogutils/CallLogEntryText.java index a7a6bba9a..aa45a697a 100644 --- a/java/com/android/dialer/calllogutils/CallLogEntryText.java +++ b/java/com/android/dialer/calllogutils/CallLogEntryText.java @@ -21,6 +21,9 @@ 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.collect.Collections2; +import java.util.ArrayList; +import java.util.List; /** * Computes the primary text and secondary text for call log entries. @@ -52,7 +55,7 @@ public final class CallLogEntryText { /** * The secondary text to show in the main call log entry list. * - *

Rules: (Duo video, )?$Label|$Location • Date + *

Rules: (Blocked • )?(Duo video, )?$Label|$Location • Date * *

Examples: * @@ -68,14 +71,16 @@ public final class CallLogEntryText { */ public static CharSequence buildSecondaryTextForEntries( Context context, Clock clock, CoalescedRow row) { - StringBuilder secondaryText = secondaryTextPrefix(context, row); - - if (secondaryText.length() > 0) { - secondaryText.append(" • "); + List components = new ArrayList<>(); + if (row.numberAttributes().getIsBlocked()) { + components.add(context.getText(R.string.new_call_log_secondary_blocked)); } - secondaryText.append( + + components.add(getNumberTypeLabel(context, row)); + + components.add( CallLogDates.newCallLogTimestampLabel(context, clock.currentTimeMillis(), row.timestamp())); - return secondaryText.toString(); + return joinSecondaryTextComponents(components); } /** @@ -85,9 +90,9 @@ public final class CallLogEntryText { * CoalescedRow)} except that instead of suffixing with the time of the call, we suffix with the * formatted number. */ - public static String buildSecondaryTextForBottomSheet(Context context, CoalescedRow row) { + public static CharSequence buildSecondaryTextForBottomSheet(Context context, CoalescedRow row) { /* - * Rules: (Duo video, )?$Label|$Location [• NumberIfNoName]? + * Rules: (Blocked • )(Duo video, )?$Label|$Location [• NumberIfNoName]? * * The number is shown at the end if there is no name for the entry. (It is shown in primary * text otherwise.) @@ -96,25 +101,27 @@ public final class CallLogEntryText { * Duo Video, Mobile • 555-1234 * Duo Video • 555-1234 * Mobile • 555-1234 + * Blocked • Mobile • 555-1234 * Mobile • 555-1234 * Brooklyn, NJ */ - StringBuilder secondaryText = secondaryTextPrefix(context, row); + List components = new ArrayList<>(); + if (row.numberAttributes().getIsBlocked()) { + components.add(context.getText(R.string.new_call_log_secondary_blocked)); + } + + components.add(getNumberTypeLabel(context, row)); 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 secondaryText.toString(); + return joinSecondaryTextComponents(components); } if (TextUtils.isEmpty(row.formattedNumber())) { // If there's no number, don't append anything. - return secondaryText.toString(); - } - // Otherwise append the number. - if (secondaryText.length() > 0) { - secondaryText.append(" • "); + return joinSecondaryTextComponents(components); } - secondaryText.append(row.formattedNumber()); - return secondaryText.toString(); + components.add(row.formattedNumber()); + return joinSecondaryTextComponents(components); } /** @@ -125,7 +132,7 @@ public final class CallLogEntryText { * time of the call, and when it is shown in a bottom sheet, it is suffixed with the formatted * number. */ - private static StringBuilder secondaryTextPrefix(Context context, CoalescedRow row) { + private static CharSequence getNumberTypeLabel(Context context, CoalescedRow row) { StringBuilder secondaryText = new StringBuilder(); if ((row.features() & Calls.FEATURES_VIDEO) == Calls.FEATURES_VIDEO) { // TODO(zachh): Add "Duo" prefix? @@ -148,4 +155,9 @@ public final class CallLogEntryText { } return secondaryText; } + + private static CharSequence joinSecondaryTextComponents(List components) { + return TextUtils.join( + " • ", Collections2.filter(components, (text) -> !TextUtils.isEmpty(text))); + } } diff --git a/java/com/android/dialer/calllogutils/res/values/strings.xml b/java/com/android/dialer/calllogutils/res/values/strings.xml index 8784bf8c9..4622e509c 100644 --- a/java/com/android/dialer/calllogutils/res/values/strings.xml +++ b/java/com/android/dialer/calllogutils/res/values/strings.xml @@ -136,4 +136,7 @@ Unknown + + + Blocked \ No newline at end of file -- cgit v1.2.3