diff options
author | linyuh <linyuh@google.com> | 2018-05-23 16:41:50 -0700 |
---|---|---|
committer | Eric Erfanian <erfanian@google.com> | 2018-05-30 14:03:01 +0000 |
commit | 19a7c0eda9730798100994e0b5a6e99197f04f3d (patch) | |
tree | 728f98a3d2b71fc7bd662a38a0f7f22b4e0009e4 /java/com/android/dialer/calllogutils/CallLogEntryText.java | |
parent | 2ad3c08bc26edee0c721505e21c9764c10e3e5f7 (diff) |
Better a11y for new call log entries.
Bug: 70989658
Test: CallLogDatesTest, CallLogEntryDescriptionsTest, NewCallLogViewHolderTest
PiperOrigin-RevId: 197811739
Change-Id: I0f9d1e79d8e687efffbb1dac01aaf6fa26a45f6a
Diffstat (limited to 'java/com/android/dialer/calllogutils/CallLogEntryText.java')
-rw-r--r-- | java/com/android/dialer/calllogutils/CallLogEntryText.java | 71 |
1 files changed, 48 insertions, 23 deletions
diff --git a/java/com/android/dialer/calllogutils/CallLogEntryText.java b/java/com/android/dialer/calllogutils/CallLogEntryText.java index acf8ef932..895497f0f 100644 --- a/java/com/android/dialer/calllogutils/CallLogEntryText.java +++ b/java/com/android/dialer/calllogutils/CallLogEntryText.java @@ -26,6 +26,7 @@ import com.android.dialer.time.Clock; import com.google.common.base.Optional; import com.google.common.collect.Collections2; import java.util.ArrayList; +import java.util.Collections; import java.util.List; /** @@ -76,45 +77,69 @@ public final class CallLogEntryText { } /** - * The secondary text to show in the main call log entry list. + * The secondary text to be shown in the main call log entry list. + * + * <p>This method first obtains a list of strings to be shown in order and then concatenates them + * with " • ". + * + * <p>Examples: + * + * <ul> + * <li>Mobile, Duo video • 10 min ago + * <li>Spam • Mobile • Now + * <li>Blocked • Spam • Mobile • Now + * </ul> + * + * @see #buildSecondaryTextListForEntries(Context, Clock, CoalescedRow, boolean) for details. + */ + public static CharSequence buildSecondaryTextForEntries( + Context context, Clock clock, CoalescedRow row) { + return joinSecondaryTextComponents( + buildSecondaryTextListForEntries(context, clock, row, /* abbreviateDateTime = */ true)); + } + + /** + * Returns a list of strings to be shown in order as the main call log entry's secondary text. * * <p>Rules: * * <ul> - * <li>An emergency number: Date + * <li>An emergency number: [{Date}] * <li>Number - not blocked, call - not spam: - * <p>$Label(, Duo video|Carrier video)?|$Location • Date + * <p>[{$Label(, Duo video|Carrier video)?|$Location}, {Date}] * <li>Number - blocked, call - not spam: - * <p>Blocked • $Label(, Duo video|Carrier video)?|$Location • Date + * <p>["Blocked", {$Label(, Duo video|Carrier video)?|$Location}, {Date}] * <li>Number - not blocked, call - spam: - * <p>Spam • $Label(, Duo video|Carrier video)? • Date + * <p>["Spam", {$Label(, Duo video|Carrier video)?}, {Date}] * <li>Number - blocked, call - spam: - * <p>Blocked • Spam • $Label(, Duo video|Carrier video)? • Date + * <p>["Blocked, Spam", {$Label(, Duo video|Carrier video)?}, {Date}] * </ul> * * <p>Examples: * * <ul> - * <li>Mobile, Duo video • Now - * <li>Duo video • 10 min ago - * <li>Mobile • 11:45 PM - * <li>Mobile • Sun - * <li>Blocked • Mobile, Duo video • Now - * <li>Blocked • Brooklyn, NJ • 10 min ago - * <li>Spam • Mobile • Now - * <li>Spam • Now - * <li>Blocked • Spam • Mobile • Now - * <li>Brooklyn, NJ • Jan 15 + * <li>["Mobile, Duo video", "Now"] + * <li>["Duo video", "10 min ago"] + * <li>["Mobile", "11:45 PM"] + * <li>["Mobile", "Sun"] + * <li>["Blocked", "Mobile, Duo video", "Now"] + * <li>["Blocked", "Brooklyn, NJ", "10 min ago"] + * <li>["Spam", "Mobile", "Now"] + * <li>["Spam", "Now"] + * <li>["Blocked", "Spam", "Mobile", "Now"] + * <li>["Brooklyn, NJ", "Jan 15"] * </ul> * - * <p>See {@link CallLogDates#newCallLogTimestampLabel(Context, long, long)} for date rules. + * <p>See {@link CallLogDates#newCallLogTimestampLabel(Context, long, long, boolean)} for date + * rules. */ - public static CharSequence buildSecondaryTextForEntries( - Context context, Clock clock, CoalescedRow row) { + static List<CharSequence> buildSecondaryTextListForEntries( + Context context, Clock clock, CoalescedRow row, boolean abbreviateDateTime) { // For emergency numbers, the secondary text should contain only the timestamp. if (row.getNumberAttributes().getIsEmergencyNumber()) { - return CallLogDates.newCallLogTimestampLabel( - context, clock.currentTimeMillis(), row.getTimestamp()); + return Collections.singletonList( + CallLogDates.newCallLogTimestampLabel( + context, clock.currentTimeMillis(), row.getTimestamp(), abbreviateDateTime)); } List<CharSequence> components = new ArrayList<>(); @@ -130,8 +155,8 @@ public final class CallLogEntryText { components.add( CallLogDates.newCallLogTimestampLabel( - context, clock.currentTimeMillis(), row.getTimestamp())); - return joinSecondaryTextComponents(components); + context, clock.currentTimeMillis(), row.getTimestamp(), abbreviateDateTime)); + return components; } /** |