Merge "Tuning the TouchExplorer"

This commit is contained in:
Svetoslav Ganov
2011-09-06 14:16:17 -07:00
committed by Android (Google) Code Review

View File

@@ -84,7 +84,7 @@ public class TouchExplorer implements Explorer {
// The minimum of the cosine between the vectors of two moving // The minimum of the cosine between the vectors of two moving
// pointers so they can be considered moving in the same direction. // pointers so they can be considered moving in the same direction.
private static final float MIN_ANGLE_COS = 0.866025404f; // cos(pi/6) private static final float MAX_DRAGGING_ANGLE_COS = 0.525321989f; // cos(pi/4)
// The delay for sending a hover enter event. // The delay for sending a hover enter event.
private static final long DELAY_SEND_HOVER_ENTER = 200; private static final long DELAY_SEND_HOVER_ENTER = 200;
@@ -364,13 +364,13 @@ public class TouchExplorer implements Explorer {
} }
mPerformLongPressDelayed.remove(); mPerformLongPressDelayed.remove();
mSendHoverDelayed.forceSendAndRemove();
ensureHoverExitSent(event, pointerIdBits, policyFlags);
// If touch exploring announce the end of the gesture. // If touch exploring announce the end of the gesture.
// Also do not click on the last explored location. // Also do not click on the last explored location.
if (mTouchExploreGestureInProgress) { if (mTouchExploreGestureInProgress) {
mTouchExploreGestureInProgress = false; mTouchExploreGestureInProgress = false;
mSendHoverDelayed.forceSendAndRemove();
ensureHoverExitSent(event, pointerIdBits, policyFlags);
mLastTouchExploreEvent = MotionEvent.obtain(event); mLastTouchExploreEvent = MotionEvent.obtain(event);
sendAccessibilityEvent(TYPE_TOUCH_EXPLORATION_GESTURE_END); sendAccessibilityEvent(TYPE_TOUCH_EXPLORATION_GESTURE_END);
break; break;
@@ -384,6 +384,8 @@ public class TouchExplorer implements Explorer {
final long exploreTime = mLastTouchExploreEvent.getEventTime(); final long exploreTime = mLastTouchExploreEvent.getEventTime();
final long deltaTime = eventTime - exploreTime; final long deltaTime = eventTime - exploreTime;
if (deltaTime > ACTIVATION_TIME_SLOP) { if (deltaTime > ACTIVATION_TIME_SLOP) {
mSendHoverDelayed.forceSendAndRemove();
ensureHoverExitSent(event, pointerIdBits, policyFlags);
mLastTouchExploreEvent = MotionEvent.obtain(event); mLastTouchExploreEvent = MotionEvent.obtain(event);
break; break;
} }
@@ -396,14 +398,25 @@ public class TouchExplorer implements Explorer {
- event.getY(pointerIndex); - event.getY(pointerIndex);
final float deltaMove = (float) Math.hypot(deltaX, deltaY); final float deltaMove = (float) Math.hypot(deltaX, deltaY);
if (deltaMove > mTouchExplorationTapSlop) { if (deltaMove > mTouchExplorationTapSlop) {
mSendHoverDelayed.forceSendAndRemove();
ensureHoverExitSent(event, pointerIdBits, policyFlags);
mLastTouchExploreEvent = MotionEvent.obtain(event); mLastTouchExploreEvent = MotionEvent.obtain(event);
break; break;
} }
// This is a tap so do not send hover events since
// this events will result in firing the corresponding
// accessibility events confusing the user about what
// is actually clicked.
mSendHoverDelayed.remove();
ensureHoverExitSent(event, pointerIdBits, policyFlags);
// All preconditions are met, so click the last explored location. // All preconditions are met, so click the last explored location.
sendActionDownAndUp(mLastTouchExploreEvent, policyFlags); sendActionDownAndUp(mLastTouchExploreEvent, policyFlags);
mLastTouchExploreEvent = null; mLastTouchExploreEvent = null;
} else { } else {
mSendHoverDelayed.forceSendAndRemove();
ensureHoverExitSent(event, pointerIdBits, policyFlags);
mLastTouchExploreEvent = MotionEvent.obtain(event); mLastTouchExploreEvent = MotionEvent.obtain(event);
} }
} break; } break;
@@ -782,7 +795,7 @@ public class TouchExplorer implements Explorer {
final float angleCos = final float angleCos =
firstXNormalized * secondXNormalized + firstYNormalized * secondYNormalized; firstXNormalized * secondXNormalized + firstYNormalized * secondYNormalized;
if (angleCos < MIN_ANGLE_COS) { if (angleCos < MAX_DRAGGING_ANGLE_COS) {
return false; return false;
} }