Merge pull request #783 from vector-im/feature/cjs/location-descriptions

This commit is contained in:
Chris Smith 2023-07-06 10:33:59 +01:00 committed by GitHub
commit bbd1ff31a3
22 changed files with 62 additions and 34 deletions

View file

@ -17,7 +17,6 @@
package io.element.android.features.location.impl.show package io.element.android.features.location.impl.show
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.rememberCoroutineScope
import dagger.assisted.Assisted import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject import dagger.assisted.AssistedInject

View file

@ -16,8 +16,10 @@
package io.element.android.features.messages.impl.timeline.components.event package io.element.android.features.messages.impl.timeline.components.event
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.heightIn import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.Preview
@ -28,21 +30,31 @@ import io.element.android.features.messages.impl.timeline.model.event.TimelineIt
import io.element.android.features.messages.impl.timeline.model.event.TimelineItemLocationContentProvider import io.element.android.features.messages.impl.timeline.model.event.TimelineItemLocationContentProvider
import io.element.android.libraries.designsystem.preview.ElementPreviewDark import io.element.android.libraries.designsystem.preview.ElementPreviewDark
import io.element.android.libraries.designsystem.preview.ElementPreviewLight import io.element.android.libraries.designsystem.preview.ElementPreviewLight
import io.element.android.libraries.designsystem.theme.components.Text
@Composable @Composable
fun TimelineItemLocationView( fun TimelineItemLocationView(
content: TimelineItemLocationContent, content: TimelineItemLocationContent,
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
) { ) {
StaticMapView( Column(modifier = modifier.fillMaxWidth()) {
modifier = modifier content.description?.let {
.fillMaxWidth() Text(
.heightIn(max = 188.dp), text = it,
lat = content.location.lat, modifier = Modifier.padding(start = 12.dp, end = 12.dp, top = 8.dp, bottom = 8.dp),
lon = content.location.lon, )
zoom = 15.0, }
contentDescription = content.body
) StaticMapView(
modifier = Modifier
.fillMaxWidth()
.heightIn(max = 188.dp),
lat = content.location.lat,
lon = content.location.lon,
zoom = 15.0,
contentDescription = content.body
)
}
} }
@Preview @Preview

View file

@ -79,6 +79,7 @@ class TimelineItemContentMessageFactory @Inject constructor(
TimelineItemLocationContent( TimelineItemLocationContent(
body = messageType.body, body = messageType.body,
location = location, location = location,
description = messageType.description
) )
} }
} }

View file

@ -29,6 +29,7 @@ class TimelineItemEventContentProvider : PreviewParameterProvider<TimelineItemEv
aTimelineItemFileContent("A file.pdf"), aTimelineItemFileContent("A file.pdf"),
aTimelineItemFileContent("A bigger file name which doesn't fit.pdf"), aTimelineItemFileContent("A bigger file name which doesn't fit.pdf"),
aTimelineItemLocationContent(), aTimelineItemLocationContent(),
aTimelineItemLocationContent("Location description"),
aTimelineItemNoticeContent(), aTimelineItemNoticeContent(),
aTimelineItemRedactedContent(), aTimelineItemRedactedContent(),
aTimelineItemTextContent(), aTimelineItemTextContent(),

View file

@ -23,14 +23,16 @@ open class TimelineItemLocationContentProvider : PreviewParameterProvider<Timeli
override val values: Sequence<TimelineItemLocationContent> override val values: Sequence<TimelineItemLocationContent>
get() = sequenceOf( get() = sequenceOf(
aTimelineItemLocationContent(), aTimelineItemLocationContent(),
aTimelineItemLocationContent("This is a description!"),
) )
} }
fun aTimelineItemLocationContent() = TimelineItemLocationContent( fun aTimelineItemLocationContent(description: String? = null) = TimelineItemLocationContent(
body = "User location geo:52.2445,0.7186;u=5000", body = "User location geo:52.2445,0.7186;u=5000",
location = Location( location = Location(
lat = 52.2445, lat = 52.2445,
lon = 0.7186, lon = 0.7186,
accuracy = 5000f, accuracy = 5000f,
) ),
description = description,
) )

View file

