6.7.0 - Alpha14 - 修复布局分析页面生成代码时对于集合控件可能生成失败的问题 (试修) (issue #328)
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"$data": {
|
"$data": {
|
||||||
"v6.7.0": {
|
"v6.7.0": {
|
||||||
"released_date": "2026/01/11",
|
"released_date": "2026/01/12",
|
||||||
"feature": [
|
"feature": [
|
||||||
"插件中心功能, 支持插件的安装/卸载/更新等操作 (入口: 主页抽屉按钮)",
|
"插件中心功能, 支持插件的安装/卸载/更新等操作 (入口: 主页抽屉按钮)",
|
||||||
"cvt 模块, 用于数据单位转换 (参阅 项目文档 > [单位转换](https://docs.autojs6.com/#/cvt))",
|
"cvt 模块, 用于数据单位转换 (参阅 项目文档 > [单位转换](https://docs.autojs6.com/#/cvt))",
|
||||||
@@ -87,6 +87,7 @@
|
|||||||
"客户端模式连接时, 旋转屏幕及切换语言等触发 Activity 重建的操作导致 AutoJs6 总是重建连接的问题",
|
"客户端模式连接时, 旋转屏幕及切换语言等触发 Activity 重建的操作导致 AutoJs6 总是重建连接的问题",
|
||||||
"服务端模式连接时, 旋转屏幕及切换语言等触发 Activity 重建的操作导致 VSCode 控制台无法输出日志的问题 _[`issue #385`](http://issues.autojs6.com/385)_",
|
"服务端模式连接时, 旋转屏幕及切换语言等触发 Activity 重建的操作导致 VSCode 控制台无法输出日志的问题 _[`issue #385`](http://issues.autojs6.com/385)_",
|
||||||
"连接 VSCode 插件时, 多种方式同时连接可能导致日志打印数量成倍增加的问题",
|
"连接 VSCode 插件时, 多种方式同时连接可能导致日志打印数量成倍增加的问题",
|
||||||
|
"布局分析页面生成代码时对于集合控件可能生成失败的问题 (试修) _[`issue #328`](http://issues.autojs6.com/328)_",
|
||||||
"构建工具启用 isCleanup[Paddle/Rapid]Ocr 配置选项时无法正常完成 Rebuild Project 任务的问题"
|
"构建工具启用 isCleanup[Paddle/Rapid]Ocr 配置选项时无法正常完成 Rebuild Project 任务的问题"
|
||||||
],
|
],
|
||||||
"improvement": [
|
"improvement": [
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
package org.autojs.autojs.codegeneration;
|
package org.autojs.autojs.codegeneration;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
|
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
|
||||||
|
|
||||||
import org.autojs.autojs.core.accessibility.UiSelector;
|
|
||||||
import org.autojs.autojs.core.accessibility.NodeInfo;
|
import org.autojs.autojs.core.accessibility.NodeInfo;
|
||||||
|
import org.autojs.autojs.core.accessibility.UiSelector;
|
||||||
import org.autojs.autojs.core.automator.UiObject;
|
import org.autojs.autojs.core.automator.UiObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Stardust on Dec 7, 2017.
|
* Created by Stardust on Dec 7, 2017.
|
||||||
|
* Modified by SuperMonster003 as of Jan 12, 2026.
|
||||||
*/
|
*/
|
||||||
public class CodeGenerator {
|
public class CodeGenerator {
|
||||||
|
|
||||||
@@ -56,7 +57,14 @@ public class CodeGenerator {
|
|||||||
public String generateCode() {
|
public String generateCode() {
|
||||||
UiObject collection = getCollectionParent(mTarget);
|
UiObject collection = getCollectionParent(mTarget);
|
||||||
if (collection != null) {
|
if (collection != null) {
|
||||||
return generateCodeForCollectionChild(collection, mTarget);
|
// @Hint by SuperMonster003 on Jan 12, 2026.
|
||||||
|
// ! Collection-based generation may fail in some apps due to unstable accessibility trees.
|
||||||
|
// ! zh-CN: 基于集合控件的生成在某些应用中可能因无障碍树不稳定而失败.
|
||||||
|
// # return generateCodeForCollectionChild(collection, mTarget);
|
||||||
|
String collectionChildCode = generateCodeForCollectionChild(collection, mTarget);
|
||||||
|
if (collectionChildCode != null) {
|
||||||
|
return collectionChildCode;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UiSelectorGenerator generator = new UiSelectorGenerator(mRoot, mTarget);
|
UiSelectorGenerator generator = new UiSelectorGenerator(mRoot, mTarget);
|
||||||
@@ -65,8 +73,9 @@ public class CodeGenerator {
|
|||||||
generator.setUsingId(mUsingId);
|
generator.setUsingId(mUsingId);
|
||||||
generator.setUsingText(mUsingText);
|
generator.setUsingText(mUsingText);
|
||||||
String selector = generateCode(generator, mRoot, mTarget, 2, 2, true);
|
String selector = generateCode(generator, mRoot, mTarget, 2, 2, true);
|
||||||
if (selector == null)
|
if (selector == null) {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
return generateAction(selector);
|
return generateAction(selector);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,8 +94,9 @@ public class CodeGenerator {
|
|||||||
if (maxChildrenLevel > 0) {
|
if (maxChildrenLevel > 0) {
|
||||||
for (int i = 0; i < target.childCount(); i++) {
|
for (int i = 0; i < target.childCount(); i++) {
|
||||||
UiObject child = target.child(i);
|
UiObject child = target.child(i);
|
||||||
if (child == null)
|
if (child == null) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
String childCode = generateCode(root, child, 0, maxChildrenLevel - 1);
|
String childCode = generateCode(root, child, 0, maxChildrenLevel - 1);
|
||||||
if (childCode != null) {
|
if (childCode != null) {
|
||||||
return childCode + ".parent()";
|
return childCode + ".parent()";
|
||||||
@@ -116,8 +126,9 @@ public class CodeGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String generateAction(String selector) {
|
private String generateAction(String selector) {
|
||||||
if (selector == null)
|
if (selector == null) {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
if (mSearchMode == WAIT_FOR) {
|
if (mSearchMode == WAIT_FOR) {
|
||||||
return selector + ".waitFor()";
|
return selector + ".waitFor()";
|
||||||
}
|
}
|
||||||
@@ -145,30 +156,38 @@ public class CodeGenerator {
|
|||||||
|
|
||||||
private String generateCodeForCollectionChild(UiObject collection, UiObject target) {
|
private String generateCodeForCollectionChild(UiObject collection, UiObject target) {
|
||||||
UiObject parent = target.parent();
|
UiObject parent = target.parent();
|
||||||
if (parent == null)
|
if (parent == null) {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
UiObject collectionItem = null;
|
UiObject collectionItem = null;
|
||||||
for (int i = 0; i < collection.childCount(); i++) {
|
for (int i = 0; i < collection.childCount(); i++) {
|
||||||
if (inherits(collection.child(i), target)) {
|
UiObject child = collection.child(i);
|
||||||
collectionItem = collection.child(i);
|
if (child == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (inherits(child, target)) {
|
||||||
|
collectionItem = child;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (collectionItem == null)
|
if (collectionItem == null) {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
String collectionCode = generateCode(mRoot, collection, 2, 0);
|
String collectionCode = generateCode(mRoot, collection, 2, 0);
|
||||||
if (collectionCode == null)
|
if (collectionCode == null) {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
String itemCode = generateCode(collectionItem, target, 1, 2, false);
|
String itemCode = generateCode(collectionItem, target, 1, 2, false);
|
||||||
if (itemCode == null)
|
if (itemCode == null) {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
return collectionCode + ".children().forEach(child => {\n"
|
return collectionCode + ".children().forEach(child => {\n"
|
||||||
+ "var target = child.findOne(" + itemCode + ");\n"
|
+ "var target = child.findOne(" + itemCode + ");\n"
|
||||||
+ "target." + getAction() + ";\n"
|
+ "target." + getAction() + ";\n"
|
||||||
+ "});";
|
+ "});";
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean inherits(UiObject root, UiObject target) {
|
private boolean inherits(@NonNull UiObject root, UiObject target) {
|
||||||
for (int i = 0; i < root.childCount(); i++) {
|
for (int i = 0; i < root.childCount(); i++) {
|
||||||
UiObject child = root.child(i);
|
UiObject child = root.child(i);
|
||||||
if (child != null) {
|
if (child != null) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#Sun Jan 11 23:41:15 CST 2026
|
#Mon Jan 12 17:10:46 CST 2026
|
||||||
BUILD_TIME=1768146075102
|
BUILD_TIME=1768209046850
|
||||||
COMPILE_SDK_VERSION=36
|
COMPILE_SDK_VERSION=36
|
||||||
IMAGE_QUANT_CMAKE_VERSION=3.22.1
|
IMAGE_QUANT_CMAKE_VERSION=3.22.1
|
||||||
IMAGE_QUANT_NDK_VERSION=26.1.10909125
|
IMAGE_QUANT_NDK_VERSION=26.1.10909125
|
||||||
@@ -27,6 +27,6 @@ RAPID_OCR_OPENCV_MOBILE_LABEL_VERSION=13
|
|||||||
RAPID_OCR_OPENCV_MOBILE_VERSION=4.5.3
|
RAPID_OCR_OPENCV_MOBILE_VERSION=4.5.3
|
||||||
TARGET_SDK_VERSION=36
|
TARGET_SDK_VERSION=36
|
||||||
TARGET_SDK_VERSION_INRT=29
|
TARGET_SDK_VERSION_INRT=29
|
||||||
VERSION_BUILD=3597
|
VERSION_BUILD=3598
|
||||||
VERSION_NAME=6.7.0 Alpha14
|
VERSION_NAME=6.7.0 Alpha14
|
||||||
VSCODE_EXT_REQUIRED_VERSION=1.0.13
|
VSCODE_EXT_REQUIRED_VERSION=1.0.13
|
||||||
|
|||||||
Reference in New Issue
Block a user