From 4c259866c418c4bbb1348ffd122a805e86ec8bbd Mon Sep 17 00:00:00 2001 From: Yohei Yukawa Date: Wed, 12 Feb 2014 18:38:37 +0900 Subject: [PATCH] Cancel keydown events immediately once the view starts scrolling The motivation of this patch is to make sure a user never feel haptic feedback when scrolling the Emoji palette. In order to achieve it, EmojiPageKeyboardView#releaseCurrentKey() should be called whenever (delayed) keydown events should be canceled. This patch wires up ViewPager.OnPageChangeListener#onPageScrolled with EmojiPageKeyboardView#releaseCurrentKey() so that delayed keydown events will be canceled immediately once the ViewParger starts scrolling. BUG: 12964092 Change-Id: Iea8c3e090bb16a8622e6b4a850af2bf963aa77d0 --- .../android/inputmethod/keyboard/EmojiPalettesView.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/java/src/com/android/inputmethod/keyboard/EmojiPalettesView.java b/java/src/com/android/inputmethod/keyboard/EmojiPalettesView.java index 672759aee..b44741cda 100644 --- a/java/src/com/android/inputmethod/keyboard/EmojiPalettesView.java +++ b/java/src/com/android/inputmethod/keyboard/EmojiPalettesView.java @@ -534,6 +534,7 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange @Override public void onPageScrolled(final int position, final float positionOffset, final int positionOffsetPixels) { + mEmojiPalettesAdapter.onPageScrolled(); final Pair newPos = mEmojiCategory.getCategoryIdAndPageIdFromPagePosition(position); final int newCategoryId = newPos.first; @@ -718,6 +719,14 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange } } + public void onPageScrolled() { + // Make sure the delayed key-down event (highlight effect and haptic feedback) will be + // canceled. + final EmojiPageKeyboardView currentKeyboardView = + mActiveKeyboardViews.get(mActivePosition); + currentKeyboardView.releaseCurrentKey(); + } + @Override public int getCount() { return mEmojiCategory.getTotalPageCountOfAllCategories();