summaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
authorjacquarg <guillaume.jacquart@hoodbrains.com>2022-04-23 16:29:10 +0200
committerjacquarg <guillaume.jacquart@hoodbrains.com>2022-04-26 18:09:43 +0200
commit66baccf4d687926e315bd7371ee523dd44519c32 (patch)
treedfb00272a67b5f29818b7c8bb14c6a97dc0e33af /app/src/main
parentd0f8ec47a5780ba7de15e3d1ebcaa9a1df77da43 (diff)
5290 : allow settings while main toggle off.
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/foundation/e/privacycentralapp/DependencyContainer.kt2
-rw-r--r--app/src/main/java/foundation/e/privacycentralapp/common/QuickPrivacyDisabledSnackbar.kt36
-rw-r--r--app/src/main/java/foundation/e/privacycentralapp/data/repositories/LocalStateRepository.kt8
-rw-r--r--app/src/main/java/foundation/e/privacycentralapp/domain/usecases/FakeLocationStateUseCase.kt59
-rw-r--r--app/src/main/java/foundation/e/privacycentralapp/domain/usecases/GetQuickPrivacyStateUseCase.kt27
-rw-r--r--app/src/main/java/foundation/e/privacycentralapp/features/location/FakeLocationFeature.kt87
-rw-r--r--app/src/main/java/foundation/e/privacycentralapp/features/location/FakeLocationFragment.kt52
-rw-r--r--app/src/main/java/foundation/e/privacycentralapp/main/MainActivity.kt6
-rw-r--r--app/src/main/res/layout/fragment_fake_location.xml3
-rw-r--r--app/src/main/res/values/strings.xml3
10 files changed, 180 insertions, 103 deletions
diff --git a/app/src/main/java/foundation/e/privacycentralapp/DependencyContainer.kt b/app/src/main/java/foundation/e/privacycentralapp/DependencyContainer.kt
index 4a790c6..0a06708 100644
--- a/app/src/main/java/foundation/e/privacycentralapp/DependencyContainer.kt
+++ b/app/src/main/java/foundation/e/privacycentralapp/DependencyContainer.kt
@@ -78,7 +78,7 @@ class DependencyContainer(val app: Application) {
// Usecases
val getQuickPrivacyStateUseCase by lazy {
- GetQuickPrivacyStateUseCase(localStateRepository)
+ GetQuickPrivacyStateUseCase(localStateRepository, GlobalScope)
}
private val ipScramblingStateUseCase by lazy {
IpScramblingStateUseCase(
diff --git a/app/src/main/java/foundation/e/privacycentralapp/common/QuickPrivacyDisabledSnackbar.kt b/app/src/main/java/foundation/e/privacycentralapp/common/QuickPrivacyDisabledSnackbar.kt
new file mode 100644
index 0000000..705f65d
--- /dev/null
+++ b/app/src/main/java/foundation/e/privacycentralapp/common/QuickPrivacyDisabledSnackbar.kt
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2022 E FOUNDATION
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package foundation.e.privacycentralapp.common
+
+import android.view.View
+import com.google.android.material.snackbar.BaseTransientBottomBar
+import com.google.android.material.snackbar.Snackbar
+import foundation.e.privacycentralapp.R
+
+fun initQuickPrivacySnackbar(view: View, onDismiss: () -> Unit): Snackbar {
+ val snackbar = Snackbar.make(view, R.string.quickprivacy_disabled_message, Snackbar.LENGTH_INDEFINITE)
+ snackbar.setAction(R.string.close) { onDismiss() }
+
+ snackbar.addCallback(object : BaseTransientBottomBar.BaseCallback<Snackbar>() {
+ override fun onDismissed(transientBottomBar: Snackbar?, event: Int) {
+ super.onDismissed(transientBottomBar, event)
+ if (event == DISMISS_EVENT_SWIPE) onDismiss()
+ }
+ })
+ return snackbar
+}
diff --git a/app/src/main/java/foundation/e/privacycentralapp/data/repositories/LocalStateRepository.kt b/app/src/main/java/foundation/e/privacycentralapp/data/repositories/LocalStateRepository.kt
index 136b20f..b4bca0b 100644
--- a/app/src/main/java/foundation/e/privacycentralapp/data/repositories/LocalStateRepository.kt
+++ b/app/src/main/java/foundation/e/privacycentralapp/data/repositories/LocalStateRepository.kt
@@ -22,6 +22,7 @@ import foundation.e.privacycentralapp.domain.entities.InternetPrivacyMode
import foundation.e.privacycentralapp.domain.entities.LocationMode
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
+import kotlinx.coroutines.flow.StateFlow
class LocalStateRepository(context: Context) {
companion object {
@@ -84,6 +85,13 @@ class LocalStateRepository(context: Context) {
val internetPrivacyMode: MutableStateFlow<InternetPrivacyMode> = MutableStateFlow(InternetPrivacyMode.REAL_IP)
+ private val _showQuickPrivacyDisabledMessage = MutableStateFlow(false)
+ val showQuickPrivacyDisabledMessage: StateFlow<Boolean> = _showQuickPrivacyDisabledMessage
+
+ fun setShowQuickPrivacyDisabledMessage(show: Boolean) {
+ _showQuickPrivacyDisabledMessage.value = show
+ }
+
var firstBoot: Boolean
get() = sharedPref.getBoolean(KEY_FIRST_BOOT, true)
set(value) = set(KEY_FIRST_BOOT, value)
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 c07657a..fb773b2 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
@@ -33,6 +33,7 @@ import foundation.e.privacymodules.permissions.data.AppOpModes
import foundation.e.privacymodules.permissions.data.ApplicationDescription
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.MutableStateFlow
+import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.launch
import kotlin.random.Random
@@ -46,8 +47,8 @@ class FakeLocationStateUseCase(
private val appContext: Context,
private val coroutineScope: CoroutineScope
) {
- // private val _locationMode = MutableStateFlow(LocationMode.REAL_LOCATION)
- // val locationMode: StateFlow<LocationMode> = _locationMode
+ private val _configuredLocationMode = MutableStateFlow<Triple<LocationMode, Float?, Float?>>(Triple(LocationMode.REAL_LOCATION, null, null))
+ val configuredLocationMode: StateFlow<Triple<LocationMode, Float?, Float?>> = _configuredLocationMode
init {
coroutineScope.launch {
@@ -60,44 +61,23 @@ class FakeLocationStateUseCase(
private val locationManager: LocationManager
get() = appContext.getSystemService(Context.LOCATION_SERVICE) as LocationManager
- fun getLocationMode(): Triple<LocationMode, Float?, Float?> {
- val fakeLocation = localStateRepository.fakeLocation
- return if (fakeLocation != null && localStateRepository.locationMode.value == LocationMode.SPECIFIC_LOCATION) {
- Triple(
- LocationMode.SPECIFIC_LOCATION,
- fakeLocation.first,
- fakeLocation.second
- )
- } else {
- Triple(localStateRepository.locationMode.value, null, null)
- }
- }
-
private fun acquireLocationPermission() {
permissionsModule.toggleDangerousPermission(
appDesc,
android.Manifest.permission.ACCESS_FINE_LOCATION, true
)
-
- // permissionsModule.setAppOpMode(
- // appDesc, AppOpsManager.OPSTR_COARSE_LOCATION,
- // AppOpModes.ALLOWED
- // )
- // permissionsModule.setAppOpMode(
- // appDesc, AppOpsManager.OPSTR_FINE_LOCATION,
- // AppOpModes.ALLOWED
- // )
}
private fun applySettings(isQuickPrivacyEnabled: Boolean, fakeLocation: Pair<Float, Float>?) {
+ _configuredLocationMode.value = computeLocationMode(fakeLocation)
+
if (isQuickPrivacyEnabled && fakeLocation != null) {
if (permissionsModule.getAppOpMode(appDesc, AppOpsManager.OPSTR_MOCK_LOCATION) != AppOpModes.ALLOWED) {
permissionsModule.setAppOpMode(appDesc, AppOpsManager.OPSTR_MOCK_LOCATION, AppOpModes.ALLOWED)
}
fakeLocationModule.startFakeLocation()
fakeLocationModule.setFakeLocation(fakeLocation.first.toDouble(), fakeLocation.second.toDouble())
- localStateRepository.locationMode.value = if (fakeLocation in citiesRepository.citiesLocationsList) LocationMode.RANDOM_LOCATION
- else LocationMode.SPECIFIC_LOCATION
+ localStateRepository.locationMode.value = configuredLocationMode.value.first
} else {
fakeLocationModule.stopFakeLocation()
localStateRepository.locationMode.value = LocationMode.REAL_LOCATION
@@ -105,10 +85,18 @@ class FakeLocationStateUseCase(
}
fun setSpecificLocation(latitude: Float, longitude: Float) {
+ if (!localStateRepository.isQuickPrivacyEnabled) {
+ localStateRepository.setShowQuickPrivacyDisabledMessage(true)
+ }
+
setFakeLocation(latitude to longitude)
}
fun setRandomLocation() {
+ if (!localStateRepository.isQuickPrivacyEnabled) {
+ localStateRepository.setShowQuickPrivacyDisabledMessage(true)
+ }
+
val randomIndex = Random.nextInt(citiesRepository.citiesLocationsList.size)
val location = citiesRepository.citiesLocationsList[randomIndex]
@@ -117,12 +105,27 @@ class FakeLocationStateUseCase(
private fun setFakeLocation(location: Pair<Float, Float>) {
localStateRepository.fakeLocation = location
- applySettings(true, location)
+ applySettings(localStateRepository.isQuickPrivacyEnabled, location)
}
fun stopFakeLocation() {
+ if (!localStateRepository.isQuickPrivacyEnabled) {
+ localStateRepository.setShowQuickPrivacyDisabledMessage(true)
+ }
+
localStateRepository.fakeLocation = null
- applySettings(true, null)
+ applySettings(localStateRepository.isQuickPrivacyEnabled, null)
+ }
+
+ private fun computeLocationMode(fakeLocation: Pair<Float, Float>?): Triple<LocationMode, Float?, Float?> {
+ return Triple(
+ when {
+ fakeLocation == null -> LocationMode.REAL_LOCATION
+ fakeLocation in citiesRepository.citiesLocationsList -> LocationMode.RANDOM_LOCATION
+ else -> LocationMode.SPECIFIC_LOCATION
+ },
+ fakeLocation?.first, fakeLocation?.second
+ )
}
val currentLocation = MutableStateFlow<Location?>(null)
diff --git a/app/src/main/java/foundation/e/privacycentralapp/domain/usecases/GetQuickPrivacyStateUseCase.kt b/app/src/main/java/foundation/e/privacycentralapp/domain/usecases/GetQuickPrivacyStateUseCase.kt
index fd9430c..6e2e7cf 100644
--- a/app/src/main/java/foundation/e/privacycentralapp/domain/usecases/GetQuickPrivacyStateUseCase.kt
+++ b/app/src/main/java/foundation/e/privacycentralapp/domain/usecases/GetQuickPrivacyStateUseCase.kt
@@ -21,10 +21,25 @@ import foundation.e.privacycentralapp.data.repositories.LocalStateRepository
import foundation.e.privacycentralapp.domain.entities.InternetPrivacyMode
import foundation.e.privacycentralapp.domain.entities.LocationMode
import foundation.e.privacycentralapp.domain.entities.QuickPrivacyState
+import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.StateFlow
+import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.combine
+import kotlinx.coroutines.launch
+
+class GetQuickPrivacyStateUseCase(
+ private val localStateRepository: LocalStateRepository,
+ private val coroutineScope: CoroutineScope
+) {
+
+ init {
+ coroutineScope.launch {
+ localStateRepository.quickPrivacyEnabledFlow.collect {
+ if (it) resetQuickPrivacyDisabledMessage()
+ }
+ }
+ }
-class GetQuickPrivacyStateUseCase(private val localStateRepository: LocalStateRepository) {
val quickPrivacyEnabledFlow = localStateRepository.quickPrivacyEnabledFlow
val isQuickPrivacyEnabled get() = localStateRepository.isQuickPrivacyEnabled
@@ -77,4 +92,14 @@ class GetQuickPrivacyStateUseCase(private val localStateRepository: LocalStateRe
val newState = !localStateRepository.isQuickPrivacyEnabled
return localStateRepository.setQuickPrivacyReturnIsFirstActivation(newState)
}
+
+ val showQuickPrivacyDisabledMessage: StateFlow<Boolean> = localStateRepository.showQuickPrivacyDisabledMessage
+
+ // fun setQuickPrivacyDisabledMessage() {
+ // localStateRepository.setShowQuickPrivacyDisabledMessage(true)
+ // }
+
+ fun resetQuickPrivacyDisabledMessage() {
+ localStateRepository.setShowQuickPrivacyDisabledMessage(false)
+ }
}
diff --git a/app/src/main/java/foundation/e/privacycentralapp/features/location/FakeLocationFeature.kt b/app/src/main/java/foundation/e/privacycentralapp/features/location/FakeLocationFeature.kt
index a7869ce..faac5a4 100644
--- a/app/src/main/java/foundation/e/privacycentralapp/features/location/FakeLocationFeature.kt
+++ b/app/src/main/java/foundation/e/privacycentralapp/features/location/FakeLocationFeature.kt
@@ -27,7 +27,6 @@ import foundation.e.privacycentralapp.domain.entities.LocationMode
import foundation.e.privacycentralapp.domain.usecases.FakeLocationStateUseCase
import foundation.e.privacycentralapp.domain.usecases.GetQuickPrivacyStateUseCase
import kotlinx.coroutines.CoroutineScope
-import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.merge
@@ -48,16 +47,17 @@ class FakeLocationFeature(
singleEventProducer
) {
data class State(
- val isEnabled: Boolean,
- val mode: LocationMode,
- val currentLocation: Location?,
+ val isEnabled: Boolean = true,
+ val mode: LocationMode = LocationMode.REAL_LOCATION,
+ val currentLocation: Location? = null,
val specificLatitude: Float? = null,
val specificLongitude: Float? = null,
- val forceRefresh: Boolean = false
+ val forceRefresh: Boolean = false,
+ val showQuickPrivacyDisabledMessage: Boolean = false
)
sealed class SingleEvent {
- data class LocationUpdatedEvent(val location: Location?) : SingleEvent()
+ data class LocationUpdatedEvent(val mode: LocationMode, val location: Location?) : SingleEvent()
data class ErrorEvent(val error: String) : SingleEvent()
}
@@ -70,6 +70,7 @@ class FakeLocationFeature(
val latitude: Float,
val longitude: Float
) : Action()
+ object CloseQuickPrivacyDisabledMessage : Action()
}
sealed class Effect {
@@ -81,17 +82,13 @@ class FakeLocationFeature(
) : Effect()
data class LocationUpdatedEffect(val location: Location?) : Effect()
data class ErrorEffect(val message: String) : Effect()
- object QuickPrivacyDisabledWarningEffect : Effect()
object NoEffect : Effect()
+ data class ShowQuickPrivacyDisabledMessageEffect(val show: Boolean) : Effect()
}
companion object {
fun create(
- initialState: State = State(
- isEnabled = false,
- mode = LocationMode.REAL_LOCATION,
- currentLocation = null
- ),
+ initialState: State = State(),
getQuickPrivacyStateUseCase: GetQuickPrivacyStateUseCase,
fakeLocationStateUseCase: FakeLocationStateUseCase,
coroutineScope: CoroutineScope
@@ -99,66 +96,58 @@ class FakeLocationFeature(
initialState, coroutineScope,
reducer = { state, effect ->
when (effect) {
- is Effect.QuickPrivacyUpdatedEffect -> state.copy(isEnabled = effect.isEnabled)
is Effect.LocationModeUpdatedEffect -> state.copy(
mode = effect.mode,
specificLatitude = effect.latitude,
specificLongitude = effect.longitude
)
- Effect.QuickPrivacyDisabledWarningEffect -> state.copy(forceRefresh = !state.forceRefresh)
+ is Effect.ShowQuickPrivacyDisabledMessageEffect -> state.copy(showQuickPrivacyDisabledMessage = effect.show)
else -> state
}
},
- actor = { state, action ->
+ actor = { _, action ->
when (action) {
- is Action.Init -> merge(
- getQuickPrivacyStateUseCase.quickPrivacyEnabledFlow.map { Effect.QuickPrivacyUpdatedEffect(it) },
- flow {
- fakeLocationStateUseCase.startListeningLocation()
- val (mode, lat, lon) = fakeLocationStateUseCase.getLocationMode()
- emit(Effect.LocationModeUpdatedEffect(mode = mode, latitude = lat, longitude = lon))
- },
- fakeLocationStateUseCase.currentLocation.map { Effect.LocationUpdatedEffect(it) }
- )
+ is Action.Init -> {
+ fakeLocationStateUseCase.startListeningLocation()
+
+ merge(
+ getQuickPrivacyStateUseCase.quickPrivacyEnabledFlow.map { Effect.QuickPrivacyUpdatedEffect(it) },
+ fakeLocationStateUseCase.configuredLocationMode.map { (mode, lat, lon) ->
+ Effect.LocationModeUpdatedEffect(mode = mode, latitude = lat, longitude = lon)
+ },
+ fakeLocationStateUseCase.currentLocation.map { Effect.LocationUpdatedEffect(it) },
+ getQuickPrivacyStateUseCase.showQuickPrivacyDisabledMessage.map { Effect.ShowQuickPrivacyDisabledMessageEffect(it) },
+ )
+ }
is Action.LeaveScreen -> {
fakeLocationStateUseCase.stopListeningLocation()
flowOf(Effect.NoEffect)
}
is Action.SetSpecificLocationAction -> {
- if (state.isEnabled) {
- fakeLocationStateUseCase.setSpecificLocation(
- action.latitude,
- action.longitude
- )
- flowOf(
- Effect.LocationModeUpdatedEffect(
- mode = LocationMode.SPECIFIC_LOCATION,
- latitude = action.latitude,
- longitude = action.longitude
- )
- )
- } else flowOf(Effect.QuickPrivacyDisabledWarningEffect)
+ fakeLocationStateUseCase.setSpecificLocation(
+ action.latitude,
+ action.longitude
+ )
+ flowOf(Effect.NoEffect)
}
is Action.UseRandomLocationAction -> {
- if (state.isEnabled) {
- fakeLocationStateUseCase.setRandomLocation()
- flowOf(Effect.LocationModeUpdatedEffect(LocationMode.RANDOM_LOCATION))
- } else flowOf(Effect.QuickPrivacyDisabledWarningEffect)
+ fakeLocationStateUseCase.setRandomLocation()
+ flowOf(Effect.NoEffect)
}
is Action.UseRealLocationAction -> {
- if (state.isEnabled) {
- fakeLocationStateUseCase.stopFakeLocation()
- flowOf(Effect.LocationModeUpdatedEffect(LocationMode.REAL_LOCATION))
- } else flowOf(Effect.QuickPrivacyDisabledWarningEffect)
+ fakeLocationStateUseCase.stopFakeLocation()
+ flowOf(Effect.NoEffect)
+ }
+ is Action.CloseQuickPrivacyDisabledMessage -> {
+ getQuickPrivacyStateUseCase.resetQuickPrivacyDisabledMessage()
+ flowOf(Effect.NoEffect)
}
}
},
- singleEventProducer = { _, _, effect ->
+ singleEventProducer = { state, _, effect ->
when (effect) {
is Effect.LocationUpdatedEffect ->
- SingleEvent.LocationUpdatedEvent(effect.location)
- Effect.QuickPrivacyDisabledWarningEffect ->
- SingleEvent.ErrorEvent("Enabled Quick Privacy to use functionalities")
+ SingleEvent.LocationUpdatedEvent(state.mode, effect.location)
is Effect.ErrorEffect -> SingleEvent.ErrorEvent(effect.message)
else -> null
}
diff --git a/app/src/main/java/foundation/e/privacycentralapp/features/location/FakeLocationFragment.kt b/app/src/main/java/foundation/e/privacycentralapp/features/location/FakeLocationFragment.kt
index bc35521..2999eb6 100644
--- a/app/src/main/java/foundation/e/privacycentralapp/features/location/FakeLocationFragment.kt
+++ b/app/src/main/java/foundation/e/privacycentralapp/features/location/FakeLocationFragment.kt
@@ -22,6 +22,7 @@ import android.content.Context
import android.location.Location
import android.os.Bundle
import android.text.Editable
+import android.util.Log
import android.view.View
import android.widget.Toast
import androidx.annotation.NonNull
@@ -29,6 +30,7 @@ import androidx.core.view.isVisible
import androidx.core.widget.addTextChangedListener
import androidx.fragment.app.viewModels
import androidx.lifecycle.lifecycleScope
+import com.google.android.material.snackbar.Snackbar
import com.google.android.material.textfield.TextInputEditText
import com.google.android.material.textfield.TextInputLayout
import com.google.android.material.textfield.TextInputLayout.END_ICON_CUSTOM
@@ -48,6 +50,7 @@ import foundation.e.privacycentralapp.DependencyContainer
import foundation.e.privacycentralapp.PrivacyCentralApplication
import foundation.e.privacycentralapp.R
import foundation.e.privacycentralapp.common.NavToolbarFragment
+import foundation.e.privacycentralapp.common.initQuickPrivacySnackbar
import foundation.e.privacycentralapp.databinding.FragmentFakeLocationBinding
import foundation.e.privacycentralapp.domain.entities.LocationMode
import foundation.e.privacycentralapp.extensions.viewModelProviderFactoryOf
@@ -78,6 +81,8 @@ class FakeLocationFragment :
private var mapboxMap: MapboxMap? = null
private var locationComponent: LocationComponent? = null
+ private var qpDisabledSnackbar: Snackbar? = null
+
private var inputJob: Job? = null
companion object {
@@ -97,18 +102,7 @@ class FakeLocationFragment :
displayToast(event.error)
}
is FakeLocationFeature.SingleEvent.LocationUpdatedEvent -> {
- if (isFirstLaunch && mapboxMap != null) {
- mapboxMap?.moveCamera(
- CameraUpdateFactory.newLatLng(
- LatLng(
- event.location?.latitude ?: 0.0,
- event.location?.longitude ?: 0.0
- )
- )
- )
- isFirstLaunch = false
- }
- updateLocation(event.location)
+ updateLocation(event.location, event.mode)
}
}
}
@@ -151,8 +145,14 @@ class FakeLocationFragment :
}
// Bind click listeners once map is ready.
bindClickListeners()
+
+ render(viewModel.fakeLocationFeature.state.value)
}
}
+
+ qpDisabledSnackbar = initQuickPrivacySnackbar(binding.root) {
+ viewModel.submitAction(Action.CloseQuickPrivacyDisabledMessage)
+ }
}
private fun getCoordinatesAfterTextChanged(
@@ -232,6 +232,9 @@ class FakeLocationFragment :
@SuppressLint("MissingPermission")
override fun render(state: FakeLocationFeature.State) {
+ if (state.showQuickPrivacyDisabledMessage) qpDisabledSnackbar?.show()
+ else qpDisabledSnackbar?.dismiss()
+
binding.radioUseRandomLocation.apply {
isChecked = state.mode == LocationMode.RANDOM_LOCATION
isEnabled = state.isEnabled
@@ -249,13 +252,14 @@ class FakeLocationFragment :
binding.mapView.isEnabled = (state.mode == LocationMode.SPECIFIC_LOCATION)
- if (state.mode != LocationMode.SPECIFIC_LOCATION) {
+ if (state.mode == LocationMode.REAL_LOCATION) {
binding.centeredMarker.isVisible = false
} else {
binding.mapLoader.isVisible = false
- binding.mapOverlay.isVisible = false
+ binding.mapOverlay.isVisible = state.mode != LocationMode.SPECIFIC_LOCATION
binding.centeredMarker.isVisible = true
+ Log.d("LocationTest", "is mapboxMap null: ${mapboxMap == null}")
mapboxMap?.moveCamera(
CameraUpdateFactory.newLatLng(
LatLng(
@@ -276,7 +280,7 @@ class FakeLocationFragment :
override fun actions(): Flow<Action> = viewModel.actions
@SuppressLint("MissingPermission")
- private fun updateLocation(lastLocation: Location?) {
+ private fun updateLocation(lastLocation: Location?, mode: LocationMode) {
lastLocation?.let { location ->
locationComponent?.isLocationComponentEnabled = true
val locationUpdate = LocationUpdate.Builder()
@@ -285,18 +289,24 @@ class FakeLocationFragment :
.build()
locationComponent?.forceLocationUpdate(locationUpdate)
- if (!binding.mapView.isEnabled) {
+ if (mode == LocationMode.REAL_LOCATION) {
binding.mapLoader.isVisible = false
binding.mapOverlay.isVisible = false
- mapboxMap?.animateCamera(
- CameraUpdateFactory.newLatLng(
- LatLng(location.latitude, location.longitude)
- )
+
+ val update = CameraUpdateFactory.newLatLng(
+ LatLng(location.latitude, location.longitude)
)
+
+ if (isFirstLaunch) {
+ mapboxMap?.moveCamera(update)
+ isFirstLaunch = false
+ } else {
+ mapboxMap?.animateCamera(update)
+ }
}
} ?: run {
locationComponent?.isLocationComponentEnabled = false
- if (!binding.mapView.isEnabled) {
+ if (mode == LocationMode.REAL_LOCATION) {
binding.mapLoader.isVisible = true
binding.mapOverlay.isVisible = true
}
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 c0bdcf0..910385e 100644
--- a/app/src/main/java/foundation/e/privacycentralapp/main/MainActivity.kt
+++ b/app/src/main/java/foundation/e/privacycentralapp/main/MainActivity.kt
@@ -23,6 +23,7 @@ import android.os.Bundle
import androidx.fragment.app.FragmentActivity
import androidx.fragment.app.add
import androidx.fragment.app.commit
+import foundation.e.privacycentralapp.PrivacyCentralApplication
import foundation.e.privacycentralapp.R
import foundation.e.privacycentralapp.features.dashboard.DashboardFragment
import kotlinx.coroutines.FlowPreview
@@ -47,6 +48,11 @@ open class MainActivity : FragmentActivity(R.layout.activity_main) {
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
+
+ (application as? PrivacyCentralApplication)
+ ?.dependencyContainer?.getQuickPrivacyStateUseCase
+ ?.resetQuickPrivacyDisabledMessage()
+
handleIntent(intent)
}
diff --git a/app/src/main/res/layout/fragment_fake_location.xml b/app/src/main/res/layout/fragment_fake_location.xml
index 64432cb..47b86bf 100644
--- a/app/src/main/res/layout/fragment_fake_location.xml
+++ b/app/src/main/res/layout/fragment_fake_location.xml
@@ -9,6 +9,7 @@
android:layout_width="match_parent"
>
+
<include layout="@layout/topbar" />
<androidx.core.widget.NestedScrollView
@@ -16,7 +17,6 @@
android:layout_width="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
>
-
<LinearLayout
android:layout_height="match_parent"
android:padding="16dp"
@@ -24,7 +24,6 @@
android:orientation="vertical"
tools:context=".main.MainActivity"
>
-
<TextView
android:id="@+id/fake_location_info"
android:layout_gravity="center_horizontal"
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index cd9c9bd..489dff2 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -7,7 +7,8 @@
<string name="graph_legend_blocked">Blocked leaks</string>
<string name="graph_legend_allowed">Allowed leaks</string>
<string name="graph_subtitle">Tap on the bars for more information.</string>
-
+ <string name="quickprivacy_disabled_message">Changes will only be effective when privacy protection toggle is enabled.</string>
+ <string name="close">Close</string>
<!-- Dashboard -->
<string name="dashboard_title">@string/app_name</string>