[Android] Accessibility: improve talkback for bookmarks
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 May 25 14:34:27 2022 +0200| [0156da892313de969d7a046a2cff593e14ab8677] | committer: Nicolas Pomepuy
Accessibility: improve talkback for bookmarks
> https://code.videolan.org/videolan/vlc-android/commit/0156da892313de969d7a046a2cff593e14ab8677
---
application/vlc-android/res/layout/bookmark_item.xml | 4 ++++
application/vlc-android/res/layout/bookmarks.xml | 2 ++
.../src/org/videolan/vlc/gui/helpers/BookmarkListDelegate.kt | 9 +++++++--
.../src/org/videolan/vlc/gui/video/VideoPlayerOverlayDelegate.kt | 5 ++++-
4 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/application/vlc-android/res/layout/bookmark_item.xml b/application/vlc-android/res/layout/bookmark_item.xml
index 74bb7792f..d70628892 100644
--- a/application/vlc-android/res/layout/bookmark_item.xml
+++ b/application/vlc-android/res/layout/bookmark_item.xml
@@ -9,6 +9,7 @@
<import type="android.text.TextUtils" />
<import type="org.videolan.medialibrary.Tools" />
+ <import type="org.videolan.vlc.gui.helpers.TalkbackUtil" />
<variable
name="holder"
@@ -41,6 +42,7 @@
android:orientation="vertical"
android:paddingTop="4dp"
android:paddingBottom="4dp"
+ android:importantForAccessibility="no"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/item_more"
app:layout_constraintStart_toStartOf="parent"
@@ -79,6 +81,7 @@
android:fontFamily="sans-serif-medium"
android:singleLine="true"
android:text="@{Tools.millisToString(bookmark.time)}"
+ android:contentDescription="@{TalkbackUtil.INSTANCE.millisToString(context, bookmark.time)}"
android:textColor="?attr/font_audio_light"
android:textSize="12sp"
app:layout_constraintBottom_toBottomOf="parent"
@@ -95,6 +98,7 @@
android:layout_centerVertical="true"
android:layout_gravity="center"
android:layout_marginRight="4dp"
+ android:contentDescription="@string/more_actions"
android:background="?attr/selectableItemBackgroundBorderless"
android:onClick="@{(view) -> holder.onMoreClick(view, bookmark)}"
android:scaleType="center"
diff --git a/application/vlc-android/res/layout/bookmarks.xml b/application/vlc-android/res/layout/bookmarks.xml
index 9651c33d2..fe671a431 100644
--- a/application/vlc-android/res/layout/bookmarks.xml
+++ b/application/vlc-android/res/layout/bookmarks.xml
@@ -25,6 +25,7 @@
android:clickable="true"
android:focusable="true"
android:padding="8dp"
+ android:contentDescription="@string/close"
android:nextFocusRight="@+id/add_bookmark"
app:layout_constraintBottom_toBottomOf="@+id/top_bar"
app:layout_constraintEnd_toStartOf="@+id/title"
@@ -54,6 +55,7 @@
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:background="?attr/actionBarItemBackground"
+ android:contentDescription="@string/add_bookmark"
android:clickable="true"
android:focusable="true"
android:padding="8dp"
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/helpers/BookmarkListDelegate.kt b/application/vlc-android/src/org/videolan/vlc/gui/helpers/BookmarkListDelegate.kt
index 2fb29953a..8f3d03b01 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/helpers/BookmarkListDelegate.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/helpers/BookmarkListDelegate.kt
@@ -48,8 +48,9 @@ import org.videolan.vlc.gui.dialogs.RenameDialog
import org.videolan.vlc.viewmodels.BookmarkModel
class BookmarkListDelegate(val activity: FragmentActivity, val service: PlaybackService, private val bookmarkModel: BookmarkModel) :
- LifecycleObserver, BookmarkAdapter.IBookmarkManager {
+ LifecycleObserver, BookmarkAdapter.IBookmarkManager {
+ lateinit var addBookmarButton: ImageView
lateinit var markerContainer: ConstraintLayout
private lateinit var adapter: BookmarkAdapter
lateinit var bookmarkList: RecyclerView
@@ -64,7 +65,11 @@ class BookmarkListDelegate(val activity: FragmentActivity, val service: Playback
rootView = it.inflate() as ConstraintLayout
bookmarkList = rootView.findViewById(R.id.bookmark_list)
rootView.findViewById<ImageView>(R.id.close).setOnClickListener { hide() }
- rootView.findViewById<ImageView>(R.id.add_bookmark).setOnClickListener { bookmarkModel.addBookmark(activity) }
+ addBookmarButton = rootView.findViewById<ImageView>(R.id.add_bookmark)
+ addBookmarButton.setOnClickListener {
+ bookmarkModel.addBookmark(activity)
+ addBookmarButton.announceForAccessibility(activity.getString(R.string.bookmark_added))
+ }
rootView.findViewById<View>(R.id.top_bar).setOnTouchListener { v, _ ->
v.parent.requestDisallowInterceptTouchEvent(true)
true
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerOverlayDelegate.kt b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerOverlayDelegate.kt
index c5262aacc..b94e25573 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerOverlayDelegate.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerOverlayDelegate.kt
@@ -418,6 +418,10 @@ class VideoPlayerOverlayDelegate (private val player: VideoPlayerActivity) {
if (overlayTimeout != VideoPlayerActivity.OVERLAY_INFINITE)
player.handler.sendMessageDelayed(player.handler.obtainMessage(VideoPlayerActivity.FADE_OUT), overlayTimeout.toLong())
hudBinding.playerOverlayPlay.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED)
+ if (isBookmarkShown())try {
+ if (player.isTalkbackIsEnabled()) bookmarkListDelegate.addBookmarButton.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED)
+ } catch (e: Exception) {
+ }
}
enterAnimate(arrayOf(hudRightBinding.hudRightOverlay, hudRightBackground), -100.dp.toFloat())
@@ -432,7 +436,6 @@ class VideoPlayerOverlayDelegate (private val player: VideoPlayerActivity) {
player.handler.sendMessageDelayed(player.handler.obtainMessage(VideoPlayerActivity.FADE_OUT), overlayTimeout.toLong())
}
player.handler.removeMessages(VideoPlayerActivity.FADE_OUT)
-
}
}
More information about the Android
mailing list