From bcbaffd9dd950c6b82c682a742c93f9319d908f5 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Wed, 7 Mar 2012 19:09:36 +0900 Subject: [PATCH] Fix centering more suggestions panel on tablet Bug: 6129726 Change-Id: I8dac3251eec68ad3fb523c632ff39f3cc661c81f --- java/res/layout/more_keys_keyboard.xml | 1 - java/res/layout/more_suggestions.xml | 1 - .../keyboard/MoreKeysKeyboardView.java | 33 +++++++------------ .../suggestions/MoreSuggestionsView.java | 32 +++++++----------- 4 files changed, 22 insertions(+), 45 deletions(-) diff --git a/java/res/layout/more_keys_keyboard.xml b/java/res/layout/more_keys_keyboard.xml index 89161c6b4..6b2464b99 100644 --- a/java/res/layout/more_keys_keyboard.xml +++ b/java/res/layout/more_keys_keyboard.xml @@ -27,7 +27,6 @@ diff --git a/java/res/layout/more_suggestions.xml b/java/res/layout/more_suggestions.xml index 34f54f974..49a00c6b5 100644 --- a/java/res/layout/more_suggestions.xml +++ b/java/res/layout/more_suggestions.xml @@ -27,7 +27,6 @@ right) - return right - width; - return x; + mOriginX = x + container.getPaddingLeft(); + mOriginY = y + container.getPaddingTop(); } private boolean mIsDismissing; diff --git a/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestionsView.java b/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestionsView.java index 1f7214777..f11b1a4c1 100644 --- a/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestionsView.java +++ b/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestionsView.java @@ -147,32 +147,22 @@ public class MoreSuggestionsView extends KeyboardView implements MoreKeysPanel { mListener = listener; final View container = (View)getParent(); final MoreSuggestions pane = (MoreSuggestions)getKeyboard(); - - parentView.getLocationInWindow(mCoordinates); - final int paneLeft = pointX - (pane.mOccupiedWidth / 2) + parentView.getPaddingLeft(); - final int x = wrapUp(Math.max(0, Math.min(paneLeft, - parentView.getWidth() - pane.mOccupiedWidth)) - - container.getPaddingLeft() + mCoordinates[0], - container.getMeasuredWidth(), 0, parentView.getWidth()); - final int y = pointY - - (container.getMeasuredHeight() - container.getPaddingBottom()) - + parentView.getPaddingTop() + mCoordinates[1]; + final int defaultCoordX = pane.mOccupiedWidth / 2; + // The coordinates of panel's left-top corner in parentView's coordinate system. + final int x = pointX - defaultCoordX - container.getPaddingLeft() + + parentView.getPaddingLeft(); + final int y = pointY - container.getMeasuredHeight() + container.getPaddingBottom() + + parentView.getPaddingTop(); window.setContentView(container); window.setWidth(container.getMeasuredWidth()); window.setHeight(container.getMeasuredHeight()); - window.showAtLocation(parentView, Gravity.NO_GRAVITY, x, y); + parentView.getLocationInWindow(mCoordinates); + window.showAtLocation(parentView, Gravity.NO_GRAVITY, + x + mCoordinates[0], y + mCoordinates[1]); - mOriginX = x + container.getPaddingLeft() - mCoordinates[0]; - 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; + mOriginX = x + container.getPaddingLeft(); + mOriginY = y + container.getPaddingTop(); } private boolean mIsDismissing;