From 975dae971bbf245b1e34a0d2667340b05c704d25 Mon Sep 17 00:00:00 2001 From: SuperMonster003 Date: Wed, 19 Nov 2025 14:01:31 +0800 Subject: [PATCH] =?UTF-8?q?6.7.0=20-=20Alpha11=20-=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E7=AE=A1=E7=90=86=E5=99=A8=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E6=96=87=E4=BB=B6=E5=A4=B9=E5=90=8E=20UI=20?= =?UTF-8?q?=E6=9C=AA=E8=83=BD=E8=87=AA=E5=8A=A8=E5=88=B7=E6=96=B0=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .changelog/lang_zh-Hans.json | 3 ++- .../autojs/inrt/launch/AssetsProjectLauncher.kt | 3 +-- .../model/explorer/ExplorerProjectPage.java | 5 +++++ .../autojs/autojs/project/ProjectConfig.java | 17 ++++++++++++++--- .../autojs/ui/common/ScriptOperations.java | 13 +++++++++---- .../ui/explorer/ExplorerProjectToolbar.java | 5 +++-- .../autojs/ui/viewmodel/ExplorerItemManager.kt | 2 +- 7 files changed, 35 insertions(+), 13 deletions(-) diff --git a/.changelog/lang_zh-Hans.json b/.changelog/lang_zh-Hans.json index f35ee96b..a8c73511 100644 --- a/.changelog/lang_zh-Hans.json +++ b/.changelog/lang_zh-Hans.json @@ -47,7 +47,7 @@ "images 部分相关方法可能引发内存泄露的问题 _[`issue #372`](http://issues.autojs6.com/372)_", "Android 10 UiObject#child 方法可能出现 ArrayIndexOutOfBoundsException 异常的问题 _[`issue #416`](http://issues.autojs6.com/416)_", "运行项目时 project.json 配置参数无法正常解析的问题", - "修复项目配置文件中构建版本号或构建时间出现较大数字时可能导致应用崩溃的问题", + "项目配置文件中构建版本号或构建时间出现较大数字时可能导致应用崩溃的问题", "频繁获取或重建 ImageReader 时可能因缓冲区暂无可用帧导致应用崩溃的问题", "输入事件观察器 InputEventObserver 可能导致应用启动时明显卡顿的问题", "打包应用无法正常使用 Paddle OCR 与 Rapid OCR 功能的问题", @@ -55,6 +55,7 @@ "部分设备无法正常初始化 MLKit Google OCR 的问题 (试修) _[`issue #8`](http://issues.autojs6.com/8#issuecomment-3117061768)_", "ErrorDialogActivity 可能无法正常启动或短时间自动消失的问题 _[`issue #414`](http://issues.autojs6.com/414)_ _[`issue #340`](http://issues.autojs6.com/340#issuecomment-2973485826)_", "崩溃报告页面复制详细信息功能失效的问题", + "文件管理器删除项目文件夹后 UI 未能自动刷新的问题", "APK 文件类型信息对话框可能无法获取应用名称及 SDK 信息的问题", "构建工具启用 isCleanup[Paddle/Rapid]Ocr 配置选项时无法正常完成 Rebuild Project 任务的问题" ], diff --git a/app/src/main/java/org/autojs/autojs/inrt/launch/AssetsProjectLauncher.kt b/app/src/main/java/org/autojs/autojs/inrt/launch/AssetsProjectLauncher.kt index 28f07fa4..674ead30 100644 --- a/app/src/main/java/org/autojs/autojs/inrt/launch/AssetsProjectLauncher.kt +++ b/app/src/main/java/org/autojs/autojs/inrt/launch/AssetsProjectLauncher.kt @@ -77,8 +77,7 @@ open class AssetsProjectLauncher(private val mAssetsProjectDir: String, private } private fun prepare() { - val projectConfigPath = PFiles.join(mProjectDir, ProjectConfig.CONFIG_FILE_NAME) - val projectConfig = ProjectConfig.fromFile(projectConfigPath) + val projectConfig = ProjectConfig.fromProjectDir(mProjectDir) if (projectConfig != null && TextUtils.equals(projectConfig.buildInfo.buildId, mProjectConfig.buildInfo.buildId) ) { diff --git a/app/src/main/java/org/autojs/autojs/model/explorer/ExplorerProjectPage.java b/app/src/main/java/org/autojs/autojs/model/explorer/ExplorerProjectPage.java index e4f2e8ab..05eec336 100644 --- a/app/src/main/java/org/autojs/autojs/model/explorer/ExplorerProjectPage.java +++ b/app/src/main/java/org/autojs/autojs/model/explorer/ExplorerProjectPage.java @@ -8,6 +8,11 @@ import java.io.File; public class ExplorerProjectPage extends ExplorerDirPage { private final ProjectConfig mProjectConfig; + public ExplorerProjectPage(PFile file, ExplorerPage parent) { + super(file, parent); + mProjectConfig = ProjectConfig.fromFile(file); + } + public ExplorerProjectPage(PFile file, ExplorerPage parent, ProjectConfig projectConfig) { super(file, parent); mProjectConfig = projectConfig; diff --git a/app/src/main/java/org/autojs/autojs/project/ProjectConfig.java b/app/src/main/java/org/autojs/autojs/project/ProjectConfig.java index 4a30db9d..cbb84097 100644 --- a/app/src/main/java/org/autojs/autojs/project/ProjectConfig.java +++ b/app/src/main/java/org/autojs/autojs/project/ProjectConfig.java @@ -199,7 +199,11 @@ public class ProjectConfig { } @Nullable - public static ProjectConfig fromFile(String path) { + public static ProjectConfig fromFile(File file) { + return fromFilePath(file.getPath()); + } + + public static ProjectConfig fromFilePath(String path) { String fileContents = null; try { fileContents = PFiles.read(path); @@ -369,14 +373,21 @@ public class ProjectConfig { // ! zh-CN: 无论 project.json 是否包含必要信息或是否可以正常解析, 都认为是一个有效项目. // ! // # return fromProjectDir(page.getPath()) != null; - String path = page.getPath(); + return isProject(page.getPath()); + } + + public static boolean isProject(File file) { + return isProject(file.getPath()); + } + + public static boolean isProject(String path) { String pathname = configFileOfDir(path); return new File(pathname).exists(); } @Nullable public static ProjectConfig fromProjectDir(String path) { - return fromFile(configFileOfDir(path)); + return fromFilePath(configFileOfDir(path)); } public static String configFileOfDir(String projectDir) { diff --git a/app/src/main/java/org/autojs/autojs/ui/common/ScriptOperations.java b/app/src/main/java/org/autojs/autojs/ui/common/ScriptOperations.java index 526a5f14..3a0288d0 100644 --- a/app/src/main/java/org/autojs/autojs/ui/common/ScriptOperations.java +++ b/app/src/main/java/org/autojs/autojs/ui/common/ScriptOperations.java @@ -27,6 +27,7 @@ import org.autojs.autojs.model.explorer.Explorer; import org.autojs.autojs.model.explorer.ExplorerDirPage; import org.autojs.autojs.model.explorer.ExplorerFileItem; import org.autojs.autojs.model.explorer.ExplorerPage; +import org.autojs.autojs.model.explorer.ExplorerProjectPage; import org.autojs.autojs.model.explorer.Explorers; import org.autojs.autojs.model.sample.SampleFile; import org.autojs.autojs.model.script.ScriptFile; @@ -35,6 +36,7 @@ import org.autojs.autojs.network.download.DownloadManager; import org.autojs.autojs.pio.PFile; import org.autojs.autojs.pio.PFiles; import org.autojs.autojs.pio.UncheckedIOException; +import org.autojs.autojs.project.ProjectConfig; import org.autojs.autojs.storage.file.TmpScriptFiles; import org.autojs.autojs.ui.filechooser.FileChooserDialogBuilder; import org.autojs.autojs.ui.shortcut.ShortcutCreateActivity; @@ -421,13 +423,14 @@ public class ScriptOperations { public void deleteWithoutConfirm(final ScriptFile scriptFile) { boolean isDir = scriptFile.isDirectory(); + boolean isProject = ProjectConfig.isProject(scriptFile); Observable.fromPublisher((Publisher) s -> s.onNext(PFiles.deleteRecursively(scriptFile))) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(deleted -> { if (deleted) { showMessage(R.string.text_already_deleted); - notifyFileRemoved(isDir, scriptFile); + notifyFileRemoved(isProject, isDir, scriptFile); } else { showMessage(R.string.text_failed_to_delete); } @@ -440,8 +443,10 @@ public class ScriptOperations { showMessage(R.string.text_done); } - private void notifyFileRemoved(boolean isDir, ScriptFile scriptFile) { - if (isDir) { + private void notifyFileRemoved(boolean isProject, boolean isDir, ScriptFile scriptFile) { + if (isProject) { + mExplorer.notifyItemRemoved(new ExplorerProjectPage(scriptFile, mExplorerPage)); + } else if (isDir) { mExplorer.notifyItemRemoved(new ExplorerDirPage(scriptFile, mExplorerPage)); } else { mExplorer.notifyItemRemoved(new ExplorerFileItem(scriptFile, mExplorerPage)); @@ -504,8 +509,8 @@ public class ScriptOperations { private class InputCallback implements MaterialDialog.InputCallback { private final String mExcluded; - private boolean mIsFirstTextChanged = true; private final String mExtension; + private boolean mIsFirstTextChanged = true; InputCallback(@Nullable String ext, @Nullable String excluded) { mExtension = ext == null ? null : "." + ext; diff --git a/app/src/main/java/org/autojs/autojs/ui/explorer/ExplorerProjectToolbar.java b/app/src/main/java/org/autojs/autojs/ui/explorer/ExplorerProjectToolbar.java index 4172037e..14d27ac0 100644 --- a/app/src/main/java/org/autojs/autojs/ui/explorer/ExplorerProjectToolbar.java +++ b/app/src/main/java/org/autojs/autojs/ui/explorer/ExplorerProjectToolbar.java @@ -124,8 +124,9 @@ public class ExplorerProjectToolbar extends CardView { return; } ExplorerItem item = event.getItem(); - if ((event.getAction() == ExplorerChangeEvent.ALL) - || (item != null && mDirectory.getPath().equals(item.getPath()))) { + if (event.getAction() == ExplorerChangeEvent.ALL) { + refresh(); + } else if (item != null && mDirectory.getPath().equals(item.getPath())) { refresh(); } } diff --git a/app/src/main/java/org/autojs/autojs/ui/viewmodel/ExplorerItemManager.kt b/app/src/main/java/org/autojs/autojs/ui/viewmodel/ExplorerItemManager.kt index 52bfcd3e..05c52743 100644 --- a/app/src/main/java/org/autojs/autojs/ui/viewmodel/ExplorerItemManager.kt +++ b/app/src/main/java/org/autojs/autojs/ui/viewmodel/ExplorerItemManager.kt @@ -104,7 +104,7 @@ class ExplorerItemManager(private val mContext: Context) { } } - private fun remove(list: ArrayList<*>, o: T): Int { + private fun remove(list: ArrayList, o: T): Int { return list.indexOf(o).also { i -> list.takeUnless { i < 0 }?.removeAt(i) }