Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 816cad3f authored by Wenbo Jie's avatar Wenbo Jie
Browse files

[DocsUI M3] Fix talkback issue on the breadcrumb

Previously we put clickable/focusable directly on the TextView
inside the breadcrumb, which doesn't work well with the special
handling (AccessibilityEventRouter) of a11y inside breadcrumb,
which causes double tapping can't activate the breadcrumb item.
This CL moves the clickable/focusable back to the breadcrumb item
container and use duplicateParentState=true on the TextView to
get the expected state on the TextView.

Check the attached bug for the demo.

Bug: 415695308
Test: m DocumentsUIGoogle && manual inspection
Flag: com.android.documentsui.flags.use_material3
Change-Id: I3d9349fef193e86ca15ba32be0b6ed39963e460f
parent 3b94d234
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

<ripple
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:color="@color/breadcrumb_item_ripple_color">
    <item
        android:id="@android:id/mask"
@@ -24,6 +23,9 @@

    <item>
        <selector>
            <item android:state_enabled="false">
                <color android:color="@android:color/transparent"/>
            </item>
            <item android:state_pressed="true">
                <shape android:tint="?attr/colorOnSurfaceVariant">
                    <corners android:radius="@dimen/breadcrumb_item_height_m3" />
+11 −2
Original line number Diff line number Diff line
@@ -21,14 +21,23 @@
    android:layout_height="wrap_content"
    android:minHeight="@dimen/breadcrumb_height"
    android:gravity="center_vertical"
    android:focusable="true"
    android:clickable="true"
    android:defaultFocusHighlightEnabled="false"
    android:orientation="horizontal">

    <!-- We can't put clickable/focusable on the TextView below even though we only want the
         highlight/focus ring on the TextView instead of the whole item, this is because there is a
         specific logic in HorizontalBreadcrumb when binding click event, the event is bound
         on the whole item directly and there are special a11y handling (check the
         `setAccessibilityDelegateCompat` call). Given we don't want the focus background on
         the item, we also need defaultFocusHighlightEnabled above and duplicateParentState
         below.  -->
    <com.google.android.material.textview.MaterialTextView
        android:id="@+id/breadcrumb_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:focusable="true"
        android:clickable="true"
        android:duplicateParentState="true"
        android:maxWidth="275dp"
        android:gravity="center_vertical"
        android:maxLines="1"
+1 −1
Original line number Diff line number Diff line
@@ -203,7 +203,7 @@ public final class HorizontalBreadcrumb extends RecyclerView implements Breadcru
                    isFirst ? mEnv.getCurrentRoot().title : mState.stack.get(position).displayName);
            if (isUseMaterial3FlagEnabled()) {
                // The last path part in the breadcrumb is not clickable.
                holder.mTitle.setEnabled(!isLast);
                holder.itemView.setEnabled(!isLast);
            } else {
                holder.mTitle.setEnabled(isLast);
            }