fix(dialogs): dialog.select() shows checkbox

This commit is contained in:
hyb1996 committed 2018-04-21 14:23:42 +08:00
1 parent 4f9f79f33b
commit ae243719b1
4 files changed
+58 -71

No files matched your search

+2 -2
View File
@@ -8,8 +8,8 @@ android {
applicationId "com.stardust.scriptdroid" applicationId "com.stardust.scriptdroid"
minSdkVersion 17 minSdkVersion 17
targetSdkVersion 23 targetSdkVersion 23
versionCode 262 versionCode 263
versionName "3.1.1 Alpha6" versionName "3.1.1 Alpha7"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true multiDexEnabled true
ndk { ndk {
@@ -14,7 +14,7 @@ if(content != null){
ui.content.setText(content); ui.content.setText(content);
} }
ui.save.click(()=>{ ui.save.click(()=>{
storage.put("content", ui.content.getText()); storage.put("content", ui.content.text());
}); });
@@ -206,74 +206,74 @@ public class JsDialog {
@UiThread @UiThread
public void setTitle(int newTitleRes) { public void setTitle(int newTitleRes) {
if(Looper.myLooper()==Looper.getMainLooper()){ if (Looper.myLooper() == Looper.getMainLooper()) {
mDialog.setTitle(newTitleRes); mDialog.setTitle(newTitleRes);
}else{ } else {
mUiHandler.post(()->mDialog.setTitle(newTitleRes)); mUiHandler.post(() -> mDialog.setTitle(newTitleRes));
} }
} }
@UiThread @UiThread
public void setTitle(int newTitleRes, @Nullable Object... formatArgs) { public void setTitle(int newTitleRes, @Nullable Object... formatArgs) {
if(Looper.myLooper()==Looper.getMainLooper()){ if (Looper.myLooper() == Looper.getMainLooper()) {
mDialog.setTitle(newTitleRes, formatArgs); mDialog.setTitle(newTitleRes, formatArgs);
}else{ } else {
mUiHandler.post(()->mDialog.setTitle(newTitleRes, formatArgs)); mUiHandler.post(() -> mDialog.setTitle(newTitleRes, formatArgs));
} }
} }
@UiThread @UiThread
public void setIcon(int resId) { public void setIcon(int resId) {
if(Looper.myLooper()==Looper.getMainLooper()){ if (Looper.myLooper() == Looper.getMainLooper()) {
mDialog.setIcon(resId); mDialog.setIcon(resId);
}else{ } else {
mUiHandler.post(()->mDialog.setIcon(resId)); mUiHandler.post(() -> mDialog.setIcon(resId));
} }
} }
@UiThread @UiThread
public void setIcon(Drawable d) { public void setIcon(Drawable d) {
if(Looper.myLooper()==Looper.getMainLooper()){ if (Looper.myLooper() == Looper.getMainLooper()) {
mDialog.setIcon(d); mDialog.setIcon(d);
}else{ } else {
mUiHandler.post(()-> mDialog.setIcon(d)); mUiHandler.post(() -> mDialog.setIcon(d));
} }
} }
@UiThread @UiThread
public void setIconAttribute(int attrId) { public void setIconAttribute(int attrId) {
if(Looper.myLooper()==Looper.getMainLooper()){ if (Looper.myLooper() == Looper.getMainLooper()) {
mDialog.setIconAttribute(attrId); mDialog.setIconAttribute(attrId);
}else{ } else {
mUiHandler.post(()->mDialog.setIconAttribute(attrId)); mUiHandler.post(() -> mDialog.setIconAttribute(attrId));
} }
} }
@UiThread @UiThread
public void setContent(CharSequence newContent) { public void setContent(CharSequence newContent) {
if(Looper.myLooper()==Looper.getMainLooper()){ if (Looper.myLooper() == Looper.getMainLooper()) {
mDialog.setContent(newContent); mDialog.setContent(newContent);
}else{ } else {
mUiHandler.post(()-> mDialog.setContent(newContent)); mUiHandler.post(() -> mDialog.setContent(newContent));
} }
} }
@UiThread @UiThread
public void setContent(int newContentRes) { public void setContent(int newContentRes) {
if(Looper.myLooper()==Looper.getMainLooper()){ if (Looper.myLooper() == Looper.getMainLooper()) {
mDialog.setContent(newContentRes); mDialog.setContent(newContentRes);
}else{ } else {
mUiHandler.post(()->mDialog.setContent(newContentRes)); mUiHandler.post(() -> mDialog.setContent(newContentRes));
} }
} }
@UiThread @UiThread
public void setContent(int newContentRes, @Nullable Object... formatArgs) { public void setContent(int newContentRes, @Nullable Object... formatArgs) {
if(Looper.myLooper()==Looper.getMainLooper()){ if (Looper.myLooper() == Looper.getMainLooper()) {
mDialog.setContent(newContentRes, formatArgs); mDialog.setContent(newContentRes, formatArgs);
}else{ } else {
mUiHandler.post(()-> mDialog.setContent(newContentRes, formatArgs)); mUiHandler.post(() -> mDialog.setContent(newContentRes, formatArgs));
} }
} }
@Deprecated @Deprecated
@@ -288,11 +288,11 @@ mUiHandler.post(()-> mDialog.setContent(newContentRes, formatArgs));
@UiThread @UiThread
public void setItems(CharSequence... items) { public void setItems(CharSequence... items) {
if(Looper.myLooper()==Looper.getMainLooper()){ if (Looper.myLooper() == Looper.getMainLooper()) {
mDialog.setItems(items); mDialog.setItems(items);
}else{ } else {
mUiHandler.post(()->mDialog.setItems(items)); mUiHandler.post(() -> mDialog.setItems(items));
} }
} }
@UiThread @UiThread
@@ -319,19 +319,19 @@ mUiHandler.post(()->mDialog.setItems(items));
} }
public void incrementProgress(int by) { public void incrementProgress(int by) {
if(Looper.myLooper()==Looper.getMainLooper()){ if (Looper.myLooper() == Looper.getMainLooper()) {
mDialog.incrementProgress(by); mDialog.incrementProgress(by);
}else{ } else {
mUiHandler.post(()->mDialog.incrementProgress(by)); mUiHandler.post(() -> mDialog.incrementProgress(by));
} }
} }
public void setProgress(int progress) { public void setProgress(int progress) {
if(Looper.myLooper()==Looper.getMainLooper()){ if (Looper.myLooper() == Looper.getMainLooper()) {
mDialog.setProgress(progress); mDialog.setProgress(progress);
}else{ } else {
mUiHandler.post(()->mDialog.setProgress(progress)); mUiHandler.post(() -> mDialog.setProgress(progress));
} }
} }
public void setMaxProgress(int max) { public void setMaxProgress(int max) {
@@ -80,12 +80,6 @@ public class Dialogs {
return ((BlockedMaterialDialog.Builder) dialogBuilder(callback) return ((BlockedMaterialDialog.Builder) dialogBuilder(callback)
.itemsCallback() .itemsCallback()
.title(title) .title(title)
.checkBoxPrompt("", true, new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
}
})
.items((CharSequence[]) items)) .items((CharSequence[]) items))
.showAndGet(); .showAndGet();
} }
@@ -106,13 +100,6 @@ public class Dialogs {
return items; 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 @ScriptInterface
public Object singleChoice(String title, int selectedIndex, String[] items, Object callback) { public Object singleChoice(String title, int selectedIndex, String[] items, Object callback) {
return ((BlockedMaterialDialog.Builder) dialogBuilder(callback) return ((BlockedMaterialDialog.Builder) dialogBuilder(callback)