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

Commit 2a884404 authored by Tadashi G. Takaoka's avatar Tadashi G. Takaoka
Browse files

Rename KeyboardActionListener methods

* Rename KeyboardActionListener.onPress to onPressKey
* Rename KeyboardActionListener.onRelease to onReleaseKey
* Merge KeyboardSwicther.onPressShift, onPressSymbol, and onPressOtherKey to onPressKey.
* Merge KeyboardSwitcher.onReleaseShift and onReleaseSymbol to onReleaseKey.
* Merge KeyboardState.onPressShift, onPressSymbol, and onPressOtherKey to onPressKey.
* Merge KeyboardState.onReleaseShift and onReleaseSymbol to onReleaseKey.

Change-Id: Icf28fd18e238c5e534c292893e4ab5b6b98e72f8
parent c9fade6b
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -434,9 +434,10 @@ public class Keyboard {
        case CODE_SHORTCUT: return "shortcut";
        case CODE_UNSPECIFIED: return "unspec";
        default:
            if (code < 0) Log.w(TAG, "Unknow negative key code=" + code);
            if (code < 0x100) return String.format("\\u%02x", code);
            return String.format("\\u04x", code);
            if (code <= 0) Log.w(TAG, "Unknown non-positive key code=" + code);
            if (code < CODE_SPACE) return String.format("'\\u%02x'", code);
            if (code < 0x100) return String.format("'%c'", code);
            return String.format("'\\u%04x'", code);
        }
    }

+4 −6
Original line number Diff line number Diff line
@@ -24,10 +24,8 @@ public interface KeyboardActionListener {
     *
     * @param primaryCode the unicode of the key being pressed. If the touch is not on a valid key,
     *            the value will be zero.
     * @param withSliding true if pressing has occurred because the user slid finger from other key
     *             to this key without releasing the finger.
     */
    public void onPress(int primaryCode, boolean withSliding);
    public void onPressKey(int primaryCode);

    /**
     * Called when the user releases a key. This is sent after the {@link #onCodeInput} is called.
@@ -37,7 +35,7 @@ public interface KeyboardActionListener {
     * @param withSliding true if releasing has occurred because the user slid finger from the key
     *             to other key without releasing the finger.
     */
    public void onRelease(int primaryCode, boolean withSliding);
    public void onReleaseKey(int primaryCode, boolean withSliding);

    /**
     * Send a key code to the listener.
@@ -79,9 +77,9 @@ public interface KeyboardActionListener {

    public static class Adapter implements KeyboardActionListener {
        @Override
        public void onPress(int primaryCode, boolean withSliding) {}
        public void onPressKey(int primaryCode) {}
        @Override
        public void onRelease(int primaryCode, boolean withSliding) {}
        public void onReleaseKey(int primaryCode, boolean withSliding) {}
        @Override
        public void onCodeInput(int primaryCode, int[] keyCodes, int x, int y) {}
        @Override
+4 −16
Original line number Diff line number Diff line
@@ -270,24 +270,12 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
        mState.onUpdateShiftState(mInputMethodService.getCurrentAutoCapsState());
    }

    public void onPressShift(boolean withSliding) {
        mState.onPressShift(withSliding);
    public void onPressKey(int code) {
        mState.onPressKey(code);
    }

    public void onReleaseShift(boolean withSliding) {
        mState.onReleaseShift(withSliding);
    }

    public void onPressSymbol() {
        mState.onPressSymbol();
    }

    public void onReleaseSymbol() {
        mState.onReleaseSymbol();
    }

    public void onOtherKeyPressed() {
        mState.onOtherKeyPressed();
    public void onReleaseKey(int code, boolean withSliding) {
        mState.onReleaseKey(code, withSliding);
    }

    public void onCancelInput() {
+6 −6
Original line number Diff line number Diff line
@@ -417,9 +417,9 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
        // the second tap is treated as this double tap event, so that we need not mark tracker
        // calling setAlreadyProcessed() nor remove the tracker from mPointerQueue.
        if (ignore) {
            mKeyboardActionListener.onCustomRequest(LatinIME.CODE_HAPTIC_AND_AUDIO_FEEDBACK);
            invokeCustomRequest(LatinIME.CODE_HAPTIC_AND_AUDIO_FEEDBACK);
        } else {
            mKeyboardActionListener.onCodeInput(Keyboard.CODE_CAPSLOCK, null, 0, 0);
            invokeCodeInput(Keyboard.CODE_CAPSLOCK);
        }
    }

@@ -479,17 +479,17 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
    }

    private boolean invokeCustomRequest(int code) {
        return getKeyboardActionListener().onCustomRequest(code);
        return mKeyboardActionListener.onCustomRequest(code);
    }

    private void invokeCodeInput(int primaryCode) {
        getKeyboardActionListener().onCodeInput(primaryCode, null,
        mKeyboardActionListener.onCodeInput(primaryCode, null,
                KeyboardActionListener.NOT_A_TOUCH_COORDINATE,
                KeyboardActionListener.NOT_A_TOUCH_COORDINATE);
    }

    private void invokeReleaseKey(int primaryCode) {
        getKeyboardActionListener().onRelease(primaryCode, false);
        mKeyboardActionListener.onReleaseKey(primaryCode, false);
    }

    private boolean openMoreKeysPanel(Key parentKey, PointerTracker tracker) {
@@ -514,7 +514,7 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
                : parentKey.mX + parentKey.mWidth / 2;
        final int pointY = parentKey.mY - keyboard.mVerticalGap;
        moreKeysPanel.showMoreKeysPanel(
                this, this, pointX, pointY, mMoreKeysWindow, getKeyboardActionListener());
                this, this, pointX, pointY, mMoreKeysWindow, mKeyboardActionListener);
        final int translatedX = moreKeysPanel.translateX(tracker.getLastX());
        final int translatedY = moreKeysPanel.translateY(tracker.getLastY());
        tracker.onShowMoreKeysPanel(translatedX, translatedY, moreKeysPanel);
+5 −4
Original line number Diff line number Diff line
@@ -61,12 +61,13 @@ public class MiniKeyboardView extends KeyboardView implements MoreKeysPanel {
        }

        @Override
        public void onPress(int primaryCode, boolean withSliding) {
            mListener.onPress(primaryCode, withSliding);
        public void onPressKey(int primaryCode) {
            mListener.onPressKey(primaryCode);
        }

        @Override
        public void onRelease(int primaryCode, boolean withSliding) {
            mListener.onRelease(primaryCode, withSliding);
        public void onReleaseKey(int primaryCode, boolean withSliding) {
            mListener.onReleaseKey(primaryCode, withSliding);
        }
    };

Loading