diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageAudioItem.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageAudioItem.kt index 8d5810a60a..397f43546e 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageAudioItem.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageAudioItem.kt @@ -16,6 +16,7 @@ package im.vector.app.features.home.room.detail.timeline.item +import android.content.Context import android.content.res.ColorStateList import android.graphics.Color import android.graphics.Paint @@ -105,11 +106,20 @@ abstract class MessageAudioItem : AbsMessageItem() { } private fun bindViewAttributes(holder: Holder) { + val formattedDuration = formatPlaybackTime(duration) + val formattedFileSize = TextUtils.formatFileSize(holder.rootLayout.context, fileSize, true) + val durationContentDescription = getPlaybackTimeContentDescription(holder.rootLayout.context, duration) + holder.filenameView.text = filename holder.filenameView.onClick(attributes.itemClickListener) holder.filenameView.paintFlags = (holder.filenameView.paintFlags or Paint.UNDERLINE_TEXT_FLAG) - holder.audioPlaybackDuration.text = formatPlaybackTime(duration) - holder.fileSize.text = TextUtils.formatFileSize(holder.rootLayout.context, fileSize, true) + holder.audioPlaybackDuration.text = formattedDuration + holder.fileSize.text = holder.rootLayout.context.getString( + R.string.audio_message_file_size, formattedFileSize + ) + holder.mainLayout.contentDescription = holder.rootLayout.context.getString( + R.string.a11y_audio_message_item, filename, durationContentDescription, formattedFileSize + ) } private fun bindSeekBar(holder: Holder) { @@ -172,6 +182,12 @@ abstract class MessageAudioItem : AbsMessageItem() { private fun formatPlaybackTime(time: Int) = DateUtils.formatElapsedTime((time / 1000).toLong()) + private fun getPlaybackTimeContentDescription(context: Context, time: Int): String { + val formattedPlaybackTime = formatPlaybackTime(time) + val (minutes, seconds) = formattedPlaybackTime.split(":").map { it.toIntOrNull() ?: 0 } + return context.getString(R.string.a11y_audio_playback_duration, minutes, seconds) + } + override fun unbind(holder: Holder) { super.unbind(holder) contentUploadStateTrackerBinder.unbind(attributes.informationData.eventId) diff --git a/vector/src/main/res/values/strings.xml b/vector/src/main/res/values/strings.xml index 90f6c5f7b1..1e50b32c6b 100644 --- a/vector/src/main/res/values/strings.xml +++ b/vector/src/main/res/values/strings.xml @@ -2860,10 +2860,13 @@ Cannot reply or edit while voice message is active Voice Message (%1$s) + %1$s, %2$s, %3$s + %1$d minutes %2$d seconds Play %1$s Pause %1$s Unable to play %1$s %1$s (%2$s) + (%1$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.