aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/inputlogic
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/com/android/inputmethod/latin/inputlogic')
-rw-r--r--java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java68
1 files changed, 25 insertions, 43 deletions
diff --git a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
index f3840f74e..5b3b28d75 100644
--- a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
+++ b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
@@ -225,9 +225,7 @@ public final class InputLogic {
* @return the complete transaction object
*/
public InputTransaction onTextInput(final SettingsValues settingsValues, final Event event,
- final int keyboardShiftMode,
- // TODO: remove this argument
- final LatinIME.UIHandler handler) {
+ final int keyboardShiftMode, final LatinIME.UIHandler handler) {
final String rawText = event.getTextToCommit().toString();
final InputTransaction inputTransaction = new InputTransaction(settingsValues, event,
SystemClock.uptimeMillis(), mSpaceState,
@@ -266,12 +264,14 @@ public final class InputLogic {
// interface
public InputTransaction onPickSuggestionManually(final SettingsValues settingsValues,
final SuggestedWordInfo suggestionInfo, final int keyboardShiftState,
- // TODO: remove these arguments
final int currentKeyboardScriptId, final LatinIME.UIHandler handler) {
final SuggestedWords suggestedWords = mSuggestedWords;
final String suggestion = suggestionInfo.mWord;
// If this is a punctuation picked from the suggestion strip, pass it to onCodeInput
if (suggestion.length() == 1 && suggestedWords.isPunctuationSuggestions()) {
+ // We still want to log a suggestion click.
+ StatsUtils.onPickSuggestionManually(
+ mSuggestedWords, suggestionInfo, mDictionaryFacilitator);
// Word separators are suggested before the user inputs something.
// Rely on onCodeInput to do the complicated swapping/stripping logic consistently.
final Event event = Event.createPunctuationSuggestionPickedEvent(suggestionInfo);
@@ -324,7 +324,8 @@ public final class InputLogic {
// That's going to be predictions (or punctuation suggestions), so INPUT_STYLE_NONE.
handler.postUpdateSuggestionStrip(SuggestedWords.INPUT_STYLE_NONE);
- StatsUtils.onPickSuggestionManually(mSuggestedWords, suggestionInfo);
+ StatsUtils.onPickSuggestionManually(
+ mSuggestedWords, suggestionInfo, mDictionaryFacilitator);
StatsUtils.onWordCommitSuggestionPickedManually(
suggestionInfo.mWord, mWordComposer.isBatchMode());
return inputTransaction;
@@ -418,7 +419,6 @@ public final class InputLogic {
*/
public InputTransaction onCodeInput(final SettingsValues settingsValues,
@Nonnull final Event event, final int keyboardShiftMode,
- // TODO: remove these arguments
final int currentKeyboardScriptId, final LatinIME.UIHandler handler) {
final Event processedEvent = mWordComposer.processEvent(event);
final InputTransaction inputTransaction = new InputTransaction(settingsValues,
@@ -465,7 +465,6 @@ public final class InputLogic {
}
public void onStartBatchInput(final SettingsValues settingsValues,
- // TODO: remove these arguments
final KeyboardSwitcher keyboardSwitcher, final LatinIME.UIHandler handler) {
mInputLogicHandler.onStartBatchInput();
handler.showGesturePreviewAndSuggestionStrip(
@@ -529,10 +528,7 @@ public final class InputLogic {
* earlier sequence number.
*/
private int mAutoCommitSequenceNumber = 1;
- public void onUpdateBatchInput(final SettingsValues settingsValues,
- final InputPointers batchPointers,
- // TODO: remove these arguments
- final KeyboardSwitcher keyboardSwitcher) {
+ public void onUpdateBatchInput(final InputPointers batchPointers) {
mInputLogicHandler.onUpdateBatchInput(batchPointers, mAutoCommitSequenceNumber);
}
@@ -541,7 +537,6 @@ public final class InputLogic {
++mAutoCommitSequenceNumber;
}
- // TODO: remove this argument
public void onCancelBatchInput(final LatinIME.UIHandler handler) {
mInputLogicHandler.onCancelBatchInput();
handler.showGesturePreviewAndSuggestionStrip(
@@ -617,7 +612,6 @@ public final class InputLogic {
* @param inputTransaction The transaction in progress.
*/
private void handleFunctionalEvent(final Event event, final InputTransaction inputTransaction,
- // TODO: remove these arguments
final int currentKeyboardScriptId, final LatinIME.UIHandler handler) {
switch (event.mKeyCode) {
case Constants.CODE_DELETE:
@@ -669,7 +663,6 @@ public final class InputLogic {
// handled in {@link KeyboardState#onEvent(Event,int)}.
break;
case Constants.CODE_SHIFT_ENTER:
- // TODO: remove this object
final Event tmpEvent = Event.createSoftwareKeypressEvent(Constants.CODE_ENTER,
event.mKeyCode, event.mX, event.mY, event.isKeyRepeat());
handleNonSpecialCharacterEvent(tmpEvent, inputTransaction, handler);
@@ -693,7 +686,6 @@ public final class InputLogic {
*/
private void handleNonFunctionalEvent(final Event event,
final InputTransaction inputTransaction,
- // TODO: remove this argument
final LatinIME.UIHandler handler) {
inputTransaction.setDidAffectContents();
switch (event.mCodePoint) {
@@ -739,7 +731,6 @@ public final class InputLogic {
*/
private void handleNonSpecialCharacterEvent(final Event event,
final InputTransaction inputTransaction,
- // TODO: remove this argument
final LatinIME.UIHandler handler) {
final int codePoint = event.mCodePoint;
mSpaceState = SpaceState.NONE;
@@ -845,7 +836,6 @@ public final class InputLogic {
* @param inputTransaction The transaction in progress.
*/
private void handleSeparatorEvent(final Event event, final InputTransaction inputTransaction,
- // TODO: remove this argument
final LatinIME.UIHandler handler) {
final int codePoint = event.mCodePoint;
final SettingsValues settingsValues = inputTransaction.mSettingsValues;
@@ -953,7 +943,6 @@ public final class InputLogic {
* @param inputTransaction The transaction in progress.
*/
private void handleBackspaceEvent(final Event event, final InputTransaction inputTransaction,
- // TODO: remove this argument, put it into settingsValues
final int currentKeyboardScriptId) {
mSpaceState = SpaceState.NONE;
mDeleteCount++;
@@ -1157,7 +1146,6 @@ public final class InputLogic {
settingsValues.mSpacingAndPunctuations,
currentKeyboardScriptId);
if (range == null) {
- // TODO(zivkovic): Check for bad connection before getting this far.
// Happens if we don't have an input connection at all.
return false;
}
@@ -1395,6 +1383,11 @@ public final class InputLogic {
return;
}
+ if (!mWordComposer.isComposingWord() && !settingsValues.mBigramPredictionEnabled) {
+ mSuggestionStripViewAccessor.setNeutralSuggestionStrip();
+ return;
+ }
+
final AsyncResultHolder<SuggestedWords> holder = new AsyncResultHolder<>();
mInputLogicHandler.getSuggestedWords(inputStyle, SuggestedWords.NOT_A_SEQUENCE_NUMBER,
new OnGetSuggestedWordsCallback() {
@@ -1402,7 +1395,8 @@ public final class InputLogic {
public void onGetSuggestedWords(final SuggestedWords suggestedWords) {
final String typedWordString = mWordComposer.getTypedWord();
final SuggestedWordInfo typedWordInfo = new SuggestedWordInfo(
- typedWordString, SuggestedWordInfo.MAX_SCORE,
+ typedWordString, "" /* prevWordsContext */,
+ SuggestedWordInfo.MAX_SCORE,
SuggestedWordInfo.KIND_TYPED, Dictionary.DICTIONARY_USER_TYPED,
SuggestedWordInfo.NOT_AN_INDEX /* indexOfTouchPointOfSecondWord */,
SuggestedWordInfo.NOT_A_CONFIDENCE);
@@ -1435,7 +1429,6 @@ public final class InputLogic {
* to a cursor move, for example). In ICS, there is a platform bug that we need to work
* around only when we come here at input start time.
*/
- // TODO: make this private.
public void restartSuggestionsOnWordTouchedByCursor(final SettingsValues settingsValues,
final boolean forStartInput,
// TODO: remove this argument, put it into settingsValues
@@ -1486,7 +1479,7 @@ public final class InputLogic {
final ArrayList<SuggestedWordInfo> suggestions = new ArrayList<>();
final String typedWordString = range.mWord.toString();
final SuggestedWordInfo typedWordInfo = new SuggestedWordInfo(typedWordString,
- SuggestedWords.MAX_SUGGESTIONS + 1,
+ "" /* prevWordsContext */, SuggestedWords.MAX_SUGGESTIONS + 1,
SuggestedWordInfo.KIND_TYPED, Dictionary.DICTIONARY_USER_TYPED,
SuggestedWordInfo.NOT_AN_INDEX /* indexOfTouchPointOfSecondWord */,
SuggestedWordInfo.NOT_A_CONFIDENCE /* autoCommitFirstWordConfidence */);
@@ -1501,7 +1494,7 @@ public final class InputLogic {
++i;
if (!TextUtils.equals(s, typedWordString)) {
suggestions.add(new SuggestedWordInfo(s,
- SuggestedWords.MAX_SUGGESTIONS - i,
+ "" /* prevWordsContext */, SuggestedWords.MAX_SUGGESTIONS - i,
SuggestedWordInfo.KIND_RESUMED, Dictionary.DICTIONARY_RESUMED,
SuggestedWordInfo.NOT_AN_INDEX /* indexOfTouchPointOfSecondWord */,
SuggestedWordInfo.NOT_A_CONFIDENCE
@@ -1602,15 +1595,11 @@ public final class InputLogic {
// First, add the committed word to the list of suggestions.
suggestions.add(committedWordString);
for (final Object span : spans) {
- // If this is a suggestion span, we check that the locale is the right one, and
- // that the word is not the committed word. That should mostly be the case.
+ // If this is a suggestion span, we check that the word is not the committed word.
+ // That should mostly be the case.
// Given this, we add it to the list of suggestions, otherwise we discard it.
if (span instanceof SuggestionSpan) {
final SuggestionSpan suggestionSpan = (SuggestionSpan)span;
- if (!suggestionSpan.getLocale().equals(
- inputTransaction.mSettingsValues.mLocale.toString())) {
- continue;
- }
for (final String suggestion : suggestionSpan.getSuggestions()) {
if (!suggestion.equals(committedWordString)) {
suggestions.add(suggestion);
@@ -1719,7 +1708,6 @@ public final class InputLogic {
* @param nthPreviousWord reverse index of the word to get (1-indexed)
* @return the information of previous words
*/
- // TODO: Make this private
public NgramContext getNgramContextFromNthPreviousWordForSuggestion(
final SpacingAndPunctuations spacingAndPunctuations, final int nthPreviousWord) {
if (spacingAndPunctuations.mCurrentLanguageHasSpaces) {
@@ -1949,9 +1937,7 @@ public final class InputLogic {
* @param suggestedWords suggestedWords to use.
*/
public void onUpdateTailBatchInputCompleted(final SettingsValues settingsValues,
- final SuggestedWords suggestedWords,
- // TODO: remove this argument
- final KeyboardSwitcher keyboardSwitcher) {
+ final SuggestedWords suggestedWords, final KeyboardSwitcher keyboardSwitcher) {
final String batchInputText = suggestedWords.isEmpty() ? null : suggestedWords.getWord(0);
if (TextUtils.isEmpty(batchInputText)) {
return;
@@ -1984,7 +1970,6 @@ public final class InputLogic {
* @param settingsValues the current values of the settings.
* @param separatorString the separator that's causing the commit, or NOT_A_SEPARATOR if none.
*/
- // TODO: Make this private
public void commitTyped(final SettingsValues settingsValues, final String separatorString) {
if (!mWordComposer.isComposingWord()) return;
final String typedWord = mWordComposer.getTypedWord();
@@ -2013,9 +1998,7 @@ public final class InputLogic {
* @param separator the separator that's causing the commit to happen.
*/
private void commitCurrentAutoCorrection(final SettingsValues settingsValues,
- final String separator,
- // TODO: Remove this argument.
- final LatinIME.UIHandler handler) {
+ final String separator, final LatinIME.UIHandler handler) {
// Complete any pending suggestions query first
if (handler.hasPendingUpdateSuggestions()) {
handler.cancelUpdateSuggestionStrip();
@@ -2051,9 +2034,11 @@ public final class InputLogic {
mConnection.commitCorrection(new CorrectionInfo(
mConnection.getExpectedSelectionEnd() - stringToCommit.length(),
typedWord, stringToCommit));
+ String prevWordsContext = (autoCorrectionOrNull != null)
+ ? autoCorrectionOrNull.mPrevWordsContext
+ : "";
StatsUtils.onAutoCorrection(typedWord, stringToCommit, isBatchMode,
- null == autoCorrectionOrNull
- ? null : autoCorrectionOrNull.mSourceDict.mDictType);
+ mDictionaryFacilitator, prevWordsContext);
StatsUtils.onWordCommitAutoCorrect(stringToCommit, isBatchMode);
} else {
StatsUtils.onWordCommitUserTyped(stringToCommit, isBatchMode);
@@ -2102,11 +2087,8 @@ public final class InputLogic {
* @param remainingTries How many times we may try again before giving up.
* @return whether true if the caches were successfully reset, false otherwise.
*/
- // TODO: make this private
public boolean retryResetCachesAndReturnSuccess(final boolean tryResumeSuggestions,
- final int remainingTries,
- // TODO: remove these arguments
- final LatinIME.UIHandler handler) {
+ final int remainingTries, final LatinIME.UIHandler handler) {
final boolean shouldFinishComposition = mConnection.hasSelection()
|| !mConnection.isCursorPositionKnown();
if (!mConnection.resetCachesUponCursorMoveAndReturnSuccess(