am c93ac9db: am ffa88f0e: Merge "Move inflating mini keyboard code into separate method" into gingerbread
Merge commit 'c93ac9db7129f935425f79d5a460e7b926cb4a22' * commit 'c93ac9db7129f935425f79d5a460e7b926cb4a22': Move inflating mini keyboard code into separate methodmain
commit
bf669e4379
|
@ -971,24 +971,15 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @param popupKey the key that was long pressed
|
||||
* @return true if the long press is handled, false otherwise. Subclasses should call the
|
||||
* method on the base class if the subclass doesn't wish to handle the call.
|
||||
*/
|
||||
protected boolean onLongPress(Key popupKey) {
|
||||
private View inflateMiniKeyboardContainer(Key popupKey) {
|
||||
int popupKeyboardId = popupKey.popupResId;
|
||||
|
||||
if (popupKeyboardId != 0) {
|
||||
View container = mMiniKeyboardCache.get(popupKey);
|
||||
if (container == null) {
|
||||
LayoutInflater inflater = (LayoutInflater)getContext().getSystemService(
|
||||
Context.LAYOUT_INFLATER_SERVICE);
|
||||
container = inflater.inflate(mPopupLayout, null);
|
||||
mMiniKeyboard = (LatinKeyboardBaseView) container.findViewById(
|
||||
R.id.LatinKeyboardBaseView);
|
||||
View container = inflater.inflate(mPopupLayout, null);
|
||||
if (container == null)
|
||||
throw new NullPointerException();
|
||||
|
||||
mMiniKeyboard = (LatinKeyboardBaseView)container.findViewById(R.id.LatinKeyboardBaseView);
|
||||
mMiniKeyboard.setOnKeyboardActionListener(new OnKeyboardActionListener() {
|
||||
public void onKey(int primaryCode, int[] keyCodes, int x, int y) {
|
||||
mKeyboardActionListener.onKey(primaryCode, keyCodes, x, y);
|
||||
|
@ -1000,10 +991,14 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx
|
|||
dismissPopupKeyboard();
|
||||
}
|
||||
|
||||
public void swipeLeft() { }
|
||||
public void swipeRight() { }
|
||||
public void swipeUp() { }
|
||||
public void swipeDown() { }
|
||||
public void swipeLeft() {
|
||||
}
|
||||
public void swipeRight() {
|
||||
}
|
||||
public void swipeUp() {
|
||||
}
|
||||
public void swipeDown() {
|
||||
}
|
||||
public void onPress(int primaryCode) {
|
||||
mKeyboardActionListener.onPress(primaryCode);
|
||||
}
|
||||
|
@ -1014,22 +1009,40 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx
|
|||
|
||||
Keyboard keyboard;
|
||||
if (popupKey.popupCharacters != null) {
|
||||
keyboard = new Keyboard(getContext(), popupKeyboardId,
|
||||
popupKey.popupCharacters, -1, getPaddingLeft() + getPaddingRight());
|
||||
keyboard = new Keyboard(getContext(), popupKeyboardId, popupKey.popupCharacters,
|
||||
-1, getPaddingLeft() + getPaddingRight());
|
||||
} else {
|
||||
keyboard = new Keyboard(getContext(), popupKeyboardId);
|
||||
}
|
||||
mMiniKeyboard.setKeyboard(keyboard);
|
||||
mMiniKeyboard.setPopupParent(this);
|
||||
container.measure(
|
||||
MeasureSpec.makeMeasureSpec(getWidth(), MeasureSpec.AT_MOST),
|
||||
|
||||
container.measure(MeasureSpec.makeMeasureSpec(getWidth(), MeasureSpec.AT_MOST),
|
||||
MeasureSpec.makeMeasureSpec(getHeight(), MeasureSpec.AT_MOST));
|
||||
|
||||
mMiniKeyboardCache.put(popupKey, container);
|
||||
} else {
|
||||
mMiniKeyboard = (LatinKeyboardBaseView) container.findViewById(
|
||||
R.id.LatinKeyboardBaseView);
|
||||
return container;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @param popupKey the key that was long pressed
|
||||
* @return true if the long press is handled, false otherwise. Subclasses should call the
|
||||
* method on the base class if the subclass doesn't wish to handle the call.
|
||||
*/
|
||||
protected boolean onLongPress(Key popupKey) {
|
||||
// TODO if popupKey.popupCharacters has only one letter, send it as key without opening
|
||||
// mini keyboard.
|
||||
|
||||
if (popupKey.popupResId == 0)
|
||||
return false;
|
||||
|
||||
View container = mMiniKeyboardCache.get(popupKey);
|
||||
if (container == null) {
|
||||
container = inflateMiniKeyboardContainer(popupKey);
|
||||
mMiniKeyboardCache.put(popupKey, container);
|
||||
}
|
||||
mMiniKeyboard = (LatinKeyboardBaseView)container.findViewById(R.id.LatinKeyboardBaseView);
|
||||
if (mWindowOffset == null) {
|
||||
mWindowOffset = new int[2];
|
||||
getLocationInWindow(mWindowOffset);
|
||||
|
@ -1055,16 +1068,14 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx
|
|||
// Inject down event on the key to mini keyboard.
|
||||
long eventTime = System.currentTimeMillis();
|
||||
mMiniKeyboardPopupTime = eventTime;
|
||||
MotionEvent downEvent = generateMiniKeyboardMotionEvent(MotionEvent.ACTION_DOWN,
|
||||
popupKey.x + popupKey.width / 2, popupKey.y + popupKey.height / 2, eventTime);
|
||||
MotionEvent downEvent = generateMiniKeyboardMotionEvent(MotionEvent.ACTION_DOWN, popupKey.x
|
||||
+ popupKey.width / 2, popupKey.y + popupKey.height / 2, eventTime);
|
||||
mMiniKeyboard.onTouchEvent(downEvent);
|
||||
downEvent.recycle();
|
||||
|
||||
invalidateAllKeys();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private MotionEvent generateMiniKeyboardMotionEvent(int action, int x, int y, long eventTime) {
|
||||
return MotionEvent.obtain(mMiniKeyboardPopupTime, eventTime, action,
|
||||
|
|
Loading…
Reference in New Issue