From 70cded273348eec5fd4d1cef7dacab828f26d7e3 Mon Sep 17 00:00:00 2001 From: ericdecanini Date: Thu, 28 Apr 2022 11:12:47 +0200 Subject: [PATCH] Adds user id and canonical alias to search result subtitles --- .../app/features/home/room/list/RoomSummaryItem.kt | 10 +++++----- .../home/room/list/RoomSummaryItemFactory.kt | 12 +++++++++++- vector/src/main/res/layout/item_room.xml | 4 ++-- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItem.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItem.kt index a869041aa8..3c091d0e05 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItem.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItem.kt @@ -59,7 +59,7 @@ abstract class RoomSummaryItem : VectorEpoxyModel() { var displayMode: RoomListDisplayMode = RoomListDisplayMode.PEOPLE @EpoxyAttribute - var spaceName: String? = null + lateinit var subtitle: String @EpoxyAttribute lateinit var lastFormattedEvent: EpoxyCharSequence @@ -112,7 +112,7 @@ abstract class RoomSummaryItem : VectorEpoxyModel() { } holder.titleView.text = matrixItem.getBestName() holder.lastEventTimeView.text = lastEventTime - holder.lastEventView.text = getTextForLastEventView() + holder.subtitleView.text = getTextForLastEventView() holder.unreadCounterBadgeView.render(UnreadCounterBadgeView.State(unreadNotificationCount, showHighlighted)) holder.unreadIndentIndicator.isVisible = hasUnreadMessage holder.draftView.isVisible = hasDraft @@ -122,13 +122,13 @@ abstract class RoomSummaryItem : VectorEpoxyModel() { holder.roomAvatarFailSendingImageView.isVisible = hasFailedSending renderSelection(holder, showSelected) holder.typingView.setTextOrHide(typingMessage) - holder.lastEventView.isInvisible = holder.typingView.isVisible + holder.subtitleView.isInvisible = holder.typingView.isVisible holder.roomAvatarPresenceImageView.render(showPresence, userPresence) } private fun getTextForLastEventView(): CharSequence { return if (displayMode == RoomListDisplayMode.FILTERED) { - spaceName.orEmpty() // TODO: handle other cases + subtitle } else { lastFormattedEvent.charSequence } @@ -157,7 +157,7 @@ abstract class RoomSummaryItem : VectorEpoxyModel() { val titleView by bind(R.id.roomNameView) val unreadCounterBadgeView by bind(R.id.roomUnreadCounterBadgeView) val unreadIndentIndicator by bind(R.id.roomUnreadIndicator) - val lastEventView by bind(R.id.roomLastEventView) + val subtitleView by bind(R.id.subtitleView) val typingView by bind(R.id.roomTypingView) val draftView by bind(R.id.roomDraftBadge) val lastEventTimeView by bind(R.id.roomLastEventTimeView) diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItemFactory.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItemFactory.kt index f11f39e402..cc99c0eb6e 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItemFactory.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItemFactory.kt @@ -111,6 +111,7 @@ class RoomSummaryItemFactory @Inject constructor(private val displayableEventFor onClick: ((RoomSummary) -> Unit)?, onLongClick: ((RoomSummary) -> Boolean)? ): VectorEpoxyModel<*> { + val subtitle = getSearchResultSubtitle(roomSummary) val unreadCount = roomSummary.notificationCount val showHighlighted = roomSummary.highlightCount > 0 val showSelected = selectedRoomIds.contains(roomSummary.roomId) @@ -121,6 +122,7 @@ class RoomSummaryItemFactory @Inject constructor(private val displayableEventFor latestFormattedEvent = displayableEventFormatter.format(latestEvent, roomSummary.isDirect, roomSummary.isDirect.not()) latestEventTime = dateFormatter.format(latestEvent.root.originServerTs, DateFormatKind.ROOM_LIST) } + val typingMessage = typingHelper.getTypingMessage(roomSummary.typingUsers) return RoomSummaryItem_() .id(roomSummary.roomId) @@ -128,7 +130,7 @@ class RoomSummaryItemFactory @Inject constructor(private val displayableEventFor // We do not display shield in the room list anymore // .encryptionTrustLevel(roomSummary.roomEncryptionTrustLevel) .displayMode(displayMode) - .spaceName(roomSummary.spaceParents?.firstOrNull()?.roomSummary?.name.orEmpty()) + .subtitle(subtitle) .isPublic(roomSummary.isPublic) .showPresence(roomSummary.isDirect) .userPresence(roomSummary.directUserPresence) @@ -147,4 +149,12 @@ class RoomSummaryItemFactory @Inject constructor(private val displayableEventFor } .itemClickListener { onClick?.invoke(roomSummary) } } + + private fun getSearchResultSubtitle(roomSummary: RoomSummary): String { + val spaceName = roomSummary.spaceParents?.firstOrNull()?.roomSummary?.name + val userId = roomSummary.directUserId + val canonicalAlias = roomSummary.canonicalAlias + + return (spaceName ?: userId ?: canonicalAlias).orEmpty() + } } diff --git a/vector/src/main/res/layout/item_room.xml b/vector/src/main/res/layout/item_room.xml index 3911e8df34..ab0af18acb 100644 --- a/vector/src/main/res/layout/item_room.xml +++ b/vector/src/main/res/layout/item_room.xml @@ -183,7 +183,7 @@ tools:text="@tools:sample/date/hhmm" />