aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java22
-rw-r--r--java/src/com/android/inputmethod/latin/spellcheck/AndroidWordLevelSpellCheckerSession.java28
2 files changed, 21 insertions, 29 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 953ec310a..84c752934 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -1577,21 +1577,11 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
commitTyped(LastComposedWord.NOT_A_SEPARATOR);
}
mExpectingUpdateSelection = true;
- // The following is necessary for the case where the user typed something but didn't
- // manual pick it and didn't input any separator: we want to put a space between what
- // has been entered and the coming gesture input result, so we go into phantom space
- // state, which will be promoted to a space when the gesture result is committed. But if
- // the current input ends in a word connector on the other hand, then we want to have
- // the next input stick to the current input so we don't switch to phantom space state.
- if (!mSettings.getCurrent().isWordConnector(lastChar)) {
- mSpaceState = SPACE_STATE_PHANTOM;
- }
- } else {
- final int codePointBeforeCursor = mConnection.getCodePointBeforeCursor();
- if (Character.isLetter(codePointBeforeCursor)
- || mSettings.getCurrent().isUsuallyFollowedBySpace(codePointBeforeCursor)) {
- mSpaceState = SPACE_STATE_PHANTOM;
- }
+ }
+ final int codePointBeforeCursor = mConnection.getCodePointBeforeCursor();
+ if (Character.isLetterOrDigit(codePointBeforeCursor)
+ || mSettings.getCurrent().isUsuallyFollowedBySpace(codePointBeforeCursor)) {
+ mSpaceState = SPACE_STATE_PHANTOM;
}
mConnection.endBatchEdit();
mWordComposer.setCapitalizedModeAtStartComposingTime(getActualCapsMode());
@@ -1905,6 +1895,8 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
final int y, final int spaceState) {
boolean isComposingWord = mWordComposer.isComposingWord();
+ // TODO: remove isWordConnector() and use isUsuallyFollowedBySpace() instead.
+ // See onStartBatchInput() to see how to do it.
if (SPACE_STATE_PHANTOM == spaceState &&
!mSettings.getCurrent().isWordConnector(primaryCode)) {
if (isComposingWord) {
diff --git a/java/src/com/android/inputmethod/latin/spellcheck/AndroidWordLevelSpellCheckerSession.java b/java/src/com/android/inputmethod/latin/spellcheck/AndroidWordLevelSpellCheckerSession.java
index c03b77d98..61850e42e 100644
--- a/java/src/com/android/inputmethod/latin/spellcheck/AndroidWordLevelSpellCheckerSession.java
+++ b/java/src/com/android/inputmethod/latin/spellcheck/AndroidWordLevelSpellCheckerSession.java
@@ -283,20 +283,6 @@ public abstract class AndroidWordLevelSpellCheckerSession extends Session {
//suggestionsLimit);
final SuggestionsGatherer suggestionsGatherer = mService.newSuggestionsGatherer(
text, suggestionsLimit);
- final WordComposer composer = new WordComposer();
- final int length = text.length();
- for (int i = 0; i < length; i = text.offsetByCodePoints(i, 1)) {
- final int codePoint = text.codePointAt(i);
- // The getXYForCodePointAndScript method returns (Y << 16) + X
- final int xy = SpellCheckerProximityInfo.getXYForCodePointAndScript(
- codePoint, mScript);
- if (SpellCheckerProximityInfo.NOT_A_COORDINATE_PAIR == xy) {
- composer.add(codePoint,
- Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE);
- } else {
- composer.add(codePoint, xy & 0xFFFF, xy >> 16);
- }
- }
final int capitalizeType = StringUtils.getCapitalizationType(text);
boolean isInDict = true;
@@ -306,6 +292,20 @@ public abstract class AndroidWordLevelSpellCheckerSession extends Session {
if (!DictionaryPool.isAValidDictionary(dictInfo)) {
return AndroidSpellCheckerService.getNotInDictEmptySuggestions();
}
+ final WordComposer composer = new WordComposer();
+ final int length = text.length();
+ for (int i = 0; i < length; i = text.offsetByCodePoints(i, 1)) {
+ final int codePoint = text.codePointAt(i);
+ // The getXYForCodePointAndScript method returns (Y << 16) + X
+ final int xy = SpellCheckerProximityInfo.getXYForCodePointAndScript(
+ codePoint, mScript);
+ if (SpellCheckerProximityInfo.NOT_A_COORDINATE_PAIR == xy) {
+ composer.add(codePoint,
+ Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE);
+ } else {
+ composer.add(codePoint, xy & 0xFFFF, xy >> 16);
+ }
+ }
// TODO: make a spell checker option to block offensive words or not
final ArrayList<SuggestedWordInfo> suggestions =
dictInfo.mDictionary.getSuggestions(composer, prevWord,