Pass time stamp to addToUserHistory method as an argument

Bug: 12179576
Change-Id: I93037ee2aa7c0432400fe2f93fb60d2e60f70f5f
This commit is contained in:
Tadashi G. Takaoka 2014-01-14 15:23:58 +09:00
parent 62df0a6d53
commit bf418f7cba
2 changed files with 14 additions and 13 deletions

View file

@ -375,26 +375,21 @@ public class DictionaryFacilitatorForSuggest {
mUserDictionary.addWordToUserDictionary(word);
}
public void addToUserHistory(final WordComposer wordComposer, final String previousWord,
final String suggestion) {
public void addToUserHistory(final String suggestion, final boolean wasAutoCapitalized,
final String previousWord, final int timeStampInSeconds) {
if (mUserHistoryDictionary == null) {
return;
}
final String secondWord;
if (wordComposer.wasAutoCapitalized() && !wordComposer.isMostlyCaps()) {
secondWord = suggestion.toLowerCase(mLocale);
} else {
secondWord = suggestion;
}
// We demote unrecognized words (frequency < 0, below) by specifying them as "invalid".
// We don't add words with 0-frequency (assuming they would be profanity etc.).
final int maxFreq = getMaxFrequency(suggestion);
if (maxFreq == 0) {
return;
}
final String secondWord = wasAutoCapitalized ? suggestion.toLowerCase(mLocale) : suggestion;
// We demote unrecognized words (frequency < 0, below) by specifying them as "invalid".
// We don't add words with 0-frequency (assuming they would be profanity etc.).
final boolean isValid = maxFreq > 0;
final int timeStamp = (int)TimeUnit.MILLISECONDS.toSeconds((System.currentTimeMillis()));
mUserHistoryDictionary.addToDictionary(previousWord, secondWord, isValid, timeStamp);
mUserHistoryDictionary.addToDictionary(
previousWord, secondWord, isValid, timeStampInSeconds);
}
public void cancelAddingUserHistory(final String previousWord, final String committedWord) {

View file

@ -59,6 +59,7 @@ import com.android.inputmethod.research.ResearchLogger;
import java.util.ArrayList;
import java.util.TreeSet;
import java.util.concurrent.TimeUnit;
/**
* This class manages the input logic.
@ -994,7 +995,12 @@ public final class InputLogic {
final Suggest suggest = mSuggest;
if (suggest == null) return;
suggest.mDictionaryFacilitator.addToUserHistory(mWordComposer, prevWord, suggestion);
final boolean wasAutoCapitalized =
mWordComposer.wasAutoCapitalized() && !mWordComposer.isMostlyCaps();
final int timeStampInSeconds = (int)TimeUnit.MILLISECONDS.toSeconds(
System.currentTimeMillis());
suggest.mDictionaryFacilitator.addToUserHistory(suggestion, wasAutoCapitalized, prevWord,
timeStampInSeconds);
}
public void performUpdateSuggestionStripSync(final SettingsValues settingsValues,