Merge "Not visible view should not be announced or interacted with."
This commit is contained in:
committed by
Android (Google) Code Review
commit
aacbf9111b
@@ -4543,7 +4543,7 @@ public final class ViewRootImpl extends Handler implements ViewParent,
|
|||||||
predicate.init(accessibilityId);
|
predicate.init(accessibilityId);
|
||||||
View root = ViewRootImpl.this.mView;
|
View root = ViewRootImpl.this.mView;
|
||||||
View target = root.findViewByPredicate(predicate);
|
View target = root.findViewByPredicate(predicate);
|
||||||
if (target != null && target.isShown()) {
|
if (target != null && target.getVisibility() == View.VISIBLE) {
|
||||||
info = target.createAccessibilityNodeInfo();
|
info = target.createAccessibilityNodeInfo();
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
@@ -4586,7 +4586,7 @@ public final class ViewRootImpl extends Handler implements ViewParent,
|
|||||||
try {
|
try {
|
||||||
View root = ViewRootImpl.this.mView;
|
View root = ViewRootImpl.this.mView;
|
||||||
View target = root.findViewById(viewId);
|
View target = root.findViewById(viewId);
|
||||||
if (target != null && target.isShown()) {
|
if (target != null && target.getVisibility() == View.VISIBLE) {
|
||||||
info = target.createAccessibilityNodeInfo();
|
info = target.createAccessibilityNodeInfo();
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
@@ -4637,14 +4637,14 @@ public final class ViewRootImpl extends Handler implements ViewParent,
|
|||||||
ArrayList<View> foundViews = mAttachInfo.mFocusablesTempList;
|
ArrayList<View> foundViews = mAttachInfo.mFocusablesTempList;
|
||||||
foundViews.clear();
|
foundViews.clear();
|
||||||
|
|
||||||
View root;
|
View root = null;
|
||||||
if (accessibilityViewId != View.NO_ID) {
|
if (accessibilityViewId != View.NO_ID) {
|
||||||
root = findViewByAccessibilityId(accessibilityViewId);
|
root = findViewByAccessibilityId(accessibilityViewId);
|
||||||
} else {
|
} else {
|
||||||
root = ViewRootImpl.this.mView;
|
root = ViewRootImpl.this.mView;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (root == null || !root.isShown()) {
|
if (root == null || root.getVisibility() != View.VISIBLE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4659,7 +4659,7 @@ public final class ViewRootImpl extends Handler implements ViewParent,
|
|||||||
final int viewCount = foundViews.size();
|
final int viewCount = foundViews.size();
|
||||||
for (int i = 0; i < viewCount; i++) {
|
for (int i = 0; i < viewCount; i++) {
|
||||||
View foundView = foundViews.get(i);
|
View foundView = foundViews.get(i);
|
||||||
if (foundView.isShown()) {
|
if (foundView.getVisibility() == View.VISIBLE) {
|
||||||
infos.add(foundView.createAccessibilityNodeInfo());
|
infos.add(foundView.createAccessibilityNodeInfo());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4732,7 +4732,7 @@ public final class ViewRootImpl extends Handler implements ViewParent,
|
|||||||
|
|
||||||
private boolean performActionFocus(int accessibilityId) {
|
private boolean performActionFocus(int accessibilityId) {
|
||||||
View target = findViewByAccessibilityId(accessibilityId);
|
View target = findViewByAccessibilityId(accessibilityId);
|
||||||
if (target == null) {
|
if (target == null || target.getVisibility() != View.VISIBLE) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Get out of touch mode since accessibility wants to move focus around.
|
// 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) {
|
private boolean performActionClearFocus(int accessibilityId) {
|
||||||
View target = findViewByAccessibilityId(accessibilityId);
|
View target = findViewByAccessibilityId(accessibilityId);
|
||||||
if (target == null) {
|
if (target == null || target.getVisibility() != View.VISIBLE) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!target.isFocused()) {
|
if (!target.isFocused()) {
|
||||||
@@ -4754,7 +4754,7 @@ public final class ViewRootImpl extends Handler implements ViewParent,
|
|||||||
|
|
||||||
private boolean performActionSelect(int accessibilityId) {
|
private boolean performActionSelect(int accessibilityId) {
|
||||||
View target = findViewByAccessibilityId(accessibilityId);
|
View target = findViewByAccessibilityId(accessibilityId);
|
||||||
if (target == null) {
|
if (target == null || target.getVisibility() != View.VISIBLE) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (target.isSelected()) {
|
if (target.isSelected()) {
|
||||||
@@ -4766,7 +4766,7 @@ public final class ViewRootImpl extends Handler implements ViewParent,
|
|||||||
|
|
||||||
private boolean performActionClearSelection(int accessibilityId) {
|
private boolean performActionClearSelection(int accessibilityId) {
|
||||||
View target = findViewByAccessibilityId(accessibilityId);
|
View target = findViewByAccessibilityId(accessibilityId);
|
||||||
if (target == null) {
|
if (target == null || target.getVisibility() != View.VISIBLE) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!target.isSelected()) {
|
if (!target.isSelected()) {
|
||||||
@@ -4783,18 +4783,21 @@ public final class ViewRootImpl extends Handler implements ViewParent,
|
|||||||
}
|
}
|
||||||
mFindByAccessibilityIdPredicate.init(accessibilityId);
|
mFindByAccessibilityIdPredicate.init(accessibilityId);
|
||||||
View foundView = root.findViewByPredicate(mFindByAccessibilityIdPredicate);
|
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> {
|
private final class FindByAccessibilitytIdPredicate implements Predicate<View> {
|
||||||
public int mSerchedId;
|
public int mSearchedId;
|
||||||
|
|
||||||
public void init(int searchedId) {
|
public void init(int searchedId) {
|
||||||
mSerchedId = searchedId;
|
mSearchedId = searchedId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean apply(View view) {
|
public boolean apply(View view) {
|
||||||
return (view.getAccessibilityViewId() == mSerchedId);
|
return (view.getAccessibilityViewId() == mSearchedId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -886,9 +886,11 @@ public abstract class AdapterView<T extends Adapter> extends ViewGroup {
|
|||||||
event.setEventType(AccessibilityEvent.TYPE_VIEW_SELECTED);
|
event.setEventType(AccessibilityEvent.TYPE_VIEW_SELECTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
// We first get a chance to populate the event.
|
View selectedView = getSelectedView();
|
||||||
onPopulateAccessibilityEvent(event);
|
if (selectedView != null && selectedView.getVisibility() == VISIBLE) {
|
||||||
|
// We first get a chance to populate the event.
|
||||||
|
onPopulateAccessibilityEvent(event);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -896,10 +898,7 @@ public abstract class AdapterView<T extends Adapter> extends ViewGroup {
|
|||||||
public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
|
public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
|
||||||
// We send selection events only from AdapterView to avoid
|
// We send selection events only from AdapterView to avoid
|
||||||
// generation of such event for each child.
|
// generation of such event for each child.
|
||||||
View selectedView = getSelectedView();
|
getSelectedView().dispatchPopulateAccessibilityEvent(event);
|
||||||
if (selectedView != null) {
|
|
||||||
selectedView.dispatchPopulateAccessibilityEvent(event);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -961,7 +961,8 @@ public class RelativeLayout extends ViewGroup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (View view : mTopToBottomLeftToRightSet) {
|
for (View view : mTopToBottomLeftToRightSet) {
|
||||||
if (view.dispatchPopulateAccessibilityEvent(event)) {
|
if (view.getVisibility() == View.VISIBLE
|
||||||
|
&& view.dispatchPopulateAccessibilityEvent(event)) {
|
||||||
mTopToBottomLeftToRightSet.clear();
|
mTopToBottomLeftToRightSet.clear();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -405,7 +405,10 @@ public class TabWidget extends LinearLayout implements OnFocusChangeListener {
|
|||||||
onPopulateAccessibilityEvent(event);
|
onPopulateAccessibilityEvent(event);
|
||||||
// Dispatch only to the selected tab.
|
// Dispatch only to the selected tab.
|
||||||
if (mSelectedTab != -1) {
|
if (mSelectedTab != -1) {
|
||||||
return getChildTabViewAt(mSelectedTab).dispatchPopulateAccessibilityEvent(event);
|
View tabView = getChildTabViewAt(mSelectedTab);
|
||||||
|
if (tabView != null && tabView.getVisibility() == VISIBLE) {
|
||||||
|
return tabView.dispatchPopulateAccessibilityEvent(event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user