Skip to content

Commit

Permalink
Merge pull request #56 from d-tree-org/update-app-for-new-resources
Browse files Browse the repository at this point in the history
Update app for new fhir resources format
  • Loading branch information
sevenreup committed May 27, 2024
2 parents 7e3834c + 0678424 commit 2b04f0f
Show file tree
Hide file tree
Showing 115 changed files with 3,186 additions and 1,266 deletions.
45 changes: 21 additions & 24 deletions .github/workflows/apk-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,36 +62,33 @@ jobs:
env:
KEYSTORE_PROPERTIES: ${{ secrets.KEYSTORE_PROPERTIES }}

- name: Spotless check quest application
run: ./gradlew :quest:spotlessCheck
working-directory: android
# - name: Spotless check quest application
# run: ./gradlew :quest:spotlessCheck
# working-directory: android

- name: Generate AAB (Android App Bundle) file
if: ${{ false }}
run: ./gradlew :quest:bundle${{steps.product-flavor.outputs.idCapitalized}} -x :quest:test${{steps.product-flavor.outputs.idCapitalized}}DebugUnitTest --stacktrace
working-directory: android
# - name: Generate AAB (Android App Bundle) file
# if: ${{ false }}
# run: ./gradlew :quest:bundle${{steps.product-flavor.outputs.idCapitalized}} -x :quest:test${{steps.product-flavor.outputs.idCapitalized}}DebugUnitTest --stacktrace
# working-directory: android

- name: Upload AAB file to tag assets
if: ${{ false }}
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: android/quest/build/outputs/bundle/${{steps.product-flavor.outputs.id}}/release/quest-${{steps.product-flavor.outputs.id}}-release.aab
asset_name: "quest-$tag.aab"
tag: ${{ github.ref }}
overwrite: true
# - name: Upload AAB file to tag assets
# if: ${{ false }}
# uses: svenstaro/upload-release-action@v2
# with:
# repo_token: ${{ secrets.GITHUB_TOKEN }}
# file: android/quest/build/outputs/bundle/${{steps.product-flavor.outputs.id}}/release/quest-${{steps.product-flavor.outputs.id}}-release.aab
# asset_name: "quest-$tag.aab"
# tag: ${{ github.ref }}
# overwrite: true

- name: Generate APK (Android App PacKage) file
run: ./gradlew :quest:assemble${{steps.product-flavor.outputs.idCapitalized}} -x :quest:test${{steps.product-flavor.outputs.idCapitalized}}DebugUnitTest --stacktrace
working-directory: android

- name: Upload APK file to tag assets
uses: svenstaro/upload-release-action@v2
uses: wzieba/Firebase-Distribution-Github-Action@v1
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: android/quest/build/outputs/apk/${{steps.product-flavor.outputs.id}}/release/quest-${{steps.product-flavor.outputs.id}}-release.apk
asset_name: "quest-$tag.apk"
tag: ${{ github.ref }}
prerelease: ${{ contains(github.ref, '-alpha') || contains(github.ref, '-beta') }}
overwrite: true

appId: ${{secrets.FIREBASE_APP_ID}}
serviceCredentialsFileContent: ${{ secrets.CREDENTIAL_FILE_CONTENT }}
groups: dev
file: android/quest/build/outputs/apk/${{steps.product-flavor.outputs.id}}/release/quest-${{steps.product-flavor.outputs.id}}-release.apk
15 changes: 14 additions & 1 deletion android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ plugins {
id("com.google.gms.google-services") version "4.3.14" apply false
id("com.google.firebase.firebase-perf") version "1.4.2" apply false
id("com.google.firebase.crashlytics") version "2.9.5"
id("com.google.firebase.appdistribution") version "5.0.0" apply false
}

