diff options
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java index f2a6f3b2e..e2feb7c4d 100644 --- a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java +++ b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java @@ -405,10 +405,11 @@ public final class InputLogic { final int keyboardShiftMode, // TODO: remove these arguments final int currentKeyboardScriptId, final LatinIME.UIHandler handler) { - final InputTransaction inputTransaction = new InputTransaction(settingsValues, event, - SystemClock.uptimeMillis(), mSpaceState, + final Event processedEvent = mWordComposer.processEvent(event); + final InputTransaction inputTransaction = new InputTransaction(settingsValues, + processedEvent, SystemClock.uptimeMillis(), mSpaceState, getActualCapsMode(settingsValues, keyboardShiftMode)); - if (event.mKeyCode != Constants.CODE_DELETE + if (processedEvent.mKeyCode != Constants.CODE_DELETE || inputTransaction.mTimestamp > mLastKeyTime + Constants.LONG_PRESS_MILLISECONDS) { mDeleteCount = 0; } @@ -419,14 +420,14 @@ public final class InputLogic { } // TODO: Consolidate the double-space period timer, mLastKeyTime, and the space state. - if (event.mCodePoint != Constants.CODE_SPACE) { + if (processedEvent.mCodePoint != Constants.CODE_SPACE) { cancelDoubleSpacePeriodCountdown(); } boolean didAutoCorrect = false; - if (event.isFunctionalKeyEvent()) { + if (processedEvent.isFunctionalKeyEvent()) { // A special key, like delete, shift, emoji, or the settings key. - switch (event.mKeyCode) { + switch (processedEvent.mKeyCode) { case Constants.CODE_DELETE: handleBackspace(inputTransaction, currentKeyboardScriptId); // Backspace is a functional key, but it affects the contents of the editor. @@ -478,7 +479,8 @@ public final class InputLogic { case Constants.CODE_SHIFT_ENTER: // TODO: remove this object final Event tmpEvent = Event.createSoftwareKeypressEvent(Constants.CODE_ENTER, - event.mKeyCode, event.mX, event.mY, event.isKeyRepeat()); + processedEvent.mKeyCode, processedEvent.mX, processedEvent.mY, + processedEvent.isKeyRepeat()); final InputTransaction tmpTransaction = new InputTransaction( inputTransaction.mSettingsValues, tmpEvent, inputTransaction.mTimestamp, inputTransaction.mSpaceState, @@ -489,11 +491,11 @@ public final class InputLogic { inputTransaction.setDidAffectContents(); break; default: - throw new RuntimeException("Unknown key code : " + event.mKeyCode); + throw new RuntimeException("Unknown key code : " + processedEvent.mKeyCode); } } else { inputTransaction.setDidAffectContents(); - switch (event.mCodePoint) { + switch (processedEvent.mCodePoint) { case Constants.CODE_ENTER: final EditorInfo editorInfo = getCurrentInputEditorInfo(); final int imeOptionsActionId = @@ -522,11 +524,11 @@ public final class InputLogic { break; } } - if (!didAutoCorrect && event.mKeyCode != Constants.CODE_SHIFT - && event.mKeyCode != Constants.CODE_CAPSLOCK - && event.mKeyCode != Constants.CODE_SWITCH_ALPHA_SYMBOL) + if (!didAutoCorrect && processedEvent.mKeyCode != Constants.CODE_SHIFT + && processedEvent.mKeyCode != Constants.CODE_CAPSLOCK + && processedEvent.mKeyCode != Constants.CODE_SWITCH_ALPHA_SYMBOL) mLastComposedWord.deactivate(); - if (Constants.CODE_DELETE != event.mKeyCode) { + if (Constants.CODE_DELETE != processedEvent.mKeyCode) { mEnteredText = null; } mConnection.endBatchEdit(); @@ -712,8 +714,7 @@ public final class InputLogic { */ private void handleNonSeparator(final SettingsValues settingsValues, final InputTransaction inputTransaction) { - final Event processedEvent = mWordComposer.processEvent(inputTransaction.mEvent); - final int codePoint = processedEvent.mCodePoint; + final int codePoint = inputTransaction.mEvent.mCodePoint; // TODO: refactor this method to stop flipping isComposingWord around all the time, and // make it shorter (possibly cut into several pieces). Also factor handleNonSpecialCharacter // which has the same name as other handle* methods but is not the same. @@ -763,7 +764,7 @@ public final class InputLogic { resetComposingState(false /* alsoResetLastComposedWord */); } if (isComposingWord) { - mWordComposer.applyProcessedEvent(processedEvent); + mWordComposer.applyProcessedEvent(inputTransaction.mEvent); // If it's the first letter, make note of auto-caps state if (mWordComposer.isSingleLetter()) { mWordComposer.setCapitalizedModeAtStartComposingTime(inputTransaction.mShiftState); @@ -772,7 +773,7 @@ public final class InputLogic { mWordComposer.getTypedWord()), 1); } else { final boolean swapWeakSpace = tryStripSpaceAndReturnWhetherShouldSwapInstead( - inputTransaction, processedEvent.isSuggestionStripPress()); + inputTransaction); if (swapWeakSpace && trySwapSwapperAndSpace(inputTransaction)) { mSpaceState = SpaceState.WEAK; @@ -823,7 +824,7 @@ public final class InputLogic { } final boolean swapWeakSpace = tryStripSpaceAndReturnWhetherShouldSwapInstead( - inputTransaction, isFromSuggestionStrip); + inputTransaction); final boolean isInsideDoubleQuoteOrAfterDigit = Constants.CODE_DOUBLE_QUOTE == codePoint && mConnection.isInsideDoubleQuoteOrAfterDigit(); @@ -903,7 +904,7 @@ public final class InputLogic { private void handleBackspace(final InputTransaction inputTransaction, // TODO: remove this argument, put it into settingsValues final int currentKeyboardScriptId) { - final Event processedEvent = mWordComposer.processEvent(inputTransaction.mEvent); + final Event event = inputTransaction.mEvent; mSpaceState = SpaceState.NONE; mDeleteCount++; @@ -915,7 +916,7 @@ public final class InputLogic { // Then again, even in the case of a key repeat, if the cursor is at start of text, it // can't go any further back, so we can update right away even if it's a key repeat. final int shiftUpdateKind = - processedEvent.isKeyRepeat() && mConnection.getExpectedSelectionStart() > 0 + event.isKeyRepeat() && mConnection.getExpectedSelectionStart() > 0 ? InputTransaction.SHIFT_UPDATE_LATER : InputTransaction.SHIFT_UPDATE_NOW; inputTransaction.requireShiftUpdate(shiftUpdateKind); @@ -935,7 +936,7 @@ public final class InputLogic { mDictionaryFacilitator.removeWordFromPersonalizedDicts(rejectedSuggestion); } } else { - mWordComposer.applyProcessedEvent(processedEvent); + mWordComposer.applyProcessedEvent(event); } if (mWordComposer.isComposingWord()) { mConnection.setComposingText(getTextWithUnderline(mWordComposer.getTypedWord()), 1); @@ -1072,12 +1073,12 @@ public final class InputLogic { /* * Strip a trailing space if necessary and returns whether it's a swap weak space situation. * @param inputTransaction The transaction in progress. - * @param isFromSuggestionStrip Whether this code point is coming from the suggestion strip. * @return whether we should swap the space instead of removing it. */ private boolean tryStripSpaceAndReturnWhetherShouldSwapInstead( - final InputTransaction inputTransaction, final boolean isFromSuggestionStrip) { + final InputTransaction inputTransaction) { final int codePoint = inputTransaction.mEvent.mCodePoint; + final boolean isFromSuggestionStrip = inputTransaction.mEvent.isSuggestionStripPress(); if (Constants.CODE_ENTER == codePoint && SpaceState.SWAP_PUNCTUATION == inputTransaction.mSpaceState) { mConnection.removeTrailingSpace(); |