From bf418f7cba9b935785797e4ec34959fe0aef69b3 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Tue, 14 Jan 2014 15:23:58 +0900 Subject: [PATCH] Pass time stamp to addToUserHistory method as an argument Bug: 12179576 Change-Id: I93037ee2aa7c0432400fe2f93fb60d2e60f70f5f --- .../DictionaryFacilitatorForSuggest.java | 19 +++++++------------ .../latin/inputlogic/InputLogic.java | 8 +++++++- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/DictionaryFacilitatorForSuggest.java b/java/src/com/android/inputmethod/latin/DictionaryFacilitatorForSuggest.java index f733a9a6b..7e4f0e85c 100644 --- a/java/src/com/android/inputmethod/latin/DictionaryFacilitatorForSuggest.java +++ b/java/src/com/android/inputmethod/latin/DictionaryFacilitatorForSuggest.java @@ -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) { diff --git a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java index 55e92cc09..71b88703a 100644 --- a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java +++ b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java @@ -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,