Skip to content

Commit 272be27

Browse files
author
Jonah Williams
authored
update live region to trigger on label change, remove manual trigger (flutter#6248)
1 parent 7a9b430 commit 272be27

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

shell/platform/android/io/flutter/view/AccessibilityBridge.java

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -733,8 +733,12 @@ void updateSemantics(ByteBuffer buffer, String[] strings) {
733733
}
734734
sendAccessibilityEvent(event);
735735
}
736-
if (object.hasFlag(Flag.IS_LIVE_REGION) && !object.hadFlag(Flag.IS_LIVE_REGION)) {
737-
sendAccessibilityEvent(object.id, AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED);
736+
if (object.hasFlag(Flag.IS_LIVE_REGION)) {
737+
String label = object.label == null ? "" : object.label;
738+
String previousLabel = object.previousLabel == null ? "" : object.label;
739+
if (!label.equals(previousLabel) || !object.hadFlag(Flag.IS_LIVE_REGION)) {
740+
sendAccessibilityEvent(object.id, AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED);
741+
}
738742
} else if (object.hasFlag(Flag.IS_TEXT_FIELD) && object.didChangeLabel()
739743
&& mInputFocusedObject != null && mInputFocusedObject.id == object.id) {
740744
// Text fields should announce when their label changes while focused. We use a live
@@ -865,17 +869,6 @@ public void onMessage(Object message, BasicMessageChannel.Reply<Object> reply) {
865869
sendAccessibilityEvent(e);
866870
break;
867871
}
868-
// Requires that the node id provided corresponds to a live region, or TalkBack will
869-
// ignore the event. The event will cause talkback to read out the new label even
870-
// if node is not focused.
871-
case "updateLiveRegion": {
872-
Integer nodeId = (Integer) annotatedEvent.get("nodeId");
873-
if (nodeId == null) {
874-
return;
875-
}
876-
sendAccessibilityEvent(nodeId, AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED);
877-
break;
878-
}
879872
}
880873
}
881874

0 commit comments

Comments
 (0)