From 37568f2fb2da190c840d264c88cbc8ae42e083b1 Mon Sep 17 00:00:00 2001 From: Leonard Kugis Date: Wed, 3 Jan 2024 23:51:17 +0100 Subject: FakeLocation: Fixed camera position in ROUTE mode --- .../features/location/FakeLocationFragment.kt | 26 +++++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/foundation/e/advancedprivacy/features/location/FakeLocationFragment.kt b/app/src/main/java/foundation/e/advancedprivacy/features/location/FakeLocationFragment.kt index 3aaeb61..6dafd5d 100644 --- a/app/src/main/java/foundation/e/advancedprivacy/features/location/FakeLocationFragment.kt +++ b/app/src/main/java/foundation/e/advancedprivacy/features/location/FakeLocationFragment.kt @@ -455,11 +455,9 @@ class FakeLocationFragment : NavToolbarFragment(R.layout.fragment_fake_location) if(!binding.edittextJitter.isFocused) binding.edittextJitter.setText(state.jitter?.toString()) - if (state.mode == LocationMode.REAL_LOCATION) { - binding.centeredMarker.isVisible = false - } else { + if (state.mode == LocationMode.SPECIFIC_LOCATION) { binding.mapLoader.isVisible = false - binding.mapOverlay.isVisible = state.mode != LocationMode.SPECIFIC_LOCATION + binding.mapOverlay.isVisible = false binding.centeredMarker.isVisible = true mapboxMap?.moveCamera( CameraUpdateFactory.newLatLng( @@ -469,6 +467,22 @@ class FakeLocationFragment : NavToolbarFragment(R.layout.fragment_fake_location) ) ) ) + } else if(state.mode == LocationMode.ROUTE) { + binding.mapLoader.isVisible = false + binding.mapOverlay.isVisible = true + binding.centeredMarker.isVisible = false + state.route?.let { + mapboxMap?.moveCamera( + CameraUpdateFactory.newLatLng( + LatLng( + state.route.first().latitude.toDouble(), + state.route.first().longitude.toDouble() + ) + ) + ) + } + } else { + binding.centeredMarker.isVisible = false } binding.textlayoutLatitude.isVisible = (state.mode == LocationMode.SPECIFIC_LOCATION) @@ -492,7 +506,7 @@ class FakeLocationFragment : NavToolbarFragment(R.layout.fragment_fake_location) locationComponent?.isLocationComponentEnabled = true locationComponent?.forceLocationUpdate(location) - if (mode == LocationMode.REAL_LOCATION) { + if (mode != LocationMode.SPECIFIC_LOCATION) { binding.mapLoader.isVisible = false binding.mapOverlay.isVisible = false @@ -508,7 +522,7 @@ class FakeLocationFragment : NavToolbarFragment(R.layout.fragment_fake_location) } } ?: run { locationComponent?.isLocationComponentEnabled = false - if (mode == LocationMode.REAL_LOCATION) { + if (mode != LocationMode.SPECIFIC_LOCATION) { binding.mapLoader.isVisible = true binding.mapOverlay.isVisible = true } -- cgit v1.2.1