Skip to content

Commit 57b4773

Browse files
committed
Merge branch 'master' into master-release
2 parents 75f243d + 9b1cb4f commit 57b4773

File tree

45 files changed

+794
-480
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+794
-480
lines changed

buildSrc/src/main/kotlin/Releases.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ object Releases {
4848

4949
object Engine : LibraryArtifact {
5050
override val artifactId = "engine"
51-
override val version = "0.1.0-beta03-preview10-SNAPSHOT"
51+
override val version = "0.1.0-beta04"
5252
override val name = "Android FHIR Engine Library"
5353
}
5454

catalog/src/main/java/com/google/android/fhir/catalog/ComponentListFragment.kt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,13 @@ class ComponentListFragment : Fragment(R.layout.component_list_fragment) {
9999
fileName = component.questionnaireFile,
100100
),
101101
questionnaireWithValidationJsonStringKey =
102-
getQuestionnaireJsonStringFromAssets(
103-
context = requireContext(),
104-
backgroundContext = coroutineContext,
105-
fileName = component.questionnaireFileWithValidation,
106-
),
102+
component.questionnaireFileWithValidation?.let {
103+
getQuestionnaireJsonStringFromAssets(
104+
context = requireContext(),
105+
backgroundContext = coroutineContext,
106+
fileName = it
107+
)
108+
},
107109
workflow = component.workflow
108110
)
109111
)

catalog/src/main/java/com/google/android/fhir/catalog/ComponentListViewModel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class ComponentListViewModel(application: Application, private val state: SavedS
4444
* Path to the questionnaire json file with some or all required fields. If the user doesn't
4545
* answer the required questions, an error may be displayed on the particular question.
4646
*/
47-
val questionnaireFileWithValidation: String = "",
47+
val questionnaireFileWithValidation: String? = null,
4848
val workflow: WorkflowType = WorkflowType.COMPONENT
4949
) {
5050
BOOLEAN_CHOICE(

catalog/src/main/java/com/google/android/fhir/catalog/QuestionnaireFileOperationUtil.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,13 @@ suspend fun getQuestionnaireJsonStringFromAssets(
2626
context: Context,
2727
backgroundContext: CoroutineContext,
2828
fileName: String
29-
): String {
29+
): String? {
3030
return withContext(backgroundContext) {
31-
context.assets.open(fileName).bufferedReader().use { it.readText() }
31+
if (fileName.isNotEmpty()) {
32+
context.assets.open(fileName).bufferedReader().use { it.readText() }
33+
} else {
34+
null
35+
}
3236
}
3337
}
3438

datacapture/src/main/java/com/google/android/fhir/datacapture/extensions/MoreLocalDates.kt

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2022 Google LLC
2+
* Copyright 2022-2023 Google LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,15 +23,19 @@ import java.lang.Character.isLetter
2323
import java.text.ParseException
2424
import java.time.LocalDate
2525
import java.time.ZoneId
26+
import java.time.chrono.IsoChronology
2627
import java.time.format.DateTimeFormatter
28+
import java.time.format.DateTimeFormatterBuilder
29+
import java.time.format.FormatStyle
2730
import java.util.Date
31+
import java.util.Locale
2832

2933
/**
3034
* Returns the first character that is not a letter in the given date pattern string (e.g. "/" for
31-
* "dd/mm/yyyy").
35+
* "dd/mm/yyyy") otherwise null.
3236
*/
33-
internal fun getDateSeparator(localeDatePattern: String): Char =
34-
localeDatePattern.filterNot { isLetter(it) }.first()
37+
internal fun getDateSeparator(localeDatePattern: String): Char? =
38+
localeDatePattern.filterNot { isLetter(it) }.firstOrNull()
3539

3640
/**
3741
* Converts date pattern to acceptable date pattern where 2 digits are expected for day(dd) and
@@ -112,3 +116,16 @@ internal fun LocalDate.format(pattern: String? = null): String {
112116
DateTimeFormatter.ofPattern(pattern).format(this)
113117
}
114118
}
119+
120+
/**
121+
* Medium and long format styles use alphabetical month names which are difficult for the user to
122+
* input. Use short format style which is always numerical.
123+
*/
124+
internal fun getLocalizedDatePattern(): String {
125+
return DateTimeFormatterBuilder.getLocalizedDateTimePattern(
126+
FormatStyle.SHORT,
127+
null,
128+
IsoChronology.INSTANCE,
129+
Locale.getDefault()
130+
)
131+
}

0 commit comments

Comments
 (0)