summaryrefslogtreecommitdiffstats
path: root/core/java/android/view
diff options
context:
space:
mode:
authorSvetoslav Ganov <svetoslavganov@google.com>2012-11-02 16:03:06 -0700
committerSvetoslav Ganov <svetoslavganov@google.com>2012-11-02 16:39:16 -0700
commit11f19f15ea474edde07bf34877d2531fff6c26f0 (patch)
tree98f2191369b124141e26bc52a9588339ea3f9e9c /core/java/android/view
parent37238e5a4e10c5c5439f6864dd19049a5544e01a (diff)
downloadframeworks_base-11f19f15ea474edde07bf34877d2531fff6c26f0.zip
frameworks_base-11f19f15ea474edde07bf34877d2531fff6c26f0.tar.gz
frameworks_base-11f19f15ea474edde07bf34877d2531fff6c26f0.tar.bz2
View's visibility to the user not checking predecessor alpha.
1. A view is visible to the user if is attached to a visible window, its visibility is VISIBLE, its alpha is not zero, all its predecessors have visibility VISIBLE and non zero alpha, the view is not fully covered by predecessors and is within the screen. The function that computes whether a view is visible for accessibility purposes was not taking into account the predecessors' alpha. bug:7454355 Change-Id: I7609f4366da260091d68e5b25832498843fd3d0a
Diffstat (limited to 'core/java/android/view')
-rw-r--r--core/java/android/view/View.java37
1 files changed, 24 insertions, 13 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index d5e1ed3..ff44475 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -5088,24 +5088,35 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
*/
protected boolean isVisibleToUser(Rect boundInView) {
if (mAttachInfo != null) {
+ // Attached to invisible window means this view is not visible.
+ if (mAttachInfo.mWindowVisibility != View.VISIBLE) {
+ return false;
+ }
+ // An invisible predecessor or one with alpha zero means
+ // that this view is not visible to the user.
+ Object current = this;
+ while (current instanceof View) {
+ View view = (View) current;
+ // We have attach info so this view is attached and there is no
+ // need to check whether we reach to ViewRootImpl on the way up.
+ if (view.getAlpha() <= 0 || view.getVisibility() != VISIBLE) {
+ return false;
+ }
+ current = view.mParent;
+ }
+ // Check if the view is entirely covered by its predecessors.
Rect visibleRect = mAttachInfo.mTmpInvalRect;
Point offset = mAttachInfo.mPoint;
- // The first two checks are made also made by isShown() which
- // however traverses the tree up to the parent to catch that.
- // Therefore, we do some fail fast check to minimize the up
- // tree traversal.
- boolean isVisible = mAttachInfo.mWindowVisibility == View.VISIBLE
- && getAlpha() > 0
- && isShown()
- && getGlobalVisibleRect(visibleRect, offset);
- if (isVisible && boundInView != null) {
+ if (!getGlobalVisibleRect(visibleRect, offset)) {
+ return false;
+ }
+ // Check if the visible portion intersects the rectangle of interest.
+ if (boundInView != null) {
visibleRect.offset(-offset.x, -offset.y);
- // isVisible is always true here, use a simple assignment
- isVisible = boundInView.intersect(visibleRect);
+ return boundInView.intersect(visibleRect);
}
- return isVisible;
+ return true;
}
-
return false;
}