From 87b12b7e1188800baa1bde26dab56b0418b5898e Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Fri, 7 May 2021 16:41:30 +0200 Subject: [PATCH] Add the public icon on the rooms in the room list (#3292) --- CHANGES.md | 1 + .../sdk/api/session/room/model/RoomSummary.kt | 3 +++ .../home/room/list/RoomSummaryItem.kt | 3 +++ .../home/room/list/RoomSummaryItemFactory.kt | 1 + .../main/res/drawable/background_circle.xml | 7 +++++++ .../src/main/res/drawable/ic_public_room.xml | 20 +++++++++---------- vector/src/main/res/layout/item_room.xml | 19 +++++++++++++++++- vector/src/main/res/values/strings.xml | 1 + 8 files changed, 43 insertions(+), 12 deletions(-) create mode 100644 vector/src/main/res/drawable/background_circle.xml diff --git a/CHANGES.md b/CHANGES.md index b3f9615c70..fedc77833a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -11,6 +11,7 @@ Improvements 🙌: - Improve file too big error detection (#3245) - User can now select video when selecting Gallery to send attachments to a room - Add option to record a video from the camera + - Add the public icon on the rooms in the room list (#3292) Bugfix 🐛: - Message states cosmetic changes (#3007) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/RoomSummary.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/RoomSummary.kt index e06d70d4f9..cae4775e71 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/RoomSummary.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/RoomSummary.kt @@ -75,6 +75,9 @@ data class RoomSummary( val isFavorite: Boolean get() = hasTag(RoomTag.ROOM_TAG_FAVOURITE) + val isPublic: Boolean + get() = joinRules == RoomJoinRules.PUBLIC + fun hasTag(tag: String) = tags.any { it.name == tag } val canStartCall: Boolean diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItem.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItem.kt index 06f55d3952..d099ac16b7 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItem.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItem.kt @@ -50,6 +50,7 @@ abstract class RoomSummaryItem : VectorEpoxyModel() { @EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) lateinit var lastFormattedEvent: CharSequence @EpoxyAttribute lateinit var lastEventTime: CharSequence @EpoxyAttribute var encryptionTrustLevel: RoomEncryptionTrustLevel? = null + @EpoxyAttribute var izPublic: Boolean = false @EpoxyAttribute var unreadNotificationCount: Int = 0 @EpoxyAttribute var hasUnreadMessage: Boolean = false @EpoxyAttribute var hasDraft: Boolean = false @@ -74,6 +75,7 @@ abstract class RoomSummaryItem : VectorEpoxyModel() { holder.draftView.isVisible = hasDraft avatarRenderer.render(matrixItem, holder.avatarImageView) holder.roomAvatarDecorationImageView.render(encryptionTrustLevel) + holder.roomAvatarPublicDecorationImageView.isVisible = izPublic holder.roomAvatarFailSendingImageView.isVisible = hasFailedSending renderSelection(holder, showSelected) holder.typingView.setTextOrHide(typingMessage) @@ -110,6 +112,7 @@ abstract class RoomSummaryItem : VectorEpoxyModel() { val avatarCheckedImageView by bind(R.id.roomAvatarCheckedImageView) val avatarImageView by bind(R.id.roomAvatarImageView) val roomAvatarDecorationImageView by bind(R.id.roomAvatarDecorationImageView) + val roomAvatarPublicDecorationImageView by bind(R.id.roomAvatarPublicDecorationImageView) val roomAvatarFailSendingImageView by bind(R.id.roomAvatarFailSendingImageView) val rootView by bind(R.id.itemRoomLayout) } diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItemFactory.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItemFactory.kt index 283ed0ac85..e4826af04c 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItemFactory.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItemFactory.kt @@ -112,6 +112,7 @@ class RoomSummaryItemFactory @Inject constructor(private val displayableEventFor .avatarRenderer(avatarRenderer) // We do not display shield in the room list anymore // .encryptionTrustLevel(roomSummary.roomEncryptionTrustLevel) + .izPublic(roomSummary.isPublic) .matrixItem(roomSummary.toMatrixItem()) .lastEventTime(latestEventTime) .typingMessage(typingMessage) diff --git a/vector/src/main/res/drawable/background_circle.xml b/vector/src/main/res/drawable/background_circle.xml new file mode 100644 index 0000000000..5e20ad45ce --- /dev/null +++ b/vector/src/main/res/drawable/background_circle.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/vector/src/main/res/drawable/ic_public_room.xml b/vector/src/main/res/drawable/ic_public_room.xml index 1520898831..d6602cc59c 100644 --- a/vector/src/main/res/drawable/ic_public_room.xml +++ b/vector/src/main/res/drawable/ic_public_room.xml @@ -1,13 +1,11 @@ - - + android:width="21dp" + android:height="20dp" + android:viewportWidth="21" + android:viewportHeight="20"> + + diff --git a/vector/src/main/res/layout/item_room.xml b/vector/src/main/res/layout/item_room.xml index 4e20d270cd..bd5aff6a5b 100644 --- a/vector/src/main/res/layout/item_room.xml +++ b/vector/src/main/res/layout/item_room.xml @@ -60,6 +60,7 @@ app:layout_constraintCircleRadius="30dp" tools:ignore="MissingConstraints" /> + + tools:ignore="MissingConstraints" + tools:visibility="gone" /> + + Notify without sound Do not notify View read receipts + This room is public Dev Tools Explore Room State