From 8ba33c1a494db5ef3cce17754f4d6981532074a0 Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Thu, 5 Jul 2012 14:08:52 +0900 Subject: [PATCH 1/6] Simplification (A62) Change-Id: I606270a0387787445b7cd6b94e4830bfc144b49e --- .../src/com/android/inputmethod/latin/LatinIME.java | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 78b7eaa44..b59e76b0d 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -1523,15 +1523,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen swapSwapperAndSpace(); mSpaceState = SPACE_STATE_WEAK; } - // Some characters are not word separators, yet they don't start a new - // composing span. For these, we haven't changed the suggestion strip, and - // if the "add to dictionary" hint is shown, we should do so now. Examples of - // such characters include single quote, dollar, and others; the exact list is - // the list of characters for which we enter handleCharacterWhileInBatchEdit - // that don't match the test if ((isAlphabet...)) at the top of this method. - if (null != mSuggestionsView && mSuggestionsView.dismissAddToDictionaryHint()) { - mHandler.postUpdateBigramPredictions(); - } + // We may need to update predictions, if the "add to dictionary" hint was displayed + // for example. + if (null != mSuggestionsView) mSuggestionsView.dismissAddToDictionaryHint(); + mHandler.postUpdateBigramPredictions(); } Utils.Stats.onNonSeparator((char)primaryCode, x, y); } From 43193ad60f623a00c2ba2eb4c666353418979923 Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Thu, 5 Jul 2012 14:18:43 +0900 Subject: [PATCH 2/6] Remove useless code (A63) If the separator is not a space, then we will always call setPunctuationSuggestions and reset the suggestion strip anyway. If the separator is a space, then the cursor has a space on the left, which means isCursorTouchingWord depends only on whether it touches a word on the right. If we were displaying the "add to dictionary hint", it means a suggestion was just chosen, so it had to be displayed, and that requires a composing word and no non-separator at the right of the cursor. In the end, if we go through this postUpdateSuggestions call, we are sure we will reset the suggestions later in this method, either by calling postUpdateBigramPredictions, or setPunctuationSuggestions. Change-Id: I95d5f77a5d0ac6d1a6ced8d67d6ac8f650db4a32 --- java/src/com/android/inputmethod/latin/LatinIME.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index b59e76b0d..c0f125e3a 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -1534,11 +1534,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen // Returns true if we did an autocorrection, false otherwise. private boolean handleSeparator(final int primaryCode, final int x, final int y, final int spaceState) { - // Should dismiss the "Touch again to save" message when handling separator - if (mSuggestionsView != null && mSuggestionsView.dismissAddToDictionaryHint()) { - mHandler.postUpdateSuggestions(); - } - boolean didAutoCorrect = false; // Handle separator if (mWordComposer.isComposingWord()) { From 449be371aee91594bc6ee09479af0cc20bcfcea9 Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Thu, 5 Jul 2012 14:49:45 +0900 Subject: [PATCH 3/6] Refinement (A64) Change-Id: I7c16e28ffce4fe0965b756bf2b00ee63b77dd039 --- java/src/com/android/inputmethod/latin/LatinIME.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index c0f125e3a..25159b5ce 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -2015,7 +2015,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen // Since we just changed languages, we should re-evaluate suggestions with whatever word // we are currently composing. If we are not composing anything, we may want to display // predictions or punctuation signs (which is done by updateBigramPredictions anyway). - if (mConnection.isCursorTouchingWord(mCurrentSettings)) { + if (mWordComposer.isComposingWord()) { mHandler.postUpdateSuggestions(); } else { mHandler.postUpdateBigramPredictions(); From 4fde56b8182514bcae64d76488724d2a64a73f14 Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Fri, 6 Jul 2012 17:50:35 +0900 Subject: [PATCH 4/6] Fix a bug where spaces would be forgotten Bug: 6785706 Change-Id: Ic7bf242ef058d116b986d47ad197b6d2802e2342 --- java/src/com/android/inputmethod/latin/LatinIME.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 78b7eaa44..047bc734f 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -1799,6 +1799,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen return; } + mConnection.beginBatchEdit(); if (SPACE_STATE_PHANTOM == mSpaceState && suggestion.length() > 0) { int firstChar = Character.codePointAt(suggestion, 0); if ((!mCurrentSettings.isWeakSpaceStripper(firstChar)) @@ -1816,7 +1817,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen mKeyboardSwitcher.updateShiftState(); resetComposingState(true /* alsoResetLastComposedWord */); final CompletionInfo completionInfo = mApplicationSpecifiedCompletions[index]; - mConnection.beginBatchEdit(); mConnection.commitCompletion(completionInfo); mConnection.endBatchEdit(); if (ProductionFlag.IS_EXPERIMENTAL) { @@ -1837,6 +1837,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen mExpectingUpdateSelection = true; commitChosenWord(suggestion, LastComposedWord.COMMIT_TYPE_MANUAL_PICK, LastComposedWord.NOT_A_SEPARATOR); + mConnection.endBatchEdit(); // Don't allow cancellation of manual pick mLastComposedWord.deactivate(); mSpaceState = SPACE_STATE_PHANTOM; From 4be03befe3cf771a33448367f50c517dc01ced21 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Wed, 4 Jul 2012 15:24:59 +0900 Subject: [PATCH 5/6] Extend onTextInput to be able to inject suggestions Change-Id: I1061da0edfdb05c64c5711717d4ef9fa9681e568 --- .../keyboard/KeyboardActionListener.java | 18 ++++++++++ .../keyboard/MoreKeysKeyboardView.java | 10 ++++++ .../android/inputmethod/latin/LatinIME.java | 35 ++++++++++++++++++- 3 files changed, 62 insertions(+), 1 deletion(-) diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardActionListener.java b/java/src/com/android/inputmethod/keyboard/KeyboardActionListener.java index c41d24529..dc27769ab 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardActionListener.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardActionListener.java @@ -64,6 +64,20 @@ public interface KeyboardActionListener { */ public void onTextInput(CharSequence text); + // TODO: Should move this method to some more appropriate interface. + /** + * Called when user started batch input. + */ + public void onStartBatchInput(); + + // TODO: Should move this method to some more appropriate interface. + /** + * Sends a sequence of characters to the listener as batch input. + * + * @param text the sequence of characters to be displayed as composing text. + */ + public void onEndBatchInput(CharSequence text); + /** * Called when user released a finger outside any key. */ @@ -85,6 +99,10 @@ public interface KeyboardActionListener { @Override public void onTextInput(CharSequence text) {} @Override + public void onStartBatchInput() {} + @Override + public void onEndBatchInput(CharSequence text) {} + @Override public void onCancelInput() {} @Override public boolean onCustomRequest(int requestCode) { diff --git a/java/src/com/android/inputmethod/keyboard/MoreKeysKeyboardView.java b/java/src/com/android/inputmethod/keyboard/MoreKeysKeyboardView.java index be7644fb5..9c8069194 100644 --- a/java/src/com/android/inputmethod/keyboard/MoreKeysKeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/MoreKeysKeyboardView.java @@ -57,6 +57,16 @@ public class MoreKeysKeyboardView extends KeyboardView implements MoreKeysPanel mListener.onTextInput(text); } + @Override + public void onStartBatchInput() { + mListener.onStartBatchInput(); + } + + @Override + public void onEndBatchInput(CharSequence text) { + mListener.onEndBatchInput(text); + } + @Override public void onCancelInput() { mListener.onCancelInput(); diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index b59e76b0d..0baa3ba65 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -1272,6 +1272,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen if (mCurrentSettings.isWordSeparator(primaryCode)) { didAutoCorrect = handleSeparator(primaryCode, x, y, spaceState); } else { + if (SPACE_STATE_PHANTOM == spaceState) { + commitTyped(LastComposedWord.NOT_A_SEPARATOR); + } final Keyboard keyboard = mKeyboardSwitcher.getKeyboard(); if (keyboard != null && keyboard.hasProximityCharsCorrection(primaryCode)) { handleCharacter(primaryCode, x, y, spaceState); @@ -1313,6 +1316,31 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen resetComposingState(true /* alsoResetLastComposedWord */); } + @Override + public void onStartBatchInput() { + mConnection.beginBatchEdit(); + if (mWordComposer.isComposingWord()) { + commitTyped(LastComposedWord.NOT_A_SEPARATOR); + mExpectingUpdateSelection = true; + // TODO: Can we remove this? + mSpaceState = SPACE_STATE_PHANTOM; + } + mConnection.endBatchEdit(); + } + + @Override + public void onEndBatchInput(CharSequence text) { + mConnection.beginBatchEdit(); + if (SPACE_STATE_PHANTOM == mSpaceState) { + sendKeyCodePoint(Keyboard.CODE_SPACE); + } + mConnection.setComposingText(text, 1); + mExpectingUpdateSelection = true; + mConnection.endBatchEdit(); + mKeyboardSwitcher.updateShiftState(); + mSpaceState = SPACE_STATE_PHANTOM; + } + private CharSequence specificTldProcessingOnTextInput(final CharSequence text) { if (text.length() <= 1 || text.charAt(0) != Keyboard.CODE_PERIOD || !Character.isLetter(text.charAt(1))) { @@ -1359,7 +1387,12 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen if (mWordComposer.isComposingWord()) { final int length = mWordComposer.size(); if (length > 0) { - mWordComposer.deleteLast(); + // Immediately after a batch input. + if (SPACE_STATE_PHANTOM == spaceState) { + mWordComposer.reset(); + } else { + mWordComposer.deleteLast(); + } mConnection.setComposingText(getTextWithUnderline(mWordComposer.getTypedWord()), 1); // If we have deleted the last remaining character of a word, then we are not // isComposingWord() any more. From 1a9ef011874df0303647df96e5debf8c66409596 Mon Sep 17 00:00:00 2001 From: Ken Wakasa Date: Fri, 6 Jul 2012 20:29:08 +0900 Subject: [PATCH 6/6] Add a copyright header to AndroidManifest.xml Change-Id: I588d7acc6f64360404440ad8dc2c00296046b09d --- java/AndroidManifest.xml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/java/AndroidManifest.xml b/java/AndroidManifest.xml index 06d852bb0..6b823829f 100644 --- a/java/AndroidManifest.xml +++ b/java/AndroidManifest.xml @@ -1,3 +1,19 @@ + + +