Android A11Y: Add supported role infos to A11yNodeInfo

This allows the screen reader to pick up on them and give additional
info e.g. that text links which are now added automatically since
QTBUG-67878 are clickable.

Pick-to: 6.3 6.2 5.15
Change-Id: I96d8dd628d10b26b4c9ffee15dfa01a9abef61b1
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
bb10
Mike Achtelik 2022-03-25 09:11:42 +01:00
parent 9a4c32cedd
commit ec4c6e0acb
1 changed files with 9 additions and 1 deletions

View File

@ -69,6 +69,7 @@ namespace QtAndroidAccessibility
static jmethodID m_setEnabledMethodID = 0;
static jmethodID m_setFocusableMethodID = 0;
static jmethodID m_setFocusedMethodID = 0;
static jmethodID m_setHeadingMethodID = 0;
static jmethodID m_setScrollableMethodID = 0;
static jmethodID m_setTextSelectionMethodID = 0;
static jmethodID m_setVisibleToUserMethodID = 0;
@ -461,6 +462,7 @@ if (!clazz) { \
{
bool valid = false;
QAccessible::State state;
QAccessible::Role role;
QStringList actions;
QString description;
bool hasTextSelection = false;
@ -475,6 +477,7 @@ if (!clazz) { \
if (iface && iface->isValid()) {
info.valid = true;
info.state = iface->state();
info.role = iface->role();
info.actions = QAccessibleBridgeUtils::effectiveActionNames(iface);
info.description = descriptionForInterface(iface);
QAccessibleTextInterface *textIface = iface->textInterface();
@ -518,9 +521,11 @@ if (!clazz) { \
env->CallVoidMethod(node, m_setEnabledMethodID, !info.state.disabled);
env->CallVoidMethod(node, m_setFocusableMethodID, (bool)info.state.focusable);
env->CallVoidMethod(node, m_setFocusedMethodID, (bool)info.state.focused);
if (m_setHeadingMethodID)
env->CallVoidMethod(node, m_setHeadingMethodID, info.role == QAccessible::Heading);
env->CallVoidMethod(node, m_setVisibleToUserMethodID, !info.state.invisible);
env->CallVoidMethod(node, m_setScrollableMethodID, hasIncreaseAction || hasDecreaseAction);
env->CallVoidMethod(node, m_setClickableMethodID, hasClickableAction);
env->CallVoidMethod(node, m_setClickableMethodID, hasClickableAction || info.role == QAccessible::Link);
// Add ACTION_CLICK
if (hasClickableAction)
@ -584,6 +589,9 @@ if (!clazz) { \
GET_AND_CHECK_STATIC_METHOD(m_setEnabledMethodID, nodeInfoClass, "setEnabled", "(Z)V");
GET_AND_CHECK_STATIC_METHOD(m_setFocusableMethodID, nodeInfoClass, "setFocusable", "(Z)V");
GET_AND_CHECK_STATIC_METHOD(m_setFocusedMethodID, nodeInfoClass, "setFocused", "(Z)V");
if (QtAndroidPrivate::androidSdkVersion() >= 28) {
GET_AND_CHECK_STATIC_METHOD(m_setHeadingMethodID, nodeInfoClass, "setHeading", "(Z)V");
}
GET_AND_CHECK_STATIC_METHOD(m_setScrollableMethodID, nodeInfoClass, "setScrollable", "(Z)V");
GET_AND_CHECK_STATIC_METHOD(m_setVisibleToUserMethodID, nodeInfoClass, "setVisibleToUser", "(Z)V");
GET_AND_CHECK_STATIC_METHOD(m_setTextSelectionMethodID, nodeInfoClass, "setTextSelection", "(II)V");