From 56afac26ad57198fb38be551a5fb40946cac0bb8 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Thu, 30 Jun 2022 16:30:49 +0100 Subject: [PATCH] creating a location sharing config for holding the map tiler key --- .../main/java/im/vector/app/config/Config.kt | 1 + vector/build.gradle | 2 -- .../vector/app/core/di/ConfigurationModule.kt | 10 +++++++-- .../location/LocationSharingConfig.kt | 21 +++++++++++++++++++ .../app/features/location/UrlMapProvider.kt | 6 +++--- 5 files changed, 33 insertions(+), 7 deletions(-) create mode 100644 vector/src/main/java/im/vector/app/features/location/LocationSharingConfig.kt diff --git a/vector-config/src/main/java/im/vector/app/config/Config.kt b/vector-config/src/main/java/im/vector/app/config/Config.kt index 384dc2e7f7..9398cd1457 100644 --- a/vector-config/src/main/java/im/vector/app/config/Config.kt +++ b/vector-config/src/main/java/im/vector/app/config/Config.kt @@ -38,6 +38,7 @@ object Config { const val ALLOW_EXTERNAL_UNIFIED_PUSH_DISTRIBUTORS = true const val ENABLE_LOCATION_SHARING = true + const val LOCATION_MAP_TILER_KEY = "fU3vlMsMn4Jb6dnEIFsx" /** * The maximum length of voice messages in milliseconds. diff --git a/vector/build.gradle b/vector/build.gradle index a3b228b0af..f9a81eb76c 100644 --- a/vector/build.gradle +++ b/vector/build.gradle @@ -160,8 +160,6 @@ android { // This *must* only be set in trusted environments. buildConfigField "Boolean", "handleCallAssertedIdentityEvents", "false" - buildConfigField "String", "mapTilerKey", "\"fU3vlMsMn4Jb6dnEIFsx\"" - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" // Keep abiFilter for the universalApk diff --git a/vector/src/main/java/im/vector/app/core/di/ConfigurationModule.kt b/vector/src/main/java/im/vector/app/core/di/ConfigurationModule.kt index dc4f8dac40..c8469957f6 100644 --- a/vector/src/main/java/im/vector/app/core/di/ConfigurationModule.kt +++ b/vector/src/main/java/im/vector/app/core/di/ConfigurationModule.kt @@ -27,6 +27,7 @@ import im.vector.app.config.KeySharingStrategy import im.vector.app.features.analytics.AnalyticsConfig import im.vector.app.features.crypto.keysrequest.OutboundSessionKeySharingStrategy import im.vector.app.features.home.room.detail.composer.voice.VoiceMessageConfig +import im.vector.app.features.location.LocationSharingConfig import im.vector.app.features.raw.wellknown.CryptoConfig @InstallIn(SingletonComponent::class) @@ -40,7 +41,7 @@ object ConfigurationModule { false -> Config.RELEASE_ANALYTICS_CONFIG } return when (config) { - Analytics.Disabled -> AnalyticsConfig(isEnabled = false, "", "", "") + Analytics.Disabled -> AnalyticsConfig(isEnabled = false, "", "", "") is Analytics.PostHog -> AnalyticsConfig( isEnabled = true, postHogHost = config.postHogHost, @@ -60,7 +61,12 @@ object ConfigurationModule { fallbackKeySharingStrategy = when (Config.KEY_SHARING_STRATEGY) { KeySharingStrategy.WhenSendingEvent -> OutboundSessionKeySharingStrategy.WhenSendingEvent KeySharingStrategy.WhenEnteringRoom -> OutboundSessionKeySharingStrategy.WhenSendingEvent - KeySharingStrategy.WhenTyping -> OutboundSessionKeySharingStrategy.WhenSendingEvent + KeySharingStrategy.WhenTyping -> OutboundSessionKeySharingStrategy.WhenSendingEvent } ) + + @Provides + fun providesLocationSharingConfig() = LocationSharingConfig( + mapTilerKey = Config.LOCATION_MAP_TILER_KEY, + ) } diff --git a/vector/src/main/java/im/vector/app/features/location/LocationSharingConfig.kt b/vector/src/main/java/im/vector/app/features/location/LocationSharingConfig.kt new file mode 100644 index 0000000000..4615564e41 --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/location/LocationSharingConfig.kt @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package im.vector.app.features.location + +data class LocationSharingConfig( + val mapTilerKey: String, +) diff --git a/vector/src/main/java/im/vector/app/features/location/UrlMapProvider.kt b/vector/src/main/java/im/vector/app/features/location/UrlMapProvider.kt index f043006d70..3748b1b19e 100644 --- a/vector/src/main/java/im/vector/app/features/location/UrlMapProvider.kt +++ b/vector/src/main/java/im/vector/app/features/location/UrlMapProvider.kt @@ -16,7 +16,6 @@ package im.vector.app.features.location -import im.vector.app.BuildConfig import im.vector.app.features.raw.wellknown.getElementWellknown import org.matrix.android.sdk.api.extensions.tryOrNull import org.matrix.android.sdk.api.raw.RawService @@ -25,9 +24,10 @@ import javax.inject.Inject class UrlMapProvider @Inject constructor( private val session: Session, - private val rawService: RawService + private val rawService: RawService, + locationSharingConfig: LocationSharingConfig, ) { - private val keyParam = "?key=${BuildConfig.mapTilerKey}" + private val keyParam = "?key=${locationSharingConfig.mapTilerKey}" private val fallbackMapUrl = buildString { append(MAP_BASE_URL)