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

Commit b5aeb9f4 authored by Patrick Dubroy's avatar Patrick Dubroy Committed by Android (Google) Code Review
Browse files

Merge "Fix 3272590: Long-press on home & menu should be same as click"

parents df3c4b45 ece94529
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
@@ -42,13 +42,12 @@ public class KeyButtonView extends ImageView {

    IWindowManager mWindowManager;
    long mDownTime;
    boolean mSending, mLongPressed;
    boolean mSending;
    int mCode;
    int mRepeat;
    Runnable mCheckLongPress = new Runnable() {
        public void run() {
            if (isPressed()) {
                mLongPressed = true;
                mRepeat++;
                sendEvent(KeyEvent.ACTION_DOWN,
                        KeyEvent.FLAG_FROM_SYSTEM
@@ -91,7 +90,6 @@ public class KeyButtonView extends ImageView {
                mDownTime = SystemClock.uptimeMillis();
                mRepeat = 0;
                mSending = true;
                mLongPressed = false;
                sendEvent(KeyEvent.ACTION_DOWN,
                        KeyEvent.FLAG_FROM_SYSTEM | KeyEvent.FLAG_VIRTUAL_HARD_KEY, mDownTime);
                setPressed(true);
@@ -107,7 +105,7 @@ public class KeyButtonView extends ImageView {
                break;
            case MotionEvent.ACTION_CANCEL:
                setPressed(false);
                if (mSending && !mLongPressed) {
                if (mSending) {
                    mSending = false;
                    sendEvent(KeyEvent.ACTION_UP,
                            KeyEvent.FLAG_FROM_SYSTEM | KeyEvent.FLAG_VIRTUAL_HARD_KEY
@@ -117,7 +115,7 @@ public class KeyButtonView extends ImageView {
                break;
            case MotionEvent.ACTION_UP:
                setPressed(false);
                if (mSending && !mLongPressed) {
                if (mSending) {
                    mSending = false;
                    sendEvent(KeyEvent.ACTION_UP,
                            KeyEvent.FLAG_FROM_SYSTEM | KeyEvent.FLAG_VIRTUAL_HARD_KEY);
+0 −15
Original line number Diff line number Diff line
@@ -143,7 +143,6 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
     * this is 0, there is no key held down.
     */
    private int mPanelChordingKey;
    private boolean mPanelMayLongPress;

    private ImageView mLeftIconView;

@@ -658,22 +657,11 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
        if (event.getRepeatCount() == 0) {
            // The panel key was pushed, so set the chording key
            mPanelChordingKey = keyCode;
            mPanelMayLongPress = false;

            PanelFeatureState st = getPanelState(featureId, true);
            if (!st.isOpen) {
                if (getContext().getResources().getConfiguration().keyboard
                        == Configuration.KEYBOARD_NOKEYS) {
                    mPanelMayLongPress = true;
                }
                return preparePanel(st, event);
            }
        } else if (mPanelMayLongPress && mPanelChordingKey == keyCode
                && (event.getFlags()&KeyEvent.FLAG_LONG_PRESS) != 0) {
            // We have had a long press while in a state where this
            // should be executed...  do it!
            mPanelChordingKey = 0;
            mPanelMayLongPress = false;
        }

        return false;
@@ -688,7 +676,6 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
        // The panel key was released, so clear the chording key
        if (mPanelChordingKey != 0) {
            mPanelChordingKey = 0;
            mPanelMayLongPress = false;

            if (event.isCanceled()) {
                return;
@@ -2140,8 +2127,6 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
        public void onWindowFocusChanged(boolean hasWindowFocus) {
            super.onWindowFocusChanged(hasWindowFocus);

            mPanelMayLongPress = false;

            // If the user is chording a menu shortcut, release the chord since
            // this window lost focus
            if (!hasWindowFocus && mPanelChordingKey != 0) {
+18 −16
Original line number Diff line number Diff line
@@ -601,19 +601,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
     */
    Runnable mHomeLongPress = new Runnable() {
        public void run() {
            /*
             * Eat the longpress so it won't dismiss the recent apps dialog when
             * the user lets go of the home key
             */
            mHomePressed = false;
            showRecentAppsDialog();
            handleLongPressOnHome();
        }
    };

    /**
     * Create (if necessary) and launch the recent apps dialog
     */
    void showRecentAppsDialog() {
    private void handleLongPressOnHome() {
        // We can't initialize this in init() since the configuration hasn't been loaded yet.
        if (mLongPressOnHomeBehavior < 0) {
            mLongPressOnHomeBehavior
@@ -627,14 +619,14 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        if (mLongPressOnHomeBehavior != LONG_PRESS_HOME_NOTHING) {
            performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false);
            sendCloseSystemWindows(SYSTEM_DIALOG_REASON_RECENT_APPS);

            // Eat the longpress so it won't dismiss the recent apps dialog when
            // the user lets go of the home key
            mHomePressed = false;
        }

        if (mLongPressOnHomeBehavior == LONG_PRESS_HOME_RECENT_DIALOG) {
            // Fallback to dialog if we fail to launch the above.
            if (mRecentAppsDialog == null) {
                mRecentAppsDialog = new RecentApplicationsDialog(mContext);
            }
            mRecentAppsDialog.show();
            showRecentAppsDialog();
        } else if (mLongPressOnHomeBehavior == LONG_PRESS_HOME_RECENT_ACTIVITY) {
            try {
                Intent intent = new Intent();
@@ -650,6 +642,16 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        }
    }

    /**
     * Create (if necessary) and launch the recent apps dialog
     */
    void showRecentAppsDialog() {
        if (mRecentAppsDialog == null) {
            mRecentAppsDialog = new RecentApplicationsDialog(mContext);
        }
        mRecentAppsDialog.show();
    }
    
    /** {@inheritDoc} */
    public void init(Context context, IWindowManager windowManager,
            LocalPowerManager powerManager) {