Revert "Send TYPE_VIEW_FOCUSED for views with input focus. (#12410)" (flutter/engine#12455)

This reverts commit 599389642b because it breaks the Flutter framework build.
This commit is contained in:
Greg Spencer
2019-09-25 20:35:55 -07:00
committed by GitHub
parent e07437abee
commit c671d64ac9

View File

@@ -519,10 +519,6 @@ public class AccessibilityBridge extends AccessibilityNodeProvider {
result.setClassName("android.view.View"); result.setClassName("android.view.View");
result.setSource(rootAccessibilityView, virtualViewId); result.setSource(rootAccessibilityView, virtualViewId);
result.setFocusable(semanticsNode.isFocusable()); result.setFocusable(semanticsNode.isFocusable());
if (semanticsNode.isFocusable()) {
result.addAction(AccessibilityNodeInfo.ACTION_FOCUS);
}
if (inputFocusedSemanticsNode != null) { if (inputFocusedSemanticsNode != null) {
result.setFocused(inputFocusedSemanticsNode.id == virtualViewId); result.setFocused(inputFocusedSemanticsNode.id == virtualViewId);
} }
@@ -1232,11 +1228,6 @@ public class AccessibilityBridge extends AccessibilityNodeProvider {
} }
if (semanticsNode.hasFlag(Flag.IS_FOCUSED)) { if (semanticsNode.hasFlag(Flag.IS_FOCUSED)) {
inputFocusedSemanticsNode = semanticsNode; inputFocusedSemanticsNode = semanticsNode;
AccessibilityEvent event = obtainAccessibilityEvent(
inputFocusedSemanticsNode.id,
AccessibilityEvent.TYPE_VIEW_FOCUSED
);
sendAccessibilityEvent(event);
} }
if (semanticsNode.hadPreviousConfig) { if (semanticsNode.hadPreviousConfig) {
updated.add(semanticsNode); updated.add(semanticsNode);
@@ -1280,7 +1271,7 @@ public class AccessibilityBridge extends AccessibilityNodeProvider {
} }
if (lastAdded != null && lastAdded.id != previousRouteId) { if (lastAdded != null && lastAdded.id != previousRouteId) {
previousRouteId = lastAdded.id; previousRouteId = lastAdded.id;
sendWindowChangeEvent(lastAdded); createAndSendWindowChangeEvent(lastAdded);
} }
flutterNavigationStack.clear(); flutterNavigationStack.clear();
for (SemanticsNode semanticsNode : newRoutes) { for (SemanticsNode semanticsNode : newRoutes) {
@@ -1299,7 +1290,7 @@ public class AccessibilityBridge extends AccessibilityNodeProvider {
// TODO(goderbauer): Send this event only once (!) for changed subtrees, // TODO(goderbauer): Send this event only once (!) for changed subtrees,
// see https://github.com/flutter/flutter/issues/14534 // see https://github.com/flutter/flutter/issues/14534
sendWindowContentChangeEvent(0); sendAccessibilityEvent(0, AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED);
for (SemanticsNode object : updated) { for (SemanticsNode object : updated) {
if (object.didScroll()) { if (object.didScroll()) {
@@ -1371,13 +1362,13 @@ public class AccessibilityBridge extends AccessibilityNodeProvider {
String label = object.label == null ? "" : object.label; String label = object.label == null ? "" : object.label;
String previousLabel = object.previousLabel == null ? "" : object.label; String previousLabel = object.previousLabel == null ? "" : object.label;
if (!label.equals(previousLabel) || !object.hadFlag(Flag.IS_LIVE_REGION)) { if (!label.equals(previousLabel) || !object.hadFlag(Flag.IS_LIVE_REGION)) {
sendWindowContentChangeEvent(object.id); sendAccessibilityEvent(object.id, AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED);
} }
} else if (object.hasFlag(Flag.IS_TEXT_FIELD) && object.didChangeLabel() } else if (object.hasFlag(Flag.IS_TEXT_FIELD) && object.didChangeLabel()
&& inputFocusedSemanticsNode != null && inputFocusedSemanticsNode.id == object.id) { && inputFocusedSemanticsNode != null && inputFocusedSemanticsNode.id == object.id) {
// Text fields should announce when their label changes while focused. We use a live // Text fields should announce when their label changes while focused. We use a live
// region tag to do so, and this event triggers that update. // region tag to do so, and this event triggers that update.
sendWindowContentChangeEvent(object.id); sendAccessibilityEvent(object.id, AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED);
} }
if (accessibilityFocusedSemanticsNode != null && accessibilityFocusedSemanticsNode.id == object.id if (accessibilityFocusedSemanticsNode != null && accessibilityFocusedSemanticsNode.id == object.id
&& !object.hadFlag(Flag.IS_SELECTED) && object.hasFlag(Flag.IS_SELECTED)) { && !object.hadFlag(Flag.IS_SELECTED) && object.hasFlag(Flag.IS_SELECTED)) {
@@ -1481,13 +1472,13 @@ public class AccessibilityBridge extends AccessibilityNodeProvider {
} }
/** /**
* Creates a {@link AccessibilityEvent#TYPE_WINDOW_STATE_CHANGED} and sends the event to * Factory method that creates a {@link AccessibilityEvent#TYPE_WINDOW_STATE_CHANGED} and sends
* Android's accessibility system. * the event to Android's accessibility system.
* *
* The given {@code route} should be a {@link SemanticsNode} that represents a navigation route * The given {@code route} should be a {@link SemanticsNode} that represents a navigation route
* in the Flutter app. * in the Flutter app.
*/ */
private void sendWindowChangeEvent(@NonNull SemanticsNode route) { private void createAndSendWindowChangeEvent(@NonNull SemanticsNode route) {
AccessibilityEvent event = obtainAccessibilityEvent( AccessibilityEvent event = obtainAccessibilityEvent(
route.id, route.id,
AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED
@@ -1497,27 +1488,6 @@ public class AccessibilityBridge extends AccessibilityNodeProvider {
sendAccessibilityEvent(event); sendAccessibilityEvent(event);
} }
/**
* Creates a {@link AccessibilityEvent#TYPE_WINDOW_CONTENT_CHANGED} and sends the event to
* Android's accessibility system.
*
* It sets the content change types to {@link AccessibilityEvent#CONTENT_CHANGE_TYPE_SUBTREE}
* when supported by the API level.
*
* The given {@code virtualViewId} should be a {@link SemanticsNode} below which the content has
* changed.
*/
private void sendWindowContentChangeEvent(int virtualViewId) {
AccessibilityEvent event = obtainAccessibilityEvent(
virtualViewId,
AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED
);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
event.setContentChangeTypes(AccessibilityEvent.CONTENT_CHANGE_TYPE_SUBTREE);
}
sendAccessibilityEvent(event);
}
/** /**
* Factory method that creates a new {@link AccessibilityEvent} that is configured to represent * Factory method that creates a new {@link AccessibilityEvent} that is configured to represent
* the Flutter {@link SemanticsNode} represented by the given {@code virtualViewId}, categorized * the Flutter {@link SemanticsNode} represented by the given {@code virtualViewId}, categorized
@@ -1589,7 +1559,7 @@ public class AccessibilityBridge extends AccessibilityNodeProvider {
} }
accessibilityFocusedSemanticsNode = null; accessibilityFocusedSemanticsNode = null;
hoveredObject = null; hoveredObject = null;
sendWindowContentChangeEvent(0); sendAccessibilityEvent(0, AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED);
} }
/** /**