Merge "Cleanup keyboard related code a bit"
This commit is contained in:
commit
39cc806605
3 changed files with 18 additions and 3 deletions
|
@ -463,7 +463,7 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
|
||||||
mPopupPanelPointerTrackerId = tracker.mPointerId;
|
mPopupPanelPointerTrackerId = tracker.mPointerId;
|
||||||
|
|
||||||
final Keyboard keyboard = getKeyboard();
|
final Keyboard keyboard = getKeyboard();
|
||||||
mPopupPanel.setShifted(keyboard.isShiftedOrShiftLocked());
|
popupPanel.setShifted(keyboard.isShiftedOrShiftLocked());
|
||||||
final int pointX = (mConfigShowMiniKeyboardAtTouchedPoint) ? tracker.getLastX()
|
final int pointX = (mConfigShowMiniKeyboardAtTouchedPoint) ? tracker.getLastX()
|
||||||
: parentKey.mX + parentKey.mWidth / 2;
|
: parentKey.mX + parentKey.mWidth / 2;
|
||||||
final int pointY = parentKey.mY - keyboard.mVerticalGap;
|
final int pointY = parentKey.mY - keyboard.mVerticalGap;
|
||||||
|
|
|
@ -197,8 +197,8 @@ public class PopupMiniKeyboardView extends KeyboardView implements PopupPanel {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setShifted(boolean shifted) {
|
public void setShifted(boolean shifted) {
|
||||||
final MiniKeyboard miniKeyboard = (MiniKeyboard)getKeyboard();
|
final Keyboard keyboard = getKeyboard();
|
||||||
if (miniKeyboard.setShifted(shifted)) {
|
if (keyboard.setShifted(shifted)) {
|
||||||
invalidateAllKeys();
|
invalidateAllKeys();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,6 +64,15 @@ public class KeyboardParams {
|
||||||
|
|
||||||
public int mMostCommonKeyWidth = 0;
|
public int mMostCommonKeyWidth = 0;
|
||||||
|
|
||||||
|
protected void clearKeys() {
|
||||||
|
mKeys.clear();
|
||||||
|
mShiftKeys.clear();
|
||||||
|
mShiftLockKeys.clear();
|
||||||
|
mShiftedIcons.clear();
|
||||||
|
mUnshiftedIcons.clear();
|
||||||
|
clearHistogram();
|
||||||
|
}
|
||||||
|
|
||||||
public void onAddKey(Key key) {
|
public void onAddKey(Key key) {
|
||||||
mKeys.add(key);
|
mKeys.add(key);
|
||||||
updateHistogram(key);
|
updateHistogram(key);
|
||||||
|
@ -83,6 +92,12 @@ public class KeyboardParams {
|
||||||
private int mMaxCount = 0;
|
private int mMaxCount = 0;
|
||||||
private final Map<Integer, Integer> mHistogram = new HashMap<Integer, Integer>();
|
private final Map<Integer, Integer> mHistogram = new HashMap<Integer, Integer>();
|
||||||
|
|
||||||
|
private void clearHistogram() {
|
||||||
|
mMostCommonKeyWidth = 0;
|
||||||
|
mMaxCount = 0;
|
||||||
|
mHistogram.clear();
|
||||||
|
}
|
||||||
|
|
||||||
private void updateHistogram(Key key) {
|
private void updateHistogram(Key key) {
|
||||||
final Integer width = key.mWidth + key.mHorizontalGap;
|
final Integer width = key.mWidth + key.mHorizontalGap;
|
||||||
final int count = (mHistogram.containsKey(width) ? mHistogram.get(width) : 0) + 1;
|
final int count = (mHistogram.containsKey(width) ? mHistogram.get(width) : 0) + 1;
|
||||||
|
|
Loading…
Reference in a new issue