Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 57da8570 authored by Yuri Schimke's avatar Yuri Schimke
Browse files

Update Remote Compose Platform A11y handler

Includes some recent improvements and a critical NPE fix from
the Androidx equivalent.

Bug: 403275243
Flag: EXEMPT External Libraries
Test: in GoB
Change-Id: Ie010c72e38a685313043cbf82b47136cb8bd9226
parent 200ec468
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -88,13 +88,14 @@ public class AndroidPlatformSemanticNodeApplier

    @Override
    protected void setBoundsInScreen(AccessibilityNodeInfo nodeInfo, Rect bounds) {
        nodeInfo.setBoundsInParent(bounds);
        nodeInfo.setBoundsInParent(new Rect(0, 0, 1, 1));
        nodeInfo.setBoundsInScreen(bounds);
    }

    @Override
    protected void setUniqueId(AccessibilityNodeInfo nodeInfo, String id) {
        nodeInfo.setUniqueId(id);
        nodeInfo.setSource(mPlayer, Integer.parseInt(id));
    }

    @Override
@@ -143,6 +144,7 @@ public class AndroidPlatformSemanticNodeApplier
        if (scrollDirection == RootContentBehavior.SCROLL_HORIZONTAL) {
            nodeInfo.setClassName("android.widget.HorizontalScrollView");
        } else {
            nodeInfo.setCollectionInfo(AccessibilityNodeInfo.CollectionInfo.obtain(-1, 1, false));
            nodeInfo.setClassName("android.widget.ScrollView");
        }
    }
+11 −7
Original line number Diff line number Diff line
@@ -94,19 +94,23 @@ public class PlatformRemoteComposeTouchHelper extends ExploreByTouchHelper {
     * @param virtualViewIds The list to be populated with the visible virtual view IDs.
     */
    @Override
    protected void getVisibleVirtualViews(IntArray virtualViewIds) {
    public void getVisibleVirtualViews(IntArray virtualViewIds) {
        List<Integer> children = getVisibleChildVirtualViews();
        for (int child : children) {
            virtualViewIds.add(child);
        }
    }

    @SuppressWarnings("JdkImmutableCollections")
    public List<Integer> getVisibleChildVirtualViews() {
        Component rootComponent = mRemoteDocA11y.findComponentById(RootId);

        if (rootComponent == null
                || !mRemoteDocA11y.semanticModifiersForComponent(rootComponent).isEmpty()) {
            virtualViewIds.add(RootId);
            return List.of(RootId);
        }

        List<Integer> children =
                mRemoteDocA11y.semanticallyRelevantChildComponents(rootComponent, false);
        for (int child : children) {
            virtualViewIds.add(child);
        }
        return mRemoteDocA11y.semanticallyRelevantChildComponents(rootComponent, false);
    }

    @Override