summaryrefslogtreecommitdiffstats
path: root/core/java/android/view
diff options
context:
space:
mode:
authorJustin Koh <justinkoh@google.com>2012-12-19 11:46:34 -0800
committerAndroid Git Automerger <android-git-automerger@android.com>2012-12-19 11:46:34 -0800
commita90c92a1c97830de5e1766bb64ff421a2a50ed56 (patch)
tree920dcbd6c98a63fc6ccf6b63f4a0dfc6f01d41f9 /core/java/android/view
parentc4241766be958d68d4b9605957093bed9b540a75 (diff)
parent86903699692a0b3229062da2995d829629e64e7b (diff)
downloadframeworks_base-a90c92a1c97830de5e1766bb64ff421a2a50ed56.zip
frameworks_base-a90c92a1c97830de5e1766bb64ff421a2a50ed56.tar.gz
frameworks_base-a90c92a1c97830de5e1766bb64ff421a2a50ed56.tar.bz2
am 86903699: Merge "Start RecognitionActivity with an upswipe gesture." into jb-mr1-aah-dev
* commit '86903699692a0b3229062da2995d829629e64e7b': Start RecognitionActivity with an upswipe gesture.
Diffstat (limited to 'core/java/android/view')
-rw-r--r--core/java/android/view/SimulatedTrackball.java32
-rw-r--r--core/java/android/view/ViewRootImpl.java3
2 files changed, 25 insertions, 10 deletions
diff --git a/core/java/android/view/SimulatedTrackball.java b/core/java/android/view/SimulatedTrackball.java
index 0eb197e..4ab557a 100644
--- a/core/java/android/view/SimulatedTrackball.java
+++ b/core/java/android/view/SimulatedTrackball.java
@@ -16,13 +16,15 @@
package android.view;
+import android.app.SearchManager;
import android.content.ActivityNotFoundException;
+import android.content.Context;
import android.content.Intent;
import android.os.Handler;
-import android.os.Handler.Callback;
import android.os.Message;
import android.os.SystemClock;
import android.os.SystemProperties;
+import android.os.UserHandle;
import android.util.Log;
/**
@@ -30,6 +32,8 @@ import android.util.Log;
*
* @see ViewRootImpl
*/
+
+//TODO: Make this class an internal class of ViewRootImpl.java
class SimulatedTrackball {
private static final String TAG = "SimulatedTrackball";
@@ -43,7 +47,6 @@ class SimulatedTrackball {
private static final int MSG_FLICK = 313;
// TODO: Pass touch slop from the input device
private static final int TOUCH_SLOP = 30;
-
// The position of the previous touchpad event
private float mLastTouchpadXPosition;
private float mLastTouchpadYPosition;
@@ -59,6 +62,8 @@ class SimulatedTrackball {
// Did the swipe begin in a valid region
private boolean mEdgeSwipePossible;
+ private final Context mContext;
+
// How quickly keys were sent;
private int mKeySendRateMs = 0;
private int mLastKeySent;
@@ -92,7 +97,7 @@ class SimulatedTrackball {
// How quickly the repeated events die off
private float mFlickDecay;
- public SimulatedTrackball() {
+ public SimulatedTrackball(Context context) {
mDistancePerTick = SystemProperties.getInt("persist.vr_dist_tick", 64);
mDistancePerTickSquared = mDistancePerTick * mDistancePerTick;
mMaxRepeatDelay = SystemProperties.getInt("persist.vr_repeat_delay", 300);
@@ -102,6 +107,8 @@ class SimulatedTrackball {
"persist.sys.vr_flick_decay", "1.3"));
mTouchSlop = TOUCH_SLOP;
mTouchSlopSquared = mTouchSlop * mTouchSlop;
+
+ mContext = context;
}
private final Handler mHandler = new Handler(true /*async*/) {
@@ -167,12 +174,19 @@ class SimulatedTrackball {
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");
- try {
- viewroot.mView.getContext().startActivity(intent);
- } catch (ActivityNotFoundException e) {
- Log.e(TAG,"Search activity not found.");
+
+ Intent intent =
+ ((SearchManager)mContext.getSystemService(Context.SEARCH_SERVICE))
+ .getAssistIntent(mContext, UserHandle.USER_CURRENT_OR_SELF);
+ if (intent != null) {
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ try {
+ mContext.startActivity(intent);
+ } catch (ActivityNotFoundException e){
+ Log.e(TAG, "Could not start search activity");
+ }
+ } else {
+ Log.e(TAG, "Could not find a search activity");
}
}
// Find the difference in position between the two most recent
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 27d770b..fe2cf0e 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -144,7 +144,7 @@ public final class ViewRootImpl implements ViewParent,
final TrackballAxis mTrackballAxisX = new TrackballAxis();
final TrackballAxis mTrackballAxisY = new TrackballAxis();
- final SimulatedTrackball mSimulatedTrackball = new SimulatedTrackball();
+ final SimulatedTrackball mSimulatedTrackball;
int mLastJoystickXDirection;
int mLastJoystickYDirection;
@@ -385,6 +385,7 @@ public final class ViewRootImpl implements ViewParent,
PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
mAttachInfo.mScreenOn = powerManager.isScreenOn();
loadSystemProperties();
+ mSimulatedTrackball = new SimulatedTrackball(context);
}
/**