Skip to content

Commit

Permalink
Merge branch 'google:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
jingtang10 authored Jun 20, 2024
2 parents 96b5c5f + ced8527 commit a3b6a01
Show file tree
Hide file tree
Showing 97 changed files with 3,022 additions and 517 deletions.
17 changes: 15 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ jobs:
permissions:
actions: read
contents: read
packages: write

strategy:
fail-fast: false
Expand All @@ -75,9 +76,21 @@ jobs:
- name: Check with Gradle
run: ./gradlew check --scan --full-stacktrace

- name: Publish Maven packages to GitHub Packages
if: ${{ github.event_name == 'push' }}
run: ./gradlew publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPOSITORY_URL: 'https://maven.pkg.github.com/google/android-fhir'
# Use SNAPSHOT Prefix to follow Maven convention
ARTIFACT_VERSION_SUFFIX: SNAPSHOT

- name: Release artifacts to local repo
run: ./gradlew publishReleasePublicationToCIRepository --scan
- name: Upload maven repo
env:
ARTIFACT_VERSION_SUFFIX: build_${{ github.run_id }}

- name: Upload artifact maven-repository.zip
uses: actions/upload-artifact@v4
with:
name: maven-repository
Expand Down Expand Up @@ -118,7 +131,7 @@ jobs:

- name: Setup GitHub Pages
if: ${{ github.event_name == 'push' }}
uses: actions/configure-pages@v4
uses: actions/configure-pages@v5

