优化布局分析显示
This commit is contained in:
@@ -61,8 +61,7 @@ class LayoutInspector(private val mContext: Context) {
|
||||
}
|
||||
|
||||
private fun refreshChildList(root: AccessibilityNodeInfo?) {
|
||||
if (root == null)
|
||||
return
|
||||
if (root == null) return
|
||||
root.refresh()
|
||||
val childCount = root.childCount
|
||||
for (i in 0 until childCount) {
|
||||
|
||||
@@ -1,31 +1,24 @@
|
||||
package org.autojs.autojs.core.ui;
|
||||
package org.autojs.autojs.core.ui
|
||||
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.autojs.autojs.core.ui.inflater.util.Ids;
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import org.autojs.autojs.core.ui.inflater.util.Ids
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/5/14.
|
||||
*/
|
||||
public class JsViewHelper {
|
||||
|
||||
@Nullable
|
||||
public static View findViewByStringId(View view, String id) {
|
||||
View result = view.findViewById(Ids.parse(id));
|
||||
if (result != null)
|
||||
return result;
|
||||
if (!(view instanceof ViewGroup group)) {
|
||||
return null;
|
||||
object JsViewHelper {
|
||||
@JvmStatic
|
||||
fun findViewByStringId(view: View, id: String?): View? {
|
||||
var result = view.findViewById<View>(Ids.parse(id))
|
||||
if (result != null) return result
|
||||
if (view !is ViewGroup) {
|
||||
return null
|
||||
}
|
||||
for (int i = 0; i < group.getChildCount(); i++) {
|
||||
result = findViewByStringId(group.getChildAt(i), id);
|
||||
if (result != null)
|
||||
return result;
|
||||
for (i in 0 until view.childCount) {
|
||||
result = findViewByStringId(view.getChildAt(i), id)
|
||||
if (result != null) return result
|
||||
}
|
||||
return null;
|
||||
return null
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.autojs.autojs.ui.floating.layoutinspector
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.graphics.Canvas
|
||||
import android.graphics.Color
|
||||
@@ -97,7 +98,7 @@ open class LayoutBoundsView : View {
|
||||
draw(canvas, child)
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
override fun onTouchEvent(event: MotionEvent): Boolean {
|
||||
if (mRootNode != null) {
|
||||
setSelectedNode(findNodeAt(mRootNode!!, event.rawX.toInt(), event.rawY.toInt()))
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.autojs.autojs.ui.floating.layoutinspector;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
@@ -18,12 +19,7 @@ import org.autojs.autojs.ui.widget.LevelBeamView;
|
||||
import org.autojs.autojs.util.ViewUtils;
|
||||
import org.autojs.autojs6.R;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import java.util.Stack;
|
||||
import java.util.*;
|
||||
|
||||
import pl.openrnd.multilevellistview.ItemInfo;
|
||||
import pl.openrnd.multilevellistview.MultiLevelListAdapter;
|
||||
@@ -186,7 +182,7 @@ public class LayoutHierarchyView extends MultiLevelListView {
|
||||
return found;
|
||||
}
|
||||
|
||||
private class ViewHolder {
|
||||
private static class ViewHolder {
|
||||
TextView nameView;
|
||||
TextView infoView;
|
||||
ImageView arrowView;
|
||||
@@ -220,6 +216,7 @@ public class LayoutHierarchyView extends MultiLevelListView {
|
||||
return mInitiallyExpandedNodes.contains((NodeInfo) object);
|
||||
}
|
||||
|
||||
@SuppressLint("InflateParams")
|
||||
@Override
|
||||
public View getViewForObject(Object object, View convertView, ItemInfo itemInfo) {
|
||||
NodeInfo nodeInfo = (NodeInfo) object;
|
||||
@@ -231,8 +228,8 @@ public class LayoutHierarchyView extends MultiLevelListView {
|
||||
} else {
|
||||
viewHolder = (ViewHolder) convertView.getTag();
|
||||
}
|
||||
|
||||
viewHolder.nameView.setText(simplifyClassName(nodeInfo.getClassName()));
|
||||
//对于id,desc,text,clickable,longClickable不为空的显示信息
|
||||
viewHolder.nameView.setText(extraInfo(nodeInfo));
|
||||
viewHolder.nodeInfo = nodeInfo;
|
||||
if (viewHolder.infoView.getVisibility() == VISIBLE)
|
||||
viewHolder.infoView.setText(getItemInfoDsc(itemInfo));
|
||||
@@ -266,6 +263,25 @@ public class LayoutHierarchyView extends MultiLevelListView {
|
||||
return s;
|
||||
}
|
||||
|
||||
private String extraInfo(NodeInfo nodeInfo) {
|
||||
String extra = simplifyClassName(nodeInfo.getClassName());
|
||||
ArrayList<String> info = new ArrayList<>();
|
||||
if (nodeInfo.getSimpleId() != null) {
|
||||
info.add("id=" + nodeInfo.getSimpleId());
|
||||
}
|
||||
if (!nodeInfo.getText().equals("")) {
|
||||
info.add("text=" + nodeInfo.getText());
|
||||
}
|
||||
if (nodeInfo.getDesc() != null) {
|
||||
info.add("desc=" + nodeInfo.getDesc());
|
||||
}
|
||||
//字符串拼接
|
||||
String others = String.join(", ", info);
|
||||
if (!others.isEmpty()) {
|
||||
return extra + " [" + others + "]";
|
||||
}
|
||||
return extra;
|
||||
}
|
||||
|
||||
private String getItemInfoDsc(ItemInfo itemInfo) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.autojs.autojs.ui.floating.layoutinspector
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
@@ -41,6 +42,7 @@ class NodeInfoView : RecyclerView {
|
||||
)
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
fun setNodeInfo(nodeInfo: NodeInfo) {
|
||||
for (i in FIELDS.indices) {
|
||||
try {
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
package org.autojs.autojs.ui.floating.layoutinspector;
|
||||
package org.autojs.autojs.ui.floating.layoutinspector
|
||||
|
||||
import org.autojs.autojs.core.accessibility.NodeInfo;
|
||||
import org.autojs.autojs.core.accessibility.NodeInfo
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/3/10.
|
||||
*/
|
||||
public interface OnNodeInfoSelectListener {
|
||||
|
||||
void onNodeSelect(NodeInfo info);
|
||||
|
||||
fun interface OnNodeInfoSelectListener {
|
||||
fun onNodeSelect(info: NodeInfo)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user