From 11d9579036bbcfe62b160d4c413e4954d3401924 Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Tue, 12 Apr 2022 10:32:06 +0200 Subject: [PATCH] Adding currentUserId attribute --- .../timeline/item/MessageLiveLocationItem.kt | 73 +++++++++++++------ 1 file changed, 50 insertions(+), 23 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageLiveLocationItem.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageLiveLocationItem.kt index 6163ac5463..741866784a 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageLiveLocationItem.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageLiveLocationItem.kt @@ -17,6 +17,7 @@ package im.vector.app.features.home.room.detail.timeline.item import androidx.core.view.isVisible +import com.airbnb.epoxy.EpoxyAttribute import com.airbnb.epoxy.EpoxyModelClass import im.vector.app.R import im.vector.app.core.utils.DimensionConverter @@ -28,6 +29,8 @@ import im.vector.app.features.location.live.LocationLiveMessageBannerViewState abstract class MessageLiveLocationItem : AbsMessageLocationItem() { // TODO define the needed attributes + @EpoxyAttribute + var currentUserId: String? = null override fun bind(holder: Holder) { super.bind(holder) @@ -35,35 +38,59 @@ abstract class MessageLiveLocationItem : AbsMessageLocationItem + LocationLiveMessageBannerViewState.Emitter( + remainingTimeInMillis = 4000 * 1000L, + bottomStartCornerRadiusInDp = messageLayout.cornersRadius.bottomStartRadius, + bottomEndCornerRadiusInDp = messageLayout.cornersRadius.bottomEndRadius, + isStopButtonCenteredVertically = false + ) + messageLayout is TimelineMessageLayout.Bubble -> + LocationLiveMessageBannerViewState.Watcher( + bottomStartCornerRadiusInDp = messageLayout.cornersRadius.bottomStartRadius, + bottomEndCornerRadiusInDp = messageLayout.cornersRadius.bottomEndRadius, + formattedLocalTimeOfEndOfLive = "12:34", + ) + isEmitter -> { + val cornerRadius = getBannerCornerRadiusForDefaultLayout(holder) + LocationLiveMessageBannerViewState.Emitter( + remainingTimeInMillis = 4000 * 1000L, + bottomStartCornerRadiusInDp = cornerRadius, + bottomEndCornerRadiusInDp = cornerRadius, + isStopButtonCenteredVertically = true + ) + } + else -> { + val cornerRadius = getBannerCornerRadiusForDefaultLayout(holder) + LocationLiveMessageBannerViewState.Watcher( + bottomStartCornerRadiusInDp = cornerRadius, + bottomEndCornerRadiusInDp = cornerRadius, + formattedLocalTimeOfEndOfLive = "12:34", + ) + } + } + } + + private fun getBannerCornerRadiusForDefaultLayout(holder: Holder): Float { + val dimensionConverter = DimensionConverter(holder.view.resources) + return dimensionConverter.dpToPx(8).toFloat() + } + class Holder : AbsMessageLocationItem.Holder() { val locationLiveMessageBanner by bind(R.id.locationLiveMessageBanner) }