[Android] Accessibility: fix the video player root view selection and announcement
Nicolas Pomepuy
git at videolan.org
Fri Jun 3 11:30:22 UTC 2022
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Fri Jun 3 07:45:21 2022 +0200| [43066f47de77d9aface2384c935dca9744b4343a] | committer: Nicolas Pomepuy
Accessibility: fix the video player root view selection and announcement
Fixes an issue where the video player root view is selected and announced
every now and then. It was triggered by the AccessibleSeekBar custom
accessibility delegate.
> https://code.videolan.org/videolan/vlc-android/commit/43066f47de77d9aface2384c935dca9744b4343a
---
.../videolan/vlc/gui/video/VideoPlayerOverlayDelegate.kt | 1 +
.../src/org/videolan/vlc/gui/view/AccessibleSeekBar.kt | 14 ++++++++++++++
2 files changed, 15 insertions(+)
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 b8fde2ba9..f36fc0f05 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
@@ -842,6 +842,7 @@ class VideoPlayerOverlayDelegate (private val player: VideoPlayerActivity) {
hudRightBinding.audioDelayQuickAction.text = "${(player.service?.audioDelay ?: 0L) / 1000L} ms"
}
+ if (!show) hudBinding.playerOverlaySeekbar.disableAccessibilityEvents() else hudBinding.playerOverlaySeekbar.enableAccessibilityEvents()
}
/**
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/view/AccessibleSeekBar.kt b/application/vlc-android/src/org/videolan/vlc/gui/view/AccessibleSeekBar.kt
index 311e8de21..46a72feb7 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/view/AccessibleSeekBar.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/view/AccessibleSeekBar.kt
@@ -20,6 +20,7 @@ class AccessibleSeekBar : AppCompatSeekBar {
field = value
if( value) sendAccessibilityEventUnchecked(this at AccessibleSeekBar, AccessibilityEvent.obtain().apply { eventType = AccessibilityEvent.TYPE_VIEW_SELECTED })
}
+ var disabled = true
/**
@@ -32,6 +33,10 @@ class AccessibleSeekBar : AppCompatSeekBar {
* @param event the accessibility event to send
*/
override fun sendAccessibilityEventUnchecked(host: View?, event: AccessibilityEvent) {
+ if (disabled) {
+ super.sendAccessibilityEventUnchecked(host, event)
+ return
+ }
if (BuildConfig.DEBUG) Log.d(this::class.java.simpleName, "sendAccessibilityEventUnchecked: ${event.eventType}")
contentDescription = context.getString(R.string.talkback_out_of, TalkbackUtil.millisToString(context, progress.toLong()), TalkbackUtil.millisToString(context, max.toLong()) )
if (event.eventType != AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED
@@ -62,9 +67,18 @@ class AccessibleSeekBar : AppCompatSeekBar {
}
fun forceAccessibilityUpdate() {
+ if (BuildConfig.DEBUG) Log.d(this::class.java.simpleName, "forceAccessibilityUpdate", Exception("Give me a stack"))
customAccessibilityDelegate.force = true
}
+ fun disableAccessibilityEvents() {
+ customAccessibilityDelegate.disabled = true
+ }
+
+ fun enableAccessibilityEvents() {
+ customAccessibilityDelegate.disabled = false
+ }
+
More information about the Android
mailing list