Adding live location summary data into MessageInformationData

This commit is contained in:
Maxime NATUREL 2022-04-29 16:28:34 +02:00
parent 0b00f97879
commit 90aad44edf
2 changed files with 25 additions and 4 deletions

View File

@ -21,6 +21,7 @@ import im.vector.app.core.date.VectorDateFormatter
import im.vector.app.core.extensions.localDateTime
import im.vector.app.features.home.room.detail.timeline.factory.TimelineItemFactoryParams
import im.vector.app.features.home.room.detail.timeline.item.E2EDecoration
import im.vector.app.features.home.room.detail.timeline.item.LiveLocationShareSummaryData
import im.vector.app.features.home.room.detail.timeline.item.MessageInformationData
import im.vector.app.features.home.room.detail.timeline.item.PollResponseData
import im.vector.app.features.home.room.detail.timeline.item.PollVoteSummaryData
@ -44,8 +45,7 @@ import org.matrix.android.sdk.api.session.room.timeline.hasBeenEdited
import javax.inject.Inject
/**
* TODO Update this comment
* This class compute if data of an event (such has avatar, display name, ...) should be displayed, depending on the previous event in the timeline
* This class is responsible of building extra information data associated to a given event.
*/
class MessageInformationDataFactory @Inject constructor(private val session: Session,
private val dateFormatter: VectorDateFormatter,
@ -119,7 +119,8 @@ class MessageInformationDataFactory @Inject constructor(private val session: Ses
isFirstFromThisSender = isFirstFromThisSender,
isLastFromThisSender = isLastFromThisSender,
e2eDecoration = e2eDecoration,
sendStateDecoration = sendStateDecoration
sendStateDecoration = sendStateDecoration,
liveLocationShareSummaryData = getLiveLocationShareSummaryData(event)
)
}
@ -188,6 +189,16 @@ class MessageInformationDataFactory @Inject constructor(private val session: Ses
}
}
private fun getLiveLocationShareSummaryData(event: TimelineEvent): LiveLocationShareSummaryData? {
return event.annotations?.liveLocationShareAggregatedSummary?.let { summary ->
LiveLocationShareSummaryData(
isActive = summary.isActive,
endOfLiveTimestampAsMilliseconds = summary.endOfLiveTimestampAsMilliseconds,
lastGeoUri = summary.lastLocationDataContent?.getBestLocationInfo()?.geoUri
)
}
}
/**
* Tiles type message never show the sender information (like verification request), so we should repeat it for next message
* even if same sender

View File

@ -20,6 +20,8 @@ import android.os.Parcelable
import im.vector.app.features.home.room.detail.timeline.style.TimelineMessageLayout
import kotlinx.parcelize.Parcelize
import org.matrix.android.sdk.api.session.crypto.verification.VerificationState
import org.matrix.android.sdk.api.session.room.model.message.LocationInfo
import org.matrix.android.sdk.api.session.room.model.message.MessageBeaconLocationDataContent
import org.matrix.android.sdk.api.session.room.send.SendState
import org.matrix.android.sdk.api.util.MatrixItem
@ -42,7 +44,8 @@ data class MessageInformationData(
val e2eDecoration: E2EDecoration = E2EDecoration.NONE,
val sendStateDecoration: SendStateDecoration = SendStateDecoration.NONE,
val isFirstFromThisSender: Boolean = false,
val isLastFromThisSender: Boolean = false
val isLastFromThisSender: Boolean = false,
val liveLocationShareSummaryData: LiveLocationShareSummaryData? = null,
) : Parcelable {
val matrixItem: MatrixItem
@ -98,6 +101,13 @@ data class PollVoteSummaryData(
val percentage: Double = 0.0
) : Parcelable
@Parcelize
data class LiveLocationShareSummaryData(
val isActive: Boolean?,
val endOfLiveTimestampAsMilliseconds: Long?,
val lastGeoUri: String?,
) : Parcelable
enum class E2EDecoration {
NONE,
WARN_IN_CLEAR,