summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Justin Koh <justinkoh@google.com> 2012-11-08 06:18:07 -0800
committer Android Git Automerger <android-git-automerger@android.com> 2012-11-08 06:18:07 -0800
commitb892e8c642557b73ee6aa9bd8fc07b03eae85e9a (patch)
tree65edebec8a0f8070a7d036a5d4ca3140352bb88f
parentcb2f707f869933e4e5bb16add76dbf8747cf3b06 (diff)
parenta1459793d4e2ea483deb8baa733abbac56c2c199 (diff)
am a1459793: am 58e0fb9a: Merge "Trigger Google Now intent with swipe from bottom" into jb-mr1-aah-dev
* commit 'a1459793d4e2ea483deb8baa733abbac56c2c199': Trigger Google Now intent with swipe from bottom
-rw-r--r--core/java/android/view/SimulatedTrackball.java22
1 files changed, 21 insertions, 1 deletions
diff --git a/core/java/android/view/SimulatedTrackball.java b/core/java/android/view/SimulatedTrackball.java
index 1878e28590b7..5314019150ca 100644
--- a/core/java/android/view/SimulatedTrackball.java
+++ b/core/java/android/view/SimulatedTrackball.java
@@ -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