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); mUserDictionary.addWordToUserDictionary(word);
} }
public void addToUserHistory(final WordComposer wordComposer, final String previousWord, public void addToUserHistory(final String suggestion, final boolean wasAutoCapitalized,
final String suggestion) { final String previousWord, final int timeStampInSeconds) {
if (mUserHistoryDictionary == null) { if (mUserHistoryDictionary == null) {
return; 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); final int maxFreq = getMaxFrequency(suggestion);
if (maxFreq == 0) { if (maxFreq == 0) {
return; 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 boolean isValid = maxFreq > 0;
final int timeStamp = (int)TimeUnit.MILLISECONDS.toSeconds((System.currentTimeMillis())); mUserHistoryDictionary.addToDictionary(
mUserHistoryDictionary.addToDictionary(previousWord, secondWord, isValid, timeStamp); previousWord, secondWord, isValid, timeStampInSeconds);
} }
public void cancelAddingUserHistory(final String previousWord, final String committedWord) { 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.ArrayList;
import java.util.TreeSet; import java.util.TreeSet;
import java.util.concurrent.TimeUnit;
/** /**
* This class manages the input logic. * This class manages the input logic.
@ -994,7 +995,12 @@ public final class InputLogic {
final Suggest suggest = mSuggest; final Suggest suggest = mSuggest;
if (suggest == null) return; 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, public void performUpdateSuggestionStripSync(final SettingsValues settingsValues,