diff options
author | twyen <twyen@google.com> | 2018-01-24 16:48:49 -0800 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-01-24 19:09:39 -0800 |
commit | 0874af841f7e23357ceb2bb8825180b111d613b4 (patch) | |
tree | 23982c4a353490aa0a605b0e04b8656def2a3775 /java/com/android/dialer/calllogutils | |
parent | 2a422f719b70f6c292b954fb24f324b7f4ac1858 (diff) |
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
Diffstat (limited to 'java/com/android/dialer/calllogutils')
-rw-r--r-- | java/com/android/dialer/calllogutils/CallLogEntryText.java | 50 | ||||
-rw-r--r-- | java/com/android/dialer/calllogutils/res/values/strings.xml | 3 |
2 files changed, 34 insertions, 19 deletions
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. * - * <p>Rules: (Duo video, )?$Label|$Location • Date + * <p>Rules: (Blocked • )?(Duo video, )?$Label|$Location • Date * * <p>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<CharSequence> 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<CharSequence> 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<CharSequence> 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 @@ <!-- String used to display calls from unknown numbers in the call log. [CHAR LIMIT=30] --> <string name="new_call_log_unknown">Unknown</string> + + <!-- String used to display calls from blocked numbers in the call log. [CHAR LIMIT=30] --> + <string name="new_call_log_secondary_blocked">Blocked</string> </resources>
\ No newline at end of file |