summaryrefslogtreecommitdiff
path: root/app/src/main/java/foundation
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/foundation')
-rw-r--r--app/src/main/java/foundation/e/privacycentralapp/domain/usecases/FakeLocationStateUseCase.kt26
-rw-r--r--app/src/main/java/foundation/e/privacycentralapp/main/MainActivity.kt2
2 files changed, 12 insertions, 16 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..c026275 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
@@ -23,6 +23,7 @@ import android.location.Location
import android.location.LocationListener
import android.location.LocationManager
import android.os.Bundle
+import android.os.Looper
import android.util.Log
import foundation.e.privacycentralapp.data.repositories.LocalStateRepository
import foundation.e.privacycentralapp.domain.entities.LocationMode
@@ -68,8 +69,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 +90,7 @@ class FakeLocationStateUseCase(
localStateRepository.setShowQuickPrivacyDisabledMessage(true)
}
- setFakeLocation(latitude to longitude)
+ setFakeLocation(latitude to longitude, true)
}
fun setRandomLocation() {
@@ -103,9 +104,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 +118,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
@@ -172,14 +173,9 @@ class FakeLocationStateUseCase(
LocationManager.NETWORK_PROVIDER, // TODO: tight this with fakelocation module.
0L,
0f,
- listener
- )
- // locationManager.requestLocationUpdates(
- // LocationManager.NETWORK_PROVIDER, // TODO: tight this with fakelocation module.
- // 0L,
- // 0f,
- // listener
- // )
+ listener,
+ Looper.getMainLooper()
+ )
val location: Location? = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER)
location?.let { listener.onLocationChanged(it) }
diff --git a/app/src/main/java/foundation/e/privacycentralapp/main/MainActivity.kt b/app/src/main/java/foundation/e/privacycentralapp/main/MainActivity.kt
index 92a156a..e1ccae8 100644
--- a/app/src/main/java/foundation/e/privacycentralapp/main/MainActivity.kt
+++ b/app/src/main/java/foundation/e/privacycentralapp/main/MainActivity.kt
@@ -57,10 +57,10 @@ open class MainActivity : FragmentActivity(R.layout.activity_main) {
)
ACTION_VIEW_TRACKERS -> {
add<TrackersFragment>(R.id.container)
- addToBackStack("dashboard")
}
else -> add<DashboardFragment>(R.id.container)
}
+ disallowAddToBackStack()
}
}