From 21b13e2975180744020b0fb8c150e4a74c45e30c Mon Sep 17 00:00:00 2001 From: linyuh Date: Thu, 8 Feb 2018 10:44:50 -0800 Subject: Show icon and label for a spam number in the new call log. Bug: 73077158 Test: CallLogEntryTextTest, GlidePhotoManagerImplTest, PhoneLookupInfoConsolidatorTest PiperOrigin-RevId: 185017362 Change-Id: I113472482da2213d17a847054272a22249edc578 --- .../dialer/calllogutils/CallLogEntryText.java | 37 +++++++++++++++++++--- .../calllogutils/NumberAttributesConverter.java | 37 ++++++++++++++++++++++ .../dialer/calllogutils/res/values/strings.xml | 3 ++ 3 files changed, 72 insertions(+), 5 deletions(-) create mode 100644 java/com/android/dialer/calllogutils/NumberAttributesConverter.java (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 49f5e42ca..737b1d30f 100644 --- a/java/com/android/dialer/calllogutils/CallLogEntryText.java +++ b/java/com/android/dialer/calllogutils/CallLogEntryText.java @@ -65,7 +65,13 @@ public final class CallLogEntryText { /** * The secondary text to show in the main call log entry list. * - *

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

Rules: + * + *

* *

Examples: * @@ -74,6 +80,10 @@ public final class CallLogEntryText { *

  • Duo Video • 10 min ago *
  • Mobile • 11:45 PM *
  • Mobile • Sun + *
  • Blocked • Duo Video, Mobile • Now + *
  • Blocked • Brooklyn, NJ • 10 min ago + *
  • Spam • Mobile • Now + *
  • Spam • Now *
  • Brooklyn, NJ • Jan 15 * * @@ -82,7 +92,11 @@ public final class CallLogEntryText { public static CharSequence buildSecondaryTextForEntries( Context context, Clock clock, CoalescedRow row) { List components = new ArrayList<>(); - if (row.numberAttributes().getIsBlocked()) { + + // If a number is both spam and blocked, only show "Spam". + if (row.numberAttributes().getIsSpam()) { + components.add(context.getText(R.string.new_call_log_secondary_spam)); + } else if (row.numberAttributes().getIsBlocked()) { components.add(context.getText(R.string.new_call_log_secondary_blocked)); } @@ -102,7 +116,13 @@ public final class CallLogEntryText { */ public static CharSequence buildSecondaryTextForBottomSheet(Context context, CoalescedRow row) { /* - * Rules: (Blocked • )(Duo video, )?$Label|$Location [• NumberIfNoName]? + * Rules: + * For numbers that are not spam or blocked: + * (Duo video, )?$Label|$Location [• NumberIfNoName]? + * For blocked non-spam numbers: + * Blocked • (Duo video, )?$Label|$Location [• NumberIfNoName]? + * For spam numbers: + * Spam • (Duo video, )?$Label [• NumberIfNoName]? * * The number is shown at the end if there is no name for the entry. (It is shown in primary * text otherwise.) @@ -112,11 +132,17 @@ public final class CallLogEntryText { * Duo Video • 555-1234 * Mobile • 555-1234 * Blocked • Mobile • 555-1234 + * Blocked • Brooklyn, NJ • 555-1234 + * Spam • Mobile • 555-1234 * Mobile • 555-1234 * Brooklyn, NJ */ List components = new ArrayList<>(); - if (row.numberAttributes().getIsBlocked()) { + + // If a number is both spam and blocked, only show "Spam". + if (row.numberAttributes().getIsSpam()) { + components.add(context.getText(R.string.new_call_log_secondary_spam)); + } else if (row.numberAttributes().getIsBlocked()) { components.add(context.getText(R.string.new_call_log_secondary_blocked)); } @@ -162,7 +188,8 @@ public final class CallLogEntryText { secondaryText.append(", "); } secondaryText.append(numberTypeLabel); - } else { // If there's a number type label, don't show the location. + } else if (!row.numberAttributes().getIsSpam()) { + // Don't show the location if there's a number type label or the number is spam. String location = row.geocodedLocation(); if (!TextUtils.isEmpty(location)) { if (secondaryText.length() > 0) { diff --git a/java/com/android/dialer/calllogutils/NumberAttributesConverter.java b/java/com/android/dialer/calllogutils/NumberAttributesConverter.java new file mode 100644 index 000000000..bed1edd06 --- /dev/null +++ b/java/com/android/dialer/calllogutils/NumberAttributesConverter.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.dialer.calllogutils; + +import com.android.dialer.NumberAttributes; +import com.android.dialer.glidephotomanager.PhotoInfo; + +/** Converts {@link NumberAttributes} to {@link PhotoInfo} */ +public final class NumberAttributesConverter { + + /** Converts to {@link PhotoInfo.Builder} */ + public static PhotoInfo.Builder toPhotoInfoBuilder(NumberAttributes numberAttributes) { + return PhotoInfo.builder() + .setName(numberAttributes.getName()) + .setPhotoUri(numberAttributes.getPhotoUri()) + .setPhotoId(numberAttributes.getPhotoId()) + .setLookupUri(numberAttributes.getLookupUri()) + .setIsBusiness(numberAttributes.getIsBusiness()) + .setIsSpam(numberAttributes.getIsSpam()) + .setIsVoicemail(numberAttributes.getIsVoicemail()) + .setIsBlocked(numberAttributes.getIsBlocked()); + } +} diff --git a/java/com/android/dialer/calllogutils/res/values/strings.xml b/java/com/android/dialer/calllogutils/res/values/strings.xml index 4622e509c..f536ca66d 100644 --- a/java/com/android/dialer/calllogutils/res/values/strings.xml +++ b/java/com/android/dialer/calllogutils/res/values/strings.xml @@ -139,4 +139,7 @@ Blocked + + + Spam \ No newline at end of file -- cgit v1.2.3