mirror of
https://github.com/element-hq/element-android
synced 2024-12-22 01:04:56 +03:00
Improve accessibility of voice messages
Signed-off-by: Peter Vágner <pvdeejay@gmail.com>
This commit is contained in:
parent
60caac4214
commit
8c590b50e3
5 changed files with 18 additions and 6 deletions
|
@ -20,6 +20,7 @@ import android.content.Context
|
||||||
import android.text.format.DateUtils
|
import android.text.format.DateUtils
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.view.MotionEvent
|
import android.view.MotionEvent
|
||||||
|
import android.view.View
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout
|
import androidx.constraintlayout.widget.ConstraintLayout
|
||||||
import androidx.core.view.isInvisible
|
import androidx.core.view.isInvisible
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
|
@ -476,12 +477,14 @@ class VoiceMessageRecorderView @JvmOverloads constructor(
|
||||||
views.voiceMessagePlaybackTimerIndicator.isVisible = true
|
views.voiceMessagePlaybackTimerIndicator.isVisible = true
|
||||||
views.voicePlaybackControlButton.isVisible = false
|
views.voicePlaybackControlButton.isVisible = false
|
||||||
views.voiceMessageSendButton.isVisible = true
|
views.voiceMessageSendButton.isVisible = true
|
||||||
|
views.voicePlaybackWaveform.importantForAccessibility = View.IMPORTANT_FOR_ACCESSIBILITY_YES
|
||||||
renderToast(context.getString(R.string.voice_message_tap_to_stop_toast))
|
renderToast(context.getString(R.string.voice_message_tap_to_stop_toast))
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showPlaybackViews() {
|
private fun showPlaybackViews() {
|
||||||
views.voiceMessagePlaybackTimerIndicator.isVisible = false
|
views.voiceMessagePlaybackTimerIndicator.isVisible = false
|
||||||
views.voicePlaybackControlButton.isVisible = true
|
views.voicePlaybackControlButton.isVisible = true
|
||||||
|
views.voicePlaybackWaveform.importantForAccessibility = View.IMPORTANT_FOR_ACCESSIBILITY_NO
|
||||||
callback?.onVoiceRecordingPlaybackModeOn()
|
callback?.onVoiceRecordingPlaybackModeOn()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -507,12 +510,14 @@ class VoiceMessageRecorderView @JvmOverloads constructor(
|
||||||
}
|
}
|
||||||
is VoiceMessagePlaybackTracker.Listener.State.Playing -> {
|
is VoiceMessagePlaybackTracker.Listener.State.Playing -> {
|
||||||
views.voicePlaybackControlButton.setImageResource(R.drawable.ic_play_pause_pause)
|
views.voicePlaybackControlButton.setImageResource(R.drawable.ic_play_pause_pause)
|
||||||
|
views.voicePlaybackControlButton.contentDescription = resources.getString(R.string.a11y_pause_voice_message)
|
||||||
val formattedTimerText = DateUtils.formatElapsedTime((state.playbackTime / 1000).toLong())
|
val formattedTimerText = DateUtils.formatElapsedTime((state.playbackTime / 1000).toLong())
|
||||||
views.voicePlaybackTime.text = formattedTimerText
|
views.voicePlaybackTime.text = formattedTimerText
|
||||||
}
|
}
|
||||||
is VoiceMessagePlaybackTracker.Listener.State.Paused,
|
is VoiceMessagePlaybackTracker.Listener.State.Paused,
|
||||||
is VoiceMessagePlaybackTracker.Listener.State.Idle -> {
|
is VoiceMessagePlaybackTracker.Listener.State.Idle -> {
|
||||||
views.voicePlaybackControlButton.setImageResource(R.drawable.ic_play_pause_play)
|
views.voicePlaybackControlButton.setImageResource(R.drawable.ic_play_pause_play)
|
||||||
|
views.voicePlaybackControlButton.contentDescription = resources.getString(R.string.a11y_play_voice_message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,16 +98,19 @@ abstract class MessageVoiceItem : AbsMessageItem<MessageVoiceItem.Holder>() {
|
||||||
|
|
||||||
private fun renderIdleState(holder: Holder) {
|
private fun renderIdleState(holder: Holder) {
|
||||||
holder.voicePlaybackControlButton.setImageResource(R.drawable.ic_play_pause_play)
|
holder.voicePlaybackControlButton.setImageResource(R.drawable.ic_play_pause_play)
|
||||||
|
holder.voicePlaybackControlButton.contentDescription = holder.view.context.resources.getString(R.string.a11y_play_voice_message)
|
||||||
holder.voicePlaybackTime.text = formatPlaybackTime(duration)
|
holder.voicePlaybackTime.text = formatPlaybackTime(duration)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun renderPlayingState(holder: Holder, state: VoiceMessagePlaybackTracker.Listener.State.Playing) {
|
private fun renderPlayingState(holder: Holder, state: VoiceMessagePlaybackTracker.Listener.State.Playing) {
|
||||||
holder.voicePlaybackControlButton.setImageResource(R.drawable.ic_play_pause_pause)
|
holder.voicePlaybackControlButton.setImageResource(R.drawable.ic_play_pause_pause)
|
||||||
|
holder.voicePlaybackControlButton.contentDescription = holder.view.context.resources.getString(R.string.a11y_pause_voice_message)
|
||||||
holder.voicePlaybackTime.text = formatPlaybackTime(state.playbackTime)
|
holder.voicePlaybackTime.text = formatPlaybackTime(state.playbackTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun renderPausedState(holder: Holder, state: VoiceMessagePlaybackTracker.Listener.State.Paused) {
|
private fun renderPausedState(holder: Holder, state: VoiceMessagePlaybackTracker.Listener.State.Paused) {
|
||||||
holder.voicePlaybackControlButton.setImageResource(R.drawable.ic_play_pause_play)
|
holder.voicePlaybackControlButton.setImageResource(R.drawable.ic_play_pause_play)
|
||||||
|
holder.voicePlaybackControlButton.contentDescription = holder.view.context.resources.getString(R.string.a11y_play_voice_message)
|
||||||
holder.voicePlaybackTime.text = formatPlaybackTime(state.playbackTime)
|
holder.voicePlaybackTime.text = formatPlaybackTime(state.playbackTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,7 @@
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_marginStart="8dp"
|
android:layout_marginStart="8dp"
|
||||||
android:layout_marginEnd="8dp"
|
android:layout_marginEnd="8dp"
|
||||||
|
android:importantForAccessibility="no"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toEndOf="@id/voicePlaybackTime"
|
app:layout_constraintStart_toEndOf="@id/voicePlaybackTime"
|
||||||
|
@ -77,4 +78,4 @@
|
||||||
app:layout_constraintTop_toBottomOf="@+id/voicePlaybackLayout"
|
app:layout_constraintTop_toBottomOf="@+id/voicePlaybackLayout"
|
||||||
tools:visibility="visible" />
|
tools:visibility="visible" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
|
@ -107,7 +107,7 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="28dp"
|
android:layout_marginTop="28dp"
|
||||||
android:contentDescription="@string/a11y_lock_voice_message"
|
android:importantForAccessibility="no"
|
||||||
android:src="@drawable/ic_voice_message_unlocked"
|
android:src="@drawable/ic_voice_message_unlocked"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
app:layout_constraintEnd_toEndOf="@id/voiceMessageMicButton"
|
app:layout_constraintEnd_toEndOf="@id/voiceMessageMicButton"
|
||||||
|
@ -215,6 +215,8 @@
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_marginStart="8dp"
|
android:layout_marginStart="8dp"
|
||||||
android:layout_marginEnd="8dp"
|
android:layout_marginEnd="8dp"
|
||||||
|
android:contentDescription="@string/a11y_stop_voice_message"
|
||||||
|
android:importantForAccessibility="no"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toEndOf="@id/voicePlaybackTime"
|
app:layout_constraintStart_toEndOf="@id/voicePlaybackTime"
|
||||||
|
@ -231,10 +233,11 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="84dp"
|
android:layout_marginBottom="84dp"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
|
android:accessibilityLiveRegion="polite"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
tools:text="@string/voice_message_release_to_send_toast"
|
tools:text="@string/voice_message_release_to_send_toast"
|
||||||
tools:visibility="visible" />
|
tools:visibility="visible" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
|
@ -3460,13 +3460,13 @@
|
||||||
|
|
||||||
<string name="error_failed_to_join_room">Sorry, an error occurred while trying to join: %s</string>
|
<string name="error_failed_to_join_room">Sorry, an error occurred while trying to join: %s</string>
|
||||||
|
|
||||||
<string name="a11y_start_voice_message">Start Voice Message</string>
|
<string name="a11y_start_voice_message">Record Voice Message</string>
|
||||||
<string name="voice_message_slide_to_cancel">Slide to cancel</string>
|
<string name="voice_message_slide_to_cancel">Slide to cancel</string>
|
||||||
<string name="a11y_lock_voice_message">Voice Message Lock</string>
|
|
||||||
<string name="a11y_play_voice_message">Play Voice Message</string>
|
<string name="a11y_play_voice_message">Play Voice Message</string>
|
||||||
<string name="a11y_pause_voice_message">Pause Voice Message</string>
|
<string name="a11y_pause_voice_message">Pause Voice Message</string>
|
||||||
|
<string name="a11y_stop_voice_message">Stop Recording</string>
|
||||||
<string name="a11y_recording_voice_message">Recording voice message</string>
|
<string name="a11y_recording_voice_message">Recording voice message</string>
|
||||||
<string name="a11y_delete_recorded_voice_message">Delete recorded voice message</string>
|
<string name="a11y_delete_recorded_voice_message">Delete recording</string>
|
||||||
<string name="voice_message_release_to_send_toast">Hold to record, release to send</string>
|
<string name="voice_message_release_to_send_toast">Hold to record, release to send</string>
|
||||||
<string name="voice_message_n_seconds_warning_toast">%1$ds left</string>
|
<string name="voice_message_n_seconds_warning_toast">%1$ds left</string>
|
||||||
<string name="voice_message_tap_to_stop_toast">Tap on your recording to stop or listen</string>
|
<string name="voice_message_tap_to_stop_toast">Tap on your recording to stop or listen</string>
|
||||||
|
|
Loading…
Reference in a new issue