From cb28d70fb5d220953dec337885601597c654e4fd Mon Sep 17 00:00:00 2001 From: Leonard Kugis Date: Thu, 4 Jan 2024 00:09:06 +0100 Subject: FakeLocation: Correct propagation of states --- .../domain/usecases/FakeLocationStateUseCase.kt | 22 ++++++++++++++++------ .../features/location/FakeLocationFragment.kt | 3 +++ 2 files changed, 19 insertions(+), 6 deletions(-) (limited to 'app/src/main') diff --git a/app/src/main/java/foundation/e/advancedprivacy/domain/usecases/FakeLocationStateUseCase.kt b/app/src/main/java/foundation/e/advancedprivacy/domain/usecases/FakeLocationStateUseCase.kt index 76a1e69..b7743df 100644 --- a/app/src/main/java/foundation/e/advancedprivacy/domain/usecases/FakeLocationStateUseCase.kt +++ b/app/src/main/java/foundation/e/advancedprivacy/domain/usecases/FakeLocationStateUseCase.kt @@ -245,6 +245,20 @@ class FakeLocationStateUseCase( } fun routeStart() { + _configuredLocationMode.value = FakeLocationState( + LocationMode.ROUTE, + null, + null, + null, + null, + null, + null, + false, + localStateRepository.route, + localStateRepository.routeLoopEnabled, + true + ) + if (hasAcquireMockLocationPermission()) { fakeLocationModule.startFakeLocation() fakeLocationModule.routeStart(localStateRepository.route, localStateRepository.routeLoopEnabled) @@ -254,12 +268,8 @@ class FakeLocationStateUseCase( } fun routeStop() { - if (hasAcquireMockLocationPermission()) { - fakeLocationModule.stopFakeLocation() - fakeLocationModule.routeStop() - } else { - useRealLocation() - } + fakeLocationModule.routeStop() + useRealLocation() } val currentLocation = MutableStateFlow(null) 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 6dafd5d..33884f7 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 @@ -443,6 +443,9 @@ class FakeLocationFragment : NavToolbarFragment(R.layout.fragment_fake_location) binding.buttonLocationRouteStart.isVisible = state.mode == LocationMode.ROUTE binding.buttonLocationRouteStop.isVisible = state.mode == LocationMode.ROUTE + binding.buttonLocationRouteStart.isEnabled = state.route != null + binding.checkboxRouteLoop.isEnabled = state.route != null + if(binding.checkboxRouteLoop.isVisible) binding.checkboxRouteLoop.isChecked = state.loopRoute -- cgit v1.2.1