Timeline : fix minor UI issues

This commit is contained in:
ganfra 2019-01-16 10:41:32 +01:00
parent 06dd3760c5
commit cb05d10824
4 changed files with 18 additions and 10 deletions

View File

@ -4,10 +4,11 @@ import android.text.SpannableStringBuilder
import android.text.util.Linkify
import im.vector.matrix.android.api.permalinks.MatrixLinkify
import im.vector.matrix.android.api.permalinks.MatrixPermalinkSpan
import im.vector.matrix.android.api.session.events.model.EventType
import im.vector.matrix.android.api.session.events.model.TimelineEvent
import im.vector.matrix.android.api.session.events.model.toModel
import im.vector.matrix.android.api.session.room.model.MessageContent
import org.threeten.bp.LocalDateTime
import im.vector.riotredesign.core.extensions.localDateTime
class MessageItemFactory(private val timelineDateFormatter: TimelineDateFormatter) {
@ -15,8 +16,6 @@ class MessageItemFactory(private val timelineDateFormatter: TimelineDateFormatte
fun create(event: TimelineEvent,
nextEvent: TimelineEvent?,
addDaySeparator: Boolean,
date: LocalDateTime,
callback: TimelineEventController.Callback?
): MessageItem? {
@ -26,7 +25,17 @@ class MessageItemFactory(private val timelineDateFormatter: TimelineDateFormatte
return null
}
val nextRoomMember = nextEvent?.roomMember
if (addDaySeparator || nextRoomMember != roomMember) {
val date = event.root.localDateTime()
val nextDate = nextEvent?.root?.localDateTime()
val addDaySeparator = date.toLocalDate() != nextDate?.toLocalDate()
val isNextMessageReceivedMoreThanOneHourAgo = nextDate?.isBefore(date.minusMinutes(60))
?: false
if (addDaySeparator
|| nextRoomMember != roomMember
|| nextEvent.root.type != EventType.MESSAGE
|| isNextMessageReceivedMoreThanOneHourAgo) {
messagesDisplayedWithInformation.add(event.root.eventId)
}

View File

@ -49,7 +49,7 @@ class TimelineEventController(private val roomId: String,
val nextDate = nextEvent?.root?.localDateTime()
val addDaySeparator = date.toLocalDate() != nextDate?.toLocalDate()
timelineItemFactory.create(event, nextEvent, addDaySeparator, date, callback)?.also {
timelineItemFactory.create(event, nextEvent, callback)?.also {
it.id(event.localId)
epoxyModels.add(it)
}

View File

@ -3,7 +3,6 @@ package im.vector.riotredesign.features.home.room.detail.timeline
import com.airbnb.epoxy.EpoxyModel
import im.vector.matrix.android.api.session.events.model.EventType
import im.vector.matrix.android.api.session.events.model.TimelineEvent
import org.threeten.bp.LocalDateTime
class TimelineItemFactory(private val messageItemFactory: MessageItemFactory,
private val roomNameItemFactory: RoomNameItemFactory,
@ -13,12 +12,10 @@ class TimelineItemFactory(private val messageItemFactory: MessageItemFactory,
fun create(event: TimelineEvent,
nextEvent: TimelineEvent?,
addDaySeparator: Boolean,
date: LocalDateTime,
callback: TimelineEventController.Callback?): EpoxyModel<*>? {
return when (event.root.type) {
EventType.MESSAGE -> messageItemFactory.create(event, nextEvent, addDaySeparator, date, callback)
EventType.MESSAGE -> messageItemFactory.create(event, nextEvent, callback)
EventType.STATE_ROOM_NAME -> roomNameItemFactory.create(event)
EventType.STATE_ROOM_TOPIC -> roomTopicItemFactory.create(event)
EventType.STATE_ROOM_MEMBER -> roomMemberItemFactory.create(event)

View File

@ -4,7 +4,9 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:paddingLeft="16dp"
android:paddingRight="16dp">
<ImageView
android:id="@+id/itemNoticeAvatarView"