Convert local members to local variables
Change-Id: I852787986c79502a4de7effe9c8281a4cf2d519dmain
parent
3ecb2747b3
commit
10abf10c1f
|
@ -58,11 +58,6 @@ public class Suggest {
|
||||||
|
|
||||||
private float mAutoCorrectionThreshold;
|
private float mAutoCorrectionThreshold;
|
||||||
|
|
||||||
// TODO: Remove these member variables by passing more context to addWord() callback method
|
|
||||||
private boolean mIsFirstCharCapitalized;
|
|
||||||
private boolean mIsAllUpperCase;
|
|
||||||
private int mTrailingSingleQuotesCount;
|
|
||||||
|
|
||||||
// Locale used for upper- and title-casing words
|
// Locale used for upper- and title-casing words
|
||||||
final private Locale mLocale;
|
final private Locale mLocale;
|
||||||
|
|
||||||
|
@ -191,15 +186,16 @@ public class Suggest {
|
||||||
final ProximityInfo proximityInfo, final boolean isCorrectionEnabled,
|
final ProximityInfo proximityInfo, final boolean isCorrectionEnabled,
|
||||||
final boolean isPrediction) {
|
final boolean isPrediction) {
|
||||||
LatinImeLogger.onStartSuggestion(prevWordForBigram);
|
LatinImeLogger.onStartSuggestion(prevWordForBigram);
|
||||||
mIsFirstCharCapitalized = !isPrediction && wordComposer.isFirstCharCapitalized();
|
final boolean isFirstCharCapitalized =
|
||||||
mIsAllUpperCase = !isPrediction && wordComposer.isAllUpperCase();
|
!isPrediction && wordComposer.isFirstCharCapitalized();
|
||||||
mTrailingSingleQuotesCount = wordComposer.trailingSingleQuotesCount();
|
final boolean isAllUpperCase = !isPrediction && wordComposer.isAllUpperCase();
|
||||||
|
final int trailingSingleQuotesCount = wordComposer.trailingSingleQuotesCount();
|
||||||
final ArrayList<SuggestedWordInfo> suggestionsContainer =
|
final ArrayList<SuggestedWordInfo> suggestionsContainer =
|
||||||
new ArrayList<SuggestedWordInfo>(MAX_SUGGESTIONS);
|
new ArrayList<SuggestedWordInfo>(MAX_SUGGESTIONS);
|
||||||
|
|
||||||
final String typedWord = wordComposer.getTypedWord();
|
final String typedWord = wordComposer.getTypedWord();
|
||||||
final String consideredWord = mTrailingSingleQuotesCount > 0
|
final String consideredWord = trailingSingleQuotesCount > 0
|
||||||
? typedWord.substring(0, typedWord.length() - mTrailingSingleQuotesCount)
|
? typedWord.substring(0, typedWord.length() - trailingSingleQuotesCount)
|
||||||
: typedWord;
|
: typedWord;
|
||||||
LatinImeLogger.onAddSuggestedWord(typedWord, Dictionary.TYPE_USER_TYPED);
|
LatinImeLogger.onAddSuggestedWord(typedWord, Dictionary.TYPE_USER_TYPED);
|
||||||
|
|
||||||
|
@ -227,9 +223,9 @@ public class Suggest {
|
||||||
}
|
}
|
||||||
} else if (wordComposer.size() > 1) {
|
} else if (wordComposer.size() > 1) {
|
||||||
final WordComposer wordComposerForLookup;
|
final WordComposer wordComposerForLookup;
|
||||||
if (mTrailingSingleQuotesCount > 0) {
|
if (trailingSingleQuotesCount > 0) {
|
||||||
wordComposerForLookup = new WordComposer(wordComposer);
|
wordComposerForLookup = new WordComposer(wordComposer);
|
||||||
for (int i = mTrailingSingleQuotesCount - 1; i >= 0; --i) {
|
for (int i = trailingSingleQuotesCount - 1; i >= 0; --i) {
|
||||||
wordComposerForLookup.deleteLast();
|
wordComposerForLookup.deleteLast();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -253,14 +249,14 @@ public class Suggest {
|
||||||
for (int i = 0; i < suggestionsContainer.size(); ++i) {
|
for (int i = 0; i < suggestionsContainer.size(); ++i) {
|
||||||
final SuggestedWordInfo wordInfo = suggestionsContainer.get(i);
|
final SuggestedWordInfo wordInfo = suggestionsContainer.get(i);
|
||||||
final SuggestedWordInfo transformedWordInfo = getTransformedSuggestedWordInfo(wordInfo,
|
final SuggestedWordInfo transformedWordInfo = getTransformedSuggestedWordInfo(wordInfo,
|
||||||
mLocale, mIsAllUpperCase, mIsFirstCharCapitalized, mTrailingSingleQuotesCount);
|
mLocale, isAllUpperCase, isFirstCharCapitalized, trailingSingleQuotesCount);
|
||||||
suggestionsContainer.set(i, transformedWordInfo);
|
suggestionsContainer.set(i, transformedWordInfo);
|
||||||
LatinImeLogger.onAddSuggestedWord(transformedWordInfo.mWord.toString(),
|
LatinImeLogger.onAddSuggestedWord(transformedWordInfo.mWord.toString(),
|
||||||
transformedWordInfo.mSourceDict);
|
transformedWordInfo.mSourceDict);
|
||||||
}
|
}
|
||||||
|
|
||||||
final CharSequence whitelistedWord = capitalizeWord(mIsAllUpperCase,
|
final CharSequence whitelistedWord = capitalizeWord(isAllUpperCase,
|
||||||
mIsFirstCharCapitalized, mWhiteListDictionary.getWhitelistedWord(consideredWord));
|
isFirstCharCapitalized, mWhiteListDictionary.getWhitelistedWord(consideredWord));
|
||||||
|
|
||||||
final boolean hasAutoCorrection;
|
final boolean hasAutoCorrection;
|
||||||
if (isCorrectionEnabled) {
|
if (isCorrectionEnabled) {
|
||||||
|
@ -274,9 +270,9 @@ public class Suggest {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (whitelistedWord != null) {
|
if (whitelistedWord != null) {
|
||||||
if (mTrailingSingleQuotesCount > 0) {
|
if (trailingSingleQuotesCount > 0) {
|
||||||
final StringBuilder sb = new StringBuilder(whitelistedWord);
|
final StringBuilder sb = new StringBuilder(whitelistedWord);
|
||||||
for (int i = mTrailingSingleQuotesCount - 1; i >= 0; --i) {
|
for (int i = trailingSingleQuotesCount - 1; i >= 0; --i) {
|
||||||
sb.appendCodePoint(Keyboard.CODE_SINGLE_QUOTE);
|
sb.appendCodePoint(Keyboard.CODE_SINGLE_QUOTE);
|
||||||
}
|
}
|
||||||
suggestionsContainer.add(0, new SuggestedWordInfo(sb.toString(),
|
suggestionsContainer.add(0, new SuggestedWordInfo(sb.toString(),
|
||||||
|
|
Loading…
Reference in New Issue