From 946d8cd660b2841035a47c94880ed970f2a1bea0 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Fri, 18 Aug 2023 14:45:52 +0200 Subject: [PATCH 1/3] Fix loing sender name displayed on several lines (#1033) --- .../impl/timeline/TimelineStateProvider.kt | 15 +++++++----- .../components/TimelineItemEventRow.kt | 24 +++++++++++++++++++ 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/TimelineStateProvider.kt b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/TimelineStateProvider.kt index b47ded8b3a..6172da0469 100644 --- a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/TimelineStateProvider.kt +++ b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/TimelineStateProvider.kt @@ -106,6 +106,7 @@ internal fun aTimelineItemEvent( eventId: EventId = EventId("\$" + Random.nextInt().toString()), transactionId: TransactionId? = null, isMine: Boolean = false, + senderDisplayName: String = "Sender", content: TimelineItemEventContent = aTimelineItemTextContent(), groupPosition: TimelineItemGroupPosition = TimelineItemGroupPosition.None, sendState: LocalEventSendState = LocalEventSendState.Sent(eventId), @@ -123,7 +124,7 @@ internal fun aTimelineItemEvent( reactionsState = timelineItemReactions, sentTime = "12:34", isMine = isMine, - senderDisplayName = "Sender", + senderDisplayName = senderDisplayName, groupPosition = groupPosition, localSendState = sendState, inReplyTo = inReplyTo, @@ -141,11 +142,13 @@ fun aTimelineItemReactions( reactions = buildList { repeat(count) { index -> val key = emojis[index % emojis.size] - add(anAggregatedReaction( - key = key, - count = index + 1, - isHighlighted = isHighlighted - )) + add( + anAggregatedReaction( + key = key, + count = index + 1, + isHighlighted = isHighlighted + ) + ) } }.toPersistentList() ) diff --git a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/TimelineItemEventRow.kt b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/TimelineItemEventRow.kt index 90d3e6cd8c..fbeb0af1d7 100644 --- a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/TimelineItemEventRow.kt +++ b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/TimelineItemEventRow.kt @@ -340,6 +340,8 @@ private fun MessageSenderInformation( Spacer(modifier = Modifier.width(4.dp)) Text( text = sender, + maxLines = 1, + overflow = TextOverflow.Ellipsis, color = MaterialTheme.colorScheme.primary, style = ElementTheme.typography.fontBodyMdMedium, ) @@ -786,3 +788,25 @@ private fun ContentWithManyReactionsToPreview() { } } } + +// Note: no need for light/dark variant for this preview +@Preview +@Composable +internal fun TimelineItemEventRowLongSenderNamePreview() = ElementPreviewLight { + TimelineItemEventRow( + event = aTimelineItemEvent( + senderDisplayName = "a long sender display name to test single line and ellipsis at the end of the line", + ), + isHighlighted = false, + canReply = true, + onClick = {}, + onLongClick = {}, + onUserDataClick = {}, + inReplyToClick = {}, + onReactionClick = { _, _ -> }, + onReactionLongClick = { _, _ -> }, + onMoreReactionsClick = {}, + onSwipeToReply = {}, + onTimestampClicked = {}, + ) +} From 42eb0d89e2622e403d089722a9982667951c1fda Mon Sep 17 00:00:00 2001 From: ElementBot Date: Fri, 18 Aug 2023 13:16:39 +0000 Subject: [PATCH 2/3] Update screenshots --- ...melineItemEventRowLongSenderName_0_null,NEXUS_5,1.0,en].png | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 tests/uitests/src/test/snapshots/images/ui_S_t[f.messages.impl.timeline.components_null_TimelineItemEventRowLongSenderName_0_null,NEXUS_5,1.0,en].png diff --git a/tests/uitests/src/test/snapshots/images/ui_S_t[f.messages.impl.timeline.components_null_TimelineItemEventRowLongSenderName_0_null,NEXUS_5,1.0,en].png b/tests/uitests/src/test/snapshots/images/ui_S_t[f.messages.impl.timeline.components_null_TimelineItemEventRowLongSenderName_0_null,NEXUS_5,1.0,en].png new file mode 100644 index 0000000000..56d35e8f11 --- /dev/null +++ b/tests/uitests/src/test/snapshots/images/ui_S_t[f.messages.impl.timeline.components_null_TimelineItemEventRowLongSenderName_0_null,NEXUS_5,1.0,en].png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cb071f845598b35931253304f4c9f4c865b5fe9f57662c03c88a0c94a7835d83 +size 18615 From f6f1ab7db30bf72f33298b8895ba949579391754 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Fri, 18 Aug 2023 15:21:14 +0200 Subject: [PATCH 3/3] changelog --- changelog.d/1033.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/1033.bugfix diff --git a/changelog.d/1033.bugfix b/changelog.d/1033.bugfix new file mode 100644 index 0000000000..db4397449b --- /dev/null +++ b/changelog.d/1033.bugfix @@ -0,0 +1 @@ +Timeline: sender names are now displayed in one single line.