aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/com/android/inputmethod/latin')
-rw-r--r--java/src/com/android/inputmethod/latin/ImfUtils.java16
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java4
-rw-r--r--java/src/com/android/inputmethod/latin/Suggest.java1
-rw-r--r--java/src/com/android/inputmethod/latin/WordComposer.java14
4 files changed, 32 insertions, 3 deletions
diff --git a/java/src/com/android/inputmethod/latin/ImfUtils.java b/java/src/com/android/inputmethod/latin/ImfUtils.java
index af46a02c0..36f6d8ba0 100644
--- a/java/src/com/android/inputmethod/latin/ImfUtils.java
+++ b/java/src/com/android/inputmethod/latin/ImfUtils.java
@@ -63,7 +63,8 @@ public class ImfUtils {
return getInputMethodInfoOfThisIme(context).getId();
}
- public static boolean checkIfSubtypeBelongsToThisIme(Context context, InputMethodSubtype ims) {
+ public static boolean checkIfSubtypeBelongsToThisImeAndEnabled(Context context,
+ InputMethodSubtype ims) {
final InputMethodInfo myImi = getInputMethodInfoOfThisIme(context);
final InputMethodManager imm = getInputMethodManager(context);
// TODO: Cache all subtypes of this IME for optimization
@@ -76,6 +77,19 @@ public class ImfUtils {
return false;
}
+ public static boolean checkIfSubtypeBelongsToThisIme(Context context,
+ InputMethodSubtype ims) {
+ final InputMethodInfo myImi = getInputMethodInfoOfThisIme(context);
+ final int count = myImi.getSubtypeCount();
+ for (int i = 0; i < count; i++) {
+ final InputMethodSubtype subtype = myImi.getSubtypeAt(i);
+ if (subtype.equals(ims)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
public static boolean hasMultipleEnabledIMEsOrSubtypes(Context context,
final boolean shouldIncludeAuxiliarySubtypes) {
final InputMethodManager imm = getInputMethodManager(context);
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index c6381180c..7efdef987 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -1148,8 +1148,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
final IBinder token = getWindow().getWindow().getAttributes().token;
if (mShouldSwitchToLastSubtype) {
final InputMethodSubtype lastSubtype = mImm.getLastInputMethodSubtype();
- final boolean lastSubtypeBelongsToThisIme = ImfUtils.checkIfSubtypeBelongsToThisIme(
- this, lastSubtype);
+ final boolean lastSubtypeBelongsToThisIme =
+ ImfUtils.checkIfSubtypeBelongsToThisImeAndEnabled(this, lastSubtype);
if ((includesOtherImes || lastSubtypeBelongsToThisIme)
&& mImm.switchToLastInputMethod(token)) {
mShouldSwitchToLastSubtype = false;
diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java
index 7cbee4f71..112bde6a3 100644
--- a/java/src/com/android/inputmethod/latin/Suggest.java
+++ b/java/src/com/android/inputmethod/latin/Suggest.java
@@ -385,6 +385,7 @@ public class Suggest implements Dictionary.WordCallback {
}
// Don't auto-correct words with multiple capital letter
autoCorrectionAvailable &= !wordComposer.isMostlyCaps();
+ autoCorrectionAvailable &= !wordComposer.isResumed();
if (allowsToBeAutoCorrected && suggestionsList.size() > 1 && mAutoCorrectionThreshold > 0
&& Suggest.shouldBlockAutoCorrectionBySafetyNet(typedWord,
suggestionsList.get(1).mWord)) {
diff --git a/java/src/com/android/inputmethod/latin/WordComposer.java b/java/src/com/android/inputmethod/latin/WordComposer.java
index bd8532ebd..e27a546c5 100644
--- a/java/src/com/android/inputmethod/latin/WordComposer.java
+++ b/java/src/com/android/inputmethod/latin/WordComposer.java
@@ -38,6 +38,7 @@ public class WordComposer {
private int[] mYCoordinates;
private StringBuilder mTypedWord;
private CharSequence mAutoCorrection;
+ private boolean mIsResumed;
// Cache these values for performance
private int mCapsCount;
@@ -57,6 +58,7 @@ public class WordComposer {
mYCoordinates = new int[N];
mAutoCorrection = null;
mTrailingSingleQuotesCount = 0;
+ mIsResumed = false;
refreshSize();
}
@@ -73,6 +75,7 @@ public class WordComposer {
mIsFirstCharCapitalized = source.mIsFirstCharCapitalized;
mAutoCapitalized = source.mAutoCapitalized;
mTrailingSingleQuotesCount = source.mTrailingSingleQuotesCount;
+ mIsResumed = source.mIsResumed;
refreshSize();
}
@@ -85,6 +88,7 @@ public class WordComposer {
mCapsCount = 0;
mIsFirstCharCapitalized = false;
mTrailingSingleQuotesCount = 0;
+ mIsResumed = false;
refreshSize();
}
@@ -193,6 +197,7 @@ public class WordComposer {
int codePoint = Character.codePointAt(word, i);
addKeyInfo(codePoint, keyboard);
}
+ mIsResumed = true;
}
/**
@@ -299,6 +304,13 @@ public class WordComposer {
return mAutoCorrection;
}
+ /**
+ * @return whether we started composing this word by resuming suggestion on an existing string
+ */
+ public boolean isResumed() {
+ return mIsResumed;
+ }
+
// `type' should be one of the LastComposedWord.COMMIT_TYPE_* constants above.
public LastComposedWord commitWord(final int type, final String committedWord,
final int separatorCode) {
@@ -320,6 +332,7 @@ public class WordComposer {
mTypedWord.setLength(0);
refreshSize();
mAutoCorrection = null;
+ mIsResumed = false;
return lastComposedWord;
}
@@ -331,5 +344,6 @@ public class WordComposer {
mTypedWord.append(lastComposedWord.mTypedWord);
refreshSize();
mAutoCorrection = null; // This will be filled by the next call to updateSuggestion.
+ mIsResumed = true;
}
}