diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/timeline/TimelineEvent.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/timeline/TimelineEvent.kt index 95131b9d27..1566425e98 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/timeline/TimelineEvent.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/timeline/TimelineEvent.kt @@ -27,6 +27,7 @@ import org.matrix.android.sdk.api.session.events.model.isEdition import org.matrix.android.sdk.api.session.events.model.isLiveLocation import org.matrix.android.sdk.api.session.events.model.isPoll import org.matrix.android.sdk.api.session.events.model.isReply +import org.matrix.android.sdk.api.session.events.model.isReplyRenderedInThread import org.matrix.android.sdk.api.session.events.model.isSticker import org.matrix.android.sdk.api.session.events.model.toContent import org.matrix.android.sdk.api.session.events.model.toModel @@ -206,6 +207,10 @@ fun TimelineEvent.isReply(): Boolean { return root.isReply() } +fun TimelineEvent.isReplyRenderedInThread(): Boolean { + return root.isReplyRenderedInThread() +} + fun TimelineEvent.isEdition(): Boolean { return root.isEdition() } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/MessageInformationDataFactory.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/MessageInformationDataFactory.kt index ba949e647a..c0c9df21a7 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/MessageInformationDataFactory.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/MessageInformationDataFactory.kt @@ -50,6 +50,7 @@ import org.matrix.android.sdk.api.session.room.send.SendState import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent import org.matrix.android.sdk.api.session.room.timeline.hasBeenEdited import org.matrix.android.sdk.api.session.room.timeline.isReply +import org.matrix.android.sdk.api.session.room.timeline.isReplyRenderedInThread import timber.log.Timber import javax.inject.Inject @@ -160,7 +161,7 @@ class MessageInformationDataFactory @Inject constructor( senderPowerLevel = senderPowerLevel, isDirect = isEffectivelyDirect, isPublic = roomSummary?.isPublic ?: false, - isReply = event.isReply(), + isReply = if (params.isFromThreadTimeline()) event.isReplyRenderedInThread() else event.isReply(), dmChatPartnerId = dmOtherMemberId, isFirstFromThisSender = isFirstFromThisSender, isLastFromThisSender = isLastFromThisSender, diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/style/TimelineMessageLayoutFactory.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/style/TimelineMessageLayoutFactory.kt index 0858b57204..4c710d7d5a 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/style/TimelineMessageLayoutFactory.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/style/TimelineMessageLayoutFactory.kt @@ -26,6 +26,7 @@ import im.vector.app.features.home.room.detail.timeline.factory.TimelineItemFact import im.vector.app.features.settings.VectorPreferences import im.vector.app.features.themes.BubbleThemeUtils import im.vector.app.features.voicebroadcast.VoiceBroadcastConstants.STATE_ROOM_VOICE_BROADCAST_INFO +import org.matrix.android.sdk.api.extensions.orFalse import org.matrix.android.sdk.api.session.Session import org.matrix.android.sdk.api.session.events.model.EventType import org.matrix.android.sdk.api.session.room.model.message.MessageContent @@ -39,6 +40,7 @@ import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent import org.matrix.android.sdk.api.session.room.timeline.getLastMessageContent import org.matrix.android.sdk.api.session.room.timeline.isEdition import org.matrix.android.sdk.api.session.room.timeline.isReply +import org.matrix.android.sdk.api.session.room.timeline.isReplyRenderedInThread import org.matrix.android.sdk.api.session.room.timeline.isRootThread import javax.inject.Inject @@ -129,7 +131,7 @@ class TimelineMessageLayoutFactory @Inject constructor( val messageContent = event.getLastMessageContent() val isBubble = event.shouldBuildBubbleLayout() val singleSidedLayout = bubbleThemeUtils.getBubbleStyle() == BubbleThemeUtils.BUBBLE_STYLE_START - val pseudoBubble = messageContent.isPseudoBubble(event) + val pseudoBubble = messageContent.isPseudoBubble(event, params = params) val showTimestamp = showInformation || !singleSidedLayout || vectorPreferences.alwaysShowTimeStamps() return TimelineMessageLayout.ScBubble( showAvatar = showInformation, @@ -217,10 +219,11 @@ class TimelineMessageLayoutFactory @Inject constructor( } } - private fun MessageContent?.isPseudoBubble(event: TimelineEvent, ignoreReply: Boolean = false): Boolean { + private fun MessageContent?.isPseudoBubble(event: TimelineEvent, ignoreReply: Boolean = false, params: TimelineItemFactoryParams? = null): Boolean { if (this == null) return false if (event.root.isRedacted()) return false - if (!ignoreReply && event.isReply()) return false + val isReply = if (params?.isFromThreadTimeline().orFalse()) event.isReplyRenderedInThread() else event.isReply() + if (!ignoreReply && isReply) return false if (this is MessageWithAttachmentContent && !getCaption().isNullOrBlank()) return false return this.msgType in MSG_TYPES_WITH_PSEUDO_BUBBLE_LAYOUT }