From 37943779846c99360fd0f0a44336c841d6c7fb13 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 11:29:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B8=83=E5=B1=80=E5=88=86=E6=9E=90=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=A4=9A=E9=80=89=E5=8A=9F=E8=83=BD=EF=BC=88=E6=9C=AA?= =?UTF-8?q?=E5=AE=8C=E5=96=84=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../autojs/codegeneration/ReadOnlyUiObject.java | 2 +- .../autojs/autojs/core/accessibility/NodeInfo.kt | 10 ++++++---- .../autojs/ui/floating/LayoutFloatyWindow.kt | 10 +++++++++- .../layoutinspector/LayoutHierarchyView.java | 4 ++-- .../ui/floating/layoutinspector/NodeInfoView.kt | 16 +++++++++++++--- app/src/main/res/layout/node_info_view_item.xml | 5 +++++ version.properties | 6 +++--- 7 files changed, 39 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/org/autojs/autojs/codegeneration/ReadOnlyUiObject.java b/app/src/main/java/org/autojs/autojs/codegeneration/ReadOnlyUiObject.java index 47b999f8..5634eadb 100644 --- a/app/src/main/java/org/autojs/autojs/codegeneration/ReadOnlyUiObject.java +++ b/app/src/main/java/org/autojs/autojs/codegeneration/ReadOnlyUiObject.java @@ -70,7 +70,7 @@ public class ReadOnlyUiObject extends UiObject { @Override public String id() { - return mNodeInfo.getSimpleId(); + return mNodeInfo.getId(); } @Override diff --git a/app/src/main/java/org/autojs/autojs/core/accessibility/NodeInfo.kt b/app/src/main/java/org/autojs/autojs/core/accessibility/NodeInfo.kt index 3aea3cb7..8f1b70bf 100644 --- a/app/src/main/java/org/autojs/autojs/core/accessibility/NodeInfo.kt +++ b/app/src/main/java/org/autojs/autojs/core/accessibility/NodeInfo.kt @@ -1,5 +1,6 @@ package org.autojs.autojs.core.accessibility +import android.annotation.SuppressLint import android.content.Context import android.content.pm.PackageManager import android.content.res.Resources @@ -17,7 +18,7 @@ import java.util.HashMap * Modified by SuperMonster003 as of Jun 17, 2022. */ -@Suppress("unused") +@Suppress("unused", "MemberVisibilityCanBePrivate") @Keep class NodeInfo(private val resources: Resources?, private val node: UiObject, var parent: NodeInfo?) { @@ -27,8 +28,8 @@ class NodeInfo(private val resources: Resources?, private val node: UiObject, va val bounds = boundsToString(boundsInScreen) val children = ArrayList() - var fullId: String? = node.viewIdResourceName - val simpleId = node.simpleId() + val fullId = node.fullId() + val id = node.simpleId() val desc = node.desc() val text = node.text() val className = node.className() @@ -59,6 +60,7 @@ class NodeInfo(private val resources: Resources?, private val node: UiObject, va val childCount = node.childCount() val actionNames = node.actionNames() + @SuppressLint("DiscouragedApi") val idHex = takeIf { resources != null && packageName != null && fullId != null }?.let { "0x${Integer.toHexString(resources!!.getIdentifier(fullId, null, null))}" } @@ -68,7 +70,7 @@ class NodeInfo(private val resources: Resources?, private val node: UiObject, va "childCount=${children.size}, " + "boundsInScreen=$boundsInScreen, " + "boundsInParent=$boundsInParent, " + - "id='$simpleId', " + + "id='$id', " + "desc='$desc', " + "packageName='$packageName', " + "text='$text', " + diff --git a/app/src/main/java/org/autojs/autojs/ui/floating/LayoutFloatyWindow.kt b/app/src/main/java/org/autojs/autojs/ui/floating/LayoutFloatyWindow.kt index 0f4af14c..7e23a25c 100644 --- a/app/src/main/java/org/autojs/autojs/ui/floating/LayoutFloatyWindow.kt +++ b/app/src/main/java/org/autojs/autojs/ui/floating/LayoutFloatyWindow.kt @@ -13,9 +13,11 @@ import org.autojs.autojs.ui.floating.layoutinspector.LayoutBoundsFloatyWindow import org.autojs.autojs.ui.floating.layoutinspector.LayoutHierarchyFloatyWindow import org.autojs.autojs.ui.floating.layoutinspector.NodeInfoView import org.autojs.autojs.ui.widget.BubblePopupMenu +import org.autojs.autojs.util.ClipboardUtils +import org.autojs.autojs.util.ViewUtils import org.autojs.autojs6.R -abstract class LayoutFloatyWindow(private val rootNode: NodeInfo?, private val context: Context, private val isServiceRelied: Boolean) : FullScreenFloatyWindow() { +abstract class LayoutFloatyWindow(private val rootNode: NodeInfo?, private val context: Context, private val isServiceRelied: Boolean) : FullScreenFloatyWindow(){ private lateinit var mServiceContext: Context private lateinit var mActions: LinkedHashMap @@ -27,6 +29,12 @@ abstract class LayoutFloatyWindow(private val rootNode: NodeInfo?, private val c private val mNodeInfoDialog by lazy { AppLevelThemeDialogBuilder(mServiceContext) .customView(mNodeInfoView, false) + .positiveText("生成") + .onPositive { _, _ -> + ViewUtils.showToast(context, "TODO") + val selector = mNodeInfoView.getCheckedDate().joinToString(".") + if (selector.isNotEmpty()) ClipboardUtils.setClip(context, selector) + } .build() .also { it.window!!.setType(FloatyWindowManger.getWindowType()) } } 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 82b1c64f..8e6790ae 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 @@ -291,8 +291,8 @@ public class LayoutHierarchyView extends MultiLevelListView { private String extraInfo(NodeInfo nodeInfo) { String extra = simplifyClassName(nodeInfo.getClassName()); ArrayList info = new ArrayList<>(); - if (nodeInfo.getSimpleId() != null) { - info.add("id=" + nodeInfo.getSimpleId()); + if (nodeInfo.getId() != null) { + info.add("id=" + nodeInfo.getId()); } if (!nodeInfo.getText().equals("")) { info.add("text=" + nodeInfo.getText()); diff --git a/app/src/main/java/org/autojs/autojs/ui/floating/layoutinspector/NodeInfoView.kt b/app/src/main/java/org/autojs/autojs/ui/floating/layoutinspector/NodeInfoView.kt index 4ef7a072..a08702c0 100644 --- a/app/src/main/java/org/autojs/autojs/ui/floating/layoutinspector/NodeInfoView.kt +++ b/app/src/main/java/org/autojs/autojs/ui/floating/layoutinspector/NodeInfoView.kt @@ -6,6 +6,7 @@ import android.util.AttributeSet import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import android.widget.CheckBox import android.widget.TextView import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView @@ -21,7 +22,7 @@ import java.lang.reflect.Field * Modified by SuperMonster003 as of Dec 1, 2021. */ class NodeInfoView : RecyclerView { - + //todo:调整数据结构,对话框关闭后根据已勾选的属性,生成选择器 private val data = Array(FIELDS.size + 1) { Array(2) { "" } } constructor(context: Context) : super(context) @@ -73,6 +74,14 @@ class NodeInfoView : RecyclerView { } } + fun getCheckedDate(): Array { + //todo:数据增加checked属性,区分已选中项目 + val checkedArr = data.filter { it[0] == "id" || it[0] == "text" } + return Array(checkedArr.size) { + dataToFx(checkedArr[it]) + } + } + private inner class Adapter : RecyclerView.Adapter() { val mViewTypeHeader = 0 @@ -86,6 +95,7 @@ class NodeInfoView : RecyclerView { override fun onBindViewHolder(holder: ViewHolder, position: Int) { holder.apply { data[position].let { + //attrChecked.isChecked = false attrName.text = it[0] attrValue.text = it[1] } @@ -99,7 +109,7 @@ class NodeInfoView : RecyclerView { } internal inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { - + //val attrChecked: CheckBox = itemView.findViewById(R.id.generate) val attrName: TextView = itemView.findViewById(R.id.name) val attrValue: TextView = itemView.findViewById(R.id.value) @@ -132,7 +142,7 @@ class NodeInfoView : RecyclerView { private val FIELD_NAMES = arrayOf( // Common - "packageName", "simpleId", "fullId", "idHex", + "packageName", "id", "fullId", "idHex", "desc", "text", "bounds", "className", "clickable", "longClickable", "scrollable", diff --git a/app/src/main/res/layout/node_info_view_item.xml b/app/src/main/res/layout/node_info_view_item.xml index 06370ace..6280f231 100644 --- a/app/src/main/res/layout/node_info_view_item.xml +++ b/app/src/main/res/layout/node_info_view_item.xml @@ -10,6 +10,11 @@ android:orientation="horizontal" android:padding="8dp"> +