Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 58e0fb9a authored by Justin Koh's avatar Justin Koh Committed by Android (Google) Code Review
Browse files

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

parents aecee8a9 29880223
Loading
Loading
Loading
Loading
+21 −1
Original line number Original line Diff line number Diff line
@@ -16,6 +16,7 @@


package android.view;
package android.view;


import android.content.Intent;
import android.os.Handler;
import android.os.Handler;
import android.os.Handler.Callback;
import android.os.Handler.Callback;
import android.os.Message;
import android.os.Message;
@@ -33,6 +34,8 @@ class SimulatedTrackball {
    // event for it to be considered a tap
    // event for it to be considered a tap
    // TODO:Read this value from a configuration file
    // TODO:Read this value from a configuration file
    private static final int MAX_TAP_TIME = 250;
    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;
    private static final int FLICK_MSG_ID = 313;


    // The position of the previous touchpad event
    // The position of the previous touchpad event
@@ -47,6 +50,8 @@ class SimulatedTrackball {
    private long mLastTouchPadKeySendTimeMs = 0;
    private long mLastTouchPadKeySendTimeMs = 0;
    // When the most recent touch event of any type occurred
    // When the most recent touch event of any type occurred
    private long mLastTouchPadEventTimeMs = 0;
    private long mLastTouchPadEventTimeMs = 0;
    // Did the swipe begin in a valid region
    private boolean mEdgeSwipePossible;


    // How quickly keys were sent;
    // How quickly keys were sent;
    private int mKeySendRateMs = 0;
    private int mKeySendRateMs = 0;
@@ -131,8 +136,14 @@ class SimulatedTrackball {
                mAccumulatedY = 0;
                mAccumulatedY = 0;
                mLastMoveX = 0;
                mLastMoveX = 0;
                mLastMoveY = 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
                // Clear any flings
                mHandler.removeMessages(FLICK_MSG_ID);
                mHandler.removeMessages(FLICK_MSG_ID);

                break;
                break;
            case MotionEvent.ACTION_HOVER_MOVE:
            case MotionEvent.ACTION_HOVER_MOVE:
                // Determine whether the move is slop or an intentional move
                // Determine whether the move is slop or an intentional move
@@ -141,7 +152,15 @@ class SimulatedTrackball {
                if (mTouchSlopSquared < deltaX * deltaX + deltaY * deltaY) {
                if (mTouchSlopSquared < deltaX * deltaX + deltaY * deltaY) {
                    mAlwaysInTapRegion = false;
                    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
                // Find the difference in position between the two most recent
                // touchpad events
                // touchpad events
                mLastMoveX = event.getX() - mLastTouchpadXPosition;
                mLastMoveX = event.getX() - mLastTouchpadXPosition;
@@ -222,6 +241,7 @@ class SimulatedTrackball {
                        mHandler.sendMessageDelayed(message, mKeySendRateMs);
                        mHandler.sendMessageDelayed(message, mKeySendRateMs);
                    }
                    }
                }
                }
                mEdgeSwipePossible = false;
                break;
                break;
        }
        }
        // Store touch event position and time
        // Store touch event position and time