diff --git a/java/res/drawable/btn_keyboard_key_ics.xml b/java/res/drawable/btn_keyboard_key_ics.xml
index 9db0eee..af14cd5 100644
--- a/java/res/drawable/btn_keyboard_key_ics.xml
+++ b/java/res/drawable/btn_keyboard_key_ics.xml
@@ -15,12 +15,6 @@
 -->
 
 <selector xmlns:android="http://schemas.android.com/apk/res/android">
-    <!-- Functional keys. -->
-    <item android:state_single="true" android:state_pressed="true"
-          android:drawable="@drawable/btn_keyboard_key_dark_pressed_ics" />
-    <item android:state_single="true"
-          android:drawable="@drawable/btn_keyboard_key_dark_normal_holo" />
-
     <!-- Action keys. -->
     <item android:state_active="true" android:state_pressed="true"
           android:drawable="@drawable/btn_keyboard_key_dark_pressed_ics" />
diff --git a/java/res/drawable/btn_keyboard_key_klp.xml b/java/res/drawable/btn_keyboard_key_klp.xml
index 500e3ea..56c295f 100644
--- a/java/res/drawable/btn_keyboard_key_klp.xml
+++ b/java/res/drawable/btn_keyboard_key_klp.xml
@@ -15,12 +15,6 @@
 -->
 
 <selector xmlns:android="http://schemas.android.com/apk/res/android">
-    <!-- Functional keys. -->
-    <item android:state_single="true" android:state_pressed="true"
-          android:drawable="@drawable/btn_keyboard_key_dark_pressed_klp" />
-    <item android:state_single="true"
-          android:drawable="@drawable/btn_keyboard_key_dark_normal_holo" />
-
     <!-- Action keys. -->
     <item android:state_active="true" android:state_pressed="true"
           android:drawable="@drawable/btn_keyboard_key_dark_pressed_klp" />
diff --git a/java/res/drawable/btn_keyboard_key_lmp.xml b/java/res/drawable/btn_keyboard_key_lmp.xml
index 4aaafb5..636b637 100644
--- a/java/res/drawable/btn_keyboard_key_lmp.xml
+++ b/java/res/drawable/btn_keyboard_key_lmp.xml
@@ -15,12 +15,6 @@
 -->
 
 <selector xmlns:android="http://schemas.android.com/apk/res/android">
-    <!-- Functional keys. -->
-    <item android:state_single="true" android:state_pressed="true"
-          android:drawable="@color/key_background_pressed_lmp" />
-    <item android:state_single="true"
-          android:drawable="@color/key_background_lmp" />
-
     <!-- Action keys. -->
     <item android:state_active="true" android:state_pressed="true"
           android:drawable="@color/key_background_pressed_lmp" />
diff --git a/java/res/values/attrs.xml b/java/res/values/attrs.xml
index 769a1d9..79cc139 100644
--- a/java/res/values/attrs.xml
+++ b/java/res/values/attrs.xml
@@ -41,13 +41,16 @@
     </declare-styleable>
 
     <declare-styleable name="KeyboardView">
-        <!-- Image for the key. This image needs to be a {@link StateListDrawable}, with the
-             following possible states: normal, pressed, checkable, checkable+pressed,
+        <!-- Background 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" />
-
+        <!-- Background image for the functional key. This image needs to be a
+             {@link StateListDrawable}, with the following possible states: normal, pressed. -->
+        <attr name="functionalKeyBackground" format="reference" />
+        <!-- Background image for the spacebar.  This image needs to be a
+             {@link StateListDrawable}, with the following possible states: normal, pressed. -->
+        <attr name="spacebarBackground" format="reference" />
         <!-- Horizontal padding of left/right aligned key label to the edge of the key. -->
         <attr name="keyLabelHorizontalPadding" format="dimension" />
         <!-- Right padding of hint letter to the edge of the key.-->
@@ -76,8 +79,6 @@
         <attr name="languageOnSpacebarTextColor" format="color" />
         <attr name="languageOnSpacebarTextShadowRadius" format="float" />
         <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-common.xml b/java/res/values/themes-common.xml
index 76abb10..df26fb3 100644
--- a/java/res/values/themes-common.xml
+++ b/java/res/values/themes-common.xml
@@ -109,12 +109,7 @@
     <style name="KeyPreviewTextView" />
     <!-- Though {@link EmojiPalettesView} doesn't extend {@link KeyboardView}, some views inside it,
          for instance delete button, need themed {@link KeyboardView} attributes. -->
-    <style
-        name="EmojiPalettesView"
-        parent="KeyboardView"
-    >
-        <item name="emojiTabLabelColor">@color/emoji_tab_label_color_holo</item>
-    </style>
+    <style name="EmojiPalettesView" />
     <style name="MoreKeysKeyboard" />
     <style
         name="MoreKeysKeyboardView"
diff --git a/java/res/values/themes-ics.xml b/java/res/values/themes-ics.xml
index d7943ee..560cfc5 100644
--- a/java/res/values/themes-ics.xml
+++ b/java/res/values/themes-ics.xml
@@ -48,6 +48,8 @@
     >
         <item name="android:background">@drawable/keyboard_background_holo</item>
         <item name="keyBackground">@drawable/btn_keyboard_key_ics</item>
+        <item name="functionalKeyBackground">@drawable/btn_keyboard_key_functional_ics</item>
+        <item name="spacebarBackground">@drawable/btn_keyboard_spacebar_ics</item>
         <item name="keyTypeface">bold</item>
         <item name="keyTextColor">@color/key_text_color_holo</item>
         <item name="keyTextInactivatedColor">@color/key_text_inactivated_color_holo</item>
@@ -73,7 +75,6 @@
         <item name="languageOnSpacebarTextColor">@color/spacebar_text_color_holo</item>
         <item name="languageOnSpacebarTextShadowRadius">1.0</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"
@@ -85,9 +86,8 @@
          for instance delete button, need themed {@link KeyboardView} attributes. -->
     <style
         name="EmojiPalettesView.ICS"
-        parent="KeyboardView.ICS"
+        parent="MainKeyboardView.ICS"
     >
-        <item name="keyBackgroundEmojiFunctional">@drawable/btn_keyboard_key_functional_ics</item>
         <item name="emojiTabLabelColor">@color/emoji_tab_label_color_holo</item>
     </style>
     <style
diff --git a/java/res/values/themes-klp.xml b/java/res/values/themes-klp.xml
index 13500fe..453e5cb 100644
--- a/java/res/values/themes-klp.xml
+++ b/java/res/values/themes-klp.xml
@@ -48,6 +48,8 @@
     >
         <item name="android:background">@drawable/keyboard_background_holo</item>
         <item name="keyBackground">@drawable/btn_keyboard_key_klp</item>
+        <item name="functionalKeyBackground">@drawable/btn_keyboard_key_functional_klp</item>
+        <item name="spacebarBackground">@drawable/btn_keyboard_spacebar_klp</item>
         <item name="keyTypeface">bold</item>
         <item name="keyTextColor">@color/key_text_color_holo</item>
         <item name="keyTextInactivatedColor">@color/key_text_inactivated_color_holo</item>
@@ -73,7 +75,6 @@
         <item name="languageOnSpacebarTextColor">@color/spacebar_text_color_holo</item>
         <item name="languageOnSpacebarTextShadowRadius">1.0</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"
@@ -85,9 +86,8 @@
          for instance delete button, need themed {@link KeyboardView} attributes. -->
     <style
         name="EmojiPalettesView.KLP"
-        parent="KeyboardView.KLP"
+        parent="MainKeyboardView.KLP"
     >
-        <item name="keyBackgroundEmojiFunctional">@drawable/btn_keyboard_key_functional_klp</item>
         <item name="emojiTabLabelColor">@color/emoji_tab_label_color_holo</item>
     </style>
     <style
diff --git a/java/res/values/themes-lmp.xml b/java/res/values/themes-lmp.xml
index c05190b..a9b8a93 100644
--- a/java/res/values/themes-lmp.xml
+++ b/java/res/values/themes-lmp.xml
@@ -48,6 +48,8 @@
     >
         <item name="android:background">@color/keyboard_background_lmp</item>
         <item name="keyBackground">@drawable/btn_keyboard_key_lmp</item>
+        <item name="functionalKeyBackground">@drawable/btn_keyboard_key_functional_lmp</item>
+        <item name="spacebarBackground">@drawable/btn_keyboard_spacebar_lmp</item>
         <item name="keyTypeface">bold</item>
         <item name="keyTextColor">@color/key_text_color_holo</item>
         <item name="keyTextInactivatedColor">@color/key_text_inactive_color_lmp</item>
@@ -73,7 +75,6 @@
         <item name="languageOnSpacebarTextColor">@color/key_text_inactive_color_lmp</item>
         <!-- A negative value to disable text shadow layer. -->
         <item name="languageOnSpacebarTextShadowRadius">-1.0</item>
-        <item name="spacebarBackground">@drawable/btn_keyboard_spacebar_lmp</item>
     </style>
     <style
         name="KeyPreviewTextView.LMP"
@@ -85,9 +86,8 @@
          for instance delete button, need themed {@link KeyboardView} attributes. -->
     <style
         name="EmojiPalettesView.LMP"
-        parent="KeyboardView.LMP"
+        parent="MainKeyboardView.LMP"
     >
-        <item name="keyBackgroundEmojiFunctional">@drawable/btn_keyboard_key_functional_lmp</item>
         <item name="emojiTabLabelColor">@color/emoji_tab_label_color_holo</item>
     </style>
     <style
diff --git a/java/src/com/android/inputmethod/event/MyanmarReordering.java b/java/src/com/android/inputmethod/event/MyanmarReordering.java
index 27b8c14..da0228b 100644
--- a/java/src/com/android/inputmethod/event/MyanmarReordering.java
+++ b/java/src/com/android/inputmethod/event/MyanmarReordering.java
@@ -207,9 +207,33 @@
                 return clearAndGetResultingEvent(newEvent);
             }
         } else if (Constants.CODE_DELETE == newEvent.mKeyCode) {
-            if (mCurrentEvents.size() > 0) {
-                mCurrentEvents.remove(mCurrentEvents.size() - 1);
-                return null;
+            final Event lastEvent = getLastEvent();
+            final int eventSize = mCurrentEvents.size();
+            if (null != lastEvent) {
+                if (VOWEL_E == lastEvent.mCodePoint) {
+                    // We have a VOWEL_E at the end. There are four cases.
+                    // - The vowel is the only code point in the buffer. Remove it.
+                    // - The vowel is preceded by a ZWNJ. Remove both vowel E and ZWNJ.
+                    // - The vowel is preceded by a consonant/medial, remove the consonant/medial.
+                    // - In all other cases, it's strange, so just remove the last code point.
+                    if (eventSize <= 1) {
+                        mCurrentEvents.clear();
+                    } else { // eventSize >= 2
+                        final int previousCodePoint = mCurrentEvents.get(eventSize - 2).mCodePoint;
+                        if (previousCodePoint == ZERO_WIDTH_NON_JOINER) {
+                            mCurrentEvents.remove(eventSize - 1);
+                            mCurrentEvents.remove(eventSize - 2);
+                        } else if (isConsonantOrMedial(previousCodePoint)) {
+                            mCurrentEvents.remove(eventSize - 2);
+                        } else {
+                            mCurrentEvents.remove(eventSize - 1);
+                        }
+                    }
+                    return null;
+                } else if (eventSize > 0) {
+                    mCurrentEvents.remove(eventSize - 1);
+                    return null;
+                }
             }
         }
         // This character is not part of the combining scheme, so we should reset everything.
diff --git a/java/src/com/android/inputmethod/keyboard/EmojiCategoryPageIndicatorView.java b/java/src/com/android/inputmethod/keyboard/EmojiCategoryPageIndicatorView.java
index 4ef9e22..9922f90 100644
--- a/java/src/com/android/inputmethod/keyboard/EmojiCategoryPageIndicatorView.java
+++ b/java/src/com/android/inputmethod/keyboard/EmojiCategoryPageIndicatorView.java
@@ -24,7 +24,8 @@
 import android.util.AttributeSet;
 import android.widget.LinearLayout;
 
-public class EmojiCategoryPageIndicatorView extends LinearLayout {
+//TODO: Move this class to com.android.inputmethod.emoji package.
+public final class EmojiCategoryPageIndicatorView extends LinearLayout {
     private static final float BOTTOM_MARGIN_RATIO = 1.0f;
     private final Paint mPaint = new Paint();
     private int mCategoryPageSize = 0;
diff --git a/java/src/com/android/inputmethod/keyboard/EmojiPalettesView.java b/java/src/com/android/inputmethod/keyboard/EmojiPalettesView.java
index d8b5758..2012d34 100644
--- a/java/src/com/android/inputmethod/keyboard/EmojiPalettesView.java
+++ b/java/src/com/android/inputmethod/keyboard/EmojiPalettesView.java
@@ -19,50 +19,37 @@
 import static com.android.inputmethod.latin.Constants.NOT_A_COORDINATE;
 
 import android.content.Context;
-import android.content.SharedPreferences;
 import android.content.res.ColorStateList;
 import android.content.res.Resources;
 import android.content.res.TypedArray;
 import android.graphics.Color;
-import android.graphics.Rect;
-import android.os.Build;
+import android.graphics.Typeface;
 import android.os.CountDownTimer;
 import android.preference.PreferenceManager;
-import android.support.v4.view.PagerAdapter;
 import android.support.v4.view.ViewPager;
 import android.util.AttributeSet;
-import android.util.Log;
 import android.util.Pair;
-import android.util.SparseArray;
 import android.util.TypedValue;
 import android.view.LayoutInflater;
 import android.view.MotionEvent;
 import android.view.View;
-import android.view.ViewGroup;
 import android.widget.ImageView;
 import android.widget.LinearLayout;
 import android.widget.TabHost;
 import android.widget.TabHost.OnTabChangeListener;
 import android.widget.TextView;
 
-import com.android.inputmethod.keyboard.internal.DynamicGridKeyboard;
+import com.android.inputmethod.keyboard.internal.EmojiCategory;
 import com.android.inputmethod.keyboard.internal.EmojiLayoutParams;
 import com.android.inputmethod.keyboard.internal.EmojiPageKeyboardView;
+import com.android.inputmethod.keyboard.internal.EmojiPalettesAdapter;
 import com.android.inputmethod.keyboard.internal.KeyDrawParams;
 import com.android.inputmethod.keyboard.internal.KeyVisualAttributes;
 import com.android.inputmethod.latin.Constants;
 import com.android.inputmethod.latin.R;
 import com.android.inputmethod.latin.SubtypeSwitcher;
-import com.android.inputmethod.latin.settings.Settings;
-import com.android.inputmethod.latin.utils.CollectionUtils;
 import com.android.inputmethod.latin.utils.ResourceUtils;
 
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.TimeUnit;
 
 /**
@@ -76,13 +63,12 @@
  * </ol>
  * Because of the above reasons, this class doesn't extend {@link KeyboardView}.
  */
+// TODO: Move this class to com.android.inputmethod.emoji package.
 public final class EmojiPalettesView extends LinearLayout implements OnTabChangeListener,
         ViewPager.OnPageChangeListener, View.OnClickListener, View.OnTouchListener,
         EmojiPageKeyboardView.OnKeyEventListener {
-    static final String TAG = EmojiPalettesView.class.getSimpleName();
-    private static final boolean DEBUG_PAGER = false;
-    private final int mKeyBackgroundId;
-    private final int mEmojiFunctionalKeyBackgroundId;
+    private final int mFunctionalKeyBackgroundId;
+    private final int mSpacebarBackgroundId;
     private final ColorStateList mTabLabelColor;
     private final DeleteKeyOnTouchListener mDeleteKeyOnTouchListener;
     private EmojiPalettesAdapter mEmojiPalettesAdapter;
@@ -97,317 +83,6 @@
 
     private KeyboardActionListener mKeyboardActionListener = KeyboardActionListener.EMPTY_LISTENER;
 
-    private static final int CATEGORY_ID_UNSPECIFIED = -1;
-    public static final int CATEGORY_ID_RECENTS = 0;
-    public static final int CATEGORY_ID_PEOPLE = 1;
-    public static final int CATEGORY_ID_OBJECTS = 2;
-    public static final int CATEGORY_ID_NATURE = 3;
-    public static final int CATEGORY_ID_PLACES = 4;
-    public static final int CATEGORY_ID_SYMBOLS = 5;
-    public static final int CATEGORY_ID_EMOTICONS = 6;
-
-    private static class CategoryProperties {
-        public int mCategoryId;
-        public int mPageCount;
-        public CategoryProperties(final int categoryId, final int pageCount) {
-            mCategoryId = categoryId;
-            mPageCount = pageCount;
-        }
-    }
-
-    private static class EmojiCategory {
-        private static final String[] sCategoryName = {
-                "recents",
-                "people",
-                "objects",
-                "nature",
-                "places",
-                "symbols",
-                "emoticons" };
-        private static final int[] sCategoryIcon = {
-                R.drawable.ic_emoji_recent_light,
-                R.drawable.ic_emoji_people_light,
-                R.drawable.ic_emoji_objects_light,
-                R.drawable.ic_emoji_nature_light,
-                R.drawable.ic_emoji_places_light,
-                R.drawable.ic_emoji_symbols_light,
-                0 };
-        private static final String[] sCategoryLabel =
-                { null, null, null, null, null, null, ":-)" };
-        private static final int[] sAccessibilityDescriptionResourceIdsForCategories = {
-                R.string.spoken_descrption_emoji_category_recents,
-                R.string.spoken_descrption_emoji_category_people,
-                R.string.spoken_descrption_emoji_category_objects,
-                R.string.spoken_descrption_emoji_category_nature,
-                R.string.spoken_descrption_emoji_category_places,
-                R.string.spoken_descrption_emoji_category_symbols,
-                R.string.spoken_descrption_emoji_category_emoticons };
-        private static final int[] sCategoryElementId = {
-                KeyboardId.ELEMENT_EMOJI_RECENTS,
-                KeyboardId.ELEMENT_EMOJI_CATEGORY1,
-                KeyboardId.ELEMENT_EMOJI_CATEGORY2,
-                KeyboardId.ELEMENT_EMOJI_CATEGORY3,
-                KeyboardId.ELEMENT_EMOJI_CATEGORY4,
-                KeyboardId.ELEMENT_EMOJI_CATEGORY5,
-                KeyboardId.ELEMENT_EMOJI_CATEGORY6 };
-        private final SharedPreferences mPrefs;
-        private final Resources mRes;
-        private final int mMaxPageKeyCount;
-        private final KeyboardLayoutSet mLayoutSet;
-        private final HashMap<String, Integer> mCategoryNameToIdMap = CollectionUtils.newHashMap();
-        private final ArrayList<CategoryProperties> mShownCategories =
-                CollectionUtils.newArrayList();
-        private final ConcurrentHashMap<Long, DynamicGridKeyboard>
-                mCategoryKeyboardMap = new ConcurrentHashMap<Long, DynamicGridKeyboard>();
-
-        private int mCurrentCategoryId = CATEGORY_ID_UNSPECIFIED;
-        private int mCurrentCategoryPageId = 0;
-
-        public EmojiCategory(final SharedPreferences prefs, final Resources res,
-                final KeyboardLayoutSet layoutSet) {
-            mPrefs = prefs;
-            mRes = res;
-            mMaxPageKeyCount = res.getInteger(R.integer.config_emoji_keyboard_max_page_key_count);
-            mLayoutSet = layoutSet;
-            for (int i = 0; i < sCategoryName.length; ++i) {
-                mCategoryNameToIdMap.put(sCategoryName[i], i);
-            }
-            addShownCategoryId(CATEGORY_ID_RECENTS);
-            if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR2
-                    || android.os.Build.VERSION.CODENAME.equalsIgnoreCase("KeyLimePie")
-                    || android.os.Build.VERSION.CODENAME.equalsIgnoreCase("KitKat")) {
-                addShownCategoryId(CATEGORY_ID_PEOPLE);
-                addShownCategoryId(CATEGORY_ID_OBJECTS);
-                addShownCategoryId(CATEGORY_ID_NATURE);
-                addShownCategoryId(CATEGORY_ID_PLACES);
-                mCurrentCategoryId =
-                        Settings.readLastShownEmojiCategoryId(mPrefs, CATEGORY_ID_PEOPLE);
-            } else {
-                mCurrentCategoryId =
-                        Settings.readLastShownEmojiCategoryId(mPrefs, CATEGORY_ID_SYMBOLS);
-            }
-            addShownCategoryId(CATEGORY_ID_SYMBOLS);
-            addShownCategoryId(CATEGORY_ID_EMOTICONS);
-            getKeyboard(CATEGORY_ID_RECENTS, 0 /* cagetoryPageId */)
-                    .loadRecentKeys(mCategoryKeyboardMap.values());
-        }
-
-        private void addShownCategoryId(final int categoryId) {
-            // Load a keyboard of categoryId
-            getKeyboard(categoryId, 0 /* cagetoryPageId */);
-            final CategoryProperties properties =
-                    new CategoryProperties(categoryId, getCategoryPageCount(categoryId));
-            mShownCategories.add(properties);
-        }
-
-        public String getCategoryName(final int categoryId, final int categoryPageId) {
-            return sCategoryName[categoryId] + "-" + categoryPageId;
-        }
-
-        public int getCategoryId(final String name) {
-            final String[] strings = name.split("-");
-            return mCategoryNameToIdMap.get(strings[0]);
-        }
-
-        public int getCategoryIcon(final int categoryId) {
-            return sCategoryIcon[categoryId];
-        }
-
-        public String getCategoryLabel(final int categoryId) {
-            return sCategoryLabel[categoryId];
-        }
-
-        public String getAccessibilityDescription(final int categoryId) {
-            return mRes.getString(sAccessibilityDescriptionResourceIdsForCategories[categoryId]);
-        }
-
-        public ArrayList<CategoryProperties> getShownCategories() {
-            return mShownCategories;
-        }
-
-        public int getCurrentCategoryId() {
-            return mCurrentCategoryId;
-        }
-
-        public int getCurrentCategoryPageSize() {
-            return getCategoryPageSize(mCurrentCategoryId);
-        }
-
-        public int getCategoryPageSize(final int categoryId) {
-            for (final CategoryProperties prop : mShownCategories) {
-                if (prop.mCategoryId == categoryId) {
-                    return prop.mPageCount;
-                }
-            }
-            Log.w(TAG, "Invalid category id: " + categoryId);
-            // Should not reach here.
-            return 0;
-        }
-
-        public void setCurrentCategoryId(final int categoryId) {
-            mCurrentCategoryId = categoryId;
-            Settings.writeLastShownEmojiCategoryId(mPrefs, categoryId);
-        }
-
-        public void setCurrentCategoryPageId(final int id) {
-            mCurrentCategoryPageId = id;
-        }
-
-        public int getCurrentCategoryPageId() {
-            return mCurrentCategoryPageId;
-        }
-
-        public void saveLastTypedCategoryPage() {
-            Settings.writeLastTypedEmojiCategoryPageId(
-                    mPrefs, mCurrentCategoryId, mCurrentCategoryPageId);
-        }
-
-        public boolean isInRecentTab() {
-            return mCurrentCategoryId == CATEGORY_ID_RECENTS;
-        }
-
-        public int getTabIdFromCategoryId(final int categoryId) {
-            for (int i = 0; i < mShownCategories.size(); ++i) {
-                if (mShownCategories.get(i).mCategoryId == categoryId) {
-                    return i;
-                }
-            }
-            Log.w(TAG, "categoryId not found: " + categoryId);
-            return 0;
-        }
-
-        // Returns the view pager's page position for the categoryId
-        public int getPageIdFromCategoryId(final int categoryId) {
-            final int lastSavedCategoryPageId =
-                    Settings.readLastTypedEmojiCategoryPageId(mPrefs, categoryId);
-            int sum = 0;
-            for (int i = 0; i < mShownCategories.size(); ++i) {
-                final CategoryProperties props = mShownCategories.get(i);
-                if (props.mCategoryId == categoryId) {
-                    return sum + lastSavedCategoryPageId;
-                }
-                sum += props.mPageCount;
-            }
-            Log.w(TAG, "categoryId not found: " + categoryId);
-            return 0;
-        }
-
-        public int getRecentTabId() {
-            return getTabIdFromCategoryId(CATEGORY_ID_RECENTS);
-        }
-
-        private int getCategoryPageCount(final int categoryId) {
-            final Keyboard keyboard = mLayoutSet.getKeyboard(sCategoryElementId[categoryId]);
-            return (keyboard.getSortedKeys().size() - 1) / mMaxPageKeyCount + 1;
-        }
-
-        // Returns a pair of the category id and the category page id from the view pager's page
-        // position. The category page id is numbered in each category. And the view page position
-        // is the position of the current shown page in the view pager which contains all pages of
-        // all categories.
-        public Pair<Integer, Integer> getCategoryIdAndPageIdFromPagePosition(final int position) {
-            int sum = 0;
-            for (final CategoryProperties properties : mShownCategories) {
-                final int temp = sum;
-                sum += properties.mPageCount;
-                if (sum > position) {
-                    return new Pair<Integer, Integer>(properties.mCategoryId, position - temp);
-                }
-            }
-            return null;
-        }
-
-        // Returns a keyboard from the view pager's page position.
-        public DynamicGridKeyboard getKeyboardFromPagePosition(final int position) {
-            final Pair<Integer, Integer> categoryAndId =
-                    getCategoryIdAndPageIdFromPagePosition(position);
-            if (categoryAndId != null) {
-                return getKeyboard(categoryAndId.first, categoryAndId.second);
-            }
-            return null;
-        }
-
-        private static final Long getCategoryKeyboardMapKey(final int categoryId, final int id) {
-            return (((long) categoryId) << Constants.MAX_INT_BIT_COUNT) | id;
-        }
-
-        public DynamicGridKeyboard getKeyboard(final int categoryId, final int id) {
-            synchronized (mCategoryKeyboardMap) {
-                final Long categotyKeyboardMapKey = getCategoryKeyboardMapKey(categoryId, id);
-                if (mCategoryKeyboardMap.containsKey(categotyKeyboardMapKey)) {
-                    return mCategoryKeyboardMap.get(categotyKeyboardMapKey);
-                }
-
-                if (categoryId == CATEGORY_ID_RECENTS) {
-                    final DynamicGridKeyboard kbd = new DynamicGridKeyboard(mPrefs,
-                            mLayoutSet.getKeyboard(KeyboardId.ELEMENT_EMOJI_RECENTS),
-                            mMaxPageKeyCount, categoryId);
-                    mCategoryKeyboardMap.put(categotyKeyboardMapKey, kbd);
-                    return kbd;
-                }
-
-                final Keyboard keyboard = mLayoutSet.getKeyboard(sCategoryElementId[categoryId]);
-                final Key[][] sortedKeys = sortKeysIntoPages(
-                        keyboard.getSortedKeys(), mMaxPageKeyCount);
-                for (int pageId = 0; pageId < sortedKeys.length; ++pageId) {
-                    final DynamicGridKeyboard tempKeyboard = new DynamicGridKeyboard(mPrefs,
-                            mLayoutSet.getKeyboard(KeyboardId.ELEMENT_EMOJI_RECENTS),
-                            mMaxPageKeyCount, categoryId);
-                    for (final Key emojiKey : sortedKeys[pageId]) {
-                        if (emojiKey == null) {
-                            break;
-                        }
-                        tempKeyboard.addKeyLast(emojiKey);
-                    }
-                    mCategoryKeyboardMap.put(
-                            getCategoryKeyboardMapKey(categoryId, pageId), tempKeyboard);
-                }
-                return mCategoryKeyboardMap.get(categotyKeyboardMapKey);
-            }
-        }
-
-        public int getTotalPageCountOfAllCategories() {
-            int sum = 0;
-            for (CategoryProperties properties : mShownCategories) {
-                sum += properties.mPageCount;
-            }
-            return sum;
-        }
-
-        private static Comparator<Key> EMOJI_KEY_COMPARATOR = new Comparator<Key>() {
-            @Override
-            public int compare(final Key lhs, final Key rhs) {
-                final Rect lHitBox = lhs.getHitBox();
-                final Rect rHitBox = rhs.getHitBox();
-                if (lHitBox.top < rHitBox.top) {
-                    return -1;
-                } else if (lHitBox.top > rHitBox.top) {
-                    return 1;
-                }
-                if (lHitBox.left < rHitBox.left) {
-                    return -1;
-                } else if (lHitBox.left > rHitBox.left) {
-                    return 1;
-                }
-                if (lhs.getCode() == rhs.getCode()) {
-                    return 0;
-                }
-                return lhs.getCode() < rhs.getCode() ? -1 : 1;
-            }
-        };
-
-        private static Key[][] sortKeysIntoPages(final List<Key> inKeys, final int maxPageCount) {
-            final ArrayList<Key> keys = CollectionUtils.newArrayList(inKeys);
-            Collections.sort(keys, EMOJI_KEY_COMPARATOR);
-            final int pageCount = (keys.size() - 1) / maxPageCount + 1;
-            final Key[][] retval = new Key[pageCount][maxPageCount];
-            for (int i = 0; i < keys.size(); ++i) {
-                retval[i / maxPageCount][i % maxPageCount] = keys.get(i);
-            }
-            return retval;
-        }
-    }
-
     private final EmojiCategory mEmojiCategory;
 
     public EmojiPalettesView(final Context context, final AttributeSet attrs) {
@@ -418,10 +93,12 @@
         super(context, attrs, defStyle);
         final TypedArray keyboardViewAttr = context.obtainStyledAttributes(attrs,
                 R.styleable.KeyboardView, defStyle, R.style.KeyboardView);
-        mKeyBackgroundId = keyboardViewAttr.getResourceId(
+        final int keyBackgroundId = keyboardViewAttr.getResourceId(
                 R.styleable.KeyboardView_keyBackground, 0);
-        mEmojiFunctionalKeyBackgroundId = keyboardViewAttr.getResourceId(
-                R.styleable.KeyboardView_keyBackgroundEmojiFunctional, 0);
+        mFunctionalKeyBackgroundId = keyboardViewAttr.getResourceId(
+                R.styleable.KeyboardView_functionalKeyBackground, keyBackgroundId);
+        mSpacebarBackgroundId = keyboardViewAttr.getResourceId(
+                R.styleable.KeyboardView_spacebarBackground, keyBackgroundId);
         keyboardViewAttr.recycle();
         final TypedArray emojiPalettesViewAttr = context.obtainStyledAttributes(attrs,
                 R.styleable.EmojiPalettesView, defStyle, R.style.EmojiPalettesView);
@@ -481,7 +158,8 @@
     protected void onFinishInflate() {
         mTabHost = (TabHost)findViewById(R.id.emoji_category_tabhost);
         mTabHost.setup();
-        for (final CategoryProperties properties : mEmojiCategory.getShownCategories()) {
+        for (final EmojiCategory.CategoryProperties properties
+                : mEmojiCategory.getShownCategories()) {
             addTab(mTabHost, properties.mCategoryId);
         }
         mTabHost.setOnTabChangedListener(this);
@@ -507,6 +185,7 @@
 
         // deleteKey depends only on OnTouchListener.
         final ImageView deleteKey = (ImageView)findViewById(R.id.emoji_keyboard_delete);
+        deleteKey.setBackgroundResource(mFunctionalKeyBackgroundId);
         deleteKey.setTag(Constants.CODE_DELETE);
         deleteKey.setOnTouchListener(mDeleteKeyOnTouchListener);
 
@@ -518,17 +197,17 @@
         // The text on alphabet keys are set at
         // {@link #startEmojiPalettes(String,int,float,Typeface)}.
         mAlphabetKeyLeft = (TextView)findViewById(R.id.emoji_keyboard_alphabet_left);
-        mAlphabetKeyLeft.setBackgroundResource(mEmojiFunctionalKeyBackgroundId);
+        mAlphabetKeyLeft.setBackgroundResource(mFunctionalKeyBackgroundId);
         mAlphabetKeyLeft.setTag(Constants.CODE_ALPHA_FROM_EMOJI);
         mAlphabetKeyLeft.setOnTouchListener(this);
         mAlphabetKeyLeft.setOnClickListener(this);
         mAlphabetKeyRight = (TextView)findViewById(R.id.emoji_keyboard_alphabet_right);
-        mAlphabetKeyRight.setBackgroundResource(mEmojiFunctionalKeyBackgroundId);
+        mAlphabetKeyRight.setBackgroundResource(mFunctionalKeyBackgroundId);
         mAlphabetKeyRight.setTag(Constants.CODE_ALPHA_FROM_EMOJI);
         mAlphabetKeyRight.setOnTouchListener(this);
         mAlphabetKeyRight.setOnClickListener(this);
         final ImageView spaceKey = (ImageView)findViewById(R.id.emoji_keyboard_space);
-        spaceKey.setBackgroundResource(mKeyBackgroundId);
+        spaceKey.setBackgroundResource(mSpacebarBackgroundId);
         spaceKey.setTag(Constants.CODE_SPACE);
         spaceKey.setOnTouchListener(this);
         spaceKey.setOnClickListener(this);
@@ -675,9 +354,6 @@
 
     public void startEmojiPalettes(final String switchToAlphaLabel,
             final KeyVisualAttributes keyVisualAttr) {
-        if (DEBUG_PAGER) {
-            Log.d(TAG, "allocate emoji palettes memory " + mCurrentPagerPosition);
-        }
         final KeyDrawParams params = new KeyDrawParams();
         params.updateParams(mEmojiLayoutParams.getActionBarHeight(), keyVisualAttr);
         setupAlphabetKey(mAlphabetKeyLeft, switchToAlphaLabel, params);
@@ -687,9 +363,6 @@
     }
 
     public void stopEmojiPalettes() {
-        if (DEBUG_PAGER) {
-            Log.d(TAG, "deallocate emoji palettes memory");
-        }
         mEmojiPalettesAdapter.flushPendingRecentKeys();
         mEmojiPager.setAdapter(null);
     }
@@ -714,7 +387,7 @@
             return;
         }
 
-        if (oldCategoryId == CATEGORY_ID_RECENTS) {
+        if (oldCategoryId == EmojiCategory.ID_RECENTS) {
             // Needs to save pending updates for recent keys when we get out of the recents
             // category because we don't want to move the recent emojis around while the user
             // is in the recents category.
@@ -733,124 +406,11 @@
         }
     }
 
-    private static class EmojiPalettesAdapter extends PagerAdapter {
-        private final EmojiPageKeyboardView.OnKeyEventListener mListener;
-        private final DynamicGridKeyboard mRecentsKeyboard;
-        private final SparseArray<EmojiPageKeyboardView> mActiveKeyboardViews =
-                CollectionUtils.newSparseArray();
-        private final EmojiCategory mEmojiCategory;
-        private int mActivePosition = 0;
-
-        public EmojiPalettesAdapter(final EmojiCategory emojiCategory,
-                final EmojiPageKeyboardView.OnKeyEventListener listener) {
-            mEmojiCategory = emojiCategory;
-            mListener = listener;
-            mRecentsKeyboard = mEmojiCategory.getKeyboard(CATEGORY_ID_RECENTS, 0);
-        }
-
-        public void flushPendingRecentKeys() {
-            mRecentsKeyboard.flushPendingRecentKeys();
-            final KeyboardView recentKeyboardView =
-                    mActiveKeyboardViews.get(mEmojiCategory.getRecentTabId());
-            if (recentKeyboardView != null) {
-                recentKeyboardView.invalidateAllKeys();
-            }
-        }
-
-        public void addRecentKey(final Key key) {
-            if (mEmojiCategory.isInRecentTab()) {
-                mRecentsKeyboard.addPendingKey(key);
-                return;
-            }
-            mRecentsKeyboard.addKeyFirst(key);
-            final KeyboardView recentKeyboardView =
-                    mActiveKeyboardViews.get(mEmojiCategory.getRecentTabId());
-            if (recentKeyboardView != null) {
-                recentKeyboardView.invalidateAllKeys();
-            }
-        }
-
-        public void onPageScrolled() {
-            // Make sure the delayed key-down event (highlight effect and haptic feedback) will be
-            // canceled.
-            final EmojiPageKeyboardView currentKeyboardView =
-                    mActiveKeyboardViews.get(mActivePosition);
-            if (currentKeyboardView != null) {
-                currentKeyboardView.releaseCurrentKey();
-            }
-        }
-
-        @Override
-        public int getCount() {
-            return mEmojiCategory.getTotalPageCountOfAllCategories();
-        }
-
-        @Override
-        public void setPrimaryItem(final ViewGroup container, final int position,
-                final Object object) {
-            if (mActivePosition == position) {
-                return;
-            }
-            final EmojiPageKeyboardView oldKeyboardView = mActiveKeyboardViews.get(mActivePosition);
-            if (oldKeyboardView != null) {
-                oldKeyboardView.releaseCurrentKey();
-                oldKeyboardView.deallocateMemory();
-            }
-            mActivePosition = position;
-        }
-
-        @Override
-        public Object instantiateItem(final ViewGroup container, final int position) {
-            if (DEBUG_PAGER) {
-                Log.d(TAG, "instantiate item: " + position);
-            }
-            final EmojiPageKeyboardView oldKeyboardView = mActiveKeyboardViews.get(position);
-            if (oldKeyboardView != null) {
-                oldKeyboardView.deallocateMemory();
-                // This may be redundant but wanted to be safer..
-                mActiveKeyboardViews.remove(position);
-            }
-            final Keyboard keyboard =
-                    mEmojiCategory.getKeyboardFromPagePosition(position);
-            final LayoutInflater inflater = LayoutInflater.from(container.getContext());
-            final EmojiPageKeyboardView keyboardView = (EmojiPageKeyboardView)inflater.inflate(
-                    R.layout.emoji_keyboard_page, container, false /* attachToRoot */);
-            keyboardView.setKeyboard(keyboard);
-            keyboardView.setOnKeyEventListener(mListener);
-            container.addView(keyboardView);
-            mActiveKeyboardViews.put(position, keyboardView);
-            return keyboardView;
-        }
-
-        @Override
-        public boolean isViewFromObject(final View view, final Object object) {
-            return view == object;
-        }
-
-        @Override
-        public void destroyItem(final ViewGroup container, final int position,
-                final Object object) {
-            if (DEBUG_PAGER) {
-                Log.d(TAG, "destroy item: " + position + ", " + object.getClass().getSimpleName());
-            }
-            final EmojiPageKeyboardView keyboardView = mActiveKeyboardViews.get(position);
-            if (keyboardView != null) {
-                keyboardView.deallocateMemory();
-                mActiveKeyboardViews.remove(position);
-            }
-            if (object instanceof View) {
-                container.removeView((View)object);
-            } else {
-                Log.w(TAG, "Warning!!! Emoji palette may be leaking. " + object);
-            }
-        }
-    }
-
     private static class DeleteKeyOnTouchListener implements OnTouchListener {
-        private static final long MAX_REPEAT_COUNT_TIME = TimeUnit.SECONDS.toMillis(30);
-        private final int mDeleteKeyPressedBackgroundColor;
-        private final long mKeyRepeatStartTimeout;
-        private final long mKeyRepeatInterval;
+        static final long MAX_REPEAT_COUNT_TIME = TimeUnit.SECONDS.toMillis(30);
+        final int mDeleteKeyPressedBackgroundColor;
+        final long mKeyRepeatStartTimeout;
+        final long mKeyRepeatInterval;
 
         public DeleteKeyOnTouchListener(Context context) {
             final Resources res = context.getResources();
@@ -953,7 +513,7 @@
         }
 
         // Called by {@link #mTimer} in the UI thread as an auto key-repeat signal.
-        private void onKeyRepeat() {
+        void onKeyRepeat() {
             switch (mState) {
             case KEY_REPEAT_STATE_INITIALIZED:
                 // Basically this should not happen.
diff --git a/java/src/com/android/inputmethod/keyboard/Key.java b/java/src/com/android/inputmethod/keyboard/Key.java
index 816a943..4c22507 100644
--- a/java/src/com/android/inputmethod/keyboard/Key.java
+++ b/java/src/com/android/inputmethod/keyboard/Key.java
@@ -218,7 +218,7 @@
      *
      * @param keySpec the key specification.
      * @param keyAttr the Key XML attributes array.
-     * @param keyStyle the {@link KeyStyle} of this key.
+     * @param style the {@link KeyStyle} of this key.
      * @param params the keyboard building parameters.
      * @param row the row that this key belongs to. row's x-coordinate will be the right edge of
      *        this key.
@@ -857,17 +857,6 @@
         android.R.attr.state_empty
     };
 
-    // functional normal state (with properties)
-    private static final int[] KEY_STATE_FUNCTIONAL_NORMAL = {
-            android.R.attr.state_single
-    };
-
-    // functional pressed state (with properties)
-    private static final int[] KEY_STATE_FUNCTIONAL_PRESSED = {
-            android.R.attr.state_single,
-            android.R.attr.state_pressed
-    };
-
     // action normal state (with properties)
     private static final int[] KEY_STATE_ACTIVE_NORMAL = {
             android.R.attr.state_active
@@ -880,25 +869,43 @@
     };
 
     /**
-     * Returns the drawable state for the key, based on the current state and type of the key.
-     * @return the drawable state of the key.
+     * Returns the background drawable for the key, based on the current state and type of the key.
+     * @return the background drawable of the key.
      * @see android.graphics.drawable.StateListDrawable#setState(int[])
      */
-    public final int[] getCurrentDrawableState() {
-        switch (mBackgroundType) {
-        case BACKGROUND_TYPE_FUNCTIONAL:
-            return mPressed ? KEY_STATE_FUNCTIONAL_PRESSED : KEY_STATE_FUNCTIONAL_NORMAL;
-        case BACKGROUND_TYPE_ACTION:
-            return mPressed ? KEY_STATE_ACTIVE_PRESSED : KEY_STATE_ACTIVE_NORMAL;
-        case BACKGROUND_TYPE_STICKY_OFF:
-            return mPressed ? KEY_STATE_PRESSED_HIGHLIGHT_OFF : KEY_STATE_NORMAL_HIGHLIGHT_OFF;
-        case BACKGROUND_TYPE_STICKY_ON:
-            return mPressed ? KEY_STATE_PRESSED_HIGHLIGHT_ON : KEY_STATE_NORMAL_HIGHLIGHT_ON;
-        case BACKGROUND_TYPE_EMPTY:
-            return mPressed ? KEY_STATE_PRESSED : KEY_STATE_EMPTY;
-        default: /* BACKGROUND_TYPE_NORMAL */
-            return mPressed ? KEY_STATE_PRESSED : KEY_STATE_NORMAL;
+    public final Drawable selectBackgroundDrawable(final Drawable keyBackground,
+            final Drawable functionalKeyBackground, final Drawable spacebarBackground) {
+        final Drawable background;
+        if (mBackgroundType == BACKGROUND_TYPE_FUNCTIONAL) {
+            background = functionalKeyBackground;
+        } else if (getCode() == Constants.CODE_SPACE) {
+            background = spacebarBackground;
+        } else {
+            background = keyBackground;
         }
+        final int[] stateSet;
+        switch (mBackgroundType) {
+        case BACKGROUND_TYPE_ACTION:
+            stateSet = mPressed ? KEY_STATE_ACTIVE_PRESSED : KEY_STATE_ACTIVE_NORMAL;
+            break;
+        case BACKGROUND_TYPE_STICKY_OFF:
+            stateSet = mPressed ? KEY_STATE_PRESSED_HIGHLIGHT_OFF : KEY_STATE_NORMAL_HIGHLIGHT_OFF;
+            break;
+        case BACKGROUND_TYPE_STICKY_ON:
+            stateSet = mPressed ? KEY_STATE_PRESSED_HIGHLIGHT_ON : KEY_STATE_NORMAL_HIGHLIGHT_ON;
+            break;
+        case BACKGROUND_TYPE_EMPTY:
+            stateSet = mPressed ? KEY_STATE_PRESSED : KEY_STATE_EMPTY;
+            break;
+        case BACKGROUND_TYPE_FUNCTIONAL:
+            stateSet = mPressed ? KEY_STATE_PRESSED : KEY_STATE_NORMAL;
+            break;
+        default: /* BACKGROUND_TYPE_NORMAL */
+            stateSet = mPressed ? KEY_STATE_PRESSED : KEY_STATE_NORMAL;
+            break;
+        }
+        background.setState(stateSet);
+        return background;
     }
 
     public static class Spacer extends Key {
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
index 4450a44..a6eac4c 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
@@ -47,6 +47,8 @@
  * A view that renders a virtual {@link Keyboard}.
  *
  * @attr ref R.styleable#KeyboardView_keyBackground
+ * @attr ref R.styleable#KeyboardView_functionalKeyBackground
+ * @attr ref R.styleable#KeyboardView_spacebarBackground
  * @attr ref R.styleable#KeyboardView_keyLabelHorizontalPadding
  * @attr ref R.styleable#KeyboardView_keyHintLetterPadding
  * @attr ref R.styleable#KeyboardView_keyPopupHintLetterPadding
@@ -81,6 +83,8 @@
     private final float mKeyTextShadowRadius;
     private final float mVerticalCorrection;
     private final Drawable mKeyBackground;
+    private final Drawable mFunctionalKeyBackground;
+    private final Drawable mSpacebarBackground;
     private final Rect mKeyBackgroundPadding = new Rect();
     private static final float KET_TEXT_SHADOW_RADIUS_DISABLED = -1.0f;
 
@@ -125,6 +129,14 @@
                 R.styleable.KeyboardView, defStyle, R.style.KeyboardView);
         mKeyBackground = keyboardViewAttr.getDrawable(R.styleable.KeyboardView_keyBackground);
         mKeyBackground.getPadding(mKeyBackgroundPadding);
+        final Drawable functionalKeyBackground = keyboardViewAttr.getDrawable(
+                R.styleable.KeyboardView_functionalKeyBackground);
+        mFunctionalKeyBackground = (functionalKeyBackground != null) ? functionalKeyBackground
+                : mKeyBackground;
+        final Drawable spacebarBackground = keyboardViewAttr.getDrawable(
+                R.styleable.KeyboardView_spacebarBackground);
+        mSpacebarBackground = (spacebarBackground != null) ? spacebarBackground
+                : mKeyBackground;
         mKeyLabelHorizontalPadding = keyboardViewAttr.getDimensionPixelOffset(
                 R.styleable.KeyboardView_keyLabelHorizontalPadding, 0);
         mKeyHintLetterPadding = keyboardViewAttr.getDimension(
@@ -324,7 +336,9 @@
         params.mAnimAlpha = Constants.Color.ALPHA_OPAQUE;
 
         if (!key.isSpacer()) {
-            onDrawKeyBackground(key, canvas, mKeyBackground);
+            final Drawable background = key.selectBackgroundDrawable(
+                    mKeyBackground, mFunctionalKeyBackground, mSpacebarBackground);
+            onDrawKeyBackground(key, canvas, background);
         }
         onDrawKeyTopVisuals(key, canvas, paint, params);
 
@@ -339,8 +353,6 @@
         final int bgHeight = key.getHeight() + padding.top + padding.bottom;
         final int bgX = -padding.left;
         final int bgY = -padding.top;
-        final int[] drawableState = key.getCurrentDrawableState();
-        background.setState(drawableState);
         final Rect bounds = background.getBounds();
         if (bgWidth != bounds.right || bgHeight != bounds.bottom) {
             background.setBounds(0, 0, bgWidth, bgHeight);
diff --git a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java
index 1a8e4b7..4a09768 100644
--- a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java
@@ -76,7 +76,6 @@
  * @attr ref R.styleable#MainKeyboardView_languageOnSpacebarTextColor
  * @attr ref R.styleable#MainKeyboardView_languageOnSpacebarTextShadowRadius
  * @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
@@ -120,7 +119,6 @@
     /* Space key and its icon and background. */
     private Key mSpaceKey;
     private Drawable mSpacebarIcon;
-    private final Drawable mSpacebarBackground;
     // Stuff to draw language name on spacebar.
     private final int mLanguageOnSpacebarFinalAlpha;
     private ObjectAnimator mLanguageOnSpacebarFadeoutAnimator;
@@ -154,7 +152,6 @@
     private final SlidingKeyInputDrawingPreview mSlidingKeyInputDrawingPreview;
 
     // Key preview
-    private static final boolean FADE_OUT_KEY_TOP_LETTER_WHEN_KEY_IS_PRESSED = false;
     private final KeyPreviewDrawParams mKeyPreviewDrawParams;
     private final KeyPreviewChoreographer mKeyPreviewChoreographer;
 
@@ -224,8 +221,6 @@
                 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(
@@ -557,6 +552,7 @@
     }
 
     // Note that this method is called from a non-UI thread.
+    @SuppressWarnings("static-method")
     public void setMainDictionaryAvailability(final boolean mainDictionaryAvailable) {
         PointerTracker.setMainDictionaryAvailability(mainDictionaryAvailable);
     }
@@ -864,30 +860,12 @@
         }
     }
 
-    // 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) {
         if (key.altCodeWhileTyping() && key.isEnabled()) {
             params.mAnimAlpha = mAltCodeKeyWhileTypingAnimAlpha;
         }
-        // Don't draw key top letter when key preview is showing.
-        if (FADE_OUT_KEY_TOP_LETTER_WHEN_KEY_IS_PRESSED
-                && mKeyPreviewChoreographer.isShowingKeyPreview(key)) {
-            // TODO: Fade out animation for the key top letter, and fade in animation for the key
-            // background color when the user presses the key.
-            return;
-        }
         final int code = key.getCode();
         if (code == Constants.CODE_SPACE) {
             drawSpacebar(key, canvas, paint);
diff --git a/java/src/com/android/inputmethod/keyboard/internal/DynamicGridKeyboard.java b/java/src/com/android/inputmethod/keyboard/internal/DynamicGridKeyboard.java
index 67a2227..a4879b8 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/DynamicGridKeyboard.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/DynamicGridKeyboard.java
@@ -20,7 +20,6 @@
 import android.text.TextUtils;
 import android.util.Log;
 
-import com.android.inputmethod.keyboard.EmojiPalettesView;
 import com.android.inputmethod.keyboard.Key;
 import com.android.inputmethod.keyboard.Keyboard;
 import com.android.inputmethod.latin.settings.Settings;
@@ -36,6 +35,7 @@
 /**
  * This is a Keyboard class where you can add keys dynamically shown in a grid layout
  */
+// TODO: Move this class to com.android.inputmethod.emoji package.
 public class DynamicGridKeyboard extends Keyboard {
     private static final String TAG = DynamicGridKeyboard.class.getSimpleName();
     private static final int TEMPLATE_KEY_CODE_0 = 0x30;
@@ -62,7 +62,7 @@
         mVerticalStep = key0.getHeight() + mVerticalGap;
         mColumnsNum = mBaseWidth / mHorizontalStep;
         mMaxKeyCount = maxKeyCount;
-        mIsRecents = categoryId == EmojiPalettesView.CATEGORY_ID_RECENTS;
+        mIsRecents = categoryId == EmojiCategory.ID_RECENTS;
         mPrefs = prefs;
     }
 
diff --git a/java/src/com/android/inputmethod/keyboard/internal/EmojiCategory.java b/java/src/com/android/inputmethod/keyboard/internal/EmojiCategory.java
new file mode 100644
index 0000000..10bd621
--- /dev/null
+++ b/java/src/com/android/inputmethod/keyboard/internal/EmojiCategory.java
@@ -0,0 +1,359 @@
+/*
+ * Copyright (C) 2014 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.
+ */
+
+package com.android.inputmethod.keyboard.internal;
+
+import android.content.SharedPreferences;
+import android.content.res.Resources;
+import android.graphics.Rect;
+import android.os.Build;
+import android.util.Log;
+import android.util.Pair;
+
+import com.android.inputmethod.keyboard.Key;
+import com.android.inputmethod.keyboard.Keyboard;
+import com.android.inputmethod.keyboard.KeyboardId;
+import com.android.inputmethod.keyboard.KeyboardLayoutSet;
+import com.android.inputmethod.latin.Constants;
+import com.android.inputmethod.latin.R;
+import com.android.inputmethod.latin.settings.Settings;
+import com.android.inputmethod.latin.utils.CollectionUtils;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.concurrent.ConcurrentHashMap;
+
+// TODO: Move this class to com.android.inputmethod.emoji package.
+public final class EmojiCategory {
+    private final String TAG = EmojiCategory.class.getSimpleName();
+
+    private static final int ID_UNSPECIFIED = -1;
+    public static final int ID_RECENTS = 0;
+    private static final int ID_PEOPLE = 1;
+    private static final int ID_OBJECTS = 2;
+    private static final int ID_NATURE = 3;
+    private static final int ID_PLACES = 4;
+    private static final int ID_SYMBOLS = 5;
+    private static final int ID_EMOTICONS = 6;
+
+    public final class CategoryProperties {
+        public final int mCategoryId;
+        public final int mPageCount;
+        public CategoryProperties(final int categoryId, final int pageCount) {
+            mCategoryId = categoryId;
+            mPageCount = pageCount;
+        }
+    }
+
+    private static final String[] sCategoryName = {
+            "recents",
+            "people",
+            "objects",
+            "nature",
+            "places",
+            "symbols",
+            "emoticons" };
+
+    private static final int[] sCategoryIcon = {
+            R.drawable.ic_emoji_recent_light,
+            R.drawable.ic_emoji_people_light,
+            R.drawable.ic_emoji_objects_light,
+            R.drawable.ic_emoji_nature_light,
+            R.drawable.ic_emoji_places_light,
+            R.drawable.ic_emoji_symbols_light,
+            0 };
+
+    private static final String[] sCategoryLabel =
+            { null, null, null, null, null, null, ":-)" };
+
+    private static final int[] sAccessibilityDescriptionResourceIdsForCategories = {
+            R.string.spoken_descrption_emoji_category_recents,
+            R.string.spoken_descrption_emoji_category_people,
+            R.string.spoken_descrption_emoji_category_objects,
+            R.string.spoken_descrption_emoji_category_nature,
+            R.string.spoken_descrption_emoji_category_places,
+            R.string.spoken_descrption_emoji_category_symbols,
+            R.string.spoken_descrption_emoji_category_emoticons };
+
+    private static final int[] sCategoryElementId = {
+            KeyboardId.ELEMENT_EMOJI_RECENTS,
+            KeyboardId.ELEMENT_EMOJI_CATEGORY1,
+            KeyboardId.ELEMENT_EMOJI_CATEGORY2,
+            KeyboardId.ELEMENT_EMOJI_CATEGORY3,
+            KeyboardId.ELEMENT_EMOJI_CATEGORY4,
+            KeyboardId.ELEMENT_EMOJI_CATEGORY5,
+            KeyboardId.ELEMENT_EMOJI_CATEGORY6 };
+
+    private final SharedPreferences mPrefs;
+    private final Resources mRes;
+    private final int mMaxPageKeyCount;
+    private final KeyboardLayoutSet mLayoutSet;
+    private final HashMap<String, Integer> mCategoryNameToIdMap = CollectionUtils.newHashMap();
+    private final ArrayList<CategoryProperties> mShownCategories =
+            CollectionUtils.newArrayList();
+    private final ConcurrentHashMap<Long, DynamicGridKeyboard>
+            mCategoryKeyboardMap = new ConcurrentHashMap<Long, DynamicGridKeyboard>();
+
+    private int mCurrentCategoryId = EmojiCategory.ID_UNSPECIFIED;
+    private int mCurrentCategoryPageId = 0;
+
+    public EmojiCategory(final SharedPreferences prefs, final Resources res,
+            final KeyboardLayoutSet layoutSet) {
+        mPrefs = prefs;
+        mRes = res;
+        mMaxPageKeyCount = res.getInteger(R.integer.config_emoji_keyboard_max_page_key_count);
+        mLayoutSet = layoutSet;
+        for (int i = 0; i < sCategoryName.length; ++i) {
+            mCategoryNameToIdMap.put(sCategoryName[i], i);
+        }
+        addShownCategoryId(EmojiCategory.ID_RECENTS);
+        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR2
+                || android.os.Build.VERSION.CODENAME.equalsIgnoreCase("KeyLimePie")
+                || android.os.Build.VERSION.CODENAME.equalsIgnoreCase("KitKat")) {
+            addShownCategoryId(EmojiCategory.ID_PEOPLE);
+            addShownCategoryId(EmojiCategory.ID_OBJECTS);
+            addShownCategoryId(EmojiCategory.ID_NATURE);
+            addShownCategoryId(EmojiCategory.ID_PLACES);
+            mCurrentCategoryId =
+                    Settings.readLastShownEmojiCategoryId(mPrefs, EmojiCategory.ID_PEOPLE);
+        } else {
+            mCurrentCategoryId =
+                    Settings.readLastShownEmojiCategoryId(mPrefs, EmojiCategory.ID_SYMBOLS);
+        }
+        addShownCategoryId(EmojiCategory.ID_SYMBOLS);
+        addShownCategoryId(EmojiCategory.ID_EMOTICONS);
+        getKeyboard(EmojiCategory.ID_RECENTS, 0 /* cagetoryPageId */)
+                .loadRecentKeys(mCategoryKeyboardMap.values());
+    }
+
+    private void addShownCategoryId(final int categoryId) {
+        // Load a keyboard of categoryId
+        getKeyboard(categoryId, 0 /* cagetoryPageId */);
+        final CategoryProperties properties =
+                new CategoryProperties(categoryId, getCategoryPageCount(categoryId));
+        mShownCategories.add(properties);
+    }
+
+    public String getCategoryName(final int categoryId, final int categoryPageId) {
+        return sCategoryName[categoryId] + "-" + categoryPageId;
+    }
+
+    public int getCategoryId(final String name) {
+        final String[] strings = name.split("-");
+        return mCategoryNameToIdMap.get(strings[0]);
+    }
+
+    public int getCategoryIcon(final int categoryId) {
+        return sCategoryIcon[categoryId];
+    }
+
+    public String getCategoryLabel(final int categoryId) {
+        return sCategoryLabel[categoryId];
+    }
+
+    public String getAccessibilityDescription(final int categoryId) {
+        return mRes.getString(sAccessibilityDescriptionResourceIdsForCategories[categoryId]);
+    }
+
+    public ArrayList<CategoryProperties> getShownCategories() {
+        return mShownCategories;
+    }
+
+    public int getCurrentCategoryId() {
+        return mCurrentCategoryId;
+    }
+
+    public int getCurrentCategoryPageSize() {
+        return getCategoryPageSize(mCurrentCategoryId);
+    }
+
+    public int getCategoryPageSize(final int categoryId) {
+        for (final CategoryProperties prop : mShownCategories) {
+            if (prop.mCategoryId == categoryId) {
+                return prop.mPageCount;
+            }
+        }
+        Log.w(TAG, "Invalid category id: " + categoryId);
+        // Should not reach here.
+        return 0;
+    }
+
+    public void setCurrentCategoryId(final int categoryId) {
+        mCurrentCategoryId = categoryId;
+        Settings.writeLastShownEmojiCategoryId(mPrefs, categoryId);
+    }
+
+    public void setCurrentCategoryPageId(final int id) {
+        mCurrentCategoryPageId = id;
+    }
+
+    public int getCurrentCategoryPageId() {
+        return mCurrentCategoryPageId;
+    }
+
+    public void saveLastTypedCategoryPage() {
+        Settings.writeLastTypedEmojiCategoryPageId(
+                mPrefs, mCurrentCategoryId, mCurrentCategoryPageId);
+    }
+
+    public boolean isInRecentTab() {
+        return mCurrentCategoryId == EmojiCategory.ID_RECENTS;
+    }
+
+    public int getTabIdFromCategoryId(final int categoryId) {
+        for (int i = 0; i < mShownCategories.size(); ++i) {
+            if (mShownCategories.get(i).mCategoryId == categoryId) {
+                return i;
+            }
+        }
+        Log.w(TAG, "categoryId not found: " + categoryId);
+        return 0;
+    }
+
+    // Returns the view pager's page position for the categoryId
+    public int getPageIdFromCategoryId(final int categoryId) {
+        final int lastSavedCategoryPageId =
+                Settings.readLastTypedEmojiCategoryPageId(mPrefs, categoryId);
+        int sum = 0;
+        for (int i = 0; i < mShownCategories.size(); ++i) {
+            final CategoryProperties props = mShownCategories.get(i);
+            if (props.mCategoryId == categoryId) {
+                return sum + lastSavedCategoryPageId;
+            }
+            sum += props.mPageCount;
+        }
+        Log.w(TAG, "categoryId not found: " + categoryId);
+        return 0;
+    }
+
+    public int getRecentTabId() {
+        return getTabIdFromCategoryId(EmojiCategory.ID_RECENTS);
+    }
+
+    private int getCategoryPageCount(final int categoryId) {
+        final Keyboard keyboard = mLayoutSet.getKeyboard(sCategoryElementId[categoryId]);
+        return (keyboard.getSortedKeys().size() - 1) / mMaxPageKeyCount + 1;
+    }
+
+    // Returns a pair of the category id and the category page id from the view pager's page
+    // position. The category page id is numbered in each category. And the view page position
+    // is the position of the current shown page in the view pager which contains all pages of
+    // all categories.
+    public Pair<Integer, Integer> getCategoryIdAndPageIdFromPagePosition(final int position) {
+        int sum = 0;
+        for (final CategoryProperties properties : mShownCategories) {
+            final int temp = sum;
+            sum += properties.mPageCount;
+            if (sum > position) {
+                return new Pair<Integer, Integer>(properties.mCategoryId, position - temp);
+            }
+        }
+        return null;
+    }
+
+    // Returns a keyboard from the view pager's page position.
+    public DynamicGridKeyboard getKeyboardFromPagePosition(final int position) {
+        final Pair<Integer, Integer> categoryAndId =
+                getCategoryIdAndPageIdFromPagePosition(position);
+        if (categoryAndId != null) {
+            return getKeyboard(categoryAndId.first, categoryAndId.second);
+        }
+        return null;
+    }
+
+    private static final Long getCategoryKeyboardMapKey(final int categoryId, final int id) {
+        return (((long) categoryId) << Constants.MAX_INT_BIT_COUNT) | id;
+    }
+
+    public DynamicGridKeyboard getKeyboard(final int categoryId, final int id) {
+        synchronized (mCategoryKeyboardMap) {
+            final Long categotyKeyboardMapKey = getCategoryKeyboardMapKey(categoryId, id);
+            if (mCategoryKeyboardMap.containsKey(categotyKeyboardMapKey)) {
+                return mCategoryKeyboardMap.get(categotyKeyboardMapKey);
+            }
+
+            if (categoryId == EmojiCategory.ID_RECENTS) {
+                final DynamicGridKeyboard kbd = new DynamicGridKeyboard(mPrefs,
+                        mLayoutSet.getKeyboard(KeyboardId.ELEMENT_EMOJI_RECENTS),
+                        mMaxPageKeyCount, categoryId);
+                mCategoryKeyboardMap.put(categotyKeyboardMapKey, kbd);
+                return kbd;
+            }
+
+            final Keyboard keyboard = mLayoutSet.getKeyboard(sCategoryElementId[categoryId]);
+            final Key[][] sortedKeys = sortKeysIntoPages(
+                    keyboard.getSortedKeys(), mMaxPageKeyCount);
+            for (int pageId = 0; pageId < sortedKeys.length; ++pageId) {
+                final DynamicGridKeyboard tempKeyboard = new DynamicGridKeyboard(mPrefs,
+                        mLayoutSet.getKeyboard(KeyboardId.ELEMENT_EMOJI_RECENTS),
+                        mMaxPageKeyCount, categoryId);
+                for (final Key emojiKey : sortedKeys[pageId]) {
+                    if (emojiKey == null) {
+                        break;
+                    }
+                    tempKeyboard.addKeyLast(emojiKey);
+                }
+                mCategoryKeyboardMap.put(
+                        getCategoryKeyboardMapKey(categoryId, pageId), tempKeyboard);
+            }
+            return mCategoryKeyboardMap.get(categotyKeyboardMapKey);
+        }
+    }
+
+    public int getTotalPageCountOfAllCategories() {
+        int sum = 0;
+        for (CategoryProperties properties : mShownCategories) {
+            sum += properties.mPageCount;
+        }
+        return sum;
+    }
+
+    private static Comparator<Key> EMOJI_KEY_COMPARATOR = new Comparator<Key>() {
+        @Override
+        public int compare(final Key lhs, final Key rhs) {
+            final Rect lHitBox = lhs.getHitBox();
+            final Rect rHitBox = rhs.getHitBox();
+            if (lHitBox.top < rHitBox.top) {
+                return -1;
+            } else if (lHitBox.top > rHitBox.top) {
+                return 1;
+            }
+            if (lHitBox.left < rHitBox.left) {
+                return -1;
+            } else if (lHitBox.left > rHitBox.left) {
+                return 1;
+            }
+            if (lhs.getCode() == rhs.getCode()) {
+                return 0;
+            }
+            return lhs.getCode() < rhs.getCode() ? -1 : 1;
+        }
+    };
+
+    private static Key[][] sortKeysIntoPages(final List<Key> inKeys, final int maxPageCount) {
+        final ArrayList<Key> keys = CollectionUtils.newArrayList(inKeys);
+        Collections.sort(keys, EMOJI_KEY_COMPARATOR);
+        final int pageCount = (keys.size() - 1) / maxPageCount + 1;
+        final Key[][] retval = new Key[pageCount][maxPageCount];
+        for (int i = 0; i < keys.size(); ++i) {
+            retval[i / maxPageCount][i % maxPageCount] = keys.get(i);
+        }
+        return retval;
+    }
+}
diff --git a/java/src/com/android/inputmethod/keyboard/internal/EmojiLayoutParams.java b/java/src/com/android/inputmethod/keyboard/internal/EmojiLayoutParams.java
index d57ea5a..78af66b 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/EmojiLayoutParams.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/EmojiLayoutParams.java
@@ -24,7 +24,8 @@
 import android.widget.ImageView;
 import android.widget.LinearLayout;
 
-public class EmojiLayoutParams {
+//TODO: Move this class to com.android.inputmethod.emoji package.
+public final class EmojiLayoutParams {
     private static final int DEFAULT_KEYBOARD_ROWS = 4;
 
     public final int mEmojiPagerHeight;
diff --git a/java/src/com/android/inputmethod/keyboard/internal/EmojiPageKeyboardView.java b/java/src/com/android/inputmethod/keyboard/internal/EmojiPageKeyboardView.java
index e175a05..2f67d19 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/EmojiPageKeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/EmojiPageKeyboardView.java
@@ -33,6 +33,7 @@
  * This is an extended {@link KeyboardView} class that hosts an emoji page keyboard.
  * Multi-touch unsupported. No {@link PointerTracker}s. No gesture support.
  */
+// TODO: Move this class to com.android.inputmethod.emoji package.
 // TODO: Implement key popup preview.
 public final class EmojiPageKeyboardView extends KeyboardView implements
         GestureDetector.OnGestureListener {
diff --git a/java/src/com/android/inputmethod/keyboard/internal/EmojiPalettesAdapter.java b/java/src/com/android/inputmethod/keyboard/internal/EmojiPalettesAdapter.java
new file mode 100644
index 0000000..a44d134
--- /dev/null
+++ b/java/src/com/android/inputmethod/keyboard/internal/EmojiPalettesAdapter.java
@@ -0,0 +1,147 @@
+/*
+ * Copyright (C) 2014 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.
+ */
+
+package com.android.inputmethod.keyboard.internal;
+
+import android.support.v4.view.PagerAdapter;
+import android.util.Log;
+import android.util.SparseArray;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import com.android.inputmethod.keyboard.Key;
+import com.android.inputmethod.keyboard.Keyboard;
+import com.android.inputmethod.keyboard.KeyboardView;
+import com.android.inputmethod.latin.R;
+import com.android.inputmethod.latin.utils.CollectionUtils;
+
+// TODO: Move this class to com.android.inputmethod.emoji package.
+public final class EmojiPalettesAdapter extends PagerAdapter {
+    private static final String TAG = EmojiPalettesAdapter.class.getSimpleName();
+    private static final boolean DEBUG_PAGER = false;
+
+    private final EmojiPageKeyboardView.OnKeyEventListener mListener;
+    private final DynamicGridKeyboard mRecentsKeyboard;
+    private final SparseArray<EmojiPageKeyboardView> mActiveKeyboardViews =
+            CollectionUtils.newSparseArray();
+    private final EmojiCategory mEmojiCategory;
+    private int mActivePosition = 0;
+
+    public EmojiPalettesAdapter(final EmojiCategory emojiCategory,
+            final EmojiPageKeyboardView.OnKeyEventListener listener) {
+        mEmojiCategory = emojiCategory;
+        mListener = listener;
+        mRecentsKeyboard = mEmojiCategory.getKeyboard(EmojiCategory.ID_RECENTS, 0);
+    }
+
+    public void flushPendingRecentKeys() {
+        mRecentsKeyboard.flushPendingRecentKeys();
+        final KeyboardView recentKeyboardView =
+                mActiveKeyboardViews.get(mEmojiCategory.getRecentTabId());
+        if (recentKeyboardView != null) {
+            recentKeyboardView.invalidateAllKeys();
+        }
+    }
+
+    public void addRecentKey(final Key key) {
+        if (mEmojiCategory.isInRecentTab()) {
+            mRecentsKeyboard.addPendingKey(key);
+            return;
+        }
+        mRecentsKeyboard.addKeyFirst(key);
+        final KeyboardView recentKeyboardView =
+                mActiveKeyboardViews.get(mEmojiCategory.getRecentTabId());
+        if (recentKeyboardView != null) {
+            recentKeyboardView.invalidateAllKeys();
+        }
+    }
+
+    public void onPageScrolled() {
+        // Make sure the delayed key-down event (highlight effect and haptic feedback) will be
+        // canceled.
+        final EmojiPageKeyboardView currentKeyboardView =
+                mActiveKeyboardViews.get(mActivePosition);
+        if (currentKeyboardView != null) {
+            currentKeyboardView.releaseCurrentKey();
+        }
+    }
+
+    @Override
+    public int getCount() {
+        return mEmojiCategory.getTotalPageCountOfAllCategories();
+    }
+
+    @Override
+    public void setPrimaryItem(final ViewGroup container, final int position,
+            final Object object) {
+        if (mActivePosition == position) {
+            return;
+        }
+        final EmojiPageKeyboardView oldKeyboardView = mActiveKeyboardViews.get(mActivePosition);
+        if (oldKeyboardView != null) {
+            oldKeyboardView.releaseCurrentKey();
+            oldKeyboardView.deallocateMemory();
+        }
+        mActivePosition = position;
+    }
+
+    @Override
+    public Object instantiateItem(final ViewGroup container, final int position) {
+        if (DEBUG_PAGER) {
+            Log.d(TAG, "instantiate item: " + position);
+        }
+        final EmojiPageKeyboardView oldKeyboardView = mActiveKeyboardViews.get(position);
+        if (oldKeyboardView != null) {
+            oldKeyboardView.deallocateMemory();
+            // This may be redundant but wanted to be safer..
+            mActiveKeyboardViews.remove(position);
+        }
+        final Keyboard keyboard =
+                mEmojiCategory.getKeyboardFromPagePosition(position);
+        final LayoutInflater inflater = LayoutInflater.from(container.getContext());
+        final EmojiPageKeyboardView keyboardView = (EmojiPageKeyboardView)inflater.inflate(
+                R.layout.emoji_keyboard_page, container, false /* attachToRoot */);
+        keyboardView.setKeyboard(keyboard);
+        keyboardView.setOnKeyEventListener(mListener);
+        container.addView(keyboardView);
+        mActiveKeyboardViews.put(position, keyboardView);
+        return keyboardView;
+    }
+
+    @Override
+    public boolean isViewFromObject(final View view, final Object object) {
+        return view == object;
+    }
+
+    @Override
+    public void destroyItem(final ViewGroup container, final int position,
+            final Object object) {
+        if (DEBUG_PAGER) {
+            Log.d(TAG, "destroy item: " + position + ", " + object.getClass().getSimpleName());
+        }
+        final EmojiPageKeyboardView keyboardView = mActiveKeyboardViews.get(position);
+        if (keyboardView != null) {
+            keyboardView.deallocateMemory();
+            mActiveKeyboardViews.remove(position);
+        }
+        if (object instanceof View) {
+            container.removeView((View)object);
+        } else {
+            Log.w(TAG, "Warning!!! Emoji palette may be leaking. " + object);
+        }
+    }
+}
diff --git a/native/jni/src/suggest/policyimpl/dictionary/structure/v4/ver4_dict_buffers.cpp b/native/jni/src/suggest/policyimpl/dictionary/structure/v4/ver4_dict_buffers.cpp
index 77ed38b..5aa6b9a 100644
--- a/native/jni/src/suggest/policyimpl/dictionary/structure/v4/ver4_dict_buffers.cpp
+++ b/native/jni/src/suggest/policyimpl/dictionary/structure/v4/ver4_dict_buffers.cpp
@@ -56,6 +56,7 @@
             return false;
         }
     }
+    umask(S_IWGRP | S_IWOTH);
     if (mkdir(tmpDirPath, S_IRWXU) == -1) {
         AKLOGE("Cannot create directory: %s. errno: %d.", tmpDirPath, errno);
         return false;
diff --git a/native/jni/src/suggest/policyimpl/dictionary/utils/dict_file_writing_utils.cpp b/native/jni/src/suggest/policyimpl/dictionary/utils/dict_file_writing_utils.cpp
index 7bc7b0a..80970c7 100644
--- a/native/jni/src/suggest/policyimpl/dictionary/utils/dict_file_writing_utils.cpp
+++ b/native/jni/src/suggest/policyimpl/dictionary/utils/dict_file_writing_utils.cpp
@@ -17,6 +17,10 @@
 #include "suggest/policyimpl/dictionary/utils/dict_file_writing_utils.h"
 
 #include <cstdio>
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <sys/types.h>
 
 #include "suggest/policyimpl/dictionary/header/header_policy.h"
 #include "suggest/policyimpl/dictionary/structure/pt_common/dynamic_pt_writing_utils.h"
@@ -100,9 +104,15 @@
 
 /* static */ bool DictFileWritingUtils::flushBufferToFile(const char *const filePath,
         const BufferWithExtendableBuffer *const buffer) {
-    FILE *const file = fopen(filePath, "wb");
+    const int fd = open(filePath, O_WRONLY | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
+    if (fd == -1) {
+        AKLOGE("File %s cannot be opened. errno: %d", filePath, errno);
+        ASSERT(false);
+        return false;
+    }
+    FILE *const file = fdopen(fd, "wb");
     if (!file) {
-        AKLOGE("File %s cannot be opened.", filePath);
+        AKLOGE("fdopen failed for the file %s. errno: %d", filePath, errno);
         ASSERT(false);
         return false;
     }
diff --git a/tests/src/com/android/inputmethod/latin/InputLogicTestsReorderingMyanmar.java b/tests/src/com/android/inputmethod/latin/InputLogicTestsReorderingMyanmar.java
index b3f2819..bb36a2a 100644
--- a/tests/src/com/android/inputmethod/latin/InputLogicTestsReorderingMyanmar.java
+++ b/tests/src/com/android/inputmethod/latin/InputLogicTestsReorderingMyanmar.java
@@ -220,7 +220,7 @@
 
     public void testMyanmarReordering() {
         int testNumber = 0;
-        changeLanguage("mm_MY");
+        changeLanguage("my_MM", "CombiningRules=MyanmarReordering");
         for (final Pair[] test : TESTS) {
             // Small trick to reset LatinIME : setText("") and send updateSelection with values
             // LatinIME has never seen, and cursor pos 0,0.
diff --git a/tests/src/com/android/inputmethod/latin/InputTestsBase.java b/tests/src/com/android/inputmethod/latin/InputTestsBase.java
index 260e534..09c5320 100644
--- a/tests/src/com/android/inputmethod/latin/InputTestsBase.java
+++ b/tests/src/com/android/inputmethod/latin/InputTestsBase.java
@@ -299,11 +299,15 @@
     }
 
     protected void changeLanguage(final String locale) {
-        changeLanguageWithoutWait(locale);
+        changeLanguage(locale, null);
+    }
+
+    protected void changeLanguage(final String locale, final String combiningSpec) {
+        changeLanguageWithoutWait(locale, combiningSpec);
         waitForDictionariesToBeLoaded();
     }
 
-    protected void changeLanguageWithoutWait(final String locale) {
+    protected void changeLanguageWithoutWait(final String locale, final String combiningSpec) {
         mEditText.mCurrentLocale = LocaleUtils.constructLocaleFromString(locale);
         // TODO: this is forcing a QWERTY keyboard for all locales, which is wrong.
         // It's still better than using whatever keyboard is the current one, but we
@@ -314,7 +318,8 @@
                 "KeyboardLayoutSet=" + SubtypeLocaleUtils.QWERTY
                 + "," + Constants.Subtype.ExtraValue.ASCII_CAPABLE
                 + "," + Constants.Subtype.ExtraValue.ENABLED_WHEN_DEFAULT_IS_NOT_ASCII_CAPABLE
-                + "," + Constants.Subtype.ExtraValue.EMOJI_CAPABLE;
+                + "," + Constants.Subtype.ExtraValue.EMOJI_CAPABLE
+                + null == combiningSpec ? "" : ("," + combiningSpec);
         final InputMethodSubtype subtype = InputMethodSubtypeCompatUtils.newInputMethodSubtype(
                 R.string.subtype_no_language_qwerty,
                 R.drawable.ic_ime_switcher_dark,
@@ -325,7 +330,7 @@
                 false /* overridesImplicitlyEnabledSubtype */,
                 0 /* id */);
         SubtypeSwitcher.getInstance().forceSubtype(subtype);
-        mLatinIME.loadKeyboard();
+        mLatinIME.onCurrentInputMethodSubtypeChanged(subtype);
         runMessages();
         mKeyboard = mLatinIME.mKeyboardSwitcher.getKeyboard();
         mLatinIME.clearPersonalizedDictionariesForTest();
diff --git a/tests/src/com/android/inputmethod/latin/LatinImeStressTests.java b/tests/src/com/android/inputmethod/latin/LatinImeStressTests.java
index db14b83..0a29d83 100644
--- a/tests/src/com/android/inputmethod/latin/LatinImeStressTests.java
+++ b/tests/src/com/android/inputmethod/latin/LatinImeStressTests.java
@@ -33,7 +33,8 @@
         final int codePointSetSize = 30;
         final int[] codePointSet = CodePointUtils.LATIN_ALPHABETS_LOWER;
         for (int i = 0; i < switchCount; ++i) {
-            changeLanguageWithoutWait(locales[random.nextInt(locales.length)]);
+            changeLanguageWithoutWait(locales[random.nextInt(locales.length)],
+                    null /* combiningSpec */);
             final int wordCount = random.nextInt(maxWordCountToTypeInEachIteration);
             for (int j = 0; j < wordCount; ++j) {
                 final String word = CodePointUtils.generateWord(random, codePointSet);
@@ -50,7 +51,8 @@
         final int codePointSetSize = 30;
         final int[] codePointSet = CodePointUtils.generateCodePointSet(codePointSetSize, random);
         for (int i = 0; i < switchCount; ++i) {
-            changeLanguageWithoutWait(locales[random.nextInt(locales.length)]);
+            changeLanguageWithoutWait(locales[random.nextInt(locales.length)],
+                    null /* combiningSpec */);
             final int wordCount = random.nextInt(maxWordCountToTypeInEachIteration);
             for (int j = 0; j < wordCount; ++j) {
                 final String word = CodePointUtils.generateWord(random, codePointSet);
