Mini popup keyboard adjustment: Have the leftmost number right above the key.
Also fixed an issue when the mini popup keyboard hits the right edge of the view. A few code cleanups as well. bug: 2980864 Change-Id: I95f8392521e57560907d54b662e3483ebaf6f7cemain
parent
6aa1939510
commit
f62166c13b
|
@ -989,8 +989,9 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx
|
||||||
if (container == null)
|
if (container == null)
|
||||||
throw new NullPointerException();
|
throw new NullPointerException();
|
||||||
|
|
||||||
mMiniKeyboard = (LatinKeyboardBaseView)container.findViewById(R.id.LatinKeyboardBaseView);
|
LatinKeyboardBaseView miniKeyboard =
|
||||||
mMiniKeyboard.setOnKeyboardActionListener(new OnKeyboardActionListener() {
|
(LatinKeyboardBaseView)container.findViewById(R.id.LatinKeyboardBaseView);
|
||||||
|
miniKeyboard.setOnKeyboardActionListener(new OnKeyboardActionListener() {
|
||||||
public void onKey(int primaryCode, int[] keyCodes, int x, int y) {
|
public void onKey(int primaryCode, int[] keyCodes, int x, int y) {
|
||||||
mKeyboardActionListener.onKey(primaryCode, keyCodes, x, y);
|
mKeyboardActionListener.onKey(primaryCode, keyCodes, x, y);
|
||||||
dismissPopupKeyboard();
|
dismissPopupKeyboard();
|
||||||
|
@ -1028,8 +1029,8 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx
|
||||||
} else {
|
} else {
|
||||||
keyboard = new Keyboard(getContext(), popupKeyboardId);
|
keyboard = new Keyboard(getContext(), popupKeyboardId);
|
||||||
}
|
}
|
||||||
mMiniKeyboard.setKeyboard(keyboard);
|
miniKeyboard.setKeyboard(keyboard);
|
||||||
mMiniKeyboard.setPopupParent(this);
|
miniKeyboard.setPopupParent(this);
|
||||||
|
|
||||||
container.measure(MeasureSpec.makeMeasureSpec(getWidth(), MeasureSpec.AT_MOST),
|
container.measure(MeasureSpec.makeMeasureSpec(getWidth(), MeasureSpec.AT_MOST),
|
||||||
MeasureSpec.makeMeasureSpec(getHeight(), MeasureSpec.AT_MOST));
|
MeasureSpec.makeMeasureSpec(getHeight(), MeasureSpec.AT_MOST));
|
||||||
|
@ -1061,17 +1062,38 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx
|
||||||
mWindowOffset = new int[2];
|
mWindowOffset = new int[2];
|
||||||
getLocationInWindow(mWindowOffset);
|
getLocationInWindow(mWindowOffset);
|
||||||
}
|
}
|
||||||
int popupX = popupKey.x + popupKey.width + getPaddingLeft();
|
|
||||||
int popupY = popupKey.y + getPaddingTop();
|
// HACK: Have the leftmost number in the popup characters right above the key
|
||||||
popupX -= container.getMeasuredWidth();
|
boolean isNumberAtLeftmost = false;
|
||||||
|
if (popupKey.popupCharacters != null && popupKey.popupCharacters.length() > 1) {
|
||||||
|
char leftmostChar = popupKey.popupCharacters.charAt(0);
|
||||||
|
isNumberAtLeftmost = leftmostChar >= '0' && leftmostChar <= '9';
|
||||||
|
}
|
||||||
|
|
||||||
|
int popupX = popupKey.x + mWindowOffset[0];
|
||||||
|
int popupY = popupKey.y + mWindowOffset[1];
|
||||||
|
if (isNumberAtLeftmost) {
|
||||||
|
popupX -= container.getPaddingLeft();
|
||||||
|
} else {
|
||||||
|
popupX += popupKey.width + getPaddingLeft();
|
||||||
|
popupX -= container.getMeasuredWidth();
|
||||||
|
popupX += container.getPaddingRight();
|
||||||
|
}
|
||||||
|
popupY += getPaddingTop();
|
||||||
popupY -= container.getMeasuredHeight();
|
popupY -= container.getMeasuredHeight();
|
||||||
popupX += mWindowOffset[0];
|
popupY += container.getPaddingBottom();
|
||||||
popupY += mWindowOffset[1];
|
final int x = popupX;
|
||||||
final int x = popupX + container.getPaddingRight();
|
final int y = popupY;
|
||||||
final int y = popupY + container.getPaddingBottom();
|
|
||||||
mMiniKeyboardOriginX = (x < 0 ? 0 : x) + container.getPaddingLeft();
|
int adjustedX = x;
|
||||||
|
if (x < 0) {
|
||||||
|
adjustedX = 0;
|
||||||
|
} else if (x > (getMeasuredWidth() - container.getMeasuredWidth())) {
|
||||||
|
adjustedX = getMeasuredWidth() - container.getMeasuredWidth();
|
||||||
|
}
|
||||||
|
mMiniKeyboardOriginX = adjustedX + container.getPaddingLeft();
|
||||||
mMiniKeyboardOriginY = y + container.getPaddingTop();
|
mMiniKeyboardOriginY = y + container.getPaddingTop();
|
||||||
mMiniKeyboard.setPopupOffset((x < 0) ? 0 : x, y);
|
mMiniKeyboard.setPopupOffset(adjustedX, y);
|
||||||
mMiniKeyboard.setShifted(isShifted());
|
mMiniKeyboard.setShifted(isShifted());
|
||||||
// Mini keyboard needs no pop-up key preview displayed.
|
// Mini keyboard needs no pop-up key preview displayed.
|
||||||
mMiniKeyboard.setPreviewEnabled(false);
|
mMiniKeyboard.setPreviewEnabled(false);
|
||||||
|
|
Loading…
Reference in New Issue