@ -162,7 +162,7 @@ class DefaultRoomLastMessageFormatterTests {
AudioMessageType(body, MediaSource("url"), null), AudioMessageType(body, MediaSource("url"), null),
ImageMessageType(body, MediaSource("url"), null), ImageMessageType(body, MediaSource("url"), null),
FileMessageType(body, MediaSource("url"), null), FileMessageType(body, MediaSource("url"), null),
LocationMessageType(body, "geo:1,2"), LocationMessageType(body, "geo:1,2", null),
NoticeMessageType(body, null), NoticeMessageType(body, null),
EmoteMessageType(body, null), EmoteMessageType(body, null),
) )

View file

@ -128,6 +128,7 @@ data class ImageMessageType(
data class LocationMessageType( data class LocationMessageType(
val body: String, val body: String,
val geoUri: String, val geoUri: String,
val description: String?,
) : MessageType ) : MessageType
data class AudioMessageType( data class AudioMessageType(

View file

@ -55,7 +55,7 @@ class EventMessageMapper {
ImageMessageType(type.content.body, type.content.source.map(), type.content.info?.map()) ImageMessageType(type.content.body, type.content.source.map(), type.content.info?.map())
} }
is MessageType.Location -> { is MessageType.Location -> {
LocationMessageType(type.content.body, type.content.geoUri) LocationMessageType(type.content.body, type.content.geoUri, type.content.description)
} }
is MessageType.Notice -> { is MessageType.Notice -> {
NoticeMessageType(type.content.body, type.content.formatted?.map()) NoticeMessageType(type.content.body, type.content.formatted?.map())

View file

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:8b14570268c5885105bb68d55e54afe83d1916e32a5a9cd8fa4084cba020b272
size 80504

View file

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:2ae5e86ad1728027f7189041745592d4ed24df07e008b5798b29eadba5449569
size 159493

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:4d4d701ed86f9bc3e23dbcb0d1f4a61f66153e3f2d2e71c12cefb1ef72634f9f oid sha256:fb8609b0babc1a2e50f990b400090f57d3f0bddffbdfc02f76fb57d4c085bccd
size 65937 size 50178

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:bcecf59a9361f9de63971d88a1e3d4daa1041d48cabdbe0bd6485052668d3906 oid sha256:4d4d701ed86f9bc3e23dbcb0d1f4a61f66153e3f2d2e71c12cefb1ef72634f9f
size 56636 size 65937

View file

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:bcecf59a9361f9de63971d88a1e3d4daa1041d48cabdbe0bd6485052668d3906
size 56636

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:9d544ff72f07770d725a02ffe23fdf77278c15520273fd83a89509ef6a4632f0 oid sha256:a89052fe6e40609a3a01fbe9e804a77bec37c428234fb4a68ca2044889c01913
size 53520 size 165199

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:7ae78c21fa4c5bc13ef4d9b540a6db805af73a4b2ab686d35b5d37edca33ee1c oid sha256:9d544ff72f07770d725a02ffe23fdf77278c15520273fd83a89509ef6a4632f0
size 65012 size 53520

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:fb8609b0babc1a2e50f990b400090f57d3f0bddffbdfc02f76fb57d4c085bccd oid sha256:7ae78c21fa4c5bc13ef4d9b540a6db805af73a4b2ab686d35b5d37edca33ee1c
size 50178 size 65012

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:2c9a43dedfef18acc8713b033ffe8ac59545eb96a77e3640ba69b9048a19bc59 oid sha256:73dd69d4168847ee6339f9d02ae80157f810cab559f9f6c4659ba93c10d14a9e
size 68644 size 51702

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:9a5713bf7670620247cd96760627c5b97dc393b3576b32712ae9073c7d5948de oid sha256:2c9a43dedfef18acc8713b033ffe8ac59545eb96a77e3640ba69b9048a19bc59
size 58797 size 68644

View file

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:9a5713bf7670620247cd96760627c5b97dc393b3576b32712ae9073c7d5948de
size 58797

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:1f031f626ce7b2aaa4d9fd551b5ddbf81dc9dd53bc7013bec179bc42a814bd9b oid sha256:589e8f7ca791fc13ee4171e05789e52269dfca142f633af9d0ff4a88e694e78b
size 55325 size 323977

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:351257a00f2b73baea6d6646123f48fa822d7af8dfdc21bc18647aa75ec848cd oid sha256:1f031f626ce7b2aaa4d9fd551b5ddbf81dc9dd53bc7013bec179bc42a814bd9b
size 67457 size 55325

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:73dd69d4168847ee6339f9d02ae80157f810cab559f9f6c4659ba93c10d14a9e oid sha256:351257a00f2b73baea6d6646123f48fa822d7af8dfdc21bc18647aa75ec848cd
size 51702 size 67457