[CB23] Merge add and deleteLast

Bug: 13406701
Change-Id: Id9a2e4144b1908ad27d78228ee19e6fc4d4d669f
main
Jean Chalard 2014-03-27 16:12:58 +09:00
parent 633e4f4533
commit d52bec0069
2 changed files with 11 additions and 18 deletions

View File

@ -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)));
}

View File

@ -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();