[Android] Accessibility: improve talkback for Android TV navigation
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 11:57:27 2022 +0200| [219bce90e9dc299b63ca72bec806d6ff71abe4a2] | committer: Nicolas Pomepuy
Accessibility: improve talkback for Android TV navigation
> https://code.videolan.org/videolan/vlc-android/commit/219bce90e9dc299b63ca72bec806d6ff71abe4a2
---
application/resources/src/main/res/values/strings.xml | 1 +
.../org/videolan/television/ui/browser/BaseBrowserTvFragment.kt | 2 ++
.../org/videolan/television/ui/browser/FileBrowserTvFragment.kt | 8 +++++++-
.../television/src/main/res/layout/media_browser_tv_item.xml | 1 +
.../television/src/main/res/layout/media_browser_tv_item_list.xml | 1 +
application/television/src/main/res/layout/song_browser.xml | 5 +++++
.../vlc-android/src/org/videolan/vlc/util/AccessibilityHelper.kt | 3 ++-
7 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/application/resources/src/main/res/values/strings.xml b/application/resources/src/main/res/values/strings.xml
index eaea750f0..d9bed6bd9 100644
--- a/application/resources/src/main/res/values/strings.xml
+++ b/application/resources/src/main/res/values/strings.xml
@@ -1025,6 +1025,7 @@
<string name="downloading">Downloading</string>
<string name="talkback_action_rewind">Rewind %s seconds</string>
<string name="talkback_action_forward">Seek forward %s seconds</string>
+ <string name="talkback_display_settings">Display settings</string>
</resources>
diff --git a/application/television/src/main/java/org/videolan/television/ui/browser/BaseBrowserTvFragment.kt b/application/television/src/main/java/org/videolan/television/ui/browser/BaseBrowserTvFragment.kt
index 0ab3b4af9..ae59e6c62 100644
--- a/application/television/src/main/java/org/videolan/television/ui/browser/BaseBrowserTvFragment.kt
+++ b/application/television/src/main/java/org/videolan/television/ui/browser/BaseBrowserTvFragment.kt
@@ -265,6 +265,8 @@ abstract class BaseBrowserTvFragment<T> : Fragment(), BrowserFragmentInterface,
binding.imageButtonDisplay.setImageResource(if (inGrid) R.drawable.ic_fabtvmini_list else R.drawable.ic_fabtvmini_grid)
binding.displayButton.setImageResource(if (inGrid) R.drawable.ic_list else R.drawable.ic_grid)
binding.displayDescription.setText(if (inGrid) R.string.display_in_list else R.string.display_in_grid)
+ binding.displayButton.contentDescription = getString(if (inGrid) R.string.display_in_list else R.string.display_in_grid)
+ binding.imageButtonDisplay.contentDescription = getString(if (inGrid) R.string.display_in_list else R.string.display_in_grid)
}
override fun onStart() {
diff --git a/application/television/src/main/java/org/videolan/television/ui/browser/FileBrowserTvFragment.kt b/application/television/src/main/java/org/videolan/television/ui/browser/FileBrowserTvFragment.kt
index 17b946277..b5615f586 100644
--- a/application/television/src/main/java/org/videolan/television/ui/browser/FileBrowserTvFragment.kt
+++ b/application/television/src/main/java/org/videolan/television/ui/browser/FileBrowserTvFragment.kt
@@ -16,7 +16,9 @@ import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat
import com.google.android.material.snackbar.Snackbar
-import kotlinx.coroutines.*
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.launch
+import kotlinx.coroutines.withContext
import org.videolan.libvlc.Dialog
import org.videolan.medialibrary.MLServiceLocator
import org.videolan.medialibrary.interfaces.Medialibrary
@@ -196,7 +198,9 @@ class FileBrowserTvFragment : BaseBrowserTvFragment<MediaLibraryItem>(), PathAda
animationDelegate.setVisibility(binding.favoriteDescription, View.VISIBLE)
favExists = (currentItem as? MediaWrapper)?.let { browserFavRepository.browserFavExists(it.uri) } ?: false
binding.favoriteButton.setImageResource(if (favExists) R.drawable.ic_favorite else R.drawable.ic_favorite_outline)
+ binding.favoriteButton.contentDescription = getString(if (favExists) R.string.favorites_remove else R.string.favorites_add)
binding.imageButtonFavorite.setImageResource(if (favExists) R.drawable.ic_fabtvmini_bookmark else R.drawable.ic_fabtvmini_bookmark_outline)
+ binding.imageButtonFavorite.contentDescription = getString(if (favExists) R.string.favorites_remove else R.string.favorites_add)
}
binding.favoriteButton.setOnClickListener(favoriteClickListener)
binding.imageButtonFavorite.setOnClickListener(favoriteClickListener)
@@ -270,7 +274,9 @@ class FileBrowserTvFragment : BaseBrowserTvFragment<MediaLibraryItem>(), PathAda
}
favExists = browserFavRepository.browserFavExists(mw.uri)
binding.favoriteButton.setImageResource(if (favExists) R.drawable.ic_favorite else R.drawable.ic_favorite_outline)
+ binding.favoriteButton.contentDescription = getString(if (favExists) R.string.favorites_remove else R.string.favorites_add)
binding.imageButtonFavorite.setImageResource(if (favExists) R.drawable.ic_fabtvmini_bookmark else R.drawable.ic_fabtvmini_bookmark_outline)
+ binding.imageButtonFavorite.contentDescription = getString(if (favExists) R.string.favorites_remove else R.string.favorites_add)
}
}
}
diff --git a/application/television/src/main/res/layout/media_browser_tv_item.xml b/application/television/src/main/res/layout/media_browser_tv_item.xml
index 7ee254861..ed52e5129 100644
--- a/application/television/src/main/res/layout/media_browser_tv_item.xml
+++ b/application/television/src/main/res/layout/media_browser_tv_item.xml
@@ -88,6 +88,7 @@
android:focusable="true"
android:longClickable="true"
android:minHeight="@dimen/audio_browser_item_size"
+ vlc:mediaContentDescription="@{item}"
android:onClick="@{holder::onClick}"
android:onLongClick="@{holder::onLongClick}"
android:paddingBottom="@dimen/kl_small"
diff --git a/application/television/src/main/res/layout/media_browser_tv_item_list.xml b/application/television/src/main/res/layout/media_browser_tv_item_list.xml
index c9afcb23b..b7a0146b4 100644
--- a/application/television/src/main/res/layout/media_browser_tv_item_list.xml
+++ b/application/television/src/main/res/layout/media_browser_tv_item_list.xml
@@ -107,6 +107,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/tv_list_background_transition"
+ vlc:mediaContentDescription="@{item}"
android:clickable="true"
android:focusable="true"
android:longClickable="true"
diff --git a/application/television/src/main/res/layout/song_browser.xml b/application/television/src/main/res/layout/song_browser.xml
index 227da2b86..ac099721b 100644
--- a/application/television/src/main/res/layout/song_browser.xml
+++ b/application/television/src/main/res/layout/song_browser.xml
@@ -97,6 +97,7 @@
android:layout_marginEnd="8dp"
android:background="@color/transparent"
android:elevation="6dp"
+ android:contentDescription="@string/sortby"
app:srcCompat="@drawable/ic_sort"
app:layout_constraintEnd_toStartOf="@+id/headerButton"
app:layout_constraintTop_toTopOf="parent" />
@@ -109,6 +110,7 @@
android:layout_marginEnd="@dimen/tv_overscan_horizontal"
android:background="@color/transparent"
android:elevation="6dp"
+ android:contentDescription="@string/jump_to"
app:srcCompat="@drawable/ic_jumptoheader"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
@@ -162,6 +164,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
+ android:contentDescription="@string/sortby"
android:elevation="6dp"
android:nextFocusDown="@id/imageButtonHeader"
app:srcCompat="@drawable/ic_fabtvmini_sort"
@@ -190,6 +193,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
+ android:contentDescription="@string/jump_to"
android:elevation="6dp"
android:nextFocusUp="@id/imageButtonSort"
android:nextFocusDown="@id/imageButtonSettings"
@@ -209,6 +213,7 @@
android:elevation="6dp"
android:nextFocusUp="@id/imageButtonHeader"
android:nextFocusForward="@id/imageButtonHeader"
+ android:contentDescription="@string/talkback_display_settings"
app:srcCompat="@drawable/ic_fabtv_preferences"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/headerListContainer" />
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 80e3db98e..abf724520 100644
--- a/application/vlc-android/src/org/videolan/vlc/util/AccessibilityHelper.kt
+++ b/application/vlc-android/src/org/videolan/vlc/util/AccessibilityHelper.kt
@@ -52,7 +52,8 @@ fun mediaDescription(v: View, media: MediaLibraryItem) {
MediaWrapper.TYPE_VIDEO -> TalkbackUtil.getVideo(v.context, media)
MediaWrapper.TYPE_AUDIO -> TalkbackUtil.getAudioTrack(v.context, media)
MediaWrapper.TYPE_STREAM -> TalkbackUtil.getStream(v.context, media)
- else -> throw NotImplementedError("")
+ MediaWrapper.TYPE_DIR, MediaWrapper.TYPE_SUBTITLE, MediaWrapper.TYPE_PLAYLIST-> TalkbackUtil.getDir(v.context, media, false)
+ else -> throw NotImplementedError("Media type not found: ${media.type}")
}
else -> throw NotImplementedError("Unknown item type")
}
More information about the Android
mailing list