[IL12] move restartSuggestions* to InputLogic
Bug: 8636060 Change-Id: I99474248e8fa35eb3053b5520abc8716805fdfb4
This commit is contained in:
parent
10755af97b
commit
bbe40835a9
2 changed files with 44 additions and 35 deletions
|
@ -2222,40 +2222,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
mHandler.showSuggestionStripWithTypedWord(suggestedWords, typedWord);
|
mHandler.showSuggestionStripWithTypedWord(suggestedWords, typedWord);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if the cursor is actually at the end of a word. If so, restart suggestions on this
|
|
||||||
* word, else do nothing.
|
|
||||||
*/
|
|
||||||
// TODO[IL]: Move this to InputLogic and make it private.
|
|
||||||
public void restartSuggestionsOnWordBeforeCursorIfAtEndOfWord() {
|
|
||||||
final CharSequence word =
|
|
||||||
mInputLogic.mConnection.getWordBeforeCursorIfAtEndOfWord(mSettings.getCurrent());
|
|
||||||
if (null != word) {
|
|
||||||
final String wordString = word.toString();
|
|
||||||
restartSuggestionsOnWordBeforeCursor(wordString);
|
|
||||||
// TODO: Handle the case where the user manually moves the cursor and then backs up over
|
|
||||||
// a separator. In that case, the current log unit should not be uncommitted.
|
|
||||||
if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
|
|
||||||
ResearchLogger.getInstance().uncommitCurrentLogUnit(wordString,
|
|
||||||
true /* dumpCurrentLogUnit */);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO[IL]: Move this to InputLogic
|
|
||||||
private void restartSuggestionsOnWordBeforeCursor(final String word) {
|
|
||||||
mInputLogic.mWordComposer.setComposingWord(word,
|
|
||||||
// Previous word is the 2nd word before cursor because we are restarting on the
|
|
||||||
// 1st word before cursor.
|
|
||||||
mInputLogic.getNthPreviousWordForSuggestion(mSettings.getCurrent(),
|
|
||||||
2 /* nthPreviousWord */),
|
|
||||||
mKeyboardSwitcher.getKeyboard());
|
|
||||||
final int length = word.length();
|
|
||||||
mInputLogic.mConnection.deleteSurroundingText(length, 0);
|
|
||||||
mInputLogic.mConnection.setComposingText(word, 1);
|
|
||||||
mHandler.postUpdateSuggestionStrip();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retry resetting caches in the rich input connection.
|
* Retry resetting caches in the rich input connection.
|
||||||
*
|
*
|
||||||
|
|
|
@ -632,7 +632,8 @@ public final class InputLogic {
|
||||||
// TODO: move mDisplayOrientation to CurrentSettings.
|
// TODO: move mDisplayOrientation to CurrentSettings.
|
||||||
if (settingsValues.isSuggestionsRequested(mLatinIME.mDisplayOrientation)
|
if (settingsValues.isSuggestionsRequested(mLatinIME.mDisplayOrientation)
|
||||||
&& settingsValues.mCurrentLanguageHasSpaces) {
|
&& settingsValues.mCurrentLanguageHasSpaces) {
|
||||||
mLatinIME.restartSuggestionsOnWordBeforeCursorIfAtEndOfWord();
|
restartSuggestionsOnWordBeforeCursorIfAtEndOfWord(settingsValues, keyboardSwitcher,
|
||||||
|
handler);
|
||||||
}
|
}
|
||||||
// We just removed a character. We need to update the auto-caps state.
|
// We just removed a character. We need to update the auto-caps state.
|
||||||
keyboardSwitcher.updateShiftState();
|
keyboardSwitcher.updateShiftState();
|
||||||
|
@ -810,6 +811,48 @@ public final class InputLogic {
|
||||||
keyboardSwitcher.updateShiftState();
|
keyboardSwitcher.updateShiftState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the cursor is actually at the end of a word. If so, restart suggestions on this
|
||||||
|
* word, otherwise do nothing.
|
||||||
|
* @param settingsValues the current values of the settings.
|
||||||
|
*/
|
||||||
|
private void restartSuggestionsOnWordBeforeCursorIfAtEndOfWord(
|
||||||
|
final SettingsValues settingsValues,
|
||||||
|
// TODO: remove these two arguments
|
||||||
|
final KeyboardSwitcher keyboardSwitcher, final LatinIME.UIHandler handler) {
|
||||||
|
final CharSequence word = mConnection.getWordBeforeCursorIfAtEndOfWord(settingsValues);
|
||||||
|
if (null != word) {
|
||||||
|
final String wordString = word.toString();
|
||||||
|
restartSuggestionsOnWordBeforeCursor(settingsValues, wordString, keyboardSwitcher,
|
||||||
|
handler);
|
||||||
|
// TODO: Handle the case where the user manually moves the cursor and then backs up over
|
||||||
|
// a separator. In that case, the current log unit should not be uncommitted.
|
||||||
|
if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
|
||||||
|
ResearchLogger.getInstance().uncommitCurrentLogUnit(wordString,
|
||||||
|
true /* dumpCurrentLogUnit */);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Restart suggestions on the word passed as an argument, assuming it is before the cursor.
|
||||||
|
* @param settingsValues the current settings values.
|
||||||
|
*/
|
||||||
|
private void restartSuggestionsOnWordBeforeCursor(final SettingsValues settingsValues,
|
||||||
|
final String word,
|
||||||
|
// TODO: remove these two arguments
|
||||||
|
final KeyboardSwitcher keyboardSwitcher, final LatinIME.UIHandler handler) {
|
||||||
|
mWordComposer.setComposingWord(word,
|
||||||
|
// Previous word is the 2nd word before cursor because we are restarting on the
|
||||||
|
// 1st word before cursor.
|
||||||
|
getNthPreviousWordForSuggestion(settingsValues, 2 /* nthPreviousWord */),
|
||||||
|
keyboardSwitcher.getKeyboard());
|
||||||
|
final int length = word.length();
|
||||||
|
mConnection.deleteSurroundingText(length, 0);
|
||||||
|
mConnection.setComposingText(word, 1);
|
||||||
|
handler.postUpdateSuggestionStrip();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reverts a previous commit with auto-correction.
|
* Reverts a previous commit with auto-correction.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue