Refactor recorrection variable and method names
Change-Id: I3cb76e622e33985a187afe0a8928ed7b261615fd
This commit is contained in:
parent
2e04770adf
commit
952cb7e973
2 changed files with 39 additions and 39 deletions
|
@ -167,7 +167,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
private boolean mHasDictionary;
|
private boolean mHasDictionary;
|
||||||
private boolean mJustAddedAutoSpace;
|
private boolean mJustAddedAutoSpace;
|
||||||
private boolean mAutoCorrectEnabled;
|
private boolean mAutoCorrectEnabled;
|
||||||
private boolean mReCorrectionEnabled;
|
private boolean mRecorrectionEnabled;
|
||||||
private boolean mBigramSuggestionEnabled;
|
private boolean mBigramSuggestionEnabled;
|
||||||
private boolean mAutoCorrectOn;
|
private boolean mAutoCorrectOn;
|
||||||
private boolean mVibrateOn;
|
private boolean mVibrateOn;
|
||||||
|
@ -381,10 +381,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
// If the option should not be shown, do not read the recorrection preference
|
// If the option should not be shown, do not read the recorrection preference
|
||||||
// but always use the default setting defined in the resources.
|
// but always use the default setting defined in the resources.
|
||||||
if (res.getBoolean(R.bool.config_enable_show_recorrection_option)) {
|
if (res.getBoolean(R.bool.config_enable_show_recorrection_option)) {
|
||||||
mReCorrectionEnabled = prefs.getBoolean(Settings.PREF_RECORRECTION_ENABLED,
|
mRecorrectionEnabled = prefs.getBoolean(Settings.PREF_RECORRECTION_ENABLED,
|
||||||
res.getBoolean(R.bool.config_default_recorrection_enabled));
|
res.getBoolean(R.bool.config_default_recorrection_enabled));
|
||||||
} else {
|
} else {
|
||||||
mReCorrectionEnabled = res.getBoolean(R.bool.config_default_recorrection_enabled);
|
mRecorrectionEnabled = res.getBoolean(R.bool.config_default_recorrection_enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
mConfigEnableShowSubtypeSettings = res.getBoolean(
|
mConfigEnableShowSubtypeSettings = res.getBoolean(
|
||||||
|
@ -562,7 +562,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
inputView.setProximityCorrectionEnabled(true);
|
inputView.setProximityCorrectionEnabled(true);
|
||||||
inputView.setAccessibilityEnabled(accessibilityEnabled);
|
inputView.setAccessibilityEnabled(accessibilityEnabled);
|
||||||
// If we just entered a text field, maybe it has some old text that requires correction
|
// If we just entered a text field, maybe it has some old text that requires correction
|
||||||
checkReCorrectionOnStart();
|
checkRecorrectionOnStart();
|
||||||
inputView.setForeground(true);
|
inputView.setForeground(true);
|
||||||
|
|
||||||
mVoiceConnector.onStartInputView(inputView.getWindowToken());
|
mVoiceConnector.onStartInputView(inputView.getWindowToken());
|
||||||
|
@ -625,8 +625,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkReCorrectionOnStart() {
|
private void checkRecorrectionOnStart() {
|
||||||
if (!mReCorrectionEnabled) return;
|
if (!mRecorrectionEnabled) return;
|
||||||
|
|
||||||
final InputConnection ic = getCurrentInputConnection();
|
final InputConnection ic = getCurrentInputConnection();
|
||||||
if (ic == null) return;
|
if (ic == null) return;
|
||||||
|
@ -735,18 +735,18 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
mLastSelectionStart = newSelStart;
|
mLastSelectionStart = newSelStart;
|
||||||
mLastSelectionEnd = newSelEnd;
|
mLastSelectionEnd = newSelEnd;
|
||||||
|
|
||||||
if (mReCorrectionEnabled && isShowingSuggestionsStrip()) {
|
if (mRecorrectionEnabled && isShowingSuggestionsStrip()) {
|
||||||
// Don't look for corrections if the keyboard is not visible
|
// Don't look for corrections if the keyboard is not visible
|
||||||
if (mKeyboardSwitcher.isInputViewShown()) {
|
if (mKeyboardSwitcher.isInputViewShown()) {
|
||||||
// Check if we should go in or out of correction mode.
|
// Check if we should go in or out of correction mode.
|
||||||
if (isSuggestionsRequested() && !mJustReverted
|
if (isSuggestionsRequested() && !mJustReverted
|
||||||
&& (candidatesStart == candidatesEnd || newSelStart != oldSelStart
|
&& (candidatesStart == candidatesEnd || newSelStart != oldSelStart
|
||||||
|| TextEntryState.isCorrecting())
|
|| TextEntryState.isRecorrecting())
|
||||||
&& (newSelStart < newSelEnd - 1 || !mHasValidSuggestions)) {
|
&& (newSelStart < newSelEnd - 1 || !mHasValidSuggestions)) {
|
||||||
if (isCursorTouchingWord() || mLastSelectionStart < mLastSelectionEnd) {
|
if (isCursorTouchingWord() || mLastSelectionStart < mLastSelectionEnd) {
|
||||||
mHandler.postUpdateOldSuggestions();
|
mHandler.postUpdateOldSuggestions();
|
||||||
} else {
|
} else {
|
||||||
abortCorrection(false);
|
abortRecorrection(false);
|
||||||
// Show the punctuation suggestions list if the current one is not
|
// Show the punctuation suggestions list if the current one is not
|
||||||
// and if not showing "Touch again to save".
|
// and if not showing "Touch again to save".
|
||||||
if (mCandidateView != null && !isShowingPunctuationList()
|
if (mCandidateView != null && !isShowingPunctuationList()
|
||||||
|
@ -769,7 +769,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onExtractedTextClicked() {
|
public void onExtractedTextClicked() {
|
||||||
if (mReCorrectionEnabled && isSuggestionsRequested()) return;
|
if (mRecorrectionEnabled && isSuggestionsRequested()) return;
|
||||||
|
|
||||||
super.onExtractedTextClicked();
|
super.onExtractedTextClicked();
|
||||||
}
|
}
|
||||||
|
@ -785,7 +785,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onExtractedCursorMovement(int dx, int dy) {
|
public void onExtractedCursorMovement(int dx, int dy) {
|
||||||
if (mReCorrectionEnabled && isSuggestionsRequested()) return;
|
if (mRecorrectionEnabled && isSuggestionsRequested()) return;
|
||||||
|
|
||||||
super.onExtractedCursorMovement(dx, dy);
|
super.onExtractedCursorMovement(dx, dy);
|
||||||
}
|
}
|
||||||
|
@ -1154,7 +1154,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
mVoiceConnector.commitVoiceInput();
|
mVoiceConnector.commitVoiceInput();
|
||||||
InputConnection ic = getCurrentInputConnection();
|
InputConnection ic = getCurrentInputConnection();
|
||||||
if (ic == null) return;
|
if (ic == null) return;
|
||||||
abortCorrection(false);
|
abortRecorrection(false);
|
||||||
ic.beginBatchEdit();
|
ic.beginBatchEdit();
|
||||||
commitTyped(ic);
|
commitTyped(ic);
|
||||||
maybeRemovePreviousPeriod(text);
|
maybeRemovePreviousPeriod(text);
|
||||||
|
@ -1255,9 +1255,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void abortCorrection(boolean force) {
|
private void abortRecorrection(boolean force) {
|
||||||
if (force || TextEntryState.isCorrecting()) {
|
if (force || TextEntryState.isRecorrecting()) {
|
||||||
TextEntryState.onAbortCorrection();
|
TextEntryState.onAbortRecorrection();
|
||||||
setCandidatesViewShown(isCandidateStripVisible());
|
setCandidatesViewShown(isCandidateStripVisible());
|
||||||
getCurrentInputConnection().finishComposingText();
|
getCurrentInputConnection().finishComposingText();
|
||||||
clearSuggestions();
|
clearSuggestions();
|
||||||
|
@ -1267,8 +1267,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
private void handleCharacter(int primaryCode, int[] keyCodes, int x, int y) {
|
private void handleCharacter(int primaryCode, int[] keyCodes, int x, int y) {
|
||||||
mVoiceConnector.handleCharacter();
|
mVoiceConnector.handleCharacter();
|
||||||
|
|
||||||
if (mLastSelectionStart == mLastSelectionEnd && TextEntryState.isCorrecting()) {
|
if (mLastSelectionStart == mLastSelectionEnd && TextEntryState.isRecorrecting()) {
|
||||||
abortCorrection(false);
|
abortRecorrection(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
int code = primaryCode;
|
int code = primaryCode;
|
||||||
|
@ -1336,7 +1336,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
final InputConnection ic = getCurrentInputConnection();
|
final InputConnection ic = getCurrentInputConnection();
|
||||||
if (ic != null) {
|
if (ic != null) {
|
||||||
ic.beginBatchEdit();
|
ic.beginBatchEdit();
|
||||||
abortCorrection(false);
|
abortRecorrection(false);
|
||||||
}
|
}
|
||||||
if (mHasValidSuggestions) {
|
if (mHasValidSuggestions) {
|
||||||
// In certain languages where single quote is a separator, it's better
|
// In certain languages where single quote is a separator, it's better
|
||||||
|
@ -1439,7 +1439,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
private boolean isCandidateStripVisible() {
|
private boolean isCandidateStripVisible() {
|
||||||
if (mCandidateView == null)
|
if (mCandidateView == null)
|
||||||
return false;
|
return false;
|
||||||
if (mCandidateView.isShowingAddToDictionaryHint() || TextEntryState.isCorrecting())
|
if (mCandidateView.isShowingAddToDictionaryHint() || TextEntryState.isRecorrecting())
|
||||||
return true;
|
return true;
|
||||||
if (!isShowingSuggestionsStrip())
|
if (!isShowingSuggestionsStrip())
|
||||||
return false;
|
return false;
|
||||||
|
@ -1528,7 +1528,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
}
|
}
|
||||||
// Don't auto-correct words with multiple capital letter
|
// Don't auto-correct words with multiple capital letter
|
||||||
correctionAvailable &= !word.isMostlyCaps();
|
correctionAvailable &= !word.isMostlyCaps();
|
||||||
correctionAvailable &= !TextEntryState.isCorrecting();
|
correctionAvailable &= !TextEntryState.isRecorrecting();
|
||||||
|
|
||||||
// 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
|
||||||
|
@ -1586,7 +1586,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
SuggestedWords suggestions = mCandidateView.getSuggestions();
|
SuggestedWords suggestions = mCandidateView.getSuggestions();
|
||||||
mVoiceConnector.flushAndLogAllTextModificationCounters(index, suggestion, mWordSeparators);
|
mVoiceConnector.flushAndLogAllTextModificationCounters(index, suggestion, mWordSeparators);
|
||||||
|
|
||||||
final boolean correcting = TextEntryState.isCorrecting();
|
final boolean recorrecting = TextEntryState.isRecorrecting();
|
||||||
InputConnection ic = getCurrentInputConnection();
|
InputConnection ic = getCurrentInputConnection();
|
||||||
if (ic != null) {
|
if (ic != null) {
|
||||||
ic.beginBatchEdit();
|
ic.beginBatchEdit();
|
||||||
|
@ -1636,7 +1636,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
index, suggestions.mWords);
|
index, suggestions.mWords);
|
||||||
TextEntryState.acceptedSuggestion(mComposing.toString(), suggestion);
|
TextEntryState.acceptedSuggestion(mComposing.toString(), suggestion);
|
||||||
// Follow it with a space
|
// Follow it with a space
|
||||||
if (mAutoSpace && !correcting) {
|
if (mAutoSpace && !recorrecting) {
|
||||||
sendSpace();
|
sendSpace();
|
||||||
mJustAddedAutoSpace = true;
|
mJustAddedAutoSpace = true;
|
||||||
}
|
}
|
||||||
|
@ -1657,7 +1657,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
&& !mSuggest.isValidWord(suggestion)
|
&& !mSuggest.isValidWord(suggestion)
|
||||||
&& !mSuggest.isValidWord(suggestion.toString().toLowerCase())));
|
&& !mSuggest.isValidWord(suggestion.toString().toLowerCase())));
|
||||||
|
|
||||||
if (!correcting) {
|
if (!recorrecting) {
|
||||||
// Fool the state watcher so that a subsequent backspace will not do a revert, unless
|
// Fool the state watcher so that a subsequent backspace will not do a revert, unless
|
||||||
// we just did a correction, in which case we need to stay in
|
// we just did a correction, in which case we need to stay in
|
||||||
// TextEntryState.State.PICKED_SUGGESTION state.
|
// TextEntryState.State.PICKED_SUGGESTION state.
|
||||||
|
@ -1761,19 +1761,19 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
|
|
||||||
if (!mVoiceConnector.applyVoiceAlternatives(touching)
|
if (!mVoiceConnector.applyVoiceAlternatives(touching)
|
||||||
&& !applyTypedAlternatives(touching)) {
|
&& !applyTypedAlternatives(touching)) {
|
||||||
abortCorrection(true);
|
abortRecorrection(true);
|
||||||
} else {
|
} else {
|
||||||
TextEntryState.selectedForCorrection();
|
TextEntryState.selectedForRecorrection();
|
||||||
EditingUtils.underlineWord(ic, touching);
|
EditingUtils.underlineWord(ic, touching);
|
||||||
}
|
}
|
||||||
|
|
||||||
ic.endBatchEdit();
|
ic.endBatchEdit();
|
||||||
} else {
|
} else {
|
||||||
abortCorrection(true);
|
abortRecorrection(true);
|
||||||
setPunctuationSuggestions(); // Show the punctuation suggestions list
|
setPunctuationSuggestions(); // Show the punctuation suggestions list
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
abortCorrection(true);
|
abortRecorrection(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,8 +61,8 @@ public class TextEntryState {
|
||||||
SPACE_AFTER_ACCEPTED,
|
SPACE_AFTER_ACCEPTED,
|
||||||
SPACE_AFTER_PICKED,
|
SPACE_AFTER_PICKED,
|
||||||
UNDO_COMMIT,
|
UNDO_COMMIT,
|
||||||
CORRECTING,
|
RECORRECTING,
|
||||||
PICKED_CORRECTION,
|
PICKED_RECORRECTION,
|
||||||
}
|
}
|
||||||
|
|
||||||
private static State sState = State.UNKNOWN;
|
private static State sState = State.UNKNOWN;
|
||||||
|
@ -158,21 +158,21 @@ public class TextEntryState {
|
||||||
if (typedWord.equals(actualWord)) {
|
if (typedWord.equals(actualWord)) {
|
||||||
acceptedTyped(typedWord);
|
acceptedTyped(typedWord);
|
||||||
}
|
}
|
||||||
if (oldState == State.CORRECTING || oldState == State.PICKED_CORRECTION) {
|
if (oldState == State.RECORRECTING || oldState == State.PICKED_RECORRECTION) {
|
||||||
sState = State.PICKED_CORRECTION;
|
sState = State.PICKED_RECORRECTION;
|
||||||
} else {
|
} else {
|
||||||
sState = State.PICKED_SUGGESTION;
|
sState = State.PICKED_SUGGESTION;
|
||||||
}
|
}
|
||||||
displayState();
|
displayState();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void selectedForCorrection() {
|
public static void selectedForRecorrection() {
|
||||||
sState = State.CORRECTING;
|
sState = State.RECORRECTING;
|
||||||
displayState();
|
displayState();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onAbortCorrection() {
|
public static void onAbortRecorrection() {
|
||||||
if (isCorrecting()) {
|
if (isRecorrecting()) {
|
||||||
sState = State.START;
|
sState = State.START;
|
||||||
}
|
}
|
||||||
displayState();
|
displayState();
|
||||||
|
@ -199,7 +199,7 @@ public class TextEntryState {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PICKED_SUGGESTION:
|
case PICKED_SUGGESTION:
|
||||||
case PICKED_CORRECTION:
|
case PICKED_RECORRECTION:
|
||||||
if (isSpace) {
|
if (isSpace) {
|
||||||
sState = State.SPACE_AFTER_PICKED;
|
sState = State.SPACE_AFTER_PICKED;
|
||||||
} else if (isSeparator) {
|
} else if (isSeparator) {
|
||||||
|
@ -227,7 +227,7 @@ public class TextEntryState {
|
||||||
sState = State.IN_WORD;
|
sState = State.IN_WORD;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CORRECTING:
|
case RECORRECTING:
|
||||||
sState = State.START;
|
sState = State.START;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -258,8 +258,8 @@ public class TextEntryState {
|
||||||
return sState;
|
return sState;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isCorrecting() {
|
public static boolean isRecorrecting() {
|
||||||
return sState == State.CORRECTING || sState == State.PICKED_CORRECTION;
|
return sState == State.RECORRECTING || sState == State.PICKED_RECORRECTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void keyPressedAt(Key key, int x, int y) {
|
public static void keyPressedAt(Key key, int x, int y) {
|
||||||
|
|
Loading…
Reference in a new issue