Skip to content

Commit d2cd803

Browse files
VelikovPetarclaude
andauthored
Split hold-to-record hint text based on audioRecordingSendOnComplete (#6345)
Co-authored-by: Claude <noreply@anthropic.com>
1 parent 77a4a20 commit d2cd803

9 files changed

Lines changed: 27 additions & 13 deletions

File tree

stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/messages/composer/internal/AudioRecordingButton.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,14 @@ private class RecordingHintState(
449449
private fun rememberRecordingHint(): RecordingHintState {
450450
val snackbarHostState = remember { SnackbarHostState() }
451451
val scope = rememberCoroutineScope()
452-
val message = stringResource(R.string.stream_compose_audio_recording_hint)
452+
val sendOnComplete = ChatTheme.config.composer.audioRecordingSendOnComplete
453+
val message = stringResource(
454+
if (sendOnComplete) {
455+
R.string.stream_compose_audio_recording_hint_send
456+
} else {
457+
R.string.stream_compose_audio_recording_hint_save
458+
},
459+
)
453460
return remember(snackbarHostState, scope, message) {
454461
RecordingHintState(snackbarHostState, scope, message)
455462
}

stream-chat-android-compose/src/main/res/values/strings.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,8 @@
200200

201201
<!-- Audio Recording -->
202202
<string name="stream_compose_audio_recording_start">Record audio message</string>
203-
<string name="stream_compose_audio_recording_hint">Hold to record. Release to send.</string>
203+
<string name="stream_compose_audio_recording_hint_send">Hold to record. Release to send.</string>
204+
<string name="stream_compose_audio_recording_hint_save">Hold to record. Release to save.</string>
204205
<string name="stream_compose_audio_recording_slide_to_cancel">Slide to cancel</string>
205206
<string name="stream_compose_audio_recording_delete">Delete recording</string>
206207
<string name="stream_compose_audio_recording_stop">Stop recording</string>

stream-chat-android-docs/src/main/kotlin/io/getstream/chat/docs/kotlin/ui/guides/AddingRecordingSupport.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class AddingRecordingSupport {
1919
fun customizeUiInMessageComposer(context: Context) {
2020
TransformStyle.messageComposerStyleTransformer = StyleTransformer { defaultStyle ->
2121
defaultStyle.copy(
22-
audioRecordingHoldToRecordText = context.getString(R.string.stream_ui_message_composer_hold_to_record),
22+
audioRecordingHoldToRecordText = context.getString(R.string.stream_ui_message_composer_hold_to_record_save),
2323
audioRecordingHoldToRecordTextStyle = TextStyle(
2424
size = context.getDimension(R.dimen.stream_ui_text_medium),
2525
color = context.getColorCompat(R.color.stream_ui_text_color_secondary),

stream-chat-android-ui-components/src/main/kotlin/io/getstream/chat/android/ui/feature/messages/composer/MessageComposerViewStyle.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ import io.getstream.chat.android.ui.common.R as UiCommonR
107107
* @param audioRecordingButtonWidth The width of the button to record audio.
108108
* @param audioRecordingButtonHeight The height of the button to record audio.
109109
* @param audioRecordingButtonPadding The padding of the button to record audio.
110-
* @param audioRecordingHoldToRecordText The info text that will be shown if touch event on audio button was too short.
110+
* @param audioRecordingHoldToRecordText Optional override for the info text shown on a short touch of the audio button.
111+
* When `null`, the text is resolved from string resources based on [audioRecordingSendOnComplete].
111112
* @param audioRecordingHoldToRecordTextStyle The text style that will be used for the "hold to record" text.
112113
* @param audioRecordingHoldToRecordBackgroundDrawable The drawable will be used as a background for the "hold to
113114
* record" text.
@@ -215,7 +216,7 @@ public data class MessageComposerViewStyle(
215216
public val messageInputVideoAttachmentIconDrawablePaddingStart: Int,
216217
public val messageInputVideoAttachmentIconDrawablePaddingEnd: Int,
217218
// Center overlap content
218-
public val audioRecordingHoldToRecordText: String,
219+
public val audioRecordingHoldToRecordText: String?,
219220
public val audioRecordingHoldToRecordTextStyle: TextStyle,
220221
public val audioRecordingHoldToRecordBackgroundDrawable: Drawable,
221222
@ColorInt public val audioRecordingHoldToRecordBackgroundDrawableTint: Int?,
@@ -534,7 +535,7 @@ public data class MessageComposerViewStyle(
534535
*/
535536
val audioRecordingHoldToRecordText = a.getString(
536537
R.styleable.MessageComposerView_streamUiMessageComposerAudioRecordingHoldToRecordText,
537-
) ?: context.getString(R.string.stream_ui_message_composer_hold_to_record)
538+
)
538539
val audioRecordingHoldToRecordTextStyle = TextStyle.Builder(a)
539540
.size(
540541
R.styleable.MessageComposerView_streamUiMessageComposerAudioRecordingHoldToRecordTextSize,

stream-chat-android-ui-components/src/main/kotlin/io/getstream/chat/android/ui/feature/messages/composer/content/DefaultMessageComposerOverlappingContent.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,13 @@ public open class DefaultMessageComposerOverlappingContent : ConstraintLayout, M
717717
false,
718718
).also {
719719
it.findViewById<TextView>(R.id.holdToRecordText).apply {
720-
text = style.audioRecordingHoldToRecordText
720+
text = style.audioRecordingHoldToRecordText ?: context.getString(
721+
if (style.audioRecordingSendOnComplete) {
722+
R.string.stream_ui_message_composer_hold_to_record_send
723+
} else {
724+
R.string.stream_ui_message_composer_hold_to_record_save
725+
},
726+
)
721727
setTextStyle(style.audioRecordingHoldToRecordTextStyle)
722728
background = style.audioRecordingHoldToRecordBackgroundDrawable.applyTint(
723729
style.audioRecordingHoldToRecordBackgroundDrawableTint,

stream-chat-android-ui-components/src/main/res/layout/stream_ui_message_composer_default_center_overlap_floating_hold.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
android:background="@drawable/stream_ui_message_composer_audio_record_hold_background"
2929
android:paddingHorizontal="16dp"
3030
android:gravity="center_vertical"
31-
android:text="@string/stream_ui_message_composer_hold_to_record"
31+
android:text="@string/stream_ui_message_composer_hold_to_record_save"
3232
android:textColor="@color/stream_ui_white_snow"
3333
android:textStyle="bold"
3434
/>

stream-chat-android-ui-components/src/main/res/values-es/strings.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@
6262
<string name="stream_ui_message_composer_gallery_access">"Permitir acceso a tu galería"</string>
6363
<string name="stream_ui_message_composer_hint_cannot_send_message">"No puedes enviar mensajes en este canal"</string>
6464
<string name="stream_ui_message_composer_hint_normal">"Escribe algo aquí"</string>
65-
<string name="stream_ui_message_composer_hold_to_record">"Mantén pulsado para empezar, suelta para enviar."</string>
65+
<string name="stream_ui_message_composer_hold_to_record_send">"Mantén pulsado para empezar, suelta para enviar."</string>
66+
<string name="stream_ui_message_composer_hold_to_record_save">"Mantén pulsado para empezar, suelta para guardar."</string>
6667
<string name="stream_ui_message_composer_instant_commands">"Comandos instantáneos"</string>
6768
<string name="stream_ui_message_composer_mode_edit">"Editar Mensaje"</string>
6869
<string name="stream_ui_message_composer_mode_reply">"Contestar al mensaje"</string>

stream-chat-android-ui-components/src/main/res/values/strings.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@
108108

109109
<!-- Audio Recording -->
110110
<string name="stream_ui_message_composer_slide_to_cancel">Slide to cancel</string>
111-
<string name="stream_ui_message_composer_hold_to_record">Hold to record. Release to send.</string>
111+
<string name="stream_ui_message_composer_hold_to_record_send">Hold to record. Release to send.</string>
112+
<string name="stream_ui_message_composer_hold_to_record_save">Hold to record. Release to save.</string>
112113

113114
<string name="stream_ui_message_list_empty">No messages</string>
114115
<string name="stream_ui_message_list_download_started">Download started</string>

stream-chat-android-ui-components/src/main/res/values/styles.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,9 +1369,6 @@
13691369
</item>
13701370

13711371
<!-- Center overlap content -->
1372-
<item name="streamUiMessageComposerAudioRecordingHoldToRecordText">
1373-
@string/stream_ui_message_composer_hold_to_record
1374-
</item>
13751372
<item name="streamUiMessageComposerAudioRecordingHoldToRecordTextSize">
13761373
@dimen/stream_ui_text_medium
13771374
</item>

0 commit comments

Comments
 (0)