Skip to content

Commit 779c162

Browse files
authored
Merge pull request #4620 from nextcloud/fix/4557/reactionsBackground
Fix reactions background
2 parents 86db9f7 + 9fcd466 commit 779c162

8 files changed

+34
-15
lines changed

app/src/main/java/com/nextcloud/talk/adapters/messages/OutcomingTextMessageViewHolder.kt

+4-1
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,15 @@ class OutcomingTextMessageViewHolder(itemView: View) :
8989
itemView
9090
)
9191

92+
var isBubbled = true
9293
if (
9394
(message.messageParameters == null || message.messageParameters!!.size <= 0) &&
9495
TextMatchers.isMessageWithSingleEmoticonOnly(message.text)
9596
) {
9697
textSize = (textSize * TEXT_SIZE_MULTIPLIER).toFloat()
9798
layoutParams.isWrapBefore = true
9899
realView.isSelected = true
100+
isBubbled = false
99101
}
100102

101103
setBubbleOnChatMessage(message)
@@ -154,7 +156,8 @@ class OutcomingTextMessageViewHolder(itemView: View) :
154156
binding.reactions,
155157
context,
156158
true,
157-
viewThemeUtils
159+
viewThemeUtils,
160+
isBubbled
158161
)
159162
}
160163

app/src/main/java/com/nextcloud/talk/adapters/messages/PreviewMessageViewHolder.kt

+10-2
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ import com.nextcloud.android.common.ui.theme.utils.ColorRole
2828
import com.nextcloud.talk.R
2929
import com.nextcloud.talk.application.NextcloudTalkApplication
3030
import com.nextcloud.talk.application.NextcloudTalkApplication.Companion.sharedApplication
31+
import com.nextcloud.talk.chat.data.model.ChatMessage
3132
import com.nextcloud.talk.components.filebrowser.models.BrowserFile
3233
import com.nextcloud.talk.components.filebrowser.webdav.ReadFilesystemOperation
3334
import com.nextcloud.talk.data.user.model.User
3435
import com.nextcloud.talk.databinding.ReactionsInsideMessageBinding
3536
import com.nextcloud.talk.extensions.loadChangelogBotAvatar
3637
import com.nextcloud.talk.extensions.loadFederatedUserAvatar
37-
import com.nextcloud.talk.chat.data.model.ChatMessage
3838
import com.nextcloud.talk.ui.theme.ViewThemeUtils
3939
import com.nextcloud.talk.users.UserManager
4040
import com.nextcloud.talk.utils.DateUtils
@@ -150,15 +150,18 @@ abstract class PreviewMessageViewHolder(itemView: View?, payload: Any?) :
150150
messageText.text = ""
151151
}
152152
itemView.setTag(R.string.replyable_message_view_tag, message.replyable)
153+
val paddingSide = DisplayUtils.convertDpToPixel(HORIZONTAL_REACTION_PADDING, context!!).toInt()
153154
Reaction().showReactions(
154155
message,
155156
::clickOnReaction,
156157
::longClickOnReaction,
157158
reactionsBinding!!,
158159
messageText.context,
159160
true,
160-
viewThemeUtils!!
161+
viewThemeUtils!!,
162+
hasBubbleBackground(message)
161163
)
164+
reactionsBinding!!.reactionsEmojiWrapper.setPadding(paddingSide, 0, paddingSide, 0)
162165

163166
if (userAvatar != null) {
164167
if (message.isGrouped || message.isOneToOneConversation) {
@@ -313,6 +316,10 @@ abstract class PreviewMessageViewHolder(itemView: View?, payload: Any?) :
313316
this.previewMessageInterface = previewMessageInterface
314317
}
315318

319+
fun hasBubbleBackground(message: ChatMessage): Boolean {
320+
return !message.isVoiceMessage && message.message != "{file}"
321+
}
322+
316323
abstract val messageText: EmojiTextView
317324
abstract val messageCaption: EmojiTextView
318325
abstract val previewContainer: View
@@ -332,5 +339,6 @@ abstract class PreviewMessageViewHolder(itemView: View?, payload: Any?) :
332339
const val ACTOR_ID_CHANGELOG = "changelog"
333340
const val KEY_NAME = "name"
334341
const val MIN_IMAGE_HEIGHT = 100F
342+
const val HORIZONTAL_REACTION_PADDING = 8.0F
335343
}
336344
}

app/src/main/java/com/nextcloud/talk/adapters/messages/Reaction.kt

+11-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ class Reaction {
2626
binding: ReactionsInsideMessageBinding,
2727
context: Context,
2828
isOutgoingMessage: Boolean,
29-
viewThemeUtils: ViewThemeUtils
29+
viewThemeUtils: ViewThemeUtils,
30+
isBubbled: Boolean = true
3031
) {
3132
binding.reactionsEmojiWrapper.removeAllViews()
3233

@@ -64,7 +65,8 @@ class Reaction {
6465
viewThemeUtils,
6566
isOutgoingMessage,
6667
isSelfReaction
67-
)
68+
),
69+
isBubbled
6870
)
6971

7072
emojiWithAmountWrapper.setOnClickListener {
@@ -86,7 +88,8 @@ class Reaction {
8688
context: Context,
8789
emoji: String,
8890
amount: Int,
89-
layoutInfo: EmojiWithAmountWrapperLayoutInfo
91+
layoutInfo: EmojiWithAmountWrapperLayoutInfo,
92+
isBubbled: Boolean
9093
): LinearLayout {
9194
val emojiWithAmountWrapper = LinearLayout(context)
9295
emojiWithAmountWrapper.orientation = LinearLayout.HORIZONTAL
@@ -96,7 +99,11 @@ class Reaction {
9699
emojiWithAmountWrapper.layoutParams = layoutInfo.wrapperParams
97100

98101
if (layoutInfo.isSelfReaction) {
99-
layoutInfo.viewThemeUtils.talk.setCheckedBackground(emojiWithAmountWrapper, layoutInfo.isOutgoingMessage)
102+
layoutInfo.viewThemeUtils.talk.setCheckedBackground(
103+
emojiWithAmountWrapper,
104+
layoutInfo.isOutgoingMessage,
105+
isBubbled
106+
)
100107

101108
emojiWithAmountWrapper.setPaddingRelative(
102109
layoutInfo.paddingSide,

app/src/main/java/com/nextcloud/talk/ui/theme/TalkSpecificViewThemeUtils.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,12 @@ class TalkSpecificViewThemeUtils @Inject constructor(
168168
}
169169
}
170170

171-
fun setCheckedBackground(linearLayout: LinearLayout, outgoing: Boolean) {
171+
fun setCheckedBackground(linearLayout: LinearLayout, outgoing: Boolean, isBubbled: Boolean) {
172172
withScheme(linearLayout) { scheme ->
173173
val drawable = AppCompatResources
174174
.getDrawable(linearLayout.context, R.drawable.reaction_self_background)!!
175175
.mutate()
176-
val backgroundColor = if (outgoing) {
176+
val backgroundColor = if (outgoing && isBubbled) {
177177
ContextCompat.getColor(
178178
linearLayout.context,
179179
R.color.bg_message_list_incoming_bubble

app/src/main/res/drawable/ic_mimetype_application_pdf.xml

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
<vector xmlns:android="http://schemas.android.com/apk/res/android"
88
android:width="24dp"
99
android:height="24dp"
10-
android:tint="#dc5047"
1110
android:viewportWidth="24"
1211
android:viewportHeight="24">
1312
<path
14-
android:fillColor="#dc5047"
15-
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" />
13+
android:fillColor="#DC5047"
14+
android:fillType="nonZero"
15+
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" />
1616
</vector>

app/src/main/res/drawable/reaction_self_background.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@
1919
android:right="1dp"
2020
android:top="1dp" />
2121

22-
<corners android:radius="15dp" />
22+
<corners android:radius="8dp" />
2323
</shape>

app/src/main/res/layout/reactions_inside_message.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
android:id="@+id/reactions_emoji_wrapper"
1919
android:layout_width="wrap_content"
2020
android:layout_height="wrap_content"
21+
android:layout_marginTop="@dimen/standard_half_margin"
2122
android:gravity="center_vertical"
22-
android:orientation="horizontal"/>
23+
android:orientation="horizontal" />
2324
</HorizontalScrollView>

detekt.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
22
# SPDX-License-Identifier: GPL-3.0-or-later
33
build:
4-
maxIssues: 82
4+
maxIssues: 78
55
weights:
66
# complexity: 2
77
# LongParameterList: 1

0 commit comments

Comments
 (0)