am 58e0fb9a: Merge "Trigger Google Now intent with swipe from bottom" into jb-mr1-aah-dev

* commit '58e0fb9adbe579a068849a7865a7f1bce7531d1c':
  Trigger Google Now intent with swipe from bottom
This commit is contained in:
Justin Koh
2012-11-08 06:12:26 -08:00
committed by Android Git Automerger

View File

@@ -16,6 +16,7 @@
package android.view;
import android.content.Intent;
import android.os.Handler;
import android.os.Handler.Callback;
import android.os.Message;
@@ -33,6 +34,8 @@ class SimulatedTrackball {
// event for it to be considered a tap
// TODO:Read this value from a configuration file
private static final int MAX_TAP_TIME = 250;
// Where the cutoff is for determining an edge swipe
private static final float EDGE_SWIPE_THRESHOLD = 0.9f;
private static final int FLICK_MSG_ID = 313;
// The position of the previous touchpad event
@@ -47,6 +50,8 @@ class SimulatedTrackball {
private long mLastTouchPadKeySendTimeMs = 0;
// When the most recent touch event of any type occurred
private long mLastTouchPadEventTimeMs = 0;
// Did the swipe begin in a valid region
private boolean mEdgeSwipePossible;
// How quickly keys were sent;
private int mKeySendRateMs = 0;
@@ -131,8 +136,14 @@ class SimulatedTrackball {
mAccumulatedY = 0;
mLastMoveX = 0;
mLastMoveY = 0;
if (event.getDevice().getMotionRange(MotionEvent.AXIS_Y).getMax()
* EDGE_SWIPE_THRESHOLD < event.getY()) {
// Did the swipe begin in a valid region
mEdgeSwipePossible = true;
}
// Clear any flings
mHandler.removeMessages(FLICK_MSG_ID);
break;
case MotionEvent.ACTION_HOVER_MOVE:
// Determine whether the move is slop or an intentional move
@@ -141,7 +152,15 @@ class SimulatedTrackball {
if (mTouchSlopSquared < deltaX * deltaX + deltaY * deltaY) {
mAlwaysInTapRegion = false;
}
// Checks if the swipe has crossed the midpoint
// and if our swipe gesture is complete
if (event.getY() < (event.getDevice().getMotionRange(MotionEvent.AXIS_Y).getMax()
* .5) && mEdgeSwipePossible) {
mEdgeSwipePossible = false;
Intent intent = new Intent("android.search.action.GLOBAL_SEARCH");
intent.addCategory("android.intent.category.DEFAULT");
viewroot.mView.getContext().startActivity(intent);
}
// Find the difference in position between the two most recent
// touchpad events
mLastMoveX = event.getX() - mLastTouchpadXPosition;
@@ -222,6 +241,7 @@ class SimulatedTrackball {
mHandler.sendMessageDelayed(message, mKeySendRateMs);
}
}
mEdgeSwipePossible = false;
break;
}
// Store touch event position and time