Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1557,10 +1557,12 @@ public final class io/getstream/chat/android/compose/ui/components/messages/Comp
public final class io/getstream/chat/android/compose/ui/components/messages/ComposableSingletons$QuotedMessageKt {
public static final field INSTANCE Lio/getstream/chat/android/compose/ui/components/messages/ComposableSingletons$QuotedMessageKt;
public fun <init> ()V
public final fun getLambda$-1414494261$stream_chat_android_compose_release ()Lkotlin/jvm/functions/Function2;
public final fun getLambda$-242957275$stream_chat_android_compose_release ()Lkotlin/jvm/functions/Function2;
public final fun getLambda$-615170823$stream_chat_android_compose_release ()Lkotlin/jvm/functions/Function2;
public final fun getLambda$1327756724$stream_chat_android_compose_release ()Lkotlin/jvm/functions/Function2;
public final fun getLambda$1642749758$stream_chat_android_compose_release ()Lkotlin/jvm/functions/Function2;
public final fun getLambda$1769024465$stream_chat_android_compose_release ()Lkotlin/jvm/functions/Function2;
public final fun getLambda$1784593268$stream_chat_android_compose_release ()Lkotlin/jvm/functions/Function2;
public final fun getLambda$976393970$stream_chat_android_compose_release ()Lkotlin/jvm/functions/Function2;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

@file:Suppress("TooManyFunctions")

package io.getstream.chat.android.compose.ui.components.messages

import androidx.annotation.DrawableRes
Expand Down Expand Up @@ -154,10 +156,26 @@ private fun QuotedMessageUserName(
isComposerBanner -> stringResource(R.string.stream_compose_quoted_message_reply_to, message.user.name)
else -> message.user.name
}
val accessibilityName = if (isMine && isComposerBanner) {
stringResource(R.string.stream_compose_quoted_message_reply_to_you)
} else {
null
val accessibilityName = when {
replyMessage == null && isMine ->
stringResource(R.string.stream_compose_quoted_message_reply_to_you)
replyMessage != null -> {
val replierName = if (replyMessage.isMine(currentUser)) {
stringResource(R.string.stream_compose_quoted_message_you)
} else {
replyMessage.user.name
}
if (isMine) {
stringResource(R.string.stream_compose_quoted_message_replied_to_your_message, replierName)
} else {
stringResource(
R.string.stream_compose_quoted_message_replied_to_their_message,
replierName,
message.user.name,
)
}
}
else -> null
}

Text(
Expand Down Expand Up @@ -287,6 +305,18 @@ private fun QuotedMessageInComposerPreview() {
ChatTheme { QuotedMessageInComposer() }
}

@Preview
@Composable
private fun QuotedMessageReplyByMeToOtherPreview() {
ChatTheme { QuotedMessageReplyByMeToOther() }
}

@Preview
@Composable
private fun QuotedMessageReplyByOtherToMePreview() {
ChatTheme { QuotedMessageReplyByOtherToMe() }
}

@Composable
internal fun QuotedMessageFromOtherUser() {
QuotedMessage(
Expand Down Expand Up @@ -374,3 +404,37 @@ internal fun QuotedMessageInComposer() {
onCancelClick = {},
)
}

@Composable
internal fun QuotedMessageReplyByMeToOther() {
QuotedMessage(
message = Message(
id = "msg-7",
text = "Original message from the other user",
user = PreviewUserData.user2,
),
currentUser = PreviewUserData.user1,
replyMessage = Message(
id = "reply-7",
text = "On it.",
user = PreviewUserData.user1,
),
)
}

@Composable
internal fun QuotedMessageReplyByOtherToMe() {
QuotedMessage(
message = Message(
id = "msg-8",
text = "Original message from me",
user = PreviewUserData.user1,
),
currentUser = PreviewUserData.user1,
replyMessage = Message(
id = "reply-8",
text = "Got it, thanks!",
user = PreviewUserData.user2,
),
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import androidx.compose.animation.core.tween
import androidx.compose.foundation.background
import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.gestures.detectHorizontalDragGestures
import androidx.compose.foundation.gestures.detectTapGestures
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
Expand Down Expand Up @@ -62,6 +63,8 @@ import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.onLongClick
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.LayoutDirection
Expand Down Expand Up @@ -177,15 +180,36 @@ public fun MessageContainer(

val openThreadLabel = stringResource(R.string.stream_compose_message_item_open_thread)
val messageOptionsLabel = stringResource(R.string.stream_compose_message_item_options)
val clickModifier = Modifier.combinedClickable(
interactionSource = remember(::MutableInteractionSource),
indication = null,
enabled = canOpenThread || canOpenActions,
onClick = { if (canOpenThread) onThreadClick(message) },
onLongClick = { if (canOpenActions) onLongItemClick(message) },
onClickLabel = openThreadLabel.takeIf { canOpenThread },
onLongClickLabel = messageOptionsLabel.takeIf { canOpenActions },
)
// The pointerInput lambda below is keyed on Unit, so it is launched once and survives
// recomposition. Read the latest message + handler through rememberUpdatedState so the
// long-press fires with the current state (e.g. after a reaction is added) instead of a
// stale capture from first composition.
val currentMessage by rememberUpdatedState(message)
val currentOnLongItemClick by rememberUpdatedState(onLongItemClick)
val clickModifier = when {
canOpenThread -> Modifier.combinedClickable(
interactionSource = remember(::MutableInteractionSource),
indication = null,
onClick = { onThreadClick(message) },
onLongClick = { if (canOpenActions) onLongItemClick(message) },
onClickLabel = openThreadLabel,
onLongClickLabel = messageOptionsLabel.takeIf { canOpenActions },
)
canOpenActions ->
Modifier
.pointerInput(Unit) {
detectTapGestures(
onLongPress = { currentOnLongItemClick(currentMessage) },
)
}
.semantics(mergeDescendants = true) {
onLongClick(label = messageOptionsLabel) {
currentOnLongItemClick(currentMessage)
true
}
}
else -> Modifier.semantics(mergeDescendants = true) {}
}

val highlightColor = ChatTheme.colors.backgroundCoreHighlight
val backgroundColor = when {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@
<string name="stream_compose_quoted_message_audio_recording">"Mensaje de voz (%s)"</string>
<string name="stream_compose_quoted_message_giphy_tag">"Giphy"</string>
<string name="stream_compose_quoted_message_media">"%d multimedia"</string>
<string name="stream_compose_quoted_message_replied_to_their_message">"%1$s respondió al mensaje de %2$s"</string>
<string name="stream_compose_quoted_message_replied_to_your_message">"%1$s respondió a tu mensaje"</string>
<string name="stream_compose_quoted_message_reply_to">"Responder a %s"</string>
<string name="stream_compose_quoted_message_reply_to_you">"Responder a ti"</string>
<string name="stream_compose_quoted_message_you">"Tú"</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@
<string name="stream_compose_quoted_message_audio_recording">"Message vocal (%s)"</string>
<string name="stream_compose_quoted_message_giphy_tag">"Giphy"</string>
<string name="stream_compose_quoted_message_media">"%d média"</string>
<string name="stream_compose_quoted_message_replied_to_their_message">"%1$s a répondu au message de %2$s"</string>
<string name="stream_compose_quoted_message_replied_to_your_message">"%1$s a répondu à votre message"</string>
<string name="stream_compose_quoted_message_reply_to">"Répondre à %s"</string>
<string name="stream_compose_quoted_message_reply_to_you">"Répondre à vous-même"</string>
<string name="stream_compose_quoted_message_you">"Vous"</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@
<string name="stream_compose_quoted_message_audio_recording">"वॉइस मैसेज (%s)"</string>
<string name="stream_compose_quoted_message_giphy_tag">"Giphy"</string>
<string name="stream_compose_quoted_message_media">"%d मीडिया"</string>
<string name="stream_compose_quoted_message_replied_to_their_message">"%1$s ने %2$s के संदेश का जवाब दिया"</string>
<string name="stream_compose_quoted_message_replied_to_your_message">"%1$s ने आपके संदेश का जवाब दिया"</string>
<string name="stream_compose_quoted_message_reply_to">"%s को जवाब"</string>
<string name="stream_compose_quoted_message_reply_to_you">"स्वयं को जवाब"</string>
<string name="stream_compose_quoted_message_you">"आप"</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@
<string name="stream_compose_quoted_message_audio_recording">"Pesan suara (%s)"</string>
<string name="stream_compose_quoted_message_giphy_tag">"Giphy"</string>
<string name="stream_compose_quoted_message_media">"%d media"</string>
<string name="stream_compose_quoted_message_replied_to_their_message">"%1$s membalas pesan %2$s"</string>
<string name="stream_compose_quoted_message_replied_to_your_message">"%1$s membalas pesan Anda"</string>
<string name="stream_compose_quoted_message_reply_to">"Balas ke %s"</string>
<string name="stream_compose_quoted_message_reply_to_you">"Balas ke diri sendiri"</string>
<string name="stream_compose_quoted_message_you">"Anda"</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@
<string name="stream_compose_quoted_message_audio_recording">"Messaggio vocale (%s)"</string>
<string name="stream_compose_quoted_message_giphy_tag">"Giphy"</string>
<string name="stream_compose_quoted_message_media">"%d media"</string>
<string name="stream_compose_quoted_message_replied_to_their_message">"%1$s ha risposto al messaggio di %2$s"</string>
<string name="stream_compose_quoted_message_replied_to_your_message">"%1$s ha risposto al tuo messaggio"</string>
<string name="stream_compose_quoted_message_reply_to">"Rispondi a %s"</string>
<string name="stream_compose_quoted_message_reply_to_you">"Rispondi a te stesso"</string>
<string name="stream_compose_quoted_message_you">"Tu"</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@
<item quantity="other">"%d枚の写真"</item>
</plurals>
<string name="stream_compose_quoted_message_media">"%dメディア"</string>
<string name="stream_compose_quoted_message_replied_to_their_message">"%1$sが%2$sのメッセージに返信しました"</string>
<string name="stream_compose_quoted_message_replied_to_your_message">"%1$sがあなたのメッセージに返信しました"</string>
<string name="stream_compose_quoted_message_reply_to">"%sへの返信"</string>
<string name="stream_compose_quoted_message_reply_to_you">"自分への返信"</string>
<plurals name="stream_compose_quoted_message_videos">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@
<item quantity="other">"%d장의 사진"</item>
</plurals>
<string name="stream_compose_quoted_message_media">"%d 미디어"</string>
<string name="stream_compose_quoted_message_replied_to_their_message">"%1$s님이 %2$s님의 메시지에 답장했습니다"</string>
<string name="stream_compose_quoted_message_replied_to_your_message">"%1$s님이 회원님의 메시지에 답장했습니다"</string>
<string name="stream_compose_quoted_message_reply_to">"%s에게 답장"</string>
<string name="stream_compose_quoted_message_reply_to_you">"자신에게 답장"</string>
<plurals name="stream_compose_quoted_message_videos">
Expand Down
2 changes: 2 additions & 0 deletions stream-chat-android-compose/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@
<string name="stream_compose_quoted_message_media">%d media</string>
<string name="stream_compose_quoted_message_reply_to">Reply to %s</string>
<string name="stream_compose_quoted_message_reply_to_you">Reply to you</string>
<string name="stream_compose_quoted_message_replied_to_your_message">%1$s replied to your message</string>
<string name="stream_compose_quoted_message_replied_to_their_message">%1$s replied to %2$s\'s message</string>
<string name="stream_compose_quoted_message_you">You</string>

<plurals name="stream_compose_quoted_message_files">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,14 @@ internal class QuotedMessageTest : PaparazziComposeTest {
fun `in composer`() {
snapshotWithDarkModeRow { QuotedMessageInComposer() }
}

@Test
fun `reply by me to other`() {
snapshotWithDarkModeRow { QuotedMessageReplyByMeToOther() }
}

@Test
fun `reply by other to me`() {
snapshotWithDarkModeRow { QuotedMessageReplyByOtherToMe() }
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading