Correct location event body (#930)
- Now sending the correct body format as agreed with design. This won't be show in EX clients though. Related to: - https://github.com/vector-im/element-meta/issues/1682
This commit is contained in:
parent
584a227920
commit
188af2ee98
3 changed files with 5 additions and 18 deletions
|
|
@ -45,7 +45,6 @@ dependencies {
|
||||||
implementation(projects.libraries.uiStrings)
|
implementation(projects.libraries.uiStrings)
|
||||||
implementation(libs.dagger)
|
implementation(libs.dagger)
|
||||||
implementation(projects.anvilannotations)
|
implementation(projects.anvilannotations)
|
||||||
implementation(projects.services.toolbox.api)
|
|
||||||
anvil(projects.anvilcodegen)
|
anvil(projects.anvilcodegen)
|
||||||
ksp(libs.showkase.processor)
|
ksp(libs.showkase.processor)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,12 +36,7 @@ import io.element.android.libraries.core.meta.BuildMeta
|
||||||
import io.element.android.libraries.matrix.api.room.MatrixRoom
|
import io.element.android.libraries.matrix.api.room.MatrixRoom
|
||||||
import io.element.android.libraries.matrix.api.room.location.AssetType
|
import io.element.android.libraries.matrix.api.room.location.AssetType
|
||||||
import io.element.android.services.analytics.api.AnalyticsService
|
import io.element.android.services.analytics.api.AnalyticsService
|
||||||
import io.element.android.services.toolbox.api.systemclock.SystemClock
|
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import java.time.Instant
|
|
||||||
import java.time.ZoneOffset
|
|
||||||
import java.time.ZonedDateTime
|
|
||||||
import java.time.format.DateTimeFormatter
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class SendLocationPresenter @Inject constructor(
|
class SendLocationPresenter @Inject constructor(
|
||||||
|
|
@ -50,7 +45,6 @@ class SendLocationPresenter @Inject constructor(
|
||||||
private val analyticsService: AnalyticsService,
|
private val analyticsService: AnalyticsService,
|
||||||
private val messageComposerContext: MessageComposerContext,
|
private val messageComposerContext: MessageComposerContext,
|
||||||
private val locationActions: LocationActions,
|
private val locationActions: LocationActions,
|
||||||
private val systemClock: SystemClock,
|
|
||||||
private val buildMeta: BuildMeta,
|
private val buildMeta: BuildMeta,
|
||||||
) : Presenter<SendLocationState> {
|
) : Presenter<SendLocationState> {
|
||||||
|
|
||||||
|
|
@ -115,7 +109,7 @@ class SendLocationPresenter @Inject constructor(
|
||||||
SendLocationState.Mode.PinLocation -> {
|
SendLocationState.Mode.PinLocation -> {
|
||||||
val geoUri = event.cameraPosition.toGeoUri()
|
val geoUri = event.cameraPosition.toGeoUri()
|
||||||
room.sendLocation(
|
room.sendLocation(
|
||||||
body = generateBody(geoUri, systemClock.epochMillis()),
|
body = generateBody(geoUri),
|
||||||
geoUri = geoUri,
|
geoUri = geoUri,
|
||||||
description = null,
|
description = null,
|
||||||
zoomLevel = MapDefaults.DEFAULT_ZOOM.toInt(),
|
zoomLevel = MapDefaults.DEFAULT_ZOOM.toInt(),
|
||||||
|
|
@ -134,7 +128,7 @@ class SendLocationPresenter @Inject constructor(
|
||||||
SendLocationState.Mode.SenderLocation -> {
|
SendLocationState.Mode.SenderLocation -> {
|
||||||
val geoUri = event.toGeoUri()
|
val geoUri = event.toGeoUri()
|
||||||
room.sendLocation(
|
room.sendLocation(
|
||||||
body = generateBody(geoUri, systemClock.epochMillis()),
|
body = generateBody(geoUri),
|
||||||
geoUri = geoUri,
|
geoUri = geoUri,
|
||||||
description = null,
|
description = null,
|
||||||
zoomLevel = MapDefaults.DEFAULT_ZOOM.toInt(),
|
zoomLevel = MapDefaults.DEFAULT_ZOOM.toInt(),
|
||||||
|
|
@ -158,7 +152,4 @@ private fun SendLocationEvents.SendLocation.toGeoUri(): String = location?.toGeo
|
||||||
|
|
||||||
private fun SendLocationEvents.SendLocation.CameraPosition.toGeoUri(): String = "geo:$lat,$lon"
|
private fun SendLocationEvents.SendLocation.CameraPosition.toGeoUri(): String = "geo:$lat,$lon"
|
||||||
|
|
||||||
private fun generateBody(uri: String, epochMillis: Long): String {
|
private fun generateBody(uri: String): String = "Location was shared at $uri"
|
||||||
val timestamp = ZonedDateTime.ofInstant(Instant.ofEpochMilli(epochMillis), ZoneOffset.UTC).format(DateTimeFormatter.ISO_INSTANT)
|
|
||||||
return "Location was shared at $uri as of $timestamp"
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,6 @@ import io.element.android.libraries.matrix.test.core.aBuildMeta
|
||||||
import io.element.android.libraries.matrix.test.room.FakeMatrixRoom
|
import io.element.android.libraries.matrix.test.room.FakeMatrixRoom
|
||||||
import io.element.android.libraries.matrix.test.room.SendLocationInvocation
|
import io.element.android.libraries.matrix.test.room.SendLocationInvocation
|
||||||
import io.element.android.libraries.textcomposer.MessageComposerMode
|
import io.element.android.libraries.textcomposer.MessageComposerMode
|
||||||
import io.element.android.services.toolbox.api.systemclock.SystemClock
|
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.test.runTest
|
import kotlinx.coroutines.test.runTest
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
|
@ -46,7 +45,6 @@ class SendLocationPresenterTest {
|
||||||
private val fakeAnalyticsService = FakeAnalyticsService()
|
private val fakeAnalyticsService = FakeAnalyticsService()
|
||||||
private val messageComposerContextFake = MessageComposerContextFake()
|
private val messageComposerContextFake = MessageComposerContextFake()
|
||||||
private val fakeLocationActions = FakeLocationActions()
|
private val fakeLocationActions = FakeLocationActions()
|
||||||
private val fakeSystemClock = SystemClock { 0L }
|
|
||||||
private val fakeBuildMeta = aBuildMeta(applicationName = "app name")
|
private val fakeBuildMeta = aBuildMeta(applicationName = "app name")
|
||||||
private val sendLocationPresenter: SendLocationPresenter = SendLocationPresenter(
|
private val sendLocationPresenter: SendLocationPresenter = SendLocationPresenter(
|
||||||
permissionsPresenterFactory = object : PermissionsPresenter.Factory {
|
permissionsPresenterFactory = object : PermissionsPresenter.Factory {
|
||||||
|
|
@ -56,7 +54,6 @@ class SendLocationPresenterTest {
|
||||||
analyticsService = fakeAnalyticsService,
|
analyticsService = fakeAnalyticsService,
|
||||||
messageComposerContext = messageComposerContextFake,
|
messageComposerContext = messageComposerContextFake,
|
||||||
locationActions = fakeLocationActions,
|
locationActions = fakeLocationActions,
|
||||||
systemClock = fakeSystemClock,
|
|
||||||
buildMeta = fakeBuildMeta,
|
buildMeta = fakeBuildMeta,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -292,7 +289,7 @@ class SendLocationPresenterTest {
|
||||||
Truth.assertThat(fakeMatrixRoom.sentLocations.size).isEqualTo(1)
|
Truth.assertThat(fakeMatrixRoom.sentLocations.size).isEqualTo(1)
|
||||||
Truth.assertThat(fakeMatrixRoom.sentLocations.last()).isEqualTo(
|
Truth.assertThat(fakeMatrixRoom.sentLocations.last()).isEqualTo(
|
||||||
SendLocationInvocation(
|
SendLocationInvocation(
|
||||||
body = "Location was shared at geo:3.0,4.0;u=5.0 as of 1970-01-01T00:00:00Z",
|
body = "Location was shared at geo:3.0,4.0;u=5.0",
|
||||||
geoUri = "geo:3.0,4.0;u=5.0",
|
geoUri = "geo:3.0,4.0;u=5.0",
|
||||||
description = null,
|
description = null,
|
||||||
zoomLevel = 15,
|
zoomLevel = 15,
|
||||||
|
|
@ -349,7 +346,7 @@ class SendLocationPresenterTest {
|
||||||
Truth.assertThat(fakeMatrixRoom.sentLocations.size).isEqualTo(1)
|
Truth.assertThat(fakeMatrixRoom.sentLocations.size).isEqualTo(1)
|
||||||
Truth.assertThat(fakeMatrixRoom.sentLocations.last()).isEqualTo(
|
Truth.assertThat(fakeMatrixRoom.sentLocations.last()).isEqualTo(
|
||||||
SendLocationInvocation(
|
SendLocationInvocation(
|
||||||
body = "Location was shared at geo:0.0,1.0 as of 1970-01-01T00:00:00Z",
|
body = "Location was shared at geo:0.0,1.0",
|
||||||
geoUri = "geo:0.0,1.0",
|
geoUri = "geo:0.0,1.0",
|
||||||
description = null,
|
description = null,
|
||||||
zoomLevel = 15,
|
zoomLevel = 15,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue