diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageLocationItem.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageLocationItem.kt index 51d95570c0..6d91ef2d14 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageLocationItem.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageLocationItem.kt @@ -20,9 +20,14 @@ import android.widget.FrameLayout import androidx.constraintlayout.widget.ConstraintLayout import com.airbnb.epoxy.EpoxyAttribute import com.airbnb.epoxy.EpoxyModelClass +import com.bumptech.glide.load.resource.bitmap.GranularRoundedCorners +import com.bumptech.glide.load.resource.bitmap.RoundedCorners +import com.google.android.material.card.MaterialCardView import im.vector.app.R import im.vector.app.core.epoxy.onClick import im.vector.app.features.home.room.detail.timeline.helper.LocationPinProvider +import im.vector.app.features.home.room.detail.timeline.style.TimelineMessageLayout +import im.vector.app.features.home.room.detail.timeline.style.shapeAppearanceModel import im.vector.app.features.location.LocationData import im.vector.app.features.location.MapTilerMapView @@ -48,9 +53,12 @@ abstract class MessageLocationItem : AbsMessageItem( override fun bind(holder: Holder) { super.bind(holder) renderSendState(holder.mapViewContainer, null) - val location = locationData ?: return val locationOwnerId = userId ?: return + val messageLayout = attributes.informationData.messageLayout + if (messageLayout is TimelineMessageLayout.Bubble) { + holder.mapCardView.shapeAppearanceModel = messageLayout.shapeAppearanceModel(12f) + } holder.clickableMapArea.onClick { callback?.onMapClicked() @@ -71,6 +79,7 @@ abstract class MessageLocationItem : AbsMessageItem( override fun getViewStubId() = STUB_ID class Holder : AbsMessageItem.Holder(STUB_ID) { + val mapCardView by bind(R.id.mapCardView) val mapViewContainer by bind(R.id.mapViewContainer) val mapView by bind(R.id.mapView) val clickableMapArea by bind(R.id.clickableMapArea) 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 e5ba544657..2f6ec15fde 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 @@ -21,6 +21,7 @@ import im.vector.app.features.home.room.detail.timeline.factory.TimelineItemFact import im.vector.app.features.settings.VectorPreferences 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 import org.matrix.android.sdk.api.session.room.model.message.MessageType import org.matrix.android.sdk.api.session.room.model.message.MessageVerificationRequestContent import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent @@ -100,8 +101,8 @@ class TimelineMessageLayoutFactory @Inject constructor(private val session: Sess isIncoming = !isSentByMe, isFirstFromThisSender = isFirstFromThisSender, isLastFromThisSender = isLastFromThisSender, - isPseudoBubble = messageContent?.msgType in MSG_TYPES_WITH_PSEUDO_BUBBLE_LAYOUT, - timestampAsOverlay = messageContent?.msgType in MSG_TYPES_WITH_TIMESTAMP_AS_OVERLAY + isPseudoBubble = messageContent.isPseudoBubble(), + timestampAsOverlay = messageContent.timestampAsOverlay() ) } else { buildModernLayout(showInformation) @@ -111,14 +112,23 @@ class TimelineMessageLayoutFactory @Inject constructor(private val session: Sess return messageLayout } + private fun MessageContent?.isPseudoBubble(): Boolean{ + if(this == null) return false + if(msgType == MessageType.MSGTYPE_LOCATION) return vectorPreferences.labsRenderLocationsInTimeline() + return this.msgType in MSG_TYPES_WITH_PSEUDO_BUBBLE_LAYOUT + } + + private fun MessageContent?.timestampAsOverlay(): Boolean{ + if(this == null) return false + if(msgType == MessageType.MSGTYPE_LOCATION) return vectorPreferences.labsRenderLocationsInTimeline() + return this.msgType in MSG_TYPES_WITH_TIMESTAMP_AS_OVERLAY + } + private fun TimelineEvent.shouldBuildBubbleLayout(): Boolean { val type = root.getClearType() if (type in EVENT_TYPES_WITH_BUBBLE_LAYOUT) { val messageContent = getLastMessageContent() - if (messageContent?.msgType in MSG_TYPES_WITHOUT_BUBBLE_LAYOUT) { - return false - } - return true + return messageContent?.msgType !in MSG_TYPES_WITHOUT_BUBBLE_LAYOUT } return false } diff --git a/vector/src/main/res/layout/item_timeline_event_location_stub.xml b/vector/src/main/res/layout/item_timeline_event_location_stub.xml index b2f68b2fc3..134e9e005d 100644 --- a/vector/src/main/res/layout/item_timeline_event_location_stub.xml +++ b/vector/src/main/res/layout/item_timeline_event_location_stub.xml @@ -1,13 +1,14 @@ + android:layout_height="wrap_content">