- name: Upload site/ directory as GitHub Pages artifact
if: ${{ github.event_name == 'push' }}
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ dependencies {
implementation("com.spotify.ruler:ruler-gradle-plugin:1.4.0")

implementation("ca.uhn.hapi.fhir:hapi-fhir-structures-r4:6.10.0")
implementation("com.squareup:kotlinpoet:1.15.3")
implementation("com.squareup:kotlinpoet:1.17.0")
}
19 changes: 16 additions & 3 deletions buildSrc/src/main/kotlin/Releases.kt
Original file line number Diff line number Diff line change
Expand Up @@ -119,20 +119,33 @@ fun Project.publishArtifact(artifact: LibraryArtifact) {
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
}
repositories {
maven {
name = "CI"
url = uri("file://${rootProject.buildDir}/ci-repo")
url =
if (System.getenv("REPOSITORY_URL") != null) {
// REPOSITORY_URL is defined in .github/workflows/build.yml
uri(System.getenv("REPOSITORY_URL"))
} else {
uri("file://${rootProject.buildDir}/ci-repo")
}
version =
if (project.providers.environmentVariable("GITHUB_ACTIONS").isPresent) {
"${artifact.version}-build_${System.getenv("GITHUB_RUN_ID")}"
// ARTIFACT_VERSION_SUFFIX is defined in .github/workflows/build.yml
"${artifact.version}-${System.getenv("ARTIFACT_VERSION_SUFFIX")}"
} else {
artifact.version
}
if (System.getenv("GITHUB_TOKEN") != null) {
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions catalog/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ android {

buildTypes {
release {
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"))
isMinifyEnabled = true
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
}
compileOptions {
Expand Down
21 changes: 21 additions & 0 deletions catalog/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.kts
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021-2023 Google LLC
* Copyright 2021-2024 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 @@ -20,10 +20,9 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Button
import android.widget.CheckBox
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

Expand All @@ -40,25 +39,16 @@ class ModalBottomSheetFragment : BottomSheetDialogFragment() {

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
val showHideErrorButton = view.findViewById<Button>(R.id.errorToggleButton)
showHideErrorButton.text =
requireContext()
.getString(
if (args.errorState) {
R.string.hide_error_state
} else {
R.string.show_error_state
},
)
showHideErrorButton.setOnClickListener {

val showHideErrorCheckBox = view.findViewById<CheckBox>(R.id.errorToggleCheckBox)
showHideErrorCheckBox.isChecked = args.errorState
showHideErrorCheckBox.setOnCheckedChangeListener { _, isChecked ->
setFragmentResult(
REQUEST_ERROR_KEY,
bundleOf(
BUNDLE_ERROR_KEY to
(showHideErrorButton.text == requireContext().getString(R.string.show_error_state)),
BUNDLE_ERROR_KEY to isChecked,
),
)
NavHostFragment.findNavController(this).navigateUp()
}
(activity as? MainActivity)?.showOpenQuestionnaireMenu(false)
}
Expand Down
15 changes: 6 additions & 9 deletions catalog/src/main/res/layout/fragment_modal_bottom_sheet.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
android:layout_height="match_parent"
tools:context=".ModalBottomSheetFragment"
>

<TextView
android:id="@+id/optionsTextView"
android:layout_width="wrap_content"
Expand All @@ -19,13 +18,12 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>

<Button
style="@style/Widget.App.MaterialComponents.Button"
android:id="@+id/errorToggleButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="60dp"
<CheckBox
android:id="@+id/errorToggleCheckBox"
style="@style/Questionnaire.CheckBoxStyle"
android:layout_width="280dp"
android:layout_height="68dp"
android:layout_marginTop="24dp"
android:layout_marginBottom="116dp"
android:text="@string/show_error_state"
android:textAllCaps="false"
Expand All @@ -34,5 +32,4 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/optionsTextView"
/>

</androidx.constraintlayout.widget.ConstraintLayout>
1 change: 0 additions & 1 deletion catalog/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
>Below is the JSON code</string>
<string name="submit">Submit</string>
<string name="show_error_state">Show error state</string>
<string name="hide_error_state">Hide error state</string>
<string name="options">Options</string>
<string name="error">Error</string>
<string name="widgets">Widgets</string>
Expand Down
1 change: 1 addition & 0 deletions datacapture/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ android {
testInstrumentationRunner = Dependencies.androidJunitRunner
// Need to specify this to prevent junit runner from going deep into our dependencies
testInstrumentationRunnerArguments["package"] = "com.google.android.fhir.datacapture"
consumerProguardFile("proguard-rules.pro")
}

buildFeatures { viewBinding = true }
Expand Down
11 changes: 11 additions & 0 deletions datacapture/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## HAPI Strucutres need to be kept beause
# 1. Reflection is used in resource extraction as the FHIR Path expression is then translated to field names to locate data elements in FHIR resources.
# 2. In HAPI Strucures, ClassLoader is used to load classes from different packages that are hardcoded.
-keep class ca.uhn.fhir.** { *; }
-keep class org.hl7.fhir.** { *; }
# Used by hapi's XmlUtil which is internally used by hapi's FHIRPathEngine.
-keep class com.ctc.wstx.stax.** { *; }
# Used by HapiWorkerContext (fhirpath engine in QuestionnaireViewModel)
-keep class com.github.benmanes.caffeine.cache.** { *; }
## hapi libs ends
-ignorewarnings
24 changes: 24 additions & 0 deletions datacapture/sampledata/component_repeated_group.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"resourceType": "Questionnaire",
"item": [
{
"linkId": "1",
"type": "group",
"text": "Repeated Group",
"repeats": true,
"item": [
{
"linkId": "1-1",
"text": "Sample date question",
"type": "date",
"extension": [
{
"url": "http://hl7.org/fhir/StructureDefinition/entryFormat",
"valueString": "yyyy-mm-dd"
}
]
}
]
}
]
}
20 changes: 20 additions & 0 deletions datacapture/sampledata/repeated_group_response.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"resourceType": "QuestionnaireResponse",
"item": [
{
"linkId": "1",
"text": "Repeated Group",
"item": [
{
"linkId": "1-1",
"text": "Sample date question",
"answer": [
{
"valueDate": "2024-06-03"
}
]
}
]
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class PhoneNumberViewHolderFactoryInstrumentedTest {
}

@Test
fun createViewHolder_shouldReturn_phoneNumberViewHolder() {
fun createViewHolder_phoneNumberViewHolderFactory_returnsViewHolder() {
val viewHolderFromAdapter =
questionnaireEditAdapter.createViewHolder(
parent,
Expand All @@ -74,8 +74,13 @@ class PhoneNumberViewHolderFactoryInstrumentedTest {
subtype = QuestionnaireViewHolderType.PHONE_NUMBER.value,
)
.viewType,
) as QuestionnaireEditAdapter.ViewHolder.QuestionHolder
assertThat(
viewHolderFromAdapter.holder.itemView
.findViewById<TextInputEditText>(R.id.text_input_edit_text)
.visibility,
)
assertThat(viewHolderFromAdapter).isInstanceOf(viewHolder::class.java)
.isEqualTo(View.VISIBLE)
}

@Test
Expand Down
Loading

0 comments on commit a3b6a01

Please sign in to comment.