allprojects {
Expand All @@ -35,6 +36,18 @@ allprojects {
mavenCentral()
maven(url = "https://oss.sonatype.org/content/repositories/snapshots")
maven(url = "https://jcenter.bintray.com/")
ProjectProperties.readProperties("local.properties")
.takeIf { it.getProperty("dtreeRepositoryUsername") != null && it.getProperty("dtreeRepositoryPassword") != null }
?.let {
maven {
url = uri("https://maven.pkg.github.com/d-tree-org/android-fhir")
name = "dtreeRepository"
credentials {
username = it["dtreeRepositoryUsername"]?.toString()
password = it["dtreeRepositoryPassword"]?.toString()
}
}
}
maven {
name = "fhirsdk"
url = uri("/Users/ndegwamartin/.m2.dev/fhirsdk")
Expand All @@ -45,7 +58,7 @@ allprojects {
subprojects {
apply {
plugin("com.diffplug.spotless")
plugin( "jacoco")
plugin("jacoco")
}

configure<SpotlessExtension> {
Expand Down
19 changes: 19 additions & 0 deletions android/buildSrc/src/main/kotlin/Properties.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import java.io.File
import java.io.FileInputStream
import java.io.InputStreamReader
import java.util.Properties

object ProjectProperties {
fun readProperties(file: String): Properties {
val properties = Properties()
val localProperties = File(file)
if (localProperties.isFile) {
InputStreamReader(FileInputStream(localProperties), Charsets.UTF_8).use { reader
->
properties.load(reader)
}
} else println("\u001B[34mFILE_NOT_FOUND_EXCEPTION: File $file not found\u001B[0m")

return properties
}
}
22 changes: 2 additions & 20 deletions android/buildSrc/src/main/kotlin/fhir-properties.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import java.io.FileInputStream
import java.io.InputStreamReader
import java.util.Properties

val fhirAuthArray = arrayOf(
"FHIR_BASE_URL", "OAUTH_BASE_URL", "OAUTH_CIENT_ID", "OAUTH_CLIENT_SECRET", "OAUTH_SCOPE", "APP_ID"
)
Expand All @@ -10,7 +6,7 @@ val keystoreAuthArray = arrayOf(
"KEYSTORE_ALIAS", "KEY_PASSWORD", "KEYSTORE_PASSWORD"
)

val localProperties = readProperties((properties["localPropertiesFile"] ?: "${rootProject.projectDir}/local.properties").toString())
val localProperties = ProjectProperties.readProperties((properties["localPropertiesFile"] ?: "${rootProject.projectDir}/local.properties").toString())

fhirAuthArray.forEach { property ->
extra.set(property, localProperties.getProperty(property, when {
Expand All @@ -20,22 +16,8 @@ fhirAuthArray.forEach { property ->
))
}


val keystoreProperties = readProperties((properties["keystorePropertiesFile"] ?: "${rootProject.projectDir}/keystore.properties").toString())
val keystoreProperties = ProjectProperties.readProperties((properties["keystorePropertiesFile"] ?: "${rootProject.projectDir}/keystore.properties").toString())

keystoreAuthArray.forEach { property ->
extra.set(property, keystoreProperties.getProperty(property, "sample_$property"))
}

fun readProperties(file: String): Properties {
val properties = Properties()
val localProperties = File(file)
if (localProperties.isFile) {
InputStreamReader(FileInputStream(localProperties), Charsets.UTF_8).use { reader
->
properties.load(reader)
}
} else println("\u001B[34mFILE_NOT_FOUND_EXCEPTION: File $file not found\u001B[0m")

return properties
}
171 changes: 119 additions & 52 deletions android/dataclerk/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ plugins {
id("com.google.firebase.firebase-perf")
id("com.google.gms.google-services")
id("com.google.firebase.crashlytics")
id("com.google.firebase.appdistribution")
}

kotlin { jvmToolchain(17) }
Expand All @@ -31,6 +32,7 @@ android {
buildConfigField("String", "FHIR_BASE_URL", """"${project.extra["FHIR_BASE_URL"]}"""")
buildConfigField("String", "OAUTH_BASE_URL", """"${project.extra["OAUTH_BASE_URL"]}"""")
buildConfigField("String", "OAUTH_CIENT_ID", """"${project.extra["OAUTH_CIENT_ID"]}"""")
buildConfigField("String", "APP_ID", """"${project.extra["APP_ID"]}"""")
buildConfigField(
"String",
"OAUTH_CLIENT_SECRET",
Expand All @@ -42,33 +44,63 @@ android {
vectorDrawables { useSupportLibrary = true }
}

// signingConfigs {
// release {
//
// v1SigningEnabled false
// v2SigningEnabled true
//
// keyAlias System.getenv("KEYSTORE_ALIAS")?: project.KEYSTORE_ALIAS
// keyPassword System.getenv("KEY_PASSWORD") ?: project.KEY_PASSWORD
// storePassword System.getenv("KEYSTORE_PASSWORD") ?: project.KEYSTORE_PASSWORD
// storeFile file(System.getProperty("user.home") + "/fhircore.keystore.jks")
// }
// }
signingConfigs {
create("release") {
enableV1Signing = false
enableV2Signing = true

keyAlias = System.getenv("KEYSTORE_ALIAS") ?: """${project.extra["KEYSTORE_ALIAS"]}"""
keyPassword = System.getenv("KEY_PASSWORD") ?: """${project.extra["KEY_PASSWORD"]}"""
storePassword =
System.getenv("KEYSTORE_PASSWORD") ?: """${project.extra["KEYSTORE_PASSWORD"]}"""
storeFile = file(System.getProperty("user.home") + "/fhircore.keystore.jks")
}
}

buildTypes {
debug {
// enableUnitTestCoverage true
resValue("string", "authenticator_account_type", "\"${android.defaultConfig.applicationId}\"")
}
release {
resValue("string", "authenticator_account_type", "\"${android.defaultConfig.applicationId}\"")
// minifyEnabled false
// proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"),
// "proguard-rules.pro"
// signingConfig signingConfigs.release
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
signingConfig = signingConfigs.getByName("release")
// firebaseCrashlytics {
// nativeSymbolUploadEnabled false
// isNativeSymbolUploadEnabled = false
// }
firebaseAppDistribution {
artifactType = "APK"
releaseNotes = "Update"
}
}
}

packaging {
resources {
excludes +=
listOf(
"META-INF/ASL-2.0.txt",
"META-INF/LGPL-3.0.txt",
"license.html",
"readme.html",
"META-INF/DEPENDENCIES",
"META-INF/LICENSE",
"META-INF/LICENSE.txt",
"META-INF/license.txt",
"META-INF/license.html",
"META-INF/LICENSE.md",
"META-INF/NOTICE",
"META-INF/NOTICE.txt",
"META-INF/NOTICE.md",
"META-INF/notice.txt",
"META-INF/ASL2.0",
"META-INF/ASL-2.0.txt",
"META-INF/LGPL-3.0.txt",
"META-INF/sun-jaxb.episode",
"META-INF/*.kotlin_module",
"META-INF/AL2.0",
"META-INF/LGPL2.1",
)
}
}

Expand Down Expand Up @@ -99,32 +131,51 @@ android {
}
}
}
packaging {
resources {
excludes +=
listOf(
"META-INF/ASL-2.0.txt",
"META-INF/LGPL-3.0.txt",
"license.html",
"readme.html",
"META-INF/DEPENDENCIES",
"META-INF/LICENSE",
"META-INF/LICENSE.txt",
"META-INF/license.txt",
"META-INF/license.html",
"META-INF/LICENSE.md",
"META-INF/NOTICE",
"META-INF/NOTICE.txt",
"META-INF/NOTICE.md",
"META-INF/notice.txt",
"META-INF/ASL2.0",
"META-INF/ASL-2.0.txt",
"META-INF/LGPL-3.0.txt",
"META-INF/sun-jaxb.episode",
"META-INF/*.kotlin_module",
"META-INF/AL2.0",
"META-INF/LGPL2.1",
)

flavorDimensions += "apps"

productFlavors {
create("exposedInfant") {
dimension = "apps"
applicationIdSuffix = ".exposedInfant"
versionNameSuffix = "-exposedInfant"
versionCode = 1
versionName = "0.0.1"
}
create("artClient") {
dimension = "apps"
applicationIdSuffix = ".artClient"
versionNameSuffix = "-artClient"
versionCode = 1
versionName = "0.0.1"
}
create("exposedInfantDev") {
dimension = "apps"
applicationIdSuffix = ".exposedInfantDev"
versionNameSuffix = "-exposedInfantDev"
versionCode = 3
versionName = "0.0.3"
}
create("artClientDev") {
dimension = "apps"
applicationIdSuffix = ".artClientDev"
versionNameSuffix = "-artClientDev"
versionCode = 3
versionName = "0.0.3"
}
create("exposedInfantStaging") {
dimension = "apps"
applicationIdSuffix = ".exposedInfantStaging"
versionNameSuffix = "-exposedInfantStaging"
versionCode = 1
versionName = "0.0.1"
}
create("artClientStaging") {
dimension = "apps"
applicationIdSuffix = ".artClientStaging"
versionNameSuffix = "-artClientStaging"
versionCode = 1
versionName = "0.0.1"
}
}

Expand Down Expand Up @@ -153,27 +204,43 @@ dependencies {
implementation("androidx.compose.material3:material3")
implementation("androidx.paging:paging-compose:3.2.1")

implementation("com.github.anrwatchdog:anrwatchdog:1.4.0")

// Hilt - Dependency Injection
implementation("com.google.dagger:hilt-android:${Deps.versions.hiltVersion}")
kapt("com.google.dagger:hilt-compiler:${Deps.versions.hiltVersion}")

testImplementation(Deps.junit5_api)
testRuntimeOnly(Deps.junit5_engine)
testRuntimeOnly(Deps.junit5_engine_vintage)
testImplementation(Deps.robolectric)
testImplementation(Deps.atsl.core)
testImplementation(Deps.atsl.ext_junit)
testImplementation(Deps.atsl.ext_junit_ktx)
testImplementation(Deps.coroutines.test)
testImplementation(Deps.androidx.core_test)
debugImplementation(Deps.fragment_testing)
releaseImplementation(Deps.fragment_testing)
testImplementation(Deps.mockk)
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.3")

// analytics
implementation(platform("com.google.firebase:firebase-bom:32.7.3"))

implementation("com.google.firebase:firebase-perf-ktx")
implementation("com.google.firebase:firebase-crashlytics-ktx")
implementation("com.google.firebase:firebase-analytics-ktx")

testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
androidTestImplementation(platform("androidx.compose:compose-bom:2024.02.01"))
androidTestImplementation("androidx.compose.ui:ui-test-junit4")
// Hilt test dependencies
testImplementation("com.google.dagger:hilt-android-testing:${Deps.versions.hiltVersion}")
kaptTest("com.google.dagger:hilt-compiler:${Deps.versions.hiltVersion}")
kaptTest("com.google.dagger:hilt-android-compiler:${Deps.versions.hiltVersion}")

debugImplementation("androidx.compose.ui:ui-tooling")
androidTestImplementation(Deps.atsl.ext_junit)
androidTestImplementation(Deps.atsl.espresso)
debugImplementation("androidx.compose.ui:ui-test-manifest")
testImplementation("androidx.compose.ui:ui-test-junit4")
// debugImplementation because LeakCanary should only run in debug builds.
// debugImplementation "com.squareup.leakcanary:leakcanary-android:2.7"
}

kapt { correctErrorTypes = true }
Expand Down
5 changes: 5 additions & 0 deletions android/dataclerk/src/artClient/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Data Clerk ART</string>
<string name="authenticator_account_type" translatable="false">org.dtree.fhircore.dataclerk.artClient</string>
</resources>
5 changes: 5 additions & 0 deletions android/dataclerk/src/artClientDev/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Data Clerk ART</string>
<string name="authenticator_account_type" translatable="false">org.dtree.fhircore.dataclerk.artClientDev</string>
</resources>
Loading

0 comments on commit 2b04f0f

Please sign in to comment.