Tell Android which SemanticsNodes are focusable (#4067)

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 https://github.com/flutter/flutter/issues/11179
This commit is contained in:
Michael Goderbauer 2017-09-06 16:56:23 -07:00 committed by GitHub
parent 83ce8c40b1
commit ccf68cdcb6

View File

@ -95,6 +95,7 @@ class AccessibilityBridge extends AccessibilityNodeProvider implements BasicMess
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;
@ -144,7 +145,6 @@ class AccessibilityBridge extends AccessibilityNodeProvider implements BasicMess
}
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);
@ -509,6 +509,10 @@ class AccessibilityBridge extends AccessibilityNodeProvider implements BasicMess
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);