From 4897ebe559bcf0047835660b2bac6d2149e5bd98 Mon Sep 17 00:00:00 2001
From: santosh-pingle <86107848+santosh-pingle@users.noreply.github.com>
Date: Fri, 13 May 2022 19:50:35 +0530
Subject: [PATCH 01/12] Datacapture, date picker custom style (#1261)
* Material date picker.
* spotless apply
* spotless apply
* Date picker custom style
* spotless apply
* Remove merged conflict code.
---
...ionnaireItemDatePickerViewHolderFactory.kt | 1 +
datacapture/src/main/res/values/styles.xml | 43 +++++++++++++++++++
2 files changed, 44 insertions(+)
diff --git a/datacapture/src/main/java/com/google/android/fhir/datacapture/views/QuestionnaireItemDatePickerViewHolderFactory.kt b/datacapture/src/main/java/com/google/android/fhir/datacapture/views/QuestionnaireItemDatePickerViewHolderFactory.kt
index 76d9f75d3c..fe7fd0d2d8 100644
--- a/datacapture/src/main/java/com/google/android/fhir/datacapture/views/QuestionnaireItemDatePickerViewHolderFactory.kt
+++ b/datacapture/src/main/java/com/google/android/fhir/datacapture/views/QuestionnaireItemDatePickerViewHolderFactory.kt
@@ -111,6 +111,7 @@ internal object QuestionnaireItemDatePickerViewHolderFactory :
?.toEpochMilli()
?: MaterialDatePicker.todayInUtcMilliseconds()
return MaterialDatePicker.Builder.datePicker()
+ .setTheme(R.style.ThemeOverlay_Questionnaire_DatePicker)
.setTitleText(R.string.select_date)
.setSelection(selectedDate)
.build()
diff --git a/datacapture/src/main/res/values/styles.xml b/datacapture/src/main/res/values/styles.xml
index 415efb8ca6..2a442cbddb 100644
--- a/datacapture/src/main/res/values/styles.xml
+++ b/datacapture/src/main/res/values/styles.xml
@@ -192,6 +192,49 @@
- ?attr/colorPrimary
+
+
+
+
+
+
+
-
-
+
+
+
From 472aec46ee61ad711fbaf242e69313504147368a Mon Sep 17 00:00:00 2001
From: santosh-pingle <86107848+santosh-pingle@users.noreply.github.com>
Date: Tue, 17 May 2022 17:39:42 +0530
Subject: [PATCH 04/12] Update Theme.Material3.* (#1379)
* Update 1.6.0 material dependency version.
* Update Theme.Material3.*
* Update Material3 theme.
Co-authored-by: Santosh Pingle
---
catalog/src/main/res/values-night/themes.xml | 2 +-
catalog/src/main/res/values/themes.xml | 2 +-
datacapture/src/main/res/values/styles.xml | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/catalog/src/main/res/values-night/themes.xml b/catalog/src/main/res/values-night/themes.xml
index a109d769c5..e8a8ca21e2 100644
--- a/catalog/src/main/res/values-night/themes.xml
+++ b/catalog/src/main/res/values-night/themes.xml
@@ -17,7 +17,7 @@
+
From 745e2e3145e1a7749604ab5412932e27898aea8b Mon Sep 17 00:00:00 2001
From: santosh-pingle <86107848+santosh-pingle@users.noreply.github.com>
Date: Mon, 23 May 2022 15:31:39 +0530
Subject: [PATCH 07/12] Catalog, Gear icon and bottom sheet to show error
workflow. (#1270)
* Gear icon and bottomsheet to show error workflow.
* Remove unwanted resources.
* Remove title text.
* Fix Lint error.
* Address review comments.
* Address review comments.
---
.../fhir/catalog/ComponentListFragment.kt | 3 +-
.../fhir/catalog/ComponentListViewModel.kt | 3 +-
.../fhir/catalog/DemoQuestionnaireFragment.kt | 42 +++++++++--
.../fhir/catalog/LayoutListFragment.kt | 3 +-
.../fhir/catalog/LayoutListViewModel.kt | 6 +-
.../fhir/catalog/ModalBottomSheetFragment.kt | 69 +++++++++++++++++++
catalog/src/main/res/drawable/ic_icon.xml | 13 ++++
.../layout/fragment_modal_bottom_sheet.xml | 38 ++++++++++
catalog/src/main/res/menu/component_menu.xml | 13 ++++
.../res/menu/{menu.xml => layout_menu.xml} | 0
catalog/src/main/res/navigation/nav_graph.xml | 16 +++++
catalog/src/main/res/values/strings.xml | 4 ++
catalog/src/main/res/values/styles.xml | 13 ++++
13 files changed, 213 insertions(+), 10 deletions(-)
create mode 100644 catalog/src/main/java/com/google/android/fhir/catalog/ModalBottomSheetFragment.kt
create mode 100644 catalog/src/main/res/drawable/ic_icon.xml
create mode 100644 catalog/src/main/res/layout/fragment_modal_bottom_sheet.xml
create mode 100644 catalog/src/main/res/menu/component_menu.xml
rename catalog/src/main/res/menu/{menu.xml => layout_menu.xml} (100%)
diff --git a/catalog/src/main/java/com/google/android/fhir/catalog/ComponentListFragment.kt b/catalog/src/main/java/com/google/android/fhir/catalog/ComponentListFragment.kt
index a4977ec30f..b70f9bd860 100644
--- a/catalog/src/main/java/com/google/android/fhir/catalog/ComponentListFragment.kt
+++ b/catalog/src/main/java/com/google/android/fhir/catalog/ComponentListFragment.kt
@@ -76,7 +76,8 @@ class ComponentListFragment : Fragment(R.layout.component_list_fragment) {
.navigate(
ComponentListFragmentDirections.actionComponentsFragmentToGalleryQuestionnaireFragment(
context?.getString(component.textId) ?: "",
- component.questionnaireFile
+ component.questionnaireFile,
+ component.workflow
)
)
}
diff --git a/catalog/src/main/java/com/google/android/fhir/catalog/ComponentListViewModel.kt b/catalog/src/main/java/com/google/android/fhir/catalog/ComponentListViewModel.kt
index c5f89ac281..c1f9f72bae 100644
--- a/catalog/src/main/java/com/google/android/fhir/catalog/ComponentListViewModel.kt
+++ b/catalog/src/main/java/com/google/android/fhir/catalog/ComponentListViewModel.kt
@@ -32,7 +32,8 @@ class ComponentListViewModel(application: Application, private val state: SavedS
enum class Component(
@DrawableRes val iconId: Int,
@StringRes val textId: Int,
- val questionnaireFile: String
+ val questionnaireFile: String,
+ val workflow: WorkflowType = WorkflowType.COMPONENT
) {
SINGLE_CHOICE(
R.drawable.ic_singlechoice,
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 81c95552f9..a643e3eb86 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
@@ -29,18 +29,21 @@ import androidx.core.os.bundleOf
import androidx.fragment.app.Fragment
import androidx.fragment.app.add
import androidx.fragment.app.commit
+import androidx.fragment.app.setFragmentResultListener
import androidx.fragment.app.viewModels
import androidx.lifecycle.lifecycleScope
import androidx.navigation.fragment.NavHostFragment
import androidx.navigation.fragment.findNavController
import androidx.navigation.fragment.navArgs
-import com.google.android.fhir.catalog.QuestionnaireContainerFragment.Companion.QUESTIONNAIRE_FRAGMENT_TAG
+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 kotlinx.coroutines.launch
class DemoQuestionnaireFragment : Fragment() {
private val viewModel: DemoQuestionnaireViewModel by viewModels()
private val args: DemoQuestionnaireFragmentArgs by navArgs()
+ private var isErrorState = false
override fun onCreateView(
inflater: LayoutInflater,
@@ -53,6 +56,9 @@ class DemoQuestionnaireFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
+ setFragmentResultListener(REQUEST_ERROR_KEY) { _, bundle ->
+ isErrorState = bundle.getBoolean(BUNDLE_ERROR_KEY)
+ }
updateArguments()
if (savedInstanceState == null) {
addQuestionnaireFragment()
@@ -76,13 +82,17 @@ class DemoQuestionnaireFragment : Fragment() {
onSubmitQuestionnaireClick()
true
}
+ R.id.error_menu -> {
+ launchModalBottomSheetFragment()
+ true
+ }
else -> super.onOptionsItemSelected(item)
}
}
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
super.onCreateOptionsMenu(menu, inflater)
- inflater.inflate(R.menu.menu, menu)
+ inflater.inflate(getMenu(), menu)
}
private fun setUpActionBar() {
@@ -121,9 +131,16 @@ class DemoQuestionnaireFragment : Fragment() {
}
private fun getThemeId(): Int {
- return when (args.questionnaireFilePathKey) {
- "default_layout_questionnaire.json" -> R.style.Theme_Androidfhir_layout
- else -> R.style.Theme_Androidfhir
+ return when (args.workflow) {
+ WorkflowType.DEFAULT -> R.style.Theme_Androidfhir_layout
+ WorkflowType.COMPONENT, WorkflowType.PAGINATED -> R.style.Theme_Androidfhir
+ }
+ }
+
+ private fun getMenu(): Int {
+ return when (args.workflow) {
+ WorkflowType.DEFAULT, WorkflowType.PAGINATED -> R.menu.layout_menu
+ WorkflowType.COMPONENT -> R.menu.component_menu
}
}
@@ -147,7 +164,22 @@ class DemoQuestionnaireFragment : Fragment() {
)
}
+ private fun launchModalBottomSheetFragment() {
+ findNavController()
+ .navigate(
+ DemoQuestionnaireFragmentDirections.actionGalleryQuestionnaireFragmentToModalBottomSheet(
+ isErrorState
+ )
+ )
+ }
+
companion object {
const val QUESTIONNAIRE_FRAGMENT_TAG = "questionnaire-fragment-tag"
}
}
+
+enum class WorkflowType {
+ COMPONENT,
+ DEFAULT,
+ PAGINATED
+}
diff --git a/catalog/src/main/java/com/google/android/fhir/catalog/LayoutListFragment.kt b/catalog/src/main/java/com/google/android/fhir/catalog/LayoutListFragment.kt
index 87ae06c25b..89eccbdc44 100644
--- a/catalog/src/main/java/com/google/android/fhir/catalog/LayoutListFragment.kt
+++ b/catalog/src/main/java/com/google/android/fhir/catalog/LayoutListFragment.kt
@@ -71,7 +71,8 @@ class LayoutListFragment : Fragment(R.layout.layout_list_fragment) {
.navigate(
LayoutListFragmentDirections.actionLayoutsFragmentToGalleryQuestionnaireFragment(
context?.getString(layout.textId) ?: "",
- layout.questionnaireFileName
+ layout.questionnaireFileName,
+ layout.workflow
)
)
}
diff --git a/catalog/src/main/java/com/google/android/fhir/catalog/LayoutListViewModel.kt b/catalog/src/main/java/com/google/android/fhir/catalog/LayoutListViewModel.kt
index a6da2c65a2..b734ecf614 100644
--- a/catalog/src/main/java/com/google/android/fhir/catalog/LayoutListViewModel.kt
+++ b/catalog/src/main/java/com/google/android/fhir/catalog/LayoutListViewModel.kt
@@ -32,12 +32,14 @@ class LayoutListViewModel(application: Application, private val state: SavedStat
enum class Layout(
@DrawableRes val iconId: Int,
@StringRes val textId: Int,
- val questionnaireFileName: String
+ val questionnaireFileName: String,
+ val workflow: WorkflowType = WorkflowType.PAGINATED
) {
DEFAULT(
R.drawable.ic_defaultlayout,
R.string.layout_name_default_text,
- "default_layout_questionnaire.json"
+ "default_layout_questionnaire.json",
+ WorkflowType.DEFAULT
),
PAGINATED(
R.drawable.ic_paginatedlayout,
diff --git a/catalog/src/main/java/com/google/android/fhir/catalog/ModalBottomSheetFragment.kt b/catalog/src/main/java/com/google/android/fhir/catalog/ModalBottomSheetFragment.kt
new file mode 100644
index 0000000000..0626571962
--- /dev/null
+++ b/catalog/src/main/java/com/google/android/fhir/catalog/ModalBottomSheetFragment.kt
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2021 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.catalog
+
+import android.os.Bundle
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import android.widget.Button
+import androidx.core.os.bundleOf
+import androidx.fragment.app.setFragmentResult
+import androidx.navigation.fragment.NavHostFragment
+import androidx.navigation.fragment.navArgs
+import com.google.android.material.bottomsheet.BottomSheetDialogFragment
+
+class ModalBottomSheetFragment : BottomSheetDialogFragment() {
+ private val args: ModalBottomSheetFragmentArgs by navArgs()
+
+ override fun onCreateView(
+ inflater: LayoutInflater,
+ container: ViewGroup?,
+ savedInstanceState: Bundle?
+ ): View? {
+ return inflater.inflate(R.layout.fragment_modal_bottom_sheet, container, false)
+ }
+
+ override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
+ super.onViewCreated(view, savedInstanceState)
+ val showHideErrorButton = view.findViewById