From d52bec00695a6e43b8e8836112919c02952d4dcc Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Thu, 27 Mar 2014 16:12:58 +0900 Subject: [PATCH] [CB23] Merge add and deleteLast Bug: 13406701 Change-Id: Id9a2e4144b1908ad27d78228ee19e6fc4d4d669f --- .../inputmethod/latin/WordComposer.java | 25 +++++++------------ .../latin/inputlogic/InputLogic.java | 4 +-- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/WordComposer.java b/java/src/com/android/inputmethod/latin/WordComposer.java index d30ed2ef8..81d642ff2 100644 --- a/java/src/com/android/inputmethod/latin/WordComposer.java +++ b/java/src/com/android/inputmethod/latin/WordComposer.java @@ -165,14 +165,14 @@ public final class WordComposer { } /** - * Add a new event for a key stroke, with the pressed key's code point with the touch point - * coordinates. + * Process an input event. + * + * All input events should be supported, including software/hardware events, characters as well + * as deletions, multiple inputs and gestures. + * + * @param event the event to process. */ - public void add(final Event event) { - processEvent(event); - } - - private void processEvent(final Event event) { + public void processEvent(final Event event) { final int primaryCode = event.mCodePoint; final int keyX = event.mX; final int keyY = event.mY; @@ -223,13 +223,6 @@ public final class WordComposer { mAutoCorrection = null; } - /** - * Delete the last composing unit as a result of hitting backspace. - */ - public void deleteLast(final Event event) { - processEvent(event); - } - public void setCursorPositionWithinWord(final int posWithinWord) { mCursorPositionWithinWord = posWithinWord; // TODO: compute where that puts us inside the events @@ -301,7 +294,7 @@ public final class WordComposer { final int codePoint = Character.codePointAt(word, i); // We don't want to override the batch input points that are held in mInputPointers // (See {@link #add(int,int,int)}). - add(Event.createEventForCodePointFromUnknownSource(codePoint)); + processEvent(Event.createEventForCodePointFromUnknownSource(codePoint)); } } @@ -318,7 +311,7 @@ public final class WordComposer { reset(); final int length = codePoints.length; for (int i = 0; i < length; ++i) { - add(Event.createEventForCodePointFromAlreadyTypedText(codePoints[i], + processEvent(Event.createEventForCodePointFromAlreadyTypedText(codePoints[i], CoordinateUtils.xFromArray(coordinates, i), CoordinateUtils.yFromArray(coordinates, i))); } diff --git a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java index 7ffc95697..7cf8c5e49 100644 --- a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java +++ b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java @@ -727,7 +727,7 @@ public final class InputLogic { resetComposingState(false /* alsoResetLastComposedWord */); } if (isComposingWord) { - mWordComposer.add(inputTransaction.mEvent); + mWordComposer.processEvent(inputTransaction.mEvent); // If it's the first letter, make note of auto-caps state if (mWordComposer.isSingleLetter()) { // We pass 1 to getPreviousWordForSuggestion because we were not composing a word @@ -893,7 +893,7 @@ public final class InputLogic { mWordComposer.reset(); mWordComposer.setRejectedBatchModeSuggestion(rejectedSuggestion); } else { - mWordComposer.deleteLast(inputTransaction.mEvent); + mWordComposer.processEvent(inputTransaction.mEvent); } mConnection.setComposingText(getTextWithUnderline(mWordComposer.getTypedWord()), 1); inputTransaction.setRequiresUpdateSuggestions();