Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

[a11y] Support TalkBack reading by word, character, and paragraph #17626

Merged
merged 13 commits into from
Apr 16, 2020
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions shell/platform/android/io/flutter/view/AccessibilityBridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,12 @@ && shouldSetCollectionInfo(semanticsNode)) {
result.setLiveRegion(View.ACCESSIBILITY_LIVE_REGION_POLITE);
}

if (semanticsNode.hasFlag(Flag.IS_TEXT_FIELD)) {
result.setText(semanticsNode.getValueLabelHint());
} else {
result.setContentDescription(semanticsNode.getValueLabelHint());
}

boolean hasCheckedState = semanticsNode.hasFlag(Flag.HAS_CHECKED_STATE);
boolean hasToggledState = semanticsNode.hasFlag(Flag.HAS_TOGGLED_STATE);
if (BuildConfig.DEBUG && (hasCheckedState && hasToggledState)) {
Expand All @@ -747,7 +753,6 @@ && shouldSetCollectionInfo(semanticsNode)) {
result.setCheckable(hasCheckedState || hasToggledState);
if (hasCheckedState) {
result.setChecked(semanticsNode.hasFlag(Flag.IS_CHECKED));
result.setContentDescription(semanticsNode.getValueLabelHint());
if (semanticsNode.hasFlag(Flag.IS_IN_MUTUALLY_EXCLUSIVE_GROUP)) {
result.setClassName("android.widget.RadioButton");
} else {
Expand All @@ -756,13 +761,7 @@ && shouldSetCollectionInfo(semanticsNode)) {
} else if (hasToggledState) {
result.setChecked(semanticsNode.hasFlag(Flag.IS_TOGGLED));
result.setClassName("android.widget.Switch");
result.setContentDescription(semanticsNode.getValueLabelHint());
} else if (!semanticsNode.hasFlag(Flag.SCOPES_ROUTE)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this change now make SemanticsNodes that are scoping a route and have a label focusable?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll update the condition so we don't apply it to those nodes, thanks for jogging my memory a bit on the context

// Setting the text directly instead of the content description
// will replace the "checked" or "not-checked" label.
result.setText(semanticsNode.getValueLabelHint());
}

result.setSelected(semanticsNode.hasFlag(Flag.IS_SELECTED));

// Heading support
Expand Down