这是indexloc提供的服务,不要输入任何密码
Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion app/src/main/java/com/termux/api/DialogActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import com.termux.api.util.TermuxApiLogger;
import com.termux.api.util.TermuxApiPermissionActivity;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.Locale;
Expand Down Expand Up @@ -126,7 +127,14 @@ public void writeJson(JsonWriter out) throws Exception {

out.name("code").value(result.code);
out.name("text").value(result.text);

if (result.values.size() > 0) {
out.name("values");
out.beginArray();
for (String value : result.values) {
out.value(value);
}
out.endArray();
}
if (!result.error.equals("")) {
out.name("error").value(result.error);
}
Expand Down Expand Up @@ -204,6 +212,7 @@ static class InputResult {
public String text = "";
public String error = "";
public int code = 0;
public List<String> values = new ArrayList<>();
}


Expand Down Expand Up @@ -254,15 +263,18 @@ LinearLayout createWidgetView(AppCompatActivity activity) {
String getResult() {
int checkBoxCount = widgetView.getChildCount();

List<String> values = new ArrayList<>();
StringBuilder sb = new StringBuilder();
sb.append("[");

for (int j = 0; j < checkBoxCount; ++j) {
CheckBox box = widgetView.findViewById(j);
if (box.isChecked()) {
values.add(box.getText().toString());
sb.append(box.getText().toString()).append(", ");
}
}
inputResult.values = values;
// remove trailing comma and add closing bracket
return sb.toString().replaceAll(", $", "") + "]";
}
Expand Down