From 9e1c091ed7611b9536eeb92c47da38caa9b20b00 Mon Sep 17 00:00:00 2001 From: TheScarastic Date: Fri, 13 May 2022 14:33:20 +0530 Subject: privacycentralapp: properly set specific location --- .../domain/usecases/FakeLocationStateUseCase.kt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'app/src/main/java/foundation/e') diff --git a/app/src/main/java/foundation/e/privacycentralapp/domain/usecases/FakeLocationStateUseCase.kt b/app/src/main/java/foundation/e/privacycentralapp/domain/usecases/FakeLocationStateUseCase.kt index fb773b2..bf4dfa4 100644 --- a/app/src/main/java/foundation/e/privacycentralapp/domain/usecases/FakeLocationStateUseCase.kt +++ b/app/src/main/java/foundation/e/privacycentralapp/domain/usecases/FakeLocationStateUseCase.kt @@ -68,8 +68,8 @@ class FakeLocationStateUseCase( ) } - private fun applySettings(isQuickPrivacyEnabled: Boolean, fakeLocation: Pair?) { - _configuredLocationMode.value = computeLocationMode(fakeLocation) + private fun applySettings(isQuickPrivacyEnabled: Boolean, fakeLocation: Pair?, isSpecificLocation: Boolean = false) { + _configuredLocationMode.value = computeLocationMode(fakeLocation, isSpecificLocation) if (isQuickPrivacyEnabled && fakeLocation != null) { if (permissionsModule.getAppOpMode(appDesc, AppOpsManager.OPSTR_MOCK_LOCATION) != AppOpModes.ALLOWED) { @@ -89,7 +89,7 @@ class FakeLocationStateUseCase( localStateRepository.setShowQuickPrivacyDisabledMessage(true) } - setFakeLocation(latitude to longitude) + setFakeLocation(latitude to longitude, true) } fun setRandomLocation() { @@ -103,9 +103,9 @@ class FakeLocationStateUseCase( setFakeLocation(location) } - private fun setFakeLocation(location: Pair) { + private fun setFakeLocation(location: Pair, isSpecificLocation: Boolean = false) { localStateRepository.fakeLocation = location - applySettings(localStateRepository.isQuickPrivacyEnabled, location) + applySettings(localStateRepository.isQuickPrivacyEnabled, location ,isSpecificLocation) } fun stopFakeLocation() { @@ -117,11 +117,11 @@ class FakeLocationStateUseCase( applySettings(localStateRepository.isQuickPrivacyEnabled, null) } - private fun computeLocationMode(fakeLocation: Pair?): Triple { + private fun computeLocationMode(fakeLocation: Pair?, isSpecificLocation: Boolean = false): Triple { return Triple( when { fakeLocation == null -> LocationMode.REAL_LOCATION - fakeLocation in citiesRepository.citiesLocationsList -> LocationMode.RANDOM_LOCATION + fakeLocation in citiesRepository.citiesLocationsList && !isSpecificLocation -> LocationMode.RANDOM_LOCATION else -> LocationMode.SPECIFIC_LOCATION }, fakeLocation?.first, fakeLocation?.second -- cgit v1.2.1 From b6536db42492c158d981a930f1e0ab5b7ef9f0d3 Mon Sep 17 00:00:00 2001 From: Jonathan Klee Date: Fri, 13 May 2022 12:20:41 +0000 Subject: Apply 1 suggestion(s) to 1 file(s) --- .../e/privacycentralapp/domain/usecases/FakeLocationStateUseCase.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/src/main/java/foundation/e') diff --git a/app/src/main/java/foundation/e/privacycentralapp/domain/usecases/FakeLocationStateUseCase.kt b/app/src/main/java/foundation/e/privacycentralapp/domain/usecases/FakeLocationStateUseCase.kt index bf4dfa4..a475aa2 100644 --- a/app/src/main/java/foundation/e/privacycentralapp/domain/usecases/FakeLocationStateUseCase.kt +++ b/app/src/main/java/foundation/e/privacycentralapp/domain/usecases/FakeLocationStateUseCase.kt @@ -105,7 +105,7 @@ class FakeLocationStateUseCase( private fun setFakeLocation(location: Pair, isSpecificLocation: Boolean = false) { localStateRepository.fakeLocation = location - applySettings(localStateRepository.isQuickPrivacyEnabled, location ,isSpecificLocation) + applySettings(localStateRepository.isQuickPrivacyEnabled, location, isSpecificLocation) } fun stopFakeLocation() { -- cgit v1.2.1