summaryrefslogtreecommitdiff
path: root/app/src/main/java/foundation/e
diff options
context:
space:
mode:
authorLeonard Kugis <leonard@kug.is>2024-01-04 00:09:06 +0100
committerLeonard Kugis <leonard@kug.is>2024-01-04 00:09:06 +0100
commitcb28d70fb5d220953dec337885601597c654e4fd (patch)
treec3a5bb2e6bc1e6015581be896b1685818f7a09fd /app/src/main/java/foundation/e
parent37568f2fb2da190c840d264c88cbc8ae42e083b1 (diff)
FakeLocation: Correct propagation of states
Diffstat (limited to 'app/src/main/java/foundation/e')
-rw-r--r--app/src/main/java/foundation/e/advancedprivacy/domain/usecases/FakeLocationStateUseCase.kt22
-rw-r--r--app/src/main/java/foundation/e/advancedprivacy/features/location/FakeLocationFragment.kt3
2 files changed, 19 insertions, 6 deletions
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<Location?>(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