Timeline: clean code and update CHANGES

This commit is contained in:
ganfra 2021-03-30 20:04:26 +02:00
parent 5d19cfff13
commit c7c76d1e67
19 changed files with 12 additions and 32 deletions

View File

@ -13,6 +13,7 @@ Improvements 🙌:
- Api interceptor to allow app developers peek responses (#2986)
- Update reactions to Unicode 13.1 (#2998)
- Be more robust when parsing some enums
- Improve timeline filtering (dissociate membership and profile events, display hidden events when highlighted, fix hidden item/read receipts behavior)
Bugfix 🐛:
- Fix bad theme change for the MainActivity
@ -23,7 +24,7 @@ Translations 🗣:
-
SDK API changes ⚠️:
-
- Removes filtering options on Timeline.
Build 🧱:
-

View File

@ -17,7 +17,6 @@
package org.matrix.android.sdk.internal.database.mapper
import org.matrix.android.sdk.api.session.events.model.Event
import org.matrix.android.sdk.api.session.room.model.ReadReceipt
import org.matrix.android.sdk.api.session.room.sender.SenderInfo
import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent
import org.matrix.android.sdk.internal.database.model.TimelineEventEntity

View File

@ -31,7 +31,6 @@ import org.matrix.android.sdk.api.session.room.timeline.TimelineService
import org.matrix.android.sdk.api.session.room.timeline.TimelineSettings
import org.matrix.android.sdk.api.util.Optional
import org.matrix.android.sdk.internal.database.RealmSessionProvider
import org.matrix.android.sdk.internal.database.mapper.ReadReceiptsSummaryMapper
import org.matrix.android.sdk.internal.database.mapper.TimelineEventMapper
import org.matrix.android.sdk.internal.database.model.TimelineEventEntity
import org.matrix.android.sdk.internal.database.model.TimelineEventEntityFields

View File

@ -71,7 +71,6 @@ internal class UIEchoManager(
}
fun onLocalEchoCreated(timelineEvent: TimelineEvent) {
// Manage some ui echos (do it before filter because actual event could be filtered out)
when (timelineEvent.root.getClearType()) {
EventType.REDACTION -> {

View File

@ -48,7 +48,4 @@ class UserPreferencesProvider @Inject constructor(private val vectorPreferences:
fun shouldShowAvatarDisplayNameChanges(): Boolean {
return vectorPreferences.showAvatarDisplayNameChangeMessages()
}
}

View File

@ -20,7 +20,6 @@ import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import im.vector.app.core.platform.DefaultListUpdateCallback
import im.vector.app.features.home.room.detail.timeline.TimelineEventController
import org.matrix.android.sdk.api.session.room.timeline.Timeline
import timber.log.Timber
import java.util.concurrent.atomic.AtomicReference

View File

@ -428,7 +428,7 @@ class TimelineEventController @Inject constructor(private val dateFormatter: Vec
private fun getReadReceiptsByShownEvent(): Map<String, List<ReadReceipt>> {
val receiptsByEvent = HashMap<String, MutableList<ReadReceipt>>()
if(!userPreferencesProvider.shouldShowReadReceipts()){
if (!userPreferencesProvider.shouldShowReadReceipts()) {
return receiptsByEvent
}
var lastShownEventId: String? = null

View File

@ -60,7 +60,7 @@ class TimelineItemFactory @Inject constructor(private val messageItemFactory: Me
EventType.STATE_ROOM_HISTORY_VISIBILITY,
EventType.STATE_ROOM_SERVER_ACL,
EventType.STATE_ROOM_GUEST_ACCESS,
EventType.REDACTION ,
EventType.REDACTION,
EventType.STATE_ROOM_ALIASES,
EventType.KEY_VERIFICATION_ACCEPT,
EventType.KEY_VERIFICATION_START,

View File

@ -23,8 +23,8 @@ data class TimelineItemFactoryParams(
val event: TimelineEvent,
val prevEvent: TimelineEvent? = null,
val nextEvent: TimelineEvent? = null,
val highlightedEventId: String? = null ,
val lastSentEventIdWithoutReadReceipts: String? = null ,
val highlightedEventId: String? = null,
val lastSentEventIdWithoutReadReceipts: String? = null,
val callback: TimelineEventController.Callback? = null
) {

View File

@ -74,7 +74,7 @@ class VerificationItemFactory @Inject constructor(
val referenceInformationData = messageInformationDataFactory.create(TimelineItemFactoryParams(refEvent))
val informationData = messageInformationDataFactory.create(params)
val attributes = messageItemAttributesFactory.create(null, informationData,params.callback)
val attributes = messageItemAttributesFactory.create(null, informationData, params.callback)
when (event.root.getClearType()) {
EventType.KEY_VERIFICATION_CANCEL -> {

View File

@ -16,7 +16,6 @@
package im.vector.app.features.home.room.detail.timeline.helper
import im.vector.app.core.extensions.localDateTime
import org.matrix.android.sdk.api.session.events.model.EventType
import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent
@ -53,7 +52,6 @@ object TimelineDisplayableEvents {
EventType.KEY_VERIFICATION_DONE,
EventType.KEY_VERIFICATION_CANCEL
)
}
fun TimelineEvent.canBeMerged(): Boolean {

View File

@ -29,7 +29,6 @@ import javax.inject.Inject
class TimelineEventVisibilityHelper @Inject constructor(private val userPreferencesProvider: UserPreferencesProvider) {
/**
* @param timelineEvents the events to search in
* @param index the index to start computing (inclusive)
@ -60,7 +59,7 @@ class TimelineEventVisibilityHelper @Inject constructor(private val userPreferen
} else {
nextSameDayEvents.subList(0, indexOfFirstDifferentEventType)
}
val filteredSameTypeEvents = sameTypeEvents.filter { shouldShowEvent(it, eventIdToHighlight)}
val filteredSameTypeEvents = sameTypeEvents.filter { shouldShowEvent(it, eventIdToHighlight) }
if (filteredSameTypeEvents.size < minSize) {
return emptyList()
}
@ -128,12 +127,12 @@ class TimelineEventVisibilityHelper @Inject constructor(private val userPreferen
val content = root.getClearContent().toModel<RoomMemberContent>()
val prevContent = root.resolvedPrevContent().toModel<RoomMemberContent>()
val isMembershipChanged = content?.membership != prevContent?.membership;
val isMembershipChanged = content?.membership != prevContent?.membership
val isJoin = isMembershipChanged && content?.membership == Membership.JOIN
val isPart = isMembershipChanged && content?.membership == Membership.LEAVE && root.stateKey == root.senderId
val isProfileChanged = !isMembershipChanged && content?.membership == Membership.JOIN
val isDisplaynameChange = isProfileChanged && content?.displayName != prevContent?.displayName;
val isDisplaynameChange = isProfileChanged && content?.displayName != prevContent?.displayName
val isAvatarChange = isProfileChanged && content?.avatarUrl !== prevContent?.avatarUrl
return MembershipDiff(

View File

@ -24,7 +24,6 @@ import androidx.annotation.IdRes
import androidx.core.view.isVisible
import im.vector.app.R
import im.vector.app.core.ui.views.ShieldImageView
import im.vector.app.core.utils.DebouncedClickListener
import im.vector.app.features.home.AvatarRenderer
import im.vector.app.features.home.room.detail.timeline.MessageColorProvider
import im.vector.app.features.home.room.detail.timeline.TimelineEventController

View File

@ -26,7 +26,6 @@ import im.vector.app.R
import im.vector.app.core.epoxy.VectorEpoxyHolder
import im.vector.app.core.epoxy.VectorEpoxyModel
import im.vector.app.core.platform.CheckableView
import im.vector.app.core.ui.views.ReadReceiptsView
import im.vector.app.core.utils.DimensionConverter
/**
@ -44,7 +43,6 @@ abstract class BaseEventItem<H : BaseEventItem.BaseHolder> : VectorEpoxyModel<H>
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
lateinit var dimensionConverter: DimensionConverter
@CallSuper
override fun bind(holder: H) {
super.bind(holder)

View File

@ -19,10 +19,8 @@ package im.vector.app.features.home.room.detail.timeline.item
import android.view.View
import android.widget.TextView
import androidx.annotation.IdRes
import androidx.core.view.isVisible
import im.vector.app.R
import im.vector.app.features.home.AvatarRenderer
import im.vector.app.features.home.room.detail.timeline.TimelineEventController
import org.matrix.android.sdk.api.util.MatrixItem
abstract class BasedMergedItem<H : BasedMergedItem.Holder> : BaseEventItem<H>() {

View File

@ -22,9 +22,7 @@ import android.widget.TextView
import com.airbnb.epoxy.EpoxyAttribute
import com.airbnb.epoxy.EpoxyModelClass
import im.vector.app.R
import im.vector.app.core.utils.DebouncedClickListener
import im.vector.app.features.home.AvatarRenderer
import im.vector.app.features.home.room.detail.timeline.TimelineEventController
@EpoxyModelClass(layout = R.layout.item_timeline_event_base_noinfo)
abstract class DefaultItem : BaseEventItem<DefaultItem.Holder>() {
@ -59,7 +57,7 @@ abstract class DefaultItem : BaseEventItem<DefaultItem.Holder>() {
val avatarRenderer: AvatarRenderer,
val informationData: MessageInformationData,
val text: CharSequence,
val itemLongClickListener: View.OnLongClickListener? = null,
val itemLongClickListener: View.OnLongClickListener? = null
)
companion object {

View File

@ -26,5 +26,4 @@ interface ItemWithEvents {
fun canAppendReadMarker(): Boolean = true
fun isVisible(): Boolean = true
}

View File

@ -21,12 +21,10 @@ import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.core.view.children
import androidx.core.view.isVisible
import com.airbnb.epoxy.EpoxyAttribute
import com.airbnb.epoxy.EpoxyModelClass
import im.vector.app.R
import im.vector.app.features.home.AvatarRenderer
import im.vector.app.features.home.room.detail.timeline.TimelineEventController
@EpoxyModelClass(layout = R.layout.item_timeline_event_base_noinfo)
abstract class MergedMembershipEventsItem : BasedMergedItem<MergedMembershipEventsItem.Holder>() {

View File

@ -25,7 +25,6 @@ import im.vector.app.R
import im.vector.app.core.epoxy.ClickListener
import im.vector.app.core.epoxy.onClick
import im.vector.app.core.ui.views.ShieldImageView
import im.vector.app.core.utils.DebouncedClickListener
import im.vector.app.features.home.AvatarRenderer
import im.vector.app.features.home.room.detail.timeline.TimelineEventController
import org.matrix.android.sdk.api.crypto.RoomEncryptionTrustLevel