[Android] Accessibility: improve talkback for Android TV audio player
Nicolas Pomepuy
git at videolan.org
Fri Jun 3 11:30:22 UTC 2022
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Wed Jun 1 12:26:27 2022 +0200| [a882b29468e6ffa4745b36b056f476cd26763441] | committer: Nicolas Pomepuy
Accessibility: improve talkback for Android TV audio player
> https://code.videolan.org/videolan/vlc-android/commit/a882b29468e6ffa4745b36b056f476cd26763441
---
.../television/ui/audioplayer/AudioPlayerActivity.kt | 13 +++++++++++--
.../television/src/main/res/layout/tv_audio_player.xml | 7 ++++++-
2 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/application/television/src/main/java/org/videolan/television/ui/audioplayer/AudioPlayerActivity.kt b/application/television/src/main/java/org/videolan/television/ui/audioplayer/AudioPlayerActivity.kt
index 0f5dba4f2..420379bcd 100644
--- a/application/television/src/main/java/org/videolan/television/ui/audioplayer/AudioPlayerActivity.kt
+++ b/application/television/src/main/java/org/videolan/television/ui/audioplayer/AudioPlayerActivity.kt
@@ -35,7 +35,9 @@ import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat
-import kotlinx.coroutines.*
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.launch
+import kotlinx.coroutines.withContext
import org.videolan.medialibrary.interfaces.media.MediaWrapper
import org.videolan.resources.AndroidDevices
import org.videolan.television.R
@@ -55,7 +57,6 @@ import org.videolan.vlc.util.getScreenWidth
import org.videolan.vlc.viewmodels.BookmarkModel
import org.videolan.vlc.viewmodels.PlayerState
import org.videolan.vlc.viewmodels.PlaylistModel
-import java.lang.Runnable
import kotlin.math.abs
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
@@ -179,6 +180,7 @@ class AudioPlayerActivity : BaseTvActivity(),KeycodeListener {
}
wasPlaying = state.playing
+ binding.buttonPlay.contentDescription = getString(if (state.playing) org.videolan.vlc.R.string.pause else org.videolan.vlc.R.string.play)
val mw = model.currentMediaWrapper
lifecycleScope.launch {
@@ -192,6 +194,7 @@ class AudioPlayerActivity : BaseTvActivity(),KeycodeListener {
R.drawable.ic_shuffle_on
else
R.drawable.ic_shuffle_audio)
+ binding.buttonShuffle.contentDescription = getString(if (shuffling) org.videolan.vlc.R.string.shuffle_on else org.videolan.vlc.R.string.shuffle)
if (mw == null || currentCoverArt == mw.artworkMrl) return at launch
currentCoverArt = mw.artworkMrl
updateBackground()
@@ -352,13 +355,16 @@ class AudioPlayerActivity : BaseTvActivity(),KeycodeListener {
when (model.repeatType) {
PlaybackStateCompat.REPEAT_MODE_ALL -> {
binding.buttonRepeat.setImageResource(R.drawable.ic_repeat_all_audio)
+ binding.buttonRepeat.contentDescription = getString(R.string.repeat_all)
}
PlaybackStateCompat.REPEAT_MODE_ONE -> {
binding.buttonRepeat.setImageResource(R.drawable.ic_repeat_one_audio)
+ binding.buttonRepeat.contentDescription = getString(R.string.repeat_single)
}
PlaybackStateCompat.REPEAT_MODE_NONE -> {
model.repeatType = PlaybackStateCompat.REPEAT_MODE_NONE
binding.buttonRepeat.setImageResource(R.drawable.ic_repeat_audio)
+ binding.buttonRepeat.contentDescription = getString(R.string.repeat)
}
}
}
@@ -368,14 +374,17 @@ class AudioPlayerActivity : BaseTvActivity(),KeycodeListener {
PlaybackStateCompat.REPEAT_MODE_NONE -> {
model.repeatType = PlaybackStateCompat.REPEAT_MODE_ALL
binding.buttonRepeat.setImageResource(R.drawable.ic_repeat_all_audio)
+ binding.buttonRepeat.contentDescription = getString(R.string.repeat_all)
}
PlaybackStateCompat.REPEAT_MODE_ALL -> {
model.repeatType = PlaybackStateCompat.REPEAT_MODE_ONE
binding.buttonRepeat.setImageResource(R.drawable.ic_repeat_one_audio)
+ binding.buttonRepeat.contentDescription = getString(R.string.repeat_single)
}
PlaybackStateCompat.REPEAT_MODE_ONE -> {
model.repeatType = PlaybackStateCompat.REPEAT_MODE_NONE
binding.buttonRepeat.setImageResource(R.drawable.ic_repeat_audio)
+ binding.buttonRepeat.contentDescription = getString(R.string.repeat)
}
}
}
diff --git a/application/television/src/main/res/layout/tv_audio_player.xml b/application/television/src/main/res/layout/tv_audio_player.xml
index 8c35bda9a..e0c2eaabf 100644
--- a/application/television/src/main/res/layout/tv_audio_player.xml
+++ b/application/television/src/main/res/layout/tv_audio_player.xml
@@ -199,11 +199,12 @@
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:text="@{progress.timeText}"
+ android:importantForAccessibility="no"
app:layout_constraintBottom_toTopOf="@+id/media_progress"
app:layout_constraintStart_toStartOf="@+id/media_progress"
tools:text="0:30" />
- <SeekBar
+ <org.videolan.vlc.gui.view.AccessibleSeekBar
android:id="@+id/media_progress"
android:layout_width="0dp"
android:layout_height="wrap_content"
@@ -233,6 +234,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
+ android:importantForAccessibility="no"
android:text="@{progress.lengthText}"
app:layout_constraintBottom_toTopOf="@+id/media_progress"
app:layout_constraintEnd_toEndOf="@+id/media_progress"
@@ -266,6 +268,7 @@
android:layout_marginEnd="16dp"
android:background="@drawable/ic_circle_audio_player"
android:clickable="true"
+ android:contentDescription="@string/previous"
android:focusable="true"
android:nextFocusDown="@+id/playlist"
android:onClick="onClick"
@@ -308,6 +311,7 @@
android:clickable="true"
android:focusable="true"
android:nextFocusDown="@+id/playlist"
+ android:contentDescription="@string/next"
android:onClick="onClick"
android:padding="8dp"
app:layout_constraintBottom_toBottomOf="@+id/button_play"
@@ -347,6 +351,7 @@
android:nextFocusDown="@+id/playlist"
android:onClick="onClick"
android:padding="8dp"
+ android:contentDescription="@string/more_actions"
app:layout_constraintBottom_toBottomOf="@+id/button_play"
app:layout_constraintEnd_toEndOf="@+id/media_progress"
app:layout_constraintTop_toTopOf="@+id/button_play"
More information about the Android
mailing list