-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MWCore] Create Dataclerk App (#2630)
* rework auth items * init tagging * update register * update * update sync * update sync key * fix location syncs * fix activity listener * test fixes * fixes * replace app with default Update ConfigurationRegistryTest.kt * tests fixed * stuff * test fixes * Update CqlContentTest.kt * init * add tests * add tests * save * update appsettings * data clerks can log in * format * update * update * add sync status * update ui * update QuestViewmodel * Update AppScreen.kt * Update QuestionnaireActivity.kt * update update * Update LoginViewModel.kt * update sync status * update sync * Update TokenAuthenticator.kt * update icon * format * update auth * Update AppSettingActivityTest.kt * updates * update create button * Update DataClerkConfigService.kt * update resource tags * load patients * update data clerk * update patient details * update details * add pagination * add sync indicators to ui * reload on sync on the list * update * Update build.gradle * update * block to finish saving data * update * spotless run * Update network_security_config.xml * Update network_security_config.xml * Fix failed AppNotIdleException for some Compose tests robolectric/robolectric#7055 robolectric/robolectric#7055 (comment) * Disable catching of non-test related exceptions Kotlin/kotlinx.coroutines#3736 (comment) * add tests * Update SharedPreferencesHelperTest.kt * Update AndroidExtensions.kt * update tests * fix merge issues * add last updated * update network * fix pagination issues * add prod config --------- Co-authored-by: L≡ZRS <[email protected]>
- Loading branch information
Showing
67 changed files
with
2,617 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,185 @@ | ||
plugins { | ||
id 'com.android.application' | ||
id 'kotlin-android' | ||
id 'kotlin-kapt' | ||
id 'de.mannodermaus.android-junit5' version '1.9.3.0' | ||
id 'org.jetbrains.dokka' | ||
id 'org.jetbrains.kotlin.plugin.serialization' | ||
id 'jacoco' | ||
id 'dagger.hilt.android.plugin' | ||
id 'org.jetbrains.kotlin.android' | ||
id 'com.google.firebase.firebase-perf' | ||
id 'com.google.gms.google-services' | ||
id 'com.google.firebase.crashlytics' | ||
} | ||
|
||
apply from: '../properties.gradle' | ||
|
||
android { | ||
namespace 'org.dtree.fhircore.dataclerk' | ||
compileSdkVersion sdk_versions.compile_sdk | ||
|
||
defaultConfig { | ||
applicationId "org.dtree.fhircore.dataclerk" | ||
minSdkVersion sdk_versions.min_sdk | ||
targetSdkVersion sdk_versions.target_sdk | ||
versionCode 3 | ||
versionName "1.0.0" | ||
multiDexEnabled true | ||
|
||
buildConfigField("boolean", 'SKIP_AUTH_CHECK', "false") | ||
buildConfigField("String", 'FHIR_BASE_URL', "\"${FHIR_BASE_URL}\"") | ||
buildConfigField("String", 'OAUTH_BASE_URL', "\"${OAUTH_BASE_URL}\"") | ||
buildConfigField("String", 'OAUTH_CIENT_ID', "\"${OAUTH_CIENT_ID}\"") | ||
buildConfigField("String", 'OAUTH_CLIENT_SECRET', "\"${OAUTH_CLIENT_SECRET}\"") | ||
buildConfigField("String", 'OAUTH_SCOPE', "\"${OAUTH_SCOPE}\"") | ||
|
||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
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") | ||
// } | ||
// } | ||
|
||
buildTypes { | ||
debug { | ||
// testCoverageEnabled 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 | ||
// firebaseCrashlytics { | ||
// nativeSymbolUploadEnabled false | ||
// } | ||
} | ||
} | ||
|
||
compileOptions { | ||
coreLibraryDesugaringEnabled true | ||
sourceCompatibility JavaVersion.VERSION_11 | ||
targetCompatibility JavaVersion.VERSION_11 | ||
} | ||
|
||
kotlinOptions { | ||
jvmTarget = JavaVersion.VERSION_11.toString() | ||
freeCompilerArgs = ['-Xjvm-default=all-compatibility', '-opt-in=kotlin.RequiresOptIn'] | ||
} | ||
|
||
buildFeatures { | ||
compose true | ||
} | ||
|
||
composeOptions { | ||
kotlinCompilerExtensionVersion '1.4.8' | ||
} | ||
|
||
testOptions { | ||
execution 'ANDROIDX_TEST_ORCHESTRATOR' | ||
animationsDisabled true | ||
|
||
unitTests { | ||
includeAndroidResources = true | ||
returnDefaultValues = true | ||
all { | ||
beforeTest { testDescriptor -> | ||
println "${testDescriptor.className} > ${testDescriptor.name} STARTED" | ||
} | ||
} | ||
} | ||
} | ||
|
||
lintOptions { | ||
abortOnError false | ||
} | ||
|
||
configurations.all { | ||
resolutionStrategy { | ||
force "ca.uhn.hapi.fhir:org.hl7.fhir.utilities:5.5.7" | ||
} | ||
} | ||
|
||
packagingOptions { | ||
exclude 'META-INF/ASL-2.0.txt' | ||
exclude 'META-INF/LGPL-3.0.txt' | ||
exclude 'license.html' | ||
exclude 'readme.html' | ||
exclude 'META-INF/DEPENDENCIES' | ||
exclude 'META-INF/LICENSE' | ||
exclude 'META-INF/LICENSE.txt' | ||
exclude 'META-INF/license.txt' | ||
exclude 'META-INF/license.html' | ||
exclude 'META-INF/LICENSE.md' | ||
exclude 'META-INF/NOTICE' | ||
exclude 'META-INF/NOTICE.txt' | ||
exclude 'META-INF/NOTICE.md' | ||
exclude 'META-INF/notice.txt' | ||
exclude 'META-INF/ASL2.0' | ||
exclude 'META-INF/ASL-2.0.txt' | ||
exclude 'META-INF/LGPL-3.0.txt' | ||
exclude 'META-INF/sun-jaxb.episode' | ||
exclude("META-INF/*.kotlin_module") | ||
exclude("META-INF/AL2.0") | ||
exclude("META-INF/LGPL2.1") | ||
} | ||
} | ||
|
||
dependencies { | ||
coreLibraryDesugaring deps.desugar | ||
implementation(project(":engine")) | ||
|
||
implementation 'androidx.core:core-ktx:1.8.0' | ||
implementation platform('org.jetbrains.kotlin:kotlin-bom:1.8.0') | ||
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1' | ||
implementation 'androidx.activity:activity-compose:1.5.1' | ||
|
||
implementation deps.accompanist.swiperefresh | ||
|
||
implementation platform('androidx.compose:compose-bom:2022.10.00') | ||
implementation 'androidx.compose.ui:ui' | ||
implementation 'androidx.compose.ui:ui-graphics' | ||
implementation 'androidx.compose.ui:ui-tooling-preview' | ||
implementation 'androidx.compose.material3:material3' | ||
implementation "androidx.paging:paging-compose:3.2.0-rc01" | ||
|
||
//Hilt - Dependency Injection | ||
implementation "com.google.dagger:hilt-android:$hiltVersion" | ||
kapt "com.google.dagger:hilt-compiler:$hiltVersion" | ||
|
||
// analytics | ||
implementation platform('com.google.firebase:firebase-bom:31.2.0') | ||
|
||
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:2022.10.00') | ||
androidTestImplementation 'androidx.compose.ui:ui-test-junit4' | ||
debugImplementation 'androidx.compose.ui:ui-tooling' | ||
debugImplementation 'androidx.compose.ui:ui-test-manifest' | ||
} | ||
|
||
kapt { | ||
correctErrorTypes true | ||
} | ||
|
||
hilt { | ||
enableAggregatingTask = true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
# | ||
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"version": 3, | ||
"artifactType": { | ||
"type": "APK", | ||
"kind": "Directory" | ||
}, | ||
"applicationId": "org.dtree.fhircore.dataclerk", | ||
"variantName": "release", | ||
"elements": [ | ||
{ | ||
"type": "SINGLE", | ||
"filters": [], | ||
"attributes": [], | ||
"versionCode": 2, | ||
"versionName": "0.0.2", | ||
"outputFile": "dataclerk-release.apk" | ||
} | ||
], | ||
"elementType": "File" | ||
} |
38 changes: 38 additions & 0 deletions
38
...id/dataclerk/src/androidTest/java/org/dtree/fhircore/dataclerk/ExampleInstrumentedTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright 2021 Ona Systems, Inc | ||
* | ||
* 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 org.dtree.fhircore.dataclerk | ||
|
||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import androidx.test.platform.app.InstrumentationRegistry | ||
import org.junit.Assert.assertEquals | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* See [testing documentation](http://d.android.com/tools/testing). | ||
*/ | ||
@RunWith(AndroidJUnit4::class) | ||
class ExampleInstrumentedTest { | ||
@Test | ||
fun useAppContext() { | ||
// Context of the app under test. | ||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext | ||
assertEquals("org.dtree.fhircore.dataclerk", appContext.packageName) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<application android:name=".DataClerkApplication" | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme.NoActionBar" | ||
android:largeHeap="true" | ||
android:networkSecurityConfig="@xml/network_security_config"> | ||
<activity android:name=".ui.main.AppMainActivity"/> | ||
<service | ||
android:name="org.smartregister.fhircore.engine.auth.AuthAndroidService" | ||
android:exported="false"> | ||
<intent-filter> | ||
<action android:name="android.accounts.AccountAuthenticator" /> | ||
</intent-filter> | ||
|
||
<meta-data | ||
android:name="android.accounts.AccountAuthenticator" | ||
android:resource="@xml/authenticator" /> | ||
</service> | ||
|
||
<provider | ||
android:name="androidx.core.content.FileProvider" | ||
android:authorities="${applicationId}.fileprovider" | ||
|
||
android:grantUriPermissions="true"> | ||
<meta-data | ||
android:name="android.support.FILE_PROVIDER_PATHS" | ||
android:resource="@xml/file_paths" /> | ||
</provider> | ||
</application> | ||
|
||
</manifest> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
71 changes: 71 additions & 0 deletions
71
android/dataclerk/src/main/java/org/dtree/fhircore/dataclerk/DataClerkApplication.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Copyright 2021 Ona Systems, Inc | ||
* | ||
* 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 org.dtree.fhircore.dataclerk | ||
|
||
import android.app.Application | ||
import android.util.Log | ||
import androidx.hilt.work.HiltWorkerFactory | ||
import androidx.work.Configuration | ||
import com.google.android.fhir.datacapture.DataCaptureConfig | ||
import com.google.firebase.crashlytics.ktx.crashlytics | ||
import com.google.firebase.ktx.Firebase | ||
import com.google.firebase.perf.ktx.performance | ||
import dagger.hilt.android.HiltAndroidApp | ||
import javax.inject.Inject | ||
import org.dtree.fhircore.dataclerk.data.QuestXFhirQueryResolver | ||
import org.smartregister.fhircore.engine.data.remote.fhir.resource.ReferenceUrlResolver | ||
import org.smartregister.fhircore.engine.ui.questionnaire.QuestionnaireItemViewHolderFactoryMatchersProviderFactoryImpl | ||
import timber.log.Timber | ||
|
||
@HiltAndroidApp | ||
class DataClerkApplication : Application(), DataCaptureConfig.Provider, Configuration.Provider { | ||
private var configuration: DataCaptureConfig? = null | ||
|
||
@Inject lateinit var workerFactory: HiltWorkerFactory | ||
|
||
@Inject lateinit var referenceUrlResolver: ReferenceUrlResolver | ||
|
||
@Inject lateinit var xFhirQueryResolver: QuestXFhirQueryResolver | ||
|
||
override fun onCreate() { | ||
super.onCreate() | ||
|
||
if (BuildConfig.DEBUG) { | ||
Firebase.performance.isPerformanceCollectionEnabled = false | ||
Firebase.crashlytics.setCrashlyticsCollectionEnabled(false) | ||
Timber.plant(Timber.DebugTree()) | ||
} | ||
} | ||
|
||
override fun getDataCaptureConfig(): DataCaptureConfig { | ||
configuration = | ||
configuration | ||
?: DataCaptureConfig( | ||
urlResolver = referenceUrlResolver, | ||
xFhirQueryResolver = xFhirQueryResolver, | ||
questionnaireItemViewHolderFactoryMatchersProviderFactory = | ||
QuestionnaireItemViewHolderFactoryMatchersProviderFactoryImpl | ||
) | ||
return configuration as DataCaptureConfig | ||
} | ||
|
||
override fun getWorkManagerConfiguration(): Configuration = | ||
Configuration.Builder() | ||
.setMinimumLoggingLevel(if (BuildConfig.DEBUG) Log.VERBOSE else Log.INFO) | ||
.setWorkerFactory(workerFactory) | ||
.build() | ||
} |
Oops, something went wrong.