Merge "Actually use the bigram prediction option."
This commit is contained in:
commit
c121b5d03e
1 changed files with 21 additions and 16 deletions
|
@ -269,7 +269,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
private static final int MSG_FADEOUT_LANGUAGE_ON_SPACEBAR = 4;
|
private static final int MSG_FADEOUT_LANGUAGE_ON_SPACEBAR = 4;
|
||||||
private static final int MSG_DISMISS_LANGUAGE_ON_SPACEBAR = 5;
|
private static final int MSG_DISMISS_LANGUAGE_ON_SPACEBAR = 5;
|
||||||
private static final int MSG_SPACE_TYPED = 6;
|
private static final int MSG_SPACE_TYPED = 6;
|
||||||
private static final int MSG_SET_BIGRAM_SUGGESTIONS = 7;
|
private static final int MSG_SET_BIGRAM_PREDICTIONS = 7;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleMessage(Message msg) {
|
public void handleMessage(Message msg) {
|
||||||
|
@ -285,8 +285,8 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
case MSG_UPDATE_SHIFT_STATE:
|
case MSG_UPDATE_SHIFT_STATE:
|
||||||
switcher.updateShiftState();
|
switcher.updateShiftState();
|
||||||
break;
|
break;
|
||||||
case MSG_SET_BIGRAM_SUGGESTIONS:
|
case MSG_SET_BIGRAM_PREDICTIONS:
|
||||||
updateBigramSuggestions();
|
updateBigramPredictions();
|
||||||
break;
|
break;
|
||||||
case MSG_VOICE_RESULTS:
|
case MSG_VOICE_RESULTS:
|
||||||
mVoiceProxy.handleVoiceResults(preferCapitalization()
|
mVoiceProxy.handleVoiceResults(preferCapitalization()
|
||||||
|
@ -340,13 +340,13 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
removeMessages(MSG_UPDATE_SHIFT_STATE);
|
removeMessages(MSG_UPDATE_SHIFT_STATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void postSetBigramSuggestions() {
|
public void postUpdateBigramPredictions() {
|
||||||
removeMessages(MSG_SET_BIGRAM_SUGGESTIONS);
|
removeMessages(MSG_SET_BIGRAM_PREDICTIONS);
|
||||||
sendMessageDelayed(obtainMessage(MSG_SET_BIGRAM_SUGGESTIONS), DELAY_UPDATE_SUGGESTIONS);
|
sendMessageDelayed(obtainMessage(MSG_SET_BIGRAM_PREDICTIONS), DELAY_UPDATE_SUGGESTIONS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cancelSetBigramSuggestions() {
|
public void cancelUpdateBigramPredictions() {
|
||||||
removeMessages(MSG_SET_BIGRAM_SUGGESTIONS);
|
removeMessages(MSG_SET_BIGRAM_PREDICTIONS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateVoiceResults() {
|
public void updateVoiceResults() {
|
||||||
|
@ -771,7 +771,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
mComposing.setLength(0);
|
mComposing.setLength(0);
|
||||||
mHasValidSuggestions = false;
|
mHasValidSuggestions = false;
|
||||||
if (isCursorTouchingWord()) {
|
if (isCursorTouchingWord()) {
|
||||||
mHandler.cancelSetBigramSuggestions();
|
mHandler.cancelUpdateBigramPredictions();
|
||||||
mHandler.postUpdateSuggestions();
|
mHandler.postUpdateSuggestions();
|
||||||
} else {
|
} else {
|
||||||
setPunctuationSuggestions();
|
setPunctuationSuggestions();
|
||||||
|
@ -805,7 +805,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
|| TextEntryState.isRecorrecting())
|
|| TextEntryState.isRecorrecting())
|
||||||
&& (newSelStart < newSelEnd - 1 || !mHasValidSuggestions)) {
|
&& (newSelStart < newSelEnd - 1 || !mHasValidSuggestions)) {
|
||||||
if (isCursorTouchingWord() || mLastSelectionStart < mLastSelectionEnd) {
|
if (isCursorTouchingWord() || mLastSelectionStart < mLastSelectionEnd) {
|
||||||
mHandler.cancelSetBigramSuggestions();
|
mHandler.cancelUpdateBigramPredictions();
|
||||||
mHandler.postUpdateOldSuggestions();
|
mHandler.postUpdateOldSuggestions();
|
||||||
} else {
|
} else {
|
||||||
abortRecorrection(false);
|
abortRecorrection(false);
|
||||||
|
@ -817,7 +817,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
if (null == ic || !TextUtils.isEmpty(ic.getTextAfterCursor(1, 0))) {
|
if (null == ic || !TextUtils.isEmpty(ic.getTextAfterCursor(1, 0))) {
|
||||||
if (!isShowingPunctuationList()) setPunctuationSuggestions();
|
if (!isShowingPunctuationList()) setPunctuationSuggestions();
|
||||||
} else {
|
} else {
|
||||||
mHandler.postSetBigramSuggestions();
|
mHandler.postUpdateBigramPredictions();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1261,7 +1261,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
if (1 == length) {
|
if (1 == length) {
|
||||||
// 1 == length means we are about to erase the last character of the word,
|
// 1 == length means we are about to erase the last character of the word,
|
||||||
// so we can show bigrams.
|
// so we can show bigrams.
|
||||||
mHandler.postSetBigramSuggestions();
|
mHandler.postUpdateBigramPredictions();
|
||||||
} else {
|
} else {
|
||||||
// length > 1, so we still have letters to deduce a suggestion from.
|
// length > 1, so we still have letters to deduce a suggestion from.
|
||||||
mHandler.postUpdateSuggestions();
|
mHandler.postUpdateSuggestions();
|
||||||
|
@ -1401,7 +1401,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
|
|
||||||
// Should dismiss the "Touch again to save" message when handling separator
|
// Should dismiss the "Touch again to save" message when handling separator
|
||||||
if (mCandidateView != null && mCandidateView.dismissAddToDictionaryHint()) {
|
if (mCandidateView != null && mCandidateView.dismissAddToDictionaryHint()) {
|
||||||
mHandler.cancelSetBigramSuggestions();
|
mHandler.cancelUpdateBigramPredictions();
|
||||||
mHandler.postUpdateSuggestions();
|
mHandler.postUpdateSuggestions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1461,7 +1461,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
if (!isCursorTouchingWord()) {
|
if (!isCursorTouchingWord()) {
|
||||||
mHandler.cancelUpdateSuggestions();
|
mHandler.cancelUpdateSuggestions();
|
||||||
mHandler.cancelUpdateOldSuggestions();
|
mHandler.cancelUpdateOldSuggestions();
|
||||||
mHandler.postSetBigramSuggestions();
|
mHandler.postUpdateBigramPredictions();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Set punctuation right away. onUpdateSelection will fire but tests whether it is
|
// Set punctuation right away. onUpdateSelection will fire but tests whether it is
|
||||||
|
@ -1859,10 +1859,15 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final WordComposer sEmptyWordComposer = new WordComposer();
|
private static final WordComposer sEmptyWordComposer = new WordComposer();
|
||||||
private void updateBigramSuggestions() {
|
private void updateBigramPredictions() {
|
||||||
if (mSuggest == null || !isSuggestionsRequested())
|
if (mSuggest == null || !isSuggestionsRequested())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (!mBigramPredictionEnabled) {
|
||||||
|
setPunctuationSuggestions();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
final CharSequence prevWord = EditingUtils.getThisWord(getCurrentInputConnection(),
|
final CharSequence prevWord = EditingUtils.getThisWord(getCurrentInputConnection(),
|
||||||
mWordSeparators);
|
mWordSeparators);
|
||||||
SuggestedWords.Builder builder = mSuggest.getSuggestedWordBuilder(
|
SuggestedWords.Builder builder = mSuggest.getSuggestedWordBuilder(
|
||||||
|
@ -1977,7 +1982,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
ic.setComposingText(mComposing, 1);
|
ic.setComposingText(mComposing, 1);
|
||||||
TextEntryState.backspace();
|
TextEntryState.backspace();
|
||||||
}
|
}
|
||||||
mHandler.cancelSetBigramSuggestions();
|
mHandler.cancelUpdateBigramPredictions();
|
||||||
mHandler.postUpdateSuggestions();
|
mHandler.postUpdateSuggestions();
|
||||||
} else {
|
} else {
|
||||||
sendDownUpKeyEvents(KeyEvent.KEYCODE_DEL);
|
sendDownUpKeyEvents(KeyEvent.KEYCODE_DEL);
|
||||||
|
|
Loading…
Reference in a new issue