Skip to content

Commit

Permalink
Refactor GeoWidget module
Browse files Browse the repository at this point in the history
* Set Location collector

* Move geowidget config to quest

* Code re-structure on setting up views

* Setup Toolbar and Mapview Listener

* Invoke onClick location and onAdding new location callbacks

* Code-restructure on zooming locations

* Create builder for geowidget fragment

* Cleanup

* Define geowidget location

* Create location features stateflow

* Allow adding locations to map

* Clear locations on map

* Code cleanup

* Rename navigation to GeoWidgetLauncher

* Direct navigation graph to the geowidget launcher

* Re-route handleClickEvent to geowidget launcher

* Create the GeoWidgetLauncherFragment

- Responsible to launch the Geowidget module fragment
- A place to define callbacks, listeners, and passing data to the map
-

* Create the GeoWidgetLauncherViewModel

- Responsible in getting the locations to be populated into the geowidget module
- The locationsFlow is the data source of truth
- Responsible to launch a questionnaire and receiving its response

* Cleanup

* Updated search bar config to hide/show it

* added layer view for street and satellite view

* fixed package error issue

* fixed package path related issues for app theme and color

* fixed added street + satellite layer view in map

* Fixed rendering stored locations from the database on the map view

* WIP fixing map view toolbar

* adding set location dialog

* Fixed showing Map view as Default view

* reduced delay in rendering locaions

* WIP resolving feedback

* WIP working on switching between map and register view through toggle view button

* configured map layers (#3127)

* configured map layers

* configured visibility of location button, plane switcher and floating button on mapview

* WIP added toggle button on topbar

* fixed compilation error

* added toggle icon on toolbar

* added configurable functionality of toggle button on Toolbar to switch between Map and Register view

* removed unnecessary code

* disable set location dialog for now

* removed extra lines

* Lazy load geoWidgetConfiguration

* Refactor "context" to "color"

* Move latitude and longitude action parameter to configs

* Rename launchQuestionnaire method

* Remove un-used context related code

* Fixed location/play service library issue - thanks to Ben

* enabled all map layers by default for now

* Make GeoWIdget icons configurable (#3185)

* Initial Commit

* fetch related encounters

* Update models

* Refactor GeowWidgetLocation to Feature

* Update GeowWidget Config Model

* Update Feature Geometry model

* Fix location id value

* PR feedback changes

* Refactor constants

* Fix navigation graph for mapview

---------

Co-authored-by: Benjamin Mwalimu <[email protected]>

* Summary Bottom Sheet Opening from GeoWidget Map (#3183)

* WIP added summary bottom sheet for geo widget

* fixed maplayer to enum

* Initial Commit

* fetch related encounters

* fixed maplayer default value

* Update models

* converting bottom sheet view into configuration

* Refactor GeowWidgetLocation to Feature

* Update GeowWidget Config Model

* merged hamza's work for retrieve locations

* Update Feature Geometry model

* commiting half commit before merging Hamza's PR

* Fixed working summary bottom sheet opening directly through the widget fragment

* Fixed uncessary imports

* removed unnecessary code

* Refactor config for map layer

Signed-off-by: Elly Kitoto <[email protected]>

---------

Signed-off-by: Elly Kitoto <[email protected]>
Co-authored-by: Hamza Ahmed Khan <[email protected]>
Co-authored-by: Hamza Ahmed Khan <[email protected]>
Co-authored-by: Elly Kitoto <[email protected]>

* fixed import and gradle issue

* added dynamic trailing icons on toolbar with on click functionality (#3198)

* added dynamic trailing icons on toolbar with on click functionality

* added style for bottom sheet to round the corners from the top

---------

Co-authored-by: Benjamin Mwalimu <[email protected]>

* Dynamic trailing icons toolbar (#3203)

* added dynamic trailing icons on toolbar with on click functionality

* added style for bottom sheet to round the corners from the top

* added toggle map view icon on register config

* removed dropdownmenu icons for now

* ran spotless

* ran spotless

* spotless ran

* conflicts resolved and fixed imports

* Fix configuration of add location button on map view

* feedback updated

* 3155 cherry pick (#3260)

* Fix configuration of add location button on map view

* feedback updated

* Adding tests for geowidget work

* WIP fixing compilation error for tests

* spotless ran

* fixed some compilation errors on test

* fixed some UI tests compilation

* added more tests in geowidgetviewmodel

* deleted failed tests

* added more tests in geowidgetviewmodel

* removed failing test and class to check the overall coverage

---------

Signed-off-by: Elly Kitoto <[email protected]>
Co-authored-by: Aurangzaib Umer <[email protected]>
Co-authored-by: Benjamin Mwalimu <[email protected]>
Co-authored-by: aurangzaibumer <[email protected]>
Co-authored-by: Hamza Ahmed Khan <[email protected]>
Co-authored-by: Hamza Ahmed Khan <[email protected]>
Co-authored-by: Elly Kitoto <[email protected]>
Co-authored-by: Peter Lubell-Doughtie <[email protected]>
Co-authored-by: Lentumunai Mark <[email protected]>
  • Loading branch information
9 people authored May 20, 2024
1 parent 05d9903 commit b97ceea
Show file tree
Hide file tree
Showing 70 changed files with 41,751 additions and 1,226 deletions.
3 changes: 3 additions & 0 deletions android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ allprojects {
tasks.dependencyCheckAggregate{
dependencyCheck.formats.add("XML")
}
configurations.all{
resolutionStrategy.force ("com.google.android.gms:play-services-location:19.0.1")
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import kotlinx.serialization.Serializable
import org.smartregister.fhircore.engine.configuration.ConfigType
import org.smartregister.fhircore.engine.configuration.Configuration
import org.smartregister.fhircore.engine.configuration.event.EventWorkflow
import org.smartregister.fhircore.engine.domain.model.LauncherType

@Serializable
data class ApplicationConfiguration(
Expand All @@ -42,7 +43,10 @@ data class ApplicationConfiguration(
val taskBackgroundWorkerBatchSize: Int = 500,
val eventWorkflows: List<EventWorkflow> = emptyList(),
val logGpsLocation: List<LocationLogOptions> = emptyList(),
val usePractitionerAssignedLocationOnSync: Boolean = true,
val usePractitionerAssignedLocationOnSync: Boolean =
true, // TODO This defaults to scheduling periodic sync, otherwise use sync location ids from
// location selector
val launcherType: LauncherType = LauncherType.REGISTER,
) : Configuration()

enum class SyncStrategy {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,40 @@ 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
import org.smartregister.fhircore.engine.domain.model.ActionConfig
import org.smartregister.fhircore.engine.domain.model.FhirResourceConfig
import org.smartregister.fhircore.engine.domain.model.RuleConfig
import org.smartregister.fhircore.engine.domain.model.TopScreenSectionConfig

@Serializable
data class GeoWidgetConfiguration(
override var appId: String,
override var configType: String = ConfigType.GeoWidget.name,
val id: String,
val profileId: String,
val topScreenSection: TopScreenSectionConfig? = null,
val registrationQuestionnaire: QuestionnaireConfig,
val resourceConfig: FhirResourceConfig? = null,
val mapLayers: List<MapLayerConfig> = listOf(MapLayerConfig(MapLayer.STREET, true)),
val showLocation: Boolean = false,
val showPlaneSwitcher: Boolean = false,
val showAddLocation: Boolean = false,
val resourceConfig: FhirResourceConfig,
val servicePointConfig: ServicePointConfig?,
val summaryBottomSheetConfig: SummaryBottomSheetConfig? = null,
val actions: List<ActionConfig>? = emptyList(),
) : Configuration()

@Serializable
enum class MapLayer {
STREET,
SATELLITE,
STREET_SATELLITE,
}

@Serializable data class MapLayerConfig(val layer: MapLayer, val active: Boolean)

@Serializable
data class ServicePointConfig(
val rules: List<RuleConfig> = emptyList(),
val servicePointProperties: Map<String, String> = emptyMap(),
)
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,13 @@
* limitations under the License.
*/

package org.smartregister.fhircore.geowidget.model
package org.smartregister.fhircore.engine.configuration.geowidget

import android.os.Parcelable
import kotlinx.android.parcel.Parcelize
import kotlinx.serialization.Serializable
import org.smartregister.fhircore.engine.configuration.QuestionnaireConfig
import org.smartregister.fhircore.engine.configuration.geowidget.GeoWidgetConfiguration
import org.smartregister.fhircore.engine.configuration.view.ViewProperties

@Serializable
sealed class GeoWidgetEvent {

@Serializable
data class OpenProfile(val data: String, val geoWidgetConfiguration: GeoWidgetConfiguration) :
GeoWidgetEvent()

@Serializable
data class RegisterClient(val data: String, val questionnaire: QuestionnaireConfig) :
GeoWidgetEvent()
}
@Parcelize
data class SummaryBottomSheetConfig(val views: List<ViewProperties>? = emptyList()) : Parcelable
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import org.smartregister.fhircore.engine.configuration.Configuration
import org.smartregister.fhircore.engine.configuration.navigation.NavigationMenuConfig
import org.smartregister.fhircore.engine.domain.model.FhirResourceConfig
import org.smartregister.fhircore.engine.domain.model.RuleConfig
import org.smartregister.fhircore.engine.domain.model.TopScreenSectionConfig

@Serializable
data class RegisterConfiguration(
Expand All @@ -44,4 +45,5 @@ data class RegisterConfiguration(
),
val configRules: List<RuleConfig>? = null,
val registerFilter: RegisterFilterConfig? = null,
val topScreenSection: TopScreenSectionConfig? = null,
) : Configuration()
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ constructor(
suspend inline fun <reified R : Resource> search(search: Search) =
fhirEngine.search<R>(search).map { it.resource }

suspend inline fun count(search: Search) = fhirEngine.count(search)

/**
* Saves a resource in the database. It also updates the [Resource.meta.lastUpdated] and generates
* the [Resource.id] if it is missing before saving the resource.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright 2021-2024 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.domain.model

enum class LauncherType {
REGISTER,
MAP,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright 2021-2024 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.domain.model

import kotlinx.serialization.Serializable
import org.smartregister.fhircore.engine.configuration.register.RegisterContentConfig
import org.smartregister.fhircore.engine.configuration.view.ImageProperties

@Serializable
data class TopScreenSectionConfig(
val searchBar: RegisterContentConfig?,
val title: String? = null,
val menuIcons: List<ImageProperties>? = null,
)
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ enum class SharedPreferenceKey {
CARE_TEAM,
ORGANIZATION,
GEO_LOCATION,
SELECTED_LOCATION_ID,
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import android.content.Context
import android.location.Location
import android.location.LocationManager
import com.google.android.gms.location.FusedLocationProviderClient
import com.google.android.gms.location.Priority
import com.google.android.gms.location.LocationRequest
import com.google.android.gms.tasks.CancellationToken
import com.google.android.gms.tasks.CancellationTokenSource
import com.google.android.gms.tasks.OnTokenCanceledListener
Expand All @@ -44,7 +44,7 @@ object LocationUtils {
return suspendCoroutine { continuation ->
fusedLocationClient
.getCurrentLocation(
Priority.PRIORITY_HIGH_ACCURACY,
LocationRequest.PRIORITY_HIGH_ACCURACY,
object : CancellationToken() {
override fun onCanceledRequested(p0: OnTokenCanceledListener) =
CancellationTokenSource().token
Expand Down Expand Up @@ -72,7 +72,7 @@ object LocationUtils {
return suspendCoroutine { continuation ->
fusedLocationClient
.getCurrentLocation(
Priority.PRIORITY_BALANCED_POWER_ACCURACY,
LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY,
object : CancellationToken() {
override fun onCanceledRequested(p0: OnTokenCanceledListener) =
CancellationTokenSource().token
Expand Down
4 changes: 2 additions & 2 deletions android/engine/src/main/res/drawable/ic_csb_service_point.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="100dp"
android:height="100dp"
android:width="20dp"
android:height="20dp"
android:viewportWidth="100"
android:viewportHeight="100">
<path
Expand Down
4 changes: 2 additions & 2 deletions android/engine/src/main/res/drawable/ic_epp_service_point.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="100dp"
android:height="100dp"
android:width="20dp"
android:height="20dp"
android:viewportWidth="100"
android:viewportHeight="100">
<path
Expand Down
9 changes: 9 additions & 0 deletions android/engine/src/main/res/drawable/ic_gov.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="20dp"
android:height="20dp"
android:viewportWidth="100"
android:viewportHeight="100">
<path
android:fillColor="#FF000000"
android:pathData="M92.28,58.59V100H63.07V92.49H36.56V100H7.72V58.59ZM74.06,51a23.51,23.51 0,0 0,-7.88 -13.11A24.73,24.73 0,0 0,52 32h-0.39V18.07a6.21,6.21 0,0 0,1.24 -0.3c0.73,-0.26 1.5,-0.56 2.41,-0.88a23.09,23.09 0,0 1,2.57 -0.76,8.21 8.21,0 0,1 1.81,-0.28 13.72,13.72 0,0 1,2.85 0.37c1.15,0.29 2.37,0.6 3.61,1s2.44,0.71 3.56,1a11.78,11.78 0,0 0,2.74 0.36A14.88,14.88 0,0 0,76.26 18V2.88a9.66,9.66 0,0 1,-3.83 0.77,11.08 11.08,0 0,1 -2.74,-0.4c-1.12,-0.22 -2.27,-0.57 -3.56,-1s-2.42,-0.69 -3.5,-0.93A11.72,11.72 0,0 0,59.86 1a22.64,22.64 0,0 0,-8.22 1.78V0H48.07V32h-0.21a24.85,24.85 0,0 0,-14.14 5.92A24.46,24.46 0,0 0,25.83 51S22,50.33 22,54.64H78.28C78.28,50.81 74.06,51 74.06,51Z" />
</vector>
4 changes: 2 additions & 2 deletions android/engine/src/main/res/drawable/ic_hospital.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="100dp"
android:height="100dp"
android:width="20dp"
android:height="20dp"
android:viewportWidth="100"
android:viewportHeight="100">
<path
Expand Down
4 changes: 2 additions & 2 deletions android/engine/src/main/res/drawable/ic_men_service_point.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="100dp"
android:height="100dp"
android:width="20dp"
android:height="20dp"
android:viewportWidth="100"
android:viewportHeight="100">
<path
Expand Down
4 changes: 2 additions & 2 deletions android/engine/src/main/res/drawable/ic_ngo_partner.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="100dp"
android:height="100dp"
android:width="20dp"
android:height="20dp"
android:viewportWidth="100"
android:viewportHeight="100">
<path
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="100dp"
android:height="100dp"
android:width="20dp"
android:height="20dp"
android:viewportWidth="100"
android:viewportHeight="100">
<path
Expand Down
14 changes: 14 additions & 0 deletions android/engine/src/main/res/drawable/ic_toggle_map_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M8.243,2.945C8.507,2.794 8.829,2.785 9.101,2.921L15.277,6.009L20.64,2.945C20.921,2.784 21.267,2.785 21.547,2.948C21.827,3.111 22,3.41 22,3.734V16.957C22,17.284 21.825,17.585 21.542,17.747L15.757,21.052C15.493,21.203 15.171,21.212 14.899,21.076L8.723,17.988L3.36,21.052C3.079,21.213 2.733,21.212 2.453,21.049C2.173,20.887 2,20.587 2,20.263V7.04C2,6.714 2.175,6.413 2.458,6.251L8.243,2.945ZM8.723,4.765L3.818,7.568V18.697L8.243,16.168C8.507,16.017 8.829,16.008 9.101,16.144L15.277,19.233L20.182,16.43V5.301L15.757,7.829C15.493,7.98 15.171,7.989 14.899,7.853L8.723,4.765Z"
android:fillColor="#ffffff"
android:fillType="evenOdd"/>
<path
android:pathData="M8.694,2.825C9.196,2.825 9.603,3.232 9.603,3.734V16.957C9.603,17.459 9.196,17.867 8.694,17.867C8.192,17.867 7.785,17.459 7.785,16.957V3.734C7.785,3.232 8.192,2.825 8.694,2.825ZM15.306,6.131C15.808,6.131 16.215,6.538 16.215,7.04V20.263C16.215,20.765 15.808,21.172 15.306,21.172C14.804,21.172 14.397,20.765 14.397,20.263V7.04C14.397,6.538 14.804,6.131 15.306,6.131Z"
android:fillColor="#ffffff"
android:fillType="evenOdd"/>
</vector>
4 changes: 2 additions & 2 deletions android/engine/src/main/res/drawable/ic_warehouse.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="100dp"
android:height="100dp"
android:width="20dp"
android:height="20dp"
android:viewportWidth="100"
android:viewportHeight="100">
<path
Expand Down
4 changes: 2 additions & 2 deletions android/engine/src/main/res/drawable/ic_water_point.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="100dp"
android:height="100dp"
android:width="20dp"
android:height="20dp"
android:viewportWidth="100"
android:viewportHeight="100">
<path
Expand Down
Loading

0 comments on commit b97ceea

Please sign in to comment.