Fix centering more suggestions panel on tablet

Bug: 6129726
Change-Id: I8dac3251eec68ad3fb523c632ff39f3cc661c81f
main
Tadashi G. Takaoka 2012-03-07 19:09:36 +09:00
parent 77541fc92e
commit bcbaffd9dd
4 changed files with 22 additions and 45 deletions

View File

@ -27,7 +27,6 @@
<com.android.inputmethod.keyboard.MoreKeysKeyboardView
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
android:id="@+id/more_keys_keyboard_view"
android:layout_alignParentBottom="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>

View File

@ -27,7 +27,6 @@
<com.android.inputmethod.latin.suggestions.MoreSuggestionsView
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
android:id="@+id/more_suggestions_view"
android:layout_alignParentBottom="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
latin:keyLabelSize="@dimen/suggestion_text_size"

View File

@ -136,34 +136,23 @@ public class MoreKeysKeyboardView extends KeyboardView implements MoreKeysPanel
mController = controller;
mListener = listener;
final View container = (View)getParent();
final MoreKeysKeyboard moreKeysKeyboard = (MoreKeysKeyboard)getKeyboard();
parentView.getLocationInWindow(mCoordinates);
final int moreKeysKeyboardLeft = pointX - moreKeysKeyboard.getDefaultCoordX()
final MoreKeysKeyboard pane = (MoreKeysKeyboard)getKeyboard();
final int defaultCoordX = pane.getDefaultCoordX();
// The coordinates of panel's left-top corner in parentView's coordinate system.
final int x = pointX - defaultCoordX - container.getPaddingLeft()
+ parentView.getPaddingLeft();
final int x = wrapUp(Math.max(0, Math.min(moreKeysKeyboardLeft,
parentView.getWidth() - moreKeysKeyboard.mOccupiedWidth))
- container.getPaddingLeft() + mCoordinates[0],
container.getMeasuredWidth(), 0, parentView.getWidth());
final int y = pointY
- (container.getMeasuredHeight() - container.getPaddingBottom())
+ parentView.getPaddingTop() + mCoordinates[1];
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;

View File

@ -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;