diff --git a/buildSrc/src/main/kotlin/Releases.kt b/buildSrc/src/main/kotlin/Releases.kt index 38cb8d700c..e53da77fd7 100644 --- a/buildSrc/src/main/kotlin/Releases.kt +++ b/buildSrc/src/main/kotlin/Releases.kt @@ -1,5 +1,5 @@ /* - * Copyright 2023 Google LLC + * Copyright 2023-2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,7 +54,7 @@ object Releases { object DataCapture : LibraryArtifact { override val artifactId = "data-capture" - override val version = "1.0.0" + override val version = "1.1.0" override val name = "Android FHIR Structured Data Capture Library" } diff --git a/datacapture/sampledata/layout_paginated.json b/datacapture/sampledata/layout_paginated.json new file mode 100644 index 0000000000..cf27bca894 --- /dev/null +++ b/datacapture/sampledata/layout_paginated.json @@ -0,0 +1,60 @@ +{ + "resourceType": "Questionnaire", + "item": [ + { + "linkId": "1", + "type": "group", + "extension": [ + { + "url": "http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl", + "valueCodeableConcept": { + "coding": [ + { + "system": "http://hl7.org/fhir/questionnaire-item-control", + "code": "page", + "display": "Page" + } + ], + "text": "Page" + } + } + ], + "item": [ + { + "linkId": "1.1", + "type": "display", + "text": "Personal information", + "prefix": "1." + } + ] + }, + { + "linkId": "2", + "type": "group", + "extension": [ + { + "url": "http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl", + "valueCodeableConcept": { + "coding": [ + { + "system": "http://hl7.org/fhir/questionnaire-item-control", + "code": "page", + "display": "Page" + } + ], + "text": "Page" + } + } + ], + "item": [ + { + "linkId": "2.1", + "type": "date", + "text": "Date of birth", + "prefix": "2.", + "required": true + } + ] + } + ] +} diff --git a/datacapture/src/androidTest/java/com/google/android/fhir/datacapture/test/QuestionnaireUiEspressoTest.kt b/datacapture/src/androidTest/java/com/google/android/fhir/datacapture/test/QuestionnaireUiEspressoTest.kt index 96b75cba10..e5ee755f80 100644 --- a/datacapture/src/androidTest/java/com/google/android/fhir/datacapture/test/QuestionnaireUiEspressoTest.kt +++ b/datacapture/src/androidTest/java/com/google/android/fhir/datacapture/test/QuestionnaireUiEspressoTest.kt @@ -1,5 +1,5 @@ /* - * Copyright 2023 Google LLC + * Copyright 2023-2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -105,6 +105,30 @@ class QuestionnaireUiEspressoTest { ) } + @Test + fun shouldHideNextButtonIfDisabled() { + buildFragmentFromQuestionnaire("/layout_paginated.json", true) + + clickOnText("Next") + + onView(withId(R.id.pagination_next_button)) + .check( + ViewAssertions.matches(ViewMatchers.withEffectiveVisibility(ViewMatchers.Visibility.GONE)), + ) + } + + @Test + fun shouldDisplayNextButtonIfEnabled() { + buildFragmentFromQuestionnaire("/layout_paginated.json", true) + + onView(withId(R.id.pagination_next_button)) + .check( + ViewAssertions.matches( + ViewMatchers.withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE), + ), + ) + } + @Test fun integerTextEdit_inputOutOfRange_shouldShowError() { buildFragmentFromQuestionnaire("/text_questionnaire_integer.json") @@ -503,6 +527,7 @@ class QuestionnaireUiEspressoTest { val questionnaireFragment = QuestionnaireFragment.builder() .setQuestionnaire(questionnaireJsonString) + .setShowCancelButton(true) .showReviewPageBeforeSubmit(isReviewMode) .build() activityScenarioRule.scenario.onActivity { activity -> diff --git a/datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireFragment.kt b/datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireFragment.kt index f562439b8e..3e640c9456 100644 --- a/datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireFragment.kt +++ b/datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireFragment.kt @@ -1,5 +1,5 @@ /* - * Copyright 2023 Google LLC + * Copyright 2023-2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -199,8 +199,8 @@ class QuestionnaireFragment : Fragment() { if (displayMode.pagination.isPaginated) { paginationPreviousButton.visibility = View.VISIBLE paginationPreviousButton.isEnabled = displayMode.pagination.hasPreviousPage - paginationNextButton.visibility = View.VISIBLE - paginationNextButton.isEnabled = displayMode.pagination.hasNextPage + paginationNextButton.visibility = + if (displayMode.pagination.hasNextPage) View.VISIBLE else View.GONE } else { paginationPreviousButton.visibility = View.GONE paginationNextButton.visibility = View.GONE diff --git a/datacapture/src/main/res/values/styles.xml b/datacapture/src/main/res/values/styles.xml index 4fe62672e7..750f97cd7a 100644 --- a/datacapture/src/main/res/values/styles.xml +++ b/datacapture/src/main/res/values/styles.xml @@ -400,7 +400,7 @@