Skip to content

Commit

Permalink
update live region to trigger on label change, remove manual trigger (f…
Browse files Browse the repository at this point in the history
  • Loading branch information
jonahwilliams authored Sep 14, 2018
1 parent 7a9b430 commit 272be27
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions shell/platform/android/io/flutter/view/AccessibilityBridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -733,8 +733,12 @@ void updateSemantics(ByteBuffer buffer, String[] strings) {
}
sendAccessibilityEvent(event);
}
if (object.hasFlag(Flag.IS_LIVE_REGION) && !object.hadFlag(Flag.IS_LIVE_REGION)) {
sendAccessibilityEvent(object.id, AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED);
if (object.hasFlag(Flag.IS_LIVE_REGION)) {
String label = object.label == null ? "" : object.label;
String previousLabel = object.previousLabel == null ? "" : object.label;
if (!label.equals(previousLabel) || !object.hadFlag(Flag.IS_LIVE_REGION)) {
sendAccessibilityEvent(object.id, AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED);
}
} else if (object.hasFlag(Flag.IS_TEXT_FIELD) && object.didChangeLabel()
&& mInputFocusedObject != null && mInputFocusedObject.id == object.id) {
// Text fields should announce when their label changes while focused. We use a live
Expand Down Expand Up @@ -865,17 +869,6 @@ public void onMessage(Object message, BasicMessageChannel.Reply<Object> reply) {
sendAccessibilityEvent(e);
break;
}
// Requires that the node id provided corresponds to a live region, or TalkBack will
// ignore the event. The event will cause talkback to read out the new label even
// if node is not focused.
case "updateLiveRegion": {
Integer nodeId = (Integer) annotatedEvent.get("nodeId");
if (nodeId == null) {
return;
}
sendAccessibilityEvent(nodeId, AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED);
break;
}
}
}

Expand Down

0 comments on commit 272be27

Please sign in to comment.