diff options
| author | jacquarg <guillaume.jacquart@hoodbrains.com> | 2021-11-07 22:43:32 +0100 |
|---|---|---|
| committer | jacquarg <guillaume.jacquart@hoodbrains.com> | 2021-11-12 13:13:23 +0100 |
| commit | 5891ac8ea718dcb40014f5a90d2672f902eb6c55 (patch) | |
| tree | 083007df227f0c91fed1c48ed81471074dae853f /app/src/main/java/foundation/e/privacycentralapp/dummy | |
| parent | 2ea0e99f1bcec61e1a94bb7c35605fca49c53d1c (diff) | |
| download | advanced-privacy-5891ac8ea718dcb40014f5a90d2672f902eb6c55.tar.gz | |
Update fake location
Diffstat (limited to 'app/src/main/java/foundation/e/privacycentralapp/dummy')
3 files changed, 3 insertions, 69 deletions
diff --git a/app/src/main/java/foundation/e/privacycentralapp/dummy/CityDataSource.kt b/app/src/main/java/foundation/e/privacycentralapp/dummy/CityDataSource.kt deleted file mode 100644 index 988c7f4..0000000 --- a/app/src/main/java/foundation/e/privacycentralapp/dummy/CityDataSource.kt +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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 - -import foundation.e.privacycentralapp.domain.entities.LocationMode -import kotlin.random.Random - -data class City(val name: String, val latitude: Double, val longitude: Double) { - - fun toRandomLocation(): Location { - return Location(LocationMode.RANDOM_LOCATION, this.latitude, this.longitude) - } -} - -object CityDataSource { - private val BARCELONA = Pair(41.3851, 2.1734) - private val BUDAPEST = Pair(47.4979, 19.0402) - private val ABU_DHABI = Pair(24.4539, 54.3773) - private val HYDERABAD = Pair(17.3850, 78.4867) - private val QUEZON_CITY = Pair(14.6760, 121.0437) - private val PARIS = Pair(48.8566, 2.3522) - private val LONDON = Pair(51.5074, 0.1278) - private val SHANGHAI = Pair(31.2304, 121.4737) - private val MADRID = Pair(40.4168, 3.7038) - private val LAHORE = Pair(31.5204, 74.3587) - private val CHICAGO = Pair(41.8781, 87.6298) - - // LatLong Array, the order should be the same as that of R.array.cities - private val latLongArray = arrayOf( - BARCELONA, - BUDAPEST, - ABU_DHABI, - HYDERABAD, - QUEZON_CITY, - PARIS, - LONDON, - SHANGHAI, - MADRID, - LAHORE, - CHICAGO - ) - - fun getRandomCity(cities: Array<String>): City { - if (cities.size != latLongArray.size) { - throw IllegalStateException("LatLong array must have the same number of element as in cities array.") - } - val randomIndex = Random.nextInt(cities.size) - val latLong = latLongArray[randomIndex] - return City(cities[randomIndex], latLong.first, latLong.second) - } -} 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 246854b..38daeab 100644 --- a/app/src/main/java/foundation/e/privacycentralapp/dummy/DummyDataSource.kt +++ b/app/src/main/java/foundation/e/privacycentralapp/dummy/DummyDataSource.kt @@ -183,9 +183,9 @@ object DummyDataSource { requireNotNull(location) { "Custom location should be null" } _location.value = location } - LocationMode.CUSTOM_LOCATION -> { + LocationMode.SPECIFIC_LOCATION -> { requireNotNull(location) { "Custom location should be null" } - _location.value = location.copy(mode = LocationMode.CUSTOM_LOCATION) + _location.value = location.copy(mode = LocationMode.SPECIFIC_LOCATION) } } 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 index 04ee5bf..ab4ba72 100644 --- a/app/src/main/java/foundation/e/privacycentralapp/dummy/Extensions.kt +++ b/app/src/main/java/foundation/e/privacycentralapp/dummy/Extensions.kt @@ -24,5 +24,5 @@ import foundation.e.privacycentralapp.domain.entities.LocationMode fun LocationMode.mapToString(context: Context): String = when (this) { LocationMode.REAL_LOCATION -> context.getString(R.string.real_location_mode) LocationMode.RANDOM_LOCATION -> context.getString(R.string.random_location_mode) - LocationMode.CUSTOM_LOCATION -> context.getString(R.string.fake_location_mode) + LocationMode.SPECIFIC_LOCATION -> context.getString(R.string.fake_location_mode) } |
