Add background to group sender name in CIV2.

This commit is contained in:
Alex Hart 2023-09-18 10:07:02 -04:00
parent 3a601e1e65
commit 1c55ad21a3

View file

@ -51,6 +51,7 @@ import org.thoughtcrime.securesms.util.ThemeUtil
import org.thoughtcrime.securesms.util.VibrateUtil
import org.thoughtcrime.securesms.util.adapter.mapping.MappingModel
import org.thoughtcrime.securesms.util.hasExtraText
import org.thoughtcrime.securesms.util.hasNoBubble
import org.thoughtcrime.securesms.util.isScheduled
import org.thoughtcrime.securesms.util.visible
import java.util.Locale
@ -100,6 +101,7 @@ open class V2ConversationItemTextOnlyViewHolder<Model : MappingModel<Model>>(
private val bodyBubbleDrawable = ChatColorsDrawable()
private val footerDrawable = ChatColorsDrawable()
private val senderDrawable = ChatColorsDrawable()
private val bodyBubbleLayoutTransition = BodyBubbleLayoutTransition()
protected lateinit var shape: V2ConversationItemShape.MessageShape
@ -220,6 +222,7 @@ open class V2ConversationItemTextOnlyViewHolder<Model : MappingModel<Model>>(
presentAlert()
presentSender()
presentSenderNameColor()
presentSenderNameBackground()
presentReactions()
bodyBubbleDrawable.setChatColors(
@ -481,6 +484,23 @@ open class V2ConversationItemTextOnlyViewHolder<Model : MappingModel<Model>>(
}
}
private fun presentSenderNameBackground() {
if (binding.senderName == null || !shape.isStartingShape || !conversationMessage.threadRecipient.isGroup || !conversationMessage.messageRecord.hasNoBubble(context)) {
return
}
if (conversationContext.hasWallpaper()) {
senderDrawable.setChatColors(
ChatColors.forColor(ChatColors.Id.BuiltIn, themeDelegate.getFooterBubbleColor(conversationMessage)),
footerCorners
)
binding.senderName.background = senderDrawable
} else {
binding.senderName.background = null
}
}
private fun presentSender() {
if (binding.senderName == null || binding.senderPhoto == null || binding.senderBadge == null) {
return