6.7.0 - Alpha11 - 修复文件管理器删除项目文件夹后 UI 未能自动刷新的问题

This commit is contained in:
SuperMonster003
2025-11-19 14:01:31 +08:00
parent d1470346f3
commit 975dae971b
7 changed files with 35 additions and 13 deletions

View File

@@ -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 任务的问题"
],

View File

@@ -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)
) {

View File

@@ -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;

View File

@@ -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) {

View File

@@ -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<Boolean>) 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;

View File

@@ -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();
}
}

View File

@@ -104,7 +104,7 @@ class ExplorerItemManager(private val mContext: Context) {
}
}
private fun <T> remove(list: ArrayList<*>, o: T): Int {
private fun <T> remove(list: ArrayList<T>, o: T): Int {
return list.indexOf(o).also { i ->
list.takeUnless { i < 0 }?.removeAt(i)
}