From 0a04ff9aa60f584e27fc6bcb6d6a54fa354c1dd6 Mon Sep 17 00:00:00 2001 From: Maxime Naturel Date: Wed, 16 Feb 2022 13:46:06 +0100 Subject: [PATCH 1/5] Adding changelog entry --- changelog.d/2782.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/2782.misc diff --git a/changelog.d/2782.misc b/changelog.d/2782.misc new file mode 100644 index 0000000000..6c340219d5 --- /dev/null +++ b/changelog.d/2782.misc @@ -0,0 +1 @@ +Collapse ACL events From 4641153df0f1a82851526f7aeec86e6de3d3a5b6 Mon Sep 17 00:00:00 2001 From: Maxime Naturel Date: Wed, 16 Feb 2022 16:01:31 +0100 Subject: [PATCH 2/5] Making ACL multiple successive events as collapsable --- .../factory/MergedHeaderItemFactory.kt | 49 +++++++++++-------- .../helper/TimelineDisplayableEvents.kt | 3 +- ...entsItem.kt => DefaultMergedEventsItem.kt} | 6 ++- vector/src/main/res/values/strings.xml | 4 ++ 4 files changed, 39 insertions(+), 23 deletions(-) rename vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/{MergedMembershipEventsItem.kt => DefaultMergedEventsItem.kt} (91%) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/MergedHeaderItemFactory.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/MergedHeaderItemFactory.kt index 99a026a0cf..bf7e93982e 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/MergedHeaderItemFactory.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/MergedHeaderItemFactory.kt @@ -16,6 +16,7 @@ package im.vector.app.features.home.room.detail.timeline.factory +import im.vector.app.R import im.vector.app.core.di.ActiveSessionHolder import im.vector.app.core.extensions.prevOrNull import im.vector.app.features.home.AvatarRenderer @@ -26,8 +27,8 @@ import im.vector.app.features.home.room.detail.timeline.helper.TimelineEventVisi import im.vector.app.features.home.room.detail.timeline.helper.canBeMerged import im.vector.app.features.home.room.detail.timeline.helper.isRoomConfiguration import im.vector.app.features.home.room.detail.timeline.item.BasedMergedItem -import im.vector.app.features.home.room.detail.timeline.item.MergedMembershipEventsItem -import im.vector.app.features.home.room.detail.timeline.item.MergedMembershipEventsItem_ +import im.vector.app.features.home.room.detail.timeline.item.DefaultMergedEventsItem +import im.vector.app.features.home.room.detail.timeline.item.DefaultMergedEventsItem_ import im.vector.app.features.home.room.detail.timeline.item.MergedRoomCreationItem import im.vector.app.features.home.room.detail.timeline.item.MergedRoomCreationItem_ import im.vector.app.features.home.room.detail.timeline.tools.createLinkMovementMethod @@ -82,7 +83,7 @@ class MergedHeaderItemFactory @Inject constructor(private val activeSessionHolde event: TimelineEvent, eventIdToHighlight: String?, requestModelBuild: () -> Unit, - callback: TimelineEventController.Callback?): MergedMembershipEventsItem_? { + callback: TimelineEventController.Callback?): DefaultMergedEventsItem_? { val mergedEvents = timelineEventVisibilityHelper.prevSameTypeEvents( items, currentPosition, @@ -122,23 +123,31 @@ class MergedHeaderItemFactory @Inject constructor(private val activeSessionHolde collapsedEventIds.removeAll(mergedEventIds) } val mergeId = mergedEventIds.joinToString(separator = "_") { it.toString() } - val attributes = MergedMembershipEventsItem.Attributes( - isCollapsed = isCollapsed, - mergeData = mergedData, - avatarRenderer = avatarRenderer, - onCollapsedStateChanged = { - mergeItemCollapseStates[event.localId] = it - requestModelBuild() - } - ) - MergedMembershipEventsItem_() - .id(mergeId) - .leftGuideline(avatarSizeProvider.leftGuideline) - .highlighted(isCollapsed && highlighted) - .attributes(attributes) - .also { - it.setOnVisibilityStateChanged(MergedTimelineEventVisibilityStateChangedListener(callback, mergedEvents)) - } + val summaryTitleResId = when(event.root.getClearType()) { + EventType.STATE_ROOM_MEMBER -> R.plurals.membership_changes + EventType.STATE_ROOM_SERVER_ACL -> R.plurals.notice_room_server_acl_changes + else -> null + } + summaryTitleResId?.let { summaryTitle -> + val attributes = DefaultMergedEventsItem.Attributes( + summaryTitleResId = summaryTitle, + isCollapsed = isCollapsed, + mergeData = mergedData, + avatarRenderer = avatarRenderer, + onCollapsedStateChanged = { + mergeItemCollapseStates[event.localId] = it + requestModelBuild() + } + ) + DefaultMergedEventsItem_() + .id(mergeId) + .leftGuideline(avatarSizeProvider.leftGuideline) + .highlighted(isCollapsed && highlighted) + .attributes(attributes) + .also { + it.setOnVisibilityStateChanged(MergedTimelineEventVisibilityStateChangedListener(callback, mergedEvents)) + } + } } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/TimelineDisplayableEvents.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/TimelineDisplayableEvents.kt index bcccbc9f7c..53a9fbbaea 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/TimelineDisplayableEvents.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/TimelineDisplayableEvents.kt @@ -56,7 +56,8 @@ object TimelineDisplayableEvents { } fun TimelineEvent.canBeMerged(): Boolean { - return root.getClearType() == EventType.STATE_ROOM_MEMBER + return root.getClearType() == EventType.STATE_ROOM_MEMBER || + root.getClearType() == EventType.STATE_ROOM_SERVER_ACL } fun TimelineEvent.isRoomConfiguration(roomCreatorUserId: String?): Boolean { diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MergedMembershipEventsItem.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/DefaultMergedEventsItem.kt similarity index 91% rename from vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MergedMembershipEventsItem.kt rename to vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/DefaultMergedEventsItem.kt index e19dc33fff..65675efca9 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MergedMembershipEventsItem.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/DefaultMergedEventsItem.kt @@ -20,6 +20,7 @@ import android.view.View import android.view.ViewGroup import android.widget.ImageView import android.widget.TextView +import androidx.annotation.PluralsRes import androidx.core.view.children import com.airbnb.epoxy.EpoxyAttribute import com.airbnb.epoxy.EpoxyModelClass @@ -27,7 +28,7 @@ import im.vector.app.R import im.vector.app.features.home.AvatarRenderer @EpoxyModelClass(layout = R.layout.item_timeline_event_base_noinfo) -abstract class MergedMembershipEventsItem : BasedMergedItem() { +abstract class DefaultMergedEventsItem : BasedMergedItem() { override fun getViewStubId() = STUB_ID @@ -37,7 +38,7 @@ abstract class MergedMembershipEventsItem : BasedMergedItem, override val avatarRenderer: AvatarRenderer, diff --git a/vector/src/main/res/values/strings.xml b/vector/src/main/res/values/strings.xml index c155b6bb75..7387688dfe 100644 --- a/vector/src/main/res/values/strings.xml +++ b/vector/src/main/res/values/strings.xml @@ -81,6 +81,10 @@ %s changed the server ACLs for this room. You changed the server ACLs for this room. + + %d server ACLs change + %d server ACLs changes + • Servers matching %s are now banned. • Servers matching %s were removed from the ban list. • Servers matching %s are now allowed. From bc45c0ce509f764f9844c37e78b6df6310e5ae37 Mon Sep 17 00:00:00 2001 From: Maxime Naturel Date: Wed, 16 Feb 2022 16:09:10 +0100 Subject: [PATCH 3/5] Fix code formatting --- .../room/detail/timeline/factory/MergedHeaderItemFactory.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/MergedHeaderItemFactory.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/MergedHeaderItemFactory.kt index bf7e93982e..0b8c2eb572 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/MergedHeaderItemFactory.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/MergedHeaderItemFactory.kt @@ -123,10 +123,10 @@ class MergedHeaderItemFactory @Inject constructor(private val activeSessionHolde collapsedEventIds.removeAll(mergedEventIds) } val mergeId = mergedEventIds.joinToString(separator = "_") { it.toString() } - val summaryTitleResId = when(event.root.getClearType()) { - EventType.STATE_ROOM_MEMBER -> R.plurals.membership_changes + val summaryTitleResId = when (event.root.getClearType()) { + EventType.STATE_ROOM_MEMBER -> R.plurals.membership_changes EventType.STATE_ROOM_SERVER_ACL -> R.plurals.notice_room_server_acl_changes - else -> null + else -> null } summaryTitleResId?.let { summaryTitle -> val attributes = DefaultMergedEventsItem.Attributes( From 41bd516ca9144ee7dfb6cf86dd15b829fca868cf Mon Sep 17 00:00:00 2001 From: Maxime Naturel Date: Thu, 17 Feb 2022 14:50:12 +0100 Subject: [PATCH 4/5] Updating changelog entry --- changelog.d/2782.misc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.d/2782.misc b/changelog.d/2782.misc index 6c340219d5..dc20050369 100644 --- a/changelog.d/2782.misc +++ b/changelog.d/2782.misc @@ -1 +1 @@ -Collapse ACL events +Collapse successive ACLs events in room timeline From bdfe5639ee3a5b829a14a18a4958207a8be4d890 Mon Sep 17 00:00:00 2001 From: Maxime Naturel Date: Fri, 18 Feb 2022 09:53:09 +0100 Subject: [PATCH 5/5] Renaming merged event item class --- .../detail/timeline/factory/MergedHeaderItemFactory.kt | 10 +++++----- ...tMergedEventsItem.kt => MergedSimilarEventsItem.kt} | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) rename vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/{DefaultMergedEventsItem.kt => MergedSimilarEventsItem.kt} (96%) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/MergedHeaderItemFactory.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/MergedHeaderItemFactory.kt index 0b8c2eb572..76ed024370 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/MergedHeaderItemFactory.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/MergedHeaderItemFactory.kt @@ -27,10 +27,10 @@ import im.vector.app.features.home.room.detail.timeline.helper.TimelineEventVisi import im.vector.app.features.home.room.detail.timeline.helper.canBeMerged import im.vector.app.features.home.room.detail.timeline.helper.isRoomConfiguration import im.vector.app.features.home.room.detail.timeline.item.BasedMergedItem -import im.vector.app.features.home.room.detail.timeline.item.DefaultMergedEventsItem -import im.vector.app.features.home.room.detail.timeline.item.DefaultMergedEventsItem_ import im.vector.app.features.home.room.detail.timeline.item.MergedRoomCreationItem import im.vector.app.features.home.room.detail.timeline.item.MergedRoomCreationItem_ +import im.vector.app.features.home.room.detail.timeline.item.MergedSimilarEventsItem +import im.vector.app.features.home.room.detail.timeline.item.MergedSimilarEventsItem_ import im.vector.app.features.home.room.detail.timeline.tools.createLinkMovementMethod import org.matrix.android.sdk.api.extensions.orFalse import org.matrix.android.sdk.api.query.QueryStringValue @@ -83,7 +83,7 @@ class MergedHeaderItemFactory @Inject constructor(private val activeSessionHolde event: TimelineEvent, eventIdToHighlight: String?, requestModelBuild: () -> Unit, - callback: TimelineEventController.Callback?): DefaultMergedEventsItem_? { + callback: TimelineEventController.Callback?): MergedSimilarEventsItem_? { val mergedEvents = timelineEventVisibilityHelper.prevSameTypeEvents( items, currentPosition, @@ -129,7 +129,7 @@ class MergedHeaderItemFactory @Inject constructor(private val activeSessionHolde else -> null } summaryTitleResId?.let { summaryTitle -> - val attributes = DefaultMergedEventsItem.Attributes( + val attributes = MergedSimilarEventsItem.Attributes( summaryTitleResId = summaryTitle, isCollapsed = isCollapsed, mergeData = mergedData, @@ -139,7 +139,7 @@ class MergedHeaderItemFactory @Inject constructor(private val activeSessionHolde requestModelBuild() } ) - DefaultMergedEventsItem_() + MergedSimilarEventsItem_() .id(mergeId) .leftGuideline(avatarSizeProvider.leftGuideline) .highlighted(isCollapsed && highlighted) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/DefaultMergedEventsItem.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MergedSimilarEventsItem.kt similarity index 96% rename from vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/DefaultMergedEventsItem.kt rename to vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MergedSimilarEventsItem.kt index 65675efca9..f012ca6cdc 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/DefaultMergedEventsItem.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MergedSimilarEventsItem.kt @@ -28,7 +28,7 @@ import im.vector.app.R import im.vector.app.features.home.AvatarRenderer @EpoxyModelClass(layout = R.layout.item_timeline_event_base_noinfo) -abstract class DefaultMergedEventsItem : BasedMergedItem() { +abstract class MergedSimilarEventsItem : BasedMergedItem() { override fun getViewStubId() = STUB_ID