Element config (#4471)
* Add handy extension "VariantDimension.buildConfigFieldStr" * Update configuration for MapTiler. * Update configuration for Sentry. * Build AnalyticsConfig depending on analytics configuration. * Configure analytics policy url. * Add handy extension "VariantDimension.buildConfigFieldBoolean" * Configure legal urls. * Add a way to disable rageshake / reporting bugs. * Update screenshots * Quality * Fix test * Use `ifBlank` extension * Add missing configuration for PostHog * Update configuration for Rageshake. * Add build log. * Disable crash detection if rageshake feature is not available. Disabled twice. * Hide link to analytics policy if the link is missing. * Fix test when run in enterprise context. * Use RageshakeFeatureAvailability where appropriate. * Rename file. * Move some classes to their correct module. * Update screenshots --------- Co-authored-by: ElementBot <android@element.io>
This commit is contained in:
parent
c6b99c853c
commit
3c1deff79c
95 changed files with 613 additions and 273 deletions
|
|
@ -57,7 +57,7 @@ fun StaticMapView(
|
|||
) {
|
||||
val context = LocalContext.current
|
||||
var retryHash by remember { mutableIntStateOf(0) }
|
||||
val builder = remember { StaticMapUrlBuilder(context) }
|
||||
val builder = remember { StaticMapUrlBuilder() }
|
||||
val painter = rememberAsyncImagePainter(
|
||||
model = if (constraints.isZero) {
|
||||
// Avoid building a URL if any of the size constraints is zero (else it will thrown an exception).
|
||||
|
|
|
|||
|
|
@ -1,21 +0,0 @@
|
|||
/*
|
||||
* Copyright 2023, 2024 New Vector Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
* Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
package io.element.android.features.location.api.internal
|
||||
|
||||
import android.content.Context
|
||||
import io.element.android.features.location.api.R
|
||||
|
||||
internal const val MAPTILER_BASE_URL = "https://api.maptiler.com/maps"
|
||||
|
||||
internal fun Context.mapId(darkMode: Boolean) = when (darkMode) {
|
||||
true -> getString(R.string.maptiler_dark_map_id)
|
||||
false -> getString(R.string.maptiler_light_map_id)
|
||||
}
|
||||
|
||||
internal val Context.apiKey: String
|
||||
get() = getString(R.string.maptiler_api_key)
|
||||
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
package io.element.android.features.location.api.internal
|
||||
|
||||
import android.content.Context
|
||||
import io.element.android.features.location.api.BuildConfig
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
/**
|
||||
|
|
@ -16,14 +16,16 @@ import kotlin.math.roundToInt
|
|||
* https://docs.maptiler.com/cloud/api/static-maps/
|
||||
*/
|
||||
internal class MapTilerStaticMapUrlBuilder(
|
||||
private val baseUrl: String,
|
||||
private val apiKey: String,
|
||||
private val lightMapId: String,
|
||||
private val darkMapId: String,
|
||||
) : StaticMapUrlBuilder {
|
||||
constructor(context: Context) : this(
|
||||
apiKey = context.apiKey,
|
||||
lightMapId = context.mapId(darkMode = false),
|
||||
darkMapId = context.mapId(darkMode = true),
|
||||
constructor() : this(
|
||||
baseUrl = BuildConfig.MAPTILER_BASE_URL.removeSuffix("/"),
|
||||
apiKey = BuildConfig.MAPTILER_API_KEY,
|
||||
lightMapId = BuildConfig.MAPTILER_LIGHT_MAP_ID,
|
||||
darkMapId = BuildConfig.MAPTILER_DARK_MAP_ID,
|
||||
)
|
||||
|
||||
override fun build(
|
||||
|
|
@ -55,7 +57,7 @@ internal class MapTilerStaticMapUrlBuilder(
|
|||
// image smaller than the available space in pixels.
|
||||
// The resulting image will have to be scaled to fit the available space in order
|
||||
// to keep the perceived content size constant at the expense of sharpness.
|
||||
return "$MAPTILER_BASE_URL/$mapId/static/$lon,$lat,$finalZoom/${finalWidth}x${finalHeight}$scale.webp?key=$apiKey&attribution=bottomleft"
|
||||
return "$baseUrl/$mapId/static/$lon,$lat,$finalZoom/${finalWidth}x${finalHeight}$scale.webp?key=$apiKey&attribution=bottomleft"
|
||||
}
|
||||
|
||||
override fun isServiceAvailable() = apiKey.isNotEmpty()
|
||||
|
|
|
|||
|
|
@ -9,21 +9,23 @@
|
|||
|
||||
package io.element.android.features.location.api.internal
|
||||
|
||||
import android.content.Context
|
||||
import io.element.android.features.location.api.BuildConfig
|
||||
|
||||
internal class MapTilerTileServerStyleUriBuilder(
|
||||
private val baseUrl: String,
|
||||
private val apiKey: String,
|
||||
private val lightMapId: String,
|
||||
private val darkMapId: String,
|
||||
) : TileServerStyleUriBuilder {
|
||||
constructor(context: Context) : this(
|
||||
apiKey = context.apiKey,
|
||||
lightMapId = context.mapId(darkMode = false),
|
||||
darkMapId = context.mapId(darkMode = true),
|
||||
constructor() : this(
|
||||
baseUrl = BuildConfig.MAPTILER_BASE_URL.removeSuffix("/"),
|
||||
apiKey = BuildConfig.MAPTILER_API_KEY,
|
||||
lightMapId = BuildConfig.MAPTILER_LIGHT_MAP_ID,
|
||||
darkMapId = BuildConfig.MAPTILER_DARK_MAP_ID,
|
||||
)
|
||||
|
||||
override fun build(darkMode: Boolean): String {
|
||||
val mapId = if (darkMode) darkMapId else lightMapId
|
||||
return "$MAPTILER_BASE_URL/$mapId/style.json?key=$apiKey"
|
||||
return "$baseUrl/$mapId/style.json?key=$apiKey"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,8 +7,6 @@
|
|||
|
||||
package io.element.android.features.location.api.internal
|
||||
|
||||
import android.content.Context
|
||||
|
||||
/**
|
||||
* Builds an URL for a 3rd party service provider static maps API.
|
||||
*/
|
||||
|
|
@ -26,4 +24,4 @@ interface StaticMapUrlBuilder {
|
|||
fun isServiceAvailable(): Boolean
|
||||
}
|
||||
|
||||
fun StaticMapUrlBuilder(context: Context): StaticMapUrlBuilder = MapTilerStaticMapUrlBuilder(context = context)
|
||||
fun StaticMapUrlBuilder(): StaticMapUrlBuilder = MapTilerStaticMapUrlBuilder()
|
||||
|
|
|
|||
|
|
@ -7,10 +7,8 @@
|
|||
|
||||
package io.element.android.features.location.api.internal
|
||||
|
||||
import android.content.Context
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import io.element.android.compound.theme.ElementTheme
|
||||
|
||||
/**
|
||||
|
|
@ -24,7 +22,7 @@ interface TileServerStyleUriBuilder {
|
|||
): String
|
||||
}
|
||||
|
||||
fun TileServerStyleUriBuilder(context: Context): TileServerStyleUriBuilder = MapTilerTileServerStyleUriBuilder(context = context)
|
||||
fun TileServerStyleUriBuilder(): TileServerStyleUriBuilder = MapTilerTileServerStyleUriBuilder()
|
||||
|
||||
/**
|
||||
* Provides and remembers a style URI for a MapLibre compatible tile server.
|
||||
|
|
@ -33,9 +31,8 @@ fun TileServerStyleUriBuilder(context: Context): TileServerStyleUriBuilder = Map
|
|||
*/
|
||||
@Composable
|
||||
fun rememberTileStyleUrl(): String {
|
||||
val context = LocalContext.current
|
||||
val darkMode = !ElementTheme.isLightTheme
|
||||
return remember(darkMode) {
|
||||
TileServerStyleUriBuilder(context).build(darkMode)
|
||||
TileServerStyleUriBuilder().build(darkMode)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue