未验证 提交 7173a158 编写于 作者: M Michael Goderbauer 提交者: GitHub

Announce when checked status changes on Android (#4557)

Fixes https://github.com/flutter/flutter/issues/14092
上级 e1e97b91
......@@ -403,13 +403,21 @@ class AccessibilityBridge extends AccessibilityNodeProvider implements BasicMess
void updateSemantics(ByteBuffer buffer, String[] strings) {
ArrayList<Integer> updated = new ArrayList<Integer>();
ArrayList<Integer> checkedChanged = new ArrayList<Integer>();
while (buffer.hasRemaining()) {
int id = buffer.getInt();
SemanticsObject object = getOrCreateObject(id);
boolean hadCheckedState = object.hasFlag(Flag.HAS_CHECKED_STATE);
boolean wasChecked = object.hasFlag(Flag.IS_CHECKED);
object.updateWith(buffer, strings);
if (object.hasFlag(Flag.IS_FOCUSED)) {
mInputFocusedObject = object;
}
if (mA11yFocusedObject != null && mA11yFocusedObject.id == id
&& hadCheckedState && object.hasFlag(Flag.HAS_CHECKED_STATE)
&& wasChecked != object.hasFlag(Flag.IS_CHECKED)) {
checkedChanged.add(id);
}
updated.add(id);
}
......@@ -434,6 +442,10 @@ class AccessibilityBridge extends AccessibilityNodeProvider implements BasicMess
for (Integer id : updated) {
sendAccessibilityEvent(id, AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED);
}
for (Integer id : checkedChanged) {
// Simulate a click so TalkBack announces the change in checked state.
sendAccessibilityEvent(id, AccessibilityEvent.TYPE_VIEW_CLICKED);
}
}
private AccessibilityEvent obtainAccessibilityEvent(int virtualViewId, int eventType) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册