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/calllog | |
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/calllog')
3 files changed, 61 insertions, 7 deletions
diff --git a/java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java b/java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java index 4def69cf9..3b21a60de 100644 --- a/java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java +++ b/java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java @@ -26,12 +26,16 @@ import android.telecom.PhoneAccount; import android.telecom.PhoneAccountHandle; import android.text.TextUtils; import android.view.View; +import android.view.View.AccessibilityDelegate; +import android.view.accessibility.AccessibilityNodeInfo; +import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction; import android.widget.ImageView; import android.widget.TextView; import com.android.dialer.calllog.database.Coalescer; import com.android.dialer.calllog.model.CoalescedRow; import com.android.dialer.calllog.ui.NewCallLogAdapter.PopCounts; import com.android.dialer.calllog.ui.menu.NewCallLogMenu; +import com.android.dialer.calllogutils.CallLogEntryDescriptions; import com.android.dialer.calllogutils.CallLogEntryText; import com.android.dialer.calllogutils.CallLogRowActions; import com.android.dialer.calllogutils.PhoneAccountUtils; @@ -62,6 +66,7 @@ final class NewCallLogViewHolder extends RecyclerView.ViewHolder { private final ImageView assistedDialIcon; private final TextView phoneAccountView; private final ImageView menuButton; + private final View callLogEntryRootView; private final Clock clock; private final RealtimeRowProcessor realtimeRowProcessor; @@ -78,6 +83,7 @@ final class NewCallLogViewHolder extends RecyclerView.ViewHolder { PopCounts popCounts) { super(view); this.activity = activity; + callLogEntryRootView = view; contactPhotoView = view.findViewById(R.id.contact_photo_view); primaryTextView = view.findViewById(R.id.primary_text); callCountTextView = view.findViewById(R.id.call_count); @@ -107,6 +113,7 @@ final class NewCallLogViewHolder extends RecyclerView.ViewHolder { // what information we have, rather than an empty card. For example, if CP2 information needs to // be queried on the fly, we can still show the phone number until the contact name loads. displayRow(row); + configA11yForRow(row); // Note: This leaks the view holder via the callback (which is an inner class), but this is OK // because we only create ~10 of them (and they'll be collected assuming all jobs finish). @@ -142,6 +149,28 @@ final class NewCallLogViewHolder extends RecyclerView.ViewHolder { setOnClickListenerForMenuButon(row); } + private void configA11yForRow(CoalescedRow row) { + callLogEntryRootView.setContentDescription( + CallLogEntryDescriptions.buildDescriptionForEntry(activity, clock, row)); + + // Inform a11y users that double tapping an entry now makes a call. + // This will instruct TalkBack to say "double tap to call" instead of + // "double tap to activate". + callLogEntryRootView.setAccessibilityDelegate( + new AccessibilityDelegate() { + @Override + public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) { + super.onInitializeAccessibilityNodeInfo(host, info); + info.addAction( + new AccessibilityAction( + AccessibilityNodeInfo.ACTION_CLICK, + activity + .getResources() + .getString(R.string.a11y_new_call_log_entry_tap_action))); + } + }); + } + private void setNumberCalls(CoalescedRow row) { int numberCalls = row.getCoalescedIds().getCoalescedIdCount(); if (numberCalls > 1) { @@ -274,6 +303,12 @@ final class NewCallLogViewHolder extends RecyclerView.ViewHolder { private void setOnClickListenerForMenuButon(CoalescedRow row) { menuButton.setOnClickListener(NewCallLogMenu.createOnClickListener(activity, row)); + menuButton.setContentDescription( + activity + .getResources() + .getString( + R.string.a11y_new_call_log_entry_expand_menu, + CallLogEntryText.buildPrimaryText(activity, row))); } private class RealtimeRowFutureCallback implements FutureCallback<CoalescedRow> { diff --git a/java/com/android/dialer/calllog/ui/res/layout/new_call_log_entry.xml b/java/com/android/dialer/calllog/ui/res/layout/new_call_log_entry.xml index 0acd8155f..726c53bc1 100644 --- a/java/com/android/dialer/calllog/ui/res/layout/new_call_log_entry.xml +++ b/java/com/android/dialer/calllog/ui/res/layout/new_call_log_entry.xml @@ -30,13 +30,19 @@ android:layout_marginEnd="8dp" android:layout_centerVertical="true"/> + <!-- + A vertical linear layout of three rows: primary info, secondary info, and phone account info. + It is marked as not important for a11y as we will set a more user-friendly content description + for the entire entry view in Java code. + --> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_toEndOf="@+id/contact_photo_view" android:layout_toStartOf="@+id/menu_button" - android:orientation="vertical"> + android:orientation="vertical" + android:importantForAccessibility="noHideDescendants"> <!-- 1st row: primary info --> <LinearLayout @@ -134,6 +140,10 @@ </LinearLayout> + <!-- + The button to expand the bottom sheet for an entry. + Its content description is set in Java code. + --> <ImageView android:id="@+id/menu_button" android:layout_width="56dp" @@ -141,8 +151,8 @@ android:layout_alignParentEnd="true" android:layout_centerVertical="true" android:background="?android:attr/selectableItemBackgroundBorderless" - android:contentDescription="@string/a11y_new_call_log_expand_menu_for_entry" android:scaleType="center" android:src="@drawable/quantum_ic_more_vert_vd_theme_24" - android:tint="?colorIcon"/> + android:tint="?colorIcon" + tools:ignore="ContentDescription"/> </RelativeLayout> diff --git a/java/com/android/dialer/calllog/ui/res/values/strings.xml b/java/com/android/dialer/calllog/ui/res/values/strings.xml index 3f6462c7b..112044f6e 100644 --- a/java/com/android/dialer/calllog/ui/res/values/strings.xml +++ b/java/com/android/dialer/calllog/ui/res/values/strings.xml @@ -16,12 +16,21 @@ --> <resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + + <!-- + A string informing a11y users that activating a call log entry will place a call. + Note: the word "call" here is a verb. + [CHAR LIMIT=NONE] + --> + <string name="a11y_new_call_log_entry_tap_action">call</string> + <!-- - A string to describe available action for accessibility user. - It will be read as "expand menu for this call log entry". + A string describing the menu button of a call log entry for a11y users. + An example will be read as "expand call log menu for Jane Smith". + [CHAR LIMIT=NONE] --> - <string name="a11y_new_call_log_expand_menu_for_entry"> - Expand menu for this call log entry + <string name="a11y_new_call_log_entry_expand_menu"> + Expand call log menu for <xliff:g example="Jane Smith" id="primaryTextForEntry">%1$s</xliff:g> </string> <!-- Header in call log to group calls from the current day. [CHAR LIMIT=30] --> |