Add method for name fallback when there is only one member
This commit is contained in:
parent
15c51cad17
commit
923715aeb3
|
@ -26,6 +26,9 @@ class TestRoomDisplayNameFallbackProvider : RoomDisplayNameFallbackProvider {
|
||||||
override fun getNameForEmptyRoom(isDirect: Boolean, leftMemberNames: List<String>) =
|
override fun getNameForEmptyRoom(isDirect: Boolean, leftMemberNames: List<String>) =
|
||||||
"Empty room"
|
"Empty room"
|
||||||
|
|
||||||
|
override fun getNameFor1member(name: String) =
|
||||||
|
name
|
||||||
|
|
||||||
override fun getNameFor2members(name1: String, name2: String) =
|
override fun getNameFor2members(name1: String, name2: String) =
|
||||||
"$name1 and $name2"
|
"$name1 and $name2"
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ package org.matrix.android.sdk.api
|
||||||
interface RoomDisplayNameFallbackProvider {
|
interface RoomDisplayNameFallbackProvider {
|
||||||
fun getNameForRoomInvite(): String
|
fun getNameForRoomInvite(): String
|
||||||
fun getNameForEmptyRoom(isDirect: Boolean, leftMemberNames: List<String>): String
|
fun getNameForEmptyRoom(isDirect: Boolean, leftMemberNames: List<String>): String
|
||||||
|
fun getNameFor1member(name: String): String
|
||||||
fun getNameFor2members(name1: String, name2: String): String
|
fun getNameFor2members(name1: String, name2: String): String
|
||||||
fun getNameFor3members(name1: String, name2: String, name3: String): String
|
fun getNameFor3members(name1: String, name2: String, name3: String): String
|
||||||
fun getNameFor4members(name1: String, name2: String, name3: String, name4: String): String
|
fun getNameFor4members(name1: String, name2: String, name3: String, name4: String): String
|
||||||
|
|
|
@ -112,7 +112,11 @@ internal class RoomDisplayNameResolver @Inject constructor(
|
||||||
.map { it.getBestName() }
|
.map { it.getBestName() }
|
||||||
roomDisplayNameFallbackProvider.getNameForEmptyRoom(roomSummary?.isDirect.orFalse(), leftMembersNames)
|
roomDisplayNameFallbackProvider.getNameForEmptyRoom(roomSummary?.isDirect.orFalse(), leftMembersNames)
|
||||||
}
|
}
|
||||||
1 -> resolveRoomMemberName(otherMembersSubset[0], roomMembers)
|
1 -> {
|
||||||
|
roomDisplayNameFallbackProvider.getNameFor1member(
|
||||||
|
resolveRoomMemberName(otherMembersSubset[0], roomMembers)
|
||||||
|
)
|
||||||
|
}
|
||||||
2 -> {
|
2 -> {
|
||||||
roomDisplayNameFallbackProvider.getNameFor2members(
|
roomDisplayNameFallbackProvider.getNameFor2members(
|
||||||
resolveRoomMemberName(otherMembersSubset[0], roomMembers),
|
resolveRoomMemberName(otherMembersSubset[0], roomMembers),
|
||||||
|
|
|
@ -36,6 +36,8 @@ class VectorRoomDisplayNameFallbackProvider(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun getNameFor1member(name: String) = name
|
||||||
|
|
||||||
override fun getNameFor2members(name1: String, name2: String): String {
|
override fun getNameFor2members(name1: String, name2: String): String {
|
||||||
return context.getString(R.string.room_displayname_two_members, name1, name2)
|
return context.getString(R.string.room_displayname_two_members, name1, name2)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue