diff options
author | Aayush Gupta <theimpulson@e.email> | 2022-05-16 03:38:57 +0000 |
---|---|---|
committer | Aayush Gupta <theimpulson@e.email> | 2022-05-16 03:38:57 +0000 |
commit | 7bbf1f130feb3d9008e8ef9247040b53c7058fc6 (patch) | |
tree | 83807b8cb194d7fc867244c4fadfeabec72b8fcc /app/src | |
parent | 7be179d6c4c8889eef755ff11d1b0af69ee20b8a (diff) | |
parent | b6536db42492c158d981a930f1e0ab5b7ef9f0d3 (diff) |
Merge branch '302-main-specific_location' into 'main'
privacycentralapp: properly set specific location
See merge request e/privacy-central/privacycentralapp!59
Diffstat (limited to 'app/src')
-rw-r--r-- | app/src/main/java/foundation/e/privacycentralapp/domain/usecases/FakeLocationStateUseCase.kt | 14 |
1 files changed, 7 insertions, 7 deletions
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..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 @@ -68,8 +68,8 @@ class FakeLocationStateUseCase( ) } - private fun applySettings(isQuickPrivacyEnabled: Boolean, fakeLocation: Pair<Float, Float>?) { - _configuredLocationMode.value = computeLocationMode(fakeLocation) + private fun applySettings(isQuickPrivacyEnabled: Boolean, fakeLocation: Pair<Float, Float>?, 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<Float, Float>) { + private fun setFakeLocation(location: Pair<Float, Float>, 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<Float, Float>?): Triple<LocationMode, Float?, Float?> { + private fun computeLocationMode(fakeLocation: Pair<Float, Float>?, isSpecificLocation: Boolean = false): Triple<LocationMode, Float?, Float?> { 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 |