Commit 0e4b3810 authored by Filipe de Lima Brito's avatar Filipe de Lima Brito

Shows mentions with @ symbol

parent 92832192
...@@ -9,9 +9,7 @@ import chat.rocket.android.core.lifecycle.CancelStrategy ...@@ -9,9 +9,7 @@ import chat.rocket.android.core.lifecycle.CancelStrategy
import chat.rocket.android.dagger.scope.PerFragment import chat.rocket.android.dagger.scope.PerFragment
import chat.rocket.android.db.ChatRoomDao import chat.rocket.android.db.ChatRoomDao
import chat.rocket.android.db.DatabaseManager import chat.rocket.android.db.DatabaseManager
import chat.rocket.android.db.DatabaseManagerFactory
import chat.rocket.android.db.UserDao import chat.rocket.android.db.UserDao
import chat.rocket.android.server.domain.GetCurrentServerInteractor
import chat.rocket.android.server.domain.GetCurrentUserInteractor import chat.rocket.android.server.domain.GetCurrentUserInteractor
import chat.rocket.android.server.domain.PermissionsInteractor import chat.rocket.android.server.domain.PermissionsInteractor
import chat.rocket.android.server.domain.SettingsRepository import chat.rocket.android.server.domain.SettingsRepository
......
...@@ -126,8 +126,8 @@ class RoomUiModelMapper( ...@@ -126,8 +126,8 @@ class RoomUiModelMapper(
} else { } else {
null null
} }
val hasMentions = mapMentions(userMentions, groupMentions)
val open = open val open = open
val lastMessageMarkdown = val lastMessageMarkdown =
lastMessage?.let { Markwon.markdown(context, it.toString()).toString() } lastMessage?.let { Markwon.markdown(context, it.toString()).toString() }
...@@ -139,6 +139,7 @@ class RoomUiModelMapper( ...@@ -139,6 +139,7 @@ class RoomUiModelMapper(
open = open, open = open,
date = timestamp, date = timestamp,
unread = unread, unread = unread,
mentions = hasMentions,
alert = isUnread, alert = isUnread,
lastMessage = lastMessageMarkdown, lastMessage = lastMessageMarkdown,
status = status, status = status,
...@@ -203,5 +204,14 @@ class RoomUiModelMapper( ...@@ -203,5 +204,14 @@ class RoomUiModelMapper(
} }
} }
private fun mapMentions(userMentions: Long?, groupMentions: Long?): Boolean {
if (userMentions != null && groupMentions != null) {
if (userMentions > 0 || groupMentions > 0) {
return true
}
}
return false
}
private fun mapDate(date: Long?): CharSequence? = date?.localDateTime()?.date(context) private fun mapDate(date: Long?): CharSequence? = date?.localDateTime()?.date(context)
} }
...@@ -49,29 +49,19 @@ class RoomViewHolder(itemView: View, private val listener: (RoomUiModel) -> Unit ...@@ -49,29 +49,19 @@ class RoomViewHolder(itemView: View, private val listener: (RoomUiModel) -> Unit
text_timestamp.isInvisible = true text_timestamp.isInvisible = true
} }
if (room.unread != null) { if (room.alert) {
text_total_unread_messages.text = room.unread if (room.unread == null) text_total_unread_messages.text = "!"
if (room.unread != null) text_total_unread_messages.text = room.unread
if (room.mentions) text_total_unread_messages.text = "@${room.unread}"
text_timestamp.setTextAppearance(context, R.style.ChatList_Timestamp_Unread_TextView)
text_last_message.setTextAppearance(context, R.style.ChatList_LastMessage_Unread_TextView)
text_total_unread_messages.isVisible = true text_total_unread_messages.isVisible = true
} else { } else {
text_timestamp.setTextAppearance(context, R.style.ChatList_Timestamp_TextView)
text_last_message.setTextAppearance(context, R.style.ChatList_LastMessage_TextView)
text_total_unread_messages.isInvisible = true text_total_unread_messages.isInvisible = true
} }
context?.let {
if (room.alert || room.unread != null) {
text_timestamp.setTextAppearance(it, R.style.ChatList_Timestamp_Unread_TextView)
text_last_message.setTextAppearance(
it,
R.style.ChatList_LastMessage_Unread_TextView
)
text_total_unread_messages.text = "!"
text_total_unread_messages.isVisible = true
} else {
text_timestamp.setTextAppearance(it, R.style.ChatList_Timestamp_TextView)
text_last_message.setTextAppearance(it, R.style.ChatList_LastMessage_TextView)
text_total_unread_messages.isInvisible = true
}
}
setOnClickListener { listener(room) } setOnClickListener { listener(room) }
} }
} }
......
...@@ -12,6 +12,7 @@ data class RoomUiModel( ...@@ -12,6 +12,7 @@ data class RoomUiModel(
val date: CharSequence? = null, val date: CharSequence? = null,
val unread: String? = null, val unread: String? = null,
val alert: Boolean = false, val alert: Boolean = false,
val mentions: Boolean = false,
val lastMessage: CharSequence? = null, val lastMessage: CharSequence? = null,
val status: UserStatus? = null, val status: UserStatus? = null,
val username: String? = null, val username: String? = null,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment