Move a method to a more sensical place.
Change-Id: I11f87448f689cf828bff960ad7a3e4739a3457dc
This commit is contained in:
parent
f1a559c516
commit
9b01890254
4 changed files with 9 additions and 10 deletions
|
@ -1847,7 +1847,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
autoCorrection = null;
|
autoCorrection = null;
|
||||||
}
|
}
|
||||||
mWordComposer.setAutoCorrection(autoCorrection);
|
mWordComposer.setAutoCorrection(autoCorrection);
|
||||||
final boolean isAutoCorrection = Utils.willAutoCorrect(suggestedWords);
|
final boolean isAutoCorrection = suggestedWords.willAutoCorrect();
|
||||||
setSuggestions(suggestedWords, isAutoCorrection);
|
setSuggestions(suggestedWords, isAutoCorrection);
|
||||||
setAutoCorrectionIndicator(isAutoCorrection);
|
setAutoCorrectionIndicator(isAutoCorrection);
|
||||||
setSuggestionStripShown(isSuggestionsStripVisible());
|
setSuggestionStripShown(isSuggestionsStripVisible());
|
||||||
|
|
|
@ -77,6 +77,11 @@ public class SuggestedWords {
|
||||||
return mShouldBlockAutoCorrectionBySafetyNet;
|
return mShouldBlockAutoCorrectionBySafetyNet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean willAutoCorrect() {
|
||||||
|
return !mTypedWordValid && mHasAutoCorrectionCandidate
|
||||||
|
&& !shouldBlockAutoCorrectionBySafetyNet();
|
||||||
|
}
|
||||||
|
|
||||||
public static class Builder {
|
public static class Builder {
|
||||||
private List<CharSequence> mWords = new ArrayList<CharSequence>();
|
private List<CharSequence> mWords = new ArrayList<CharSequence>();
|
||||||
private boolean mTypedWordValid;
|
private boolean mTypedWordValid;
|
||||||
|
|
|
@ -778,11 +778,6 @@ public class Utils {
|
||||||
return s.toUpperCase(locale).charAt(0) + s.substring(1);
|
return s.toUpperCase(locale).charAt(0) + s.substring(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean willAutoCorrect(SuggestedWords suggestions) {
|
|
||||||
return !suggestions.mTypedWordValid && suggestions.mHasAutoCorrectionCandidate
|
|
||||||
&& !suggestions.shouldBlockAutoCorrectionBySafetyNet();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Stats {
|
public static class Stats {
|
||||||
public static void onNonSeparator(final char code, final int x,
|
public static void onNonSeparator(final char code, final int x,
|
||||||
final int y) {
|
final int y) {
|
||||||
|
|
|
@ -62,7 +62,6 @@ import com.android.inputmethod.latin.R;
|
||||||
import com.android.inputmethod.latin.StaticInnerHandlerWrapper;
|
import com.android.inputmethod.latin.StaticInnerHandlerWrapper;
|
||||||
import com.android.inputmethod.latin.SuggestedWords;
|
import com.android.inputmethod.latin.SuggestedWords;
|
||||||
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
|
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
|
||||||
import com.android.inputmethod.latin.Utils;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -261,7 +260,7 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
|
||||||
|
|
||||||
private CharSequence getStyledSuggestionWord(SuggestedWords suggestions, int pos) {
|
private CharSequence getStyledSuggestionWord(SuggestedWords suggestions, int pos) {
|
||||||
final CharSequence word = suggestions.getWord(pos);
|
final CharSequence word = suggestions.getWord(pos);
|
||||||
final boolean isAutoCorrect = pos == 1 && Utils.willAutoCorrect(suggestions);
|
final boolean isAutoCorrect = pos == 1 && suggestions.willAutoCorrect();
|
||||||
final boolean isTypedWordValid = pos == 0 && suggestions.mTypedWordValid;
|
final boolean isTypedWordValid = pos == 0 && suggestions.mTypedWordValid;
|
||||||
if (!isAutoCorrect && !isTypedWordValid)
|
if (!isAutoCorrect && !isTypedWordValid)
|
||||||
return word;
|
return word;
|
||||||
|
@ -282,7 +281,7 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
|
||||||
private int getWordPosition(int index, SuggestedWords suggestions) {
|
private int getWordPosition(int index, SuggestedWords suggestions) {
|
||||||
// TODO: This works for 3 suggestions. Revisit this algorithm when there are 5 or more
|
// TODO: This works for 3 suggestions. Revisit this algorithm when there are 5 or more
|
||||||
// suggestions.
|
// suggestions.
|
||||||
final int centerPos = Utils.willAutoCorrect(suggestions) ? 1 : 0;
|
final int centerPos = suggestions.willAutoCorrect() ? 1 : 0;
|
||||||
if (index == mCenterSuggestionIndex) {
|
if (index == mCenterSuggestionIndex) {
|
||||||
return centerPos;
|
return centerPos;
|
||||||
} else if (index == centerPos) {
|
} else if (index == centerPos) {
|
||||||
|
@ -297,7 +296,7 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
|
||||||
final boolean isSuggested = (pos != 0);
|
final boolean isSuggested = (pos != 0);
|
||||||
|
|
||||||
final int color;
|
final int color;
|
||||||
if (index == mCenterSuggestionIndex && Utils.willAutoCorrect(suggestions)) {
|
if (index == mCenterSuggestionIndex && suggestions.willAutoCorrect()) {
|
||||||
color = mColorAutoCorrect;
|
color = mColorAutoCorrect;
|
||||||
} else if (index == mCenterSuggestionIndex && suggestions.mTypedWordValid) {
|
} else if (index == mCenterSuggestionIndex && suggestions.mTypedWordValid) {
|
||||||
color = mColorValidTypedWord;
|
color = mColorValidTypedWord;
|
||||||
|
|
Loading…
Reference in a new issue