diff options
author | 2010-12-20 20:30:26 +0900 | |
---|---|---|
committer | 2010-12-20 21:58:31 +0900 | |
commit | c4f71668d7b8203dc66f0f04c089a363189eb4ce (patch) | |
tree | 5901e47d308234b926cd5bb3215aa084221f6812 /java/src | |
parent | 8aa3f5a3ad6095a3355841ce30bce4877319d0a0 (diff) | |
download | latinime-c4f71668d7b8203dc66f0f04c089a363189eb4ce.tar.gz latinime-c4f71668d7b8203dc66f0f04c089a363189eb4ce.tar.xz latinime-c4f71668d7b8203dc66f0f04c089a363189eb4ce.zip |
Remove multi-tap feature
Change-Id: Ife44b3f9d420d77d2cfb51044a8356f02ed63e8b
Diffstat (limited to 'java/src')
12 files changed, 60 insertions, 178 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/Key.java b/java/src/com/android/inputmethod/keyboard/Key.java index 1c165e323..26c3f3ede 100644 --- a/java/src/com/android/inputmethod/keyboard/Key.java +++ b/java/src/com/android/inputmethod/keyboard/Key.java @@ -32,10 +32,9 @@ import android.util.Xml; */ public class Key { /** - * All the key codes (unicode or custom code) that this key could generate, zero'th - * being the most important. + * The key code (unicode or custom code) that this key generates. */ - public final int[] mCodes; + public final int mCode; /** The unicode that this key generates in manual temporary upper case mode. */ public final int mManualTemporaryUpperCaseCode; @@ -133,8 +132,6 @@ public class Key { android.R.attr.state_pressed }; - private static final int[] DUMMY_CODES = { 0 }; - /** * Create an empty key with no attributes. * This constructor is being used only for key in mini popup keyboard. @@ -157,7 +154,7 @@ public class Key { final String popupSpecification = popupCharacter.toString(); mLabel = PopupCharactersParser.getLabel(popupSpecification); mOutputText = PopupCharactersParser.getOutputText(popupSpecification); - mCodes = PopupCharactersParser.getCodes(res, popupSpecification); + mCode = PopupCharactersParser.getCode(res, popupSpecification); mIcon = PopupCharactersParser.getIcon(res, popupSpecification); // Horizontal gap is divided equally to both sides of the key. mX = x + mGap / 2; @@ -240,13 +237,14 @@ public class Key { mOutputText = style.getText(keyAttr, R.styleable.Keyboard_Key_keyOutputText); // Choose the first letter of the label as primary code if not // specified. - final int[] codes = style.getIntArray(keyAttr, R.styleable.Keyboard_Key_codes); - if (codes == null && !TextUtils.isEmpty(mLabel)) { - mCodes = new int[] { mLabel.charAt(0) }; - } else if (codes != null) { - mCodes = codes; + final int code = style.getInt(keyAttr, R.styleable.Keyboard_Key_code, + Keyboard.CODE_UNSPECIFIED); + if (code == Keyboard.CODE_UNSPECIFIED && !TextUtils.isEmpty(mLabel)) { + mCode = mLabel.charAt(0); + } else if (code != Keyboard.CODE_UNSPECIFIED) { + mCode = code; } else { - mCodes = DUMMY_CODES; + mCode = Keyboard.CODE_DUMMY; } final Drawable shiftedIcon = style.getDrawable(keyAttr, diff --git a/java/src/com/android/inputmethod/keyboard/KeyStyles.java b/java/src/com/android/inputmethod/keyboard/KeyStyles.java index 9e87816bc..44ec53181 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyStyles.java +++ b/java/src/com/android/inputmethod/keyboard/KeyStyles.java @@ -23,11 +23,9 @@ import android.content.res.TypedArray; import android.content.res.XmlResourceParser; import android.graphics.drawable.Drawable; import android.util.Log; -import android.util.TypedValue; import java.util.ArrayList; import java.util.HashMap; -import java.util.StringTokenizer; public class KeyStyles { private static final String TAG = "KeyStyles"; @@ -38,7 +36,6 @@ public class KeyStyles { private static final KeyStyle EMPTY_KEY_STYLE = new EmptyKeyStyle(); public interface KeyStyle { - public int[] getIntArray(TypedArray a, int index); public CharSequence[] getTextArray(TypedArray a, int index); public Drawable getDrawable(TypedArray a, int index); public CharSequence getText(TypedArray a, int index); @@ -53,11 +50,6 @@ public class KeyStyles { } @Override - public int[] getIntArray(TypedArray a, int index) { - return parseIntArray(a, index); - } - - @Override public CharSequence[] getTextArray(TypedArray a, int index) { return parseTextArray(a, index); } @@ -136,50 +128,12 @@ public class KeyStyles { return list.toArray(new CharSequence[list.size()]); } } - - protected static int[] parseIntArray(TypedArray a, int index) { - if (!a.hasValue(index)) - return null; - TypedValue v = new TypedValue(); - a.getValue(index, v); - if (v.type == TypedValue.TYPE_INT_DEC || v.type == TypedValue.TYPE_INT_HEX) { - return new int[] { v.data }; - } else if (v.type == TypedValue.TYPE_STRING) { - return parseCsvInt(v.string.toString()); - } else { - return null; - } - } - - /* package */ static int[] parseCsvInt(String value) { - int count = 0; - int lastIndex = 0; - if (value.length() > 0) { - count++; - while ((lastIndex = value.indexOf(",", lastIndex + 1)) > 0) { - count++; - } - } - int[] values = new int[count]; - count = 0; - StringTokenizer st = new StringTokenizer(value, ","); - while (st.hasMoreTokens()) { - values[count++] = Integer.parseInt(st.nextToken()); - } - return values; - } } private static class DeclaredKeyStyle extends EmptyKeyStyle { private final HashMap<Integer, Object> mAttributes = new HashMap<Integer, Object>(); @Override - public int[] getIntArray(TypedArray a, int index) { - return a.hasValue(index) - ? super.getIntArray(a, index) : (int[])mAttributes.get(index); - } - - @Override public CharSequence[] getTextArray(TypedArray a, int index) { return a.hasValue(index) ? super.getTextArray(a, index) : (CharSequence[])mAttributes.get(index); @@ -221,7 +175,7 @@ public class KeyStyles { private void parseKeyStyleAttributes(TypedArray keyAttr) { // TODO: Currently not all Key attributes can be declared as style. - readIntArray(keyAttr, R.styleable.Keyboard_Key_codes); + readInt(keyAttr, R.styleable.Keyboard_Key_code); readText(keyAttr, R.styleable.Keyboard_Key_keyLabel); readFlag(keyAttr, R.styleable.Keyboard_Key_keyLabelOption); readTextArray(keyAttr, R.styleable.Keyboard_Key_popupCharacters); @@ -262,12 +216,6 @@ public class KeyStyles { mAttributes.put(index, a.getBoolean(index, false)); } - private void readIntArray(TypedArray a, int index) { - final int[] value = parseIntArray(a, index); - if (value != null) - mAttributes.put(index, value); - } - private void readTextArray(TypedArray a, int index) { final CharSequence[] value = parseTextArray(a, index); if (value != null) diff --git a/java/src/com/android/inputmethod/keyboard/Keyboard.java b/java/src/com/android/inputmethod/keyboard/Keyboard.java index a20c86142..ae1d302db 100644 --- a/java/src/com/android/inputmethod/keyboard/Keyboard.java +++ b/java/src/com/android/inputmethod/keyboard/Keyboard.java @@ -65,12 +65,15 @@ public class Keyboard { public static final int CODE_PERIOD = '.'; /** Special keys code. These should be aligned with values/keycodes.xml */ + public static final int CODE_DUMMY = 0; public static final int CODE_SHIFT = -1; public static final int CODE_SWITCH_ALPHA_SYMBOL = -2; public static final int CODE_CANCEL = -3; public static final int CODE_DONE = -4; public static final int CODE_DELETE = -5; public static final int CODE_ALT = -6; + // Code value representing the code is not specified. + public static final int CODE_UNSPECIFIED = -99; public static final int CODE_SETTINGS = -100; public static final int CODE_SETTINGS_LONGPRESS = -101; // TODO: remove this once LatinIME stops referring to this. diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardParser.java b/java/src/com/android/inputmethod/keyboard/KeyboardParser.java index ed59b8be5..c41d57075 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardParser.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardParser.java @@ -279,14 +279,14 @@ public class KeyboardParser { checkEndTag(TAG_KEY, parser); } else { Key key = new Key(mResources, row, mCurrentX, mCurrentY, parser, mKeyStyles); - if (DEBUG) Log.d(TAG, String.format("<%s keyLabel=%s codes=%s popupCharacters=%s />", - TAG_KEY, key.mLabel, Arrays.toString(key.mCodes), + if (DEBUG) Log.d(TAG, String.format("<%s keyLabel=%s code=%d popupCharacters=%s />", + TAG_KEY, key.mLabel, key.mCode, Arrays.toString(key.mPopupCharacters))); checkEndTag(TAG_KEY, parser); keys.add(key); - if (key.mCodes[0] == Keyboard.CODE_SHIFT) + if (key.mCode == Keyboard.CODE_SHIFT) mKeyboard.getShiftKeys().add(key); - if (key.mCodes[0] == Keyboard.CODE_SPACE) + if (key.mCode == Keyboard.CODE_SPACE) mKeyboard.setSpaceKey(key); endKey(key); } diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java index 7f573b24c..7c6e4dc4e 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java @@ -834,7 +834,7 @@ public class KeyboardView extends View implements PointerTracker.UIProxy { // For characters, use large font. For labels like "Done", use small font. final int labelSize; final Typeface labelStyle; - if (label.length() > 1 && key.mCodes.length < 2) { + if (label.length() > 1) { labelSize = mLabelTextSize; if ((key.mLabelOption & KEY_LABEL_OPTION_FONT_NORMAL) != 0) { labelStyle = Typeface.DEFAULT; @@ -943,7 +943,7 @@ public class KeyboardView extends View implements PointerTracker.UIProxy { // TODO Should take care of temporaryShiftLabel here. mPreviewText.setCompoundDrawables(null, null, null, null); mPreviewText.setText(adjustCase(tracker.getPreviewText(key))); - if (key.mLabel.length() > 1 && key.mCodes.length < 2) { + if (key.mLabel.length() > 1) { mPreviewText.setTextSize(TypedValue.COMPLEX_UNIT_PX, mKeyLetterSize); mPreviewText.setTypeface(Typeface.DEFAULT_BOLD); } else { diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java index b9041e36b..7b079e38e 100644 --- a/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java +++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java @@ -294,7 +294,7 @@ public class LatinKeyboard extends Keyboard { public boolean isInside(Key key, int pointX, int pointY) { int x = pointX; int y = pointY; - final int code = key.mCodes[0]; + final int code = key.mCode; if (code == CODE_SHIFT || code == CODE_DELETE) { y -= key.mHeight / 10; if (code == CODE_SHIFT) x += key.mWidth / 6; @@ -348,11 +348,11 @@ public class LatinKeyboard extends Keyboard { mPrefLetterY = y; for (int i = 0; i < nearby.length; i++) { Key k = nearbyKeys.get(nearby[i]); - if (k != key && inPrefList(k.mCodes[0], pref)) { + if (k != key && inPrefList(k.mCode, pref)) { final int dist = distanceFrom(k, x, y); if (dist < (int) (k.mWidth * OVERLAP_PERCENTAGE_LOW_PROB) && - (pref[k.mCodes[0]] > pref[mPrefLetter] * 3)) { - mPrefLetter = k.mCodes[0]; + (pref[k.mCode] > pref[mPrefLetter] * 3)) { + mPrefLetter = k.mCode; mPrefDistance = dist; if (DEBUG_PREFERRED_LETTER) { Log.d(TAG, "CORRECTED ALTHOUGH PREFERRED !!!!!!"); @@ -376,11 +376,11 @@ public class LatinKeyboard extends Keyboard { for (int i = 0; i < nearby.length; i++) { Key k = nearbyKeys.get(nearby[i]); - if (inPrefList(k.mCodes[0], pref)) { + if (inPrefList(k.mCode, pref)) { final int dist = distanceFrom(k, x, y); if (dist < (int) (k.mWidth * OVERLAP_PERCENTAGE_HIGH_PROB) && dist < mPrefDistance) { - mPrefLetter = k.mCodes[0]; + mPrefLetter = k.mCode; mPrefLetterX = x; mPrefLetterY = y; mPrefDistance = dist; @@ -430,7 +430,7 @@ public class LatinKeyboard extends Keyboard { List<Key> keys = getKeys(); int count = keys.size(); for (int i = 0; i < count; i++) { - if (keys.get(i).mCodes[0] == code) return i; + if (keys.get(i).mCode == code) return i; } return -1; } diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java index 2243e93cf..cb3b430d5 100644 --- a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java @@ -82,7 +82,7 @@ public class LatinKeyboardView extends KeyboardView { @Override protected boolean onLongPress(Key key) { - int primaryCode = key.mCodes[0]; + int primaryCode = key.mCode; if (primaryCode == Keyboard.CODE_SETTINGS) { return invokeOnKey(Keyboard.CODE_SETTINGS_LONGPRESS); } else if (primaryCode == '0' && getLatinKeyboard().isPhoneKeyboard()) { diff --git a/java/src/com/android/inputmethod/keyboard/MiniKeyboardKeyDetector.java b/java/src/com/android/inputmethod/keyboard/MiniKeyboardKeyDetector.java index 774b39ab7..f04991eb7 100644 --- a/java/src/com/android/inputmethod/keyboard/MiniKeyboardKeyDetector.java +++ b/java/src/com/android/inputmethod/keyboard/MiniKeyboardKeyDetector.java @@ -52,7 +52,7 @@ public class MiniKeyboardKeyDetector extends KeyDetector { } if (allKeys != null && closestKeyIndex != NOT_A_KEY) - allKeys[0] = keys[closestKeyIndex].mCodes[0]; + allKeys[0] = keys[closestKeyIndex].mCode; return closestKeyIndex; } } diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java index c0761117f..7928c4f8e 100644 --- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java +++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java @@ -43,7 +43,6 @@ public class PointerTracker { private final int mDelayBeforeKeyRepeatStart; private final int mLongPressKeyTimeout; private final int mLongPressShiftKeyTimeout; - private final int mMultiTapKeyTimeout; // Miscellaneous constants private static final int NOT_A_KEY = KeyDetector.NOT_A_KEY; @@ -75,13 +74,6 @@ public class PointerTracker { // true if sliding key is allowed. private boolean mIsAllowedSlidingKeyInput; - // For multi-tap - private int mLastSentIndex; - private int mTapCount; - private long mLastTapTime; - private boolean mInMultiTap; - private final StringBuilder mPreviewLabel = new StringBuilder(1); - // pressed key private int mPreviousKey = NOT_A_KEY; @@ -116,8 +108,6 @@ public class PointerTracker { mDelayBeforeKeyRepeatStart = res.getInteger(R.integer.config_delay_before_key_repeat_start); mLongPressKeyTimeout = res.getInteger(R.integer.config_long_press_key_timeout); mLongPressShiftKeyTimeout = res.getInteger(R.integer.config_long_press_shift_key_timeout); - mMultiTapKeyTimeout = res.getInteger(R.integer.config_multi_tap_key_timeout); - resetMultiTap(); } public void setOnKeyboardActionListener(KeyboardActionListener listener) { @@ -184,7 +174,7 @@ public class PointerTracker { private boolean isModifierInternal(int keyIndex) { final Key key = getKey(keyIndex); - return key == null ? false : isModifierCode(key.mCodes[0]); + return key == null ? false : isModifierCode(key.mCode); } public boolean isModifier() { @@ -197,12 +187,12 @@ public class PointerTracker { public boolean isOnShiftKey(int x, int y) { final Key key = getKey(mKeyDetector.getKeyIndexAndNearbyCodes(x, y, null)); - return key != null && key.mCodes[0] == Keyboard.CODE_SHIFT; + return key != null && key.mCode == Keyboard.CODE_SHIFT; } public boolean isSpaceKey(int keyIndex) { Key key = getKey(keyIndex); - return key != null && key.mCodes[0] == Keyboard.CODE_SPACE; + return key != null && key.mCode == Keyboard.CODE_SPACE; } public void releaseKey() { @@ -260,9 +250,8 @@ public class PointerTracker { mKeyAlreadyProcessed = false; mIsRepeatableKey = false; mIsInSlidingKeyInput = false; - checkMultiTap(eventTime, keyIndex); if (isValidKeyIndex(keyIndex)) { - callListenerOnPress(mKeys[keyIndex].mCodes[0]); + callListenerOnPress(mKeys[keyIndex].mCode); // This onPress call may have changed keyboard layout and have updated mKeyIndex. // If that's the case, mKeyIndex has been updated in setKeyboard(). keyIndex = mKeyState.getKeyIndex(); @@ -290,7 +279,7 @@ public class PointerTracker { if (oldKey == null) { // The pointer has been slid in to the new key, but the finger was not on any keys. // In this case, we must call onPress() to notify that the new key is being pressed. - callListenerOnPress(getKey(keyIndex).mCodes[0]); + callListenerOnPress(getKey(keyIndex).mCode); keyState.onMoveToNewKey(keyIndex, x, y); startLongPressTimer(keyIndex); } else if (!isMinorMoveBounce(x, y, keyIndex)) { @@ -298,11 +287,10 @@ public class PointerTracker { // onRelease() first to notify that the previous key has been released, then call // onPress() to notify that the new key is being pressed. mIsInSlidingKeyInput = true; - callListenerOnRelease(oldKey.mCodes[0]); + callListenerOnRelease(oldKey.mCode); mHandler.cancelLongPressTimers(); if (mIsAllowedSlidingKeyInput) { - resetMultiTap(); - callListenerOnPress(getKey(keyIndex).mCodes[0]); + callListenerOnPress(getKey(keyIndex).mCode); keyState.onMoveToNewKey(keyIndex, x, y); startLongPressTimer(keyIndex); } else { @@ -316,10 +304,9 @@ public class PointerTracker { // The pointer has been slid out from the previous key, we must call onRelease() to // notify that the previous key has been released. mIsInSlidingKeyInput = true; - callListenerOnRelease(oldKey.mCodes[0]); + callListenerOnRelease(oldKey.mCode); mHandler.cancelLongPressTimers(); if (mIsAllowedSlidingKeyInput) { - resetMultiTap(); keyState.onMoveToNewKey(keyIndex, x ,y); } else { setAlreadyProcessed(); @@ -351,7 +338,7 @@ public class PointerTracker { y = keyState.getKeyY(); } if (!mIsRepeatableKey) { - detectAndSendKey(keyIndex, x, y, eventTime); + detectAndSendKey(keyIndex, x, y); } if (isValidKeyIndex(keyIndex)) @@ -373,9 +360,7 @@ public class PointerTracker { public void repeatKey(int keyIndex) { Key key = getKey(keyIndex); if (key != null) { - // While key is repeating, because there is no need to handle multi-tap key, we can - // pass -1 as eventTime argument. - detectAndSendKey(keyIndex, key.mX, key.mY, -1); + detectAndSendKey(keyIndex, key.mX, key.mY); } } @@ -427,7 +412,7 @@ public class PointerTracker { private void startLongPressTimer(int keyIndex) { Key key = getKey(keyIndex); - if (key.mCodes[0] == Keyboard.CODE_SHIFT) { + if (key.mCode == Keyboard.CODE_SHIFT) { mHandler.startLongPressShiftTimer(mLongPressShiftKeyTimeout, keyIndex, this); } else if (mKeyboardSwitcher.isInMomentaryAutoModeSwitchState()) { // We use longer timeout for sliding finger input started from the symbols mode key. @@ -437,7 +422,7 @@ public class PointerTracker { } } - private void detectAndSendKey(int index, int x, int y, long eventTime) { + private void detectAndSendKey(int index, int x, int y) { final Key key = getKey(index); if (key == null) { callListenerOnCancelInput(); @@ -445,20 +430,11 @@ public class PointerTracker { } if (key.mOutputText != null) { callListenerOnTextInput(key.mOutputText); - callListenerOnRelease(key.mCodes[0]); + callListenerOnRelease(key.mCode); } else { - int code = key.mCodes[0]; + int code = key.mCode; final int[] codes = mKeyDetector.newCodeArray(); mKeyDetector.getKeyIndexAndNearbyCodes(x, y, codes); - // Multi-tap - if (mInMultiTap) { - if (mTapCount != -1) { - callListenerOnCodeInput(Keyboard.CODE_DELETE, KEY_DELETE, x, y); - } else { - mTapCount = 0; - } - code = key.mCodes[mTapCount]; - } // If keyboard is in manual temporary upper case state and key has manual temporary // shift code, alternate character code should be sent. @@ -477,51 +453,10 @@ public class PointerTracker { callListenerOnCodeInput(code, codes, x, y); callListenerOnRelease(code); } - mLastSentIndex = index; - mLastTapTime = eventTime; } - /** - * Handle multi-tap keys by producing the key label for the current multi-tap state. - */ public CharSequence getPreviewText(Key key) { - if (mInMultiTap) { - // Multi-tap - mPreviewLabel.setLength(0); - mPreviewLabel.append((char) key.mCodes[mTapCount < 0 ? 0 : mTapCount]); - return mPreviewLabel; - } else { - return key.mLabel; - } - } - - private void resetMultiTap() { - mLastSentIndex = NOT_A_KEY; - mTapCount = 0; - mLastTapTime = -1; - mInMultiTap = false; - } - - private void checkMultiTap(long eventTime, int keyIndex) { - Key key = getKey(keyIndex); - if (key == null) - return; - - final boolean isMultiTap = - (eventTime < mLastTapTime + mMultiTapKeyTimeout && keyIndex == mLastSentIndex); - if (key.mCodes.length > 1) { - mInMultiTap = true; - if (isMultiTap) { - mTapCount = (mTapCount + 1) % key.mCodes.length; - return; - } else { - mTapCount = -1; - return; - } - } - if (!isMultiTap) { - resetMultiTap(); - } + return key.mLabel; } private long mPreviousEventTime; @@ -529,7 +464,7 @@ public class PointerTracker { private void printTouchEvent(String title, int x, int y, long eventTime) { final int keyIndex = mKeyDetector.getKeyIndexAndNearbyCodes(x, y, null); final Key key = getKey(keyIndex); - final String code = (key == null) ? "----" : keyCodePrintable(key.mCodes[0]); + final String code = (key == null) ? "----" : keyCodePrintable(key.mCode); final long delta = eventTime - mPreviousEventTime; Log.d(TAG, String.format("%s%s[%d] %4d %4d %5d %3d(%s)", title, (mKeyAlreadyProcessed ? "-" : " "), mPointerId, x, y, delta, keyIndex, code)); diff --git a/java/src/com/android/inputmethod/keyboard/PopupCharactersParser.java b/java/src/com/android/inputmethod/keyboard/PopupCharactersParser.java index cad3da03e..32c25801d 100644 --- a/java/src/com/android/inputmethod/keyboard/PopupCharactersParser.java +++ b/java/src/com/android/inputmethod/keyboard/PopupCharactersParser.java @@ -39,7 +39,6 @@ public class PopupCharactersParser { private static final String PREFIX_AT = "@"; private static final String PREFIX_ICON = PREFIX_AT + "drawable/"; private static final String PREFIX_CODE = PREFIX_AT + "integer/"; - private static final int[] DUMMY_CODES = { 0 }; private PopupCharactersParser() { // Intentional empty constructor for utility class. @@ -126,13 +125,13 @@ public class PopupCharactersParser { final String label = getLabel(popupSpec); if (label == null) throw new PopupCharactersParserError("Empty label: " + popupSpec); - // Code is automatically generated for one letter label. See getCode(). + // Code is automatically generated for one letter label. See {@link getCode()}. if (label.length() == 1) return null; return label; } - public static int[] getCodes(Resources res, String popupSpec) { + public static int getCode(Resources res, String popupSpec) { if (hasCode(popupSpec)) { final int end = indexOfLabelEnd(popupSpec, 0); if (indexOfLabelEnd(popupSpec, end + 1) >= 0) @@ -140,15 +139,15 @@ public class PopupCharactersParser { final int resId = getResourceId(res, popupSpec.substring(end + LABEL_END.length() + PREFIX_AT.length())); final int code = res.getInteger(resId); - return new int[] { code }; + return code; } if (indexOfLabelEnd(popupSpec, 0) > 0) - return DUMMY_CODES; + return Keyboard.CODE_DUMMY; final String label = getLabel(popupSpec); // Code is automatically generated for one letter label. if (label != null && label.length() == 1) - return new int[] { label.charAt(0) }; - return DUMMY_CODES; + return label.charAt(0); + return Keyboard.CODE_DUMMY; } public static Drawable getIcon(Resources res, String popupSpec) { diff --git a/java/src/com/android/inputmethod/keyboard/ProximityKeyDetector.java b/java/src/com/android/inputmethod/keyboard/ProximityKeyDetector.java index bd4bbcd89..0920da2cb 100644 --- a/java/src/com/android/inputmethod/keyboard/ProximityKeyDetector.java +++ b/java/src/com/android/inputmethod/keyboard/ProximityKeyDetector.java @@ -46,17 +46,16 @@ public class ProximityKeyDetector extends KeyDetector { final int dist = key.squaredDistanceToEdge(touchX, touchY); if (isInside || (mProximityCorrectOn && dist < mProximityThresholdSquare)) { if (allKeys == null) continue; - final int nCodes = key.mCodes.length; // Find insertion point for (int j = 0; j < distances.length; j++) { if (distances[j] > dist) { - // Make space for nCodes codes - System.arraycopy(distances, j, distances, j + nCodes, - distances.length - (j + nCodes)); - System.arraycopy(allKeys, j, allKeys, j + nCodes, - allKeys.length - (j + nCodes)); - System.arraycopy(key.mCodes, 0, allKeys, j, nCodes); - Arrays.fill(distances, j, j + nCodes, dist); + final int nextPos = j + 1; + System.arraycopy(distances, j, distances, nextPos, + distances.length - nextPos); + System.arraycopy(allKeys, j, allKeys, nextPos, + allKeys.length - nextPos); + distances[j] = dist; + allKeys[j] = key.mCode; break; } } diff --git a/java/src/com/android/inputmethod/latin/TextEntryState.java b/java/src/com/android/inputmethod/latin/TextEntryState.java index f10b86293..f571f26d5 100644 --- a/java/src/com/android/inputmethod/latin/TextEntryState.java +++ b/java/src/com/android/inputmethod/latin/TextEntryState.java @@ -263,9 +263,9 @@ public class TextEntryState { } public static void keyPressedAt(Key key, int x, int y) { - if (LOGGING && sKeyLocationFile != null && key.mCodes[0] >= 32) { + if (LOGGING && sKeyLocationFile != null && key.mCode >= 32) { String out = - "KEY: " + (char) key.mCodes[0] + "KEY: " + (char) key.mCode + " X: " + x + " Y: " + y + " MX: " + (key.mX + key.mWidth / 2) |