From 580e85d232de5287cf6acd9643ad1cfb9fdb0e62 Mon Sep 17 00:00:00 2001 From: ganfra Date: Mon, 13 Apr 2026 11:51:48 +0200 Subject: [PATCH] Fix live location share item description --- .../features/location/impl/common/ui/LocationShareRow.kt | 8 ++++---- .../features/location/impl/show/ShowLocationPresenter.kt | 9 +++++++-- .../features/location/impl/show/ShowLocationState.kt | 2 +- .../location/impl/show/ShowLocationStateProvider.kt | 7 +++---- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/features/location/impl/src/main/kotlin/io/element/android/features/location/impl/common/ui/LocationShareRow.kt b/features/location/impl/src/main/kotlin/io/element/android/features/location/impl/common/ui/LocationShareRow.kt index 866c7342ca..6fbcfc4814 100644 --- a/features/location/impl/src/main/kotlin/io/element/android/features/location/impl/common/ui/LocationShareRow.kt +++ b/features/location/impl/src/main/kotlin/io/element/android/features/location/impl/common/ui/LocationShareRow.kt @@ -91,9 +91,9 @@ fun LocationShareRow( ) } Text( - text = item.description, + text = if (item.isLive) "Sharing live location" else item.formattedTimestamp, style = ElementTheme.typography.fontBodySmRegular, - color = ElementTheme.colors.textSecondary, + color = if(item.isLive) ElementTheme.colors.textPrimary else ElementTheme.colors.textSecondary, maxLines = 1, overflow = TextOverflow.Ellipsis, ) @@ -123,7 +123,7 @@ internal fun LocationShareRowPreview() = ElementPreview { url = null, size = AvatarSize.UserListItem, ), - description = "Shared 1 min ago", + formattedTimestamp = "Shared 1 min ago", isLive = true, assetType = AssetType.SENDER, location = Location(0.0, 0.0) @@ -142,7 +142,7 @@ internal fun LocationShareRowPreview() = ElementPreview { ), isLive = false, assetType = AssetType.PIN, - description = "Shared 5 hours ago", + formattedTimestamp = "Shared 5 hours ago", location = Location(0.0, 0.0) ), onShareClick = {}, diff --git a/features/location/impl/src/main/kotlin/io/element/android/features/location/impl/show/ShowLocationPresenter.kt b/features/location/impl/src/main/kotlin/io/element/android/features/location/impl/show/ShowLocationPresenter.kt index 2f9c3d0d81..e23baf1a43 100644 --- a/features/location/impl/src/main/kotlin/io/element/android/features/location/impl/show/ShowLocationPresenter.kt +++ b/features/location/impl/src/main/kotlin/io/element/android/features/location/impl/show/ShowLocationPresenter.kt @@ -123,7 +123,7 @@ class ShowLocationPresenter( url = mode.senderAvatarUrl, size = AvatarSize.UserListItem, ), - description = formattedTimestamp, + formattedTimestamp = formattedTimestamp, location = mode.location, isLive = false, assetType = mode.assetType, @@ -142,6 +142,11 @@ class ShowLocationPresenter( val member = members.find { it.userId == share.userId } val displayName = member?.getBestName() ?: share.userId.value val avatarUrl = member?.avatarUrl + val relativeTime = dateFormatter.format(timestamp = share.lastLocation?.timestamp, mode = DateFormatterMode.Full, useRelative = true) + val formattedTimestamp = stringProvider.getString( + CommonStrings.screen_static_location_sheet_timestamp_description, + relativeTime + ) LocationShareItem( userId = share.userId, displayName = displayName, @@ -151,7 +156,7 @@ class ShowLocationPresenter( url = avatarUrl, size = AvatarSize.UserListItem, ), - description = "Sharing live location", + formattedTimestamp = formattedTimestamp, location = location, isLive = true, assetType = lastLocation.assetType, diff --git a/features/location/impl/src/main/kotlin/io/element/android/features/location/impl/show/ShowLocationState.kt b/features/location/impl/src/main/kotlin/io/element/android/features/location/impl/show/ShowLocationState.kt index 3d4df465f9..b6a60f35db 100644 --- a/features/location/impl/src/main/kotlin/io/element/android/features/location/impl/show/ShowLocationState.kt +++ b/features/location/impl/src/main/kotlin/io/element/android/features/location/impl/show/ShowLocationState.kt @@ -34,7 +34,7 @@ data class LocationShareItem( val userId: UserId, val displayName: String, val avatarData: AvatarData, - val description: String, + val formattedTimestamp: String, val location: Location, val isLive: Boolean, val assetType: AssetType?, diff --git a/features/location/impl/src/main/kotlin/io/element/android/features/location/impl/show/ShowLocationStateProvider.kt b/features/location/impl/src/main/kotlin/io/element/android/features/location/impl/show/ShowLocationStateProvider.kt index 3b08e81890..1ab2310365 100644 --- a/features/location/impl/src/main/kotlin/io/element/android/features/location/impl/show/ShowLocationStateProvider.kt +++ b/features/location/impl/src/main/kotlin/io/element/android/features/location/impl/show/ShowLocationStateProvider.kt @@ -10,7 +10,6 @@ package io.element.android.features.location.impl.show import androidx.compose.ui.tooling.preview.PreviewParameterProvider import io.element.android.features.location.api.Location -import io.element.android.features.location.api.ShowLocationMode import io.element.android.features.location.impl.common.ui.LocationConstraintsDialogState import io.element.android.libraries.designsystem.components.avatar.AvatarData import io.element.android.libraries.designsystem.components.avatar.AvatarSize @@ -77,15 +76,15 @@ fun aLocationShareItem( url = null, size = AvatarSize.UserListItem, ), - formattedTimestamp: String = "Shared 1 min ago", - location: Location = Location(1.23, 2.34, 4f), isLive: Boolean = false, assetType: AssetType? = null, + formattedTimestamp: String = "Shared 1 min ago", + location: Location = Location(1.23, 2.34, 4f), ) = LocationShareItem( userId = userId, displayName = displayName, avatarData = avatarData, - description = formattedTimestamp, + formattedTimestamp = formattedTimestamp, location = location, isLive = isLive, assetType = assetType,