am f7d6517d: Various mini-cleanups

* commit 'f7d6517d6b1a1dd88e2142e1a15703bb839be01b':
  Various mini-cleanups
main
Jean Chalard 2011-12-13 06:30:55 -08:00 committed by Android Git Automerger
commit 9d6113257c
4 changed files with 11 additions and 10 deletions

View File

@ -1785,7 +1785,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
return; return;
} }
final WordComposer wordComposer = mWordComposer;
// TODO: May need a better way of retrieving previous word // TODO: May need a better way of retrieving previous word
final InputConnection ic = getCurrentInputConnection(); final InputConnection ic = getCurrentInputConnection();
final CharSequence prevWord; final CharSequence prevWord;
@ -1795,18 +1794,18 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
prevWord = EditingUtils.getPreviousWord(ic, mSettingsValues.mWordSeparators); prevWord = EditingUtils.getPreviousWord(ic, mSettingsValues.mWordSeparators);
} }
// getSuggestedWordBuilder handles gracefully a null value of prevWord // getSuggestedWordBuilder handles gracefully a null value of prevWord
final SuggestedWords.Builder builder = mSuggest.getSuggestedWordBuilder(wordComposer, final SuggestedWords.Builder builder = mSuggest.getSuggestedWordBuilder(mWordComposer,
prevWord, mKeyboardSwitcher.getLatinKeyboard().getProximityInfo(), mCorrectionMode); prevWord, mKeyboardSwitcher.getLatinKeyboard().getProximityInfo(), mCorrectionMode);
boolean autoCorrectionAvailable = !mInputTypeNoAutoCorrect && mSuggest.hasAutoCorrection(); boolean autoCorrectionAvailable = !mInputTypeNoAutoCorrect && mSuggest.hasAutoCorrection();
final CharSequence typedWord = wordComposer.getTypedWord(); final CharSequence typedWord = mWordComposer.getTypedWord();
// Here, we want to promote a whitelisted word if exists. // Here, we want to promote a whitelisted word if exists.
// TODO: Change this scheme - a boolean is not enough. A whitelisted word may be "valid" // TODO: Change this scheme - a boolean is not enough. A whitelisted word may be "valid"
// but still autocorrected from - in the case the whitelist only capitalizes the word. // but still autocorrected from - in the case the whitelist only capitalizes the word.
// The whitelist should be case-insensitive, so it's not possible to be consistent with // The whitelist should be case-insensitive, so it's not possible to be consistent with
// a boolean flag. Right now this is handled with a slight hack in // a boolean flag. Right now this is handled with a slight hack in
// WhitelistDictionary#shouldForciblyAutoCorrectFrom. // WhitelistDictionary#shouldForciblyAutoCorrectFrom.
final int quotesCount = wordComposer.trailingSingleQuotesCount(); final int quotesCount = mWordComposer.trailingSingleQuotesCount();
final boolean allowsToBeAutoCorrected = AutoCorrection.allowsToBeAutoCorrected( final boolean allowsToBeAutoCorrected = AutoCorrection.allowsToBeAutoCorrected(
mSuggest.getUnigramDictionaries(), mSuggest.getUnigramDictionaries(),
// If the typed string ends with a single quote, for dictionary lookup purposes // If the typed string ends with a single quote, for dictionary lookup purposes
@ -1822,7 +1821,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
autoCorrectionAvailable |= (!allowsToBeAutoCorrected); autoCorrectionAvailable |= (!allowsToBeAutoCorrected);
} }
// Don't auto-correct words with multiple capital letter // Don't auto-correct words with multiple capital letter
autoCorrectionAvailable &= !wordComposer.isMostlyCaps(); autoCorrectionAvailable &= !mWordComposer.isMostlyCaps();
// Basically, we update the suggestion strip only when suggestion count > 1. However, // Basically, we update the suggestion strip only when suggestion count > 1. However,
// there is an exception: We update the suggestion strip whenever typed word's length // there is an exception: We update the suggestion strip whenever typed word's length
@ -1959,6 +1958,8 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
} else { } else {
addToOnlyBigramDictionary(suggestion, 1); addToOnlyBigramDictionary(suggestion, 1);
} }
// TODO: the following is fishy, because if !mHasUncommittedTypedChars we are
// going to log an empty string
LatinImeLogger.logOnManualSuggestion(mWordComposer.getTypedWord().toString(), LatinImeLogger.logOnManualSuggestion(mWordComposer.getTypedWord().toString(),
suggestion.toString(), index, suggestions.mWords); suggestion.toString(), index, suggestions.mWords);
// Follow it with a space // Follow it with a space
@ -2399,8 +2400,8 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
} }
} }
public WordComposer getCurrentWord() { public boolean isAutoCapitalized() {
return mWordComposer; return mWordComposer.isAutoCapitalized();
} }
boolean isSoundOn() { boolean isSoundOn() {

View File

@ -159,7 +159,7 @@ public class UserBigramDictionary extends ExpandableDictionary {
*/ */
public int addBigrams(String word1, String word2) { public int addBigrams(String word1, String word2) {
// remove caps if second word is autocapitalized // remove caps if second word is autocapitalized
if (mIme != null && mIme.getCurrentWord().isAutoCapitalized()) { if (mIme != null && mIme.isAutoCapitalized()) {
word2 = Character.toLowerCase(word2.charAt(0)) + word2.substring(1); word2 = Character.toLowerCase(word2.charAt(0)) + word2.substring(1);
} }
// Do not insert a word as a bigram of itself // Do not insert a word as a bigram of itself

View File

@ -149,7 +149,7 @@ public class UserUnigramDictionary extends ExpandableDictionary {
final int length = word.length(); final int length = word.length();
// Don't add very short or very long words. // Don't add very short or very long words.
if (length < 2 || length > getMaxWordLength()) return; if (length < 2 || length > getMaxWordLength()) return;
if (mIme.getCurrentWord().isAutoCapitalized()) { if (mIme.isAutoCapitalized()) {
// Remove caps before adding // Remove caps before adding
word = Character.toLowerCase(word.charAt(0)) + word.substring(1); word = Character.toLowerCase(word.charAt(0)) + word.substring(1);
} }

View File

@ -301,7 +301,7 @@ public class WordComposer {
} }
/** /**
* @return the auto-correction for this world, or null if none. * @return the auto-correction for this word, or null if none.
*/ */
public CharSequence getAutoCorrectionOrNull() { public CharSequence getAutoCorrectionOrNull() {
return mAutoCorrection; return mAutoCorrection;