From f3f3189adbce15d609d5e06632f8e0630db890d1 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Fri, 26 Aug 2011 15:45:05 +0900 Subject: [PATCH] Wrap up popup mini keyboard Bug: 5218641 Change-Id: I88b3e7efa1f7c009c8a8e4f5453a5c4df2f91cfc --- .../inputmethod/keyboard/PopupMiniKeyboardView.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/java/src/com/android/inputmethod/keyboard/PopupMiniKeyboardView.java b/java/src/com/android/inputmethod/keyboard/PopupMiniKeyboardView.java index 2396222bc..c3b5825f5 100644 --- a/java/src/com/android/inputmethod/keyboard/PopupMiniKeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/PopupMiniKeyboardView.java @@ -213,9 +213,10 @@ public class PopupMiniKeyboardView extends KeyboardView implements PopupPanel { final int pointY = parentKey.mY; final int miniKeyboardLeft = pointX - miniKeyboard.getDefaultCoordX() + parentKeyboardView.getPaddingLeft(); - final int x = Math.max(0, Math.min(miniKeyboardLeft, + final int x = wrapUp(Math.max(0, Math.min(miniKeyboardLeft, parentKeyboardView.getWidth() - miniKeyboard.mOccupiedWidth)) - - container.getPaddingLeft() + mCoordinates[0]; + - container.getPaddingLeft() + mCoordinates[0], + container.getMeasuredWidth(), 0, parentKeyboardView.getWidth()); final int y = pointY - parentKeyboard.mVerticalGap - (container.getMeasuredHeight() - container.getPaddingBottom()) + parentKeyboardView.getPaddingTop() + mCoordinates[1]; @@ -232,6 +233,14 @@ public class PopupMiniKeyboardView extends KeyboardView implements PopupPanel { mOriginY = y + container.getPaddingTop() - mCoordinates[1]; } + private static int wrapUp(int x, int width, int left, int right) { + if (x < left) + return left; + if (x + width > right) + return right - width; + return x; + } + @Override public boolean dismissPopupPanel() { return mParentKeyboardView.dismissPopupPanel();