Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix reactions background #4620

Merged
merged 7 commits into from
Jan 17, 2025
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,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 @@ -154,7 +156,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 @@ -150,15 +150,18 @@ 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,
::longClickOnReaction,
reactionsBinding!!,
messageText.context,
true,
viewThemeUtils!!
viewThemeUtils!!,
hasBubbleBackground(message)
)
reactionsBinding!!.reactionsEmojiWrapper.setPadding(paddingSide, 0, paddingSide, 0)

if (userAvatar != null) {
if (message.isGrouped || message.isOneToOneConversation) {
Expand Down Expand Up @@ -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
Expand All @@ -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
}
}
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
2 changes: 1 addition & 1 deletion app/src/main/res/drawable/reaction_self_background.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@
android:right="1dp"
android:top="1dp" />

<corners android:radius="15dp" />
<corners android:radius="8dp" />
</shape>
3 changes: 2 additions & 1 deletion app/src/main/res/layout/reactions_inside_message.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
2 changes: 1 addition & 1 deletion detekt.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Loading