am bf418f7c: Pass time stamp to addToUserHistory method as an argument

* commit 'bf418f7cba9b935785797e4ec34959fe0aef69b3':
  Pass time stamp to addToUserHistory method as an argument
main
Tadashi G. Takaoka 2014-01-13 23:15:26 -08:00 committed by Android Git Automerger
commit 4260f4efd7
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,