Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependencies in engine colab #2268

Merged
merged 4 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 22 additions & 15 deletions codelabs/datacapture/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ plugins {
}

android {
compileSdk = 31
namespace = "com.google.codelab.sdclibrary"
compileSdk = 34

defaultConfig {
applicationId = "com.google.android.fhir.codelabs.datacapture"
minSdk = 24
targetSdk = 31
targetSdk = 34
versionCode = 1
versionName = "1.0"

Expand All @@ -22,24 +23,30 @@ android {
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
buildFeatures {
buildConfig = true
viewBinding = true
}
kotlinOptions {
jvmTarget = "1.8"
compileOptions {
// Flag to enable support for the new language APIs
// See https://developer.android.com/studio/write/java8-support
isCoreLibraryDesugaringEnabled = true
}

packaging { resources.excludes.addAll(listOf("META-INF/ASL-2.0.txt", "META-INF/LGPL-3.0.txt")) }
kotlin { jvmToolchain(11) }
}

dependencies {
implementation("androidx.core:core-ktx:1.7.0")
implementation("androidx.appcompat:appcompat:1.4.0")
implementation("com.google.android.material:material:1.4.0")
implementation("androidx.constraintlayout:constraintlayout:2.1.2")

testImplementation("junit:junit:4.+")
androidTestImplementation("androidx.test.ext:junit:1.1.3")
androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0")
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.0.3")
implementation("androidx.core:core-ktx:1.12.0")
implementation("androidx.appcompat:appcompat:1.6.1")
implementation("com.google.android.material:material:1.10.0")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")

testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")

// 3 Add dependencies for Structured Data Capture Library and Fragment KTX
}
4 changes: 2 additions & 2 deletions codelabs/datacapture/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ buildscript {
gradlePluginPortal()
}
dependencies {
classpath("com.android.tools.build:gradle:7.0.4")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10")
classpath("com.android.tools.build:gradle:8.1.2")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.20")

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle.kts files
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Fri Jan 28 09:30:50 GMT 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
51 changes: 27 additions & 24 deletions codelabs/engine/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,51 @@ plugins {
}

android {
compileSdk = 31
namespace = "com.google.android.fhir.codelabs.engine"
compileSdk = 34

defaultConfig {
applicationId = "com.google.android.fhir.codelabs.engine"
minSdk = 24
targetSdk = 31
targetSdk = 34
versionCode = 1
versionName = "1.0"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

buildFeatures { viewBinding = true }
buildTypes {
release {
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
buildFeatures {
buildConfig = true
viewBinding = true
}
packaging {
resources.excludes.addAll(listOf("META-INF/ASL-2.0.txt", "META-INF/LGPL-3.0.txt"))
compileOptions {
// Flag to enable support for the new language APIs
// See https://developer.android.com/studio/write/java8-support
isCoreLibraryDesugaringEnabled = true
}

packaging { resources.excludes.addAll(listOf("META-INF/ASL-2.0.txt", "META-INF/LGPL-3.0.txt")) }
kotlin { jvmToolchain(11) }
}

dependencies {
implementation("androidx.core:core-ktx:1.7.0")
implementation("androidx.appcompat:appcompat:1.4.0")
implementation("com.google.android.material:material:1.4.0")
implementation("androidx.constraintlayout:constraintlayout:2.1.2")
implementation("androidx.work:work-runtime-ktx:2.7.1")

testImplementation("junit:junit:4.+")
androidTestImplementation("androidx.test.ext:junit:1.1.3")
androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0")

implementation("com.google.android.fhir:engine:0.1.0-beta03")
implementation("androidx.fragment:fragment-ktx:1.5.5")
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.0.3")

implementation("androidx.core:core-ktx:1.12.0")
implementation("androidx.appcompat:appcompat:1.6.1")
implementation("com.google.android.material:material:1.10.0")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
implementation("androidx.work:work-runtime-ktx:2.8.1")

testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")

implementation("com.google.android.fhir:engine:0.1.0-beta04")
implementation("androidx.fragment:fragment-ktx:1.6.1")
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,21 @@ import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ListAdapter
import com.google.android.fhir.SearchResult
import com.google.android.fhir.codelabs.engine.databinding.PatientListItemViewBinding
import org.hl7.fhir.r4.model.Patient

class PatientItemRecyclerViewAdapter :
ListAdapter<Patient, PatientItemViewHolder>(PatientItemDiffCallback()) {
ListAdapter<SearchResult<Patient>, PatientItemViewHolder>(PatientItemDiffCallback()) {

class PatientItemDiffCallback : DiffUtil.ItemCallback<Patient>() {
override fun areItemsTheSame(oldItem: Patient, newItem: Patient) = oldItem.id == newItem.id
class PatientItemDiffCallback : DiffUtil.ItemCallback<SearchResult<Patient>>() {
override fun areItemsTheSame(oldItem: SearchResult<Patient>, newItem: SearchResult<Patient>) =
oldItem.equals(newItem)

override fun areContentsTheSame(oldItem: Patient, newItem: Patient) =
oldItem.equalsDeep(newItem)
override fun areContentsTheSame(
oldItem: SearchResult<Patient>,
newItem: SearchResult<Patient>,
) = oldItem.equals(newItem)
}

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PatientItemViewHolder {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package com.google.android.fhir.codelabs.engine

import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.google.android.fhir.SearchResult
import com.google.android.fhir.codelabs.engine.databinding.PatientListItemViewBinding
import org.hl7.fhir.r4.model.Patient

Expand All @@ -28,10 +29,12 @@ class PatientItemViewHolder(binding: PatientListItemViewBinding) :
private val genderTextView: TextView = binding.gender
private val cityTextView = binding.city

fun bind(patientItem: Patient) {
fun bind(patientItem: SearchResult<Patient>) {
nameTextView.text =
patientItem.name.first().let { it.given.joinToString(separator = " ") + " " + it.family }
genderTextView.text = patientItem.gender.display
cityTextView.text = patientItem.address.singleOrNull()?.city
patientItem.resource.name.first().let {
it.given.joinToString(separator = " ") + " " + it.family
}
genderTextView.text = patientItem.resource.gender.display
cityTextView.text = patientItem.resource.address.singleOrNull()?.city
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.google.android.fhir.SearchResult
import com.google.android.fhir.search.Order
import com.google.android.fhir.search.search
import com.google.android.fhir.sync.SyncJobStatus
Expand All @@ -35,7 +36,7 @@ class PatientListViewModel(application: Application) : AndroidViewModel(applicat
val pollState: Flow<SyncJobStatus>
get() = _pollState

val liveSearchedPatients = MutableLiveData<List<Patient>>()
val liveSearchedPatients = MutableLiveData<List<SearchResult<Patient>>>()

init {
updatePatientList { getSearchResults() }
Expand All @@ -57,13 +58,13 @@ class PatientListViewModel(application: Application) : AndroidViewModel(applicat
* client every time search query changes or data-sync is completed.
*/
private fun updatePatientList(
search: suspend () -> List<Patient>,
search: suspend () -> List<SearchResult<Patient>>,
) {
viewModelScope.launch { liveSearchedPatients.value = search() }
}

private suspend fun getSearchResults(): List<Patient> {
val patients: MutableList<Patient> = mutableListOf()
private suspend fun getSearchResults(): List<SearchResult<Patient>> {
val patients: MutableList<SearchResult<Patient>> = mutableListOf()
FhirApplication.fhirEngine(this.getApplication())
.search<Patient> { sort(Patient.GIVEN, Order.ASCENDING) }
.let { patients.addAll(it) }
Expand Down
4 changes: 2 additions & 2 deletions codelabs/engine/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ buildscript {
gradlePluginPortal()
}
dependencies {
classpath("com.android.tools.build:gradle:7.0.4")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10")
classpath("com.android.tools.build:gradle:8.1.2")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.20")

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle.kts files
Expand Down
5 changes: 2 additions & 3 deletions codelabs/engine/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Fri Jan 28 09:30:50 GMT 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading