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

Commit 5b74989b authored by Tadashi G. Takaoka's avatar Tadashi G. Takaoka
Browse files

Minor refactoring of Keyboard

* Remove isAlphaKeyboard().
* Remove isPhoneKeyboard().
* Remove getKeyboardShiftState().

Bug: 5708602
Change-Id: I8bf5009bf499ecb0501d1379f72e43406080062a
parent 46831d5a
Loading
Loading
Loading
Loading
+5 −16
Original line number Diff line number Diff line
@@ -112,7 +112,8 @@ public class Keyboard {
    public final KeyboardIconsSet mIconsSet;

    private final Map<Integer, Key> mKeyCache = new HashMap<Integer, Key>();
    private final KeyboardShiftState mShiftState = new KeyboardShiftState();
    // TODO: Move this state to KeyboardSwitcher
    /* package for debug */ final KeyboardShiftState mShiftState = new KeyboardShiftState();

    private final ProximityInfo mProximityInfo;

@@ -211,27 +212,15 @@ public class Keyboard {
    }

    public boolean isAutomaticTemporaryUpperCase() {
        return isAlphaKeyboard() && mShiftState.isAutomaticTemporaryUpperCase();
        return mId.isAlphabetKeyboard() && mShiftState.isAutomaticTemporaryUpperCase();
    }

    public boolean isManualTemporaryUpperCase() {
        return isAlphaKeyboard() && mShiftState.isManualTemporaryUpperCase();
        return mId.isAlphabetKeyboard() && mShiftState.isManualTemporaryUpperCase();
    }

    public boolean isManualTemporaryUpperCaseFromAuto() {
        return isAlphaKeyboard() && mShiftState.isManualTemporaryUpperCaseFromAuto();
    }

    public KeyboardShiftState getKeyboardShiftState() {
        return mShiftState;
    }

    public boolean isAlphaKeyboard() {
        return mId.isAlphabetKeyboard();
    }

    public boolean isPhoneKeyboard() {
        return mId.isPhoneKeyboard();
        return mId.isAlphabetKeyboard() && mShiftState.isManualTemporaryUpperCaseFromAuto();
    }

    public CharSequence adjustLabelCase(CharSequence label) {
+9 −9
Original line number Diff line number Diff line
@@ -450,7 +450,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
        mInputMethodService.mHandler.cancelUpdateShiftState();
        if (DEBUG_STATE) {
            Log.d(TAG, "toggleShift:"
                    + " keyboard=" + getLatinKeyboard().getKeyboardShiftState()
                    + " keyboard=" + getLatinKeyboard().mShiftState
                    + " state=" + mState);
        }
        if (isAlphabetMode()) {
@@ -464,7 +464,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
        mInputMethodService.mHandler.cancelUpdateShiftState();
        if (DEBUG_STATE) {
            Log.d(TAG, "toggleCapsLock:"
                    + " keyboard=" + getLatinKeyboard().getKeyboardShiftState()
                    + " keyboard=" + getLatinKeyboard().mShiftState
                    + " state=" + mState);
        }
        if (isAlphabetMode()) {
@@ -482,7 +482,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
    public void changeKeyboardMode() {
        if (DEBUG_STATE) {
            Log.d(TAG, "changeKeyboardMode:"
                    + " keyboard=" + getLatinKeyboard().getKeyboardShiftState()
                    + " keyboard=" + getLatinKeyboard().mShiftState
                    + " state=" + mState);
        }
        toggleKeyboardMode();
@@ -507,7 +507,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
        if (DEBUG_STATE) {
            Log.d(TAG, "updateShiftState:"
                    + " autoCaps=" + mInputMethodService.getCurrentAutoCapsState()
                    + " keyboard=" + getLatinKeyboard().getKeyboardShiftState()
                    + " keyboard=" + getLatinKeyboard().mShiftState
                    + " isAlphabetMode=" + isAlphabetMode
                    + " isShiftLocked=" + isShiftLocked
                    + " state=" + mState);
@@ -530,7 +530,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
            return;
        if (DEBUG_STATE) {
            Log.d(TAG, "onPressShift:"
                    + " keyboard=" + getLatinKeyboard().getKeyboardShiftState()
                    + " keyboard=" + getLatinKeyboard().mShiftState
                    + " state=" + mState + " sliding=" + withSliding);
        }
        final boolean isAlphabetMode = isAlphabetMode();
@@ -567,7 +567,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
            return;
        if (DEBUG_STATE) {
            Log.d(TAG, "onReleaseShift:"
                    + " keyboard=" + getLatinKeyboard().getKeyboardShiftState()
                    + " keyboard=" + getLatinKeyboard().mShiftState
                    + " state=" + mState + " sliding=" + withSliding);
        }
        final boolean isAlphabetMode = isAlphabetMode();
@@ -612,7 +612,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
    public void onPressSymbol() {
        if (DEBUG_STATE) {
            Log.d(TAG, "onPressSymbol:"
                    + " keyboard=" + getLatinKeyboard().getKeyboardShiftState()
                    + " keyboard=" + getLatinKeyboard().mShiftState
                    + " state=" + mState);
        }
        changeKeyboardMode();
@@ -623,7 +623,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
    public void onReleaseSymbol() {
        if (DEBUG_STATE) {
            Log.d(TAG, "onReleaseSymbol:"
                    + " keyboard=" + getLatinKeyboard().getKeyboardShiftState()
                    + " keyboard=" + getLatinKeyboard().mShiftState
                    + " state=" + mState);
        }
        // Snap back to the previous keyboard mode if the user chords the mode change key and
@@ -637,7 +637,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
    public void onOtherKeyPressed() {
        if (DEBUG_STATE) {
            Log.d(TAG, "onOtherKeyPressed:"
                    + " keyboard=" + getLatinKeyboard().getKeyboardShiftState()
                    + " keyboard=" + getLatinKeyboard().mShiftState
                    + " state=" + mState);
        }
        mState.onOtherKeyPressed();
+1 −1
Original line number Diff line number Diff line
@@ -176,7 +176,7 @@ public class LatinKeyboard extends Keyboard {

    @Override
    public CharSequence adjustLabelCase(CharSequence label) {
        if (isAlphaKeyboard() && isShiftedOrShiftLocked() && !TextUtils.isEmpty(label)
        if (mId.isAlphabetKeyboard() && isShiftedOrShiftLocked() && !TextUtils.isEmpty(label)
                && label.length() < 3 && Character.isLowerCase(label.charAt(0))) {
            return label.toString().toUpperCase(mId.mLocale);
        }
+3 −3
Original line number Diff line number Diff line
@@ -177,7 +177,7 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
        public boolean onDoubleTap(MotionEvent firstDown) {
            final Keyboard keyboard = getKeyboard();
            if (ENABLE_CAPSLOCK_BY_DOUBLETAP && keyboard instanceof LatinKeyboard
                    && ((LatinKeyboard) keyboard).isAlphaKeyboard()) {
                    && ((LatinKeyboard) keyboard).mId.isAlphabetKeyboard()) {
                final int pointerIndex = firstDown.getActionIndex();
                final int id = firstDown.getPointerId(pointerIndex);
                final PointerTracker tracker = getPointerTracker(id);
@@ -396,14 +396,14 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
        final Keyboard keyboard = getKeyboard();
        if (keyboard instanceof LatinKeyboard) {
            final LatinKeyboard latinKeyboard = (LatinKeyboard) keyboard;
            if (primaryCode == Keyboard.CODE_DIGIT0 && latinKeyboard.isPhoneKeyboard()) {
            if (primaryCode == Keyboard.CODE_DIGIT0 && latinKeyboard.mId.isPhoneKeyboard()) {
                tracker.onLongPressed();
                // Long pressing on 0 in phone number keypad gives you a '+'.
                invokeCodeInput(Keyboard.CODE_PLUS);
                invokeReleaseKey(primaryCode);
                return true;
            }
            if (primaryCode == Keyboard.CODE_SHIFT && latinKeyboard.isAlphaKeyboard()) {
            if (primaryCode == Keyboard.CODE_SHIFT && latinKeyboard.mId.isAlphabetKeyboard()) {
                tracker.onLongPressed();
                invokeCodeInput(Keyboard.CODE_CAPSLOCK);
                invokeReleaseKey(primaryCode);