update live region to trigger on label change, remove manual trigger (flutter/engine#6248)

This commit is contained in:
Jonah Williams
2018-09-14 09:10:59 -07:00
committed by GitHub
parent 62266d8440
commit b4198127e3

View File

@@ -733,8 +733,12 @@ class AccessibilityBridge
}
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
@@ -865,17 +869,6 @@ class AccessibilityBridge
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;
}
}
}