Fix centering more suggestions panel on tablet (DO NOT MERGE)
This is a cherry-pick of I8dac3251 from Master. Bug: 6129726 Change-Id: If9bce3a1a66a2d9015d19d35dd7915ff23e75926
This commit is contained in:
parent
41f7d2d9e4
commit
b92308407f
4 changed files with 22 additions and 45 deletions
|
@ -27,7 +27,6 @@
|
||||||
<com.android.inputmethod.keyboard.MiniKeyboardView
|
<com.android.inputmethod.keyboard.MiniKeyboardView
|
||||||
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
|
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
|
||||||
android:id="@+id/mini_keyboard_view"
|
android:id="@+id/mini_keyboard_view"
|
||||||
android:layout_alignParentBottom="true"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
<com.android.inputmethod.latin.MoreSuggestionsView
|
<com.android.inputmethod.latin.MoreSuggestionsView
|
||||||
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
|
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
|
||||||
android:id="@+id/more_suggestions_view"
|
android:id="@+id/more_suggestions_view"
|
||||||
android:layout_alignParentBottom="true"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
latin:keyLabelSize="@dimen/suggestion_text_size"
|
latin:keyLabelSize="@dimen/suggestion_text_size"
|
||||||
|
|
|
@ -143,34 +143,23 @@ public class MiniKeyboardView extends KeyboardView implements MoreKeysPanel {
|
||||||
mController = controller;
|
mController = controller;
|
||||||
mListener = listener;
|
mListener = listener;
|
||||||
final View container = (View)getParent();
|
final View container = (View)getParent();
|
||||||
final MiniKeyboard miniKeyboard = (MiniKeyboard)getKeyboard();
|
final MiniKeyboard pane = (MiniKeyboard)getKeyboard();
|
||||||
|
final int defaultCoordX = pane.getDefaultCoordX();
|
||||||
parentView.getLocationInWindow(mCoordinates);
|
// The coordinates of panel's left-top corner in parentView's coordinate system.
|
||||||
final int miniKeyboardLeft = pointX - miniKeyboard.getDefaultCoordX()
|
final int x = pointX - defaultCoordX - container.getPaddingLeft()
|
||||||
+ parentView.getPaddingLeft();
|
+ parentView.getPaddingLeft();
|
||||||
final int x = wrapUp(Math.max(0, Math.min(miniKeyboardLeft,
|
final int y = pointY - container.getMeasuredHeight() + container.getPaddingBottom()
|
||||||
parentView.getWidth() - miniKeyboard.mOccupiedWidth))
|
+ parentView.getPaddingTop();
|
||||||
- container.getPaddingLeft() + mCoordinates[0],
|
|
||||||
container.getMeasuredWidth(), 0, parentView.getWidth());
|
|
||||||
final int y = pointY
|
|
||||||
- (container.getMeasuredHeight() - container.getPaddingBottom())
|
|
||||||
+ parentView.getPaddingTop() + mCoordinates[1];
|
|
||||||
|
|
||||||
window.setContentView(container);
|
window.setContentView(container);
|
||||||
window.setWidth(container.getMeasuredWidth());
|
window.setWidth(container.getMeasuredWidth());
|
||||||
window.setHeight(container.getMeasuredHeight());
|
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];
|
mOriginX = x + container.getPaddingLeft();
|
||||||
mOriginY = y + container.getPaddingTop() - mCoordinates[1];
|
mOriginY = y + container.getPaddingTop();
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean mIsDismissing;
|
private boolean mIsDismissing;
|
||||||
|
|
|
@ -151,32 +151,22 @@ public class MoreSuggestionsView extends KeyboardView implements MoreKeysPanel {
|
||||||
mListener = listener;
|
mListener = listener;
|
||||||
final View container = (View)getParent();
|
final View container = (View)getParent();
|
||||||
final MoreSuggestions pane = (MoreSuggestions)getKeyboard();
|
final MoreSuggestions pane = (MoreSuggestions)getKeyboard();
|
||||||
|
final int defaultCoordX = pane.mOccupiedWidth / 2;
|
||||||
parentView.getLocationInWindow(mCoordinates);
|
// The coordinates of panel's left-top corner in parentView's coordinate system.
|
||||||
final int paneLeft = pointX - (pane.mOccupiedWidth / 2) + parentView.getPaddingLeft();
|
final int x = pointX - defaultCoordX - container.getPaddingLeft()
|
||||||
final int x = wrapUp(Math.max(0, Math.min(paneLeft,
|
+ parentView.getPaddingLeft();
|
||||||
parentView.getWidth() - pane.mOccupiedWidth))
|
final int y = pointY - container.getMeasuredHeight() + container.getPaddingBottom()
|
||||||
- container.getPaddingLeft() + mCoordinates[0],
|
+ parentView.getPaddingTop();
|
||||||
container.getMeasuredWidth(), 0, parentView.getWidth());
|
|
||||||
final int y = pointY
|
|
||||||
- (container.getMeasuredHeight() - container.getPaddingBottom())
|
|
||||||
+ parentView.getPaddingTop() + mCoordinates[1];
|
|
||||||
|
|
||||||
window.setContentView(container);
|
window.setContentView(container);
|
||||||
window.setWidth(container.getMeasuredWidth());
|
window.setWidth(container.getMeasuredWidth());
|
||||||
window.setHeight(container.getMeasuredHeight());
|
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];
|
mOriginX = x + container.getPaddingLeft();
|
||||||
mOriginY = y + container.getPaddingTop() - mCoordinates[1];
|
mOriginY = y + container.getPaddingTop();
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean mIsDismissing;
|
private boolean mIsDismissing;
|
||||||
|
|
Loading…
Reference in a new issue