mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-08-19 20:58:11 +01:00
Add reply treatment to media-send module.
This commit is contained in:
committed by
Greyson Parrelli
parent
017f5d62e2
commit
5da86f03fd
+16
-2
@@ -69,6 +69,7 @@ fun AddAMessageRow(
|
||||
canScheduleSend: Boolean = false,
|
||||
viewOnceAvailable: Boolean = false,
|
||||
viewOnce: Boolean = false,
|
||||
isReply: Boolean = false,
|
||||
recipientChatColor: Color? = null
|
||||
) {
|
||||
Row(
|
||||
@@ -87,7 +88,7 @@ fun AddAMessageRow(
|
||||
// A view-once send cannot carry a body, so the row becomes a static label rather than an entry point.
|
||||
Modifier
|
||||
} else {
|
||||
Modifier.clickable(enabled = enabled, onClickLabel = stringResource(R.string.AddAMessageRow__add_a_message), onClick = { onEvent(MediaEditScreenEvents.AddMessageClick()) }, role = Role.Button)
|
||||
Modifier.clickable(enabled = enabled, onClickLabel = stringResource(if (isReply) R.string.AddAMessageRow__add_a_reply else R.string.AddAMessageRow__add_a_message), onClick = { onEvent(MediaEditScreenEvents.AddMessageClick()) }, role = Role.Button)
|
||||
}
|
||||
)
|
||||
) {
|
||||
@@ -113,7 +114,7 @@ fun AddAMessageRow(
|
||||
}
|
||||
|
||||
LocalAddAMessageRowTextField.current(
|
||||
message?.takeIf { it.isNotBlank() } ?: stringResource(R.string.AddAMessageRow__message),
|
||||
message?.takeIf { it.isNotBlank() } ?: stringResource(if (isReply) R.string.AddAMessageRow__add_a_reply else R.string.AddAMessageRow__message),
|
||||
Modifier
|
||||
.weight(1f)
|
||||
.padding(end = if (viewOnceAvailable) 0.dp else 16.dp)
|
||||
@@ -204,6 +205,19 @@ private fun AddAMessageRowViewOncePreview() {
|
||||
}
|
||||
}
|
||||
|
||||
@DayNightPreviews
|
||||
@Composable
|
||||
private fun AddAMessageRowReplyPreview() {
|
||||
Previews.Preview {
|
||||
AddAMessageRow(
|
||||
message = null,
|
||||
onEvent = {},
|
||||
onNextClick = {},
|
||||
isReply = true
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@DayNightPreviews
|
||||
@Composable
|
||||
private fun AddAMessageRowKnownRecipientPreview() {
|
||||
|
||||
@@ -370,6 +370,7 @@ internal fun MediaEditScreen(
|
||||
canScheduleSend = !state.isStory,
|
||||
viewOnceAvailable = state.isViewOnceAvailable,
|
||||
viewOnce = state.isViewOnceEnabled,
|
||||
isReply = state.isReply,
|
||||
message = state.message,
|
||||
recipientChatColor = recipientChatColor,
|
||||
onEvent = onEvent,
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
<string name="MediaSendDialogs__add_to_story">Add to story</string>
|
||||
<!-- Accessibility label for the row that lets the user add a text message to accompany the media being sent. -->
|
||||
<string name="AddAMessageRow__add_a_message">Add a message</string>
|
||||
<!-- Label and accessibility label used in place of \"Add a message\" when the media is being sent as a reply to another message. -->
|
||||
<string name="AddAMessageRow__add_a_reply">Add a reply</string>
|
||||
<!-- Accessibility description for the button that opens the emoji keyboard. -->
|
||||
<string name="AddAMessageRow__open_emoji_keyboard">Open emoji keyboard</string>
|
||||
<!-- Placeholder text shown in the add-a-message row before the user has entered any message text. -->
|
||||
|
||||
+17
-2
@@ -89,14 +89,29 @@ class AddAMessageRowTest {
|
||||
composeTestRule.onNodeWithText("Check this out").assertExists()
|
||||
}
|
||||
|
||||
private fun setContent(canScheduleSend: Boolean = false, message: CharSequence? = null) {
|
||||
@Test
|
||||
fun `Given a reply flow with no message, when the row is displayed, then the reply placeholder is shown`() {
|
||||
setContent(isReply = true)
|
||||
|
||||
composeTestRule.onNodeWithText("Add a reply").assertExists()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Given a reply flow with a message, when the row is displayed, then the message is shown`() {
|
||||
setContent(message = "Check this out", isReply = true)
|
||||
|
||||
composeTestRule.onNodeWithText("Check this out").assertExists()
|
||||
}
|
||||
|
||||
private fun setContent(canScheduleSend: Boolean = false, message: CharSequence? = null, isReply: Boolean = false) {
|
||||
composeTestRule.setContent {
|
||||
SignalTheme {
|
||||
AddAMessageRow(
|
||||
message = message,
|
||||
onEvent = { events += it },
|
||||
onNextClick = { nextClicks++ },
|
||||
canScheduleSend = canScheduleSend
|
||||
canScheduleSend = canScheduleSend,
|
||||
isReply = isReply
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user