Enable import all the nodes for android

Summary: Enables Import and Export for all the nodes for android. Also search and Accessibility feature works

Reviewed By: danielbuechele

Differential Revision: D14406016

fbshipit-source-id: 8976db66d1ca91e98c52983a31ea584764bde0f6
This commit is contained in:
Pritesh Nandgaonkar
2019-03-12 07:05:03 -07:00
committed by Facebook Github Bot
parent 063d8aa416
commit 1c8fffa20b
5 changed files with 53 additions and 11 deletions

View File

@@ -133,6 +133,7 @@ public class InspectorFlipperPlugin implements FlipperPlugin {
}
});
connection.receive("getRoot", mGetRoot);
connection.receive("getAllNodes", mGetAllNodes);
connection.receive("getNodes", mGetNodes);
connection.receive("setData", mSetData);
connection.receive("setHighlighted", mSetHighlighted);
@@ -173,7 +174,7 @@ public class InspectorFlipperPlugin implements FlipperPlugin {
@Override
public boolean runInBackground() {
return false;
return true;
}
final FlipperReceiver mShouldShowLithoAccessibilitySettings =
@@ -207,6 +208,31 @@ public class InspectorFlipperPlugin implements FlipperPlugin {
responder.success(getAXNode(trackObject(mApplication)));
}
};
final FlipperReceiver mGetAllNodes =
new MainThreadFlipperReceiver(mConnection) {
@Override
public void onReceiveOnMainThread(
final FlipperObject params, final FlipperResponder responder) throws Exception {
final FlipperObject.Builder result = new FlipperObject.Builder();
final FlipperObject.Builder AXResults = new FlipperObject.Builder();
String rootID = trackObject(mApplication);
populateAllAXNodes(rootID, AXResults);
populateAllNodes(rootID, result);
final FlipperObject output =
new FlipperObject.Builder()
.put(
"allNodes",
new FlipperObject.Builder()
.put("elements", result.build())
.put("AXelements", AXResults.build())
.put("rootElement", rootID)
.put("rootAXElement", rootID)
.build())
.build();
responder.success(output);
}
};
final FlipperReceiver mGetNodes =
new MainThreadFlipperReceiver(mConnection) {
@@ -235,6 +261,24 @@ public class InspectorFlipperPlugin implements FlipperPlugin {
}
};
void populateAllNodes(String rootNode, FlipperObject.Builder builder) throws Exception {
FlipperObject object = getNode(rootNode);
builder.put(rootNode, object);
FlipperArray children = object.getArray("children");
for (int i = 0, count = children.length(); i < count; ++i) {
populateAllNodes(children.getString(i), builder);
}
}
void populateAllAXNodes(String rootNode, FlipperObject.Builder builder) throws Exception {
FlipperObject object = getAXNode(rootNode);
builder.put(rootNode, object);
FlipperArray children = object.getArray("children");
for (int i = 0, count = children.length(); i < count; ++i) {
populateAllAXNodes(children.getString(i), builder);
}
}
final FlipperReceiver mGetAXNodes =
new MainThreadFlipperReceiver(mConnection) {
@Override