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

Commit aacbf911 authored by Svetoslav Ganov's avatar Svetoslav Ganov Committed by Android (Google) Code Review
Browse files

Merge "Not visible view should not be announced or interacted with."

parents e68c676b 0b0a41d8
Loading
Loading
Loading
Loading
+16 −13
Original line number Diff line number Diff line
@@ -4543,7 +4543,7 @@ public final class ViewRootImpl extends Handler implements ViewParent,
                predicate.init(accessibilityId);
                View root = ViewRootImpl.this.mView;
                View target = root.findViewByPredicate(predicate);
                if (target != null && target.isShown()) {
                if (target != null && target.getVisibility() == View.VISIBLE) {
                    info = target.createAccessibilityNodeInfo();
                }
            } finally {
@@ -4586,7 +4586,7 @@ public final class ViewRootImpl extends Handler implements ViewParent,
            try {
                View root = ViewRootImpl.this.mView;
                View target = root.findViewById(viewId);
                if (target != null && target.isShown()) {
                if (target != null && target.getVisibility() == View.VISIBLE) {
                    info = target.createAccessibilityNodeInfo();
                }
            } finally {
@@ -4637,14 +4637,14 @@ public final class ViewRootImpl extends Handler implements ViewParent,
                ArrayList<View> foundViews = mAttachInfo.mFocusablesTempList;
                foundViews.clear();

                View root;
                View root = null;
                if (accessibilityViewId != View.NO_ID) {
                    root = findViewByAccessibilityId(accessibilityViewId);
                } else {
                    root = ViewRootImpl.this.mView;
                }

                if (root == null || !root.isShown()) {
                if (root == null || root.getVisibility() != View.VISIBLE) {
                    return;
                }

@@ -4659,7 +4659,7 @@ public final class ViewRootImpl extends Handler implements ViewParent,
                final int viewCount = foundViews.size();
                for (int i = 0; i < viewCount; i++) {
                    View foundView = foundViews.get(i);
                    if (foundView.isShown()) {
                    if (foundView.getVisibility() == View.VISIBLE) {
                        infos.add(foundView.createAccessibilityNodeInfo());
                    }
                 }
@@ -4732,7 +4732,7 @@ public final class ViewRootImpl extends Handler implements ViewParent,

        private boolean performActionFocus(int accessibilityId) {
            View target = findViewByAccessibilityId(accessibilityId);
            if (target == null) {
            if (target == null || target.getVisibility() != View.VISIBLE) {
                return false;
            }
            // Get out of touch mode since accessibility wants to move focus around.
@@ -4742,7 +4742,7 @@ public final class ViewRootImpl extends Handler implements ViewParent,

        private boolean performActionClearFocus(int accessibilityId) {
            View target = findViewByAccessibilityId(accessibilityId);
            if (target == null) {
            if (target == null || target.getVisibility() != View.VISIBLE) {
                return false;
            }
            if (!target.isFocused()) {
@@ -4754,7 +4754,7 @@ public final class ViewRootImpl extends Handler implements ViewParent,

        private boolean performActionSelect(int accessibilityId) {
            View target = findViewByAccessibilityId(accessibilityId);
            if (target == null) {
            if (target == null || target.getVisibility() != View.VISIBLE) {
                return false;
            }
            if (target.isSelected()) {
@@ -4766,7 +4766,7 @@ public final class ViewRootImpl extends Handler implements ViewParent,

        private boolean performActionClearSelection(int accessibilityId) {
            View target = findViewByAccessibilityId(accessibilityId);
            if (target == null) {
            if (target == null || target.getVisibility() != View.VISIBLE) {
                return false;
            }
            if (!target.isSelected()) {
@@ -4783,18 +4783,21 @@ public final class ViewRootImpl extends Handler implements ViewParent,
            }
            mFindByAccessibilityIdPredicate.init(accessibilityId);
            View foundView = root.findViewByPredicate(mFindByAccessibilityIdPredicate);
            return (foundView != null && foundView.isShown()) ? foundView : null;
            if (foundView == null || foundView.getVisibility() != View.VISIBLE) {
                return null;
            }
            return foundView;
        }

        private final class FindByAccessibilitytIdPredicate implements Predicate<View> {
            public int mSerchedId;
            public int mSearchedId;

            public void init(int searchedId) {
                mSerchedId = searchedId;
                mSearchedId = searchedId;
            }

            public boolean apply(View view) {
                return (view.getAccessibilityViewId() == mSerchedId);
                return (view.getAccessibilityViewId() == mSearchedId);
            }
        }
    }
+6 −7
Original line number Diff line number Diff line
@@ -886,9 +886,11 @@ public abstract class AdapterView<T extends Adapter> extends ViewGroup {
            event.setEventType(AccessibilityEvent.TYPE_VIEW_SELECTED);
        }

        View selectedView = getSelectedView();
        if (selectedView != null && selectedView.getVisibility() == VISIBLE) {
            // We first get a chance to populate the event.
            onPopulateAccessibilityEvent(event);

        }
        return false;
    }

@@ -896,10 +898,7 @@ public abstract class AdapterView<T extends Adapter> extends ViewGroup {
    public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
        // We send selection events only from AdapterView to avoid
        // generation of such event for each child.
        View selectedView = getSelectedView();
        if (selectedView != null) {
            selectedView.dispatchPopulateAccessibilityEvent(event);
        }
        getSelectedView().dispatchPopulateAccessibilityEvent(event);
    }

    @Override
+2 −1
Original line number Diff line number Diff line
@@ -961,7 +961,8 @@ public class RelativeLayout extends ViewGroup {
        }

        for (View view : mTopToBottomLeftToRightSet) {
            if (view.dispatchPopulateAccessibilityEvent(event)) {
            if (view.getVisibility() == View.VISIBLE
                    && view.dispatchPopulateAccessibilityEvent(event)) {
                mTopToBottomLeftToRightSet.clear();
                return true;
            }
+4 −1
Original line number Diff line number Diff line
@@ -405,7 +405,10 @@ public class TabWidget extends LinearLayout implements OnFocusChangeListener {
        onPopulateAccessibilityEvent(event);
        // Dispatch only to the selected tab.
        if (mSelectedTab != -1) {
            return getChildTabViewAt(mSelectedTab).dispatchPopulateAccessibilityEvent(event);
            View tabView = getChildTabViewAt(mSelectedTab);
            if (tabView != null && tabView.getVisibility() == VISIBLE) {
                return tabView.dispatchPopulateAccessibilityEvent(event);
            }
        }
        return false;
    }