Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#6439] Fix UI of repeat labels #6459

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# ODK Collect

![Platform](https://img.shields.io/badge/platform-Android-blue.svg)
[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![Build status](https://circleci.com/gh/getodk/collect.svg?style=shield&circle-token=:circle-token)](https://circleci.com/gh/getodk/collect)
Expand Down Expand Up @@ -120,10 +121,14 @@ When you first run Collect, it is set to download forms from [https://demo.getod

1. Once you have the XForm, use [adb](https://developer.android.com/studio/command-line/adb.html) to push the form to your device (after [enabling USB debugging](https://www.kingoapp.com/root-tutorials/how-to-enable-usb-debugging-mode-on-android.htm)) or emulator.
```
adb push my_form.xml /sdcard/Android/data/org.odk.collect.android/files/forms
adb push my_form.xml /sdcard/Android/data/org.odk.collect.android/files/projects/{project-id}/forms
```

1. Launch ODK Collect and tap `Fill Blank Form`. The new form will be there.
If you are using the demo project, kindly replace `{project_id}` with `DEMO`

4. Launch ODK Collect and tap `+ Start new form`. The new form will be there.

More information about using Android Debug Bridge with Collect can be found [here](https://docs.getodk.org/collect-adb/).

## Using APIs for local development

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class AddRepeatTest {
private static final String ONE_QUESTION_REPEAT = "one-question-repeat.xml";
private static final String FIELD_LIST_REPEAT = "field-list-repeat.xml";
private static final String FIXED_COUNT_REPEAT = "fixed-count-repeat.xml";
private static final String REPEAT_WITHOUT_LABEL = "repeat_without_label.xml";

private final CollectTestRule rule = new CollectTestRule();

Expand Down Expand Up @@ -117,4 +118,16 @@ public void whenInHierarchyForRepeat_clickingPlus_addsRepeatAtEndOfSeries() {
.addGroup()
.assertText("Person > 3");
}

@Test
public void whenInRepeatWithoutLabel_swipingNext_andClickingAdd_addsAnotherRepeat() {
rule.startAtMainMenu()
.copyForm(REPEAT_WITHOUT_LABEL)
.startBlankForm("Repeat without label")
.assertText("> 1")
.answerQuestion("First name", true, "Karan")
.swipeToNextQuestionWithRepeatGroup("")
.clickOnAdd(new FormEntryPage("Repeat without label"))
.assertText("> 2");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ public AddNewRepeatDialog(String repeatName) {

@Override
public AddNewRepeatDialog assertOnPage() {
onView(withText(getTranslatedString(org.odk.collect.strings.R.string.add_repeat_question, repeatName)))
String dialogMessage;
if (repeatName.isBlank()) {
dialogMessage = getTranslatedString(org.odk.collect.strings.R.string.add_another_question);
} else {
dialogMessage = getTranslatedString(org.odk.collect.strings.R.string.add_repeat_question, repeatName);
}
onView(withText(dialogMessage))
.inRoot(isDialog())
.check(matches(isDisplayed()));
return this;
Expand All @@ -27,7 +33,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();
karntrehan marked this conversation as resolved.
Show resolved Hide resolved
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: 0 additions & 1 deletion strings/src/main/res/values-ar/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@
<!--This sentence is used in the dialog for adding repeats and will be completed by a singular noun usually. Examples would be ‘Add “observation”?’ or ‘Add “Reading”?’. If the phrase doesn’t make sense in your language you can add a word like “new”, being careful of gender/plural.-->
<string name="add_repeat_question">أضف \"%s\"؟</string>
<string name="add_repeat">أضف</string>
<string name="dont_add_repeat">لا تقم بالإضافة</string>
<string name="add_another_menu">إضافة أخرى</string>
<!--Title of overlay menu displayed when long pressing on a question in a form-->
<string name="edit_prompt">تعديل التوجيه</string>
Expand Down
1 change: 0 additions & 1 deletion strings/src/main/res/values-cs/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@
<!--This sentence is used in the dialog for adding repeats and will be completed by a singular noun usually. Examples would be ‘Add “observation”?’ or ‘Add “Reading”?’. If the phrase doesn’t make sense in your language you can add a word like “new”, being careful of gender/plural.-->
<string name="add_repeat_question">Přidat \"%s\"?</string>
<string name="add_repeat">Přidat</string>
<string name="dont_add_repeat">Nepřidat</string>
<string name="add_another_menu">Přidat další</string>
<!--Title of overlay menu displayed when long pressing on a question in a form-->
<string name="edit_prompt">Editovat otázku</string>
Expand Down
1 change: 0 additions & 1 deletion strings/src/main/res/values-da/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
<!--This sentence is used in the dialog for adding repeats and will be completed by a singular noun usually. Examples would be ‘Add “observation”?’ or ‘Add “Reading”?’. If the phrase doesn’t make sense in your language you can add a word like “new”, being careful of gender/plural.-->
<string name="add_repeat_question">Tilføj \"1%s \"?l</string>
<string name="add_repeat">Tilføj</string>
<string name="dont_add_repeat">Undlad at tilføje</string>
<string name="add_another_menu">Tilføj anden</string>
<!--Title of overlay menu displayed when long pressing on a question in a form-->
<string name="edit_prompt">Rediger prompt</string>
Expand Down
1 change: 0 additions & 1 deletion strings/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@
<!--This sentence is used in the dialog for adding repeats and will be completed by a singular noun usually. Examples would be ‘Add “observation”?’ or ‘Add “Reading”?’. If the phrase doesn’t make sense in your language you can add a word like “new”, being careful of gender/plural.-->
<string name="add_repeat_question">\"%s\" hinzufügen?</string>
<string name="add_repeat">Hinzufügen</string>
<string name="dont_add_repeat">Nicht hinzufügen</string>
<string name="add_another_menu">Weitere hinzufügen</string>
<!--Title of overlay menu displayed when long pressing on a question in a form-->
<string name="edit_prompt">Eingabe ändern</string>
Expand Down
1 change: 0 additions & 1 deletion strings/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@
<!--This sentence is used in the dialog for adding repeats and will be completed by a singular noun usually. Examples would be ‘Add “observation”?’ or ‘Add “Reading”?’. If the phrase doesn’t make sense in your language you can add a word like “new”, being careful of gender/plural.-->
<string name="add_repeat_question">Agregar \"%s\"?</string>
<string name="add_repeat">Agregar</string>
<string name="dont_add_repeat">No agregar</string>
<string name="add_another_menu">Agregar otro</string>
<!--Title of overlay menu displayed when long pressing on a question in a form-->
<string name="edit_prompt">Editar entrada</string>
Expand Down
1 change: 0 additions & 1 deletion strings/src/main/res/values-fa-rAF/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@
<!--This sentence is used in the dialog for adding repeats and will be completed by a singular noun usually. Examples would be ‘Add “observation”?’ or ‘Add “Reading”?’. If the phrase doesn’t make sense in your language you can add a word like “new”, being careful of gender/plural.-->
<string name="add_repeat_question">\"%s\" اضافه شود؟</string>
<string name="add_repeat">اضافه کردن</string>
<string name="dont_add_repeat">اضافه نکنید</string>
<string name="add_another_menu">اضافه کردن جدید</string>
<!--Title of overlay menu displayed when long pressing on a question in a form-->
<string name="edit_prompt">ویرایش سریع</string>
Expand Down
1 change: 0 additions & 1 deletion strings/src/main/res/values-fa/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@
<!--This sentence is used in the dialog for adding repeats and will be completed by a singular noun usually. Examples would be ‘Add “observation”?’ or ‘Add “Reading”?’. If the phrase doesn’t make sense in your language you can add a word like “new”, being careful of gender/plural.-->
<string name="add_repeat_question">\"%s\" اضافه شود؟</string>
<string name="add_repeat">اضافه کردن</string>
<string name="dont_add_repeat">اضافه نکنید</string>
<string name="add_another_menu">اضافه کردن جدید</string>
<!--Title of overlay menu displayed when long pressing on a question in a form-->
<string name="edit_prompt">ویرایش سریع</string>
Expand Down
1 change: 0 additions & 1 deletion strings/src/main/res/values-fi/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@
<!--This sentence is used in the dialog for adding repeats and will be completed by a singular noun usually. Examples would be ‘Add “observation”?’ or ‘Add “Reading”?’. If the phrase doesn’t make sense in your language you can add a word like “new”, being careful of gender/plural.-->
<string name="add_repeat_question">Lisätäänkö \"%s\"?</string>
<string name="add_repeat">Lisätään</string>
<string name="dont_add_repeat">Ei lisätä</string>
<string name="add_another_menu">Lisää toinen</string>
<!--Title of overlay menu displayed when long pressing on a question in a form-->
<string name="edit_prompt">Kehotteen muokkaus</string>
Expand Down
1 change: 0 additions & 1 deletion strings/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@
<!--This sentence is used in the dialog for adding repeats and will be completed by a singular noun usually. Examples would be ‘Add “observation”?’ or ‘Add “Reading”?’. If the phrase doesn’t make sense in your language you can add a word like “new”, being careful of gender/plural.-->
<string name="add_repeat_question">Ajouter «%s» ?</string>
<string name="add_repeat">Ajouter</string>
<string name="dont_add_repeat">Ne pas ajouter</string>
<string name="add_another_menu">Ajouter un autre </string>
<!--Title of overlay menu displayed when long pressing on a question in a form-->
<string name="edit_prompt">Ligne de modification</string>
Expand Down
1 change: 0 additions & 1 deletion strings/src/main/res/values-ht/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@
<!--This sentence is used in the dialog for adding repeats and will be completed by a singular noun usually. Examples would be ‘Add “observation”?’ or ‘Add “Reading”?’. If the phrase doesn’t make sense in your language you can add a word like “new”, being careful of gender/plural.-->
<string name="add_repeat_question">Ajoute \"%s\"?</string>
<string name="add_repeat">Ajoute</string>
<string name="dont_add_repeat">Pa ajoute</string>
<string name="add_another_menu">Ajoute yon lot</string>
<!--Title of overlay menu displayed when long pressing on a question in a form-->
<string name="edit_prompt">Mesaj modifikasyon</string>
Expand Down
1 change: 0 additions & 1 deletion strings/src/main/res/values-in/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@
<!--This sentence is used in the dialog for adding repeats and will be completed by a singular noun usually. Examples would be ‘Add “observation”?’ or ‘Add “Reading”?’. If the phrase doesn’t make sense in your language you can add a word like “new”, being careful of gender/plural.-->
<string name="add_repeat_question">Tambah \"%s\"?</string>
<string name="add_repeat">Tambah</string>
<string name="dont_add_repeat">Batal tambah</string>
<string name="add_another_menu">Tambah lainnya</string>
<!--Title of overlay menu displayed when long pressing on a question in a form-->
<string name="edit_prompt">Ubah Risalah</string>
Expand Down
1 change: 0 additions & 1 deletion strings/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@
<!--This sentence is used in the dialog for adding repeats and will be completed by a singular noun usually. Examples would be ‘Add “observation”?’ or ‘Add “Reading”?’. If the phrase doesn’t make sense in your language you can add a word like “new”, being careful of gender/plural.-->
<string name="add_repeat_question">Aggingere \"%s\"?</string>
<string name="add_repeat">Aggiungere</string>
<string name="dont_add_repeat">Non aggiungere</string>
<string name="add_another_menu">Aggiungi un altro</string>
<!--Title of overlay menu displayed when long pressing on a question in a form-->
<string name="edit_prompt">Modifica Prompt</string>
Expand Down
1 change: 0 additions & 1 deletion strings/src/main/res/values-ja/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@
<!--This sentence is used in the dialog for adding repeats and will be completed by a singular noun usually. Examples would be ‘Add “observation”?’ or ‘Add “Reading”?’. If the phrase doesn’t make sense in your language you can add a word like “new”, being careful of gender/plural.-->
<string name="add_repeat_question">\"%s\" を追加?</string>
<string name="add_repeat">追加</string>
<string name="dont_add_repeat">追加しない</string>
<string name="add_another_menu">別の追加…</string>
<!--Title of overlay menu displayed when long pressing on a question in a form-->
<string name="edit_prompt">プロンプトを編集</string>
Expand Down
1 change: 0 additions & 1 deletion strings/src/main/res/values-ka/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@
<!--This sentence is used in the dialog for adding repeats and will be completed by a singular noun usually. Examples would be ‘Add “observation”?’ or ‘Add “Reading”?’. If the phrase doesn’t make sense in your language you can add a word like “new”, being careful of gender/plural.-->
<string name="add_repeat_question">დავამატოთ \"%s\"?</string>
<string name="add_repeat">დამატება</string>
<string name="dont_add_repeat">არ დაამატო</string>
<string name="add_another_menu">დამატება</string>
<!--Title of overlay menu displayed when long pressing on a question in a form-->
<string name="edit_prompt">გამოპასუხების რედაქტირება</string>
Expand Down
1 change: 0 additions & 1 deletion strings/src/main/res/values-km/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@
<!--This sentence is used in the dialog for adding repeats and will be completed by a singular noun usually. Examples would be ‘Add “observation”?’ or ‘Add “Reading”?’. If the phrase doesn’t make sense in your language you can add a word like “new”, being careful of gender/plural.-->
<string name="add_repeat_question">បន្ថែម \"%s\"?</string>
<string name="add_repeat">បន្ថែម</string>
<string name="dont_add_repeat">កុំបន្ថែម</string>
<string name="add_another_menu">បន្ថែមមួយផ្សេងទៀត</string>
<!--Title of overlay menu displayed when long pressing on a question in a form-->
<string name="edit_prompt">កែប្រែ Prompt</string>
Expand Down
1 change: 0 additions & 1 deletion strings/src/main/res/values-nl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@
<!--This sentence is used in the dialog for adding repeats and will be completed by a singular noun usually. Examples would be ‘Add “observation”?’ or ‘Add “Reading”?’. If the phrase doesn’t make sense in your language you can add a word like “new”, being careful of gender/plural.-->
<string name="add_repeat_question">%s toevoegen?</string>
<string name="add_repeat">Toevoegen</string>
<string name="dont_add_repeat">Niet toevoegen</string>
<string name="add_another_menu">Voeg toe</string>
<!--Title of overlay menu displayed when long pressing on a question in a form-->
<string name="edit_prompt">Edit Prompt</string>
Expand Down
1 change: 0 additions & 1 deletion strings/src/main/res/values-pl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@
<!--This sentence is used in the dialog for adding repeats and will be completed by a singular noun usually. Examples would be ‘Add “observation”?’ or ‘Add “Reading”?’. If the phrase doesn’t make sense in your language you can add a word like “new”, being careful of gender/plural.-->
<string name="add_repeat_question">Dodać \"%s\"?</string>
<string name="add_repeat">Dodaj</string>
<string name="dont_add_repeat">Nie dodawaj</string>
<string name="add_another_menu">Dodaj kolejne</string>
<!--Title of overlay menu displayed when long pressing on a question in a form-->
<string name="edit_prompt">Edytuj Pytanie</string>
Expand Down
1 change: 0 additions & 1 deletion strings/src/main/res/values-pt/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@
<!--This sentence is used in the dialog for adding repeats and will be completed by a singular noun usually. Examples would be ‘Add “observation”?’ or ‘Add “Reading”?’. If the phrase doesn’t make sense in your language you can add a word like “new”, being careful of gender/plural.-->
<string name="add_repeat_question">Adicionar \"%s\"?</string>
<string name="add_repeat">Adicionar</string>
<string name="dont_add_repeat">Não adicionar</string>
<string name="add_another_menu">Adicionar outra</string>
<!--Title of overlay menu displayed when long pressing on a question in a form-->
<string name="edit_prompt">Editar Prompt</string>
Expand Down
1 change: 0 additions & 1 deletion strings/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@
<!--This sentence is used in the dialog for adding repeats and will be completed by a singular noun usually. Examples would be ‘Add “observation”?’ or ‘Add “Reading”?’. If the phrase doesn’t make sense in your language you can add a word like “new”, being careful of gender/plural.-->
<string name="add_repeat_question">Добавить \"%s\"?</string>
<string name="add_repeat">Добавить</string>
<string name="dont_add_repeat">Не добавлять</string>
<string name="add_another_menu">Добавить другое</string>
<!--Title of overlay menu displayed when long pressing on a question in a form-->
<string name="edit_prompt">Изменить вопрос</string>
Expand Down
1 change: 0 additions & 1 deletion strings/src/main/res/values-rw/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@
<!--This sentence is used in the dialog for adding repeats and will be completed by a singular noun usually. Examples would be ‘Add “observation”?’ or ‘Add “Reading”?’. If the phrase doesn’t make sense in your language you can add a word like “new”, being careful of gender/plural.-->
<string name="add_repeat_question">Ongera \'1%s\' </string>
<string name="add_repeat">Shyiramo</string>
<string name="dont_add_repeat">Wishyiraho ibindi</string>
<string name="add_another_menu">Shyiraho ibindi </string>
<!--Title of overlay menu displayed when long pressing on a question in a form-->
<string name="edit_prompt">Gukosora ibyo wanditse </string>
Expand Down
1 change: 0 additions & 1 deletion strings/src/main/res/values-sl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@
<!--This sentence is used in the dialog for adding repeats and will be completed by a singular noun usually. Examples would be ‘Add “observation”?’ or ‘Add “Reading”?’. If the phrase doesn’t make sense in your language you can add a word like “new”, being careful of gender/plural.-->
<string name="add_repeat_question">Dodaj \"%s\"?</string>
<string name="add_repeat">Dodaj</string>
<string name="dont_add_repeat">Ne dodaj</string>
<string name="add_another_menu">Dodaj ponovno</string>
<!--Title of overlay menu displayed when long pressing on a question in a form-->
<string name="edit_prompt">Uredi</string>
Expand Down
Loading