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

Commit 8b127698 authored by Joey Rizzoli's avatar Joey Rizzoli
Browse files

[1/3] base: single hand for hardware keys



Change-Id: Ibc5ab1b355080d6aad52160cf1c306e27281428f
Signed-off-by: default avatarJoey Rizzoli <joey@lineageos.org>
parent c682bdb7
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -271,6 +271,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    private static final int KEY_ACTION_SLEEP = 7;
    private static final int KEY_ACTION_LAST_APP = 8;
    private static final int KEY_ACTION_SPLIT_SCREEN = 9;
    private static final int KEY_ACTION_SINGLE_HAND_LEFT = 10;
    private static final int KEY_ACTION_SINGLE_HAND_RIGHT = 11;

    // Masks for checking presence of hardware keys.
    // Must match values in core/res/res/values/config.xml
@@ -1797,6 +1799,12 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            case KEY_ACTION_SPLIT_SCREEN:
                toggleSplitScreen();
                break;
            case KEY_ACTION_SINGLE_HAND_LEFT:
                toggleSingleHand(mContext, true);
                break;
            case KEY_ACTION_SINGLE_HAND_RIGHT:
                toggleSingleHand(mContext, false);
                break;
            default:
                break;
         }
@@ -9040,4 +9048,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    public void freezeOrThawRotation(int rotation) {
        mDesiredRotation = rotation;
    }

    private void toggleSingleHand(Context context, boolean isLeft) {
        Settings.Global.putString(context.getContentResolver(), Settings.Global.SINGLE_HAND_MODE,
                Settings.Global.getString(context.getContentResolver(),
                    Settings.Global.SINGLE_HAND_MODE).isEmpty() ?
                    isLeft ? "left" : "right" : "");
    }
}