diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/RoomAvatarResolver.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/RoomAvatarResolver.kt
index 58633c39ba..99f9d3644d 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/RoomAvatarResolver.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/RoomAvatarResolver.kt
@@ -26,6 +26,8 @@ import org.matrix.android.sdk.internal.database.query.getOrNull
import org.matrix.android.sdk.internal.di.UserId
import org.matrix.android.sdk.internal.session.room.membership.RoomMemberHelper
import io.realm.Realm
+import org.matrix.android.sdk.internal.database.model.RoomSummaryEntity
+import org.matrix.android.sdk.internal.database.query.where
import javax.inject.Inject
internal class RoomAvatarResolver @Inject constructor(@UserId private val userId: String) {
@@ -46,7 +48,8 @@ internal class RoomAvatarResolver @Inject constructor(@UserId private val userId
val roomMembers = RoomMemberHelper(realm, roomId)
val members = roomMembers.queryActiveRoomMembersEvent().findAll()
// detect if it is a room with no more than 2 members (i.e. an alone or a 1:1 chat)
- if (roomMembers.isDirectRoom()) {
+ val isDirectRoom = RoomSummaryEntity.where(realm, roomId).findFirst()?.isDirect ?: false
+ if (isDirectRoom) {
if (members.size == 1) {
res = members.firstOrNull()?.avatarUrl
} else if (members.size == 2) {
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 73ae66a5b2..8d0789d675 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
@@ -116,17 +116,35 @@ internal class RoomDisplayNameResolver @Inject constructor(
// TODO (was xx and yyy) ...
}
1 -> resolveRoomMemberName(otherMembersSubset[0], roomMembers)
+ 2 -> {
+ stringProvider.getString(R.string.room_displayname_two_members,
+ resolveRoomMemberName(otherMembersSubset[0], roomMembers),
+ resolveRoomMemberName(otherMembersSubset[1], roomMembers)
+ )
+ }
+ 3 -> {
+ stringProvider.getString(R.string.room_displayname_3_members,
+ resolveRoomMemberName(otherMembersSubset[0], roomMembers),
+ resolveRoomMemberName(otherMembersSubset[1], roomMembers),
+ resolveRoomMemberName(otherMembersSubset[2], roomMembers)
+ )
+ }
+ 4 -> {
+ stringProvider.getString(R.string.room_displayname_4_members,
+ resolveRoomMemberName(otherMembersSubset[0], roomMembers),
+ resolveRoomMemberName(otherMembersSubset[1], roomMembers),
+ resolveRoomMemberName(otherMembersSubset[2], roomMembers),
+ resolveRoomMemberName(otherMembersSubset[3], roomMembers)
+ )
+ }
else -> {
- val names = otherMembersSubset.map {
- resolveRoomMemberName(it, roomMembers) ?: ""
- }
- if (otherMembersCount <= othersTotalCount) {
- val remainingCount = invitedCount + joinedCount - names.size
- (names.joinToString("${stringProvider.getString(R.string.room_displayname_separator)} ")
- + " " + stringProvider.getQuantityString(R.plurals.and_n_others, remainingCount, remainingCount))
- } else {
- names.dropLast(1).joinToString(", ") + " & ${names.last()}"
- }
+ val remainingCount = invitedCount + joinedCount - otherMembersCount + 1
+ stringProvider.getString(R.string.room_displayname_four_and_more_members,
+ resolveRoomMemberName(otherMembersSubset[0], roomMembers),
+ resolveRoomMemberName(otherMembersSubset[1], roomMembers),
+ resolveRoomMemberName(otherMembersSubset[2], roomMembers),
+ remainingCount
+ )
}
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/RoomMemberHelper.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/RoomMemberHelper.kt
index c18eb0936b..2a7c46bd42 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/RoomMemberHelper.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/RoomMemberHelper.kt
@@ -16,6 +16,8 @@
package org.matrix.android.sdk.internal.session.room.membership
+import io.realm.Realm
+import io.realm.RealmQuery
import org.matrix.android.sdk.api.session.events.model.EventType
import org.matrix.android.sdk.api.session.room.model.Membership
import org.matrix.android.sdk.internal.database.model.CurrentStateEventEntity
@@ -25,8 +27,6 @@ import org.matrix.android.sdk.internal.database.model.RoomMemberSummaryEntityFie
import org.matrix.android.sdk.internal.database.model.RoomSummaryEntity
import org.matrix.android.sdk.internal.database.query.getOrNull
import org.matrix.android.sdk.internal.database.query.where
-import io.realm.Realm
-import io.realm.RealmQuery
/**
* This class is an helper around STATE_ROOM_MEMBER events.
@@ -98,10 +98,6 @@ internal class RoomMemberHelper(private val realm: Realm,
return getNumberOfJoinedMembers() + getNumberOfInvitedMembers()
}
- fun isDirectRoom() : Boolean {
- return roomSummary?.isDirect ?: false
- }
-
/**
* Return all the roomMembers ids which are joined or invited to the room
*
diff --git a/matrix-sdk-android/src/main/res/values/strings.xml b/matrix-sdk-android/src/main/res/values/strings.xml
index c391a4edc8..130ad5570c 100644
--- a/matrix-sdk-android/src/main/res/values/strings.xml
+++ b/matrix-sdk-android/src/main/res/values/strings.xml
@@ -175,16 +175,14 @@
%1$s and %2$s
+ %1$s, %2$s and %3$s
+ %1$s, %2$s, %3$s and %4$s
+ %1$s, %2$s, %3$s and %4$d others
- %1$s and 1 other
- %1$s and %2$d others
-
- - & %d other
- - & %d others
-
- ,
Empty room
Empty room (was %s)
diff --git a/vector/src/main/java/im/vector/app/features/roommemberprofile/RoomMemberProfileController.kt b/vector/src/main/java/im/vector/app/features/roommemberprofile/RoomMemberProfileController.kt
index 44e726735f..2e91091443 100644
--- a/vector/src/main/java/im/vector/app/features/roommemberprofile/RoomMemberProfileController.kt
+++ b/vector/src/main/java/im/vector/app/features/roommemberprofile/RoomMemberProfileController.kt
@@ -161,7 +161,7 @@ class RoomMemberProfileController @Inject constructor(
} else {
genericFooterItem {
id("verify_footer_not_encrypted")
- text(RRstringProvider.getString(R.string.room_profile_not_encrypted_subtitle))
+ text(stringProvider.getString(R.string.room_profile_not_encrypted_subtitle))
centered(false)
}
}