feat(ui): confirm when delete script or dir
This commit is contained in:
@@ -224,9 +224,22 @@ public class ScriptOperations {
|
||||
.putExtra(ShortcutCreateActivity.EXTRA_FILE, file));
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
public void delete(final ScriptFile scriptFile) {
|
||||
Observable.fromPublisher((Publisher<Boolean>) s -> s.onNext(PFiles.deleteRecursively(scriptFile))).subscribeOn(Schedulers.io())
|
||||
new ThemeColorMaterialDialogBuilder(mContext)
|
||||
.title(mContext.getString(R.string.text_are_you_sure_to_delete, scriptFile.getName()))
|
||||
.positiveText(R.string.cancel)
|
||||
.negativeText(R.string.ok)
|
||||
.onNegative((dialog, which) -> {
|
||||
deleteWithoutConfirm(scriptFile);
|
||||
})
|
||||
.show();
|
||||
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
public void deleteWithoutConfirm(final ScriptFile scriptFile) {
|
||||
Observable.fromPublisher((Publisher<Boolean>) s -> s.onNext(PFiles.deleteRecursively(scriptFile)))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(deleted -> {
|
||||
showMessage(deleted ? R.string.text_already_delete : R.string.text_delete_failed);
|
||||
@@ -235,6 +248,7 @@ public class ScriptOperations {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public Observable<ScriptFile> download(String url) {
|
||||
String fileName = DownloadManager.parseFileNameLocally(url);
|
||||
return new FileChooserDialogBuilder(mContext)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.autojs.autojs.ui.main.scripts;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.support.annotation.Nullable;
|
||||
@@ -278,6 +279,7 @@ public class ScriptListView extends ThemeColorSwipeRefreshLayout implements Swip
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private void sort(final int sortType, final boolean isDir) {
|
||||
setRefreshing(true);
|
||||
Observable.fromCallable(() -> {
|
||||
|
||||
@@ -381,4 +381,5 @@
|
||||
<string name="text_execute">执行</string>
|
||||
<string name="text_use_alarm_clock">使用系统闹钟唤醒Auto.js</string>
|
||||
<string name="error_connect_to_remote">连接失败: %s</string>
|
||||
<string name="text_are_you_sure_to_delete">确定要删除%s吗</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user