diff options
Diffstat (limited to 'app/src/main/java/foundation/e/privacycentralapp/dummy')
| -rw-r--r-- | app/src/main/java/foundation/e/privacycentralapp/dummy/DummyDataSource.kt | 68 | ||||
| -rw-r--r-- | app/src/main/java/foundation/e/privacycentralapp/dummy/Extensions.kt | 29 |
2 files changed, 89 insertions, 8 deletions
diff --git a/app/src/main/java/foundation/e/privacycentralapp/dummy/DummyDataSource.kt b/app/src/main/java/foundation/e/privacycentralapp/dummy/DummyDataSource.kt index 65d072a..3f2dc1e 100644 --- a/app/src/main/java/foundation/e/privacycentralapp/dummy/DummyDataSource.kt +++ b/app/src/main/java/foundation/e/privacycentralapp/dummy/DummyDataSource.kt @@ -18,17 +18,21 @@ package foundation.e.privacycentralapp.dummy import foundation.e.privacycentralapp.R +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.asStateFlow +import kotlin.random.Random // ======================================================// // -// ============ ==== ==== ============ -// ============ ===== ===== ==== ==== -// ==== ====== ====== ==== ==== -// ==== ======= ======= ============ -// ==== ================ ==== -// ==== ==== ====== ==== ==== -// ============ ==== ==== ==== ==== -// ============ ==== == ==== ==== +// ================ ==== ==== =============== +// ================ ====== ====== ================ +// ==== ======== ======== ==== ==== +// ==== ========= ========= ==== ==== +// ==== ==================== ================ +// ==== ==== ======== ==== =============== +// ==== ==== ==== ==== ==== +// ================ ==== == ==== ==== +// ================ ==== ==== ==== // // ======================================================// @@ -47,7 +51,30 @@ data class Permission( val packagesAllowed: List<String> = emptyList() ) +enum class LocationMode { + REAL_LOCATION, RANDOM_LOCATION, CUSTOM_LOCATION +} + +enum class InternetPrivacyMode { + REAL_IP, HIDE_IP +} + +data class Location(val mode: LocationMode, val latitude: Double, val longitude: Double) + object DummyDataSource { + private val _appsUsingLocationPerm = MutableStateFlow<List<String>>(emptyList()) + val appsUsingLocationPerm = _appsUsingLocationPerm.asStateFlow() + + const val trackersCount = 77 + private val _activeTrackersCount = MutableStateFlow(10) + val activeTrackersCount = _activeTrackersCount.asStateFlow() + + private val _location = MutableStateFlow(Location(LocationMode.REAL_LOCATION, 0.0, 0.0)) + val location = _location.asStateFlow() + + private val _internetActivityMode = MutableStateFlow(InternetPrivacyMode.REAL_IP) + val internetActivityMode = _internetActivityMode.asStateFlow() + val permissions = arrayOf("Body Sensor", "Calendar", "Call Logs", "Location") val icons = arrayOf( R.drawable.ic_body_monitor, @@ -138,4 +165,29 @@ object DummyDataSource { fun getPermission(permissionId: Int): Permission { return populatedPermission.get(permissionId) } + + fun setLocationMode(locationMode: LocationMode, location: Location? = null): Boolean { + when (locationMode) { + LocationMode.REAL_LOCATION -> + _location.value = + Location(LocationMode.REAL_LOCATION, 24.39, 71.80) + LocationMode.RANDOM_LOCATION -> _location.value = randomLocation() + LocationMode.CUSTOM_LOCATION -> { + requireNotNull(location) { "Custom location should be null" } + _location.value = location.copy(mode = LocationMode.CUSTOM_LOCATION) + } + } + return true + } + + private fun randomLocation(): Location = Location( + LocationMode.RANDOM_LOCATION, + Random.nextDouble(-90.0, 90.0), + Random.nextDouble(-180.0, 180.0) + ) + + fun setInternetPrivacyMode(mode: InternetPrivacyMode): Boolean { + _internetActivityMode.value = mode + return true + } } diff --git a/app/src/main/java/foundation/e/privacycentralapp/dummy/Extensions.kt b/app/src/main/java/foundation/e/privacycentralapp/dummy/Extensions.kt new file mode 100644 index 0000000..c872012 --- /dev/null +++ b/app/src/main/java/foundation/e/privacycentralapp/dummy/Extensions.kt @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2021 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.dummy + +fun LocationMode.mapToString(): String = when (this) { + LocationMode.REAL_LOCATION -> "Real location mode" + LocationMode.RANDOM_LOCATION -> "Random location mode" + LocationMode.CUSTOM_LOCATION -> "Fake location mode" +} + +fun InternetPrivacyMode.mapToString(): String = when (this) { + InternetPrivacyMode.REAL_IP -> "I'm exposing my real IP address" + InternetPrivacyMode.HIDE_IP -> "I'm anonymous on the internet" +} |
