Render room avatar change (#1319)

This commit is contained in:
Benoit Marty 2020-07-01 14:52:37 +02:00
parent 53053d8f4a
commit f8e35da533
7 changed files with 29 additions and 0 deletions

View file

@ -13,6 +13,7 @@ Improvements 🙌:
- Update user avatar (#1054)
- Allow self-signed certificate (#1564)
- Improve file download and open in timeline
- Render room avatar change (#1319)
Bugfix 🐛:
- Fix dark theme issue on login screen (#1097)

View file

@ -65,6 +65,7 @@ internal class RoomSummaryUpdater @Inject constructor(
EventType.MESSAGE,
EventType.STATE_ROOM_NAME,
EventType.STATE_ROOM_TOPIC,
EventType.STATE_ROOM_AVATAR,
EventType.STATE_ROOM_MEMBER,
EventType.STATE_ROOM_HISTORY_VISIBILITY,
EventType.CALL_INVITE,

View file

@ -37,6 +37,8 @@
<string name="notice_display_name_removed_by_you">You removed your display name (it was %1$s)</string>
<string name="notice_room_topic_changed">%1$s changed the topic to: %2$s</string>
<string name="notice_room_topic_changed_by_you">You changed the topic to: %1$s</string>
<string name="notice_room_avatar_changed">%1$s changed the room avatar</string>
<string name="notice_room_avatar_changed_by_you">You changed the room avatar</string>
<string name="notice_room_name_changed">%1$s changed the room name to: %2$s</string>
<string name="notice_room_name_changed_by_you">You changed the room name to: %1$s</string>
<string name="notice_placed_video_call">%s placed a video call.</string>
@ -71,6 +73,8 @@
<string name="notice_room_name_removed_by_you">You removed the room name</string>
<string name="notice_room_topic_removed">%1$s removed the room topic</string>
<string name="notice_room_topic_removed_by_you">You removed the room topic</string>
<string name="notice_room_avatar_removed">%1$s removed the room avatar</string>
<string name="notice_room_avatar_removed_by_you">You removed the room avatar</string>
<string name="notice_event_redacted">Message removed</string>
<string name="notice_event_redacted_by">Message removed by %1$s</string>
<string name="notice_event_redacted_with_reason">Message removed [reason: %1$s]</string>

View file

@ -179,6 +179,7 @@ class MessageActionsViewModel @AssistedInject constructor(@Assisted
}
EventType.STATE_ROOM_NAME,
EventType.STATE_ROOM_TOPIC,
EventType.STATE_ROOM_AVATAR,
EventType.STATE_ROOM_MEMBER,
EventType.STATE_ROOM_ALIASES,
EventType.STATE_ROOM_CANONICAL_ALIAS,

View file

@ -48,6 +48,7 @@ class TimelineItemFactory @Inject constructor(private val messageItemFactory: Me
EventType.STATE_ROOM_TOMBSTONE,
EventType.STATE_ROOM_NAME,
EventType.STATE_ROOM_TOPIC,
EventType.STATE_ROOM_AVATAR,
EventType.STATE_ROOM_MEMBER,
EventType.STATE_ROOM_ALIASES,
EventType.STATE_ROOM_CANONICAL_ALIAS,

View file

@ -24,6 +24,7 @@ import im.vector.matrix.android.api.session.room.model.GuestAccess
import im.vector.matrix.android.api.session.room.model.Membership
import im.vector.matrix.android.api.session.room.model.PowerLevelsContent
import im.vector.matrix.android.api.session.room.model.RoomAliasesContent
import im.vector.matrix.android.api.session.room.model.RoomAvatarContent
import im.vector.matrix.android.api.session.room.model.RoomCanonicalAliasContent
import im.vector.matrix.android.api.session.room.model.RoomGuestAccessContent
import im.vector.matrix.android.api.session.room.model.RoomHistoryVisibilityContent
@ -57,6 +58,7 @@ class NoticeEventFormatter @Inject constructor(private val sessionHolder: Active
EventType.STATE_ROOM_CREATE -> formatRoomCreateEvent(timelineEvent.root)
EventType.STATE_ROOM_NAME -> formatRoomNameEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName)
EventType.STATE_ROOM_TOPIC -> formatRoomTopicEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName)
EventType.STATE_ROOM_AVATAR -> formatRoomAvatarEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName)
EventType.STATE_ROOM_MEMBER -> formatRoomMemberEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName)
EventType.STATE_ROOM_ALIASES -> formatRoomAliasesEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName)
EventType.STATE_ROOM_CANONICAL_ALIAS -> formatRoomCanonicalAliasEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName)
@ -149,6 +151,7 @@ class NoticeEventFormatter @Inject constructor(private val sessionHolder: Active
EventType.STATE_ROOM_JOIN_RULES -> formatJoinRulesEvent(event, senderName)
EventType.STATE_ROOM_NAME -> formatRoomNameEvent(event, senderName)
EventType.STATE_ROOM_TOPIC -> formatRoomTopicEvent(event, senderName)
EventType.STATE_ROOM_AVATAR -> formatRoomAvatarEvent(event, senderName)
EventType.STATE_ROOM_MEMBER -> formatRoomMemberEvent(event, senderName)
EventType.STATE_ROOM_HISTORY_VISIBILITY -> formatRoomHistoryVisibilityEvent(event, senderName)
EventType.CALL_INVITE,
@ -220,6 +223,23 @@ class NoticeEventFormatter @Inject constructor(private val sessionHolder: Active
}
}
private fun formatRoomAvatarEvent(event: Event, senderName: String?): CharSequence? {
val content = event.getClearContent().toModel<RoomAvatarContent>() ?: return null
return if (content.avatarUrl.isNullOrEmpty()) {
if (event.isSentByCurrentUser()) {
sp.getString(R.string.notice_room_avatar_removed_by_you)
} else {
sp.getString(R.string.notice_room_avatar_removed, senderName)
}
} else {
if (event.isSentByCurrentUser()) {
sp.getString(R.string.notice_room_avatar_changed_by_you)
} else {
sp.getString(R.string.notice_room_avatar_changed, senderName)
}
}
}
private fun formatRoomHistoryVisibilityEvent(event: Event, senderName: String?): CharSequence? {
val historyVisibility = event.getClearContent().toModel<RoomHistoryVisibilityContent>()?.historyVisibility ?: return null

View file

@ -28,6 +28,7 @@ object TimelineDisplayableEvents {
EventType.STATE_ROOM_WIDGET,
EventType.STATE_ROOM_NAME,
EventType.STATE_ROOM_TOPIC,
EventType.STATE_ROOM_AVATAR,
EventType.STATE_ROOM_MEMBER,
EventType.STATE_ROOM_ALIASES,
EventType.STATE_ROOM_CANONICAL_ALIAS,