From ae243719b175b6abc61b8d343a74021fe9f390d9 Mon Sep 17 00:00:00 2001 From: hyb1996 <946994919@qq.com> Date: Sat, 21 Apr 2018 14:23:42 +0800 Subject: [PATCH] fix(dialogs): dialog.select() shows checkbox --- app/build.gradle | 4 +- app/src/main/assets/sample/本地存储/随手记.js | 2 +- .../autojs/core/ui/dialog/JsDialog.java | 110 +++++++++--------- .../stardust/autojs/runtime/api/Dialogs.java | 13 --- 4 files changed, 58 insertions(+), 71 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index a0213d71..10d331d8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -8,8 +8,8 @@ android { applicationId "com.stardust.scriptdroid" minSdkVersion 17 targetSdkVersion 23 - versionCode 262 - versionName "3.1.1 Alpha6" + versionCode 263 + versionName "3.1.1 Alpha7" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" multiDexEnabled true ndk { diff --git a/app/src/main/assets/sample/本地存储/随手记.js b/app/src/main/assets/sample/本地存储/随手记.js index f1a8e4d2..6a34a7ae 100644 --- a/app/src/main/assets/sample/本地存储/随手记.js +++ b/app/src/main/assets/sample/本地存储/随手记.js @@ -14,7 +14,7 @@ if(content != null){ ui.content.setText(content); } ui.save.click(()=>{ - storage.put("content", ui.content.getText()); + storage.put("content", ui.content.text()); }); diff --git a/autojs/src/main/java/com/stardust/autojs/core/ui/dialog/JsDialog.java b/autojs/src/main/java/com/stardust/autojs/core/ui/dialog/JsDialog.java index 3668af84..b3b7da89 100644 --- a/autojs/src/main/java/com/stardust/autojs/core/ui/dialog/JsDialog.java +++ b/autojs/src/main/java/com/stardust/autojs/core/ui/dialog/JsDialog.java @@ -206,74 +206,74 @@ public class JsDialog { @UiThread public void setTitle(int newTitleRes) { - if(Looper.myLooper()==Looper.getMainLooper()){ -mDialog.setTitle(newTitleRes); -}else{ -mUiHandler.post(()->mDialog.setTitle(newTitleRes)); -} + if (Looper.myLooper() == Looper.getMainLooper()) { + mDialog.setTitle(newTitleRes); + } else { + mUiHandler.post(() -> mDialog.setTitle(newTitleRes)); + } } @UiThread public void setTitle(int newTitleRes, @Nullable Object... formatArgs) { - if(Looper.myLooper()==Looper.getMainLooper()){ -mDialog.setTitle(newTitleRes, formatArgs); -}else{ -mUiHandler.post(()->mDialog.setTitle(newTitleRes, formatArgs)); -} + if (Looper.myLooper() == Looper.getMainLooper()) { + mDialog.setTitle(newTitleRes, formatArgs); + } else { + mUiHandler.post(() -> mDialog.setTitle(newTitleRes, formatArgs)); + } } @UiThread public void setIcon(int resId) { - if(Looper.myLooper()==Looper.getMainLooper()){ -mDialog.setIcon(resId); -}else{ -mUiHandler.post(()->mDialog.setIcon(resId)); -} + if (Looper.myLooper() == Looper.getMainLooper()) { + mDialog.setIcon(resId); + } else { + mUiHandler.post(() -> mDialog.setIcon(resId)); + } } @UiThread public void setIcon(Drawable d) { - if(Looper.myLooper()==Looper.getMainLooper()){ - mDialog.setIcon(d); -}else{ -mUiHandler.post(()-> mDialog.setIcon(d)); -} + if (Looper.myLooper() == Looper.getMainLooper()) { + mDialog.setIcon(d); + } else { + mUiHandler.post(() -> mDialog.setIcon(d)); + } } @UiThread public void setIconAttribute(int attrId) { - if(Looper.myLooper()==Looper.getMainLooper()){ -mDialog.setIconAttribute(attrId); -}else{ -mUiHandler.post(()->mDialog.setIconAttribute(attrId)); -} + if (Looper.myLooper() == Looper.getMainLooper()) { + mDialog.setIconAttribute(attrId); + } else { + mUiHandler.post(() -> mDialog.setIconAttribute(attrId)); + } } @UiThread public void setContent(CharSequence newContent) { - if(Looper.myLooper()==Looper.getMainLooper()){ - mDialog.setContent(newContent); -}else{ -mUiHandler.post(()-> mDialog.setContent(newContent)); -} + if (Looper.myLooper() == Looper.getMainLooper()) { + mDialog.setContent(newContent); + } else { + mUiHandler.post(() -> mDialog.setContent(newContent)); + } } @UiThread public void setContent(int newContentRes) { - if(Looper.myLooper()==Looper.getMainLooper()){ -mDialog.setContent(newContentRes); -}else{ -mUiHandler.post(()->mDialog.setContent(newContentRes)); -} + if (Looper.myLooper() == Looper.getMainLooper()) { + mDialog.setContent(newContentRes); + } else { + mUiHandler.post(() -> mDialog.setContent(newContentRes)); + } } @UiThread public void setContent(int newContentRes, @Nullable Object... formatArgs) { - if(Looper.myLooper()==Looper.getMainLooper()){ - mDialog.setContent(newContentRes, formatArgs); -}else{ -mUiHandler.post(()-> mDialog.setContent(newContentRes, formatArgs)); -} + if (Looper.myLooper() == Looper.getMainLooper()) { + mDialog.setContent(newContentRes, formatArgs); + } else { + mUiHandler.post(() -> mDialog.setContent(newContentRes, formatArgs)); + } } @Deprecated @@ -288,11 +288,11 @@ mUiHandler.post(()-> mDialog.setContent(newContentRes, formatArgs)); @UiThread public void setItems(CharSequence... items) { - if(Looper.myLooper()==Looper.getMainLooper()){ -mDialog.setItems(items); -}else{ -mUiHandler.post(()->mDialog.setItems(items)); -} + if (Looper.myLooper() == Looper.getMainLooper()) { + mDialog.setItems(items); + } else { + mUiHandler.post(() -> mDialog.setItems(items)); + } } @UiThread @@ -319,19 +319,19 @@ mUiHandler.post(()->mDialog.setItems(items)); } public void incrementProgress(int by) { - if(Looper.myLooper()==Looper.getMainLooper()){ -mDialog.incrementProgress(by); -}else{ -mUiHandler.post(()->mDialog.incrementProgress(by)); -} + if (Looper.myLooper() == Looper.getMainLooper()) { + mDialog.incrementProgress(by); + } else { + mUiHandler.post(() -> mDialog.incrementProgress(by)); + } } public void setProgress(int progress) { - if(Looper.myLooper()==Looper.getMainLooper()){ -mDialog.setProgress(progress); -}else{ -mUiHandler.post(()->mDialog.setProgress(progress)); -} + if (Looper.myLooper() == Looper.getMainLooper()) { + mDialog.setProgress(progress); + } else { + mUiHandler.post(() -> mDialog.setProgress(progress)); + } } public void setMaxProgress(int max) { diff --git a/autojs/src/main/java/com/stardust/autojs/runtime/api/Dialogs.java b/autojs/src/main/java/com/stardust/autojs/runtime/api/Dialogs.java index b5a2f2de..ccc68af8 100644 --- a/autojs/src/main/java/com/stardust/autojs/runtime/api/Dialogs.java +++ b/autojs/src/main/java/com/stardust/autojs/runtime/api/Dialogs.java @@ -80,12 +80,6 @@ public class Dialogs { return ((BlockedMaterialDialog.Builder) dialogBuilder(callback) .itemsCallback() .title(title) - .checkBoxPrompt("", true, new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - - } - }) .items((CharSequence[]) items)) .showAndGet(); } @@ -106,13 +100,6 @@ public class Dialogs { return items; } - private Object getCallback(Object[] args) { - if (args.length > 1 && !(args[args.length - 1] instanceof CharSequence)) { - return args[args.length - 1]; - } - return null; - } - @ScriptInterface public Object singleChoice(String title, int selectedIndex, String[] items, Object callback) { return ((BlockedMaterialDialog.Builder) dialogBuilder(callback)