Android: Unify behavior of Accessible.description with other platforms

On Windows, macOS and iOS both text and description are read out. On
Android the description is only used, when there is no name/text and
the result is used in AccessibilityNodeInfo::setContentDescription
while AccessibilityNodeInfo::setText is ignored. Using the content
description only is right, because Android will prioritize description
over text. So we need to do our own concatenation to use both.
Using ", " as separator looks like the right way, because Android use
it to separate the text from the role too. This was checked by enabling
TalkBack settings -> Advanced settings -> Developer settings -> Display
speech output.

Fixes: QTBUG-128494
Change-Id: Ib25e993ffc8614b9c9ccdc37207f2c3c496ecb1f
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
(cherry picked from commit ce101c2c3c04f5ccd46abf7024662d0bc4e5a3a3)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Lars Schmertmann 2025-06-09 12:32:11 +02:00 committed by Qt Cherry-pick Bot
parent 1e3eb1203a
commit 5564f91b6b

View File

@ -427,8 +427,12 @@ namespace QtAndroidAccessibility
if (iface && iface->isValid()) {
bool hasValue = false;
desc = iface->text(QAccessible::Name);
if (desc.isEmpty())
desc = iface->text(QAccessible::Description);
const QString descStr = iface->text(QAccessible::Description);
if (!descStr.isEmpty()) {
if (!desc.isEmpty())
desc.append(QStringLiteral(", "));
desc.append(descStr);
}
if (desc.isEmpty()) {
desc = iface->text(QAccessible::Value);
hasValue = !desc.isEmpty();