Make sure we can display both Live and Static locations in ShowLocation

This commit is contained in:
ganfra 2026-02-26 22:07:30 +01:00
parent e1e7c264ed
commit ffad69b7b9
16 changed files with 168 additions and 67 deletions

View file

@ -15,6 +15,7 @@ import io.element.android.libraries.matrix.api.media.FileInfo
import io.element.android.libraries.matrix.api.media.ImageInfo
import io.element.android.libraries.matrix.api.media.MediaSource
import io.element.android.libraries.matrix.api.media.VideoInfo
import io.element.android.libraries.matrix.api.room.location.AssetType
@Immutable
sealed interface MessageType
@ -55,6 +56,7 @@ data class LocationMessageType(
val body: String,
val geoUri: String,
val description: String?,
val assetType: AssetType?,
) : MessageType
data class AudioMessageType(

View file

@ -9,8 +9,14 @@
package io.element.android.libraries.matrix.impl.room.location
import io.element.android.libraries.matrix.api.room.location.AssetType
import org.matrix.rustcomponents.sdk.AssetType as RustAssetType
fun AssetType.toInner(): org.matrix.rustcomponents.sdk.AssetType = when (this) {
AssetType.SENDER -> org.matrix.rustcomponents.sdk.AssetType.SENDER
AssetType.PIN -> org.matrix.rustcomponents.sdk.AssetType.PIN
fun AssetType.into(): RustAssetType = when (this) {
AssetType.SENDER -> RustAssetType.SENDER
AssetType.PIN -> RustAssetType.PIN
}
fun RustAssetType.into(): AssetType = when(this){
RustAssetType.SENDER -> AssetType.SENDER
RustAssetType.PIN -> AssetType.PIN
}

View file

@ -32,7 +32,7 @@ import io.element.android.libraries.matrix.impl.media.MediaUploadHandlerImpl
import io.element.android.libraries.matrix.impl.media.map
import io.element.android.libraries.matrix.impl.poll.toInner
import io.element.android.libraries.matrix.impl.room.RoomContentForwarder
import io.element.android.libraries.matrix.impl.room.location.toInner
import io.element.android.libraries.matrix.impl.room.location.into
import io.element.android.libraries.matrix.impl.timeline.item.event.EventTimelineItemMapper
import io.element.android.libraries.matrix.impl.timeline.item.event.TimelineEventContentMapper
import io.element.android.libraries.matrix.impl.timeline.item.virtual.VirtualTimelineItemMapper
@ -478,7 +478,7 @@ class RustTimeline(
geoUri = geoUri,
description = description,
zoomLevel = zoomLevel?.toUByte(),
assetType = assetType?.toInner(),
assetType = assetType?.into(),
repliedToEventId = inReplyToEventId?.value,
)
}

View file

@ -24,6 +24,7 @@ import io.element.android.libraries.matrix.api.timeline.item.event.TextMessageTy
import io.element.android.libraries.matrix.api.timeline.item.event.VideoMessageType
import io.element.android.libraries.matrix.api.timeline.item.event.VoiceMessageType
import io.element.android.libraries.matrix.impl.media.map
import io.element.android.libraries.matrix.impl.room.location.into
import io.element.android.libraries.matrix.impl.timeline.reply.InReplyToMapper
import org.matrix.rustcomponents.sdk.InReplyToDetails
import org.matrix.rustcomponents.sdk.MessageType
@ -112,7 +113,12 @@ class EventMessageMapper {
)
}
is RustMessageType.Location -> {
LocationMessageType(type.content.body, type.content.geoUri, type.content.description)
LocationMessageType(
body = type.content.body,
geoUri = type.content.geoUri,
description = type.content.description,
assetType = type.content.asset?.into()
)
}
is MessageType.Other -> {
OtherMessageType(type.msgtype, type.body)

View file

@ -15,7 +15,7 @@ import org.junit.Test
class AssetTypeKtTest {
@Test
fun toInner() {
assertThat(AssetType.SENDER.toInner()).isEqualTo(org.matrix.rustcomponents.sdk.AssetType.SENDER)
assertThat(AssetType.PIN.toInner()).isEqualTo(org.matrix.rustcomponents.sdk.AssetType.PIN)
assertThat(AssetType.SENDER.into()).isEqualTo(org.matrix.rustcomponents.sdk.AssetType.SENDER)
assertThat(AssetType.PIN.into()).isEqualTo(org.matrix.rustcomponents.sdk.AssetType.PIN)
}
}

View file

@ -71,7 +71,7 @@ open class InReplyToDetailsProvider : PreviewParameterProvider<InReplyToDetails>
),
aMessageContent(
body = "Location",
type = LocationMessageType("Location", "geo:1,2", null),
type = LocationMessageType("Location", "geo:1,2", null, assetType = null),
),
aMessageContent(
body = "Notice",