Loading java/src/com/android/inputmethod/keyboard/EmojiKeyboardView.java +19 −1 Original line number Original line Diff line number Diff line Loading @@ -580,10 +580,18 @@ public final class EmojiKeyboardView extends LinearLayout implements OnTabChange } } private void setCurrentCategoryId(final int categoryId, final boolean force) { private void setCurrentCategoryId(final int categoryId, final boolean force) { if (mEmojiCategory.getCurrentCategoryId() == categoryId && !force) { final int oldCategoryId = mEmojiCategory.getCurrentCategoryId(); if (oldCategoryId == categoryId && !force) { return; return; } } if (oldCategoryId == CATEGORY_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. mEmojiKeyboardAdapter.flushPendingRecentKeys(); } mEmojiCategory.setCurrentCategoryId(categoryId); mEmojiCategory.setCurrentCategoryId(categoryId); final int newTabId = mEmojiCategory.getTabIdFromCategoryId(categoryId); final int newTabId = mEmojiCategory.getTabIdFromCategoryId(categoryId); final int newCategoryPageId = mEmojiCategory.getPageIdFromCategoryId(categoryId); final int newCategoryPageId = mEmojiCategory.getPageIdFromCategoryId(categoryId); Loading Loading @@ -612,8 +620,18 @@ public final class EmojiKeyboardView extends LinearLayout implements OnTabChange mRecentsKeyboard = mEmojiCategory.getKeyboard(CATEGORY_ID_RECENTS, 0); mRecentsKeyboard = mEmojiCategory.getKeyboard(CATEGORY_ID_RECENTS, 0); } } public void flushPendingRecentKeys() { mRecentsKeyboard.flushPendingRecentKeys(); final KeyboardView recentKeyboardView = mActiveKeyboardView.get(mEmojiCategory.getRecentTabId()); if (recentKeyboardView != null) { recentKeyboardView.invalidateAllKeys(); } } public void addRecentKey(final Key key) { public void addRecentKey(final Key key) { if (mEmojiCategory.isInRecentTab()) { if (mEmojiCategory.isInRecentTab()) { mRecentsKeyboard.addPendingKey(key); return; return; } } mRecentsKeyboard.addKeyFirst(key); mRecentsKeyboard.addKeyFirst(key); Loading java/src/com/android/inputmethod/keyboard/internal/DynamicGridKeyboard.java +19 −2 Original line number Original line Diff line number Diff line Loading @@ -39,6 +39,7 @@ public class DynamicGridKeyboard extends Keyboard { private static final String TAG = DynamicGridKeyboard.class.getSimpleName(); private static final String TAG = DynamicGridKeyboard.class.getSimpleName(); private static final int TEMPLATE_KEY_CODE_0 = 0x30; private static final int TEMPLATE_KEY_CODE_0 = 0x30; private static final int TEMPLATE_KEY_CODE_1 = 0x31; private static final int TEMPLATE_KEY_CODE_1 = 0x31; private final Object mLock = new Object(); private final SharedPreferences mPrefs; private final SharedPreferences mPrefs; private final int mLeftPadding; private final int mLeftPadding; Loading @@ -48,6 +49,7 @@ public class DynamicGridKeyboard extends Keyboard { private final int mMaxKeyCount; private final int mMaxKeyCount; private final boolean mIsRecents; private final boolean mIsRecents; private final ArrayDeque<GridKey> mGridKeys = CollectionUtils.newArrayDeque(); private final ArrayDeque<GridKey> mGridKeys = CollectionUtils.newArrayDeque(); private final ArrayDeque<Key> mPendingKeys = CollectionUtils.newArrayDeque(); private Key[] mCachedGridKeys; private Key[] mCachedGridKeys; Loading @@ -74,6 +76,21 @@ public class DynamicGridKeyboard extends Keyboard { throw new RuntimeException("Can't find template key: code=" + code); throw new RuntimeException("Can't find template key: code=" + code); } } public void addPendingKey(final Key usedKey) { synchronized (mLock) { mPendingKeys.addLast(usedKey); } } public void flushPendingRecentKeys() { synchronized (mLock) { while (!mPendingKeys.isEmpty()) { addKey(mPendingKeys.pollFirst(), true); } saveRecentKeys(); } } public void addKeyFirst(final Key usedKey) { public void addKeyFirst(final Key usedKey) { addKey(usedKey, true); addKey(usedKey, true); if (mIsRecents) { if (mIsRecents) { Loading @@ -89,7 +106,7 @@ public class DynamicGridKeyboard extends Keyboard { if (usedKey == null) { if (usedKey == null) { return; return; } } synchronized (mGridKeys) { synchronized (mLock) { mCachedGridKeys = null; mCachedGridKeys = null; final GridKey key = new GridKey(usedKey); final GridKey key = new GridKey(usedKey); while (mGridKeys.remove(key)) { while (mGridKeys.remove(key)) { Loading Loading @@ -167,7 +184,7 @@ public class DynamicGridKeyboard extends Keyboard { @Override @Override public Key[] getKeys() { public Key[] getKeys() { synchronized (mGridKeys) { synchronized (mLock) { if (mCachedGridKeys != null) { if (mCachedGridKeys != null) { return mCachedGridKeys; return mCachedGridKeys; } } Loading Loading
java/src/com/android/inputmethod/keyboard/EmojiKeyboardView.java +19 −1 Original line number Original line Diff line number Diff line Loading @@ -580,10 +580,18 @@ public final class EmojiKeyboardView extends LinearLayout implements OnTabChange } } private void setCurrentCategoryId(final int categoryId, final boolean force) { private void setCurrentCategoryId(final int categoryId, final boolean force) { if (mEmojiCategory.getCurrentCategoryId() == categoryId && !force) { final int oldCategoryId = mEmojiCategory.getCurrentCategoryId(); if (oldCategoryId == categoryId && !force) { return; return; } } if (oldCategoryId == CATEGORY_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. mEmojiKeyboardAdapter.flushPendingRecentKeys(); } mEmojiCategory.setCurrentCategoryId(categoryId); mEmojiCategory.setCurrentCategoryId(categoryId); final int newTabId = mEmojiCategory.getTabIdFromCategoryId(categoryId); final int newTabId = mEmojiCategory.getTabIdFromCategoryId(categoryId); final int newCategoryPageId = mEmojiCategory.getPageIdFromCategoryId(categoryId); final int newCategoryPageId = mEmojiCategory.getPageIdFromCategoryId(categoryId); Loading Loading @@ -612,8 +620,18 @@ public final class EmojiKeyboardView extends LinearLayout implements OnTabChange mRecentsKeyboard = mEmojiCategory.getKeyboard(CATEGORY_ID_RECENTS, 0); mRecentsKeyboard = mEmojiCategory.getKeyboard(CATEGORY_ID_RECENTS, 0); } } public void flushPendingRecentKeys() { mRecentsKeyboard.flushPendingRecentKeys(); final KeyboardView recentKeyboardView = mActiveKeyboardView.get(mEmojiCategory.getRecentTabId()); if (recentKeyboardView != null) { recentKeyboardView.invalidateAllKeys(); } } public void addRecentKey(final Key key) { public void addRecentKey(final Key key) { if (mEmojiCategory.isInRecentTab()) { if (mEmojiCategory.isInRecentTab()) { mRecentsKeyboard.addPendingKey(key); return; return; } } mRecentsKeyboard.addKeyFirst(key); mRecentsKeyboard.addKeyFirst(key); Loading
java/src/com/android/inputmethod/keyboard/internal/DynamicGridKeyboard.java +19 −2 Original line number Original line Diff line number Diff line Loading @@ -39,6 +39,7 @@ public class DynamicGridKeyboard extends Keyboard { private static final String TAG = DynamicGridKeyboard.class.getSimpleName(); private static final String TAG = DynamicGridKeyboard.class.getSimpleName(); private static final int TEMPLATE_KEY_CODE_0 = 0x30; private static final int TEMPLATE_KEY_CODE_0 = 0x30; private static final int TEMPLATE_KEY_CODE_1 = 0x31; private static final int TEMPLATE_KEY_CODE_1 = 0x31; private final Object mLock = new Object(); private final SharedPreferences mPrefs; private final SharedPreferences mPrefs; private final int mLeftPadding; private final int mLeftPadding; Loading @@ -48,6 +49,7 @@ public class DynamicGridKeyboard extends Keyboard { private final int mMaxKeyCount; private final int mMaxKeyCount; private final boolean mIsRecents; private final boolean mIsRecents; private final ArrayDeque<GridKey> mGridKeys = CollectionUtils.newArrayDeque(); private final ArrayDeque<GridKey> mGridKeys = CollectionUtils.newArrayDeque(); private final ArrayDeque<Key> mPendingKeys = CollectionUtils.newArrayDeque(); private Key[] mCachedGridKeys; private Key[] mCachedGridKeys; Loading @@ -74,6 +76,21 @@ public class DynamicGridKeyboard extends Keyboard { throw new RuntimeException("Can't find template key: code=" + code); throw new RuntimeException("Can't find template key: code=" + code); } } public void addPendingKey(final Key usedKey) { synchronized (mLock) { mPendingKeys.addLast(usedKey); } } public void flushPendingRecentKeys() { synchronized (mLock) { while (!mPendingKeys.isEmpty()) { addKey(mPendingKeys.pollFirst(), true); } saveRecentKeys(); } } public void addKeyFirst(final Key usedKey) { public void addKeyFirst(final Key usedKey) { addKey(usedKey, true); addKey(usedKey, true); if (mIsRecents) { if (mIsRecents) { Loading @@ -89,7 +106,7 @@ public class DynamicGridKeyboard extends Keyboard { if (usedKey == null) { if (usedKey == null) { return; return; } } synchronized (mGridKeys) { synchronized (mLock) { mCachedGridKeys = null; mCachedGridKeys = null; final GridKey key = new GridKey(usedKey); final GridKey key = new GridKey(usedKey); while (mGridKeys.remove(key)) { while (mGridKeys.remove(key)) { Loading Loading @@ -167,7 +184,7 @@ public class DynamicGridKeyboard extends Keyboard { @Override @Override public Key[] getKeys() { public Key[] getKeys() { synchronized (mGridKeys) { synchronized (mLock) { if (mCachedGridKeys != null) { if (mCachedGridKeys != null) { return mCachedGridKeys; return mCachedGridKeys; } } Loading