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

Add Geowidget module #1548

Merged
merged 34 commits into from
Sep 7, 2022
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
0a23997
Add Geowidget module
ekigamba Aug 17, 2022
a22d332
Zoom to registered families & remove register family btn
ekigamba Aug 17, 2022
32b7c78
Fix Kujaku version and add turf dependency
ekigamba Aug 17, 2022
a36d125
Merge branch 'main' into integrate-kujaku
ekigamba Aug 20, 2022
993acf1
Connect maps menu to Geowidget
ekigamba Aug 20, 2022
6497075
Disable maps menu when geowidgetEnabled config is false
ekigamba Aug 20, 2022
b51cd34
Update eCBIS geowidget questionnaire to work with non-geowidget versions
ekigamba Aug 20, 2022
d4b9488
Add empty action when family is clicked
ekigamba Aug 20, 2022
8fdbf1c
Enable syncing of Locations in quest
ekigamba Aug 20, 2022
e8886b4
Enable saving new points into Location boundary extension
ekigamba Aug 21, 2022
f5f39bb
Add Geowidget module tests & spotless checks to CI
ekigamba Aug 21, 2022
4bdd9cf
Move data from AppMainActivity
ekigamba Aug 21, 2022
f89d724
Add KujakuFhirCoreConverterTest
ekigamba Aug 21, 2022
8544acd
Add GeowidgetViewModel tests
ekigamba Aug 22, 2022
19193b6
GeowidgetActivity tests
ekigamba Aug 22, 2022
86aa0d7
Re-enable removed sync configs
ekigamba Aug 22, 2022
fc9bdfc
Fix quest sync config failing test
ekigamba Aug 22, 2022
1fc6686
Exclude META-INF/sun-jaxb.episode from packing in Geowidget module
ekigamba Aug 22, 2022
1b1ba4a
Exclude META-INF files causing build failure in geowidget
ekigamba Aug 22, 2022
b157d37
Merge branch 'main' into integrate-kujaku
ellykits Aug 23, 2022
9fd28f3
Set application flavor for geowidget
ellykits Aug 23, 2022
d8e35b3
Merge branch 'main' into integrate-kujaku
ellykits Aug 24, 2022
6439f99
Navigate to profile from geowidget
ellykits Aug 24, 2022
b5e991e
Refactor GeoWidgetActivity to a Fragement
ellykits Sep 1, 2022
2a289c6
Setup toolbar on map view
ellykits Sep 1, 2022
4f66bde
Remove P2P menu for Geowidget NavMenu
f-odhiambo Sep 1, 2022
3eaa6bf
Merge branch 'main' into integrate-kujaku
ellykits Sep 2, 2022
0e28484
Delete irrelevant test
ellykits Sep 2, 2022
7458df6
Fix failing tests across modules
ellykits Sep 5, 2022
e818ca3
Fix GeoWidgeViewModelTest
ellykits Sep 6, 2022
76267c4
Fix permissions request from GeoWidgetFragment
ellykits Sep 6, 2022
856f891
Merge branch 'main' into integrate-kujaku
ellykits Sep 7, 2022
aa62476
Set test logs
ellykits Sep 7, 2022
da25ddd
Merge branch 'main' into integrate-kujaku
ellykits Sep 7, 2022
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
72 changes: 72 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,78 @@ jobs:
working-directory: android
run: bash <(curl -s https://codecov.io/bash) -F engine -f "engine/build/reports/jacoco/fhircoreJacocoReport/fhircoreJacocoReport.xml"

geowidget-tests:
runs-on: macos-latest
strategy:
matrix:
api-level: [30]
steps:
- name: Cancel Previous workflow runs
uses: styfle/cancel-workflow-action@0.9.1
with:
access_token: ${{ github.token }}

- name: Checkout 🛎️
uses: actions/checkout@v2
with:
fetch-depth: 2

- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11

- name: Grant execute permission for gradlew
run: chmod +x gradlew
working-directory: android

- name: Copy CI gradle.properties
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties && cat ~/.gradle/gradle.properties

- name: Setup Gradle cache
uses: gradle/gradle-build-action@v2

- name: Spotless check geowidget module
run: ./gradlew :geowidget:spotlessCheck --stacktrace
working-directory: android

- name: Load AVD cache
uses: actions/cache@v2
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ matrix.api-level }}

- name: Create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
working-directory: android
api-level: ${{ matrix.api-level }}
arch: x86_64
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
script: echo "Generated AVD snapshot for caching."

- name: Run Geowidget module unit and instrumentation tests and generate coverage report
uses: reactivecircus/android-emulator-runner@v2
with:
working-directory: android
api-level: ${{ matrix.api-level }}
arch: x86_64
force-avd-creation: true
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
script: ./gradlew :geowidget:clean && ./gradlew :geowidget:fhircoreJacocoReport --stacktrace

- name: Upload Geowidget module test coverage report to Codecov
if: matrix.api-level == 30 # Only upload coverage on API level 30
working-directory: android
run: bash <(curl -s https://codecov.io/bash) -F geowidget -f "geowidget/build/reports/jacoco/fhircoreJacocoReport/fhircoreJacocoReport.xml"

quest-tests:
runs-on: macos-latest
strategy:
Expand Down
6 changes: 6 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
apply from: 'deps.gradle'
apply from: 'configs.gradle'

repositories {
google()
maven { url "https://plugins.gradle.org/m2/" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }

}

dependencies {
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10'
classpath "org.jetbrains.kotlin:kotlin-serialization:1.6.21"
Expand All @@ -32,6 +35,9 @@ allprojects {
name = "fhirsdk"
url = uri("/Users/ndegwamartin/.m2.dev/fhirsdk")
}
maven {
url 'https://jcenter.bintray.com/'
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions android/configs.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def geowidgetEnabled = true
ext.geowidgetEnabled = geowidgetEnabled
4 changes: 4 additions & 0 deletions android/deps.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ versions.hapi_r4 = '5.3.0'
versions.junit5_api = '5.8.2'
versions.junit5_plugin = '1.8.2.0'
versions.kotlin = '1.6.10'
versions.kujaku_library = '0.9.0'
versions.lifecycle = '2.2.0'
versions.material = '1.5.0'
versions.mapbox_sdk_turf = '4.8.0'
versions.okhttp_logging_interceptor = '4.0.0'
versions.recyclerview = '1.1.0'
versions.retrofit = '2.7.2'
Expand Down Expand Up @@ -89,6 +91,8 @@ deps.junit5_plugin = "de.mannodermaus.gradle.plugins:android-junit5:$versions.ju
deps.junit5_api = "org.junit.jupiter:junit-jupiter-api:$versions.junit5_api"
deps.junit5_engine = "org.junit.jupiter:junit-jupiter-engine:$versions.junit5_api"
deps.junit5_engine_vintage = "org.junit.vintage:junit-vintage-engine:$versions.junit5_api"
deps.kujaku_library = "io.ona.kujaku:library:$versions.kujaku_library"
deps.mapbox_sdk_turf = "com.mapbox.mapboxsdk:mapbox-sdk-turf:$versions.mapbox_sdk_turf"
deps.mockk = "io.mockk:mockk:$versions.mockk"
deps.mockk_android = "io.mockk:mockk-android:$versions.mockk"
deps.dokka_plugin = "org.jetbrains.dokka:dokka-gradle-plugin:$versions.dokka"
Expand Down
4 changes: 3 additions & 1 deletion android/engine/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ plugins {
}

apply from: '../jacoco.gradle'
apply from: '../configs.gradle'

android {

Expand All @@ -18,6 +19,7 @@ android {
dataBinding {
enabled true
}

defaultConfig {
minSdkVersion sdk_versions.min_sdk
targetSdkVersion sdk_versions.target_sdk
Expand Down Expand Up @@ -158,7 +160,7 @@ dependencies {
// P2P dependency
implementation('org.smartregister:p2p-lib:0.4.0-SNAPSHOT')

// Configure Jetpack Compose
//Configure Jetpack Compose
def composeVersion = "1.3.0-alpha01"
api("androidx.compose.ui:ui:$composeVersion")
api("androidx.compose.ui:ui-tooling:$composeVersion")
Expand Down
3 changes: 2 additions & 1 deletion android/engine/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@

<uses-permission android:name="android.permission.CALL_PHONE" />

<application>
<application
xmlns:tools="http://schemas.android.com/tools">

<activity
android:name=".ui.appsetting.AppSettingActivity"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ sealed class ConfigType(
object Register : ConfigType("register", multiConfig = true)
object MeasureReport : ConfigType("measureReport")
object Profile : ConfigType("profile", multiConfig = true)
object GeoWidget : ConfigType("geoWidget", multiConfig = true)
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ package org.smartregister.fhircore.engine.configuration
* @property appId Unique identifier for the application to which this configurations is applied
* @property configType Used to categorize multiple configurations of the same type. E.g. two
* RegisterViewConfigurations used in an application with two registers.
* @property resourceType Optional FHIR resource type
*/
abstract class Configuration {
open lateinit var appId: String
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* 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.smartregister.fhircore.engine.configuration.geowidget

import kotlinx.serialization.Serializable
import org.smartregister.fhircore.engine.configuration.ConfigType
import org.smartregister.fhircore.engine.configuration.Configuration
import org.smartregister.fhircore.engine.configuration.QuestionnaireConfig

@Serializable
data class GeoWidgetConfiguration(
override var appId: String,
override var configType: String = ConfigType.GeoWidget.name,
val id: String,
val profileId: String,
val registrationQuestionnaire: QuestionnaireConfig
) : Configuration()
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,14 @@ constructor(
val baseResourceClass = baseResourceConfig.resource.resourceClassType()
val baseResourceType = baseResourceClass.newInstance().resourceType

// Some resource id maybe in the format Group/1be72fc8-5e5c-4f90-a37d-739c73fc4bdf/_history/7
val parsedResourceId =
if (resourceId.startsWith(baseResourceType.name))
resourceId.substringAfter("/").substringBefore("/")
else resourceId

val baseResource: Resource =
withContext(dispatcherProvider.io()) { fhirEngine.get(baseResourceType, resourceId) }
withContext(dispatcherProvider.io()) { fhirEngine.get(baseResourceType, parsedResourceId) }

return retrieveRelatedResources(
relatedResourcesConfig = relatedResourcesConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,15 @@ open class QuestionnaireActivity : BaseMultiLanguageActivity(), View.OnClickList

if (clientIdentifier != null) {
setBarcode(questionnaire, clientIdentifier!!, true)
questionnaireResponse =
questionnaireViewModel.generateQuestionnaireResponse(questionnaire, intent)
this.putString(
QuestionnaireFragment.EXTRA_QUESTIONNAIRE_RESPONSE_JSON_STRING,
questionnaireResponse.encodeResourceToString()
)
}

questionnaireResponse =
questionnaireViewModel.generateQuestionnaireResponse(questionnaire, intent)

this.putString(
QuestionnaireFragment.EXTRA_QUESTIONNAIRE_RESPONSE_JSON_STRING,
questionnaireResponse.encodeResourceToString()
)
}
}
supportFragmentManager.commit { add(R.id.container, fragment, QUESTIONNAIRE_FRAGMENT_TAG) }
Expand Down Expand Up @@ -374,6 +376,10 @@ open class QuestionnaireActivity : BaseMultiLanguageActivity(), View.OnClickList
}
}

override fun onResume() {
super.onResume()
}

open fun getDismissDialogMessage() = R.string.questionnaire_alert_back_pressed_message

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package org.smartregister.fhircore.engine.util.extension

import android.app.Activity
import android.content.Context
import android.content.ContextWrapper
import android.content.Intent
import android.content.res.Configuration
import android.content.res.Resources
Expand All @@ -26,6 +27,7 @@ import android.os.Build
import android.os.Bundle
import android.os.LocaleList
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.ui.graphics.Color as ComposeColor
import java.util.Locale
import org.smartregister.fhircore.engine.domain.model.QuestionnaireType
Expand Down Expand Up @@ -165,3 +167,10 @@ fun String?.parseColor(): androidx.compose.ui.graphics.Color {
}
return ComposeColor.Unspecified
}

fun Context.getActivity(): AppCompatActivity? =
when (this) {
is AppCompatActivity -> this
is ContextWrapper -> baseContext.getActivity()
else -> null
}
1 change: 1 addition & 0 deletions android/geowidget/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
Loading