diff options
author | Svetoslav Ganov <svetoslavganov@google.com> | 2012-06-01 14:19:05 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-06-01 14:19:05 -0700 |
commit | 6acca2442572a28b7d9428e5e2fc2aa4271e29f9 (patch) | |
tree | c5ca6ad075f7ea13b82e475b8b9c96a4e88f94b7 /services/java/com | |
parent | ea01e4a2d5cc28093e9fd720055082b2d3f708d9 (diff) | |
parent | 238099c0dbbdc66b8443552126680ad1c7cab17d (diff) | |
download | frameworks_base-6acca2442572a28b7d9428e5e2fc2aa4271e29f9.zip frameworks_base-6acca2442572a28b7d9428e5e2fc2aa4271e29f9.tar.gz frameworks_base-6acca2442572a28b7d9428e5e2fc2aa4271e29f9.tar.bz2 |
Merge "Cannot double tap and hold outside of the input focused window." into jb-dev
Diffstat (limited to 'services/java/com')
-rw-r--r-- | services/java/com/android/server/accessibility/TouchExplorer.java | 46 |
1 files changed, 33 insertions, 13 deletions
diff --git a/services/java/com/android/server/accessibility/TouchExplorer.java b/services/java/com/android/server/accessibility/TouchExplorer.java index 4c38ab9..67bdabd 100644 --- a/services/java/com/android/server/accessibility/TouchExplorer.java +++ b/services/java/com/android/server/accessibility/TouchExplorer.java @@ -1247,25 +1247,45 @@ public class TouchExplorer { @Override public void run() { - final int pointerIndex = mEvent.getActionIndex(); + // If the last touched explored location is not within the focused + // window we will long press at that exact spot, otherwise we find the + // accessibility focus and if the tap is within its bounds we long press + // there, otherwise we pick the middle of the focus rectangle. + MotionEvent lastEvent = mInjectedPointerTracker.getLastInjectedHoverEvent(); + if (lastEvent == null) { + return; + } + + final int exploreLocationX = (int) lastEvent.getX(lastEvent.getActionIndex()); + final int exploreLocationY = (int) lastEvent.getY(lastEvent.getActionIndex()); + + Rect bounds = mTempRect; + boolean useFocusedBounds = false; + + final int pointerId = mEvent.getPointerId(mEvent.getActionIndex()); + final int pointerIndex = mEvent.findPointerIndex(pointerId); + if (mAms.getAccessibilityFocusBounds(exploreLocationX, exploreLocationY, bounds)) { + // If the user's last touch explored location is not + // within the accessibility focus bounds we use the center + // of the accessibility focused rectangle. + if (!bounds.contains((int) mEvent.getX(pointerIndex), + (int) mEvent.getY(pointerIndex))) { + useFocusedBounds = true; + } + } + + mLongPressingPointerId = mEvent.getPointerId(pointerIndex); + final int eventX = (int) mEvent.getX(pointerIndex); final int eventY = (int) mEvent.getY(pointerIndex); - Rect bounds = mTempRect; - if (mAms.getAccessibilityFocusBounds(eventX, eventY, bounds) - && !bounds.contains(eventX, eventY)) { - mLongPressingPointerId = mEvent.getPointerId(pointerIndex); + if (useFocusedBounds) { mLongPressingPointerDeltaX = eventX - bounds.centerX(); mLongPressingPointerDeltaY = eventY - bounds.centerY(); } else { - mLongPressingPointerId = -1; - mLongPressingPointerDeltaX = 0; - mLongPressingPointerDeltaY = 0; + mLongPressingPointerDeltaX = eventX - exploreLocationX; + mLongPressingPointerDeltaY = eventY - exploreLocationY; } - // We are sending events so send exit and gesture - // end since we transition to another state. - final int pointerId = mReceivedPointerTracker.getPrimaryActivePointerId(); - final int pointerIdBits = (1 << pointerId); - mAms.touchExplorationGestureEnded(); + sendExitEventsIfNeeded(mPolicyFlags); mCurrentState = STATE_DELEGATING; |