diff options
author | Alexandre Roux <alexandre.roux.danzi@lostpod.me> | 2022-04-25 15:16:25 +0000 |
---|---|---|
committer | Alexandre Roux <alexandre.roux.danzi@lostpod.me> | 2022-04-25 15:16:25 +0000 |
commit | f3c01e7bbf130c7f304b6bf50510c3800b8586f6 (patch) | |
tree | d9bee5a2fbcbe43bc0bbc121b4fd7dcc259ef8a3 /app/src/main/java/foundation/e/privacycentralapp/data | |
parent | 27dbc4ea2c3357481f93c765008a3d66a1d51a22 (diff) | |
parent | 3ca4c651aff84c551101337984bf1d457d892a1a (diff) | |
download | advanced-privacy-f3c01e7bbf130c7f304b6bf50510c3800b8586f6.tar.gz |
Merge branch '5311_main_toggle_wording' into 'main'
5311 main toggle wording, 5321 default settings
See merge request e/privacy-central/privacycentralapp!43
Diffstat (limited to 'app/src/main/java/foundation/e/privacycentralapp/data')
-rw-r--r-- | app/src/main/java/foundation/e/privacycentralapp/data/repositories/LocalStateRepository.kt | 38 |
1 files changed, 25 insertions, 13 deletions
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 9a7fd15..136b20f 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 @@ -18,6 +18,8 @@ package foundation.e.privacycentralapp.data.repositories import android.content.Context +import foundation.e.privacycentralapp.domain.entities.InternetPrivacyMode +import foundation.e.privacycentralapp.domain.entities.LocationMode import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableStateFlow @@ -26,6 +28,7 @@ class LocalStateRepository(context: Context) { private const val SHARED_PREFS_FILE = "localState" private const val KEY_QUICK_PRIVACY = "quickPrivacy" private const val KEY_IP_SCRAMBLING = "ipScrambling" + private const val KEY_FAKE_LOCATION = "fakeLocation" private const val KEY_FAKE_LATITUDE = "fakeLatitude" private const val KEY_FAKE_LONGITUDE = "fakeLongitude" private const val KEY_FIRST_BOOT = "firstBoot" @@ -35,43 +38,52 @@ class LocalStateRepository(context: Context) { private val quickPrivacyEnabledMutableFlow = MutableStateFlow<Boolean>(sharedPref.getBoolean(KEY_QUICK_PRIVACY, false)) - var isQuickPrivacyEnabled: Boolean - get() = quickPrivacyEnabledMutableFlow.value - set(value) { - set(KEY_QUICK_PRIVACY, value) - quickPrivacyEnabledMutableFlow.value = value - } + val isQuickPrivacyEnabled: Boolean get() = quickPrivacyEnabledMutableFlow.value + + fun setQuickPrivacyReturnIsFirstActivation(value: Boolean): Boolean { + val isFirstActivation = value && !sharedPref.contains(KEY_QUICK_PRIVACY) + set(KEY_QUICK_PRIVACY, value) + quickPrivacyEnabledMutableFlow.value = value + return isFirstActivation + } var quickPrivacyEnabledFlow: Flow<Boolean> = quickPrivacyEnabledMutableFlow + val areAllTrackersBlocked: MutableStateFlow<Boolean> = MutableStateFlow(false) + var fakeLocation: Pair<Float, Float>? - get() = if (sharedPref.contains(KEY_FAKE_LATITUDE) && sharedPref.contains( - KEY_FAKE_LONGITUDE - ) - ) + get() = if (sharedPref.getBoolean(KEY_FAKE_LOCATION, true)) Pair( - sharedPref.getFloat(KEY_FAKE_LATITUDE, 0f), - sharedPref.getFloat(KEY_FAKE_LONGITUDE, 0f) + // Initial default value is Quezon City + sharedPref.getFloat(KEY_FAKE_LATITUDE, 14.6760f), + sharedPref.getFloat(KEY_FAKE_LONGITUDE, 121.0437f) ) else null + set(value) { if (value == null) { sharedPref.edit() + .putBoolean(KEY_FAKE_LOCATION, false) .remove(KEY_FAKE_LATITUDE) .remove(KEY_FAKE_LONGITUDE) .commit() } else { sharedPref.edit() + .putBoolean(KEY_FAKE_LOCATION, true) .putFloat(KEY_FAKE_LATITUDE, value.first) .putFloat(KEY_FAKE_LONGITUDE, value.second) .commit() } } + val locationMode: MutableStateFlow<LocationMode> = MutableStateFlow(LocationMode.REAL_LOCATION) + var isIpScramblingEnabled: Boolean - get() = sharedPref.getBoolean(KEY_IP_SCRAMBLING, false) + get() = sharedPref.getBoolean(KEY_IP_SCRAMBLING, true) set(value) = set(KEY_IP_SCRAMBLING, value) + val internetPrivacyMode: MutableStateFlow<InternetPrivacyMode> = MutableStateFlow(InternetPrivacyMode.REAL_IP) + var firstBoot: Boolean get() = sharedPref.getBoolean(KEY_FIRST_BOOT, true) set(value) = set(KEY_FIRST_BOOT, value) |