From ad9e8275a860c899553763b7802109cd1c3feec2 Mon Sep 17 00:00:00 2001 From: aurangzaibumer <35099184+aurangzaibumer@users.noreply.github.com> Date: Mon, 13 May 2024 15:48:26 +0500 Subject: [PATCH 1/6] update kujaku dependency (#3243) * update kujaku dependency * :arrow_up: Upgrade the Kijaku dependency and add mapbox auth credentials * mapview initializing fix * :wrench: Update the kujaku versions * :wrench: Update the versions --------- Co-authored-by: Benjamin Mwalimu --- android/build.gradle.kts | 10 +++++++--- .../fhircore/geowidget/screens/GeoWidgetFragment.kt | 4 +++- android/gradle/libs.versions.toml | 4 ++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/android/build.gradle.kts b/android/build.gradle.kts index 7a27c04503..96ad328989 100644 --- a/android/build.gradle.kts +++ b/android/build.gradle.kts @@ -14,6 +14,7 @@ buildscript { } plugins { + `project-properties` alias(libs.plugins.org.jetbrains.kotlin.jvm) alias(libs.plugins.kt3k.coveralls) alias(libs.plugins.kotlin.serialization) @@ -23,7 +24,6 @@ plugins { alias(libs.plugins.org.owasp.dependencycheck) alias(libs.plugins.com.diffplug.spotless) apply false alias(libs.plugins.android.junit5) apply false - } tasks.dokkaHtmlMultiModule { @@ -42,13 +42,17 @@ allprojects { google() mavenCentral() maven(url = "https://oss.sonatype.org/content/repositories/snapshots") + maven(url = "https://s01.oss.sonatype.org/content/repositories/snapshots") maven(url = "https://jcenter.bintray.com/") apply(plugin = "org.owasp.dependencycheck") tasks.dependencyCheckAggregate{ dependencyCheck.formats.add("XML") } - configurations.all{ - resolutionStrategy.force ("com.google.android.gms:play-services-location:19.0.1") + maven { + url = uri("https://api.mapbox.com/downloads/v2/releases/maven") + credentials.username = "mapbox" + credentials.password = property("MAPBOX_SDK_TOKEN").toString() + authentication.create("basic") } } } diff --git a/android/geowidget/src/main/java/org/smartregister/fhircore/geowidget/screens/GeoWidgetFragment.kt b/android/geowidget/src/main/java/org/smartregister/fhircore/geowidget/screens/GeoWidgetFragment.kt index e7c2f59587..aa3f804477 100644 --- a/android/geowidget/src/main/java/org/smartregister/fhircore/geowidget/screens/GeoWidgetFragment.kt +++ b/android/geowidget/src/main/java/org/smartregister/fhircore/geowidget/screens/GeoWidgetFragment.kt @@ -91,7 +91,9 @@ class GeoWidgetFragment : Fragment() { savedInstanceState: Bundle?, ): View { Mapbox.getInstance(requireContext(), BuildConfig.MAPBOX_SDK_TOKEN) - return setupViews() + val view = setupViews() + mapView.onCreate(savedInstanceState) + return view } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { diff --git a/android/gradle/libs.versions.toml b/android/gradle/libs.versions.toml index 552f6126ca..32fc125f18 100644 --- a/android/gradle/libs.versions.toml +++ b/android/gradle/libs.versions.toml @@ -41,7 +41,7 @@ knowledge = "0.1.0-alpha03-preview5-SNAPSHOT" kotlin = "1.9.22" kotlinx-coroutines = "1.7.3" kotlinx-serialization-json = "1.6.0" -kujaku-library = "0.9.0" +kujaku-library = "0.10.2-SNAPSHOT" ktlint = "0.50.0" leakcanary-android = "2.10" lifecycle= "2.7.0" @@ -148,7 +148,7 @@ kotlinx-serialization-json = { group = "org.jetbrains.kotlinx", name = "kotlinx- ktlint-main = { group = "com.pinterest", name = "ktlint", version.ref = "ktlint"} ktlint-cli-ruleset = { group = "com.pinterest.ktlint", name = "ktlint-cli-ruleset-core", version.ref = "ktlint" } ktlint-rule-engine-core = { group = "com.pinterest.ktlint", name = "ktlint-rule-engine-core", version.ref = "ktlint" } -kujaku-library = { group = "io.ona.kujaku", name = "library", version.ref = "kujaku-library" } +kujaku-library = { group = "io.ona.kujaku", name ="library", version.ref = "kujaku-library" } leakcanary-android = { group = "com.squareup.leakcanary", name = "leakcanary-android", version.ref = "leakcanary-android" } lifecycle-livedata-ktx = { group = "androidx.lifecycle", name = "lifecycle-livedata-ktx", version.ref = "lifecycle" } lifecycle-viewmodel-compose = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-compose", version.ref = "lifecycle" } From f0dc530eee360c33712d4432a8445e65107c7b2f Mon Sep 17 00:00:00 2001 From: Aurangzaib Umer Date: Wed, 22 May 2024 20:37:31 +0500 Subject: [PATCH 2/6] added mapbox sdk token for ci/cd --- android/geowidget/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/geowidget/build.gradle.kts b/android/geowidget/build.gradle.kts index 0ad95063d1..c28da50c09 100644 --- a/android/geowidget/build.gradle.kts +++ b/android/geowidget/build.gradle.kts @@ -20,7 +20,7 @@ android { defaultConfig { minSdk = BuildConfigs.minSdk - buildConfigField("String", "MAPBOX_SDK_TOKEN", """"${project.extra["MAPBOX_SDK_TOKEN"]}"""") + buildConfigField("String", "MAPBOX_SDK_TOKEN", System.getenv("MAPBOX_SDK_TOKEN") ?: """"${project.extra["MAPBOX_SDK_TOKEN"]}"""") testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles("consumer-rules.pro") From 3ab2f96f4a4e5c29da8ceadce2e083ac7f255ffd Mon Sep 17 00:00:00 2001 From: Aurangzaib Umer Date: Wed, 22 May 2024 21:19:25 +0500 Subject: [PATCH 3/6] spotless ran --- android/geowidget/build.gradle.kts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/android/geowidget/build.gradle.kts b/android/geowidget/build.gradle.kts index c28da50c09..7b7efed8e4 100644 --- a/android/geowidget/build.gradle.kts +++ b/android/geowidget/build.gradle.kts @@ -20,7 +20,11 @@ android { defaultConfig { minSdk = BuildConfigs.minSdk - buildConfigField("String", "MAPBOX_SDK_TOKEN", System.getenv("MAPBOX_SDK_TOKEN") ?: """"${project.extra["MAPBOX_SDK_TOKEN"]}"""") + buildConfigField( + "String", + "MAPBOX_SDK_TOKEN", + System.getenv("MAPBOX_SDK_TOKEN") ?: """"${project.extra["MAPBOX_SDK_TOKEN"]}"""" + ) testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles("consumer-rules.pro") From 9827c7270b165934fefe006012a3ded68b598a9d Mon Sep 17 00:00:00 2001 From: Aurangzaib Umer Date: Fri, 24 May 2024 13:21:37 +0500 Subject: [PATCH 4/6] added accessing token from system variable in project gradle --- android/build.gradle.kts | 2 +- .../quest/ui/launcher/GeoWidgetLauncherFragment.kt | 6 ++++++ .../quest/ui/launcher/GeoWidgetLauncherScreen.kt | 6 +++++- .../quest/ui/launcher/GeoWidgetLauncherViewModel.kt | 12 ++++++++++-- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/android/build.gradle.kts b/android/build.gradle.kts index 96ad328989..81758b3e57 100644 --- a/android/build.gradle.kts +++ b/android/build.gradle.kts @@ -51,7 +51,7 @@ allprojects { maven { url = uri("https://api.mapbox.com/downloads/v2/releases/maven") credentials.username = "mapbox" - credentials.password = property("MAPBOX_SDK_TOKEN").toString() + credentials.password = System.getenv("MAPBOX_SDK_TOKEN") ?: property("MAPBOX_SDK_TOKEN").toString() authentication.create("basic") } } diff --git a/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/launcher/GeoWidgetLauncherFragment.kt b/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/launcher/GeoWidgetLauncherFragment.kt index ef31618b30..f6976296f7 100644 --- a/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/launcher/GeoWidgetLauncherFragment.kt +++ b/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/launcher/GeoWidgetLauncherFragment.kt @@ -163,6 +163,7 @@ class GeoWidgetLauncherFragment : Fragment() { fragmentManager = childFragmentManager, fragment = fragment, geoWidgetConfiguration = geoWidgetConfiguration, + searchText = geoWidgetLauncherViewModel.searchText, ) } } @@ -250,6 +251,11 @@ class GeoWidgetLauncherFragment : Fragment() { } } + override fun onStop() { + super.onStop() + geoWidgetLauncherViewModel.searchText.value = "" + } + companion object { const val GEO_WIDGET_FRAGMENT_TAG = "geo-widget-fragment-tag" } diff --git a/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/launcher/GeoWidgetLauncherScreen.kt b/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/launcher/GeoWidgetLauncherScreen.kt index 9f82d59ebb..cbf57f8f86 100644 --- a/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/launcher/GeoWidgetLauncherScreen.kt +++ b/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/launcher/GeoWidgetLauncherScreen.kt @@ -16,6 +16,7 @@ package org.smartregister.fhircore.quest.ui.launcher +import androidx.compose.runtime.* import android.view.View import android.widget.FrameLayout import androidx.compose.foundation.layout.Box @@ -24,6 +25,8 @@ import androidx.compose.foundation.layout.padding import androidx.compose.material.Scaffold import androidx.compose.runtime.Composable import androidx.compose.runtime.DisposableEffect +import androidx.compose.runtime.MutableState +import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.viewinterop.AndroidView @@ -53,6 +56,7 @@ fun GeoWidgetLauncherScreen( fragmentManager: FragmentManager, fragment: Fragment, geoWidgetConfiguration: GeoWidgetConfiguration, + searchText: MutableState ) { Scaffold( topBar = { @@ -63,7 +67,7 @@ fun GeoWidgetLauncherScreen( * */ TopScreenSection( title = geoWidgetConfiguration.topScreenSection?.title ?: "", - searchText = "", + searchText = searchText.value, filteredRecordsCount = 1, isSearchBarVisible = geoWidgetConfiguration.topScreenSection?.searchBar?.visible ?: true, searchPlaceholder = geoWidgetConfiguration.topScreenSection?.searchBar?.display, diff --git a/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/launcher/GeoWidgetLauncherViewModel.kt b/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/launcher/GeoWidgetLauncherViewModel.kt index 82dad32074..8a3af61224 100644 --- a/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/launcher/GeoWidgetLauncherViewModel.kt +++ b/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/launcher/GeoWidgetLauncherViewModel.kt @@ -17,6 +17,7 @@ package org.smartregister.fhircore.quest.ui.launcher import android.content.Context +import androidx.compose.runtime.mutableStateOf import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel @@ -68,6 +69,8 @@ constructor( val locationDialog: LiveData get() = _locationDialog + val searchText = mutableStateOf("") + // TODO: use List or Linkage resource to connect Location with Group/Patient/etc private fun retrieveLocations(geoWidgetConfig: GeoWidgetConfiguration) { viewModelScope.launch(dispatcherProvider.io()) { @@ -182,8 +185,13 @@ constructor( fun onEvent(event: GeoWidgetEvent) = when (event) { is GeoWidgetEvent.SearchServicePoints -> { - // TODO: here the search bar query will be processed - "" + searchText.value = event.searchText + if (event.searchText.isEmpty()) { + //reload all data + + } else { + filterQuery(event) + } } } From a9fc051cb3fcd63d4d6aa6040add37fba6dbca48 Mon Sep 17 00:00:00 2001 From: Aurangzaib Umer Date: Fri, 24 May 2024 13:24:03 +0500 Subject: [PATCH 5/6] removed extra code of WIP search functionality of Map --- .../quest/ui/launcher/GeoWidgetLauncherFragment.kt | 6 ------ .../quest/ui/launcher/GeoWidgetLauncherScreen.kt | 6 +----- .../quest/ui/launcher/GeoWidgetLauncherViewModel.kt | 12 ++---------- 3 files changed, 3 insertions(+), 21 deletions(-) diff --git a/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/launcher/GeoWidgetLauncherFragment.kt b/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/launcher/GeoWidgetLauncherFragment.kt index f6976296f7..ef31618b30 100644 --- a/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/launcher/GeoWidgetLauncherFragment.kt +++ b/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/launcher/GeoWidgetLauncherFragment.kt @@ -163,7 +163,6 @@ class GeoWidgetLauncherFragment : Fragment() { fragmentManager = childFragmentManager, fragment = fragment, geoWidgetConfiguration = geoWidgetConfiguration, - searchText = geoWidgetLauncherViewModel.searchText, ) } } @@ -251,11 +250,6 @@ class GeoWidgetLauncherFragment : Fragment() { } } - override fun onStop() { - super.onStop() - geoWidgetLauncherViewModel.searchText.value = "" - } - companion object { const val GEO_WIDGET_FRAGMENT_TAG = "geo-widget-fragment-tag" } diff --git a/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/launcher/GeoWidgetLauncherScreen.kt b/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/launcher/GeoWidgetLauncherScreen.kt index cbf57f8f86..9f82d59ebb 100644 --- a/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/launcher/GeoWidgetLauncherScreen.kt +++ b/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/launcher/GeoWidgetLauncherScreen.kt @@ -16,7 +16,6 @@ package org.smartregister.fhircore.quest.ui.launcher -import androidx.compose.runtime.* import android.view.View import android.widget.FrameLayout import androidx.compose.foundation.layout.Box @@ -25,8 +24,6 @@ import androidx.compose.foundation.layout.padding import androidx.compose.material.Scaffold import androidx.compose.runtime.Composable import androidx.compose.runtime.DisposableEffect -import androidx.compose.runtime.MutableState -import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.viewinterop.AndroidView @@ -56,7 +53,6 @@ fun GeoWidgetLauncherScreen( fragmentManager: FragmentManager, fragment: Fragment, geoWidgetConfiguration: GeoWidgetConfiguration, - searchText: MutableState ) { Scaffold( topBar = { @@ -67,7 +63,7 @@ fun GeoWidgetLauncherScreen( * */ TopScreenSection( title = geoWidgetConfiguration.topScreenSection?.title ?: "", - searchText = searchText.value, + searchText = "", filteredRecordsCount = 1, isSearchBarVisible = geoWidgetConfiguration.topScreenSection?.searchBar?.visible ?: true, searchPlaceholder = geoWidgetConfiguration.topScreenSection?.searchBar?.display, diff --git a/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/launcher/GeoWidgetLauncherViewModel.kt b/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/launcher/GeoWidgetLauncherViewModel.kt index 8a3af61224..82dad32074 100644 --- a/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/launcher/GeoWidgetLauncherViewModel.kt +++ b/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/launcher/GeoWidgetLauncherViewModel.kt @@ -17,7 +17,6 @@ package org.smartregister.fhircore.quest.ui.launcher import android.content.Context -import androidx.compose.runtime.mutableStateOf import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel @@ -69,8 +68,6 @@ constructor( val locationDialog: LiveData get() = _locationDialog - val searchText = mutableStateOf("") - // TODO: use List or Linkage resource to connect Location with Group/Patient/etc private fun retrieveLocations(geoWidgetConfig: GeoWidgetConfiguration) { viewModelScope.launch(dispatcherProvider.io()) { @@ -185,13 +182,8 @@ constructor( fun onEvent(event: GeoWidgetEvent) = when (event) { is GeoWidgetEvent.SearchServicePoints -> { - searchText.value = event.searchText - if (event.searchText.isEmpty()) { - //reload all data - - } else { - filterQuery(event) - } + // TODO: here the search bar query will be processed + "" } } From b0ee36234bf5fb2e591ebf880108bbefd14284f9 Mon Sep 17 00:00:00 2001 From: Aurangzaib Umer Date: Fri, 24 May 2024 13:30:55 +0500 Subject: [PATCH 6/6] spotless ran --- android/geowidget/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/geowidget/build.gradle.kts b/android/geowidget/build.gradle.kts index 7b7efed8e4..a0fbe9fabc 100644 --- a/android/geowidget/build.gradle.kts +++ b/android/geowidget/build.gradle.kts @@ -23,7 +23,7 @@ android { buildConfigField( "String", "MAPBOX_SDK_TOKEN", - System.getenv("MAPBOX_SDK_TOKEN") ?: """"${project.extra["MAPBOX_SDK_TOKEN"]}"""" + System.getenv("MAPBOX_SDK_TOKEN") ?: """"${project.extra["MAPBOX_SDK_TOKEN"]}"""", ) testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles("consumer-rules.pro")