summaryrefslogtreecommitdiffstats
path: root/src/android
diff options
context:
space:
mode:
authorJens Trillmann <jens.trillmann@governikus.de>2022-05-24 08:57:45 +0200
committerIvan Solovev <ivan.solovev@qt.io>2022-08-29 19:48:57 +0000
commit85378400b36879f0837c5ea6b4e8045cc547dd86 (patch)
tree0d9e67673b566dea8d350dcfc1d752deeffc7e6c /src/android
parentb5e67b1c74ee57223f638f96e439a30956983b0d (diff)
Android A11Y: Fix TalkBack scrolling behavior
* Add CollectionInfo to scrollable nodes. Every scrollable node will get a CollectionInfo attached to signal the number of (possibly invisible) children. This is necessary as TalkBack on Android doesn't scroll to items not visible on screen if the number of further child nodes is not communicated to TalkBack. * Return success of scroll to TalkBack. TalkBack needs the result of the scroll to decide if it should leave the current element or stay after a scroll was successful. Success of a scroll action is measured as the successful movement of the children of the scrolled element. This is a workaround for the Qt Accessibility API not returning the success of failure of a performed action. Task-number: QTBUG-103499 Change-Id: Ie2c51d0b77fb5030973a0f93c42e0db3082be45e Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> (cherry picked from commit 56c4d183ec30c7f40ece09de1c483829eedc299b)
Diffstat (limited to 'src/android')
-rw-r--r--src/android/jar/src/org/qtproject/qt5/android/accessibility/QtAccessibilityDelegate.java9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/android/jar/src/org/qtproject/qt5/android/accessibility/QtAccessibilityDelegate.java b/src/android/jar/src/org/qtproject/qt5/android/accessibility/QtAccessibilityDelegate.java
index da7a69db2b..82bb229b20 100644
--- a/src/android/jar/src/org/qtproject/qt5/android/accessibility/QtAccessibilityDelegate.java
+++ b/src/android/jar/src/org/qtproject/qt5/android/accessibility/QtAccessibilityDelegate.java
@@ -43,6 +43,7 @@ package org.qtproject.qt5.android.accessibility;
import android.accessibilityservice.AccessibilityService;
import android.app.Activity;
import android.graphics.Rect;
+import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
@@ -51,6 +52,7 @@ import android.view.ViewParent;
import android.text.TextUtils;
import android.view.accessibility.*;
+import android.view.accessibility.AccessibilityNodeInfo.CollectionInfo;
import android.view.MotionEvent;
import android.view.View.OnHoverListener;
@@ -435,6 +437,13 @@ public class QtAccessibilityDelegate extends View.AccessibilityDelegate
int[] ids = QtNativeAccessibility.childIdListForAccessibleObject(virtualViewId);
for (int i = 0; i < ids.length; ++i)
node.addChild(m_view, ids[i]);
+ if (node.isScrollable()) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
+ node.setCollectionInfo(new CollectionInfo(ids.length, 1, false));
+ } else {
+ node.setCollectionInfo(CollectionInfo.obtain(ids.length, 1, false));
+ }
+ }
return node;
}