[Android] Accessibility: use the file contentDescription in the breadcrumb component
Nicolas Pomepuy
git at videolan.org
Mon Jun 27 11:45:16 UTC 2022
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Mon Jun 27 12:46:19 2022 +0200| [9b3db9776c9b467af0d7611f92ee8deab5391edd] | committer: Duncan McNamara
Accessibility: use the file contentDescription in the breadcrumb component
> https://code.videolan.org/videolan/vlc-android/commit/9b3db9776c9b467af0d7611f92ee8deab5391edd
---
.../src/org/videolan/vlc/gui/browser/PathAdapter.kt | 10 ++++++++--
1 file changed, 8 insertions(+), 2 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 ceaeb5da1..35beaa2a5 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
@@ -5,6 +5,7 @@ import android.net.Uri
import android.view.LayoutInflater
import android.view.ViewGroup
import android.widget.TextView
+import androidx.core.net.toFile
import androidx.core.net.toUri
import androidx.recyclerview.widget.RecyclerView
import org.videolan.medialibrary.interfaces.media.MediaWrapper
@@ -14,7 +15,7 @@ import org.videolan.vlc.R
import org.videolan.vlc.viewmodels.browser.IPathOperationDelegate
import org.videolan.vlc.viewmodels.browser.PathOperationDelegate
-class PathAdapter(val browser: PathAdapterListener, media: MediaWrapper) : RecyclerView.Adapter<PathAdapter.ViewHolder>() {
+class PathAdapter(val browser: PathAdapterListener, val media: MediaWrapper) : RecyclerView.Adapter<PathAdapter.ViewHolder>() {
private val pathOperationDelegate = browser.getPathOperationDelegate()
@@ -43,7 +44,12 @@ class PathAdapter(val browser: PathAdapterListener, media: MediaWrapper) : Recyc
}
holder.root.text = text
text?.let {
- holder.root.contentDescription = holder.root.context.getString(R.string.talkback_folder, holder.root.text)
+ val isFile = try {
+ Uri.parse(segments[position]).toFile().isFile
+ } catch (e: Exception) {
+ false
+ }
+ holder.root.contentDescription = holder.root.context.getString(if (isFile) R.string.talkback_file else R.string.talkback_folder, holder.root.text)
}
}
More information about the Android
mailing list