summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/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/plugins/platforms/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/plugins/platforms/android')
-rw-r--r--src/plugins/platforms/android/androidjniaccessibility.cpp28
1 files changed, 24 insertions, 4 deletions
diff --git a/src/plugins/platforms/android/androidjniaccessibility.cpp b/src/plugins/platforms/android/androidjniaccessibility.cpp
index ba58ec7cc6..78517e845e 100644
--- a/src/plugins/platforms/android/androidjniaccessibility.cpp
+++ b/src/plugins/platforms/android/androidjniaccessibility.cpp
@@ -228,7 +228,7 @@ namespace QtAndroidAccessibility
return result;
}
- static QRect screenRect_helper(int objectId)
+ static QRect screenRect_helper(int objectId, bool clip = true)
{
QRect rect;
QAccessibleInterface *iface = interfaceFromId(objectId);
@@ -236,7 +236,7 @@ namespace QtAndroidAccessibility
rect = QHighDpi::toNativePixels(iface->rect(), iface->window());
}
// If the widget is not fully in-bound in its parent then we have to clip the rectangle to draw
- if (iface && iface->parent() && iface->parent()->isValid()) {
+ if (clip && iface && iface->parent() && iface->parent()->isValid()) {
const auto parentRect = QHighDpi::toNativePixels(iface->parent()->rect(), iface->parent()->window());
rect = rect.intersected(parentRect);
}
@@ -338,23 +338,43 @@ namespace QtAndroidAccessibility
static jboolean scrollForward(JNIEnv */*env*/, jobject /*thiz*/, jint objectId)
{
bool result = false;
+
+ const auto& ids = childIdListForAccessibleObject_helper(objectId);
+ if (ids.isEmpty())
+ return false;
+
+ const int firstChildId = ids.first();
+ const QRect oldPosition = screenRect_helper(firstChildId, false);
+
if (m_accessibilityContext) {
runInObjectContext(m_accessibilityContext, [objectId]() {
return scroll_helper(objectId, QAccessibleActionInterface::increaseAction());
}, &result);
}
- return result;
+
+ // Don't check for position change if the call was not successful
+ return result && oldPosition != screenRect_helper(firstChildId, false);
}
static jboolean scrollBackward(JNIEnv */*env*/, jobject /*thiz*/, jint objectId)
{
bool result = false;
+
+ const auto& ids = childIdListForAccessibleObject_helper(objectId);
+ if (ids.isEmpty())
+ return false;
+
+ const int firstChildId = ids.first();
+ const QRect oldPosition = screenRect_helper(firstChildId, false);
+
if (m_accessibilityContext) {
runInObjectContext(m_accessibilityContext, [objectId]() {
return scroll_helper(objectId, QAccessibleActionInterface::decreaseAction());
}, &result);
}
- return result;
+
+ // Don't check for position change if the call was not successful
+ return result && oldPosition != screenRect_helper(firstChildId, false);
}