Merge pull request #4620 from nextcloud/fix/4557/reactionsBackground

Fix reactions background
This commit is contained in:
Marcel Hibbe 2025-01-17 12:14:41 +00:00 committed by GitHub
commit 779c1627aa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 34 additions and 15 deletions

View File

@ -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
)
}

View File

@ -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
@ -150,6 +150,7 @@ abstract class PreviewMessageViewHolder(itemView: View?, payload: Any?) :
messageText.text = ""
}
itemView.setTag(R.string.replyable_message_view_tag, message.replyable)
val paddingSide = DisplayUtils.convertDpToPixel(HORIZONTAL_REACTION_PADDING, context!!).toInt()
Reaction().showReactions(
message,
::clickOnReaction,
@ -157,8 +158,10 @@ abstract class PreviewMessageViewHolder(itemView: View?, payload: Any?) :
reactionsBinding!!,
messageText.context,
true,
viewThemeUtils!!
viewThemeUtils!!,
hasBubbleBackground(message)
)
reactionsBinding!!.reactionsEmojiWrapper.setPadding(paddingSide, 0, paddingSide, 0)
if (userAvatar != null) {
if (message.isGrouped || message.isOneToOneConversation) {
@ -313,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
@ -332,5 +339,6 @@ abstract class PreviewMessageViewHolder(itemView: View?, payload: Any?) :
const val ACTOR_ID_CHANGELOG = "changelog"
const val KEY_NAME = "name"
const val MIN_IMAGE_HEIGHT = 100F
const val HORIZONTAL_REACTION_PADDING = 8.0F
}
}

View File

@ -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,

View File

@ -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

View File

@ -7,10 +7,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="#dc5047"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#dc5047"
android:pathData="M20,2L8,2c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2L22,4c0,-1.1 -0.9,-2 -2,-2zM11.5,9.5c0,0.83 -0.67,1.5 -1.5,1.5L9,11v1.25c0,0.41 -0.34,0.75 -0.75,0.75s-0.75,-0.34 -0.75,-0.75L7.5,8c0,-0.55 0.45,-1 1,-1L10,7c0.83,0 1.5,0.67 1.5,1.5v1zM16.5,11.5c0,0.83 -0.67,1.5 -1.5,1.5h-2c-0.28,0 -0.5,-0.22 -0.5,-0.5v-5c0,-0.28 0.22,-0.5 0.5,-0.5h2c0.83,0 1.5,0.67 1.5,1.5v3zM20.5,7.75c0,0.41 -0.34,0.75 -0.75,0.75L19,8.5v1h0.75c0.41,0 0.75,0.34 0.75,0.75s-0.34,0.75 -0.75,0.75L19,11v1.25c0,0.41 -0.34,0.75 -0.75,0.75s-0.75,-0.34 -0.75,-0.75L17.5,8c0,-0.55 0.45,-1 1,-1h1.25c0.41,0 0.75,0.34 0.75,0.75zM9,9.5h1v-1L9,8.5v1zM3,6c-0.55,0 -1,0.45 -1,1v13c0,1.1 0.9,2 2,2h13c0.55,0 1,-0.45 1,-1s-0.45,-1 -1,-1L5,20c-0.55,0 -1,-0.45 -1,-1L4,7c0,-0.55 -0.45,-1 -1,-1zM14,11.5h1v-3h-1v3z" />
android:fillColor="#DC5047"
android:fillType="nonZero"
android:pathData="M5.75,15.125L7,15.125L7,12.625L8.25,12.625C8.604,12.625 8.901,12.505 9.141,12.265C9.38,12.026 9.5,11.729 9.5,11.375L9.5,10.125C9.5,9.771 9.38,9.474 9.141,9.234C8.901,8.995 8.604,8.875 8.25,8.875L5.75,8.875L5.75,15.125ZM7,11.375L7,10.125L8.25,10.125L8.25,11.375L7,11.375ZM10.75,15.125L13.25,15.125C13.604,15.125 13.901,15.005 14.141,14.765C14.38,14.526 14.5,14.229 14.5,13.875L14.5,10.125C14.5,9.771 14.38,9.474 14.141,9.234C13.901,8.995 13.604,8.875 13.25,8.875L10.75,8.875L10.75,15.125ZM12,13.875L12,10.125L13.25,10.125L13.25,13.875L12,13.875ZM15.75,15.125L17,15.125L17,12.625L18.25,12.625L18.25,11.375L17,11.375L17,10.125L18.25,10.125L18.25,8.875L15.75,8.875L15.75,15.125ZM4.5,22C3.812,22 3.224,21.755 2.735,21.266C2.245,20.776 2,20.188 2,19.5L2,4.5C2,3.813 2.245,3.224 2.735,2.734C3.224,2.245 3.812,2 4.5,2L19.5,2C20.188,2 20.776,2.245 21.266,2.734C21.755,3.224 22,3.813 22,4.5L22,19.5C22,20.188 21.755,20.776 21.266,21.266C20.776,21.755 20.188,22 19.5,22L4.5,22Z" />
</vector>

View File

@ -19,5 +19,5 @@
android:right="1dp"
android:top="1dp" />
<corners android:radius="15dp" />
<corners android:radius="8dp" />
</shape>

View File

@ -18,6 +18,7 @@
android:id="@+id/reactions_emoji_wrapper"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/standard_half_margin"
android:gravity="center_vertical"
android:orientation="horizontal"/>
android:orientation="horizontal" />
</HorizontalScrollView>

View File

@ -1,7 +1,7 @@
# SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
# SPDX-License-Identifier: GPL-3.0-or-later
build:
maxIssues: 82
maxIssues: 78
weights:
# complexity: 2
# LongParameterList: 1