From 9ec80d9d89eb599329c354451acdc482cc3de836 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Sat, 23 Jul 2011 01:16:56 -0700 Subject: [PATCH] Make PointerTracker aware of that popup panel is showing Bug: 5070598 Change-Id: I0604287b8c373e4763b4ccf88c0bd7235af907d5 --- .../inputmethod/keyboard/KeyboardView.java | 5 +++++ .../keyboard/LatinKeyboardBaseView.java | 12 +++++------ .../inputmethod/keyboard/PointerTracker.java | 20 ++++++++++++++++++- .../keyboard/PopupMiniKeyboardView.java | 10 ++++++---- .../inputmethod/keyboard/PopupPanel.java | 2 +- 5 files changed, 37 insertions(+), 12 deletions(-) diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java index 1010adbe0..f54084b3a 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java @@ -865,6 +865,11 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { requestLayout(); } + @Override + public boolean dismissPopupPanel() { + return false; + } + public void purgeKeyboardAndClosing() { mKeyboard = null; closing(); diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboardBaseView.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboardBaseView.java index 0ad91dbb0..22752d037 100644 --- a/java/src/com/android/inputmethod/keyboard/LatinKeyboardBaseView.java +++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboardBaseView.java @@ -400,11 +400,10 @@ public class LatinKeyboardBaseView extends KeyboardView implements PointerTracke mPopupPanel = popupPanel; mPopupPanelPointerTrackerId = tracker.mPointerId; - tracker.onLongPressed(); - popupPanel.showPanel(this, parentKey, tracker, mPopupWindow); + popupPanel.showPopupPanel(this, parentKey, tracker, mPopupWindow); final int translatedX = popupPanel.translateX(tracker.getLastX()); final int translatedY = popupPanel.translateY(tracker.getLastY()); - tracker.onDownEvent(translatedX, translatedY, SystemClock.uptimeMillis(), popupPanel); + tracker.onShowPopupPanel(translatedX, translatedY, SystemClock.uptimeMillis(), popupPanel); invalidateAllKeys(); return true; @@ -546,11 +545,12 @@ public class LatinKeyboardBaseView extends KeyboardView implements PointerTracke @Override public void closing() { super.closing(); - dismissMiniKeyboard(); + dismissPopupPanel(); mPopupPanelCache.clear(); } - public boolean dismissMiniKeyboard() { + @Override + public boolean dismissPopupPanel() { if (mPopupWindow != null && mPopupWindow.isShowing()) { mPopupWindow.dismiss(); mPopupPanel = null; @@ -562,7 +562,7 @@ public class LatinKeyboardBaseView extends KeyboardView implements PointerTracke } public boolean handleBack() { - return dismissMiniKeyboard(); + return dismissPopupPanel(); } @Override diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java index e66ea7b79..f27f74ca4 100644 --- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java +++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java @@ -67,6 +67,7 @@ public class PointerTracker { public void showKeyPreview(int keyIndex, PointerTracker tracker); public void cancelShowKeyPreview(PointerTracker tracker); public void dismissKeyPreview(PointerTracker tracker); + public boolean dismissPopupPanel(); } public interface TimerProxy { @@ -117,9 +118,12 @@ public class PointerTracker { // true if keyboard layout has been changed. private boolean mKeyboardLayoutHasBeenChanged; - // true if event is already translated to a key action (long press or mini-keyboard) + // true if event is already translated to a key action. private boolean mKeyAlreadyProcessed; + // true if this pointer has been long-pressed and is showing a popup panel. + private boolean mIsShowingPopupPanel; + // true if this pointer is repeatable key private boolean mIsRepeatableKey; @@ -579,6 +583,10 @@ public class PointerTracker { } final int keyIndex = onUpKey(keyX, keyY, eventTime); setReleasedKeyGraphics(keyIndex); + if (mIsShowingPopupPanel) { + mDrawingProxy.dismissPopupPanel(); + mIsShowingPopupPanel = false; + } if (mKeyAlreadyProcessed) return; if (!mIsRepeatableKey) { @@ -586,6 +594,12 @@ public class PointerTracker { } } + public void onShowPopupPanel(int x, int y, long eventTime, KeyEventHandler handler) { + onLongPressed(); + onDownEvent(x, y, eventTime, handler); + mIsShowingPopupPanel = true; + } + public void onLongPressed() { mKeyAlreadyProcessed = true; setReleasedKeyGraphics(mKeyIndex); @@ -612,6 +626,10 @@ public class PointerTracker { mDrawingProxy.cancelShowKeyPreview(this); setReleasedKeyGraphics(mKeyIndex); mIsInSlidingKeyInput = false; + if (mIsShowingPopupPanel) { + mDrawingProxy.dismissPopupPanel(); + mIsShowingPopupPanel = false; + } } private void startRepeatKey(int keyIndex) { diff --git a/java/src/com/android/inputmethod/keyboard/PopupMiniKeyboardView.java b/java/src/com/android/inputmethod/keyboard/PopupMiniKeyboardView.java index a90f57c62..2741ee80b 100644 --- a/java/src/com/android/inputmethod/keyboard/PopupMiniKeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/PopupMiniKeyboardView.java @@ -59,19 +59,16 @@ public class PopupMiniKeyboardView extends KeyboardView implements PopupPanel { public void onCodeInput(int primaryCode, int[] keyCodes, int x, int y) { mParentKeyboardView.getKeyboardActionListener() .onCodeInput(primaryCode, keyCodes, x, y); - mParentKeyboardView.dismissMiniKeyboard(); } @Override public void onTextInput(CharSequence text) { mParentKeyboardView.getKeyboardActionListener().onTextInput(text); - mParentKeyboardView.dismissMiniKeyboard(); } @Override public void onCancelInput() { mParentKeyboardView.getKeyboardActionListener().onCancelInput(); - mParentKeyboardView.dismissMiniKeyboard(); } @Override @@ -159,7 +156,7 @@ public class PopupMiniKeyboardView extends KeyboardView implements PopupPanel { } @Override - public void showPanel(LatinKeyboardBaseView parentKeyboardView, Key parentKey, + public void showPopupPanel(LatinKeyboardBaseView parentKeyboardView, Key parentKey, PointerTracker tracker, PopupWindow window) { mParentKeyboardView = parentKeyboardView; final View container = (View)getParent(); @@ -191,6 +188,11 @@ public class PopupMiniKeyboardView extends KeyboardView implements PopupPanel { mOriginY = y + container.getPaddingTop() - mCoordinates[1]; } + @Override + public boolean dismissPopupPanel() { + return mParentKeyboardView.dismissPopupPanel(); + } + @Override public int translateX(int x) { return x - mOriginX; diff --git a/java/src/com/android/inputmethod/keyboard/PopupPanel.java b/java/src/com/android/inputmethod/keyboard/PopupPanel.java index f94d1c562..dc526e74f 100644 --- a/java/src/com/android/inputmethod/keyboard/PopupPanel.java +++ b/java/src/com/android/inputmethod/keyboard/PopupPanel.java @@ -26,7 +26,7 @@ public interface PopupPanel extends PointerTracker.KeyEventHandler { * @param tracker the pointer tracker that pressesd the parent key * @param window PopupWindow to be used to show this popup panel */ - public void showPanel(LatinKeyboardBaseView parentKeyboardView, Key parentKey, + public void showPopupPanel(LatinKeyboardBaseView parentKeyboardView, Key parentKey, PointerTracker tracker, PopupWindow window); /**