[Android] Accessibility: video player update shuffle/repeat content descriptions

Nicolas Pomepuy git at videolan.org
Fri Jun 3 11:30:22 UTC 2022


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Thu Jun  2 08:28:18 2022 +0200| [1963d43103e72b187f3a3805b58723c48710131b] | committer: Nicolas Pomepuy

Accessibility: video player update shuffle/repeat content descriptions

> https://code.videolan.org/videolan/vlc-android/commit/1963d43103e72b187f3a3805b58723c48710131b
---

 .../src/org/videolan/vlc/gui/helpers/PlayerOptionsDelegate.kt | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/application/vlc-android/src/org/videolan/vlc/gui/helpers/PlayerOptionsDelegate.kt b/application/vlc-android/src/org/videolan/vlc/gui/helpers/PlayerOptionsDelegate.kt
index 8cf013267..2d6b2b7fb 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/helpers/PlayerOptionsDelegate.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/helpers/PlayerOptionsDelegate.kt
@@ -281,29 +281,35 @@ class PlayerOptionsDelegate(val activity: FragmentActivity, val service: Playbac
             PlaybackStateCompat.REPEAT_MODE_NONE -> {
                 repeatBinding.optionIcon.setImageResource(R.drawable.ic_repeat_one)
                 service.repeatType = PlaybackStateCompat.REPEAT_MODE_ONE
+                repeatBinding.root.contentDescription = repeatBinding.root.context.getString(R.string.repeat_single)
             }
             PlaybackStateCompat.REPEAT_MODE_ONE -> if (service.hasPlaylist()) {
                 repeatBinding.optionIcon.setImageResource(R.drawable.ic_repeat_all)
                 service.repeatType = PlaybackStateCompat.REPEAT_MODE_ALL
+                repeatBinding.root.contentDescription = repeatBinding.root.context.getString(R.string.repeat_all)
             } else {
                 repeatBinding.optionIcon.setImageResource(R.drawable.ic_repeat)
                 service.repeatType = PlaybackStateCompat.REPEAT_MODE_NONE
+                repeatBinding.root.contentDescription = repeatBinding.root.context.getString(R.string.repeat)
             }
             PlaybackStateCompat.REPEAT_MODE_ALL -> {
                 repeatBinding.optionIcon.setImageResource(R.drawable.ic_repeat)
                 service.repeatType = PlaybackStateCompat.REPEAT_MODE_NONE
+                repeatBinding.root.contentDescription = repeatBinding.root.context.getString(R.string.repeat)
             }
         }
     }
 
     private fun setShuffle() {
         shuffleBinding.optionIcon.setImageResource(if (service.isShuffling) R.drawable.ic_shuffle_on_48dp else R.drawable.ic_shuffle)
+        shuffleBinding.root.contentDescription = shuffleBinding.root.context.getString(if (service.isShuffling) R.string.shuffle_on else R.string.shuffle)
     }
 
     private fun initShuffle(binding: PlayerOptionItemBinding) {
         shuffleBinding = binding
         AppScope.launch(Dispatchers.Main) {
             shuffleBinding.optionIcon.setImageResource(if (service.isShuffling) R.drawable.ic_shuffle_on_48dp else R.drawable.ic_shuffle)
+            shuffleBinding.root.contentDescription = shuffleBinding.root.context.getString(if (service.isShuffling) R.string.shuffle_on else R.string.shuffle)
         }
     }
 
@@ -315,6 +321,11 @@ class PlayerOptionsDelegate(val activity: FragmentActivity, val service: Playbac
                 PlaybackStateCompat.REPEAT_MODE_ALL -> R.drawable.ic_repeat_all
                 else -> R.drawable.ic_repeat
             })
+            repeatBinding.root.contentDescription = repeatBinding.root.context.getString(when (service.repeatType) {
+                PlaybackStateCompat.REPEAT_MODE_ONE -> R.string.repeat_single
+                PlaybackStateCompat.REPEAT_MODE_ALL -> R.string.repeat_all
+                else -> R.string.repeat
+            })
         }
     }
 



More information about the Android mailing list