diff options
Diffstat (limited to 'java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java | 59 |
1 files changed, 30 insertions, 29 deletions
diff --git a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java index 375a42e3b..079e65766 100644 --- a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java +++ b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java @@ -225,10 +225,25 @@ public final class InputLogic { } boolean didAutoCorrect = false; + final int keyX, keyY; + final Keyboard keyboard = keyboardSwitcher.getKeyboard(); + final MainKeyboardView mainKeyboardView = keyboardSwitcher.getMainKeyboardView(); + // TODO: We should reconsider which coordinate system should be used to represent + // keyboard event. + if (keyboard != null && keyboard.hasProximityCharsCorrection(code)) { + // x and y include some padding, but everything down the line (especially native + // code) needs the coordinates in the keyboard frame. + // TODO: move this frame change up + keyX = mainKeyboardView.getKeyX(x); + keyY = mainKeyboardView.getKeyY(y); + } else { + keyX = Constants.NOT_A_COORDINATE; + keyY = Constants.NOT_A_COORDINATE; + } switch (code) { case Constants.CODE_DELETE: handleBackspace(settingsValues, spaceState, handler, keyboardSwitcher); - LatinImeLogger.logOnDelete(x, y); + LatinImeLogger.logOnDelete(keyX, keyY); break; case Constants.CODE_SHIFT: // Note: Calling back to the keyboard on Shift key is handled in @@ -289,16 +304,16 @@ public final class InputLogic { // No action label, and the action from imeOptions is NONE: this is a regular // enter key that should input a carriage return. didAutoCorrect = handleNonSpecialCharacter(settingsValues, Constants.CODE_ENTER, - x, y, spaceState, keyboardSwitcher, handler); + keyX, keyY, spaceState, keyboardSwitcher, handler); } break; case Constants.CODE_SHIFT_ENTER: didAutoCorrect = handleNonSpecialCharacter(settingsValues, Constants.CODE_ENTER, - x, y, spaceState, keyboardSwitcher, handler); + keyX, keyY, spaceState, keyboardSwitcher, handler); break; default: didAutoCorrect = handleNonSpecialCharacter(settingsValues, - code, x, y, spaceState, keyboardSwitcher, handler); + code, keyX, keyY, spaceState, keyboardSwitcher, handler); break; } keyboardSwitcher.onCodeInput(code); @@ -449,8 +464,12 @@ public final class InputLogic { final boolean didAutoCorrect; if (settingsValues.isWordSeparator(codePoint) || Character.getType(codePoint) == Character.OTHER_SYMBOL) { - didAutoCorrect = handleSeparator(settingsValues, codePoint, x, y, spaceState, - keyboardSwitcher, handler); + didAutoCorrect = handleSeparator(settingsValues, codePoint, + Constants.SUGGESTION_STRIP_COORDINATE == x, spaceState, keyboardSwitcher, + handler); + if (settingsValues.mIsInternal) { + LatinImeLoggerUtils.onSeparator((char)codePoint, x, y); + } } else { didAutoCorrect = false; if (SpaceState.PHANTOM == spaceState) { @@ -469,16 +488,7 @@ public final class InputLogic { commitTyped(settingsValues, LastComposedWord.NOT_A_SEPARATOR); } } - final int keyX, keyY; - final Keyboard keyboard = keyboardSwitcher.getKeyboard(); - if (keyboard != null && keyboard.hasProximityCharsCorrection(codePoint)) { - keyX = x; - keyY = y; - } else { - keyX = Constants.NOT_A_COORDINATE; - keyY = Constants.NOT_A_COORDINATE; - } - handleNonSeparator(settingsValues, codePoint, keyX, keyY, spaceState, + handleNonSeparator(settingsValues, codePoint, x, y, spaceState, keyboardSwitcher, handler); } return didAutoCorrect; @@ -545,12 +555,7 @@ public final class InputLogic { resetComposingState(false /* alsoResetLastComposedWord */); } if (isComposingWord) { - final MainKeyboardView mainKeyboardView = keyboardSwitcher.getMainKeyboardView(); - // TODO: We should reconsider which coordinate system should be used to represent - // keyboard event. - final int keyX = mainKeyboardView.getKeyX(x); - final int keyY = mainKeyboardView.getKeyY(y); - mWordComposer.add(codePoint, keyX, keyY); + mWordComposer.add(codePoint, x, y); // If it's the first letter, make note of auto-caps state if (mWordComposer.size() == 1) { // We pass 1 to getPreviousWordForSuggestion because we were not composing a word @@ -585,13 +590,12 @@ public final class InputLogic { * Handle input of a separator code point. * @param settingsValues The current settings values. * @param codePoint the code point associated with the key. - * @param x the x-coordinate of the key press, or Contants.NOT_A_COORDINATE if not applicable. - * @param y the y-coordinate of the key press, or Contants.NOT_A_COORDINATE if not applicable. + * @param isFromSuggestionStrip whether this code point comes from the suggestion strip. * @param spaceState the space state at start of the batch input. * @return whether this caused an auto-correction to happen. */ private boolean handleSeparator(final SettingsValues settingsValues, - final int codePoint, final int x, final int y, final int spaceState, + final int codePoint, final boolean isFromSuggestionStrip, final int spaceState, // TODO: remove these arguments final KeyboardSwitcher keyboardSwitcher, final LatinIME.UIHandler handler) { boolean didAutoCorrect = false; @@ -618,7 +622,7 @@ public final class InputLogic { } final boolean swapWeakSpace = maybeStripSpace(settingsValues, codePoint, spaceState, - Constants.SUGGESTION_STRIP_COORDINATE == x); + isFromSuggestionStrip); if (SpaceState.PHANTOM == spaceState && settingsValues.isUsuallyPrecededBySpace(codePoint)) { @@ -667,9 +671,6 @@ public final class InputLogic { // already displayed or not, so it's okay. mLatinIME.setPunctuationSuggestions(); } - if (settingsValues.mIsInternal) { - LatinImeLoggerUtils.onSeparator((char)codePoint, x, y); - } keyboardSwitcher.updateShiftState(); return didAutoCorrect; |