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

Commit a2419d4b authored by Ricardo Cerqueira's avatar Ricardo Cerqueira Committed by Gerrit Code Review
Browse files

Merge "Reimplement AOSP's home-key behavior configuration" into cm-10.2

parents d5f3281a c38affe3
Loading
Loading
Loading
Loading
+11 −4
Original line number Diff line number Diff line
@@ -562,16 +562,23 @@

    <!-- Control the behavior when the user long presses the home button.
            0 - Nothing
            1 - Recent apps view in SystemUI
            2 - Launch assist intent
            1 - Menu key
            2 - Recent apps view in SystemUI
            3 - Launch assist intent
            4 - Voice Search
            5 - In-app Search
         This needs to match the constants in
         policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
    -->
    <integer name="config_longPressOnHomeBehavior">1</integer>
    <integer name="config_longPressOnHomeBehavior">2</integer>

    <!-- Control the behavior when the user double-taps the home button.
            0 - Nothing
            1 - Recent apps view in SystemUI
            1 - Menu
            2 - Recent apps view in SystemUI
            3 - Launch assist intent
            4 - Voice Search
            5 - In-app Search
         This needs to match the constants in
         policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
    -->
+35 −42
Original line number Diff line number Diff line
@@ -157,15 +157,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    static final int LONG_PRESS_POWER_SHUT_OFF = 2;
    static final int LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM = 3;

    // These need to match the documentation/constant in
    // core/res/res/values/config.xml
    static final int LONG_PRESS_HOME_NOTHING = 0;
    static final int LONG_PRESS_HOME_RECENT_SYSTEM_UI = 1;
    static final int LONG_PRESS_HOME_ASSIST = 2;

    static final int DOUBLE_TAP_HOME_NOTHING = 0;
    static final int DOUBLE_TAP_HOME_RECENT_SYSTEM_UI = 1;

    static final int APPLICATION_MEDIA_SUBLAYER = -2;
    static final int APPLICATION_MEDIA_OVERLAY_SUBLAYER = -1;
    static final int APPLICATION_PANEL_SUBLAYER = 1;
@@ -467,8 +458,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    boolean mDreamingLockscreen;
    boolean mHomeLongPressed;
    boolean mHomePressed;
    boolean mAppSwitchLongPressed;
    boolean mHomeConsumed;
    boolean mAppSwitchLongPressed;
    boolean mHomeDoubleTapPending;
    Intent mHomeIntent;
    Intent mCarDockIntent;
@@ -1221,21 +1212,19 @@ public class PhoneWindowManager implements WindowManagerPolicy {
     * eg. Disable long press on home goes to recents on sw600dp.
     */
    private void readConfigurationDependentBehaviors() {
        /* TEMP DISABLE: This conflicts with CM's own multi-behavior code 
        mLongPressOnHomeBehavior = mContext.getResources().getInteger(
                com.android.internal.R.integer.config_longPressOnHomeBehavior);
        if (mLongPressOnHomeBehavior < LONG_PRESS_HOME_NOTHING ||
                mLongPressOnHomeBehavior > LONG_PRESS_HOME_ASSIST) {
            mLongPressOnHomeBehavior = LONG_PRESS_HOME_NOTHING;
        if (mLongPressOnHomeBehavior < KEY_ACTION_NOTHING ||
                mLongPressOnHomeBehavior > KEY_ACTION_IN_APP_SEARCH) {
            mLongPressOnHomeBehavior = KEY_ACTION_NOTHING;
        }

        mDoubleTapOnHomeBehavior = mContext.getResources().getInteger(
                com.android.internal.R.integer.config_doubleTapOnHomeBehavior);
        if (mDoubleTapOnHomeBehavior < DOUBLE_TAP_HOME_NOTHING ||
                mDoubleTapOnHomeBehavior > DOUBLE_TAP_HOME_RECENT_SYSTEM_UI) {
            mDoubleTapOnHomeBehavior = LONG_PRESS_HOME_NOTHING;
        if (mDoubleTapOnHomeBehavior < KEY_ACTION_NOTHING ||
                mDoubleTapOnHomeBehavior > KEY_ACTION_IN_APP_SEARCH) {
            mDoubleTapOnHomeBehavior = KEY_ACTION_NOTHING;
        }
        */
    }

    @Override
@@ -1392,13 +1381,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            mHasMenuKeyEnabled = false;

            if (!keyRebindingEnabled) {
                if (mHasHomeKey) {
                    if (mHasAppSwitchKey) {
                        mLongPressOnHomeBehavior = KEY_ACTION_NOTHING;
                    } else {
                        mLongPressOnHomeBehavior = KEY_ACTION_APP_SWITCH;
                    }
                }
                // Grab default configuration for home key
                readConfigurationDependentBehaviors();

                if (mHasMenuKey) {
                    mPressOnMenuBehavior = KEY_ACTION_MENU;
                    if (mHasAssistKey) {
@@ -2359,6 +2344,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                final boolean homeWasLongPressed = mHomeLongPressed;
                mHomeLongPressed = false;
                mHomePressed = false;
                if (mHomeConsumed) {
                    mHomeConsumed = false;
                    return -1;
                }

                if (!homeWasLongPressed) {
                    if (mRecentAppsPreloaded) {
                        cancelPreloadRecentApps();
@@ -2390,9 +2380,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                    }
                }

                /* TEMP DISABLE: This conflicts with CM's own multi-behavior code 
                // Delay handling home if a double-tap is possible.
                if (mDoubleTapOnHomeBehavior != DOUBLE_TAP_HOME_NOTHING) {
                if (mDoubleTapOnHomeBehavior != KEY_ACTION_NOTHING) {
                    mHandler.removeCallbacks(mHomeDoubleTapTimeoutRunnable); // just in case
                    mHomeDoubleTapPending = true;
                    mHandler.postDelayed(mHomeDoubleTapTimeoutRunnable,
@@ -2400,10 +2389,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                    return -1;
                }

                // Go home!
                launchHomeFromHotKey();
                return -1;
                */
            }

            // If a system window has focus, then it doesn't make sense
@@ -2424,21 +2410,28 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                    }
                }
            }
            if (down) {
                if (!mRecentAppsPreloaded && mLongPressOnHomeBehavior == KEY_ACTION_APP_SWITCH) {
                    preloadRecentApps();
                }
            // Remember that home is pressed and handle special actions.
            if (repeatCount == 0) {
                mHomePressed = true;
                if (mHomeDoubleTapPending) {
                    mHomeDoubleTapPending = false;
                    mHandler.removeCallbacks(mHomeDoubleTapTimeoutRunnable);
                    mHomeConsumed = true;
                    performKeyAction(mDoubleTapOnHomeBehavior);
                } else if (!mRecentAppsPreloaded &&
                        (mLongPressOnHomeBehavior == KEY_ACTION_APP_SWITCH
                         || mDoubleTapOnHomeBehavior == KEY_ACTION_APP_SWITCH)) {
                    preloadRecentApps();
                }
            } else if (longPress) {
                if (!keyguardOn && mLongPressOnHomeBehavior != KEY_ACTION_NOTHING) {
                    performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false);
                    mHomeConsumed = true;
                    performKeyAction(mLongPressOnHomeBehavior);
                    // Eat the long-press so it won't take us home when the key is released
                    mHomeLongPressed = true;
                }
            }
            }
            return -1;
        } else if (keyCode == KeyEvent.KEYCODE_MENU) {
            // Hijack modified menu keys for debugging features