Android A11Y: Add content change type to content change event
This fixes a problem where the accessibility tree is not correctly updated, when using e.g. a StackView. The problem was, that sometimes when pushing items of the previous view where still selectable via TalkBack. When popping this sometimes lead to some views not being selectable because the subtree wasn't updated. To solve this, lets tell android directly that the subtree changed when invalidating a view. Fixes: QTBUG-102825 Pick-to: 6.4 6.3 6.2 5.15 Change-Id: Ifbf8da1b95f02935b9bcffabfe821547b1128103 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
This commit is contained in:
parent
49d2944045
commit
d48ebb02fb
@ -227,10 +227,14 @@ public class QtAccessibilityDelegate extends View.AccessibilityDelegate
|
||||
|
||||
public boolean sendEventForVirtualViewId(int virtualViewId, int eventType)
|
||||
{
|
||||
if ((virtualViewId == INVALID_ID) || !m_manager.isEnabled()) {
|
||||
Log.w(TAG, "sendEventForVirtualViewId for invalid view");
|
||||
final AccessibilityEvent event = getEventForVirtualViewId(virtualViewId, eventType);
|
||||
return sendAccessibilityEvent(event);
|
||||
}
|
||||
|
||||
public boolean sendAccessibilityEvent(AccessibilityEvent event)
|
||||
{
|
||||
if (event == null)
|
||||
return false;
|
||||
}
|
||||
|
||||
final ViewGroup group = (ViewGroup) m_view.getParent();
|
||||
if (group == null) {
|
||||
@ -238,15 +242,18 @@ public class QtAccessibilityDelegate extends View.AccessibilityDelegate
|
||||
return false;
|
||||
}
|
||||
|
||||
final AccessibilityEvent event;
|
||||
event = getEventForVirtualViewId(virtualViewId, eventType);
|
||||
return group.requestSendAccessibilityEvent(m_view, event);
|
||||
}
|
||||
|
||||
public void invalidateVirtualViewId(int virtualViewId)
|
||||
{
|
||||
if (virtualViewId != INVALID_ID)
|
||||
sendEventForVirtualViewId(virtualViewId, AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED);
|
||||
final AccessibilityEvent event = getEventForVirtualViewId(virtualViewId, AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED);
|
||||
|
||||
if (event == null)
|
||||
return;
|
||||
|
||||
event.setContentChangeTypes(AccessibilityEvent.CONTENT_CHANGE_TYPE_SUBTREE);
|
||||
sendAccessibilityEvent(event);
|
||||
}
|
||||
|
||||
private void setHoveredVirtualViewId(int virtualViewId)
|
||||
@ -263,6 +270,11 @@ public class QtAccessibilityDelegate extends View.AccessibilityDelegate
|
||||
|
||||
private AccessibilityEvent getEventForVirtualViewId(int virtualViewId, int eventType)
|
||||
{
|
||||
if ((virtualViewId == INVALID_ID) || !m_manager.isEnabled()) {
|
||||
Log.w(TAG, "getEventForVirtualViewId for invalid view");
|
||||
return null;
|
||||
}
|
||||
|
||||
final AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
|
||||
|
||||
event.setEnabled(true);
|
||||
|
Loading…
Reference in New Issue
Block a user