diff --git a/CHANGES.md b/CHANGES.md
index 863b1ca455..89c1942f39 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -5,7 +5,7 @@ Features ✨:
-
Improvements 🙌:
- -
+ - Render aliases and canonical alias change in the timeline
Other changes:
-
diff --git a/matrix-sdk-android/src/main/res/values/strings_RiotX.xml b/matrix-sdk-android/src/main/res/values/strings_RiotX.xml
index 03bc6d3684..84aa9d9f5c 100644
--- a/matrix-sdk-android/src/main/res/values/strings_RiotX.xml
+++ b/matrix-sdk-android/src/main/res/values/strings_RiotX.xml
@@ -2,6 +2,19 @@
+
+ - %1$s added %2$s as an address for this room.
+ - %1$s added %2$s as addresses for this room.
+
+
+ - %1$s removed %2$s as an address for this room.
+ - %1$s removed %3$s as addresses for this room.
+
-
\ No newline at end of file
+ %1$s added %2$s and removed %3$s as addresses for this room.
+
+ "%1$s set the main address for this room to %2$s."
+ "%1$s removed the main address for this room."
+
+
diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/action/MessageActionsViewModel.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/action/MessageActionsViewModel.kt
index 1303c3aad9..be969fd532 100644
--- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/action/MessageActionsViewModel.kt
+++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/action/MessageActionsViewModel.kt
@@ -187,6 +187,8 @@ class MessageActionsViewModel @AssistedInject constructor(@Assisted
EventType.STATE_ROOM_NAME,
EventType.STATE_ROOM_TOPIC,
EventType.STATE_ROOM_MEMBER,
+ EventType.STATE_ROOM_ALIASES,
+ EventType.STATE_CANONICAL_ALIAS,
EventType.STATE_HISTORY_VISIBILITY,
EventType.CALL_INVITE,
EventType.CALL_HANGUP,
diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/factory/TimelineItemFactory.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/factory/TimelineItemFactory.kt
index 5b6dec9900..1c1155d7b2 100644
--- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/factory/TimelineItemFactory.kt
+++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/factory/TimelineItemFactory.kt
@@ -45,6 +45,8 @@ class TimelineItemFactory @Inject constructor(private val messageItemFactory: Me
EventType.STATE_ROOM_NAME,
EventType.STATE_ROOM_TOPIC,
EventType.STATE_ROOM_MEMBER,
+ EventType.STATE_ROOM_ALIASES,
+ EventType.STATE_CANONICAL_ALIAS,
EventType.STATE_ROOM_JOIN_RULES,
EventType.STATE_HISTORY_VISIBILITY,
EventType.CALL_INVITE,
diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/format/NoticeEventFormatter.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/format/NoticeEventFormatter.kt
index 75100e6c03..2bf861a970 100644
--- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/format/NoticeEventFormatter.kt
+++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/format/NoticeEventFormatter.kt
@@ -37,6 +37,8 @@ class NoticeEventFormatter @Inject constructor(private val sessionHolder: Active
EventType.STATE_ROOM_NAME -> formatRoomNameEvent(timelineEvent.root, timelineEvent.getDisambiguatedDisplayName())
EventType.STATE_ROOM_TOPIC -> formatRoomTopicEvent(timelineEvent.root, timelineEvent.getDisambiguatedDisplayName())
EventType.STATE_ROOM_MEMBER -> formatRoomMemberEvent(timelineEvent.root, timelineEvent.getDisambiguatedDisplayName())
+ EventType.STATE_ROOM_ALIASES -> formatRoomAliasesEvent(timelineEvent.root, timelineEvent.getDisambiguatedDisplayName())
+ EventType.STATE_CANONICAL_ALIAS -> formatRoomCanonicalAliasEvent(timelineEvent.root, timelineEvent.getDisambiguatedDisplayName())
EventType.STATE_HISTORY_VISIBILITY -> formatRoomHistoryVisibilityEvent(timelineEvent.root, timelineEvent.getDisambiguatedDisplayName())
EventType.STATE_ROOM_TOMBSTONE -> formatRoomTombstoneEvent(timelineEvent.getDisambiguatedDisplayName())
EventType.CALL_INVITE,
@@ -136,6 +138,34 @@ class NoticeEventFormatter @Inject constructor(private val sessionHolder: Active
}
}
+ private fun formatRoomAliasesEvent(event: Event, senderName: String?): String? {
+ val eventContent: RoomAliasesContent? = event.getClearContent().toModel()
+ val prevEventContent: RoomAliasesContent? = event.unsignedData?.prevContent?.toModel()
+
+ val addedAliases = eventContent?.aliases.orEmpty() - prevEventContent?.aliases.orEmpty()
+ val removedAliases = prevEventContent?.aliases.orEmpty() - eventContent?.aliases.orEmpty()
+
+ return if (addedAliases.isNotEmpty() && removedAliases.isNotEmpty()) {
+ sp.getString(R.string.notice_room_aliases_added_and_removed, senderName, addedAliases.joinToString(), removedAliases.joinToString())
+ } else if (addedAliases.isNotEmpty()) {
+ sp.getQuantityString(R.plurals.notice_room_aliases_added, addedAliases.size, senderName, addedAliases.joinToString())
+ } else if (removedAliases.isNotEmpty()) {
+ sp.getQuantityString(R.plurals.notice_room_aliases_removed, removedAliases.size, senderName, removedAliases.joinToString())
+ } else {
+ Timber.w("Alias event without any change...")
+ null
+ }
+ }
+
+ private fun formatRoomCanonicalAliasEvent(event: Event, senderName: String?): String? {
+ val eventContent: RoomCanonicalAliasContent? = event.getClearContent().toModel()
+ val canonicalAlias = eventContent?.canonicalAlias
+ return canonicalAlias
+ ?.takeIf { it.isNotBlank() }
+ ?.let { sp.getString(R.string.notice_room_canonical_alias_set, senderName, it) }
+ ?: sp.getString(R.string.notice_room_canonical_alias_unset, senderName)
+ }
+
private fun buildProfileNotice(event: Event, senderName: String?, eventContent: RoomMember?, prevEventContent: RoomMember?): String {
val displayText = StringBuilder()
// Check display name has been changed
diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/helper/MessageInformationDataFactory.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/helper/MessageInformationDataFactory.kt
index 3331fbf774..7ee8486ba2 100644
--- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/helper/MessageInformationDataFactory.kt
+++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/helper/MessageInformationDataFactory.kt
@@ -33,6 +33,7 @@ import me.gujun.android.span.span
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
*/
class MessageInformationDataFactory @Inject constructor(private val session: Session,
diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/helper/TimelineDisplayableEvents.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/helper/TimelineDisplayableEvents.kt
index 1cd851f8c8..4bb0fc27d5 100644
--- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/helper/TimelineDisplayableEvents.kt
+++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/helper/TimelineDisplayableEvents.kt
@@ -27,6 +27,8 @@ object TimelineDisplayableEvents {
EventType.STATE_ROOM_NAME,
EventType.STATE_ROOM_TOPIC,
EventType.STATE_ROOM_MEMBER,
+ EventType.STATE_ROOM_ALIASES,
+ EventType.STATE_CANONICAL_ALIAS,
EventType.STATE_HISTORY_VISIBILITY,
EventType.CALL_INVITE,
EventType.CALL_HANGUP,