From 20d8aed25c1a981718b4fe66a411d76585fcd435 Mon Sep 17 00:00:00 2001 From: Santosh Pingle Date: Tue, 29 Nov 2022 19:18:01 +0530 Subject: [PATCH 01/18] Reduce question text font size in review mode. --- .../fhir/catalog/DemoQuestionnaireFragment.kt | 4 +- ...QuestionnaireItemHeaderViewInReviewMode.kt | 46 ++++ ...eQuestionAnswerDisplayViewHolderFactory.kt | 2 +- ...estionnaire_item_header_in_review_mode.xml | 99 +++++++++ ...naire_item_simple_question_answer_view.xml | 2 +- datacapture/src/main/res/values/attrs.xml | 3 + datacapture/src/main/res/values/styles.xml | 6 +- ...tionnaireItemHeaderViewInReviewModeTest.kt | 196 ++++++++++++++++++ 8 files changed, 354 insertions(+), 4 deletions(-) create mode 100644 datacapture/src/main/java/com/google/android/fhir/datacapture/views/QuestionnaireItemHeaderViewInReviewMode.kt create mode 100644 datacapture/src/main/res/layout/questionnaire_item_header_in_review_mode.xml create mode 100644 datacapture/src/test/java/com/google/android/fhir/datacapture/views/QuestionnaireItemHeaderViewInReviewModeTest.kt diff --git a/catalog/src/main/java/com/google/android/fhir/catalog/DemoQuestionnaireFragment.kt b/catalog/src/main/java/com/google/android/fhir/catalog/DemoQuestionnaireFragment.kt index 0cb1bcb7e7..9bc1aee22f 100644 --- a/catalog/src/main/java/com/google/android/fhir/catalog/DemoQuestionnaireFragment.kt +++ b/catalog/src/main/java/com/google/android/fhir/catalog/DemoQuestionnaireFragment.kt @@ -40,6 +40,7 @@ import androidx.navigation.fragment.navArgs import com.google.android.fhir.catalog.ModalBottomSheetFragment.Companion.BUNDLE_ERROR_KEY import com.google.android.fhir.catalog.ModalBottomSheetFragment.Companion.REQUEST_ERROR_KEY import com.google.android.fhir.datacapture.QuestionnaireFragment +import com.google.android.fhir.datacapture.QuestionnaireFragment.Companion.EXTRA_ENABLE_REVIEW_PAGE import com.google.android.fhir.datacapture.QuestionnaireFragment.Companion.SUBMIT_REQUEST_KEY import com.google.android.material.card.MaterialCardView import kotlinx.coroutines.launch @@ -152,7 +153,8 @@ class DemoQuestionnaireFragment : Fragment() { args = bundleOf( QuestionnaireFragment.EXTRA_QUESTIONNAIRE_JSON_STRING to - viewModel.getQuestionnaireJson() + viewModel.getQuestionnaireJson(), + EXTRA_ENABLE_REVIEW_PAGE to true ) ) } diff --git a/datacapture/src/main/java/com/google/android/fhir/datacapture/views/QuestionnaireItemHeaderViewInReviewMode.kt b/datacapture/src/main/java/com/google/android/fhir/datacapture/views/QuestionnaireItemHeaderViewInReviewMode.kt new file mode 100644 index 0000000000..72430bec90 --- /dev/null +++ b/datacapture/src/main/java/com/google/android/fhir/datacapture/views/QuestionnaireItemHeaderViewInReviewMode.kt @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.android.fhir.datacapture.views + +import android.content.Context +import android.util.AttributeSet +import android.view.LayoutInflater +import android.widget.LinearLayout +import android.widget.TextView +import com.google.android.fhir.datacapture.R +import com.google.android.fhir.datacapture.localizedInstructionsSpanned +import com.google.android.fhir.datacapture.localizedPrefixSpanned +import org.hl7.fhir.r4.model.Questionnaire + +internal class QuestionnaireItemHeaderViewInReviewMode(context: Context, attrs: AttributeSet?) : + LinearLayout(context, attrs) { + + init { + LayoutInflater.from(context) + .inflate(R.layout.questionnaire_item_header_in_review_mode, this, true) + } + + fun bind(questionnaireItem: Questionnaire.QuestionnaireItemComponent) { + val prefix = findViewById(R.id.prefix) + val question = findViewById(R.id.question) + val hint = findViewById(R.id.hint) + prefix.updateTextAndVisibility(questionnaireItem.localizedPrefixSpanned) + updateQuestionText(question, questionnaireItem) + hint.updateTextAndVisibility(questionnaireItem.localizedInstructionsSpanned) + visibility = getViewGroupVisibility(prefix, question, hint) + } +} diff --git a/datacapture/src/main/java/com/google/android/fhir/datacapture/views/QuestionnaireItemSimpleQuestionAnswerDisplayViewHolderFactory.kt b/datacapture/src/main/java/com/google/android/fhir/datacapture/views/QuestionnaireItemSimpleQuestionAnswerDisplayViewHolderFactory.kt index 4ad3b041d0..f2144ae394 100644 --- a/datacapture/src/main/java/com/google/android/fhir/datacapture/views/QuestionnaireItemSimpleQuestionAnswerDisplayViewHolderFactory.kt +++ b/datacapture/src/main/java/com/google/android/fhir/datacapture/views/QuestionnaireItemSimpleQuestionAnswerDisplayViewHolderFactory.kt @@ -34,7 +34,7 @@ internal object QuestionnaireItemSimpleQuestionAnswerDisplayViewHolderFactory : QuestionnaireItemViewHolderFactory(R.layout.questionnaire_item_simple_question_answer_view) { override fun getQuestionnaireItemViewHolderDelegate() = object : QuestionnaireItemViewHolderDelegate { - private lateinit var header: QuestionnaireItemHeaderView + private lateinit var header: QuestionnaireItemHeaderViewInReviewMode private lateinit var flyOverTextView: TextView private lateinit var answerTextView: TextView private lateinit var divider: MaterialDivider diff --git a/datacapture/src/main/res/layout/questionnaire_item_header_in_review_mode.xml b/datacapture/src/main/res/layout/questionnaire_item_header_in_review_mode.xml new file mode 100644 index 0000000000..dfff796306 --- /dev/null +++ b/datacapture/src/main/res/layout/questionnaire_item_header_in_review_mode.xml @@ -0,0 +1,99 @@ + + + + + + + + + + +