From 0794d2a257315444c09b37cae3ea2bbfc4aed5dd Mon Sep 17 00:00:00 2001 From: aditya-07 Date: Wed, 15 Feb 2023 19:53:07 +0530 Subject: [PATCH] Add builder api for EXTRA_SHOW_SUBMIT_BUTTON (#1872) --- .../fhir/datacapture/QuestionnaireFragment.kt | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) 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 5a5845ef2e..cff7b49b33 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 @@ -246,7 +246,7 @@ class QuestionnaireFragment : Fragment() { */ fun getQuestionnaireResponse() = viewModel.getQuestionnaireResponse() - /** Helper to create [Questionnaire] with appropriate [Bundle] arguments. */ + /** Helper to create [QuestionnaireFragment] with appropriate [Bundle] arguments. */ class Builder { private val args = mutableListOf>() @@ -332,6 +332,11 @@ class QuestionnaireFragment : Fragment() { matchersProviderFactory: String ) = apply { args.add(EXTRA_MATCHERS_FACTORY to matchersProviderFactory) } + /** + * A [Boolean] extra to show or hide the Submit button in the questionnaire. Default is true. + */ + fun setShowSubmitButton(value: Boolean) = apply { args.add(EXTRA_SHOW_SUBMIT_BUTTON to value) } + @VisibleForTesting fun buildArgs() = bundleOf(*args.toTypedArray()) /** @return A [QuestionnaireFragment] with provided [Bundle] arguments. */ @@ -406,11 +411,12 @@ class QuestionnaireFragment : Fragment() { const val SUBMIT_REQUEST_KEY = "submit-request-key" - fun builder() = Builder() /** * A [Boolean] extra to show or hide the Submit button in the questionnaire. Default is true. */ - const val EXTRA_SHOW_SUBMIT_BUTTON = "show-submit-button" + internal const val EXTRA_SHOW_SUBMIT_BUTTON = "show-submit-button" + + fun builder() = Builder() } /**