Change highlight color on received messages

This commit is contained in:
Matéo Duparc 2021-06-18 15:17:11 +02:00
parent 0d3848360b
commit 38b322ebc5
Signed by: hardcoresushi
GPG Key ID: 007F84120107191E
2 changed files with 16 additions and 7 deletions

View File

@ -92,9 +92,12 @@ class ChatAdapter(
}
internal open class MessageViewHolder(itemView: View): BubbleViewHolder(itemView) {
protected fun bindMessage(chatItem: ChatItem): TextView {
protected fun bindMessage(chatItem: ChatItem, outgoing: Boolean): TextView {
itemView.findViewById<TextView>(R.id.text_message).apply {
text = chatItem.data.sliceArray(1 until chatItem.data.size).decodeToString()
if (!outgoing) {
highlightColor = ContextCompat.getColor(context, R.color.incomingHighlight)
}
return this
}
}
@ -106,7 +109,7 @@ class ChatAdapter(
setTextColor(ContextCompat.getColor(context, R.color.outgoingTimestamp))
}
configureBubble(context, true)
bindMessage(chatItem).apply {
bindMessage(chatItem, true).apply {
setLinkTextColor(ContextCompat.getColor(context, R.color.outgoingTextLink))
}
configureContainer(true, previousOutgoing)
@ -119,7 +122,7 @@ class ChatAdapter(
setTextColor(ContextCompat.getColor(context, R.color.incomingTimestamp))
}
configureBubble(context, false)
bindMessage(chatItem).apply {
bindMessage(chatItem, false).apply {
setLinkTextColor(ContextCompat.getColor(context, R.color.incomingTextLink))
}
configureContainer(false, previousOutgoing)
@ -127,9 +130,14 @@ class ChatAdapter(
}
internal open class FileViewHolder(itemView: View, private val onSavingFile: (filename: String, rawUuid: ByteArray) -> Unit): BubbleViewHolder(itemView) {
protected fun bindFile(chatItem: ChatItem) {
protected fun bindFile(chatItem: ChatItem, outgoing: Boolean) {
val filename = chatItem.data.sliceArray(17 until chatItem.data.size).decodeToString()
itemView.findViewById<TextView>(R.id.text_filename).text = filename
itemView.findViewById<TextView>(R.id.text_filename).apply {
text = filename
if (!outgoing) {
highlightColor = ContextCompat.getColor(context, R.color.incomingHighlight)
}
}
itemView.findViewById<ImageButton>(R.id.button_save).setOnClickListener {
onSavingFile(filename, chatItem.data.sliceArray(1 until 17))
}
@ -141,7 +149,7 @@ class ChatAdapter(
setTimestamp(chatItem).apply {
setTextColor(ContextCompat.getColor(context, R.color.outgoingTimestamp))
}
bindFile(chatItem)
bindFile(chatItem, true)
configureBubble(context, true)
configureContainer(true, previousOutgoing)
}
@ -152,7 +160,7 @@ class ChatAdapter(
setTimestamp(chatItem).apply {
setTextColor(ContextCompat.getColor(context, R.color.incomingTimestamp))
}
bindFile(chatItem)
bindFile(chatItem, false)
configureBubble(context, false)
configureContainer(false, previousOutgoing)
}

View File

@ -14,4 +14,5 @@
<color name="sessionArrow">#777777</color>
<color name="outgoingTimestamp">#777777</color>
<color name="incomingTimestamp">#d7d7d7</color>
<color name="incomingHighlight">@color/outgoingTextLink</color>
</resources>