Merge "Add StatsUtils.onAutoCorrection method."
This commit is contained in:
commit
da9bd4b9fe
3 changed files with 27 additions and 3 deletions
|
@ -20,6 +20,8 @@ import com.android.inputmethod.latin.RichInputMethodManager;
|
||||||
import com.android.inputmethod.latin.SuggestedWords;
|
import com.android.inputmethod.latin.SuggestedWords;
|
||||||
import com.android.inputmethod.latin.settings.SettingsValues;
|
import com.android.inputmethod.latin.settings.SettingsValues;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public final class StatsUtils {
|
public final class StatsUtils {
|
||||||
|
|
||||||
private StatsUtils() {
|
private StatsUtils() {
|
||||||
|
@ -63,4 +65,8 @@ public final class StatsUtils {
|
||||||
|
|
||||||
public static void onStartInputView(int inputType, int displayOrientation, boolean restarting) {
|
public static void onStartInputView(int inputType, int displayOrientation, boolean restarting) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void onAutoCorrection(final String typedWord, final String autoCorrectionWord,
|
||||||
|
final boolean isBatchInput, @Nullable final String dictionaryType) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,6 +49,7 @@ public final class WordComposer {
|
||||||
private final ArrayList<Event> mEvents;
|
private final ArrayList<Event> mEvents;
|
||||||
private final InputPointers mInputPointers = new InputPointers(MAX_WORD_LENGTH);
|
private final InputPointers mInputPointers = new InputPointers(MAX_WORD_LENGTH);
|
||||||
private String mAutoCorrection;
|
private String mAutoCorrection;
|
||||||
|
private String mAutoCorrectionDictionaryType;
|
||||||
private boolean mIsResumed;
|
private boolean mIsResumed;
|
||||||
private boolean mIsBatchMode;
|
private boolean mIsBatchMode;
|
||||||
// A memory of the last rejected batch mode suggestion, if any. This goes like this: the user
|
// A memory of the last rejected batch mode suggestion, if any. This goes like this: the user
|
||||||
|
@ -418,8 +419,9 @@ public final class WordComposer {
|
||||||
/**
|
/**
|
||||||
* Sets the auto-correction for this word.
|
* Sets the auto-correction for this word.
|
||||||
*/
|
*/
|
||||||
public void setAutoCorrection(final String correction) {
|
public void setAutoCorrection(final String correction, String dictType) {
|
||||||
mAutoCorrection = correction;
|
mAutoCorrection = correction;
|
||||||
|
mAutoCorrectionDictionaryType = dictType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -429,6 +431,13 @@ public final class WordComposer {
|
||||||
return mAutoCorrection;
|
return mAutoCorrection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the auto-correction dictionary type or null if none.
|
||||||
|
*/
|
||||||
|
public String getAutoCorrectionDictionaryTypeOrNull() {
|
||||||
|
return mAutoCorrectionDictionaryType;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return whether we started composing this word by resuming suggestion on an existing string
|
* @return whether we started composing this word by resuming suggestion on an existing string
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -612,14 +612,21 @@ public final class InputLogic {
|
||||||
final SettingsValues settingsValues, final LatinIME.UIHandler handler) {
|
final SettingsValues settingsValues, final LatinIME.UIHandler handler) {
|
||||||
if (SuggestedWords.EMPTY != suggestedWords) {
|
if (SuggestedWords.EMPTY != suggestedWords) {
|
||||||
final String autoCorrection;
|
final String autoCorrection;
|
||||||
|
final String dictType;
|
||||||
if (suggestedWords.mWillAutoCorrect) {
|
if (suggestedWords.mWillAutoCorrect) {
|
||||||
autoCorrection = suggestedWords.getWord(SuggestedWords.INDEX_OF_AUTO_CORRECTION);
|
SuggestedWordInfo info = suggestedWords.getInfo(
|
||||||
|
SuggestedWords.INDEX_OF_AUTO_CORRECTION);
|
||||||
|
autoCorrection = info.mWord;
|
||||||
|
dictType = info.mSourceDict.mDictType;
|
||||||
} else {
|
} else {
|
||||||
// We can't use suggestedWords.getWord(SuggestedWords.INDEX_OF_TYPED_WORD)
|
// We can't use suggestedWords.getWord(SuggestedWords.INDEX_OF_TYPED_WORD)
|
||||||
// because it may differ from mWordComposer.mTypedWord.
|
// because it may differ from mWordComposer.mTypedWord.
|
||||||
autoCorrection = suggestedWords.mTypedWord;
|
autoCorrection = suggestedWords.mTypedWord;
|
||||||
|
dictType = Dictionary.TYPE_USER_TYPED;
|
||||||
}
|
}
|
||||||
mWordComposer.setAutoCorrection(autoCorrection);
|
// TODO: Use the SuggestedWordInfo to set the auto correction when
|
||||||
|
// user typed word is available via SuggestedWordInfo.
|
||||||
|
mWordComposer.setAutoCorrection(autoCorrection, dictType);
|
||||||
}
|
}
|
||||||
mSuggestedWords = suggestedWords;
|
mSuggestedWords = suggestedWords;
|
||||||
final boolean newAutoCorrectionIndicator = suggestedWords.mWillAutoCorrect;
|
final boolean newAutoCorrectionIndicator = suggestedWords.mWillAutoCorrect;
|
||||||
|
@ -2100,6 +2107,8 @@ public final class InputLogic {
|
||||||
mConnection.commitCorrection(new CorrectionInfo(
|
mConnection.commitCorrection(new CorrectionInfo(
|
||||||
mConnection.getExpectedSelectionEnd() - autoCorrection.length(),
|
mConnection.getExpectedSelectionEnd() - autoCorrection.length(),
|
||||||
typedWord, autoCorrection));
|
typedWord, autoCorrection));
|
||||||
|
StatsUtils.onAutoCorrection(typedWord, autoCorrection, mWordComposer.isBatchMode(),
|
||||||
|
mWordComposer.getAutoCorrectionDictionaryTypeOrNull());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue