Skip to content

Commit

Permalink
if we don't set anything, talkback will announce it as checkbox becau…
Browse files Browse the repository at this point in the history
…se this class extends AppCompatCheckBox. This fix set the class name to be generic android view so nothing is announced if view is not checkable or clickable

PiperOrigin-RevId: 265746456
  • Loading branch information
Material Design Team authored and wcshi committed Aug 29, 2019
1 parent 72cfef9 commit 79953b0
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/java/com/google/android/material/chip/Chip.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ public class Chip extends AppCompatCheckBox implements Delegate, Shapeable {
private static final String BUTTON_ACCESSIBILITY_CLASS_NAME = "android.widget.Button";
private static final String COMPOUND_BUTTON_ACCESSIBILITY_CLASS_NAME =
"android.widget.CompoundButton";
private static final String GENERIC_VIEW_ACCESSIBILITY_CLASS_NAME = "android.view.View";

@NonNull private final ChipTouchHelper touchHelper;
private final Rect rect = new Rect();
Expand Down Expand Up @@ -266,6 +267,8 @@ public void onInitializeAccessibilityNodeInfo(@NonNull AccessibilityNodeInfo inf
isCheckable()
? COMPOUND_BUTTON_ACCESSIBILITY_CLASS_NAME
: BUTTON_ACCESSIBILITY_CLASS_NAME);
} else {
info.setClassName(GENERIC_VIEW_ACCESSIBILITY_CLASS_NAME);
}
info.setCheckable(isCheckable());
info.setClickable(isClickable());
Expand Down Expand Up @@ -1031,6 +1034,8 @@ protected void onPopulateNodeForHost(@NonNull AccessibilityNodeInfoCompat node)
isCheckable()
? COMPOUND_BUTTON_ACCESSIBILITY_CLASS_NAME
: BUTTON_ACCESSIBILITY_CLASS_NAME);
} else {
node.setClassName(GENERIC_VIEW_ACCESSIBILITY_CLASS_NAME);
}
CharSequence chipText = getText();
if (VERSION.SDK_INT >= VERSION_CODES.M) {
Expand Down

0 comments on commit 79953b0

Please sign in to comment.