diff options
author | Svetoslav Ganov <svetoslavganov@google.com> | 2011-09-01 11:27:37 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-09-01 11:27:37 -0700 |
commit | 6a13dd5544d0eb55349ccf57ee6a781ab4fd51b6 (patch) | |
tree | 0b9d94510b71db83ea702b4adb68bad48fdc728e /core | |
parent | 6c79bcf351aa1dc2929f9e876ee794b98f165b80 (diff) | |
parent | 4c1c101a91ed49089a1b81923385cb2f74253c57 (diff) | |
download | frameworks_base-6a13dd5544d0eb55349ccf57ee6a781ab4fd51b6.zip frameworks_base-6a13dd5544d0eb55349ccf57ee6a781ab4fd51b6.tar.gz frameworks_base-6a13dd5544d0eb55349ccf57ee6a781ab4fd51b6.tar.bz2 |
Merge "Accessibility hover events are fired if hover otside of modal window."
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/view/View.java | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 14677e1..aa9b3ab 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -6052,23 +6052,29 @@ public class View implements Drawable.Callback2, KeyEvent.Callback, Accessibilit * @see #onHoverChanged */ public boolean onHoverEvent(MotionEvent event) { - switch (event.getAction()) { - case MotionEvent.ACTION_HOVER_ENTER: - if (!hasHoveredChild() && !mSendingHoverAccessibilityEvents) { - mSendingHoverAccessibilityEvents = true; - sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_HOVER_ENTER); - } - break; - case MotionEvent.ACTION_HOVER_EXIT: - if (mSendingHoverAccessibilityEvents) { - mSendingHoverAccessibilityEvents = false; - sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_HOVER_EXIT); - } - break; + // The root view may receive hover (or touch) events that are outside the bounds of + // the window. This code ensures that we only send accessibility events for + // hovers that are actually within the bounds of the root view. + final int action = event.getAction(); + if (!mSendingHoverAccessibilityEvents) { + if ((action == MotionEvent.ACTION_HOVER_ENTER + || action == MotionEvent.ACTION_HOVER_MOVE) + && !hasHoveredChild() + && pointInView(event.getX(), event.getY())) { + mSendingHoverAccessibilityEvents = true; + sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_HOVER_ENTER); + } + } else { + if (action == MotionEvent.ACTION_HOVER_EXIT + || (action == MotionEvent.ACTION_HOVER_MOVE + && !pointInView(event.getX(), event.getY()))) { + mSendingHoverAccessibilityEvents = false; + sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_HOVER_EXIT); + } } if (isHoverable()) { - switch (event.getAction()) { + switch (action) { case MotionEvent.ACTION_HOVER_ENTER: setHovered(true); break; |