From 0ae817c9aee319584cbb4df5b1fa74bca684eb06 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Thu, 16 Sep 2010 14:54:45 +0900 Subject: [PATCH] Add enter/exit animation style to prevew and mini keyboard TODO This animation style API of PopupWindow can be called only in Gingrebread or later. We should refactor this using reflection to be able to be compatible with Froyo. Bug: 3004787 Bug: 2973989 Change-Id: I2abfcc853b1a0af2bccee7bdf5fbd723456b7d34 --- java/res/anim/key_preview_fadein.xml | 29 +++++++++++++++++++ java/res/anim/key_preview_fadeout.xml | 29 +++++++++++++++++++ java/res/anim/mini_keyboard_fadein.xml | 29 +++++++++++++++++++ java/res/anim/mini_keyboard_fadeout.xml | 29 +++++++++++++++++++ java/res/values/config.xml | 28 ++++++++++++++++++ java/res/values/styles.xml | 8 +++++ .../latin/LatinKeyboardBaseView.java | 27 ++++++++--------- 7 files changed, 166 insertions(+), 13 deletions(-) create mode 100644 java/res/anim/key_preview_fadein.xml create mode 100644 java/res/anim/key_preview_fadeout.xml create mode 100644 java/res/anim/mini_keyboard_fadein.xml create mode 100644 java/res/anim/mini_keyboard_fadeout.xml create mode 100644 java/res/values/config.xml diff --git a/java/res/anim/key_preview_fadein.xml b/java/res/anim/key_preview_fadein.xml new file mode 100644 index 000000000..9fad7b9a7 --- /dev/null +++ b/java/res/anim/key_preview_fadein.xml @@ -0,0 +1,29 @@ + + + + + + diff --git a/java/res/anim/key_preview_fadeout.xml b/java/res/anim/key_preview_fadeout.xml new file mode 100644 index 000000000..7de5123cd --- /dev/null +++ b/java/res/anim/key_preview_fadeout.xml @@ -0,0 +1,29 @@ + + + + + + diff --git a/java/res/anim/mini_keyboard_fadein.xml b/java/res/anim/mini_keyboard_fadein.xml new file mode 100644 index 000000000..9fad7b9a7 --- /dev/null +++ b/java/res/anim/mini_keyboard_fadein.xml @@ -0,0 +1,29 @@ + + + + + + diff --git a/java/res/anim/mini_keyboard_fadeout.xml b/java/res/anim/mini_keyboard_fadeout.xml new file mode 100644 index 000000000..7de5123cd --- /dev/null +++ b/java/res/anim/mini_keyboard_fadeout.xml @@ -0,0 +1,29 @@ + + + + + + diff --git a/java/res/values/config.xml b/java/res/values/config.xml new file mode 100644 index 000000000..6e941baaf --- /dev/null +++ b/java/res/values/config.xml @@ -0,0 +1,28 @@ + + + + + 0 + 10 + 0 + 90 + 0 + 100 + diff --git a/java/res/values/styles.xml b/java/res/values/styles.xml index 60fffe873..5e239482f 100644 --- a/java/res/values/styles.xml +++ b/java/res/values/styles.xml @@ -33,4 +33,12 @@ 0.5 white + + diff --git a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java index eeccb965c..3761dab14 100644 --- a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java +++ b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java @@ -154,8 +154,6 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx } // Timing constants - private static final int DELAY_BEFORE_PREVIEW = 0; - private static final int DELAY_AFTER_PREVIEW = 100; private static final int REPEAT_INTERVAL = PointerTracker.REPEAT_INTERVAL; // Miscellaneous constants @@ -194,6 +192,8 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx private int mPopupPreviewOffsetY; private int mWindowY; private int mPopupPreviewDisplayedY; + private final int mDelayBeforePreview; + private final int mDelayAfterPreview; // Popup mini keyboard private PopupWindow mMiniKeyboardPopup; @@ -255,7 +255,7 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx showKey(msg.arg1, (PointerTracker)msg.obj); break; case MSG_DISMISS_PREVIEW: - mPreviewText.setVisibility(INVISIBLE); + mPreviewPopup.dismiss(); break; case MSG_REPEAT_KEY: { final PointerTracker tracker = (PointerTracker)msg.obj; @@ -460,6 +460,8 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx } } + final Resources res = getResources(); + mPreviewPopup = new PopupWindow(context); if (previewLayout != 0) { mPreviewText = (TextView) inflate.inflate(previewLayout, null); @@ -470,10 +472,14 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx mShowPreview = false; } mPreviewPopup.setTouchable(false); - mMiniKeyboardParent = this; + mPreviewPopup.setAnimationStyle(R.style.KeyPreviewAnimation); + mDelayBeforePreview = res.getInteger(R.integer.config_delay_before_preview); + mDelayAfterPreview = res.getInteger(R.integer.config_delay_after_preview); + mMiniKeyboardParent = this; mMiniKeyboardPopup = new PopupWindow(context); mMiniKeyboardPopup.setBackgroundDrawable(null); + mMiniKeyboardPopup.setAnimationStyle(R.style.MiniKeyboardAnimation); mPaint = new Paint(); mPaint.setAntiAlias(true); @@ -485,7 +491,6 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx mMiniKeyboardCache = new HashMap(); mKeyBackground.getPadding(mPadding); - final Resources res = getResources(); mSwipeThreshold = (int) (500 * res.getDisplayMetrics().density); // TODO: Refer frameworks/base/core/res/res/values/config.xml mDisambiguateSwipe = res.getBoolean(R.bool.config_swipeDisambiguation); @@ -657,9 +662,7 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx public void setPopupOffset(int x, int y) { mPopupPreviewOffsetX = x; mPopupPreviewOffsetY = y; - if (mPreviewPopup.isShowing()) { - mPreviewPopup.dismiss(); - } + mPreviewPopup.dismiss(); } /** @@ -895,9 +898,9 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx || (hidePreviewOrShowSpaceKeyPreview && isLanguageSwitchEnabled))) { if (keyIndex == NOT_A_KEY) { mHandler.cancelPopupPreview(); - mHandler.dismissPreview(DELAY_AFTER_PREVIEW); + mHandler.dismissPreview(mDelayAfterPreview); } else if (tracker != null) { - mHandler.popupPreview(DELAY_BEFORE_PREVIEW, keyIndex, tracker); + mHandler.popupPreview(mDelayBeforePreview, keyIndex, tracker); } } } @@ -1375,9 +1378,7 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx } public void closing() { - if (mPreviewPopup.isShowing()) { - mPreviewPopup.dismiss(); - } + mPreviewPopup.dismiss(); mHandler.cancelAllMessages(); dismissPopupKeyboard();