summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/calllogutils
diff options
context:
space:
mode:
authorTreehugger Robot <treehugger-gerrit@google.com>2018-05-10 01:14:47 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2018-05-10 01:14:47 +0000
commitced93f2d22bffce3b4cfb9c3bfce862b385537dd (patch)
tree2b4715070bcf45b8a8395ee0ae5c7fbb0ef8274c /java/com/android/dialer/calllogutils
parentc49c914e53500fc661ec47e365621c9d33e046ca (diff)
parent2f4a0075e9f546514359eda60a24ac9cd49ea80a (diff)
Merge changes Ia54e3421,Id2176e6e,I0311770e,I79f99c34,I8579afff, ...
* changes: Add some annotations that won't influence aosp. Update answer button logic. Hide new after call spam blocking promo behind an additional flag. Allow the TextView for call log primary text to adjust size when recycled. Format callback phone number. Added getLoggingName() to CallLogDataSource and PhoneLookup interfaces. Do not show bubble for outgoing call if it's not a background call. Always fetch status onResume and add logging for voicemail status in OldMainPeer and Place Duo calls with PreCall Creating CallIntent, AutoValue builder, to replace CallIntentBuilder. Set the DisplayNameSource to PHONE in DefaultLookupUriGenerator. Config correct layout boundaries to accommodate long text (call log & bottom sheet) Use info from EmergencyPhoneLookup to render UI for an emergency number. Implement EmergencyPhoneLookup for checking if a number is an emergency number. Add GlobalSpamListStatus and UserSpamListStatus Move SpamStatus classes into subpackage Delete obsolete checkSpamStatus(Listener) API Update callers of checkSpamStatus to use Future based API Fix bug that showing block option for private number. Add a null check for digitsHint. Don't commit fragment transactions if it's not safe. Add ListenableFuture based APIs for checkSpamStatus Pass activity between new call log's adapter/view holder. Replace assert checks with safety checks instead. Add SimpleSpamStatus and use it in FakeSpam and SpamStub Show calls to/from emergency numbers as "Emergency number" in call log & call details
Diffstat (limited to 'java/com/android/dialer/calllogutils')
-rw-r--r--java/com/android/dialer/calllogutils/CallLogEntryText.java32
-rw-r--r--java/com/android/dialer/calllogutils/CallLogRowActions.java7
-rw-r--r--java/com/android/dialer/calllogutils/NumberAttributesConverter.java3
3 files changed, 36 insertions, 6 deletions
diff --git a/java/com/android/dialer/calllogutils/CallLogEntryText.java b/java/com/android/dialer/calllogutils/CallLogEntryText.java
index 1b7bb06fa..54b1e195a 100644
--- a/java/com/android/dialer/calllogutils/CallLogEntryText.java
+++ b/java/com/android/dialer/calllogutils/CallLogEntryText.java
@@ -42,28 +42,35 @@ public final class CallLogEntryText {
* following the primary text.)
*/
public static CharSequence buildPrimaryText(Context context, CoalescedRow row) {
- // Always prefer the presentation name, like "Restricted".
+ // Calls to emergency services should be shown as "Emergency number".
+ if (row.getNumberAttributes().getIsEmergencyNumber()) {
+ return context.getText(R.string.emergency_number);
+ }
+
+ // Otherwise, follow the following order of preferences.
+ // 1st preference: the presentation name, like "Restricted".
Optional<String> presentationName =
PhoneNumberDisplayUtil.getNameForPresentation(context, row.getNumberPresentation());
if (presentationName.isPresent()) {
return presentationName.get();
}
+ // 2nd preference: the voicemail tag if the call is one made to a voicemail box.
if (row.getIsVoicemailCall() && !TextUtils.isEmpty(row.getVoicemailCallTag())) {
return row.getVoicemailCallTag();
}
- // Otherwise prefer the name.
+ // 3rd preference: the name associated with the number.
if (!TextUtils.isEmpty(row.getNumberAttributes().getName())) {
return row.getNumberAttributes().getName();
}
- // Otherwise prefer the formatted number.
+ // 4th preference: the formatted number.
if (!TextUtils.isEmpty(row.getFormattedNumber())) {
return row.getFormattedNumber();
}
- // If there's no formatted number, just return "Unknown".
+ // Last resort: show "Unknown".
return context.getText(R.string.new_call_log_unknown);
}
@@ -73,6 +80,7 @@ public final class CallLogEntryText {
* <p>Rules:
*
* <ul>
+ * <li>For emergency numbers: Date
* <li>For numbers that are not spam or blocked: $Label(, Duo video|Carrier video)?|$Location •
* Date
* <li>For blocked non-spam numbers: Blocked • $Label(, Duo video|Carrier video)?|$Location •
@@ -100,6 +108,12 @@ public final class CallLogEntryText {
*/
public static CharSequence buildSecondaryTextForEntries(
Context context, Clock clock, CoalescedRow row) {
+ // For emergency numbers, the secondary text should contain only the timestamp.
+ if (row.getNumberAttributes().getIsEmergencyNumber()) {
+ return CallLogDates.newCallLogTimestampLabel(
+ context, clock.currentTimeMillis(), row.getTimestamp());
+ }
+
List<CharSequence> components = new ArrayList<>();
if (row.getNumberAttributes().getIsBlocked()) {
@@ -127,6 +141,8 @@ public final class CallLogEntryText {
public static CharSequence buildSecondaryTextForBottomSheet(Context context, CoalescedRow row) {
/*
* Rules:
+ * For emergency numbers:
+ * Number
* For numbers that are not spam or blocked:
* $Label(, Duo video|Carrier video)?|$Location [• NumberIfNoName]?
* For blocked non-spam numbers:
@@ -149,6 +165,14 @@ public final class CallLogEntryText {
* Mobile • 555-1234
* Brooklyn, NJ
*/
+
+ // For emergency numbers, the secondary text should contain only the number.
+ if (row.getNumberAttributes().getIsEmergencyNumber()) {
+ return !row.getFormattedNumber().isEmpty()
+ ? row.getFormattedNumber()
+ : row.getNumber().getNormalizedNumber();
+ }
+
List<CharSequence> components = new ArrayList<>();
if (row.getNumberAttributes().getIsBlocked()) {
diff --git a/java/com/android/dialer/calllogutils/CallLogRowActions.java b/java/com/android/dialer/calllogutils/CallLogRowActions.java
index d23a15f78..65f3c5fd6 100644
--- a/java/com/android/dialer/calllogutils/CallLogRowActions.java
+++ b/java/com/android/dialer/calllogutils/CallLogRowActions.java
@@ -20,6 +20,7 @@ import android.provider.CallLog.Calls;
import com.android.dialer.callintent.CallInitiationType;
import com.android.dialer.callintent.CallIntentBuilder;
import com.android.dialer.calllog.model.CoalescedRow;
+import com.android.dialer.duo.DuoComponent;
import com.android.dialer.precall.PreCall;
/** Actions which can be performed on a call log row. */
@@ -37,6 +38,10 @@ public final class CallLogRowActions {
activity,
new CallIntentBuilder(
row.getNumber().getNormalizedNumber(), CallInitiationType.Type.CALL_LOG)
- .setIsVideoCall((row.getFeatures() & Calls.FEATURES_VIDEO) == Calls.FEATURES_VIDEO));
+ .setIsVideoCall((row.getFeatures() & Calls.FEATURES_VIDEO) == Calls.FEATURES_VIDEO)
+ .setIsDuoCall(
+ DuoComponent.get(activity)
+ .getDuo()
+ .isDuoAccount(row.getPhoneAccountComponentName())));
}
}
diff --git a/java/com/android/dialer/calllogutils/NumberAttributesConverter.java b/java/com/android/dialer/calllogutils/NumberAttributesConverter.java
index 9f07fdac5..8081c4b3f 100644
--- a/java/com/android/dialer/calllogutils/NumberAttributesConverter.java
+++ b/java/com/android/dialer/calllogutils/NumberAttributesConverter.java
@@ -57,6 +57,7 @@ public final class NumberAttributesConverter {
.setIsCp2InfoIncomplete(phoneLookupInfoConsolidator.isDefaultCp2InfoIncomplete())
.setContactSource(phoneLookupInfoConsolidator.getContactSource())
.setCanSupportCarrierVideoCall(phoneLookupInfoConsolidator.canSupportCarrierVideoCall())
- .setGeolocation(phoneLookupInfoConsolidator.getGeolocation());
+ .setGeolocation(phoneLookupInfoConsolidator.getGeolocation())
+ .setIsEmergencyNumber(phoneLookupInfoConsolidator.isEmergencyNumber());
}
}