Merge "Accessibility hover events are fired if hover otside of modal window."
This commit is contained in:
committed by
Android (Google) Code Review
commit
6a13dd5544
@@ -6052,23 +6052,29 @@ public class View implements Drawable.Callback2, KeyEvent.Callback, Accessibilit
|
|||||||
* @see #onHoverChanged
|
* @see #onHoverChanged
|
||||||
*/
|
*/
|
||||||
public boolean onHoverEvent(MotionEvent event) {
|
public boolean onHoverEvent(MotionEvent event) {
|
||||||
switch (event.getAction()) {
|
// The root view may receive hover (or touch) events that are outside the bounds of
|
||||||
case MotionEvent.ACTION_HOVER_ENTER:
|
// the window. This code ensures that we only send accessibility events for
|
||||||
if (!hasHoveredChild() && !mSendingHoverAccessibilityEvents) {
|
// hovers that are actually within the bounds of the root view.
|
||||||
mSendingHoverAccessibilityEvents = true;
|
final int action = event.getAction();
|
||||||
sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_HOVER_ENTER);
|
if (!mSendingHoverAccessibilityEvents) {
|
||||||
}
|
if ((action == MotionEvent.ACTION_HOVER_ENTER
|
||||||
break;
|
|| action == MotionEvent.ACTION_HOVER_MOVE)
|
||||||
case MotionEvent.ACTION_HOVER_EXIT:
|
&& !hasHoveredChild()
|
||||||
if (mSendingHoverAccessibilityEvents) {
|
&& pointInView(event.getX(), event.getY())) {
|
||||||
mSendingHoverAccessibilityEvents = false;
|
mSendingHoverAccessibilityEvents = true;
|
||||||
sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_HOVER_EXIT);
|
sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_HOVER_ENTER);
|
||||||
}
|
}
|
||||||
break;
|
} 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()) {
|
if (isHoverable()) {
|
||||||
switch (event.getAction()) {
|
switch (action) {
|
||||||
case MotionEvent.ACTION_HOVER_ENTER:
|
case MotionEvent.ACTION_HOVER_ENTER:
|
||||||
setHovered(true);
|
setHovered(true);
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user