[Android] Accessibility: improve talkback for playlists

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


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Fri May 20 13:56:25 2022 +0200| [cb46c3e35f7ff2c169bdeb9bcee59bf9186e328c] | committer: Nicolas Pomepuy

Accessibility: improve talkback for playlists

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

 application/resources/src/main/res/values/strings.xml      |  2 +-
 .../src/org/videolan/vlc/gui/helpers/TalkbackUtil.kt       | 14 +++++++++++---
 .../src/org/videolan/vlc/util/AccessibilityHelper.kt       |  2 +-
 3 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/application/resources/src/main/res/values/strings.xml b/application/resources/src/main/res/values/strings.xml
index 9e956fe19..50335fb66 100644
--- a/application/resources/src/main/res/values/strings.xml
+++ b/application/resources/src/main/res/values/strings.xml
@@ -980,7 +980,7 @@
     <string name="talkback_media_content_description">%s - title: %s - duration: %s</string>
     <string name="talkback_genre">Genre: %s</string>
     <string name="talkback_history_item">History item</string>
-    <string name="talkback_playlist">Playlist</string>
+    <string name="talkback_playlist">Playlist: %s</string>
     <string name="talkback_folder">Folder: %s</string>
     <string name="talkback_file">File: %s</string>
     <string name="talkback_favorite">Favorite: %s</string>
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/helpers/TalkbackUtil.kt b/application/vlc-android/src/org/videolan/vlc/gui/helpers/TalkbackUtil.kt
index 1d77a28f6..2078db940 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/helpers/TalkbackUtil.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/helpers/TalkbackUtil.kt
@@ -36,29 +36,37 @@ object TalkbackUtil {
     fun getDuration(context: Context, duration: Long) = context.getString(R.string.talkback_duration, millisToString(context, duration))
     fun getDuration(context: Context, duration: String) = context.getString(R.string.talkback_duration, duration)
     fun getAlbumTitle(context: Context, album: String) = context.getString(R.string.talkback_album, album)
-    fun getReleaseDate(context: Context, date: String) = context.getString(R.string.talkback_release_date, date)
+    fun getReleaseDate(context: Context, date: String?) = if (date == null) "" else context.getString(R.string.talkback_release_date, date)
     fun getVideo(context: Context, video: MediaWrapper) = context.getString(R.string.talkback_video)
             .talkbackAppend(getDuration(context, millisToString(context, video.length)))
+
     fun getAudioTrack(context: Context, audio: MediaWrapper) = context.getString(R.string.talkback_audio_track, audio.title)
             .talkbackAppend(getDuration(context, millisToString(context, audio.length)))
             .talkbackAppend(context.getString(R.string.talkback_album, audio.album))
             .talkbackAppend(context.getString(R.string.talkback_artist, audio.artist))
+
     fun getVideoGroup(context: Context, video: VideoGroup) = context.getString(R.string.talkback_video_group, video.title)
             .talkbackAppend(context.resources.getQuantityString(R.plurals.videos_quantity, video.mediaCount(), video.mediaCount()))
+
     fun getGenre(context: Context, genre: Genre) = context.getString(R.string.talkback_genre, genre.title)
             .talkbackAppend(context.resources.getQuantityString(R.plurals.track_quantity, genre.tracksCount, genre.tracksCount))
+
     fun getArtist(context: Context, artist: Artist?) = if (artist == null) null else context.getString(R.string.talkback_artist, artist.title)
             .talkbackAppend(context.resources.getQuantityString(R.plurals.albums_quantity, artist.albumsCount, artist.albumsCount))
+
     fun getAlbum(context: Context, album: Album) = context.getString(R.string.talkback_album, album.title)
             .talkbackAppend(context.getString(R.string.talkback_artist, album.albumArtist))
             .talkbackAppend(context.resources.getQuantityString(R.plurals.track_quantity, album.tracksCount, album.tracksCount))
-    fun getArtist(context: Context, artist: String) = context.getString(R.string.talkback_artist, artist)
+
+    fun getPlaylist(context: Context, playlist: Playlist) = context.getString(R.string.talkback_playlist, playlist.title)
+            .talkbackAppend(context.resources.getQuantityString(R.plurals.track_quantity, playlist.tracksCount, playlist.tracksCount))
+
+    fun getArtist(context: Context, artist: String?) = if (artist == null) "" else context.getString(R.string.talkback_artist, artist)
     fun getTrackNumber(context: Context, item: MediaWrapper) = context.getString(R.string.talkback_track_number, item.trackNumber.toString())
     fun getTimeAndArtist(context: Context, item: MediaWrapper) = millisToString(context, item.length)
             .talkbackAppend(getArtist(context, item.artist))
 
 
-
     fun getFolder(context: Context, folder: Folder): String {
         val mediaCount = folder.mediaCount(Folder.TYPE_FOLDER_VIDEO)
         return context.getString(R.string.talkback_folder, folder.title)
diff --git a/application/vlc-android/src/org/videolan/vlc/util/AccessibilityHelper.kt b/application/vlc-android/src/org/videolan/vlc/util/AccessibilityHelper.kt
index c721dbe7c..368c3eb4e 100644
--- a/application/vlc-android/src/org/videolan/vlc/util/AccessibilityHelper.kt
+++ b/application/vlc-android/src/org/videolan/vlc/util/AccessibilityHelper.kt
@@ -47,7 +47,7 @@ fun mediaDescription(v: View, media: MediaLibraryItem) {
         is Folder -> TalkbackUtil.getFolder(v.context, media)
         is Genre -> TalkbackUtil.getGenre(v.context, media)
         is HistoryItem -> v.context.getString(R.string.talkback_history_item)
-        is Playlist -> v.context.getString(R.string.talkback_playlist)
+        is Playlist -> TalkbackUtil.getPlaylist(v.context, media)
         is MediaWrapper -> when (media.type) {
             MediaWrapper.TYPE_VIDEO -> TalkbackUtil.getVideo(v.context, media)
             MediaWrapper.TYPE_AUDIO -> TalkbackUtil.getAudioTrack(v.context, media)



More information about the Android mailing list