Retrieve map style url from .well-known.
This commit is contained in:
parent
4ce1ab2665
commit
9d83bafa7b
|
@ -0,0 +1 @@
|
||||||
|
Retrieve map style url from .well-known
|
|
@ -54,8 +54,11 @@ class LocationPreviewFragment @Inject constructor(
|
||||||
|
|
||||||
mapView = WeakReference(views.mapView)
|
mapView = WeakReference(views.mapView)
|
||||||
views.mapView.onCreate(savedInstanceState)
|
views.mapView.onCreate(savedInstanceState)
|
||||||
views.mapView.initialize(urlMapProvider.mapUrl)
|
|
||||||
loadPinDrawable()
|
lifecycleScope.launchWhenCreated {
|
||||||
|
views.mapView.initialize(urlMapProvider.getMapUrl())
|
||||||
|
loadPinDrawable()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
|
|
|
@ -21,6 +21,7 @@ import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.core.view.isGone
|
import androidx.core.view.isGone
|
||||||
|
import androidx.lifecycle.lifecycleScope
|
||||||
import com.airbnb.mvrx.fragmentViewModel
|
import com.airbnb.mvrx.fragmentViewModel
|
||||||
import com.airbnb.mvrx.withState
|
import com.airbnb.mvrx.withState
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
|
@ -53,7 +54,10 @@ class LocationSharingFragment @Inject constructor(
|
||||||
|
|
||||||
mapView = WeakReference(views.mapView)
|
mapView = WeakReference(views.mapView)
|
||||||
views.mapView.onCreate(savedInstanceState)
|
views.mapView.onCreate(savedInstanceState)
|
||||||
views.mapView.initialize(urlMapProvider.mapUrl)
|
|
||||||
|
lifecycleScope.launchWhenCreated {
|
||||||
|
views.mapView.initialize(urlMapProvider.getMapUrl())
|
||||||
|
}
|
||||||
|
|
||||||
views.shareLocationContainer.debouncedClicks {
|
views.shareLocationContainer.debouncedClicks {
|
||||||
viewModel.handle(LocationSharingAction.OnShareLocation)
|
viewModel.handle(LocationSharingAction.OnShareLocation)
|
||||||
|
|
|
@ -19,17 +19,27 @@ package im.vector.app.features.location
|
||||||
import im.vector.app.BuildConfig
|
import im.vector.app.BuildConfig
|
||||||
import im.vector.app.core.resources.LocaleProvider
|
import im.vector.app.core.resources.LocaleProvider
|
||||||
import im.vector.app.core.resources.isRTL
|
import im.vector.app.core.resources.isRTL
|
||||||
|
import im.vector.app.features.raw.wellknown.getElementWellknown
|
||||||
|
import org.matrix.android.sdk.api.extensions.tryOrNull
|
||||||
|
import org.matrix.android.sdk.api.raw.RawService
|
||||||
|
import org.matrix.android.sdk.api.session.Session
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class UrlMapProvider @Inject constructor(
|
class UrlMapProvider @Inject constructor(
|
||||||
private val localeProvider: LocaleProvider
|
private val localeProvider: LocaleProvider,
|
||||||
|
private val session: Session,
|
||||||
|
private val rawService: RawService
|
||||||
) {
|
) {
|
||||||
private val keyParam = "?key=${BuildConfig.mapTilerKey}"
|
private val keyParam = "?key=${BuildConfig.mapTilerKey}"
|
||||||
|
|
||||||
// This is static so no need for a fun
|
suspend fun getMapUrl(): String {
|
||||||
val mapUrl = buildString {
|
return tryOrNull { rawService.getElementWellknown(session.sessionParams) }
|
||||||
append(MAP_BASE_URL)
|
?.mapTileServerConfig
|
||||||
append(keyParam)
|
?.mapStyleUrl
|
||||||
|
?: buildString {
|
||||||
|
append(MAP_BASE_URL)
|
||||||
|
append(keyParam)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun buildStaticMapUrl(locationData: LocationData,
|
fun buildStaticMapUrl(locationData: LocationData,
|
||||||
|
|
|
@ -35,7 +35,10 @@ data class ElementWellKnown(
|
||||||
val elementE2E: E2EWellKnownConfig? = null,
|
val elementE2E: E2EWellKnownConfig? = null,
|
||||||
|
|
||||||
@Json(name = "im.vector.riot.e2ee")
|
@Json(name = "im.vector.riot.e2ee")
|
||||||
val riotE2E: E2EWellKnownConfig? = null
|
val riotE2E: E2EWellKnownConfig? = null,
|
||||||
|
|
||||||
|
@Json(name = "org.matrix.msc3488.tile_server")
|
||||||
|
val mapTileServerConfig: MapTileServerConfig? = null
|
||||||
)
|
)
|
||||||
|
|
||||||
@JsonClass(generateAdapter = true)
|
@JsonClass(generateAdapter = true)
|
||||||
|
@ -53,3 +56,9 @@ data class WellKnownPreferredConfig(
|
||||||
@Json(name = "preferredDomain")
|
@Json(name = "preferredDomain")
|
||||||
val preferredDomain: String? = null
|
val preferredDomain: String? = null
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@JsonClass(generateAdapter = true)
|
||||||
|
data class MapTileServerConfig(
|
||||||
|
@Json(name = "map_style_url")
|
||||||
|
val mapStyleUrl: String? = null
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in New Issue