/* * "enabled" => true, "visible" => true, "children" => [], "label" => nil, "rect" => { "center_y" => 158.5, "center_x" => 300.0, "height" => 25, "y" => 146, "width" => 600, "x" => 0 }, "type" => "android.widget.TextView", "id" => "FacebookTextView", "el" => nil, "name" => "", "action" => nil, "value" => "", "path" => [ [0] 0, [1] 0, [2] 2, [3] 0, [4] 2 ], "hit-point" => { "y" => 158.5, "x" => 300.0 }, "entry_types" => [ [0] "0" ] */ @SuppressWarnings({"rawtypes", "unchecked"}) public static Map<?, ?> serializeViewToDump(Object viewOrMap) { if (viewOrMap == null) { return null; } if (viewOrMap instanceof Map) { Map map = (Map) viewOrMap; map.put("el", map); Map rect = (Map) map.get("rect"); Map hitPoint = extractHitPointFromRect(rect); map.put("hit-point", hitPoint); map.put("enabled", true); map.put("visible", true); map.put("value", null); map.put("type", "dom"); map.put("name", null); map.put("label", null); map.put("children", Collections.EMPTY_LIST); String html = (String) map.get("html"); String nodeName = (String) map.get("nodeName"); if (nodeName != null && nodeName.toLowerCase().equals("input")) { String domType = extractDomType(html); if (isDomPasswordType(domType)) { map.put("entry_types", Collections.singletonList("password")); } else if (isDomTextType(domType)) { map.put("entry_types", Collections.singletonList("text")); } else { map.put("entry_types", Collections.emptyList()); } map.put("value", extractAttribute(html, "value")); map.put("type", "dom"); map.put("name", extractAttribute(html, "name")); map.put("label", extractAttribute(html, "title")); } return map; } else { Map m = new HashMap(); View view = (View) viewOrMap; m.put("id", getId(view)); m.put("el", view); Map rect = ViewMapper.getRectForView(view); Map hitPoint = extractHitPointFromRect(rect); m.put("rect", rect); m.put("hit-point", hitPoint); m.put("action", actionForView(view)); m.put("enabled", view.isEnabled()); m.put("visible", isVisible(view)); m.put("entry_types", elementEntryTypes(view)); m.put("value", extractValueFromView(view)); m.put("type", ViewMapper.getClassNameForView(view)); m.put("name", getNameForView(view)); m.put("label", ViewMapper.getContentDescriptionForView(view)); return m; } }
public static String getTag(View view) { return ViewMapper.getTagForView(view); }