Skip to content

Commit

Permalink
Tell Android which SemanticsNodes are focusable (flutter#4067)
Browse files Browse the repository at this point in the history
A node is considered focusable if it contains information that is interesing to the user. A node that doesn't add any semantic information of its own should not be focusable. It's expected that such a node has children, who have smeantics information and are therefore focusable.

Fixes flutter/flutter#11179
  • Loading branch information
goderbauer authored Sep 6, 2017
1 parent 83ce8c4 commit ccf68cd
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public AccessibilityNodeInfo createAccessibilityNodeInfo(int virtualViewId) {
result.setPackageName(mOwner.getContext().getPackageName());
result.setClassName("Flutter"); // TODO(goderbauer): Set proper class names
result.setSource(mOwner, virtualViewId);
result.setFocusable(object.isFocusable());

if (object.parent != null) {
assert object.id > 0;
Expand Down Expand Up @@ -144,7 +145,6 @@ public AccessibilityNodeInfo createAccessibilityNodeInfo(int virtualViewId) {
}
if ((object.actions & SEMANTICS_ACTION_INCREASE) != 0
|| (object.actions & SEMANTICS_ACTION_DECREASE) != 0 ) {
result.setFocusable(true);
result.setClassName("android.widget.SeekBar");
if ((object.actions & SEMANTICS_ACTION_INCREASE) != 0) {
result.addAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD);
Expand Down Expand Up @@ -509,6 +509,10 @@ SemanticsObject hitTest(float[] point) {
return this;
}

boolean isFocusable() {
return flags != 0 || label != null || (actions & ~SEMANTICS_ACTION_SCROLLABLE) != 0;
}

void updateRecursively(float[] ancestorTransform, Set<SemanticsObject> visitedObjects, boolean forceUpdate) {
visitedObjects.add(this);

Expand Down

0 comments on commit ccf68cd

Please sign in to comment.