Skip to content

Commit

Permalink
style(reactions): ensure correct color coding of own reaction backgro…
Browse files Browse the repository at this point in the history
…unds

Resolves #4557

Signed-off-by: Andy Scherzinger <[email protected]>
  • Loading branch information
AndyScherzinger committed Jan 16, 2025
1 parent 2b3ce94 commit c53262a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,15 @@ class OutcomingTextMessageViewHolder(itemView: View) :
itemView
)

var isBubbled = true
if (
(message.messageParameters == null || message.messageParameters!!.size <= 0) &&
TextMatchers.isMessageWithSingleEmoticonOnly(message.text)
) {
textSize = (textSize * TEXT_SIZE_MULTIPLIER).toFloat()
layoutParams.isWrapBefore = true
realView.isSelected = true
isBubbled = false
}

setBubbleOnChatMessage(message)
Expand Down Expand Up @@ -151,7 +153,8 @@ class OutcomingTextMessageViewHolder(itemView: View) :
binding.reactions,
context,
true,
viewThemeUtils
viewThemeUtils,
isBubbled
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ import com.nextcloud.android.common.ui.theme.utils.ColorRole
import com.nextcloud.talk.R
import com.nextcloud.talk.application.NextcloudTalkApplication
import com.nextcloud.talk.application.NextcloudTalkApplication.Companion.sharedApplication
import com.nextcloud.talk.chat.data.model.ChatMessage
import com.nextcloud.talk.components.filebrowser.models.BrowserFile
import com.nextcloud.talk.components.filebrowser.webdav.ReadFilesystemOperation
import com.nextcloud.talk.data.user.model.User
import com.nextcloud.talk.databinding.ReactionsInsideMessageBinding
import com.nextcloud.talk.extensions.loadChangelogBotAvatar
import com.nextcloud.talk.extensions.loadFederatedUserAvatar
import com.nextcloud.talk.chat.data.model.ChatMessage
import com.nextcloud.talk.ui.theme.ViewThemeUtils
import com.nextcloud.talk.users.UserManager
import com.nextcloud.talk.utils.DateUtils
Expand Down Expand Up @@ -158,7 +158,8 @@ abstract class PreviewMessageViewHolder(itemView: View?, payload: Any?) :
reactionsBinding!!,
messageText.context,
true,
viewThemeUtils!!
viewThemeUtils!!,
hasBubbleBackground(message)
)
reactionsBinding!!.reactionsEmojiWrapper.setPadding(paddingSide,0,paddingSide,0)

Expand Down Expand Up @@ -315,6 +316,10 @@ abstract class PreviewMessageViewHolder(itemView: View?, payload: Any?) :
this.previewMessageInterface = previewMessageInterface
}

fun hasBubbleBackground(message: ChatMessage): Boolean {
return !message.isVoiceMessage && message.message != "{file}";
}

abstract val messageText: EmojiTextView
abstract val messageCaption: EmojiTextView
abstract val previewContainer: View
Expand Down
15 changes: 11 additions & 4 deletions app/src/main/java/com/nextcloud/talk/adapters/messages/Reaction.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ class Reaction {
binding: ReactionsInsideMessageBinding,
context: Context,
isOutgoingMessage: Boolean,
viewThemeUtils: ViewThemeUtils
viewThemeUtils: ViewThemeUtils,
isBubbled: Boolean = true
) {
binding.reactionsEmojiWrapper.removeAllViews()

Expand Down Expand Up @@ -64,7 +65,8 @@ class Reaction {
viewThemeUtils,
isOutgoingMessage,
isSelfReaction
)
),
isBubbled
)

emojiWithAmountWrapper.setOnClickListener {
Expand All @@ -86,7 +88,8 @@ class Reaction {
context: Context,
emoji: String,
amount: Int,
layoutInfo: EmojiWithAmountWrapperLayoutInfo
layoutInfo: EmojiWithAmountWrapperLayoutInfo,
isBubbled: Boolean
): LinearLayout {
val emojiWithAmountWrapper = LinearLayout(context)
emojiWithAmountWrapper.orientation = LinearLayout.HORIZONTAL
Expand All @@ -96,7 +99,11 @@ class Reaction {
emojiWithAmountWrapper.layoutParams = layoutInfo.wrapperParams

if (layoutInfo.isSelfReaction) {
layoutInfo.viewThemeUtils.talk.setCheckedBackground(emojiWithAmountWrapper, layoutInfo.isOutgoingMessage)
layoutInfo.viewThemeUtils.talk.setCheckedBackground(
emojiWithAmountWrapper,
layoutInfo.isOutgoingMessage,
isBubbled
)

emojiWithAmountWrapper.setPaddingRelative(
layoutInfo.paddingSide,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,12 @@ class TalkSpecificViewThemeUtils @Inject constructor(
}
}

fun setCheckedBackground(linearLayout: LinearLayout, outgoing: Boolean) {
fun setCheckedBackground(linearLayout: LinearLayout, outgoing: Boolean, isBubbled: Boolean) {
withScheme(linearLayout) { scheme ->
val drawable = AppCompatResources
.getDrawable(linearLayout.context, R.drawable.reaction_self_background)!!
.mutate()
val backgroundColor = if (outgoing) {
val backgroundColor = if (outgoing && isBubbled) {
ContextCompat.getColor(
linearLayout.context,
R.color.bg_message_list_incoming_bubble
Expand Down

0 comments on commit c53262a

Please sign in to comment.