Fix mini keyboard position
This change adjusts popup mini keyboard X-coordinate not to be clipped out of the display. Bug: 4442045 Change-Id: Ibdf4e2d0a79cddbeb89ed8ded81a2db9af9797b8main
parent
fd2f1a1677
commit
528be97fca
|
@ -52,7 +52,6 @@ import android.widget.TextView;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
|
||||||
import java.util.WeakHashMap;
|
import java.util.WeakHashMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1117,19 +1116,6 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isOneRowKeys(List<Key> keys) {
|
|
||||||
if (keys.size() == 0) return false;
|
|
||||||
final int edgeFlags = keys.get(0).mEdgeFlags;
|
|
||||||
// HACK: The first key of mini keyboard which was inflated from xml and has multiple rows,
|
|
||||||
// does not have both top and bottom edge flags on at the same time. On the other hand,
|
|
||||||
// the first key of mini keyboard that was created with popupCharacters must have both top
|
|
||||||
// and bottom edge flags on.
|
|
||||||
// When you want to use one row mini-keyboard from xml file, make sure that the row has
|
|
||||||
// both top and bottom edge flags set.
|
|
||||||
return (edgeFlags & Keyboard.EDGE_TOP) != 0
|
|
||||||
&& (edgeFlags & Keyboard.EDGE_BOTTOM) != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a key is long pressed. By default this will open any popup keyboard associated
|
* Called when a key is long pressed. By default this will open any popup keyboard associated
|
||||||
* with this key through the attributes popupLayout and popupCharacters.
|
* with this key through the attributes popupLayout and popupCharacters.
|
||||||
|
@ -1155,14 +1141,14 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
||||||
}
|
}
|
||||||
final int pointX = (mConfigShowMiniKeyboardAtTouchedPoint) ? tracker.getLastX()
|
final int pointX = (mConfigShowMiniKeyboardAtTouchedPoint) ? tracker.getLastX()
|
||||||
: popupKey.mX + popupKey.mWidth / 2;
|
: popupKey.mX + popupKey.mWidth / 2;
|
||||||
final int popupX = pointX - miniKeyboard.getDefaultCoordX()
|
final int keyboardLeft = pointX - miniKeyboard.getDefaultCoordX() + getPaddingLeft();
|
||||||
- container.getPaddingLeft()
|
final int popupX = Math.max(0, Math.min(keyboardLeft,
|
||||||
+ getPaddingLeft() + mWindowOffset[0];
|
mMiniKeyboardParent.getWidth() - miniKeyboard.getMinWidth()))
|
||||||
final int popupY = popupKey.mY - mKeyboard.getVerticalGap()
|
- container.getPaddingLeft() + mWindowOffset[0];
|
||||||
- (container.getMeasuredHeight() - container.getPaddingBottom())
|
final int popupY = popupKey.mY - mKeyboard.getVerticalGap() + getPaddingTop()
|
||||||
+ getPaddingTop() + mWindowOffset[1];
|
- (container.getMeasuredHeight() - container.getPaddingBottom()) + mWindowOffset[1];
|
||||||
final int x = popupX;
|
final int x = popupX;
|
||||||
final int y = mShowPreview && isOneRowKeys(miniKeyboard.getKeys())
|
final int y = mShowPreview && miniKeyboard.isOneRowKeys()
|
||||||
? mPopupPreviewDisplayedY : popupY;
|
? mPopupPreviewDisplayedY : popupY;
|
||||||
|
|
||||||
mMiniKeyboardOriginX = x + container.getPaddingLeft() - mWindowOffset[0];
|
mMiniKeyboardOriginX = x + container.getPaddingLeft() - mWindowOffset[0];
|
||||||
|
|
|
@ -18,6 +18,8 @@ package com.android.inputmethod.keyboard;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class MiniKeyboard extends Keyboard {
|
public class MiniKeyboard extends Keyboard {
|
||||||
private int mDefaultKeyCoordX;
|
private int mDefaultKeyCoordX;
|
||||||
|
|
||||||
|
@ -32,4 +34,18 @@ public class MiniKeyboard extends Keyboard {
|
||||||
public int getDefaultCoordX() {
|
public int getDefaultCoordX() {
|
||||||
return mDefaultKeyCoordX;
|
return mDefaultKeyCoordX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isOneRowKeys() {
|
||||||
|
final List<Key> keys = getKeys();
|
||||||
|
if (keys.size() == 0) return false;
|
||||||
|
final int edgeFlags = keys.get(0).mEdgeFlags;
|
||||||
|
// HACK: The first key of mini keyboard which was inflated from xml and has multiple rows,
|
||||||
|
// does not have both top and bottom edge flags on at the same time. On the other hand,
|
||||||
|
// the first key of mini keyboard that was created with popupCharacters must have both top
|
||||||
|
// and bottom edge flags on.
|
||||||
|
// When you want to use one row mini-keyboard from xml file, make sure that the row has
|
||||||
|
// both top and bottom edge flags set.
|
||||||
|
return (edgeFlags & Keyboard.EDGE_TOP) != 0
|
||||||
|
&& (edgeFlags & Keyboard.EDGE_BOTTOM) != 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue