Merge "Revise AOSP Android Keyboard launcher icon"
diff --git a/java/res/drawable/btn_keyboard_spacebar_gb.xml b/java/res/drawable/btn_keyboard_spacebar_gb.xml
new file mode 100644
index 0000000..4d51f3c
--- /dev/null
+++ b/java/res/drawable/btn_keyboard_spacebar_gb.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2013 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:state_pressed="true"
+          android:drawable="@drawable/btn_keyboard_key_light_pressed" />
+    <item android:drawable="@drawable/btn_keyboard_key_light_normal" />
+</selector>
diff --git a/java/res/drawable/btn_keyboard_spacebar_ics.xml b/java/res/drawable/btn_keyboard_spacebar_ics.xml
new file mode 100644
index 0000000..4530ea0
--- /dev/null
+++ b/java/res/drawable/btn_keyboard_spacebar_ics.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2013 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:state_pressed="true"
+          android:drawable="@drawable/btn_keyboard_key_light_pressed_ics" />
+    <item android:drawable="@drawable/btn_keyboard_key_light_normal_holo" />
+</selector>
diff --git a/java/res/drawable/btn_keyboard_spacebar_klp.xml b/java/res/drawable/btn_keyboard_spacebar_klp.xml
new file mode 100644
index 0000000..6b07a39
--- /dev/null
+++ b/java/res/drawable/btn_keyboard_spacebar_klp.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2013 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:state_pressed="true"
+          android:drawable="@drawable/btn_keyboard_key_light_pressed_klp" />
+    <item android:drawable="@drawable/btn_keyboard_key_light_normal_holo" />
+</selector>
diff --git a/java/res/values/attrs.xml b/java/res/values/attrs.xml
index 8191ffb..a9474a0 100644
--- a/java/res/values/attrs.xml
+++ b/java/res/values/attrs.xml
@@ -41,9 +41,9 @@
     </declare-styleable>
 
     <declare-styleable name="KeyboardView">
-        <!-- Image for the key. This image needs to be a StateListDrawable, with the following
-             possible states: normal, pressed, checkable, checkable+pressed, checkable+checked,
-             checkable+checked+pressed. -->
+        <!-- Image for the key. This image needs to be a {@link StateListDrawable}, with the
+             following possible states: normal, pressed, checkable, checkable+pressed,
+             checkable+checked, checkable+checked+pressed. -->
         <attr name="keyBackground" format="reference" />
         <!-- Image for the functional key used in Emoji layout. -->
         <attr name="keyBackgroundEmojiFunctional" format="reference" />
@@ -75,6 +75,8 @@
         <attr name="languageOnSpacebarTextRatio" format="fraction" />
         <attr name="languageOnSpacebarTextColor" format="color" />
         <attr name="languageOnSpacebarTextShadowColor" format="color" />
+        <!-- Background image for the spacebar. -->
+        <attr name="spacebarBackground" format="reference" />
         <!-- Fadeout animator for spacebar language label. -->
         <attr name="languageOnSpacebarFinalAlpha" format="integer" />
         <attr name="languageOnSpacebarFadeoutAnimator" format="reference" />
diff --git a/java/res/values/themes-gb.xml b/java/res/values/themes-gb.xml
index 78d47f9..52ecafd 100644
--- a/java/res/values/themes-gb.xml
+++ b/java/res/values/themes-gb.xml
@@ -93,6 +93,7 @@
         <item name="autoCorrectionSpacebarLedIcon">@drawable/sym_keyboard_space_led_gb</item>
         <item name="languageOnSpacebarTextColor">@color/spacebar_text_color_gb</item>
         <item name="languageOnSpacebarTextShadowColor">@color/spacebar_text_shadow_color_gb</item>
+        <item name="spacebarBackground">@drawable/btn_keyboard_spacebar_gb</item>
     </style>
     <style
         name="KeyPreviewTextView.GB"
diff --git a/java/res/values/themes-ics.xml b/java/res/values/themes-ics.xml
index db8dccb..125b640 100644
--- a/java/res/values/themes-ics.xml
+++ b/java/res/values/themes-ics.xml
@@ -72,6 +72,7 @@
         <item name="autoCorrectionSpacebarLedIcon">@drawable/sym_keyboard_space_led_holo</item>
         <item name="languageOnSpacebarTextColor">@color/spacebar_text_color_holo</item>
         <item name="languageOnSpacebarTextShadowColor">@color/spacebar_text_shadow_color_holo</item>
+        <item name="spacebarBackground">@drawable/btn_keyboard_spacebar_ics</item>
     </style>
     <style
         name="KeyPreviewTextView.ICS"
diff --git a/java/res/values/themes-klp.xml b/java/res/values/themes-klp.xml
index dd1f630..f6c0767 100644
--- a/java/res/values/themes-klp.xml
+++ b/java/res/values/themes-klp.xml
@@ -72,6 +72,7 @@
         <item name="autoCorrectionSpacebarLedIcon">@drawable/sym_keyboard_space_led_holo</item>
         <item name="languageOnSpacebarTextColor">@color/spacebar_text_color_holo</item>
         <item name="languageOnSpacebarTextShadowColor">@color/spacebar_text_shadow_color_holo</item>
+        <item name="spacebarBackground">@drawable/btn_keyboard_spacebar_klp</item>
     </style>
     <style
         name="KeyPreviewTextView.KLP"
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
index dcd9007..422bd12 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
@@ -319,7 +319,7 @@
         params.mAnimAlpha = Constants.Color.ALPHA_OPAQUE;
 
         if (!key.isSpacer()) {
-            onDrawKeyBackground(key, canvas);
+            onDrawKeyBackground(key, canvas, mKeyBackground);
         }
         onDrawKeyTopVisuals(key, canvas, paint, params);
 
@@ -327,14 +327,14 @@
     }
 
     // Draw key background.
-    protected void onDrawKeyBackground(final Key key, final Canvas canvas) {
+    protected void onDrawKeyBackground(final Key key, final Canvas canvas,
+            final Drawable background) {
         final Rect padding = mKeyBackgroundPadding;
         final int bgWidth = key.getDrawWidth() + padding.left + padding.right;
         final int bgHeight = key.getHeight() + padding.top + padding.bottom;
         final int bgX = -padding.left;
         final int bgY = -padding.top;
         final int[] drawableState = key.getCurrentDrawableState();
-        final Drawable background = mKeyBackground;
         background.setState(drawableState);
         final Rect bounds = background.getBounds();
         if (bgWidth != bounds.right || bgHeight != bounds.bottom) {
diff --git a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java
index b67d4e7..8b4986f 100644
--- a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java
@@ -84,6 +84,7 @@
  * @attr ref R.styleable#MainKeyboardView_languageOnSpacebarTextRatio
  * @attr ref R.styleable#MainKeyboardView_languageOnSpacebarTextColor
  * @attr ref R.styleable#MainKeyboardView_languageOnSpacebarTextShadowColor
+ * @attr ref R.styleable#MainKeyboardView_spacebarBackground
  * @attr ref R.styleable#MainKeyboardView_languageOnSpacebarFinalAlpha
  * @attr ref R.styleable#MainKeyboardView_languageOnSpacebarFadeoutAnimator
  * @attr ref R.styleable#MainKeyboardView_altCodeKeyWhileTypingFadeoutAnimator
@@ -124,9 +125,10 @@
     /** Listener for {@link KeyboardActionListener}. */
     private KeyboardActionListener mKeyboardActionListener;
 
-    /* Space key and its icons */
+    /* Space key and its icon and background. */
     private Key mSpaceKey;
-    private Drawable mSpaceIcon;
+    private Drawable mSpacebarIcon;
+    private final Drawable mSpacebarBackground;
     // Stuff to draw language name on spacebar.
     private final int mLanguageOnSpacebarFinalAlpha;
     private ObjectAnimator mLanguageOnSpacebarFadeoutAnimator;
@@ -244,6 +246,8 @@
                 R.styleable.MainKeyboardView_backgroundDimAlpha, 0);
         mBackgroundDimAlphaPaint.setColor(Color.BLACK);
         mBackgroundDimAlphaPaint.setAlpha(backgroundDimAlpha);
+        mSpacebarBackground = mainKeyboardViewAttr.getDrawable(
+                R.styleable.MainKeyboardView_spacebarBackground);
         mAutoCorrectionSpacebarLedEnabled = mainKeyboardViewAttr.getBoolean(
                 R.styleable.MainKeyboardView_autoCorrectionSpacebarLedEnabled, false);
         mAutoCorrectionSpacebarLedIcon = mainKeyboardViewAttr.getDrawable(
@@ -431,7 +435,7 @@
         mMoreKeysKeyboardCache.clear();
 
         mSpaceKey = keyboard.getKey(Constants.CODE_SPACE);
-        mSpaceIcon = (mSpaceKey != null)
+        mSpacebarIcon = (mSpaceKey != null)
                 ? mSpaceKey.getIcon(keyboard.mIconsSet, Constants.Color.ALPHA_OPAQUE) : null;
         final int keyHeight = keyboard.mMostCommonKeyHeight - keyboard.mVerticalGap;
         mLanguageOnSpacebarTextSize = keyHeight * mLanguageOnSpacebarTextRatio;
@@ -1103,6 +1107,17 @@
         }
     }
 
+    // Draw key background.
+    @Override
+    protected void onDrawKeyBackground(final Key key, final Canvas canvas,
+            final Drawable background) {
+        if (key.getCode() == Constants.CODE_SPACE) {
+            super.onDrawKeyBackground(key, canvas, mSpacebarBackground);
+            return;
+        }
+        super.onDrawKeyBackground(key, canvas, background);
+    }
+
     @Override
     protected void onDrawKeyTopVisuals(final Key key, final Canvas canvas, final Paint paint,
             final KeyDrawParams params) {
@@ -1201,12 +1216,12 @@
             int x = (width - iconWidth) / 2;
             int y = height - iconHeight;
             drawIcon(canvas, mAutoCorrectionSpacebarLedIcon, x, y, iconWidth, iconHeight);
-        } else if (mSpaceIcon != null) {
-            final int iconWidth = mSpaceIcon.getIntrinsicWidth();
-            final int iconHeight = mSpaceIcon.getIntrinsicHeight();
+        } else if (mSpacebarIcon != null) {
+            final int iconWidth = mSpacebarIcon.getIntrinsicWidth();
+            final int iconHeight = mSpacebarIcon.getIntrinsicHeight();
             int x = (width - iconWidth) / 2;
             int y = height - iconHeight;
-            drawIcon(canvas, mSpaceIcon, x, y, iconWidth, iconHeight);
+            drawIcon(canvas, mSpacebarIcon, x, y, iconWidth, iconHeight);
         }
     }
 
diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionary.java b/java/src/com/android/inputmethod/latin/BinaryDictionary.java
index 174bbfb..0e03b52 100644
--- a/java/src/com/android/inputmethod/latin/BinaryDictionary.java
+++ b/java/src/com/android/inputmethod/latin/BinaryDictionary.java
@@ -57,7 +57,7 @@
     @UsedForTesting
     public static final String MAX_BIGRAM_COUNT_QUERY = "MAX_BIGRAM_COUNT";
 
-    private static final int NOT_A_VALID_TIME_STAMP = -1;
+    public static final int NOT_A_VALID_TIME_STAMP = -1;
 
     private long mNativeDict;
     private final Locale mLocale;
@@ -138,9 +138,9 @@
     private static native int editDistanceNative(int[] before, int[] after);
     private static native void addUnigramWordNative(long dict, int[] word, int probability,
             int[] shortcutTarget, int shortcutProbability, boolean isNotAWord,
-            boolean isBlacklisted, int timeStamp);
+            boolean isBlacklisted, int timestamp);
     private static native void addBigramWordsNative(long dict, int[] word0, int[] word1,
-            int probability, int timeStamp);
+            int probability, int timestamp);
     private static native void removeBigramWordsNative(long dict, int[] word0, int[] word1);
     private static native int addMultipleDictionaryEntriesNative(long dict,
             LanguageModelParam[] languageModelParams, int startIndex);
@@ -291,12 +291,26 @@
             return;
         }
         final int[] codePoints = StringUtils.toCodePointArray(word);
-        final int[] shortcutTarget = new int[0];
-        addUnigramWordNative(mNativeDict, codePoints, probability, shortcutTarget,
+        final int[] shortcutTargetCodePoints = new int[0];
+        addUnigramWordNative(mNativeDict, codePoints, probability, shortcutTargetCodePoints,
                 NOT_A_PROBABILITY, false /* isNotAWord */, false /* isBlacklisted */,
                 NOT_A_VALID_TIME_STAMP);
     }
 
+    // Add a unigram entry to binary dictionary with unigram attributes in native code.
+    public void addUnigramWord(final String word, final int probability,
+            final String shortcutTarget, final int shortcutProbability, final boolean isNotAWord,
+            final boolean isBlacklisted, final int timestamp) {
+        if (TextUtils.isEmpty(word)) {
+            return;
+        }
+        final int[] codePoints = StringUtils.toCodePointArray(word);
+        final int[] shortcutTargetCodePoints = (shortcutTarget != null) ?
+                StringUtils.toCodePointArray(shortcutTarget) : null;
+        addUnigramWordNative(mNativeDict, codePoints, probability, shortcutTargetCodePoints,
+                shortcutProbability, isNotAWord, isBlacklisted, timestamp);
+    }
+
     // Add a bigram entry to binary dictionary in native code.
     public void addBigramWords(final String word0, final String word1, final int probability) {
         if (TextUtils.isEmpty(word0) || TextUtils.isEmpty(word1)) {
@@ -308,6 +322,17 @@
                 NOT_A_VALID_TIME_STAMP);
     }
 
+    // Add a bigram entry to binary dictionary with timestamp in native code.
+    public void addBigramWords(final String word0, final String word1, final int probability,
+            final int timestamp) {
+        if (TextUtils.isEmpty(word0) || TextUtils.isEmpty(word1)) {
+            return;
+        }
+        final int[] codePoints0 = StringUtils.toCodePointArray(word0);
+        final int[] codePoints1 = StringUtils.toCodePointArray(word1);
+        addBigramWordsNative(mNativeDict, codePoints0, codePoints1, probability, timestamp);
+    }
+
     // Remove a bigram entry form binary dictionary in native code.
     public void removeBigramWords(final String word0, final String word1) {
         if (TextUtils.isEmpty(word0) || TextUtils.isEmpty(word1)) {
@@ -327,10 +352,11 @@
         public final int mShortcutProbability;
         public final boolean mIsNotAWord;
         public final boolean mIsBlacklisted;
-        public final int mTimeStamp;
+        public final int mTimestamp;
 
         // Constructor for unigram.
-        public LanguageModelParam(final String word, final int unigramProbability) {
+        public LanguageModelParam(final String word, final int unigramProbability,
+                final int timestamp) {
             mWord0 = null;
             mWord1 = StringUtils.toCodePointArray(word);
             mShortcutTarget = null;
@@ -339,12 +365,13 @@
             mShortcutProbability = NOT_A_PROBABILITY;
             mIsNotAWord = false;
             mIsBlacklisted = false;
-            mTimeStamp = NOT_A_VALID_TIME_STAMP;
+            mTimestamp = timestamp;
         }
 
         // Constructor for unigram and bigram.
         public LanguageModelParam(final String word0, final String word1,
-                final int unigramProbability, final int bigramProbability) {
+                final int unigramProbability, final int bigramProbability,
+                final int timestamp) {
             mWord0 = StringUtils.toCodePointArray(word0);
             mWord1 = StringUtils.toCodePointArray(word1);
             mShortcutTarget = null;
@@ -353,7 +380,7 @@
             mShortcutProbability = NOT_A_PROBABILITY;
             mIsNotAWord = false;
             mIsBlacklisted = false;
-            mTimeStamp = NOT_A_VALID_TIME_STAMP;
+            mTimestamp = timestamp;
         }
     }
 
diff --git a/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java b/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java
index 154e9b5..f86517d 100644
--- a/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java
+++ b/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java
@@ -334,8 +334,9 @@
     /**
      * Dynamically adds a word unigram to the dictionary. May overwrite an existing entry.
      */
-    protected void addWordDynamically(final String word, final String shortcutTarget,
-            final int frequency, final int shortcutFreq, final boolean isNotAWord) {
+    protected void addWordDynamically(final String word, final int frequency,
+            final String shortcutTarget, final int shortcutFreq, final boolean isNotAWord,
+            final boolean isBlacklisted, final int timestamp) {
         if (!mIsUpdatable) {
             Log.w(TAG, "addWordDynamically is called for non-updatable dictionary: " + mFilename);
             return;
@@ -344,7 +345,8 @@
             @Override
             public void run() {
                 runGCIfRequiredInternalLocked(true /* mindsBlockByGC */);
-                mBinaryDictionary.addUnigramWord(word, frequency);
+                mBinaryDictionary.addUnigramWord(word, frequency, shortcutTarget, shortcutFreq,
+                        isNotAWord, isBlacklisted, timestamp);
             }
         });
     }
@@ -353,7 +355,7 @@
      * Dynamically adds a word bigram in the dictionary. May overwrite an existing entry.
      */
     protected void addBigramDynamically(final String word0, final String word1,
-            final int frequency) {
+            final int frequency, final int timestamp) {
         if (!mIsUpdatable) {
             Log.w(TAG, "addBigramDynamically is called for non-updatable dictionary: "
                     + mFilename);
@@ -363,7 +365,7 @@
             @Override
             public void run() {
                 runGCIfRequiredInternalLocked(true /* mindsBlockByGC */);
-                mBinaryDictionary.addBigramWords(word0, word1, frequency);
+                mBinaryDictionary.addBigramWords(word0, word1, frequency, timestamp);
             }
         });
     }
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 8ce1e38..b3e7116 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -109,6 +109,7 @@
 import java.util.ArrayList;
 import java.util.Locale;
 import java.util.TreeSet;
+import java.util.concurrent.TimeUnit;
 
 /**
  * Input method implementation for Qwerty'ish keyboard.
@@ -2871,7 +2872,8 @@
         final int maxFreq = AutoCorrectionUtils.getMaxFrequency(
                 suggest.getUnigramDictionaries(), suggestion);
         if (maxFreq == 0) return null;
-        userHistoryDictionary.addToDictionary(prevWord, secondWord, maxFreq > 0);
+        userHistoryDictionary.addToDictionary(prevWord, secondWord, maxFreq > 0,
+                (int)TimeUnit.MILLISECONDS.toSeconds((System.currentTimeMillis())));
         return prevWord;
     }
 
diff --git a/java/src/com/android/inputmethod/latin/personalization/DecayingExpandableBinaryDictionaryBase.java b/java/src/com/android/inputmethod/latin/personalization/DecayingExpandableBinaryDictionaryBase.java
index 8f26f84..f4b7d6e 100644
--- a/java/src/com/android/inputmethod/latin/personalization/DecayingExpandableBinaryDictionaryBase.java
+++ b/java/src/com/android/inputmethod/latin/personalization/DecayingExpandableBinaryDictionaryBase.java
@@ -141,21 +141,22 @@
      * context, as in beginning of a sentence for example.
      * The second word may not be null (a NullPointerException would be thrown).
      */
-    public void addToDictionary(final String word0, final String word1, final boolean isValid) {
+    public void addToDictionary(final String word0, final String word1, final boolean isValid,
+            final int timestamp) {
         if (word1.length() >= Constants.DICTIONARY_MAX_WORD_LENGTH ||
                 (word0 != null && word0.length() >= Constants.DICTIONARY_MAX_WORD_LENGTH)) {
             return;
         }
         final int frequency = isValid ?
                 FREQUENCY_FOR_WORDS_IN_DICTS : FREQUENCY_FOR_WORDS_NOT_IN_DICTS;
-        addWordDynamically(word1, null /* shortcutTarget */, frequency, 0 /* shortcutFreq */,
-                false /* isNotAWord */);
+        addWordDynamically(word1, frequency, null /* shortcutTarget */, 0 /* shortcutFreq */,
+                false /* isNotAWord */, false /* isBlacklisted */, timestamp);
         // Do not insert a word as a bigram of itself
         if (word1.equals(word0)) {
             return;
         }
         if (null != word0) {
-            addBigramDynamically(word0, word1, frequency);
+            addBigramDynamically(word0, word1, frequency, timestamp);
         }
     }
 
diff --git a/java/src/com/android/inputmethod/latin/personalization/PersonalizationDictionaryUpdateSession.java b/java/src/com/android/inputmethod/latin/personalization/PersonalizationDictionaryUpdateSession.java
index 2ab366b..c273023 100644
--- a/java/src/com/android/inputmethod/latin/personalization/PersonalizationDictionaryUpdateSession.java
+++ b/java/src/com/android/inputmethod/latin/personalization/PersonalizationDictionaryUpdateSession.java
@@ -90,12 +90,12 @@
 
     // TODO: Support multi locale to add bigram
     public void addBigramToPersonalizationDictionary(String word0, String word1, boolean isValid,
-            int frequency) {
+            int frequency, int timestamp) {
         final DecayingExpandableBinaryDictionaryBase dictionary = getPredictionDictionary();
         if (dictionary == null) {
             return;
         }
-        dictionary.addToDictionary(word0, word1, isValid);
+        dictionary.addToDictionary(word0, word1, isValid, timestamp);
     }
 
     // TODO: Support multi locale.
diff --git a/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp b/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp
index c6a5900..57c170f 100644
--- a/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp
+++ b/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp
@@ -284,7 +284,7 @@
 
 static void latinime_BinaryDictionary_addUnigramWord(JNIEnv *env, jclass clazz, jlong dict,
         jintArray word, jint probability, jintArray shortcutTarget, jint shortuctProbability,
-        jboolean isNotAWord, jboolean isBlacklisted, jint timeStamp) {
+        jboolean isNotAWord, jboolean isBlacklisted, jint timestamp) {
     Dictionary *dictionary = reinterpret_cast<Dictionary *>(dict);
     if (!dictionary) {
         return;
@@ -297,11 +297,11 @@
     if (shortcutTarget) {
         env->GetIntArrayRegion(shortcutTarget, 0, shortcutLength, shortcutTargetCodePoints);
     }
-    dictionary->addUnigramWord(codePoints, wordLength, probability, timeStamp);
+    dictionary->addUnigramWord(codePoints, wordLength, probability, timestamp);
 }
 
 static void latinime_BinaryDictionary_addBigramWords(JNIEnv *env, jclass clazz, jlong dict,
-        jintArray word0, jintArray word1, jint probability, jint timeStamp) {
+        jintArray word0, jintArray word1, jint probability, jint timestamp) {
     Dictionary *dictionary = reinterpret_cast<Dictionary *>(dict);
     if (!dictionary) {
         return;
@@ -313,7 +313,7 @@
     int word1CodePoints[word1Length];
     env->GetIntArrayRegion(word1, 0, word1Length, word1CodePoints);
     dictionary->addBigramWords(word0CodePoints, word0Length, word1CodePoints,
-            word1Length, probability, timeStamp);
+            word1Length, probability, timestamp);
 }
 
 static void latinime_BinaryDictionary_removeBigramWords(JNIEnv *env, jclass clazz, jlong dict,
@@ -355,8 +355,8 @@
             env->GetFieldID(languageModelParamClass, "mUnigramProbability", "I");
     jfieldID bigramProbabilityFieldId =
             env->GetFieldID(languageModelParamClass, "mBigramProbability", "I");
-    jfieldID timeStampFieldId =
-            env->GetFieldID(languageModelParamClass, "mTimeStamp", "I");
+    jfieldID timestampFieldId =
+            env->GetFieldID(languageModelParamClass, "mTimestamp", "I");
     env->DeleteLocalRef(languageModelParamClass);
 
     for (int i = startIndex; i < languageModelParamCount; ++i) {
@@ -377,12 +377,12 @@
         int word1CodePoints[word1Length];
         env->GetIntArrayRegion(word1, 0, word1Length, word1CodePoints);
         jint unigramProbability = env->GetIntField(languageModelParam, unigramProbabilityFieldId);
-        jint timeStamp = env->GetIntField(languageModelParam, timeStampFieldId);
-        dictionary->addUnigramWord(word1CodePoints, word1Length, unigramProbability, timeStamp);
+        jint timestamp = env->GetIntField(languageModelParam, timestampFieldId);
+        dictionary->addUnigramWord(word1CodePoints, word1Length, unigramProbability, timestamp);
         if (word0) {
             jint bigramProbability = env->GetIntField(languageModelParam, bigramProbabilityFieldId);
             dictionary->addBigramWords(word0CodePoints, word0Length, word1CodePoints, word1Length,
-                    bigramProbability, timeStamp);
+                    bigramProbability, timestamp);
         }
         if (dictionary->needsToRunGC(true /* mindsBlockByGC */)) {
             return i + 1;
diff --git a/tests/src/com/android/inputmethod/latin/BinaryDictionaryTests.java b/tests/src/com/android/inputmethod/latin/BinaryDictionaryTests.java
index 29f8241..8565db9 100644
--- a/tests/src/com/android/inputmethod/latin/BinaryDictionaryTests.java
+++ b/tests/src/com/android/inputmethod/latin/BinaryDictionaryTests.java
@@ -780,10 +780,11 @@
             final int bigramProbability = random.nextInt(0xF);
             unigramProbabilities.put(word, probability);
             if (prevWord == null) {
-                languageModelParams[i] = new LanguageModelParam(word, probability);
+                languageModelParams[i] = new LanguageModelParam(word, probability,
+                        BinaryDictionary.NOT_A_VALID_TIME_STAMP);
             } else {
                 languageModelParams[i] = new LanguageModelParam(prevWord, word, probability,
-                        bigramProbability);
+                        bigramProbability, BinaryDictionary.NOT_A_VALID_TIME_STAMP);
                 bigramProbabilities.put(new Pair<String, String>(prevWord, word),
                         bigramProbability);
             }
diff --git a/tests/src/com/android/inputmethod/latin/personalization/UserHistoryDictionaryTests.java b/tests/src/com/android/inputmethod/latin/personalization/UserHistoryDictionaryTests.java
index beac57b..717b04f 100644
--- a/tests/src/com/android/inputmethod/latin/personalization/UserHistoryDictionaryTests.java
+++ b/tests/src/com/android/inputmethod/latin/personalization/UserHistoryDictionaryTests.java
@@ -71,7 +71,8 @@
     private void addToDict(final UserHistoryDictionary dict, final List<String> words) {
         String prevWord = null;
         for (String word : words) {
-            dict.addToDictionary(prevWord, word, true);
+            // TODO: Use timestamp properly.
+            dict.addToDictionary(prevWord, word, true, 0 /* timestamp */);
             prevWord = word;
         }
     }