Skip to content

Commit

Permalink
[getodk#6439] Button text and font changes. Empty text handling as well.
Browse files Browse the repository at this point in the history
  • Loading branch information
karntrehan committed Oct 16, 2024
1 parent 4dcc6be commit a23196c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public <D extends Page<D>> D clickOnAdd(D destination) {
}

public <D extends Page<D>> D clickOnDoNotAdd(D destination) {
return clickOnTextInDialog(org.odk.collect.strings.R.string.dont_add_repeat, destination);
return clickOnTextInDialog(org.odk.collect.strings.R.string.cancel, destination);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,31 @@

public class AddRepeatDialog {

private AddRepeatDialog() {}
private AddRepeatDialog() {
}

public static void show(Context context, String groupLabel, Listener listener) {
AlertDialog alertDialog = new MaterialAlertDialogBuilder(context).create();
DialogInterface.OnClickListener repeatListener = (dialog, i) -> {
switch (i) {
case BUTTON_POSITIVE:
listener.onAddRepeatClicked();
break;
case BUTTON_NEGATIVE:
listener.onCancelClicked();
break;
case BUTTON_POSITIVE -> listener.onAddRepeatClicked();
case BUTTON_NEGATIVE -> listener.onCancelClicked();
}
};

alertDialog.setMessage(context.getString(org.odk.collect.strings.R.string.add_repeat_question,
groupLabel));
String dialogMessage;
if (groupLabel.isBlank()) {
dialogMessage = context.getString(org.odk.collect.strings.R.string.add_another_question);
} else {
dialogMessage = context.getString(org.odk.collect.strings.R.string.add_repeat_question,
groupLabel);
}

alertDialog.setTitle(dialogMessage);

alertDialog.setButton(BUTTON_POSITIVE, context.getString(org.odk.collect.strings.R.string.add_repeat),
repeatListener);
alertDialog.setButton(BUTTON_NEGATIVE, context.getString(org.odk.collect.strings.R.string.dont_add_repeat),
alertDialog.setButton(BUTTON_NEGATIVE, context.getString(org.odk.collect.strings.R.string.cancel),
repeatListener);

alertDialog.setCancelable(false);
Expand Down
1 change: 1 addition & 0 deletions strings/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
<string name="add_repeat">Add</string>
<string name="dont_add_repeat">Do not add</string>
<string name="add_another_menu">Add another</string>
<string name="add_another_question">Add another?</string>

<!-- Title of overlay menu displayed when long pressing on a question in a form -->
<string name="edit_prompt">Edit Prompt</string>
Expand Down

0 comments on commit a23196c

Please sign in to comment.