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

Commit c8a09a31 authored by Roman Birg's avatar Roman Birg
Browse files

SystemUI: fix up navigation cursor keyevent flags



Volume cursor controls use slightly different flags to keep the cursor
within the field. Match them in the SystemUI for consistent (and better)
behavior.

Change-Id: I56d597f111ec611b0ca24a10f30575401fa76d18
Signed-off-by: default avatarRoman Birg <roman@cyngn.com>
parent a58f1b77
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -52,6 +52,8 @@ public class KeyButtonView extends ImageView {

    final float GLOW_MAX_SCALE_FACTOR = 1.8f;
    public static final float DEFAULT_QUIESCENT_ALPHA = 0.70f;
    public static final int CURSOR_FLAGS = KeyEvent.FLAG_SOFT_KEYBOARD
            | KeyEvent.FLAG_KEEP_TOUCH_MODE;

    long mDownTime;
    int mCode;
@@ -78,8 +80,8 @@ public class KeyButtonView extends ImageView {
            if (isPressed()) {
                // Log.d("KeyButtonView", "longpressed: " + this);
                if (mCode == KeyEvent.KEYCODE_DPAD_LEFT || mCode == KeyEvent.KEYCODE_DPAD_RIGHT) {
                    sendEvent(KeyEvent.ACTION_UP, ~KeyEvent.FLAG_VIRTUAL_HARD_KEY);
                    sendEvent(KeyEvent.ACTION_DOWN, ~KeyEvent.FLAG_VIRTUAL_HARD_KEY);
                    sendEvent(KeyEvent.ACTION_UP, CURSOR_FLAGS, System.currentTimeMillis(), false);
                    sendEvent(KeyEvent.ACTION_DOWN, CURSOR_FLAGS, System.currentTimeMillis(), false);
                    postDelayed(mCheckLongPress, ViewConfiguration.getKeyRepeatDelay());
                } else if (mCode != 0) {
                    sendEvent(KeyEvent.ACTION_DOWN, KeyEvent.FLAG_LONG_PRESS);
@@ -377,10 +379,17 @@ public class KeyButtonView extends ImageView {
    }

    void sendEvent(int action, int flags, long when) {
        sendEvent(action, flags, when, true);
    }

    void sendEvent(int action, int flags, long when, boolean applyDefaultFlags) {
        final int repeatCount = (flags & KeyEvent.FLAG_LONG_PRESS) != 0 ? 1 : 0;
        if (applyDefaultFlags) {
            flags |= KeyEvent.FLAG_FROM_SYSTEM | KeyEvent.FLAG_VIRTUAL_HARD_KEY;
        }
        final KeyEvent ev = new KeyEvent(mDownTime, when, action, mCode, repeatCount,
                0, KeyCharacterMap.VIRTUAL_KEYBOARD, 0,
                flags | KeyEvent.FLAG_FROM_SYSTEM | KeyEvent.FLAG_VIRTUAL_HARD_KEY,
                flags,
                InputDevice.SOURCE_KEYBOARD);
        InputManager.getInstance().injectInputEvent(ev,
                InputManager.INJECT_INPUT_EVENT_MODE_ASYNC);