Loading java/src/com/android/inputmethod/keyboard/KeyboardActionListener.java +2 −3 Original line number Diff line number Diff line Loading @@ -20,7 +20,6 @@ import com.android.inputmethod.latin.Constants; import com.android.inputmethod.latin.InputPointers; public interface KeyboardActionListener { /** * Called when the user presses a key. This is sent before the {@link #onCodeInput} is called. * For keys that repeat, this is only called once. Loading Loading @@ -99,9 +98,9 @@ public interface KeyboardActionListener { */ public boolean onCustomRequest(int requestCode); public static class Adapter implements KeyboardActionListener { public static final Adapter EMPTY_LISTENER = new Adapter(); public static final KeyboardActionListener EMPTY_LISTENER = new Adapter(); public static class Adapter implements KeyboardActionListener { @Override public void onPressKey(int primaryCode, boolean isSinglePointer) {} @Override Loading java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java +0 −9 Original line number Diff line number Diff line Loading @@ -31,7 +31,6 @@ import com.android.inputmethod.accessibility.AccessibleKeyboardViewProxy; import com.android.inputmethod.keyboard.KeyboardLayoutSet.KeyboardLayoutSetException; import com.android.inputmethod.keyboard.PointerTracker.TimerProxy; import com.android.inputmethod.keyboard.internal.KeyboardState; import com.android.inputmethod.latin.AudioAndHapticFeedbackManager; import com.android.inputmethod.latin.InputView; import com.android.inputmethod.latin.LatinIME; import com.android.inputmethod.latin.LatinImeLogger; Loading Loading @@ -210,7 +209,6 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions { } public void onPressKey(final int code, final boolean isSinglePointer) { hapticAndAudioFeedback(code); mState.onPressKey(code, isSinglePointer, mLatinIME.getCurrentAutoCapsState()); } Loading Loading @@ -299,13 +297,6 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions { ? keyboardView.getTimerProxy().isInDoubleTapShiftKeyTimeout() : false; } private void hapticAndAudioFeedback(final int code) { if (mKeyboardView == null || mKeyboardView.isInSlidingKeyInput()) { return; } AudioAndHapticFeedbackManager.getInstance().hapticAndAudioFeedback(code, mKeyboardView); } /** * Updates state machine to figure out when to automatically switch back to the previous mode. */ Loading java/src/com/android/inputmethod/keyboard/MainKeyboardView.java +19 −26 Original line number Diff line number Diff line Loading @@ -57,10 +57,8 @@ import com.android.inputmethod.keyboard.internal.KeyPreviewDrawParams; import com.android.inputmethod.keyboard.internal.PreviewPlacerView; import com.android.inputmethod.keyboard.internal.SlidingKeyInputPreview; import com.android.inputmethod.keyboard.internal.TouchScreenRegulator; import com.android.inputmethod.latin.AudioAndHapticFeedbackManager; import com.android.inputmethod.latin.Constants; import com.android.inputmethod.latin.DebugSettings; import com.android.inputmethod.latin.LatinIME; import com.android.inputmethod.latin.LatinImeLogger; import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.Settings; Loading Loading @@ -240,11 +238,15 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack break; case MSG_REPEAT_KEY: final Key currentKey = tracker.getKey(); if (currentKey != null && currentKey.mCode == msg.arg1) { tracker.onRepeatKey(currentKey); AudioAndHapticFeedbackManager.getInstance().hapticAndAudioFeedback( currentKey.mCode, keyboardView); final int code = msg.arg1; if (currentKey != null && currentKey.mCode == code) { startKeyRepeatTimer(tracker, mKeyRepeatInterval); startTypingStateTimer(currentKey); final KeyboardActionListener listener = keyboardView.getKeyboardActionListener(); listener.onPressKey(code, true /* isSinglePointer */); listener.onCodeInput(code, Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE); } break; case MSG_LONGPRESS_KEY: Loading Loading @@ -564,6 +566,8 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack altCodeKeyWhileTypingFadeoutAnimatorResId, this); mAltCodeKeyWhileTypingFadeinAnimator = loadObjectAnimator( altCodeKeyWhileTypingFadeinAnimatorResId, this); mKeyboardActionListener = KeyboardActionListener.EMPTY_LISTENER; } private ObjectAnimator loadObjectAnimator(final int resId, final Object target) { Loading Loading @@ -977,39 +981,28 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) { ResearchLogger.mainKeyboardView_onLongPress(); } final int code = key.mCode; final KeyboardActionListener listener = mKeyboardActionListener; if (key.hasNoPanelAutoMoreKey()) { final int embeddedCode = key.mMoreKeys[0].mCode; final int moreKeyCode = key.mMoreKeys[0].mCode; tracker.onLongPressed(); invokeCodeInput(embeddedCode); invokeReleaseKey(code); AudioAndHapticFeedbackManager.getInstance().hapticAndAudioFeedback(code, this); listener.onPressKey(moreKeyCode, true /* isSinglePointer */); listener.onCodeInput(moreKeyCode, Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE); listener.onReleaseKey(moreKeyCode, false /* withSliding */); return; } final int code = key.mCode; if (code == Constants.CODE_SPACE || code == Constants.CODE_LANGUAGE_SWITCH) { // Long pressing the space key invokes IME switcher dialog. if (invokeCustomRequest(LatinIME.CODE_SHOW_INPUT_METHOD_PICKER)) { if (listener.onCustomRequest(Constants.CUSTOM_CODE_SHOW_INPUT_METHOD_PICKER)) { tracker.onLongPressed(); invokeReleaseKey(code); listener.onReleaseKey(code, false /* withSliding */); return; } } openMoreKeysPanel(key, tracker); } private boolean invokeCustomRequest(final int requestCode) { return mKeyboardActionListener.onCustomRequest(requestCode); } private void invokeCodeInput(final int code) { mKeyboardActionListener.onCodeInput( code, Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE); } private void invokeReleaseKey(final int code) { mKeyboardActionListener.onReleaseKey(code, false); } private void openMoreKeysPanel(final Key key, final PointerTracker tracker) { final MoreKeysPanel moreKeysPanel = onCreateMoreKeysPanel(key, getContext()); if (moreKeysPanel == null) { Loading java/src/com/android/inputmethod/keyboard/PointerTracker.java +2 −7 Original line number Diff line number Diff line Loading @@ -175,7 +175,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element { private DrawingProxy mDrawingProxy; private TimerProxy mTimerProxy; private KeyDetector mKeyDetector; private KeyboardActionListener mListener = KeyboardActionListener.Adapter.EMPTY_LISTENER; private KeyboardActionListener mListener = KeyboardActionListener.EMPTY_LISTENER; private Keyboard mKeyboard; private int mPhantonSuddenMoveThreshold; Loading Loading @@ -1263,13 +1263,8 @@ public final class PointerTracker implements PointerTrackerQueue.Element { if (!key.isRepeatable()) return; // Don't start key repeat when we are in sliding input mode. if (mIsInSlidingKeyInput) return; onRepeatKey(key); mTimerProxy.startKeyRepeatTimer(this); } public void onRepeatKey(final Key key) { detectAndSendKey(key, key.mX, key.mY, SystemClock.uptimeMillis()); mTimerProxy.startTypingStateTimer(key); mTimerProxy.startKeyRepeatTimer(this); } private boolean isMajorEnoughMoveToBeOnNewKey(final int x, final int y, final long eventTime, Loading java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java +4 −13 Original line number Diff line number Diff line Loading @@ -81,9 +81,6 @@ public final class KeyboardState { private boolean mPrevSymbolsKeyboardWasShifted; private int mRecapitalizeMode; // For handling long press. private boolean mLongPressShiftLockFired; // For handling double tap. private boolean mIsInAlphabetUnshiftedFromShifted; private boolean mIsInDoubleTapShiftKey; Loading Loading @@ -325,10 +322,11 @@ public final class KeyboardState { } if (code == Constants.CODE_SHIFT) { onPressShift(); } else if (code == Constants.CODE_CAPSLOCK) { // Nothing to do here. See {@link #onReleaseKey(int,boolean)}. } else if (code == Constants.CODE_SWITCH_ALPHA_SYMBOL) { onPressSymbol(); } else { mLongPressShiftLockFired = false; mShiftKeyState.onOtherKeyPressed(); mSymbolKeyState.onOtherKeyPressed(); // It is required to reset the auto caps state when all of the following conditions Loading Loading @@ -356,6 +354,8 @@ public final class KeyboardState { } if (code == Constants.CODE_SHIFT) { onReleaseShift(withSliding); } else if (code == Constants.CODE_CAPSLOCK) { setShiftLocked(!mAlphabetShiftState.isShiftLocked()); } else if (code == Constants.CODE_SWITCH_ALPHA_SYMBOL) { onReleaseSymbol(withSliding); } Loading Loading @@ -437,7 +437,6 @@ public final class KeyboardState { } private void onPressShift() { mLongPressShiftLockFired = false; // If we are recapitalizing, we don't do any of the normal processing, including // importantly the double tap timer. if (RecapitalizeStatus.NOT_A_RECAPITALIZE_MODE != mRecapitalizeMode) { Loading Loading @@ -499,8 +498,6 @@ public final class KeyboardState { // Double tap shift key has been handled in {@link #onPressShift}, so that just // ignore this release shift key here. mIsInDoubleTapShiftKey = false; } else if (mLongPressShiftLockFired) { setShiftLocked(!mAlphabetShiftState.isShiftLocked()); } else if (mShiftKeyState.isChording()) { if (mAlphabetShiftState.isShiftLockShifted()) { // After chording input while shift locked state. Loading Loading @@ -610,12 +607,6 @@ public final class KeyboardState { break; } if (code == Constants.CODE_CAPSLOCK) { // Changing shift lock state will be handled at {@link #onPressShift()} when the shift // key is released. mLongPressShiftLockFired = true; } // If the code is a letter, update keyboard shift state. if (Constants.isLetterCode(code)) { updateAlphabetShiftState(autoCaps, RecapitalizeStatus.NOT_A_RECAPITALIZE_MODE); Loading Loading
java/src/com/android/inputmethod/keyboard/KeyboardActionListener.java +2 −3 Original line number Diff line number Diff line Loading @@ -20,7 +20,6 @@ import com.android.inputmethod.latin.Constants; import com.android.inputmethod.latin.InputPointers; public interface KeyboardActionListener { /** * Called when the user presses a key. This is sent before the {@link #onCodeInput} is called. * For keys that repeat, this is only called once. Loading Loading @@ -99,9 +98,9 @@ public interface KeyboardActionListener { */ public boolean onCustomRequest(int requestCode); public static class Adapter implements KeyboardActionListener { public static final Adapter EMPTY_LISTENER = new Adapter(); public static final KeyboardActionListener EMPTY_LISTENER = new Adapter(); public static class Adapter implements KeyboardActionListener { @Override public void onPressKey(int primaryCode, boolean isSinglePointer) {} @Override Loading
java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java +0 −9 Original line number Diff line number Diff line Loading @@ -31,7 +31,6 @@ import com.android.inputmethod.accessibility.AccessibleKeyboardViewProxy; import com.android.inputmethod.keyboard.KeyboardLayoutSet.KeyboardLayoutSetException; import com.android.inputmethod.keyboard.PointerTracker.TimerProxy; import com.android.inputmethod.keyboard.internal.KeyboardState; import com.android.inputmethod.latin.AudioAndHapticFeedbackManager; import com.android.inputmethod.latin.InputView; import com.android.inputmethod.latin.LatinIME; import com.android.inputmethod.latin.LatinImeLogger; Loading Loading @@ -210,7 +209,6 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions { } public void onPressKey(final int code, final boolean isSinglePointer) { hapticAndAudioFeedback(code); mState.onPressKey(code, isSinglePointer, mLatinIME.getCurrentAutoCapsState()); } Loading Loading @@ -299,13 +297,6 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions { ? keyboardView.getTimerProxy().isInDoubleTapShiftKeyTimeout() : false; } private void hapticAndAudioFeedback(final int code) { if (mKeyboardView == null || mKeyboardView.isInSlidingKeyInput()) { return; } AudioAndHapticFeedbackManager.getInstance().hapticAndAudioFeedback(code, mKeyboardView); } /** * Updates state machine to figure out when to automatically switch back to the previous mode. */ Loading
java/src/com/android/inputmethod/keyboard/MainKeyboardView.java +19 −26 Original line number Diff line number Diff line Loading @@ -57,10 +57,8 @@ import com.android.inputmethod.keyboard.internal.KeyPreviewDrawParams; import com.android.inputmethod.keyboard.internal.PreviewPlacerView; import com.android.inputmethod.keyboard.internal.SlidingKeyInputPreview; import com.android.inputmethod.keyboard.internal.TouchScreenRegulator; import com.android.inputmethod.latin.AudioAndHapticFeedbackManager; import com.android.inputmethod.latin.Constants; import com.android.inputmethod.latin.DebugSettings; import com.android.inputmethod.latin.LatinIME; import com.android.inputmethod.latin.LatinImeLogger; import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.Settings; Loading Loading @@ -240,11 +238,15 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack break; case MSG_REPEAT_KEY: final Key currentKey = tracker.getKey(); if (currentKey != null && currentKey.mCode == msg.arg1) { tracker.onRepeatKey(currentKey); AudioAndHapticFeedbackManager.getInstance().hapticAndAudioFeedback( currentKey.mCode, keyboardView); final int code = msg.arg1; if (currentKey != null && currentKey.mCode == code) { startKeyRepeatTimer(tracker, mKeyRepeatInterval); startTypingStateTimer(currentKey); final KeyboardActionListener listener = keyboardView.getKeyboardActionListener(); listener.onPressKey(code, true /* isSinglePointer */); listener.onCodeInput(code, Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE); } break; case MSG_LONGPRESS_KEY: Loading Loading @@ -564,6 +566,8 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack altCodeKeyWhileTypingFadeoutAnimatorResId, this); mAltCodeKeyWhileTypingFadeinAnimator = loadObjectAnimator( altCodeKeyWhileTypingFadeinAnimatorResId, this); mKeyboardActionListener = KeyboardActionListener.EMPTY_LISTENER; } private ObjectAnimator loadObjectAnimator(final int resId, final Object target) { Loading Loading @@ -977,39 +981,28 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) { ResearchLogger.mainKeyboardView_onLongPress(); } final int code = key.mCode; final KeyboardActionListener listener = mKeyboardActionListener; if (key.hasNoPanelAutoMoreKey()) { final int embeddedCode = key.mMoreKeys[0].mCode; final int moreKeyCode = key.mMoreKeys[0].mCode; tracker.onLongPressed(); invokeCodeInput(embeddedCode); invokeReleaseKey(code); AudioAndHapticFeedbackManager.getInstance().hapticAndAudioFeedback(code, this); listener.onPressKey(moreKeyCode, true /* isSinglePointer */); listener.onCodeInput(moreKeyCode, Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE); listener.onReleaseKey(moreKeyCode, false /* withSliding */); return; } final int code = key.mCode; if (code == Constants.CODE_SPACE || code == Constants.CODE_LANGUAGE_SWITCH) { // Long pressing the space key invokes IME switcher dialog. if (invokeCustomRequest(LatinIME.CODE_SHOW_INPUT_METHOD_PICKER)) { if (listener.onCustomRequest(Constants.CUSTOM_CODE_SHOW_INPUT_METHOD_PICKER)) { tracker.onLongPressed(); invokeReleaseKey(code); listener.onReleaseKey(code, false /* withSliding */); return; } } openMoreKeysPanel(key, tracker); } private boolean invokeCustomRequest(final int requestCode) { return mKeyboardActionListener.onCustomRequest(requestCode); } private void invokeCodeInput(final int code) { mKeyboardActionListener.onCodeInput( code, Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE); } private void invokeReleaseKey(final int code) { mKeyboardActionListener.onReleaseKey(code, false); } private void openMoreKeysPanel(final Key key, final PointerTracker tracker) { final MoreKeysPanel moreKeysPanel = onCreateMoreKeysPanel(key, getContext()); if (moreKeysPanel == null) { Loading
java/src/com/android/inputmethod/keyboard/PointerTracker.java +2 −7 Original line number Diff line number Diff line Loading @@ -175,7 +175,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element { private DrawingProxy mDrawingProxy; private TimerProxy mTimerProxy; private KeyDetector mKeyDetector; private KeyboardActionListener mListener = KeyboardActionListener.Adapter.EMPTY_LISTENER; private KeyboardActionListener mListener = KeyboardActionListener.EMPTY_LISTENER; private Keyboard mKeyboard; private int mPhantonSuddenMoveThreshold; Loading Loading @@ -1263,13 +1263,8 @@ public final class PointerTracker implements PointerTrackerQueue.Element { if (!key.isRepeatable()) return; // Don't start key repeat when we are in sliding input mode. if (mIsInSlidingKeyInput) return; onRepeatKey(key); mTimerProxy.startKeyRepeatTimer(this); } public void onRepeatKey(final Key key) { detectAndSendKey(key, key.mX, key.mY, SystemClock.uptimeMillis()); mTimerProxy.startTypingStateTimer(key); mTimerProxy.startKeyRepeatTimer(this); } private boolean isMajorEnoughMoveToBeOnNewKey(final int x, final int y, final long eventTime, Loading
java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java +4 −13 Original line number Diff line number Diff line Loading @@ -81,9 +81,6 @@ public final class KeyboardState { private boolean mPrevSymbolsKeyboardWasShifted; private int mRecapitalizeMode; // For handling long press. private boolean mLongPressShiftLockFired; // For handling double tap. private boolean mIsInAlphabetUnshiftedFromShifted; private boolean mIsInDoubleTapShiftKey; Loading Loading @@ -325,10 +322,11 @@ public final class KeyboardState { } if (code == Constants.CODE_SHIFT) { onPressShift(); } else if (code == Constants.CODE_CAPSLOCK) { // Nothing to do here. See {@link #onReleaseKey(int,boolean)}. } else if (code == Constants.CODE_SWITCH_ALPHA_SYMBOL) { onPressSymbol(); } else { mLongPressShiftLockFired = false; mShiftKeyState.onOtherKeyPressed(); mSymbolKeyState.onOtherKeyPressed(); // It is required to reset the auto caps state when all of the following conditions Loading Loading @@ -356,6 +354,8 @@ public final class KeyboardState { } if (code == Constants.CODE_SHIFT) { onReleaseShift(withSliding); } else if (code == Constants.CODE_CAPSLOCK) { setShiftLocked(!mAlphabetShiftState.isShiftLocked()); } else if (code == Constants.CODE_SWITCH_ALPHA_SYMBOL) { onReleaseSymbol(withSliding); } Loading Loading @@ -437,7 +437,6 @@ public final class KeyboardState { } private void onPressShift() { mLongPressShiftLockFired = false; // If we are recapitalizing, we don't do any of the normal processing, including // importantly the double tap timer. if (RecapitalizeStatus.NOT_A_RECAPITALIZE_MODE != mRecapitalizeMode) { Loading Loading @@ -499,8 +498,6 @@ public final class KeyboardState { // Double tap shift key has been handled in {@link #onPressShift}, so that just // ignore this release shift key here. mIsInDoubleTapShiftKey = false; } else if (mLongPressShiftLockFired) { setShiftLocked(!mAlphabetShiftState.isShiftLocked()); } else if (mShiftKeyState.isChording()) { if (mAlphabetShiftState.isShiftLockShifted()) { // After chording input while shift locked state. Loading Loading @@ -610,12 +607,6 @@ public final class KeyboardState { break; } if (code == Constants.CODE_CAPSLOCK) { // Changing shift lock state will be handled at {@link #onPressShift()} when the shift // key is released. mLongPressShiftLockFired = true; } // If the code is a letter, update keyboard shift state. if (Constants.isLetterCode(code)) { updateAlphabetShiftState(autoCaps, RecapitalizeStatus.NOT_A_RECAPITALIZE_MODE); Loading