Add method for name fallback when there is only one member

This commit is contained in:
Benoit Marty 2021-04-07 15:19:33 +02:00
parent 15c51cad17
commit 923715aeb3
4 changed files with 11 additions and 1 deletions

View File

@ -26,6 +26,9 @@ class TestRoomDisplayNameFallbackProvider : RoomDisplayNameFallbackProvider {
override fun getNameForEmptyRoom(isDirect: Boolean, leftMemberNames: List<String>) =
"Empty room"
override fun getNameFor1member(name: String) =
name
override fun getNameFor2members(name1: String, name2: String) =
"$name1 and $name2"

View File

@ -19,6 +19,7 @@ package org.matrix.android.sdk.api
interface RoomDisplayNameFallbackProvider {
fun getNameForRoomInvite(): String
fun getNameForEmptyRoom(isDirect: Boolean, leftMemberNames: List<String>): 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

View File

@ -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),

View File

@ -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)
}