am 528be97f: Fix mini keyboard position

* commit '528be97fca75513b81575ef64e4af6898656f5fb':
  Fix mini keyboard position
main
Tadashi G. Takaoka 2011-05-31 07:13:45 -07:00 committed by Android Git Automerger
commit 84f414f44f
2 changed files with 23 additions and 21 deletions

View File

@ -52,7 +52,6 @@ import android.widget.TextView;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.WeakHashMap;
/**
@ -1117,19 +1116,6 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
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
* 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()
: popupKey.mX + popupKey.mWidth / 2;
final int popupX = pointX - miniKeyboard.getDefaultCoordX()
- container.getPaddingLeft()
+ getPaddingLeft() + mWindowOffset[0];
final int popupY = popupKey.mY - mKeyboard.getVerticalGap()
- (container.getMeasuredHeight() - container.getPaddingBottom())
+ getPaddingTop() + mWindowOffset[1];
final int keyboardLeft = pointX - miniKeyboard.getDefaultCoordX() + getPaddingLeft();
final int popupX = Math.max(0, Math.min(keyboardLeft,
mMiniKeyboardParent.getWidth() - miniKeyboard.getMinWidth()))
- container.getPaddingLeft() + mWindowOffset[0];
final int popupY = popupKey.mY - mKeyboard.getVerticalGap() + getPaddingTop()
- (container.getMeasuredHeight() - container.getPaddingBottom()) + mWindowOffset[1];
final int x = popupX;
final int y = mShowPreview && isOneRowKeys(miniKeyboard.getKeys())
final int y = mShowPreview && miniKeyboard.isOneRowKeys()
? mPopupPreviewDisplayedY : popupY;
mMiniKeyboardOriginX = x + container.getPaddingLeft() - mWindowOffset[0];

View File

@ -18,6 +18,8 @@ package com.android.inputmethod.keyboard;
import android.content.Context;
import java.util.List;
public class MiniKeyboard extends Keyboard {
private int mDefaultKeyCoordX;
@ -32,4 +34,18 @@ public class MiniKeyboard extends Keyboard {
public int getDefaultCoordX() {
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;
}
}