From 76163c796e4463781aa35833674d3ce48188e580 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=8A=A0=E8=84=9A=E6=9C=AC=E4=BA=BA?= <742374184@qq.com> Date: Wed, 12 Jul 2023 02:35:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B8=83=E5=B1=80=E5=88=86=E6=9E=90=E7=88=B6?= =?UTF-8?q?=E6=8E=A7=E4=BB=B6=E5=AD=97=E4=BD=93=E7=BA=A2=E8=89=B2=E9=AB=98?= =?UTF-8?q?=E4=BA=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../layoutinspector/LayoutHierarchyView.java | 37 +++++++++++++++++-- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/autojs/autojs/ui/floating/layoutinspector/LayoutHierarchyView.java b/app/src/main/java/org/autojs/autojs/ui/floating/layoutinspector/LayoutHierarchyView.java index 270e8aca..82b1c64f 100644 --- a/app/src/main/java/org/autojs/autojs/ui/floating/layoutinspector/LayoutHierarchyView.java +++ b/app/src/main/java/org/autojs/autojs/ui/floating/layoutinspector/LayoutHierarchyView.java @@ -36,7 +36,7 @@ public class LayoutHierarchyView extends MultiLevelListView { public interface OnItemLongClickListener { void onItemLongClick(View view, NodeInfo nodeInfo); } - + private final Map nodeMap = new LinkedHashMap<>(); private Adapter mAdapter; private OnItemLongClickListener mOnItemLongClickListener; private final AdapterView.OnItemLongClickListener mOnItemLongClickListenerProxy = new AdapterView.OnItemLongClickListener() { @@ -107,17 +107,41 @@ public class LayoutHierarchyView extends MultiLevelListView { } private void setClickedItem(View view, NodeInfo item) { - mClickedNodeInfo = item; if (mClickedView == null) { mOriginalBackground = view.getBackground(); } else { mClickedView.setBackground(mOriginalBackground); + drawListItem(mClickedNodeInfo, false); } view.setBackgroundColor(mClickedColor); + drawListItem(item, true); + mClickedNodeInfo = item; mClickedView = view; invalidate(); } + private void drawListItem(NodeInfo info, Boolean draw) { + ArrayList list = new ArrayList<>(); + NodeInfo currentInfo = info; + while (true) { + currentInfo = currentInfo.getParent(); + if (currentInfo == null) break; + ViewHolder vh = nodeMap.get(currentInfo); + list.add(vh); + } + //todo:选用能适应深色模式的字体颜色 + //fixme:列表滑动时listview数据错乱 + if (draw) { + for (ViewHolder vh : list) { + vh.nameView.setTextColor(Color.RED); // 设置字体颜色为红色 + } + } else { + for (ViewHolder vh : list) { + vh.nameView.setTextColor(Color.BLACK); // 设置字体颜色为红色 + } + } + } + private void initPaint() { mPaint = new Paint(); mPaint.setColor(Color.DKGRAY); @@ -228,7 +252,8 @@ public class LayoutHierarchyView extends MultiLevelListView { } else { viewHolder = (ViewHolder) convertView.getTag(); } - //对于id,desc,text,clickable,longClickable不为空的显示信息 + nodeMap.put(nodeInfo,viewHolder); + //对于id,desc,text,clickable,longClickable不为空的显示额外信息 viewHolder.nameView.setText(extraInfo(nodeInfo)); viewHolder.nodeInfo = nodeInfo; if (viewHolder.infoView.getVisibility() == VISIBLE) @@ -275,6 +300,12 @@ public class LayoutHierarchyView extends MultiLevelListView { if (nodeInfo.getDesc() != null) { info.add("desc=" + nodeInfo.getDesc()); } + if (nodeInfo.getClickable()) { + info.add("clickable"); + } + if (nodeInfo.getLongClickable()) { + info.add("longClickable"); + } //字符串拼接 String others = String.join(", ", info); if (!others.isEmpty()) {