Skip to content

Commit

Permalink
Announce when checked status changes on Android (flutter#4557)
Browse files Browse the repository at this point in the history
  • Loading branch information
goderbauer authored Jan 17, 2018
1 parent e1e97b9 commit 7173a15
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions shell/platform/android/io/flutter/view/AccessibilityBridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -403,13 +403,21 @@ void handleTouchExploration(float x, float y) {

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);
}

Expand All @@ -434,6 +442,10 @@ void updateSemantics(ByteBuffer buffer, String[] strings) {
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) {
Expand Down

0 comments on commit 7173a15

Please sign in to comment.