Skip to content

Commit

Permalink
Merge branch 'master' into master-release
Browse files Browse the repository at this point in the history
  • Loading branch information
ndegwamartin committed Sep 7, 2023
2 parents 75f243d + 9b1cb4f commit 57b4773
Show file tree
Hide file tree
Showing 45 changed files with 794 additions and 480 deletions.
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/Releases.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ object Releases {

object Engine : LibraryArtifact {
override val artifactId = "engine"
override val version = "0.1.0-beta03-preview10-SNAPSHOT"
override val version = "0.1.0-beta04"
override val name = "Android FHIR Engine Library"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,13 @@ class ComponentListFragment : Fragment(R.layout.component_list_fragment) {
fileName = component.questionnaireFile,
),
questionnaireWithValidationJsonStringKey =
getQuestionnaireJsonStringFromAssets(
context = requireContext(),
backgroundContext = coroutineContext,
fileName = component.questionnaireFileWithValidation,
),
component.questionnaireFileWithValidation?.let {
getQuestionnaireJsonStringFromAssets(
context = requireContext(),
backgroundContext = coroutineContext,
fileName = it
)
},
workflow = component.workflow
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class ComponentListViewModel(application: Application, private val state: SavedS
* Path to the questionnaire json file with some or all required fields. If the user doesn't
* answer the required questions, an error may be displayed on the particular question.
*/
val questionnaireFileWithValidation: String = "",
val questionnaireFileWithValidation: String? = null,
val workflow: WorkflowType = WorkflowType.COMPONENT
) {
BOOLEAN_CHOICE(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,13 @@ suspend fun getQuestionnaireJsonStringFromAssets(
context: Context,
backgroundContext: CoroutineContext,
fileName: String
): String {
): String? {
return withContext(backgroundContext) {
context.assets.open(fileName).bufferedReader().use { it.readText() }
if (fileName.isNotEmpty()) {
context.assets.open(fileName).bufferedReader().use { it.readText() }
} else {
null
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2022 Google LLC
* Copyright 2022-2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -23,15 +23,19 @@ import java.lang.Character.isLetter
import java.text.ParseException
import java.time.LocalDate
import java.time.ZoneId
import java.time.chrono.IsoChronology
import java.time.format.DateTimeFormatter
import java.time.format.DateTimeFormatterBuilder
import java.time.format.FormatStyle
import java.util.Date
import java.util.Locale

/**
* Returns the first character that is not a letter in the given date pattern string (e.g. "/" for
* "dd/mm/yyyy").
* "dd/mm/yyyy") otherwise null.
*/
internal fun getDateSeparator(localeDatePattern: String): Char =
localeDatePattern.filterNot { isLetter(it) }.first()
internal fun getDateSeparator(localeDatePattern: String): Char? =
localeDatePattern.filterNot { isLetter(it) }.firstOrNull()

/**
* Converts date pattern to acceptable date pattern where 2 digits are expected for day(dd) and
Expand Down Expand Up @@ -112,3 +116,16 @@ internal fun LocalDate.format(pattern: String? = null): String {
DateTimeFormatter.ofPattern(pattern).format(this)
}
}

/**
* Medium and long format styles use alphabetical month names which are difficult for the user to
* input. Use short format style which is always numerical.
*/
internal fun getLocalizedDatePattern(): String {
return DateTimeFormatterBuilder.getLocalizedDateTimePattern(
FormatStyle.SHORT,
null,
IsoChronology.INSTANCE,
Locale.getDefault()
)
}
Loading

0 comments on commit 57b4773

Please sign in to comment.