mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-16 02:05:06 +08:00
Cleanup
This commit is contained in:
parent
dd81fce8d8
commit
f3e52b96c0
@ -64,7 +64,7 @@ class BreadcrumbsController @Inject constructor(
|
||||
unreadNotificationCount(it.notificationCount)
|
||||
showHighlighted(it.highlightCount > 0)
|
||||
hasUnreadMessage(it.hasUnreadMessages)
|
||||
hasTypingUsers(typingHelper.excludeCurrentUser(it.typingRoomMemberIds)?.isNotEmpty() == true)
|
||||
hasTypingUsers(typingHelper.excludeCurrentUser(it.typingRoomMemberIds).isNotEmpty())
|
||||
hasDraft(it.userDrafts.isNotEmpty())
|
||||
itemClickListener(
|
||||
DebouncedClickListener(View.OnClickListener { _ ->
|
||||
|
@ -802,7 +802,7 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
||||
.unwrap()
|
||||
.execute { async ->
|
||||
val typingRoomMembers =
|
||||
typingHelper.toTypingRoomMembers(async.invoke()?.typingRoomMemberIds, room)
|
||||
typingHelper.toTypingRoomMembers(async.invoke()?.typingRoomMemberIds.orEmpty(), room)
|
||||
|
||||
copy(
|
||||
asyncRoomSummary = async,
|
||||
|
@ -126,7 +126,7 @@ class RoomSummaryItemFactory @Inject constructor(private val noticeEventFormatte
|
||||
}
|
||||
}
|
||||
|
||||
val typingString = if (roomSummary.typingRoomMemberIds.isEmpty()) {
|
||||
val typingString = if (typingHelper.excludeCurrentUser(roomSummary.typingRoomMemberIds).isEmpty()) {
|
||||
null
|
||||
} else {
|
||||
// TODO Check how costly it is to create a Room here
|
||||
|
@ -32,37 +32,37 @@ class TypingHelper @Inject constructor(
|
||||
* Exclude current user from the list of typing users
|
||||
*/
|
||||
fun excludeCurrentUser(
|
||||
typingUserIds: List<String>?
|
||||
): List<String>? {
|
||||
typingUserIds: List<String>
|
||||
): List<String> {
|
||||
return typingUserIds
|
||||
?.filter { it != session.myUserId }
|
||||
.filter { it != session.myUserId }
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a list of userId to a list of maximum 3 UserItems
|
||||
*/
|
||||
fun toTypingRoomMembers(
|
||||
typingUserIds: List<String>?,
|
||||
typingUserIds: List<String>,
|
||||
membershipService: MembershipService?
|
||||
): List<MatrixItem.UserItem>? {
|
||||
): List<MatrixItem.UserItem> {
|
||||
return excludeCurrentUser(typingUserIds)
|
||||
?.take(3)
|
||||
?.mapNotNull { membershipService?.getRoomMember(it) }
|
||||
?.map { it.toMatrixItem() }
|
||||
.take(3)
|
||||
.mapNotNull { membershipService?.getRoomMember(it) }
|
||||
.map { it.toMatrixItem() }
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a list of typing UserItems to a human readable String
|
||||
*/
|
||||
fun toTypingMessage(typingUserItems: List<MatrixItem.UserItem>?): String? {
|
||||
fun toTypingMessage(typingUserItems: List<MatrixItem.UserItem>): String? {
|
||||
return when {
|
||||
typingUserItems.isNullOrEmpty() ->
|
||||
typingUserItems.isEmpty() ->
|
||||
null
|
||||
typingUserItems.size == 1 ->
|
||||
typingUserItems.size == 1 ->
|
||||
stringProvider.getString(R.string.room_one_user_is_typing, typingUserItems[0].getBestName())
|
||||
typingUserItems.size == 2 ->
|
||||
typingUserItems.size == 2 ->
|
||||
stringProvider.getString(R.string.room_two_users_are_typing, typingUserItems[0].getBestName(), typingUserItems[1].getBestName())
|
||||
else ->
|
||||
else ->
|
||||
stringProvider.getString(R.string.room_many_users_are_typing, typingUserItems[0].getBestName(), typingUserItems[1].getBestName())
|
||||
}
|
||||
}
|
||||
|
@ -59,7 +59,7 @@
|
||||
android:layout_height="20dp"
|
||||
android:background="@drawable/bg_breadcrumbs_typing"
|
||||
android:gravity="center"
|
||||
android:text="…"
|
||||
android:text="@string/ellipsis"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="11sp"
|
||||
android:textStyle="bold"
|
||||
@ -67,7 +67,7 @@
|
||||
app:layout_constraintCircle="@+id/breadcrumbsImageView"
|
||||
app:layout_constraintCircleAngle="135"
|
||||
app:layout_constraintCircleRadius="28dp"
|
||||
tools:ignore="HardcodedText,MissingConstraints"
|
||||
tools:ignore="MissingConstraints"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<ImageView
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
<string name="debug_screen" translatable="false">Debug screen</string>
|
||||
|
||||
<string name="ellipsis" translatable="false">…</string>
|
||||
<string name="plus_sign" translatable="false">+</string>
|
||||
<string name="semicolon_sign" translatable="false">:</string>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user