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 CALCULATE_DISTANCE_RULE_EXECUTOR LocationLogOption to Application_Config #3276

Merged
merged 7 commits into from
May 28, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,5 @@ enum class SyncStrategy {

enum class LocationLogOptions {
QUESTIONNAIRE,
CALCULATE_DISTANCE_RULE_EXECUTOR,
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import org.hl7.fhir.r4.model.QuestionnaireResponse
import org.smartregister.fhircore.engine.configuration.QuestionnaireConfig
import org.smartregister.fhircore.engine.configuration.app.ConfigService
import org.smartregister.fhircore.engine.configuration.app.LocationLogOptions
import org.smartregister.fhircore.engine.configuration.app.SyncStrategy
import org.smartregister.fhircore.engine.configuration.workflow.ActionTrigger
import org.smartregister.fhircore.engine.datastore.ProtoDataStore
Expand Down Expand Up @@ -218,18 +219,24 @@
}

private fun setupLocationServices() {
fusedLocationClient = LocationServices.getFusedLocationProviderClient(this)
if (
appMainViewModel.applicationConfiguration.logGpsLocation.contains(
LocationLogOptions.CALCULATE_DISTANCE_RULE_EXECUTOR,

Check warning on line 224 in android/quest/src/main/java/org/smartregister/fhircore/quest/ui/main/AppMainActivity.kt

View check run for this annotation

Codecov / codecov/patch

android/quest/src/main/java/org/smartregister/fhircore/quest/ui/main/AppMainActivity.kt#L224

Added line #L224 was not covered by tests
)
) {
fusedLocationClient = LocationServices.getFusedLocationProviderClient(this)

Check warning on line 227 in android/quest/src/main/java/org/smartregister/fhircore/quest/ui/main/AppMainActivity.kt

View check run for this annotation

Codecov / codecov/patch

android/quest/src/main/java/org/smartregister/fhircore/quest/ui/main/AppMainActivity.kt#L227

Added line #L227 was not covered by tests

if (!LocationUtils.isLocationEnabled(this)) {
openLocationServicesSettings()
}
if (!LocationUtils.isLocationEnabled(this)) {
openLocationServicesSettings()

Check warning on line 230 in android/quest/src/main/java/org/smartregister/fhircore/quest/ui/main/AppMainActivity.kt

View check run for this annotation

Codecov / codecov/patch

android/quest/src/main/java/org/smartregister/fhircore/quest/ui/main/AppMainActivity.kt#L230

Added line #L230 was not covered by tests
}

if (!hasLocationPermissions()) {
launchLocationPermissionsDialog()
}
if (!hasLocationPermissions()) {
launchLocationPermissionsDialog()

Check warning on line 234 in android/quest/src/main/java/org/smartregister/fhircore/quest/ui/main/AppMainActivity.kt

View check run for this annotation

Codecov / codecov/patch

android/quest/src/main/java/org/smartregister/fhircore/quest/ui/main/AppMainActivity.kt#L234

Added line #L234 was not covered by tests
}

if (LocationUtils.isLocationEnabled(this) && hasLocationPermissions()) {
fetchLocation()
if (LocationUtils.isLocationEnabled(this) && hasLocationPermissions()) {
fetchLocation()

Check warning on line 238 in android/quest/src/main/java/org/smartregister/fhircore/quest/ui/main/AppMainActivity.kt

View check run for this annotation

Codecov / codecov/patch

android/quest/src/main/java/org/smartregister/fhircore/quest/ui/main/AppMainActivity.kt#L238

Added line #L238 was not covered by tests
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ import org.smartregister.fhircore.engine.configuration.ConfigurationRegistry
import org.smartregister.fhircore.engine.configuration.QuestionnaireConfig
import org.smartregister.fhircore.engine.task.FhirCarePlanGenerator
import org.smartregister.fhircore.engine.util.SharedPreferenceKey
import org.smartregister.fhircore.engine.util.extension.second
import org.smartregister.fhircore.quest.app.fakes.Faker
import org.smartregister.fhircore.quest.event.AppEvent
import org.smartregister.fhircore.quest.event.EventBus
Expand Down Expand Up @@ -85,8 +84,8 @@ class AppMainActivityTest : ActivityRobolectricTest() {
fun testActivityIsStartedCorrectly() {
Assert.assertNotNull(appMainActivity)
val fragments = appMainActivity.supportFragmentManager.fragments
Assert.assertEquals(2, fragments.size)
Assert.assertTrue(fragments.second() is NavHostFragment)
Assert.assertEquals(1, fragments.size)
Assert.assertTrue(fragments.first() is NavHostFragment)
}

override fun getActivity(): Activity {
Expand Down
Loading