diff --git a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/common/TestRoomDisplayNameFallbackProvider.kt b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/common/TestRoomDisplayNameFallbackProvider.kt index 3f440a7d7b..af2d57f9ce 100644 --- a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/common/TestRoomDisplayNameFallbackProvider.kt +++ b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/common/TestRoomDisplayNameFallbackProvider.kt @@ -26,6 +26,9 @@ class TestRoomDisplayNameFallbackProvider : RoomDisplayNameFallbackProvider { override fun getNameForEmptyRoom(isDirect: Boolean, leftMemberNames: List) = "Empty room" + override fun getNameFor1member(name: String) = + name + override fun getNameFor2members(name1: String, name2: String) = "$name1 and $name2" diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/RoomDisplayNameFallbackProvider.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/RoomDisplayNameFallbackProvider.kt index 6028bc837d..a34dbcc196 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/RoomDisplayNameFallbackProvider.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/RoomDisplayNameFallbackProvider.kt @@ -19,6 +19,7 @@ package org.matrix.android.sdk.api interface RoomDisplayNameFallbackProvider { fun getNameForRoomInvite(): String fun getNameForEmptyRoom(isDirect: Boolean, leftMemberNames: List): String + fun getNameFor1member(name: String): String fun getNameFor2members(name1: String, name2: String): String fun getNameFor3members(name1: String, name2: String, name3: String): String fun getNameFor4members(name1: String, name2: String, name3: String, name4: String): String diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/RoomDisplayNameResolver.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/RoomDisplayNameResolver.kt index 219ef694a4..3aa812d93d 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/RoomDisplayNameResolver.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/RoomDisplayNameResolver.kt @@ -112,7 +112,11 @@ internal class RoomDisplayNameResolver @Inject constructor( .map { it.getBestName() } roomDisplayNameFallbackProvider.getNameForEmptyRoom(roomSummary?.isDirect.orFalse(), leftMembersNames) } - 1 -> resolveRoomMemberName(otherMembersSubset[0], roomMembers) + 1 -> { + roomDisplayNameFallbackProvider.getNameFor1member( + resolveRoomMemberName(otherMembersSubset[0], roomMembers) + ) + } 2 -> { roomDisplayNameFallbackProvider.getNameFor2members( resolveRoomMemberName(otherMembersSubset[0], roomMembers), diff --git a/vector/src/main/java/im/vector/app/features/room/VectorRoomDisplayNameFallbackProvider.kt b/vector/src/main/java/im/vector/app/features/room/VectorRoomDisplayNameFallbackProvider.kt index 57257dd597..a5f1ff58d6 100644 --- a/vector/src/main/java/im/vector/app/features/room/VectorRoomDisplayNameFallbackProvider.kt +++ b/vector/src/main/java/im/vector/app/features/room/VectorRoomDisplayNameFallbackProvider.kt @@ -36,6 +36,8 @@ class VectorRoomDisplayNameFallbackProvider( } } + override fun getNameFor1member(name: String) = name + override fun getNameFor2members(name1: String, name2: String): String { return context.getString(R.string.room_displayname_two_members, name1, name2) }