From 2e716cb8a043ccba3e706f88db98c66cfd9c2407 Mon Sep 17 00:00:00 2001 From: ericdecanini Date: Sat, 19 Mar 2022 18:26:37 +0100 Subject: [PATCH] Adapts special body text for audio messages --- .../app/features/home/room/detail/TimelineFragment.kt | 11 +++++++++++ vector/src/main/res/values/strings.xml | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineFragment.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineFragment.kt index a558a1cc87..8fad376a0b 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineFragment.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineFragment.kt @@ -1177,6 +1177,9 @@ class TimelineFragment @Inject constructor( val messageContent: MessageContent? = event.getLastMessageContent() val nonFormattedBody = when { + messageContent is MessageAudioContent -> { + getAudioContentBodyText(messageContent) + } messageContent is MessageAudioContent && messageContent.voiceMessageIndicator != null -> { val formattedDuration = DateUtils.formatElapsedTime(((messageContent.audioInfo?.duration ?: 0) / 1000).toLong()) getString(R.string.voice_message_reply_content, formattedDuration) @@ -1225,6 +1228,14 @@ class TimelineFragment @Inject constructor( focusComposerAndShowKeyboard() } + private fun getAudioContentBodyText(messageContent: MessageAudioContent): String { + val formattedDuration = DateUtils.formatElapsedTime(((messageContent.audioInfo?.duration ?: 0) / 1000).toLong()) + return if (messageContent.voiceMessageIndicator != null) + getString(R.string.voice_message_reply_content, formattedDuration) + else + getString(R.string.audio_message_reply_content, messageContent.body, formattedDuration) + } + override fun onResume() { super.onResume() notificationDrawerManager.setCurrentRoom(timelineArgs.roomId) diff --git a/vector/src/main/res/values/strings.xml b/vector/src/main/res/values/strings.xml index 83b2bba5fb..0cc9795589 100644 --- a/vector/src/main/res/values/strings.xml +++ b/vector/src/main/res/values/strings.xml @@ -2862,7 +2862,7 @@ Pause Audio Message Pause Audio Message Cannot reply or edit while audio message is active - Audio Message (%1$s) + %1$s (%2$s) Anyone in %s will be able to find and join this room - no need to manually invite everyone. You’ll be able to change this in room settings anytime. Anyone in a parent space will be able to find and join this room - no need to manually invite everyone. You’ll be able to change this in room settings anytime.