布局分析增加多选功能(未完善)
This commit is contained in:
@@ -70,7 +70,7 @@ public class ReadOnlyUiObject extends UiObject {
|
||||
|
||||
@Override
|
||||
public String id() {
|
||||
return mNodeInfo.getSimpleId();
|
||||
return mNodeInfo.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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<NodeInfo>()
|
||||
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', " +
|
||||
|
||||
@@ -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<Int, Runnable>
|
||||
@@ -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()) }
|
||||
}
|
||||
|
||||
@@ -291,8 +291,8 @@ public class LayoutHierarchyView extends MultiLevelListView {
|
||||
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.getId() != null) {
|
||||
info.add("id=" + nodeInfo.getId());
|
||||
}
|
||||
if (!nodeInfo.getText().equals("")) {
|
||||
info.add("text=" + nodeInfo.getText());
|
||||
|
||||
@@ -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<String> {
|
||||
//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<ViewHolder>() {
|
||||
|
||||
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",
|
||||
|
||||
@@ -10,6 +10,11 @@
|
||||
android:orientation="horizontal"
|
||||
android:padding="8dp">
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/generate"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
tools:ignore="TouchTargetSizeCheck" />
|
||||
<TextView
|
||||
android:id="@+id/name"
|
||||
android:layout_width="0dp"
|
||||
|
||||
Reference in New Issue
Block a user