Live update sidebar with click and focus accessibility events
Summary: Lets AX inspector live update the sidebar when a view is clicked (state may change) or accessibility focus changes (previously only updated the sidebar live if it became the focused element). Differential Revision: D9489376 fbshipit-source-id: 8959f722370ce1d3a622b24c7b049b03f0d662e6
This commit is contained in:
committed by
Facebook Github Bot
parent
61258d4b64
commit
364883f661
@@ -221,7 +221,8 @@ public class InspectorSonarPlugin implements SonarPlugin {
|
||||
final SonarArray.Builder result = new SonarArray.Builder();
|
||||
|
||||
// getNodes called to refresh accessibility focus
|
||||
final boolean forFocusEvent = params.getBoolean("forFocusEvent");
|
||||
final boolean forAccessibilityEvent = params.getBoolean("forAccessibilityEvent");
|
||||
final String selected = params.getString("selected");
|
||||
|
||||
for (int i = 0, count = ids.length(); i < count; i++) {
|
||||
final String id = ids.getString(i);
|
||||
@@ -231,7 +232,7 @@ public class InspectorSonarPlugin implements SonarPlugin {
|
||||
if (node == null) {
|
||||
|
||||
// some nodes may be null since we are searching through all current and previous known nodes
|
||||
if (forFocusEvent) {
|
||||
if (forAccessibilityEvent) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -243,11 +244,11 @@ public class InspectorSonarPlugin implements SonarPlugin {
|
||||
return;
|
||||
} else {
|
||||
|
||||
// only need to get the focused node in this case
|
||||
if (forFocusEvent) {
|
||||
if (node.getObject("extraInfo").getBoolean("focused")) {
|
||||
// always add currently selected node for live updates to the sidebar
|
||||
// also add focused node for updates
|
||||
if (forAccessibilityEvent) {
|
||||
if (id.equals(selected) || node.getObject("extraInfo").getBoolean("focused")) {
|
||||
result.put(node);
|
||||
break;
|
||||
}
|
||||
|
||||
// normal getNodes call, put any nodes in result
|
||||
|
||||
@@ -101,6 +101,12 @@ public class ApplicationDescriptor extends NodeDescriptor<ApplicationWrapper> {
|
||||
new SonarObject.Builder()
|
||||
.put("isFocus", false)
|
||||
.build());
|
||||
} else if (eventType == AccessibilityEvent.TYPE_VIEW_CLICKED) {
|
||||
mConnection.send("axFocusEvent",
|
||||
new SonarObject.Builder()
|
||||
.put("isFocus", false)
|
||||
.put("isClick", true)
|
||||
.build());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user