Adds user id and canonical alias to search result subtitles

This commit is contained in:
ericdecanini 2022-04-28 11:12:47 +02:00
parent 9e53e6cc8f
commit 70cded2733
3 changed files with 18 additions and 8 deletions

View File

@ -59,7 +59,7 @@ abstract class RoomSummaryItem : VectorEpoxyModel<RoomSummaryItem.Holder>() {
var displayMode: RoomListDisplayMode = RoomListDisplayMode.PEOPLE var displayMode: RoomListDisplayMode = RoomListDisplayMode.PEOPLE
@EpoxyAttribute @EpoxyAttribute
var spaceName: String? = null lateinit var subtitle: String
@EpoxyAttribute @EpoxyAttribute
lateinit var lastFormattedEvent: EpoxyCharSequence lateinit var lastFormattedEvent: EpoxyCharSequence
@ -112,7 +112,7 @@ abstract class RoomSummaryItem : VectorEpoxyModel<RoomSummaryItem.Holder>() {
} }
holder.titleView.text = matrixItem.getBestName() holder.titleView.text = matrixItem.getBestName()
holder.lastEventTimeView.text = lastEventTime holder.lastEventTimeView.text = lastEventTime
holder.lastEventView.text = getTextForLastEventView() holder.subtitleView.text = getTextForLastEventView()
holder.unreadCounterBadgeView.render(UnreadCounterBadgeView.State(unreadNotificationCount, showHighlighted)) holder.unreadCounterBadgeView.render(UnreadCounterBadgeView.State(unreadNotificationCount, showHighlighted))
holder.unreadIndentIndicator.isVisible = hasUnreadMessage holder.unreadIndentIndicator.isVisible = hasUnreadMessage
holder.draftView.isVisible = hasDraft holder.draftView.isVisible = hasDraft
@ -122,13 +122,13 @@ abstract class RoomSummaryItem : VectorEpoxyModel<RoomSummaryItem.Holder>() {
holder.roomAvatarFailSendingImageView.isVisible = hasFailedSending holder.roomAvatarFailSendingImageView.isVisible = hasFailedSending
renderSelection(holder, showSelected) renderSelection(holder, showSelected)
holder.typingView.setTextOrHide(typingMessage) holder.typingView.setTextOrHide(typingMessage)
holder.lastEventView.isInvisible = holder.typingView.isVisible holder.subtitleView.isInvisible = holder.typingView.isVisible
holder.roomAvatarPresenceImageView.render(showPresence, userPresence) holder.roomAvatarPresenceImageView.render(showPresence, userPresence)
} }
private fun getTextForLastEventView(): CharSequence { private fun getTextForLastEventView(): CharSequence {
return if (displayMode == RoomListDisplayMode.FILTERED) { return if (displayMode == RoomListDisplayMode.FILTERED) {
spaceName.orEmpty() // TODO: handle other cases subtitle
} else { } else {
lastFormattedEvent.charSequence lastFormattedEvent.charSequence
} }
@ -157,7 +157,7 @@ abstract class RoomSummaryItem : VectorEpoxyModel<RoomSummaryItem.Holder>() {
val titleView by bind<TextView>(R.id.roomNameView) val titleView by bind<TextView>(R.id.roomNameView)
val unreadCounterBadgeView by bind<UnreadCounterBadgeView>(R.id.roomUnreadCounterBadgeView) val unreadCounterBadgeView by bind<UnreadCounterBadgeView>(R.id.roomUnreadCounterBadgeView)
val unreadIndentIndicator by bind<View>(R.id.roomUnreadIndicator) val unreadIndentIndicator by bind<View>(R.id.roomUnreadIndicator)
val lastEventView by bind<TextView>(R.id.roomLastEventView) val subtitleView by bind<TextView>(R.id.subtitleView)
val typingView by bind<TextView>(R.id.roomTypingView) val typingView by bind<TextView>(R.id.roomTypingView)
val draftView by bind<ImageView>(R.id.roomDraftBadge) val draftView by bind<ImageView>(R.id.roomDraftBadge)
val lastEventTimeView by bind<TextView>(R.id.roomLastEventTimeView) val lastEventTimeView by bind<TextView>(R.id.roomLastEventTimeView)

View File

@ -111,6 +111,7 @@ class RoomSummaryItemFactory @Inject constructor(private val displayableEventFor
onClick: ((RoomSummary) -> Unit)?, onClick: ((RoomSummary) -> Unit)?,
onLongClick: ((RoomSummary) -> Boolean)? onLongClick: ((RoomSummary) -> Boolean)?
): VectorEpoxyModel<*> { ): VectorEpoxyModel<*> {
val subtitle = getSearchResultSubtitle(roomSummary)
val unreadCount = roomSummary.notificationCount val unreadCount = roomSummary.notificationCount
val showHighlighted = roomSummary.highlightCount > 0 val showHighlighted = roomSummary.highlightCount > 0
val showSelected = selectedRoomIds.contains(roomSummary.roomId) 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()) latestFormattedEvent = displayableEventFormatter.format(latestEvent, roomSummary.isDirect, roomSummary.isDirect.not())
latestEventTime = dateFormatter.format(latestEvent.root.originServerTs, DateFormatKind.ROOM_LIST) latestEventTime = dateFormatter.format(latestEvent.root.originServerTs, DateFormatKind.ROOM_LIST)
} }
val typingMessage = typingHelper.getTypingMessage(roomSummary.typingUsers) val typingMessage = typingHelper.getTypingMessage(roomSummary.typingUsers)
return RoomSummaryItem_() return RoomSummaryItem_()
.id(roomSummary.roomId) .id(roomSummary.roomId)
@ -128,7 +130,7 @@ class RoomSummaryItemFactory @Inject constructor(private val displayableEventFor
// We do not display shield in the room list anymore // We do not display shield in the room list anymore
// .encryptionTrustLevel(roomSummary.roomEncryptionTrustLevel) // .encryptionTrustLevel(roomSummary.roomEncryptionTrustLevel)
.displayMode(displayMode) .displayMode(displayMode)
.spaceName(roomSummary.spaceParents?.firstOrNull()?.roomSummary?.name.orEmpty()) .subtitle(subtitle)
.isPublic(roomSummary.isPublic) .isPublic(roomSummary.isPublic)
.showPresence(roomSummary.isDirect) .showPresence(roomSummary.isDirect)
.userPresence(roomSummary.directUserPresence) .userPresence(roomSummary.directUserPresence)
@ -147,4 +149,12 @@ class RoomSummaryItemFactory @Inject constructor(private val displayableEventFor
} }
.itemClickListener { onClick?.invoke(roomSummary) } .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()
}
} }

View File

@ -183,7 +183,7 @@
tools:text="@tools:sample/date/hhmm" /> tools:text="@tools:sample/date/hhmm" />
<TextView <TextView
android:id="@+id/roomLastEventView" android:id="@+id/subtitleView"
style="@style/Widget.Vector.TextView.Body" style="@style/Widget.Vector.TextView.Body"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -222,7 +222,7 @@
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="7dp" android:layout_height="7dp"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/roomLastEventView" app:layout_constraintTop_toBottomOf="@id/subtitleView"
tools:layout_marginStart="120dp" /> tools:layout_marginStart="120dp" />
<androidx.constraintlayout.widget.Barrier <androidx.constraintlayout.widget.Barrier