Disable location sharing when no MapTiler config is available

LocationService now exposes the MapTiler config to use: the one provided by the
homeserver takes precedence over the build time one, and null means that no map
provider is configured. It is now session scoped, and isServiceAvailable()
returns a StateFlow derived from this config.

When no config is available:
- the location sharing option is hidden from the composer, and location events
  cannot be opened in the location viewer;
- the "Location sharing" entry is hidden from the settings;
- location events in the timeline render a placeholder, without performing any
  request to MapTiler.

The show and share location screens now get the config from LocationService
rather than fetching the homeserver config by themselves.

Closes element-hq/element-android-enterprise#69

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Benoit Marty
2026-10-13 17:15:37 +02:00
parent 5104e044ff
commit 4b97d6ab96
28 changed files with 212 additions and 106 deletions
+1
View File
@@ -16,6 +16,7 @@ android {
dependencies {
api(projects.features.location.api)
implementation(projects.features.enterprise.api)
implementation(projects.libraries.architecture)
implementation(projects.libraries.matrix.api)
implementation(projects.tests.testutils)
@@ -8,10 +8,21 @@
package io.element.android.features.location.test
import io.element.android.features.enterprise.api.remoteconfig.MapTilerConfig
import io.element.android.features.location.api.LocationService
import kotlinx.coroutines.flow.MutableStateFlow
class FakeLocationService(
private val isServiceAvailable: Boolean = false,
mapTilerConfig: MapTilerConfig? = null,
) : LocationService {
override fun isServiceAvailable() = isServiceAvailable
constructor(isServiceAvailable: Boolean) : this(
MapTilerConfig(
apiKey = "test_api_key",
lightStyleId = null,
darkStyleId = null,
baseUrl = null,
).takeIf { isServiceAvailable }
)
override val mapTilerConfig = MutableStateFlow(mapTilerConfig)
}