From a2dac5e0fa9e8a79711fd0b03362060d46076be6 Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Thu, 16 Jan 2025 15:24:09 +0100 Subject: [PATCH] style(reactions): ensure correct color coding of own reaction backgrounds Resolves #4557 Signed-off-by: Andy Scherzinger --- .../messages/OutcomingTextMessageViewHolder.kt | 5 ++++- .../adapters/messages/PreviewMessageViewHolder.kt | 9 +++++++-- .../nextcloud/talk/adapters/messages/Reaction.kt | 15 +++++++++++---- .../talk/ui/theme/TalkSpecificViewThemeUtils.kt | 4 ++-- 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/adapters/messages/OutcomingTextMessageViewHolder.kt b/app/src/main/java/com/nextcloud/talk/adapters/messages/OutcomingTextMessageViewHolder.kt index dfb8b9e2e..907b3cd1d 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/messages/OutcomingTextMessageViewHolder.kt +++ b/app/src/main/java/com/nextcloud/talk/adapters/messages/OutcomingTextMessageViewHolder.kt @@ -89,6 +89,7 @@ class OutcomingTextMessageViewHolder(itemView: View) : itemView ) + var isBubbled = true if ( (message.messageParameters == null || message.messageParameters!!.size <= 0) && TextMatchers.isMessageWithSingleEmoticonOnly(message.text) @@ -96,6 +97,7 @@ class OutcomingTextMessageViewHolder(itemView: View) : textSize = (textSize * TEXT_SIZE_MULTIPLIER).toFloat() layoutParams.isWrapBefore = true realView.isSelected = true + isBubbled = false } setBubbleOnChatMessage(message) @@ -154,7 +156,8 @@ class OutcomingTextMessageViewHolder(itemView: View) : binding.reactions, context, true, - viewThemeUtils + viewThemeUtils, + isBubbled ) } diff --git a/app/src/main/java/com/nextcloud/talk/adapters/messages/PreviewMessageViewHolder.kt b/app/src/main/java/com/nextcloud/talk/adapters/messages/PreviewMessageViewHolder.kt index fd2ddb823..27f10d13b 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/messages/PreviewMessageViewHolder.kt +++ b/app/src/main/java/com/nextcloud/talk/adapters/messages/PreviewMessageViewHolder.kt @@ -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 @@ -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) @@ -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 diff --git a/app/src/main/java/com/nextcloud/talk/adapters/messages/Reaction.kt b/app/src/main/java/com/nextcloud/talk/adapters/messages/Reaction.kt index 801c2220b..d348993e0 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/messages/Reaction.kt +++ b/app/src/main/java/com/nextcloud/talk/adapters/messages/Reaction.kt @@ -26,7 +26,8 @@ class Reaction { binding: ReactionsInsideMessageBinding, context: Context, isOutgoingMessage: Boolean, - viewThemeUtils: ViewThemeUtils + viewThemeUtils: ViewThemeUtils, + isBubbled: Boolean = true ) { binding.reactionsEmojiWrapper.removeAllViews() @@ -64,7 +65,8 @@ class Reaction { viewThemeUtils, isOutgoingMessage, isSelfReaction - ) + ), + isBubbled ) emojiWithAmountWrapper.setOnClickListener { @@ -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 @@ -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, diff --git a/app/src/main/java/com/nextcloud/talk/ui/theme/TalkSpecificViewThemeUtils.kt b/app/src/main/java/com/nextcloud/talk/ui/theme/TalkSpecificViewThemeUtils.kt index 33d9e41e5..073ef7434 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/theme/TalkSpecificViewThemeUtils.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/theme/TalkSpecificViewThemeUtils.kt @@ -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