mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-01-04 14:02:23 +01:00
Bubbles: handle location sharing (need updates)
This commit is contained in:
parent
b79a5fd4f4
commit
35674ad401
@ -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<MessageLocationItem.Holder>(
|
||||
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<MessageLocationItem.Holder>(
|
||||
override fun getViewStubId() = STUB_ID
|
||||
|
||||
class Holder : AbsMessageItem.Holder(STUB_ID) {
|
||||
val mapCardView by bind<MaterialCardView>(R.id.mapCardView)
|
||||
val mapViewContainer by bind<ConstraintLayout>(R.id.mapViewContainer)
|
||||
val mapView by bind<MapTilerMapView>(R.id.mapView)
|
||||
val clickableMapArea by bind<FrameLayout>(R.id.clickableMapArea)
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -1,13 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/mapCardView"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:cardCornerRadius="8dp">
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/mapViewContainer"
|
||||
android:minWidth="@dimen/chat_bubble_fixed_size"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user