diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardActionListener.java b/java/src/com/android/inputmethod/keyboard/KeyboardActionListener.java index 1f3ee7680..b1621a55b 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardActionListener.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardActionListener.java @@ -17,7 +17,6 @@ package com.android.inputmethod.keyboard; import com.android.inputmethod.latin.InputPointers; -import com.android.inputmethod.latin.SuggestedWords; public interface KeyboardActionListener { @@ -73,18 +72,17 @@ public interface KeyboardActionListener { public void onStartBatchInput(); /** - * Sends the batch input points data to get updated suggestions + * Sends the ongoing batch input points data. * @param batchPointers the batch input points representing the user input - * @return updated suggestions that reflects the user input */ - public SuggestedWords onUpdateBatchInput(InputPointers batchPointers); + public void onUpdateBatchInput(InputPointers batchPointers); /** - * Sends a sequence of characters to the listener as batch input. + * Sends the final batch input points data. * - * @param text the sequence of characters to be displayed as composing text. + * @param batchPointers the batch input points representing the user input */ - public void onEndBatchInput(CharSequence text); + public void onEndBatchInput(InputPointers batchPointers); /** * Called when user released a finger outside any key. @@ -109,9 +107,9 @@ public interface KeyboardActionListener { @Override public void onStartBatchInput() {} @Override - public SuggestedWords onUpdateBatchInput(InputPointers batchPointers) { return null; } + public void onUpdateBatchInput(InputPointers batchPointers) {} @Override - public void onEndBatchInput(CharSequence text) {} + public void onEndBatchInput(InputPointers batchPointers) {} @Override public void onCancelInput() {} @Override diff --git a/java/src/com/android/inputmethod/keyboard/MoreKeysKeyboardView.java b/java/src/com/android/inputmethod/keyboard/MoreKeysKeyboardView.java index 9c8069194..870eff29f 100644 --- a/java/src/com/android/inputmethod/keyboard/MoreKeysKeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/MoreKeysKeyboardView.java @@ -25,6 +25,7 @@ import android.widget.PopupWindow; import com.android.inputmethod.keyboard.PointerTracker.DrawingProxy; import com.android.inputmethod.keyboard.PointerTracker.TimerProxy; +import com.android.inputmethod.latin.InputPointers; import com.android.inputmethod.latin.R; /** @@ -63,8 +64,13 @@ public class MoreKeysKeyboardView extends KeyboardView implements MoreKeysPanel } @Override - public void onEndBatchInput(CharSequence text) { - mListener.onEndBatchInput(text); + public void onUpdateBatchInput(InputPointers batchPointers) { + mListener.onUpdateBatchInput(batchPointers); + } + + @Override + public void onEndBatchInput(InputPointers batchPointers) { + mListener.onEndBatchInput(batchPointers); } @Override diff --git a/java/src/com/android/inputmethod/keyboard/internal/GestureTracker.java b/java/src/com/android/inputmethod/keyboard/internal/GestureTracker.java index 0f14dcef4..fbfa66332 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/GestureTracker.java +++ b/java/src/com/android/inputmethod/keyboard/internal/GestureTracker.java @@ -21,7 +21,6 @@ import com.android.inputmethod.keyboard.Keyboard; import com.android.inputmethod.keyboard.KeyboardActionListener; import com.android.inputmethod.keyboard.PointerTracker; import com.android.inputmethod.latin.InputPointers; -import com.android.inputmethod.latin.SuggestedWords; // TODO: Remove this class by consolidating with PointerTracker public class GestureTracker { @@ -40,7 +39,6 @@ public class GestureTracker { private boolean mInGesture = false; private KeyboardActionListener mListener; - private SuggestedWords mSuggestions; private int mLastRecognitionPointSize = 0; private long mLastRecognitionTime = 0; @@ -66,17 +64,16 @@ public class GestureTracker { } mInGesture = true; mListener.onStartBatchInput(); - mSuggestions = null; } // TODO: The corresponding startBatchInput() is a private method. Reorganize the code. public void endBatchInput() { - if (isInGesture() && mSuggestions != null && mSuggestions.size() > 0) { - final CharSequence text = mSuggestions.getWord(0); + if (isInGesture()) { + final InputPointers batchPoints = PointerTracker.getAllBatchPoints(); if (DEBUG_LISTENER) { - Log.d(TAG, "onEndBatchInput: text=" + text); + Log.d(TAG, "onEndBatchInput: batchPoints=" + batchPoints.getPointerSize()); } - mListener.onEndBatchInput(text); + mListener.onEndBatchInput(batchPoints); } mInGesture = false; clearBatchInputPoints(); @@ -117,7 +114,7 @@ public class GestureTracker { if (DEBUG_LISTENER) { Log.d(TAG, "onUpdateBatchInput: batchPoints=" + batchPoints.getPointerSize()); } - mSuggestions = mListener.onUpdateBatchInput(batchPoints); + mListener.onUpdateBatchInput(batchPoints); } } } @@ -128,7 +125,7 @@ public class GestureTracker { if (DEBUG_LISTENER) { Log.d(TAG, "onUpdateBatchInput: batchPoints=" + batchPoints.getPointerSize()); } - mSuggestions = mListener.onUpdateBatchInput(batchPoints); + mListener.onUpdateBatchInput(batchPoints); } } diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 518bcd5ce..0f8b6c48c 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -1329,13 +1329,22 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen } @Override - public SuggestedWords onUpdateBatchInput(InputPointers batchPointers) { + public void onUpdateBatchInput(InputPointers batchPointers) { mWordComposer.setBatchInputPointers(batchPointers); - return updateSuggestionsOrPredictions(); + updateSuggestionsOrPredictions(); } @Override - public void onEndBatchInput(CharSequence text) { + public void onEndBatchInput(InputPointers batchPointers) { + mWordComposer.setBatchInputPointers(batchPointers); + final SuggestedWords suggestedWords = updateSuggestionsOrPredictions(); + if (suggestedWords == null || suggestedWords.size() == 0) { + return; + } + final CharSequence text = suggestedWords.getWord(0); + if (TextUtils.isEmpty(text)) { + return; + } mWordComposer.setBatchInputWord(text); mConnection.beginBatchEdit(); if (SPACE_STATE_PHANTOM == mSpaceState) {