[Android] Accessibility: improve talkback for the PathAdapter

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


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Tue May 24 09:37:49 2022 +0200| [93f4d7979faa2ffa844438e41d6e08f527807472] | committer: Nicolas Pomepuy

Accessibility: improve talkback for the PathAdapter

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

 .../vlc-android/src/org/videolan/vlc/gui/browser/PathAdapter.kt   | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/gui/browser/PathAdapter.kt b/application/vlc-android/src/org/videolan/vlc/gui/browser/PathAdapter.kt
index d27b2dc0b..ceaeb5da1 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/browser/PathAdapter.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/browser/PathAdapter.kt
@@ -2,7 +2,6 @@ package org.videolan.vlc.gui.browser
 
 import android.content.Context
 import android.net.Uri
-import android.util.Log
 import android.view.LayoutInflater
 import android.view.ViewGroup
 import android.widget.TextView
@@ -11,7 +10,6 @@ import androidx.recyclerview.widget.RecyclerView
 import org.videolan.medialibrary.interfaces.media.MediaWrapper
 import org.videolan.medialibrary.media.MediaLibraryItem
 import org.videolan.resources.AndroidDevices
-import org.videolan.vlc.BuildConfig
 import org.videolan.vlc.R
 import org.videolan.vlc.viewmodels.browser.IPathOperationDelegate
 import org.videolan.vlc.viewmodels.browser.PathOperationDelegate
@@ -38,11 +36,15 @@ class PathAdapter(val browser: PathAdapterListener, media: MediaWrapper) : Recyc
     override fun getItemCount() = segments.size
 
     override fun onBindViewHolder(holder: ViewHolder, position: Int) {
-        holder.root.text = when {
+        val text: String? = when {
             //substitute a storage path to its name. See [replaceStoragePath]
             PathOperationDelegate.storages.containsKey(segments[position].toUri().path) -> pathOperationDelegate.retrieveSafePath(PathOperationDelegate.storages.valueAt(PathOperationDelegate.storages.indexOfKey(segments[position].toUri().path)))
             else -> segments[position].toUri().lastPathSegment
         }
+        holder.root.text = text
+        text?.let {
+            holder.root.contentDescription = holder.root.context.getString(R.string.talkback_folder, holder.root.text)
+        }
     }
 
     inner class ViewHolder(val root: TextView) : RecyclerView.ViewHolder(root) {



More information about the Android mailing list