[Android] Accessibility: improve talkback for the video player
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 08:17:16 2022 +0200| [6157ea403e052c6e50b2576bccf136c47de2810a] | committer: Nicolas Pomepuy
Accessibility: improve talkback for the video player
> https://code.videolan.org/videolan/vlc-android/commit/6157ea403e052c6e50b2576bccf136c47de2810a
---
application/resources/src/main/res/values/strings.xml | 2 ++
application/vlc-android/res/layout/player.xml | 2 ++
application/vlc-android/res/layout/player_hud.xml | 5 ++++-
.../src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt | 1 +
.../videolan/vlc/gui/video/VideoPlayerOverlayDelegate.kt | 13 +++++++++----
5 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/application/resources/src/main/res/values/strings.xml b/application/resources/src/main/res/values/strings.xml
index 4aa258076..d4c083288 100644
--- a/application/resources/src/main/res/values/strings.xml
+++ b/application/resources/src/main/res/values/strings.xml
@@ -1001,6 +1001,8 @@
<string name="talkback_enter_screen">Navigate to %s</string>
<string name="talkback_file_size">File size: %s</string>
<string name="talkback_open_in_browser">Open in web browser</string>
+ <string name="talkback_video_player">Video player. Tap to show controls. Tap the back button to hide them</string>
+
</resources>
diff --git a/application/vlc-android/res/layout/player.xml b/application/vlc-android/res/layout/player.xml
index 7fa95bbc8..00a9da399 100644
--- a/application/vlc-android/res/layout/player.xml
+++ b/application/vlc-android/res/layout/player.xml
@@ -5,6 +5,8 @@
android:id="@+id/player_root"
android:layout_width="match_parent"
android:layout_height="match_parent"
+ android:importantForAccessibility="yes"
+ android:contentDescription="@string/talkback_video_player"
android:keepScreenOn="true">
<!--
diff --git a/application/vlc-android/res/layout/player_hud.xml b/application/vlc-android/res/layout/player_hud.xml
index 2aa1df13f..fb5935f69 100644
--- a/application/vlc-android/res/layout/player_hud.xml
+++ b/application/vlc-android/res/layout/player_hud.xml
@@ -188,6 +188,7 @@
android:id="@+id/player_overlay_time"
style="@style/VLC.Player.TimeText"
android:layout_width="0dp"
+ android:importantForAccessibility="no"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:background="?attr/selectableItemBackground"
@@ -207,8 +208,9 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="24dp"
- android:background="?attr/selectableItemBackground"
android:gravity="right"
+ android:importantForAccessibility="no"
+ android:background="?attr/selectableItemBackgroundBorderless"
android:nextFocusUp="@+id/ab_repeat_add_marker"
android:onClick="@{(v) -> player.toggleTimeDisplay()}"
tools:text="56:37"
@@ -229,6 +231,7 @@
android:minHeight="@dimen/seekbar_height"
android:paddingStart="0dp"
android:paddingEnd="0dp"
+ android:importantForAccessibility="no"
android:progress="@{player.service.getTime(progress.time)}"
android:progressDrawable="@drawable/po_seekbar_video"
android:splitTrack="false"
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt
index f45eb2116..9a6f78371 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt
@@ -2165,6 +2165,7 @@ open class VideoPlayerActivity : AppCompatActivity(), PlaybackService.Callback,
service.playlistManager.waitForConfirmation.observe(this) {
if (it != null) showConfirmResumeDialog(it)
}
+ //if (isTalkbackIsEnabled()) overlayDelegate.showOverlayTimeout(OVERLAY_INFINITE)
} else if (this.service != null) {
this.service?.removeCallback(this)
this.service = null
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 b6e3b04c8..5c5f68b28 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
@@ -35,8 +35,12 @@ import android.view.Gravity
import android.view.View
import android.view.ViewGroup
import android.view.WindowManager
+import android.view.accessibility.AccessibilityEvent
import android.view.animation.AnimationUtils
-import android.widget.*
+import android.widget.Button
+import android.widget.FrameLayout
+import android.widget.ImageView
+import android.widget.TextView
import androidx.annotation.StringRes
import androidx.appcompat.content.res.AppCompatResources
import androidx.appcompat.widget.ViewStubCompat
@@ -75,10 +79,8 @@ import org.videolan.vlc.gui.helpers.UiTools.showVideoTrack
import org.videolan.vlc.gui.view.PlayerProgress
import org.videolan.vlc.manageAbRepeatStep
import org.videolan.vlc.media.MediaUtils
+import org.videolan.vlc.util.*
import org.videolan.vlc.util.FileUtils
-import org.videolan.vlc.util.getScreenWidth
-import org.videolan.vlc.util.isSchemeFile
-import org.videolan.vlc.util.isSchemeNetwork
import org.videolan.vlc.viewmodels.PlaylistModel
import java.text.DateFormat
import java.util.*
@@ -393,6 +395,7 @@ class VideoPlayerOverlayDelegate (private val player: VideoPlayerActivity) {
initOverlay()
if (!::hudBinding.isInitialized) return
overlayTimeout = when {
+ player.isTalkbackIsEnabled() -> VideoPlayerActivity.OVERLAY_INFINITE
Settings.videoHudDelay == 0 -> VideoPlayerActivity.OVERLAY_INFINITE
isBookmarkShown() -> VideoPlayerActivity.OVERLAY_INFINITE
timeout != 0 -> timeout
@@ -416,6 +419,7 @@ class VideoPlayerOverlayDelegate (private val player: VideoPlayerActivity) {
enterAnimate(arrayOf(hudBinding.progressOverlay, hudBackground), 100.dp.toFloat()) {
if (overlayTimeout != VideoPlayerActivity.OVERLAY_INFINITE)
player.handler.sendMessageDelayed(player.handler.obtainMessage(VideoPlayerActivity.FADE_OUT), overlayTimeout.toLong())
+ hudBinding.playerOverlayPlay.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED)
}
enterAnimate(arrayOf(hudRightBinding.hudRightOverlay, hudRightBackground), -100.dp.toFloat())
@@ -838,6 +842,7 @@ class VideoPlayerOverlayDelegate (private val player: VideoPlayerActivity) {
* hider overlay
*/
fun hideOverlay(fromUser: Boolean) {
+ if (!fromUser && player.isTalkbackIsEnabled()) return
if (player.isShowing) {
if (isBookmarkShown()) hideBookmarks()
player.handler.removeMessages(VideoPlayerActivity.FADE_OUT)
More information about the Android
mailing list