am a474dbc5: Merge "Don\'t autocorrect after suggestion resuming" into jb-dev

* commit 'a474dbc5c2e99a6467b0671b30be968f653e248f':
  Don't autocorrect after suggestion resuming
main
Jean Chalard 2012-05-01 01:20:49 -07:00 committed by Android Git Automerger
commit 1d6d1f8cfb
2 changed files with 15 additions and 0 deletions

View File

@ -385,6 +385,7 @@ public class Suggest implements Dictionary.WordCallback {
} }
// Don't auto-correct words with multiple capital letter // Don't auto-correct words with multiple capital letter
autoCorrectionAvailable &= !wordComposer.isMostlyCaps(); autoCorrectionAvailable &= !wordComposer.isMostlyCaps();
autoCorrectionAvailable &= !wordComposer.isResumed();
if (allowsToBeAutoCorrected && suggestionsList.size() > 1 && mAutoCorrectionThreshold > 0 if (allowsToBeAutoCorrected && suggestionsList.size() > 1 && mAutoCorrectionThreshold > 0
&& Suggest.shouldBlockAutoCorrectionBySafetyNet(typedWord, && Suggest.shouldBlockAutoCorrectionBySafetyNet(typedWord,
suggestionsList.get(1).mWord)) { suggestionsList.get(1).mWord)) {

View File

@ -38,6 +38,7 @@ public class WordComposer {
private int[] mYCoordinates; private int[] mYCoordinates;
private StringBuilder mTypedWord; private StringBuilder mTypedWord;
private CharSequence mAutoCorrection; private CharSequence mAutoCorrection;
private boolean mIsResumed;
// Cache these values for performance // Cache these values for performance
private int mCapsCount; private int mCapsCount;
@ -57,6 +58,7 @@ public class WordComposer {
mYCoordinates = new int[N]; mYCoordinates = new int[N];
mAutoCorrection = null; mAutoCorrection = null;
mTrailingSingleQuotesCount = 0; mTrailingSingleQuotesCount = 0;
mIsResumed = false;
refreshSize(); refreshSize();
} }
@ -73,6 +75,7 @@ public class WordComposer {
mIsFirstCharCapitalized = source.mIsFirstCharCapitalized; mIsFirstCharCapitalized = source.mIsFirstCharCapitalized;
mAutoCapitalized = source.mAutoCapitalized; mAutoCapitalized = source.mAutoCapitalized;
mTrailingSingleQuotesCount = source.mTrailingSingleQuotesCount; mTrailingSingleQuotesCount = source.mTrailingSingleQuotesCount;
mIsResumed = source.mIsResumed;
refreshSize(); refreshSize();
} }
@ -85,6 +88,7 @@ public class WordComposer {
mCapsCount = 0; mCapsCount = 0;
mIsFirstCharCapitalized = false; mIsFirstCharCapitalized = false;
mTrailingSingleQuotesCount = 0; mTrailingSingleQuotesCount = 0;
mIsResumed = false;
refreshSize(); refreshSize();
} }
@ -193,6 +197,7 @@ public class WordComposer {
int codePoint = Character.codePointAt(word, i); int codePoint = Character.codePointAt(word, i);
addKeyInfo(codePoint, keyboard); addKeyInfo(codePoint, keyboard);
} }
mIsResumed = true;
} }
/** /**
@ -299,6 +304,13 @@ public class WordComposer {
return mAutoCorrection; 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. // `type' should be one of the LastComposedWord.COMMIT_TYPE_* constants above.
public LastComposedWord commitWord(final int type, final String committedWord, public LastComposedWord commitWord(final int type, final String committedWord,
final int separatorCode) { final int separatorCode) {
@ -320,6 +332,7 @@ public class WordComposer {
mTypedWord.setLength(0); mTypedWord.setLength(0);
refreshSize(); refreshSize();
mAutoCorrection = null; mAutoCorrection = null;
mIsResumed = false;
return lastComposedWord; return lastComposedWord;
} }
@ -331,5 +344,6 @@ public class WordComposer {
mTypedWord.append(lastComposedWord.mTypedWord); mTypedWord.append(lastComposedWord.mTypedWord);
refreshSize(); refreshSize();
mAutoCorrection = null; // This will be filled by the next call to updateSuggestion. mAutoCorrection = null; // This will be filled by the next call to updateSuggestion.
mIsResumed = true;
} }
} }