diff --git a/app/assets/locales/android_translatable_strings.txt b/app/assets/locales/android_translatable_strings.txt index 588441a279..0be9d6d93c 100644 --- a/app/assets/locales/android_translatable_strings.txt +++ b/app/assets/locales/android_translatable_strings.txt @@ -896,8 +896,8 @@ repeat.dialog.go.back=Go Back repeat.dialog.leave=Do Not Add repeat.dialog.exit=Do Not Add. I'm Finished. repeat.dialog.add=Add Group -repeat.dialog.add.another=Add another "${0}" group? -repeat.dialog.add.new=Add a new "${0}" group? +repeat.dialog.add.another=Add another ${0}? +repeat.dialog.add.new=Add a new ${0}? lookup.table.missing.error=Unable to find lookup table "${0}". Make sure it exists and this user has access to it. ethiopian_months=Mäskäräm,T’ïk’ïmt,Hïdar,Tahsas,T’ïr,Yäkatit,Mägabit,Miyaziya,Gïnbot,Säne,Hämle,Nähäse,P’agume diff --git a/app/instrumentation-tests/src/org/commcare/androidTests/DialogTests.kt b/app/instrumentation-tests/src/org/commcare/androidTests/DialogTests.kt index ddb24a05f1..78f92ce3d5 100644 --- a/app/instrumentation-tests/src/org/commcare/androidTests/DialogTests.kt +++ b/app/instrumentation-tests/src/org/commcare/androidTests/DialogTests.kt @@ -2,6 +2,7 @@ package org.commcare.androidTests import androidx.test.espresso.Espresso.onView import androidx.test.espresso.action.ViewActions.click +import androidx.test.espresso.assertion.ViewAssertions.matches import androidx.test.espresso.matcher.ViewMatchers.withId import androidx.test.espresso.matcher.ViewMatchers.withText import androidx.test.ext.junit.runners.AndroidJUnit4 @@ -44,15 +45,16 @@ class DialogTests: BaseTest() { onView(withId(R.id.nav_btn_next)) .perform(click()) - withText("Add a new \"Error on add\" group?").isDisplayed() + onView(withId(R.id.choice_dialog_panel_2)).check(matches(withText("Add a new Error on add?"))) InstrumentationUtility.rotateLeft() //TODO Expect dialog to not persist due to a activity lifecycle bug in our dialog framework. - withText("Add a new \"Error on add\" group?").doesNotExist() + withText(R.id.choice_dialog_panel_2).doesNotExist() + InstrumentationUtility.rotatePortrait() onView(withId(R.id.nav_btn_next)) .perform(click()) - onView(withText("ADD GROUP")) + onView(withId(R.id.choice_dialog_panel_2)) .perform(click()) checkDialogExistence_withRotation("Error Occurred") diff --git a/app/src/org/commcare/activities/FormEntryActivityUIController.java b/app/src/org/commcare/activities/FormEntryActivityUIController.java index f917a62542..e06b0da10b 100644 --- a/app/src/org/commcare/activities/FormEntryActivityUIController.java +++ b/app/src/org/commcare/activities/FormEntryActivityUIController.java @@ -49,6 +49,7 @@ import org.javarosa.core.model.data.InvalidData; import org.javarosa.core.services.Logger; import org.javarosa.core.services.locale.Localization; +import org.javarosa.form.api.FormEntryCaption; import org.javarosa.form.api.FormEntryController; import org.javarosa.form.api.FormEntryPrompt; import org.javarosa.xpath.XPathException; @@ -493,24 +494,25 @@ private void createRepeatDialog() { final boolean backExitsForm = !details.relevantBeforeCurrentScreen; final boolean nextExitsForm = details.relevantAfterCurrentScreen == 0; + final FormEntryCaption repeatCaptionPrompt = FormEntryActivity.mFormController.getCaptionPrompt(); + // Assign title and text strings based on the current state String backText = Localization.get("repeat.dialog.go.back"); - String addAnotherText = Localization.get("repeat.dialog.add"); - String title, skipText; + + boolean hasRepetitions = FormEntryActivity.mFormController.getLastRepeatCount() > 0; + final String addAnotherText = repeatCaptionPrompt.getRepeatText(hasRepetitions ? "add" : "add-empty"); + + String skipText; + if (!nextExitsForm) { skipText = Localization.get("repeat.dialog.leave"); } else { skipText = Localization.get("repeat.dialog.exit"); } - if (FormEntryActivity.mFormController.getLastRepeatCount() > 0) { - title = Localization.get("repeat.dialog.add.another", FormEntryActivity.mFormController.getLastGroupText()); - } else { - title = Localization.get("repeat.dialog.add.new", FormEntryActivity.mFormController.getLastGroupText()); - } // Create the choice dialog ContextThemeWrapper wrapper = new ContextThemeWrapper(activity, R.style.DialogBaseTheme); - final PaneledChoiceDialog dialog = new HorizontalPaneledChoiceDialog(wrapper, title); + final PaneledChoiceDialog dialog = new HorizontalPaneledChoiceDialog(wrapper, addAnotherText); // Panel 1: Back option View.OnClickListener backListener = v -> {