diff --git a/buildSrc/src/main/kotlin/Releases.kt b/buildSrc/src/main/kotlin/Releases.kt index 4a5a54d064..c11dadf00c 100644 --- a/buildSrc/src/main/kotlin/Releases.kt +++ b/buildSrc/src/main/kotlin/Releases.kt @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 Google LLC + * Copyright 2023-2025 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,7 +48,7 @@ object Releases { object Engine : LibraryArtifact { override val artifactId = "engine" - override val version = "1.1.0" + override val version = "1.2.0" override val name = "Android FHIR Engine Library" } diff --git a/datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireViewModel.kt b/datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireViewModel.kt index ecc019b0a8..e96bd28a50 100644 --- a/datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireViewModel.kt +++ b/datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireViewModel.kt @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 Google LLC + * Copyright 2023-2025 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -298,12 +298,6 @@ internal class QuestionnaireViewModel(application: Application, state: SavedStat private lateinit var currentPageItems: List - /** - * True if the user has tapped the next/previous pagination buttons on the current page. This is - * needed to avoid spewing validation errors before any questions are answered. - */ - private var forceValidation = false - /** * Map of [QuestionnaireResponseItemAnswerComponent] for * [Questionnaire.QuestionnaireItemComponent]s that are disabled now. The answers will be used to @@ -903,7 +897,6 @@ internal class QuestionnaireViewModel(application: Application, state: SavedStat val validationResult = if ( modifiedQuestionnaireResponseItemSet.contains(questionnaireResponseItem) || - forceValidation || isInReviewModeFlow.value ) { questionnaireResponseItemValidator.validate( @@ -1124,13 +1117,14 @@ internal class QuestionnaireViewModel(application: Application, state: SavedStat it.item.validationResult is NotValidated } ) { - // Force update validation results for all questions on the current page. This is needed - // when the user has not answered any questions so no validation has been done. - forceValidation = true + // Add all items on the current page to modifiedQuestionnaireResponseItemSet. + // This will ensure that all fields are validated even when they're not filled by the user + currentPageItems.filterIsInstance().forEach { + modifiedQuestionnaireResponseItemSet.add(it.item.getQuestionnaireResponseItem()) + } // Results in a new questionnaire state being generated synchronously, i.e., the current // thread will be suspended until the new state is generated. modificationCount.update { it + 1 } - forceValidation = false } if ( diff --git a/demo/src/main/java/com/google/android/fhir/demo/PeriodicSyncFragment.kt b/demo/src/main/java/com/google/android/fhir/demo/PeriodicSyncFragment.kt index 4fc6d3c830..912ebbf517 100644 --- a/demo/src/main/java/com/google/android/fhir/demo/PeriodicSyncFragment.kt +++ b/demo/src/main/java/com/google/android/fhir/demo/PeriodicSyncFragment.kt @@ -1,5 +1,5 @@ /* - * Copyright 2024 Google LLC + * Copyright 2024-2025 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +21,7 @@ import android.view.LayoutInflater import android.view.MenuItem import android.view.View import android.view.ViewGroup +import android.widget.Button import android.widget.ProgressBar import android.widget.TextView import androidx.appcompat.app.AppCompatActivity @@ -48,6 +49,7 @@ class PeriodicSyncFragment : Fragment() { setUpActionBar() setHasOptionsMenu(true) refreshPeriodicSynUi() + setUpSyncButtons(view) } override fun onOptionsItemSelected(item: MenuItem): Boolean { @@ -67,6 +69,30 @@ class PeriodicSyncFragment : Fragment() { } } + private fun setUpSyncButtons(view: View) { + val syncNowButton = view.findViewById