am efc4a437: Symbol key acts as modifier key

Merge commit 'efc4a437942f0bccd8815059c5f9d823023cfac1' into gingerbread-plus-aosp

* commit 'efc4a437942f0bccd8815059c5f9d823023cfac1':
  Symbol key acts as modifier key
main
Tadashi G. Takaoka 2010-09-09 04:48:01 -07:00 committed by Android Git Automerger
commit 94fe2b6261
3 changed files with 38 additions and 25 deletions

View File

@ -229,8 +229,9 @@ public class LatinIME extends InputMethodService
private int mDeleteCount; private int mDeleteCount;
private long mLastKeyTime; private long mLastKeyTime;
// Shift modifier key state // Modifier keys state
private ModifierKeyState mShiftKeyState = new ModifierKeyState(); private ModifierKeyState mShiftKeyState = new ModifierKeyState();
private ModifierKeyState mSymbolKeyState = new ModifierKeyState();
private Tutorial mTutorial; private Tutorial mTutorial;
@ -1133,6 +1134,7 @@ public class LatinIME extends InputMethodService
mDeleteCount = 0; mDeleteCount = 0;
} }
mLastKeyTime = when; mLastKeyTime = when;
final boolean distinctMultiTouch = mKeyboardSwitcher.hasDistinctMultitouch();
switch (primaryCode) { switch (primaryCode) {
case Keyboard.KEYCODE_DELETE: case Keyboard.KEYCODE_DELETE:
handleBackspace(); handleBackspace();
@ -1141,9 +1143,14 @@ public class LatinIME extends InputMethodService
break; break;
case Keyboard.KEYCODE_SHIFT: case Keyboard.KEYCODE_SHIFT:
// Shift key is handled in onPress() when device has distinct multi-touch panel. // Shift key is handled in onPress() when device has distinct multi-touch panel.
if (!mKeyboardSwitcher.hasDistinctMultitouch()) if (!distinctMultiTouch)
handleShift(); handleShift();
break; break;
case Keyboard.KEYCODE_MODE_CHANGE:
// Symbol key is handled in onPress() when device has distinct multi-touch panel.
if (!distinctMultiTouch)
changeKeyboardMode();
break;
case Keyboard.KEYCODE_CANCEL: case Keyboard.KEYCODE_CANCEL:
if (!isShowingOptionDialog()) { if (!isShowingOptionDialog()) {
handleClose(); handleClose();
@ -1161,10 +1168,6 @@ public class LatinIME extends InputMethodService
case LatinKeyboardView.KEYCODE_PREV_LANGUAGE: case LatinKeyboardView.KEYCODE_PREV_LANGUAGE:
toggleLanguage(false, false); toggleLanguage(false, false);
break; break;
case Keyboard.KEYCODE_MODE_CHANGE:
// TODO: Mode change (symbol key) should be handled in onPress().
changeKeyboardMode();
break;
case LatinKeyboardView.KEYCODE_VOICE: case LatinKeyboardView.KEYCODE_VOICE:
if (VOICE_INSTALLED) { if (VOICE_INSTALLED) {
startListening(false /* was a button press, was not a swipe */); startListening(false /* was a button press, was not a swipe */);
@ -2210,13 +2213,16 @@ public class LatinIME extends InputMethodService
public void onPress(int primaryCode) { public void onPress(int primaryCode) {
vibrate(); vibrate();
playKeyClick(primaryCode); playKeyClick(primaryCode);
if (mKeyboardSwitcher.hasDistinctMultitouch() && primaryCode == Keyboard.KEYCODE_SHIFT) { final boolean distinctMultiTouch = mKeyboardSwitcher.hasDistinctMultitouch();
if (distinctMultiTouch && primaryCode == Keyboard.KEYCODE_SHIFT) {
mShiftKeyState.onPress(); mShiftKeyState.onPress();
handleShift(); handleShift();
} else if (primaryCode == Keyboard.KEYCODE_MODE_CHANGE) { } else if (distinctMultiTouch && primaryCode == Keyboard.KEYCODE_MODE_CHANGE) {
// TODO: We should handle KEYCODE_MODE_CHANGE (symbol) here as well. mSymbolKeyState.onPress();
changeKeyboardMode();
} else { } else {
mShiftKeyState.onOtherKeyPressed(); mShiftKeyState.onOtherKeyPressed();
mSymbolKeyState.onOtherKeyPressed();
} }
} }
@ -2224,12 +2230,15 @@ public class LatinIME extends InputMethodService
// Reset any drag flags in the keyboard // Reset any drag flags in the keyboard
((LatinKeyboard) mKeyboardSwitcher.getInputView().getKeyboard()).keyReleased(); ((LatinKeyboard) mKeyboardSwitcher.getInputView().getKeyboard()).keyReleased();
//vibrate(); //vibrate();
if (mKeyboardSwitcher.hasDistinctMultitouch() && primaryCode == Keyboard.KEYCODE_SHIFT) { final boolean distinctMultiTouch = mKeyboardSwitcher.hasDistinctMultitouch();
if (distinctMultiTouch && primaryCode == Keyboard.KEYCODE_SHIFT) {
if (mShiftKeyState.isMomentary()) if (mShiftKeyState.isMomentary())
resetShift(); resetShift();
mShiftKeyState.onRelease(); mShiftKeyState.onRelease();
} else if (primaryCode == Keyboard.KEYCODE_MODE_CHANGE) { } else if (distinctMultiTouch && primaryCode == Keyboard.KEYCODE_MODE_CHANGE) {
// TODO: We should handle KEYCODE_MODE_CHANGE (symbol) here as well. if (mSymbolKeyState.isMomentary())
changeKeyboardMode();
mSymbolKeyState.onRelease();
} }
} }

View File

@ -52,9 +52,6 @@ public class LatinKeyboardView extends LatinKeyboardBaseView {
/** The y coordinate of the last row */ /** The y coordinate of the last row */
private int mLastRowY; private int mLastRowY;
// This is local working variable for onLongPress().
private int[] mKeyCodes = new int[1];
public LatinKeyboardView(Context context, AttributeSet attrs) { public LatinKeyboardView(Context context, AttributeSet attrs) {
super(context, attrs); super(context, attrs);
} }

View File

@ -111,6 +111,8 @@ public class PointerTracker {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
mKeys = keys; mKeys = keys;
mKeyDebounceThresholdSquared = (int)(hysteresisPixel * hysteresisPixel); mKeyDebounceThresholdSquared = (int)(hysteresisPixel * hysteresisPixel);
// Update current key index because keyboard layout has been changed.
mCurrentKey = mKeyDetector.getKeyIndexAndNearbyCodes(mStartX, mStartY, null);
} }
private boolean isValidKeyIndex(int keyIndex) { private boolean isValidKeyIndex(int keyIndex) {
@ -126,8 +128,8 @@ public class PointerTracker {
if (key == null) if (key == null)
return false; return false;
int primaryCode = key.codes[0]; int primaryCode = key.codes[0];
// TODO: KEYCODE_MODE_CHANGE (symbol) will be also a modifier key return primaryCode == Keyboard.KEYCODE_SHIFT
return primaryCode == Keyboard.KEYCODE_SHIFT; || primaryCode == Keyboard.KEYCODE_MODE_CHANGE;
} }
public void updateKey(int keyIndex) { public void updateKey(int keyIndex) {
@ -173,6 +175,8 @@ public class PointerTracker {
} }
public void onDownEvent(int x, int y, long eventTime) { public void onDownEvent(int x, int y, long eventTime) {
if (DEBUG)
debugLog("onDownEvent:", x, y);
int keyIndex = mKeyDetector.getKeyIndexAndNearbyCodes(x, y, null); int keyIndex = mKeyDetector.getKeyIndexAndNearbyCodes(x, y, null);
mCurrentKey = keyIndex; mCurrentKey = keyIndex;
mStartX = x; mStartX = x;
@ -186,6 +190,8 @@ public class PointerTracker {
if (mListener != null) { if (mListener != null) {
int primaryCode = isValidKeyIndex(keyIndex) ? mKeys[keyIndex].codes[0] : 0; int primaryCode = isValidKeyIndex(keyIndex) ? mKeys[keyIndex].codes[0] : 0;
mListener.onPress(primaryCode); mListener.onPress(primaryCode);
// This onPress call may have changed keyboard layout and have updated mCurrentKey
keyIndex = mCurrentKey;
} }
if (isValidKeyIndex(keyIndex)) { if (isValidKeyIndex(keyIndex)) {
if (mKeys[keyIndex].repeatable) { if (mKeys[keyIndex].repeatable) {
@ -197,11 +203,11 @@ public class PointerTracker {
} }
showKeyPreviewAndUpdateKey(keyIndex); showKeyPreviewAndUpdateKey(keyIndex);
updateMoveDebouncing(x, y); updateMoveDebouncing(x, y);
if (DEBUG)
debugLog("onDownEvent:", x, y);
} }
public void onMoveEvent(int x, int y, long eventTime) { public void onMoveEvent(int x, int y, long eventTime) {
if (DEBUG_MOVE)
debugLog("onMoveEvent:", x, y);
if (mKeyAlreadyProcessed) if (mKeyAlreadyProcessed)
return; return;
int keyIndex = mKeyDetector.getKeyIndexAndNearbyCodes(x, y, null); int keyIndex = mKeyDetector.getKeyIndexAndNearbyCodes(x, y, null);
@ -242,15 +248,13 @@ public class PointerTracker {
*/ */
showKeyPreviewAndUpdateKey(isMinorTimeBounce() ? mLastKey : mCurrentKey); showKeyPreviewAndUpdateKey(isMinorTimeBounce() ? mLastKey : mCurrentKey);
updateMoveDebouncing(x, y); updateMoveDebouncing(x, y);
if (DEBUG_MOVE)
debugLog("onMoveEvent:", x, y);
} }
public void onUpEvent(int x, int y, long eventTime) { public void onUpEvent(int x, int y, long eventTime) {
if (mKeyAlreadyProcessed)
return;
if (DEBUG) if (DEBUG)
debugLog("onUpEvent :", x, y); debugLog("onUpEvent :", x, y);
if (mKeyAlreadyProcessed)
return;
mHandler.cancelKeyTimers(); mHandler.cancelKeyTimers();
mHandler.cancelPopupPreview(); mHandler.cancelPopupPreview();
int keyIndex = mKeyDetector.getKeyIndexAndNearbyCodes(x, y, null); int keyIndex = mKeyDetector.getKeyIndexAndNearbyCodes(x, y, null);
@ -384,8 +388,11 @@ public class PointerTracker {
// The modifier key, such as shift key, should not be shown as preview when multi-touch is // The modifier key, such as shift key, should not be shown as preview when multi-touch is
// supported. On thge other hand, if multi-touch is not supported, the modifier key should // supported. On thge other hand, if multi-touch is not supported, the modifier key should
// be shown as preview. // be shown as preview.
if (!isModifier() || !mHasDistinctMultitouch) if (mHasDistinctMultitouch && isModifier()) {
mProxy.showPreview(NOT_A_KEY, this);
} else {
mProxy.showPreview(keyIndex, this); mProxy.showPreview(keyIndex, this);
}
} }
private void detectAndSendKey(int index, int x, int y, long eventTime) { private void detectAndSendKey(int index, int x, int y, long eventTime) {
@ -478,7 +485,7 @@ public class PointerTracker {
} }
private void debugLog(String title, int x, int y) { private void debugLog(String title, int x, int y) {
Key key = getKey(mCurrentKey); Key key = getKey(mKeyDetector.getKeyIndexAndNearbyCodes(x, y, null));
final String code; final String code;
if (key == null) { if (key == null) {
code = "----"; code = "----";