summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/calllogutils
diff options
context:
space:
mode:
authorlinyuh <linyuh@google.com>2018-02-08 10:44:50 -0800
committerCopybara-Service <copybara-piper@google.com>2018-02-09 16:46:38 -0800
commit21b13e2975180744020b0fb8c150e4a74c45e30c (patch)
tree398fb87ed742538e427373e6928822ce1747387f /java/com/android/dialer/calllogutils
parentd4264575756e50c249ce26e8e12206aa3b4257a6 (diff)
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
Diffstat (limited to 'java/com/android/dialer/calllogutils')
-rw-r--r--java/com/android/dialer/calllogutils/CallLogEntryText.java37
-rw-r--r--java/com/android/dialer/calllogutils/NumberAttributesConverter.java37
-rw-r--r--java/com/android/dialer/calllogutils/res/values/strings.xml3
3 files changed, 72 insertions, 5 deletions
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.
*
- * <p>Rules: (Blocked • )?(Duo video, )?$Label|$Location • Date
+ * <p>Rules:
+ *
+ * <ul>
+ * <li>For numbers that are not spam or blocked: (Duo video, )?$Label|$Location • Date
+ * <li>For blocked non-spam numbers: Blocked • (Duo video, )?$Label|$Location • Date
+ * <li>For spam numbers: Spam • (Duo video, )?$Label • Date
+ * </ul>
*
* <p>Examples:
*
@@ -74,6 +80,10 @@ public final class CallLogEntryText {
* <li>Duo Video • 10 min ago
* <li>Mobile • 11:45 PM
* <li>Mobile • Sun
+ * <li>Blocked • Duo Video, Mobile • Now
+ * <li>Blocked • Brooklyn, NJ • 10 min ago
+ * <li>Spam • Mobile • Now
+ * <li>Spam • Now
* <li>Brooklyn, NJ • Jan 15
* </ul>
*
@@ -82,7 +92,11 @@ public final class CallLogEntryText {
public static CharSequence buildSecondaryTextForEntries(
Context context, Clock clock, CoalescedRow row) {
List<CharSequence> 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<CharSequence> 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 @@
<!-- String used to display calls from blocked numbers in the call log. [CHAR LIMIT=30] -->
<string name="new_call_log_secondary_blocked">Blocked</string>
+
+ <!-- String used to display calls from spam numbers in the call log. [CHAR LIMIT=30] -->
+ <string name="new_call_log_secondary_spam">Spam</string>
</resources> \ No newline at end of file