Display encrypted messages in thread summary and in thread list

This commit is contained in:
ariskotsomitopoulos 2022-01-11 17:52:14 +02:00
parent 1e2fb88783
commit 4560d748d3
7 changed files with 26 additions and 8 deletions

View File

@ -197,8 +197,8 @@ data class Event(
* It can be used especially for message summaries. * It can be used especially for message summaries.
* It will return a decrypted text message or an empty string otherwise. * It will return a decrypted text message or an empty string otherwise.
*/ */
fun getDecryptedTextSummary(): String { fun getDecryptedTextSummary(): String? {
val text = getDecryptedValue().orEmpty() val text = getDecryptedValue() ?: return null
return when { return when {
isReply() || isQuote() -> ContentUtils.extractUsefulTextFromReply(text) isReply() || isQuote() -> ContentUtils.extractUsefulTextFromReply(text)
isFileMessage() -> "sent a file." isFileMessage() -> "sent a file."

View File

@ -113,7 +113,7 @@ internal object EventMapper {
) )
}, },
threadNotificationState = eventEntity.threadNotificationState, threadNotificationState = eventEntity.threadNotificationState,
threadSummaryLatestTextMessage = eventEntity.threadSummaryLatestMessage?.root?.asDomain()?.getDecryptedTextSummary().orEmpty(), threadSummaryLatestTextMessage = eventEntity.threadSummaryLatestMessage?.root?.asDomain()?.getDecryptedTextSummary(),
lastMessageTimestamp = eventEntity.threadSummaryLatestMessage?.root?.originServerTs lastMessageTimestamp = eventEntity.threadSummaryLatestMessage?.root?.originServerTs
) )

View File

