From 3ca4c651aff84c551101337984bf1d457d892a1a Mon Sep 17 00:00:00 2001 From: Guillaume Jacquart Date: Mon, 25 Apr 2022 15:16:21 +0000 Subject: 5311 main toggle wording, 5321 default settings --- .../data/repositories/LocalStateRepository.kt | 38 ++++++++++++++-------- 1 file changed, 25 insertions(+), 13 deletions(-) (limited to 'app/src/main/java/foundation/e/privacycentralapp/data') 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(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 = quickPrivacyEnabledMutableFlow + val areAllTrackersBlocked: MutableStateFlow = MutableStateFlow(false) + var fakeLocation: Pair? - 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 = 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 = MutableStateFlow(InternetPrivacyMode.REAL_IP) + var firstBoot: Boolean get() = sharedPref.getBoolean(KEY_FIRST_BOOT, true) set(value) = set(KEY_FIRST_BOOT, value) -- cgit v1.2.3