Skip to content

Commit 2355d0d

Browse files
committed
Merge branch 'master' into master-release
2 parents 10e24ef + 6977691 commit 2355d0d

File tree

81 files changed

+4185
-628
lines changed

Some content is hidden

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

81 files changed

+4185
-628
lines changed

buildSrc/src/main/kotlin/Dependencies.kt

-11
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,6 @@ object Dependencies {
8787
const val playServicesLocation =
8888
"com.google.android.gms:play-services-location:${Versions.playServicesLocation}"
8989

90-
const val androidFhirGroup = "org.smartregister"
91-
const val androidFhirEngineModule = "engine"
92-
const val androidFhirKnowledgeModule = "knowledge"
93-
const val androidFhirCommon = "$androidFhirGroup:common:${Versions.androidFhirCommon}"
94-
const val androidFhirEngine =
95-
"$androidFhirGroup:$androidFhirEngineModule:${Versions.androidFhirEngine}"
96-
const val androidFhirKnowledge = "$androidFhirGroup:knowledge:${Versions.androidFhirKnowledge}"
97-
9890
const val apacheCommonsCompress =
9991
"org.apache.commons:commons-compress:${Versions.apacheCommonsCompress}"
10092

@@ -131,9 +123,6 @@ object Dependencies {
131123
const val xmlUnit = "org.xmlunit:xmlunit-core:${Versions.xmlUnit}"
132124

133125
object Versions {
134-
const val androidFhirCommon = "0.1.0-alpha05-preview3-SNAPSHOT"
135-
const val androidFhirEngine = "1.0.0-preview13-SNAPSHOT"
136-
const val androidFhirKnowledge = "0.1.0-beta01-preview-SNAPSHOT"
137126
const val apacheCommonsCompress = "1.21"
138127
const val desugarJdkLibs = "2.0.3"
139128
const val caffeine = "2.9.1"

buildSrc/src/main/kotlin/Releases.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ object Releases {
6262

6363
object Workflow : LibraryArtifact {
6464
override val artifactId = "workflow"
65-
override val version = "0.1.0-alpha04-preview13-SNAPSHOT"
65+
override val version = "0.1.0-beta01"
6666
override val name = "Android FHIR Workflow Library"
6767
}
6868

datacapture/build.gradle.kts

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ dependencies {
9090
exclude(module = "commons-logging")
9191
exclude(module = "httpclient")
9292
}
93-
implementation(Dependencies.androidFhirCommon)
9493
implementation(Dependencies.material)
9594
implementation(Dependencies.timber)
95+
implementation(libs.android.fhir.common)
9696
implementation(libs.androidx.appcompat)
9797
implementation(libs.androidx.constraintlayout)
9898
implementation(libs.androidx.core)
@@ -106,7 +106,7 @@ dependencies {
106106
testImplementation(Dependencies.mockitoKotlin)
107107
testImplementation(Dependencies.robolectric)
108108
testImplementation(project(":knowledge")) {
109-
exclude(group = Dependencies.androidFhirGroup, module = Dependencies.androidFhirEngineModule)
109+
exclude(group = "com.google.android.fhir", module = "engine")
110110
}
111111
testImplementation(libs.androidx.test.core)
112112
testImplementation(libs.androidx.fragment.testing)

demo/build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ dependencies {
6161
implementation(libs.kotlinx.coroutines.android)
6262
implementation(libs.kotlinx.coroutines.core)
6363
implementation(project(":datacapture")) {
64-
exclude(group = Dependencies.androidFhirGroup, module = Dependencies.androidFhirEngineModule)
64+
exclude(group = "com.google.android.fhir", module = "engine")
6565
}
6666
implementation(project(":engine"))
6767

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright 2024 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.android.fhir.demo
18+
19+
import android.app.Application
20+
import androidx.lifecycle.AndroidViewModel
21+
import androidx.lifecycle.viewModelScope
22+
import com.google.android.fhir.FhirEngine
23+
import com.google.android.fhir.demo.extensions.isFirstLaunch
24+
import com.google.android.fhir.demo.extensions.setFirstLaunchCompleted
25+
import com.google.android.fhir.demo.helpers.PatientCreationHelper
26+
import kotlinx.coroutines.Dispatchers
27+
import kotlinx.coroutines.launch
28+
import timber.log.Timber
29+
30+
class ActivityViewModel(application: Application) : AndroidViewModel(application) {
31+
private var fhirEngine: FhirEngine = FhirApplication.fhirEngine(application.applicationContext)
32+
33+
fun createPatientsOnAppFirstLaunch() {
34+
viewModelScope.launch(Dispatchers.IO) {
35+
if (getApplication<FhirApplication>().applicationContext.isFirstLaunch()) {
36+
Timber.i("Creating patients on first launch")
37+
PatientCreationHelper.createSamplePatients().forEach { fhirEngine.create(it) }
38+
getApplication<FhirApplication>().applicationContext.setFirstLaunchCompleted()
39+
Timber.i("Patients created on first launch")
40+
}
41+
}
42+
}
43+
}

demo/src/main/java/com/google/android/fhir/demo/AddPatientFragment.kt

-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ class AddPatientFragment : Fragment(R.layout.add_patient_fragment) {
4444
addQuestionnaireFragment()
4545
}
4646
observePatientSaveAction()
47-
(activity as MainActivity).setDrawerEnabled(false)
4847

4948
/** Use the provided cancel|submit buttons from the sdc library */
5049
childFragmentManager.setFragmentResultListener(

demo/src/main/java/com/google/android/fhir/demo/EditPatientFragment.kt

-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ class EditPatientFragment : Fragment(R.layout.add_patient_fragment) {
5555
Toast.makeText(requireContext(), R.string.message_patient_updated, Toast.LENGTH_SHORT).show()
5656
NavHostFragment.findNavController(this).navigateUp()
5757
}
58-
(activity as MainActivity).setDrawerEnabled(false)
5958

6059
/** Use the provided cancel|submit buttons from the sdc library */
6160
childFragmentManager.setFragmentResultListener(

demo/src/main/java/com/google/android/fhir/demo/HomeFragment.kt

+7-19
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package com.google.android.fhir.demo
1818

1919
import android.os.Bundle
20-
import android.view.MenuItem
2120
import android.view.View
2221
import androidx.appcompat.app.AppCompatActivity
2322
import androidx.cardview.widget.CardView
@@ -30,32 +29,21 @@ class HomeFragment : Fragment(R.layout.fragment_home) {
3029
super.onViewCreated(view, savedInstanceState)
3130
(requireActivity() as AppCompatActivity).supportActionBar?.apply {
3231
title = resources.getString(R.string.app_name)
33-
setDisplayHomeAsUpEnabled(true)
32+
setDisplayHomeAsUpEnabled(false)
3433
}
35-
setHasOptionsMenu(true)
36-
(activity as MainActivity).setDrawerEnabled(true)
3734
setOnClicks()
3835
}
3936

4037
private fun setOnClicks() {
41-
requireView().findViewById<CardView>(R.id.item_new_patient).setOnClickListener {
42-
findNavController().navigate(HomeFragmentDirections.actionHomeFragmentToAddPatientFragment())
43-
}
44-
requireView().findViewById<CardView>(R.id.item_patient_list).setOnClickListener {
45-
findNavController().navigate(HomeFragmentDirections.actionHomeFragmentToPatientList())
46-
}
4738
requireView().findViewById<CardView>(R.id.item_search).setOnClickListener {
4839
findNavController().navigate(HomeFragmentDirections.actionHomeFragmentToPatientList())
4940
}
50-
}
51-
52-
override fun onOptionsItemSelected(item: MenuItem): Boolean {
53-
return when (item.itemId) {
54-
android.R.id.home -> {
55-
(requireActivity() as MainActivity).openNavigationDrawer()
56-
true
57-
}
58-
else -> false
41+
requireView().findViewById<CardView>(R.id.item_sync).setOnClickListener {
42+
findNavController().navigate(HomeFragmentDirections.actionHomeFragmentToSyncFragment())
43+
}
44+
requireView().findViewById<CardView>(R.id.item_periodic_sync).setOnClickListener {
45+
findNavController()
46+
.navigate(HomeFragmentDirections.actionHomeFragmentToPeriodicSyncFragment())
5947
}
6048
}
6149
}

demo/src/main/java/com/google/android/fhir/demo/MainActivity.kt

+2-54
Original file line numberDiff line numberDiff line change
@@ -17,78 +17,26 @@
1717
package com.google.android.fhir.demo
1818

1919
import android.os.Bundle
20-
import android.view.MenuItem
21-
import android.widget.TextView
2220
import androidx.activity.viewModels
23-
import androidx.appcompat.app.ActionBarDrawerToggle
2421
import androidx.appcompat.app.AppCompatActivity
25-
import androidx.core.view.GravityCompat
26-
import androidx.drawerlayout.widget.DrawerLayout
2722
import com.google.android.fhir.demo.databinding.ActivityMainBinding
2823

2924
const val MAX_RESOURCE_COUNT = 20
3025

3126
class MainActivity : AppCompatActivity() {
3227
private lateinit var binding: ActivityMainBinding
33-
private lateinit var drawerToggle: ActionBarDrawerToggle
34-
private val viewModel: MainActivityViewModel by viewModels()
28+
private val activityViewModel: ActivityViewModel by viewModels()
3529

3630
override fun onCreate(savedInstanceState: Bundle?) {
3731
super.onCreate(savedInstanceState)
3832
binding = ActivityMainBinding.inflate(layoutInflater)
3933
setContentView(binding.root)
4034
initActionBar()
41-
initNavigationDrawer()
42-
observeLastSyncTime()
43-
viewModel.updateLastSyncTimestamp()
44-
}
45-
46-
override fun onBackPressed() {
47-
if (binding.drawer.isDrawerOpen(GravityCompat.START)) {
48-
binding.drawer.closeDrawer(GravityCompat.START)
49-
return
50-
}
51-
super.onBackPressed()
52-
}
53-
54-
fun setDrawerEnabled(enabled: Boolean) {
55-
val lockMode =
56-
if (enabled) DrawerLayout.LOCK_MODE_UNLOCKED else DrawerLayout.LOCK_MODE_LOCKED_CLOSED
57-
binding.drawer.setDrawerLockMode(lockMode)
58-
drawerToggle.isDrawerIndicatorEnabled = enabled
59-
}
60-
61-
fun openNavigationDrawer() {
62-
binding.drawer.openDrawer(GravityCompat.START)
63-
viewModel.updateLastSyncTimestamp()
35+
activityViewModel.createPatientsOnAppFirstLaunch()
6436
}
6537

6638
private fun initActionBar() {
6739
val toolbar = binding.toolbar
6840
setSupportActionBar(toolbar)
6941
}
70-
71-
private fun initNavigationDrawer() {
72-
binding.navigationView.setNavigationItemSelectedListener(this::onNavigationItemSelected)
73-
drawerToggle = ActionBarDrawerToggle(this, binding.drawer, R.string.open, R.string.close)
74-
binding.drawer.addDrawerListener(drawerToggle)
75-
drawerToggle.syncState()
76-
}
77-
78-
private fun onNavigationItemSelected(item: MenuItem): Boolean {
79-
when (item.itemId) {
80-
R.id.menu_sync -> {
81-
viewModel.triggerOneTimeSync()
82-
binding.drawer.closeDrawer(GravityCompat.START)
83-
return false
84-
}
85-
}
86-
return false
87-
}
88-
89-
private fun observeLastSyncTime() {
90-
viewModel.lastSyncTimestampLiveData.observe(this) {
91-
binding.navigationView.getHeaderView(0).findViewById<TextView>(R.id.last_sync_tv).text = it
92-
}
93-
}
9442
}

demo/src/main/java/com/google/android/fhir/demo/PatientDetailsFragment.kt

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2022-2023 Google LLC
2+
* Copyright 2022-2024 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.
@@ -82,7 +82,6 @@ class PatientDetailsFragment : Fragment() {
8282
}
8383
}
8484
patientDetailsViewModel.getPatientDetailData()
85-
(activity as MainActivity).setDrawerEnabled(false)
8685
}
8786

8887
private fun onAddScreenerClick() {

0 commit comments

Comments
 (0)