@ -1902,7 +1902,11 @@ class TimelineFragment @Inject constructor(
roomDetailViewModel.handle(action) roomDetailViewModel.handle(action)
} }
is EncryptedEventContent -> { is EncryptedEventContent -> {
roomDetailViewModel.handle(RoomDetailAction.TapOnFailedToDecrypt(informationData.eventId)) if(isRootThreadEvent){
onThreadSummaryClicked(informationData.eventId, isRootThreadEvent)
}else {
roomDetailViewModel.handle(RoomDetailAction.TapOnFailedToDecrypt(informationData.eventId))
}
} }
else -> { else -> {
onThreadSummaryClicked(informationData.eventId, isRootThreadEvent) onThreadSummaryClicked(informationData.eventId, isRootThreadEvent)

View File

@ -106,7 +106,12 @@ class EncryptedItemFactory @Inject constructor(private val messageInformationDat
} }
val informationData = messageInformationDataFactory.create(params) val informationData = messageInformationDataFactory.create(params)
val attributes = attributesFactory.create(event.root.content.toModel<EncryptedEventContent>(), informationData, params.callback) val threadDetails = if (params.isFromThreadTimeline()) null else event.root.threadDetails
val attributes = attributesFactory.create(
messageContent = event.root.content.toModel<EncryptedEventContent>(),
informationData = informationData,
callback = params.callback,
threadDetails = threadDetails)
return MessageTextItem_() return MessageTextItem_()
.leftGuideline(avatarSizeProvider.leftGuideline) .leftGuideline(avatarSizeProvider.leftGuideline)
.highlighted(params.isHighlighted) .highlighted(params.isHighlighted)

View File

@ -16,6 +16,8 @@
package im.vector.app.features.home.room.detail.timeline.helper package im.vector.app.features.home.room.detail.timeline.helper
import im.vector.app.EmojiCompatFontProvider import im.vector.app.EmojiCompatFontProvider
import im.vector.app.R
import im.vector.app.core.resources.StringProvider
import im.vector.app.features.home.AvatarRenderer import im.vector.app.features.home.AvatarRenderer
import im.vector.app.features.home.room.detail.timeline.MessageColorProvider import im.vector.app.features.home.room.detail.timeline.MessageColorProvider
import im.vector.app.features.home.room.detail.timeline.TimelineEventController import im.vector.app.features.home.room.detail.timeline.TimelineEventController
@ -28,6 +30,7 @@ class MessageItemAttributesFactory @Inject constructor(
private val avatarRenderer: AvatarRenderer, private val avatarRenderer: AvatarRenderer,
private val messageColorProvider: MessageColorProvider, private val messageColorProvider: MessageColorProvider,
private val avatarSizeProvider: AvatarSizeProvider, private val avatarSizeProvider: AvatarSizeProvider,
private val stringProvider: StringProvider,
private val emojiCompatFontProvider: EmojiCompatFontProvider) { private val emojiCompatFontProvider: EmojiCompatFontProvider) {
fun create(messageContent: Any?, fun create(messageContent: Any?,
@ -53,6 +56,7 @@ class MessageItemAttributesFactory @Inject constructor(
threadCallback = callback, threadCallback = callback,
readReceiptsCallback = callback, readReceiptsCallback = callback,
emojiTypeFace = emojiCompatFontProvider.typeface, emojiTypeFace = emojiCompatFontProvider.typeface,
decryptionErrorMessage = stringProvider.getString(R.string.encrypted_message),
threadDetails = threadDetails threadDetails = threadDetails
) )
} }

View File

@ -118,7 +118,7 @@ abstract class AbsMessageItem<H : AbsMessageItem.Holder> : AbsBaseMessageItem<H>
attributes.threadDetails?.let { threadDetails -> attributes.threadDetails?.let { threadDetails ->
holder.threadSummaryConstraintLayout.isVisible = threadDetails.isRootThread holder.threadSummaryConstraintLayout.isVisible = threadDetails.isRootThread
holder.threadSummaryCounterTextView.text = threadDetails.numberOfThreads.toString() holder.threadSummaryCounterTextView.text = threadDetails.numberOfThreads.toString()
holder.threadSummaryInfoTextView.text = threadDetails.threadSummaryLatestTextMessage holder.threadSummaryInfoTextView.text = threadDetails.threadSummaryLatestTextMessage ?: attributes.decryptionErrorMessage
val userId = threadDetails.threadSummarySenderInfo?.userId ?: return@let val userId = threadDetails.threadSummarySenderInfo?.userId ?: return@let
val displayName = threadDetails.threadSummarySenderInfo?.displayName val displayName = threadDetails.threadSummarySenderInfo?.displayName
@ -185,6 +185,7 @@ abstract class AbsMessageItem<H : AbsMessageItem.Holder> : AbsBaseMessageItem<H>
val threadCallback: TimelineEventController.ThreadCallback? = null, val threadCallback: TimelineEventController.ThreadCallback? = null,
override val readReceiptsCallback: TimelineEventController.ReadReceiptsCallback? = null, override val readReceiptsCallback: TimelineEventController.ReadReceiptsCallback? = null,
val emojiTypeFace: Typeface? = null, val emojiTypeFace: Typeface? = null,
val decryptionErrorMessage: String? = null,
val threadDetails: ThreadDetails? = null val threadDetails: ThreadDetails? = null
) : AbsBaseMessageItem.Attributes { ) : AbsBaseMessageItem.Attributes {

View File

@ -17,8 +17,10 @@
package im.vector.app.features.home.room.threads.list.viewmodel package im.vector.app.features.home.room.threads.list.viewmodel
import com.airbnb.epoxy.EpoxyController import com.airbnb.epoxy.EpoxyController
import im.vector.app.R
import im.vector.app.core.date.DateFormatKind import im.vector.app.core.date.DateFormatKind
import im.vector.app.core.date.VectorDateFormatter import im.vector.app.core.date.VectorDateFormatter
import im.vector.app.core.resources.StringProvider
import im.vector.app.features.home.AvatarRenderer import im.vector.app.features.home.AvatarRenderer
import im.vector.app.features.home.room.threads.list.model.threadList import im.vector.app.features.home.room.threads.list.model.threadList
import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent
@ -28,6 +30,7 @@ import javax.inject.Inject
class ThreadListController @Inject constructor( class ThreadListController @Inject constructor(
private val avatarRenderer: AvatarRenderer, private val avatarRenderer: AvatarRenderer,
private val stringProvider: StringProvider,
private val dateFormatter: VectorDateFormatter private val dateFormatter: VectorDateFormatter
) : EpoxyController() { ) : EpoxyController() {
@ -56,6 +59,7 @@ class ThreadListController @Inject constructor(
} }
?.forEach { timelineEvent -> ?.forEach { timelineEvent ->
val date = dateFormatter.format(timelineEvent.root.threadDetails?.lastMessageTimestamp, DateFormatKind.ROOM_LIST) val date = dateFormatter.format(timelineEvent.root.threadDetails?.lastMessageTimestamp, DateFormatKind.ROOM_LIST)
val decryptionErrorMessage = stringProvider.getString(R.string.encrypted_message)
threadList { threadList {
id(timelineEvent.eventId) id(timelineEvent.eventId)
avatarRenderer(host.avatarRenderer) avatarRenderer(host.avatarRenderer)
@ -64,8 +68,8 @@ class ThreadListController @Inject constructor(
date(date) date(date)
rootMessageDeleted(timelineEvent.root.isRedacted()) rootMessageDeleted(timelineEvent.root.isRedacted())
threadNotificationState(timelineEvent.root.threadDetails?.threadNotificationState ?: ThreadNotificationState.NO_NEW_MESSAGE) threadNotificationState(timelineEvent.root.threadDetails?.threadNotificationState ?: ThreadNotificationState.NO_NEW_MESSAGE)
rootMessage(timelineEvent.root.getDecryptedTextSummary()) rootMessage(timelineEvent.root.getDecryptedTextSummary() ?: decryptionErrorMessage)
lastMessage(timelineEvent.root.threadDetails?.threadSummaryLatestTextMessage.orEmpty()) lastMessage(timelineEvent.root.threadDetails?.threadSummaryLatestTextMessage ?: decryptionErrorMessage)
lastMessageCounter(timelineEvent.root.threadDetails?.numberOfThreads.toString()) lastMessageCounter(timelineEvent.root.threadDetails?.numberOfThreads.toString())
lastMessageMatrixItem(timelineEvent.root.threadDetails?.threadSummarySenderInfo?.toMatrixItem()) lastMessageMatrixItem(timelineEvent.root.threadDetails?.threadSummarySenderInfo?.toMatrixItem())
itemClickListener { itemClickListener {