Merge "Move code point constants from Keyboard to Constants class"
This commit is contained in:
commit
7947eaf475
28 changed files with 282 additions and 287 deletions
|
@ -26,6 +26,7 @@ import com.android.inputmethod.keyboard.Key;
|
||||||
import com.android.inputmethod.keyboard.Keyboard;
|
import com.android.inputmethod.keyboard.Keyboard;
|
||||||
import com.android.inputmethod.keyboard.KeyboardId;
|
import com.android.inputmethod.keyboard.KeyboardId;
|
||||||
import com.android.inputmethod.latin.CollectionUtils;
|
import com.android.inputmethod.latin.CollectionUtils;
|
||||||
|
import com.android.inputmethod.latin.Constants;
|
||||||
import com.android.inputmethod.latin.R;
|
import com.android.inputmethod.latin.R;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -61,17 +62,19 @@ public final class KeyCodeDescriptionMapper {
|
||||||
mKeyLabelMap.put(":-)", R.string.spoken_description_smiley);
|
mKeyLabelMap.put(":-)", R.string.spoken_description_smiley);
|
||||||
|
|
||||||
// Special non-character codes defined in Keyboard
|
// Special non-character codes defined in Keyboard
|
||||||
mKeyCodeMap.put(Keyboard.CODE_SPACE, R.string.spoken_description_space);
|
mKeyCodeMap.put(Constants.CODE_SPACE, R.string.spoken_description_space);
|
||||||
mKeyCodeMap.put(Keyboard.CODE_DELETE, R.string.spoken_description_delete);
|
mKeyCodeMap.put(Constants.CODE_DELETE, R.string.spoken_description_delete);
|
||||||
mKeyCodeMap.put(Keyboard.CODE_ENTER, R.string.spoken_description_return);
|
mKeyCodeMap.put(Constants.CODE_ENTER, R.string.spoken_description_return);
|
||||||
mKeyCodeMap.put(Keyboard.CODE_SETTINGS, R.string.spoken_description_settings);
|
mKeyCodeMap.put(Constants.CODE_SETTINGS, R.string.spoken_description_settings);
|
||||||
mKeyCodeMap.put(Keyboard.CODE_SHIFT, R.string.spoken_description_shift);
|
mKeyCodeMap.put(Constants.CODE_SHIFT, R.string.spoken_description_shift);
|
||||||
mKeyCodeMap.put(Keyboard.CODE_SHORTCUT, R.string.spoken_description_mic);
|
mKeyCodeMap.put(Constants.CODE_SHORTCUT, R.string.spoken_description_mic);
|
||||||
mKeyCodeMap.put(Keyboard.CODE_SWITCH_ALPHA_SYMBOL, R.string.spoken_description_to_symbol);
|
mKeyCodeMap.put(Constants.CODE_SWITCH_ALPHA_SYMBOL, R.string.spoken_description_to_symbol);
|
||||||
mKeyCodeMap.put(Keyboard.CODE_TAB, R.string.spoken_description_tab);
|
mKeyCodeMap.put(Constants.CODE_TAB, R.string.spoken_description_tab);
|
||||||
mKeyCodeMap.put(Keyboard.CODE_LANGUAGE_SWITCH, R.string.spoken_description_language_switch);
|
mKeyCodeMap.put(Constants.CODE_LANGUAGE_SWITCH,
|
||||||
mKeyCodeMap.put(Keyboard.CODE_ACTION_NEXT, R.string.spoken_description_action_next);
|
R.string.spoken_description_language_switch);
|
||||||
mKeyCodeMap.put(Keyboard.CODE_ACTION_PREVIOUS, R.string.spoken_description_action_previous);
|
mKeyCodeMap.put(Constants.CODE_ACTION_NEXT, R.string.spoken_description_action_next);
|
||||||
|
mKeyCodeMap.put(Constants.CODE_ACTION_PREVIOUS,
|
||||||
|
R.string.spoken_description_action_previous);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -97,17 +100,17 @@ public final class KeyCodeDescriptionMapper {
|
||||||
boolean shouldObscure) {
|
boolean shouldObscure) {
|
||||||
final int code = key.mCode;
|
final int code = key.mCode;
|
||||||
|
|
||||||
if (code == Keyboard.CODE_SWITCH_ALPHA_SYMBOL) {
|
if (code == Constants.CODE_SWITCH_ALPHA_SYMBOL) {
|
||||||
final String description = getDescriptionForSwitchAlphaSymbol(context, keyboard);
|
final String description = getDescriptionForSwitchAlphaSymbol(context, keyboard);
|
||||||
if (description != null)
|
if (description != null)
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (code == Keyboard.CODE_SHIFT) {
|
if (code == Constants.CODE_SHIFT) {
|
||||||
return getDescriptionForShiftKey(context, keyboard);
|
return getDescriptionForShiftKey(context, keyboard);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (code == Keyboard.CODE_ACTION_ENTER) {
|
if (code == Constants.CODE_ACTION_ENTER) {
|
||||||
return getDescriptionForActionKey(context, keyboard, key);
|
return getDescriptionForActionKey(context, keyboard, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +124,7 @@ public final class KeyCodeDescriptionMapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Just attempt to speak the description.
|
// Just attempt to speak the description.
|
||||||
if (key.mCode != Keyboard.CODE_UNSPECIFIED) {
|
if (key.mCode != Constants.CODE_UNSPECIFIED) {
|
||||||
return getDescriptionForKeyCode(context, keyboard, key, shouldObscure);
|
return getDescriptionForKeyCode(context, keyboard, key, shouldObscure);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,11 +16,11 @@
|
||||||
|
|
||||||
package com.android.inputmethod.keyboard;
|
package com.android.inputmethod.keyboard;
|
||||||
|
|
||||||
import static com.android.inputmethod.keyboard.Keyboard.CODE_OUTPUT_TEXT;
|
|
||||||
import static com.android.inputmethod.keyboard.Keyboard.CODE_SHIFT;
|
|
||||||
import static com.android.inputmethod.keyboard.Keyboard.CODE_SWITCH_ALPHA_SYMBOL;
|
|
||||||
import static com.android.inputmethod.keyboard.Keyboard.CODE_UNSPECIFIED;
|
|
||||||
import static com.android.inputmethod.keyboard.internal.KeyboardIconsSet.ICON_UNDEFINED;
|
import static com.android.inputmethod.keyboard.internal.KeyboardIconsSet.ICON_UNDEFINED;
|
||||||
|
import static com.android.inputmethod.latin.Constants.CODE_OUTPUT_TEXT;
|
||||||
|
import static com.android.inputmethod.latin.Constants.CODE_SHIFT;
|
||||||
|
import static com.android.inputmethod.latin.Constants.CODE_SWITCH_ALPHA_SYMBOL;
|
||||||
|
import static com.android.inputmethod.latin.Constants.CODE_UNSPECIFIED;
|
||||||
|
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
|
@ -39,6 +39,7 @@ import com.android.inputmethod.keyboard.internal.KeyboardIconsSet;
|
||||||
import com.android.inputmethod.keyboard.internal.KeyboardParams;
|
import com.android.inputmethod.keyboard.internal.KeyboardParams;
|
||||||
import com.android.inputmethod.keyboard.internal.KeyboardRow;
|
import com.android.inputmethod.keyboard.internal.KeyboardRow;
|
||||||
import com.android.inputmethod.keyboard.internal.MoreKeySpec;
|
import com.android.inputmethod.keyboard.internal.MoreKeySpec;
|
||||||
|
import com.android.inputmethod.latin.Constants;
|
||||||
import com.android.inputmethod.latin.R;
|
import com.android.inputmethod.latin.R;
|
||||||
import com.android.inputmethod.latin.ResourceUtils;
|
import com.android.inputmethod.latin.ResourceUtils;
|
||||||
import com.android.inputmethod.latin.StringUtils;
|
import com.android.inputmethod.latin.StringUtils;
|
||||||
|
@ -453,7 +454,7 @@ public class Key implements Comparable<Key> {
|
||||||
label = "/" + mLabel;
|
label = "/" + mLabel;
|
||||||
}
|
}
|
||||||
return String.format("%s%s %d,%d %dx%d %s/%s/%s",
|
return String.format("%s%s %d,%d %dx%d %s/%s/%s",
|
||||||
Keyboard.printableCode(mCode), label, mX, mY, mWidth, mHeight, mHintLabel,
|
Constants.printableCode(mCode), label, mX, mY, mWidth, mHeight, mHintLabel,
|
||||||
KeyboardIconsSet.getIconName(mIconId), backgroundName(mBackgroundType));
|
KeyboardIconsSet.getIconName(mIconId), backgroundName(mBackgroundType));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -118,7 +118,7 @@ public class KeyDetector {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String printableCode(Key key) {
|
public static String printableCode(Key key) {
|
||||||
return key != null ? Keyboard.printableCode(key.mCode) : "none";
|
return key != null ? Constants.printableCode(key.mCode) : "none";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String printableCodes(int[] codes) {
|
public static String printableCodes(int[] codes) {
|
||||||
|
@ -127,7 +127,7 @@ public class KeyDetector {
|
||||||
for (final int code : codes) {
|
for (final int code : codes) {
|
||||||
if (code == Constants.NOT_A_CODE) break;
|
if (code == Constants.NOT_A_CODE) break;
|
||||||
if (addDelimiter) sb.append(", ");
|
if (addDelimiter) sb.append(", ");
|
||||||
sb.append(Keyboard.printableCode(code));
|
sb.append(Constants.printableCode(code));
|
||||||
addDelimiter = true;
|
addDelimiter = true;
|
||||||
}
|
}
|
||||||
return "[" + sb + "]";
|
return "[" + sb + "]";
|
||||||
|
|
|
@ -16,13 +16,13 @@
|
||||||
|
|
||||||
package com.android.inputmethod.keyboard;
|
package com.android.inputmethod.keyboard;
|
||||||
|
|
||||||
import android.util.Log;
|
|
||||||
import android.util.SparseArray;
|
import android.util.SparseArray;
|
||||||
|
|
||||||
import com.android.inputmethod.keyboard.internal.KeyVisualAttributes;
|
import com.android.inputmethod.keyboard.internal.KeyVisualAttributes;
|
||||||
import com.android.inputmethod.keyboard.internal.KeyboardIconsSet;
|
import com.android.inputmethod.keyboard.internal.KeyboardIconsSet;
|
||||||
import com.android.inputmethod.keyboard.internal.KeyboardParams;
|
import com.android.inputmethod.keyboard.internal.KeyboardParams;
|
||||||
import com.android.inputmethod.latin.CollectionUtils;
|
import com.android.inputmethod.latin.CollectionUtils;
|
||||||
|
import com.android.inputmethod.latin.Constants;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -45,46 +45,6 @@ import com.android.inputmethod.latin.CollectionUtils;
|
||||||
* </pre>
|
* </pre>
|
||||||
*/
|
*/
|
||||||
public class Keyboard {
|
public class Keyboard {
|
||||||
private static final String TAG = Keyboard.class.getSimpleName();
|
|
||||||
|
|
||||||
/** Some common keys code. Must be positive.
|
|
||||||
* These should be aligned with values/keycodes.xml
|
|
||||||
*/
|
|
||||||
public static final int CODE_ENTER = '\n';
|
|
||||||
public static final int CODE_TAB = '\t';
|
|
||||||
public static final int CODE_SPACE = ' ';
|
|
||||||
public static final int CODE_PERIOD = '.';
|
|
||||||
public static final int CODE_DASH = '-';
|
|
||||||
public static final int CODE_SINGLE_QUOTE = '\'';
|
|
||||||
public static final int CODE_DOUBLE_QUOTE = '"';
|
|
||||||
public static final int CODE_QUESTION_MARK = '?';
|
|
||||||
public static final int CODE_EXCLAMATION_MARK = '!';
|
|
||||||
// TODO: Check how this should work for right-to-left languages. It seems to stand
|
|
||||||
// that for rtl languages, a closing parenthesis is a left parenthesis. Is this
|
|
||||||
// managed by the font? Or is it a different char?
|
|
||||||
public static final int CODE_CLOSING_PARENTHESIS = ')';
|
|
||||||
public static final int CODE_CLOSING_SQUARE_BRACKET = ']';
|
|
||||||
public static final int CODE_CLOSING_CURLY_BRACKET = '}';
|
|
||||||
public static final int CODE_CLOSING_ANGLE_BRACKET = '>';
|
|
||||||
|
|
||||||
/** Special keys code. Must be negative.
|
|
||||||
* These should be aligned with KeyboardCodesSet.ID_TO_NAME[],
|
|
||||||
* KeyboardCodesSet.DEFAULT[] and KeyboardCodesSet.RTL[]
|
|
||||||
*/
|
|
||||||
public static final int CODE_SHIFT = -1;
|
|
||||||
public static final int CODE_SWITCH_ALPHA_SYMBOL = -2;
|
|
||||||
public static final int CODE_OUTPUT_TEXT = -3;
|
|
||||||
public static final int CODE_DELETE = -4;
|
|
||||||
public static final int CODE_SETTINGS = -5;
|
|
||||||
public static final int CODE_SHORTCUT = -6;
|
|
||||||
public static final int CODE_ACTION_ENTER = -7;
|
|
||||||
public static final int CODE_ACTION_NEXT = -8;
|
|
||||||
public static final int CODE_ACTION_PREVIOUS = -9;
|
|
||||||
public static final int CODE_LANGUAGE_SWITCH = -10;
|
|
||||||
public static final int CODE_RESEARCH = -11;
|
|
||||||
// Code value representing the code is not specified.
|
|
||||||
public static final int CODE_UNSPECIFIED = -12;
|
|
||||||
|
|
||||||
public final KeyboardId mId;
|
public final KeyboardId mId;
|
||||||
public final int mThemeId;
|
public final int mThemeId;
|
||||||
|
|
||||||
|
@ -163,7 +123,7 @@ public class Keyboard {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Key getKey(final int code) {
|
public Key getKey(final int code) {
|
||||||
if (code == CODE_UNSPECIFIED) {
|
if (code == Constants.CODE_UNSPECIFIED) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
synchronized (mKeyCache) {
|
synchronized (mKeyCache) {
|
||||||
|
@ -197,10 +157,6 @@ public class Keyboard {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isLetterCode(final int code) {
|
|
||||||
return code >= CODE_SPACE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return mId.toString();
|
return mId.toString();
|
||||||
|
@ -219,27 +175,4 @@ public class Keyboard {
|
||||||
final int adjustedY = Math.max(0, Math.min(y, mOccupiedHeight - 1));
|
final int adjustedY = Math.max(0, Math.min(y, mOccupiedHeight - 1));
|
||||||
return mProximityInfo.getNearestKeys(adjustedX, adjustedY);
|
return mProximityInfo.getNearestKeys(adjustedX, adjustedY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String printableCode(final int code) {
|
|
||||||
switch (code) {
|
|
||||||
case CODE_SHIFT: return "shift";
|
|
||||||
case CODE_SWITCH_ALPHA_SYMBOL: return "symbol";
|
|
||||||
case CODE_OUTPUT_TEXT: return "text";
|
|
||||||
case CODE_DELETE: return "delete";
|
|
||||||
case CODE_SETTINGS: return "settings";
|
|
||||||
case CODE_SHORTCUT: return "shortcut";
|
|
||||||
case CODE_ACTION_ENTER: return "actionEnter";
|
|
||||||
case CODE_ACTION_NEXT: return "actionNext";
|
|
||||||
case CODE_ACTION_PREVIOUS: return "actionPrevious";
|
|
||||||
case CODE_LANGUAGE_SWITCH: return "languageSwitch";
|
|
||||||
case CODE_UNSPECIFIED: return "unspec";
|
|
||||||
case CODE_TAB: return "tab";
|
|
||||||
case CODE_ENTER: return "enter";
|
|
||||||
default:
|
|
||||||
if (code <= 0) Log.w(TAG, "Unknown non-positive key code=" + code);
|
|
||||||
if (code < CODE_SPACE) return String.format("'\\u%02x'", code);
|
|
||||||
if (code < 0x100) return String.format("'%c'", code);
|
|
||||||
return String.format("'\\u%04x'", code);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -227,7 +227,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
cancelLongPressTimer();
|
cancelLongPressTimer();
|
||||||
final int delay;
|
final int delay;
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case Keyboard.CODE_SHIFT:
|
case Constants.CODE_SHIFT:
|
||||||
delay = mLongPressShiftKeyTimeout;
|
delay = mLongPressShiftKeyTimeout;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -248,7 +248,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
final Key key = tracker.getKey();
|
final Key key = tracker.getKey();
|
||||||
final int delay;
|
final int delay;
|
||||||
switch (key.mCode) {
|
switch (key.mCode) {
|
||||||
case Keyboard.CODE_SHIFT:
|
case Constants.CODE_SHIFT:
|
||||||
delay = mLongPressShiftKeyTimeout;
|
delay = mLongPressShiftKeyTimeout;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -305,7 +305,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
|
|
||||||
// When user hits the space or the enter key, just cancel the while-typing timer.
|
// When user hits the space or the enter key, just cancel the while-typing timer.
|
||||||
final int typedCode = typedKey.mCode;
|
final int typedCode = typedKey.mCode;
|
||||||
if (typedCode == Keyboard.CODE_SPACE || typedCode == Keyboard.CODE_ENTER) {
|
if (typedCode == Constants.CODE_SPACE || typedCode == Constants.CODE_ENTER) {
|
||||||
startWhileTypingFadeinAnimation(keyboardView);
|
startWhileTypingFadeinAnimation(keyboardView);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -487,7 +487,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
mTouchScreenRegulator.setKeyboard(keyboard);
|
mTouchScreenRegulator.setKeyboard(keyboard);
|
||||||
mMoreKeysPanelCache.clear();
|
mMoreKeysPanelCache.clear();
|
||||||
|
|
||||||
mSpaceKey = keyboard.getKey(Keyboard.CODE_SPACE);
|
mSpaceKey = keyboard.getKey(Constants.CODE_SPACE);
|
||||||
mSpaceIcon = (mSpaceKey != null)
|
mSpaceIcon = (mSpaceKey != null)
|
||||||
? mSpaceKey.getIcon(keyboard.mIconsSet, Constants.Color.ALPHA_OPAQUE) : null;
|
? mSpaceKey.getIcon(keyboard.mIconsSet, Constants.Color.ALPHA_OPAQUE) : null;
|
||||||
final int keyHeight = keyboard.mMostCommonKeyHeight - keyboard.mVerticalGap;
|
final int keyHeight = keyboard.mMostCommonKeyHeight - keyboard.mVerticalGap;
|
||||||
|
@ -604,7 +604,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
KeyboardSwitcher.getInstance().hapticAndAudioFeedback(primaryCode);
|
KeyboardSwitcher.getInstance().hapticAndAudioFeedback(primaryCode);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (primaryCode == Keyboard.CODE_SPACE || primaryCode == Keyboard.CODE_LANGUAGE_SWITCH) {
|
if (primaryCode == Constants.CODE_SPACE || primaryCode == Constants.CODE_LANGUAGE_SWITCH) {
|
||||||
// Long pressing the space key invokes IME switcher dialog.
|
// Long pressing the space key invokes IME switcher dialog.
|
||||||
if (invokeCustomRequest(LatinIME.CODE_SHOW_INPUT_METHOD_PICKER)) {
|
if (invokeCustomRequest(LatinIME.CODE_SHOW_INPUT_METHOD_PICKER)) {
|
||||||
tracker.onLongPressed();
|
tracker.onLongPressed();
|
||||||
|
@ -875,7 +875,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
public void updateShortcutKey(final boolean available) {
|
public void updateShortcutKey(final boolean available) {
|
||||||
final Keyboard keyboard = getKeyboard();
|
final Keyboard keyboard = getKeyboard();
|
||||||
if (keyboard == null) return;
|
if (keyboard == null) return;
|
||||||
final Key shortcutKey = keyboard.getKey(Keyboard.CODE_SHORTCUT);
|
final Key shortcutKey = keyboard.getKey(Constants.CODE_SHORTCUT);
|
||||||
if (shortcutKey == null) return;
|
if (shortcutKey == null) return;
|
||||||
shortcutKey.setEnabled(available);
|
shortcutKey.setEnabled(available);
|
||||||
invalidateKey(shortcutKey);
|
invalidateKey(shortcutKey);
|
||||||
|
@ -924,13 +924,13 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
if (key.altCodeWhileTyping() && key.isEnabled()) {
|
if (key.altCodeWhileTyping() && key.isEnabled()) {
|
||||||
params.mAnimAlpha = mAltCodeKeyWhileTypingAnimAlpha;
|
params.mAnimAlpha = mAltCodeKeyWhileTypingAnimAlpha;
|
||||||
}
|
}
|
||||||
if (key.mCode == Keyboard.CODE_SPACE) {
|
if (key.mCode == Constants.CODE_SPACE) {
|
||||||
drawSpacebar(key, canvas, paint);
|
drawSpacebar(key, canvas, paint);
|
||||||
// Whether space key needs to show the "..." popup hint for special purposes
|
// Whether space key needs to show the "..." popup hint for special purposes
|
||||||
if (key.isLongPressEnabled() && mHasMultipleEnabledIMEsOrSubtypes) {
|
if (key.isLongPressEnabled() && mHasMultipleEnabledIMEsOrSubtypes) {
|
||||||
drawKeyPopupHint(key, canvas, paint, params);
|
drawKeyPopupHint(key, canvas, paint, params);
|
||||||
}
|
}
|
||||||
} else if (key.mCode == Keyboard.CODE_LANGUAGE_SWITCH) {
|
} else if (key.mCode == Constants.CODE_LANGUAGE_SWITCH) {
|
||||||
super.onDrawKeyTopVisuals(key, canvas, paint, params);
|
super.onDrawKeyTopVisuals(key, canvas, paint, params);
|
||||||
drawKeyPopupHint(key, canvas, paint, params);
|
drawKeyPopupHint(key, canvas, paint, params);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -27,6 +27,7 @@ import com.android.inputmethod.keyboard.internal.GestureStroke.GestureStrokePara
|
||||||
import com.android.inputmethod.keyboard.internal.GestureStrokeWithPreviewPoints;
|
import com.android.inputmethod.keyboard.internal.GestureStrokeWithPreviewPoints;
|
||||||
import com.android.inputmethod.keyboard.internal.PointerTrackerQueue;
|
import com.android.inputmethod.keyboard.internal.PointerTrackerQueue;
|
||||||
import com.android.inputmethod.latin.CollectionUtils;
|
import com.android.inputmethod.latin.CollectionUtils;
|
||||||
|
import com.android.inputmethod.latin.Constants;
|
||||||
import com.android.inputmethod.latin.InputPointers;
|
import com.android.inputmethod.latin.InputPointers;
|
||||||
import com.android.inputmethod.latin.LatinImeLogger;
|
import com.android.inputmethod.latin.LatinImeLogger;
|
||||||
import com.android.inputmethod.latin.R;
|
import com.android.inputmethod.latin.R;
|
||||||
|
@ -453,8 +454,8 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
final boolean altersCode = key.altCodeWhileTyping() && mTimerProxy.isTypingState();
|
final boolean altersCode = key.altCodeWhileTyping() && mTimerProxy.isTypingState();
|
||||||
final int code = altersCode ? key.getAltCode() : primaryCode;
|
final int code = altersCode ? key.getAltCode() : primaryCode;
|
||||||
if (DEBUG_LISTENER) {
|
if (DEBUG_LISTENER) {
|
||||||
final String output = code == Keyboard.CODE_OUTPUT_TEXT
|
final String output = code == Constants.CODE_OUTPUT_TEXT
|
||||||
? key.getOutputText() : Keyboard.printableCode(code);
|
? key.getOutputText() : Constants.printableCode(code);
|
||||||
Log.d(TAG, String.format("[%d] onCodeInput: %4d %4d %s%s%s", mPointerId, x, y,
|
Log.d(TAG, String.format("[%d] onCodeInput: %4d %4d %s%s%s", mPointerId, x, y,
|
||||||
output, ignoreModifierKey ? " ignoreModifier" : "",
|
output, ignoreModifierKey ? " ignoreModifier" : "",
|
||||||
altersCode ? " altersCode" : "", key.isEnabled() ? "" : " disabled"));
|
altersCode ? " altersCode" : "", key.isEnabled() ? "" : " disabled"));
|
||||||
|
@ -469,9 +470,9 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
// Even if the key is disabled, it should respond if it is in the altCodeWhileTyping state.
|
// Even if the key is disabled, it should respond if it is in the altCodeWhileTyping state.
|
||||||
if (key.isEnabled() || altersCode) {
|
if (key.isEnabled() || altersCode) {
|
||||||
sTimeRecorder.onCodeInput(code, eventTime);
|
sTimeRecorder.onCodeInput(code, eventTime);
|
||||||
if (code == Keyboard.CODE_OUTPUT_TEXT) {
|
if (code == Constants.CODE_OUTPUT_TEXT) {
|
||||||
mListener.onTextInput(key.getOutputText());
|
mListener.onTextInput(key.getOutputText());
|
||||||
} else if (code != Keyboard.CODE_UNSPECIFIED) {
|
} else if (code != Constants.CODE_UNSPECIFIED) {
|
||||||
mListener.onCodeInput(code, x, y);
|
mListener.onCodeInput(code, x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -487,7 +488,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
final boolean ignoreModifierKey = mIsInSlidingKeyInputFromModifier && key.isModifier();
|
final boolean ignoreModifierKey = mIsInSlidingKeyInputFromModifier && key.isModifier();
|
||||||
if (DEBUG_LISTENER) {
|
if (DEBUG_LISTENER) {
|
||||||
Log.d(TAG, String.format("[%d] onRelease : %s%s%s%s", mPointerId,
|
Log.d(TAG, String.format("[%d] onRelease : %s%s%s%s", mPointerId,
|
||||||
Keyboard.printableCode(primaryCode),
|
Constants.printableCode(primaryCode),
|
||||||
withSliding ? " sliding" : "", ignoreModifierKey ? " ignoreModifier" : "",
|
withSliding ? " sliding" : "", ignoreModifierKey ? " ignoreModifier" : "",
|
||||||
key.isEnabled() ? "": " disabled"));
|
key.isEnabled() ? "": " disabled"));
|
||||||
}
|
}
|
||||||
|
@ -952,8 +953,8 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
+ " phantom sudden move event (distance=%d) is translated to "
|
+ " phantom sudden move event (distance=%d) is translated to "
|
||||||
+ "up[%d,%d,%s]/down[%d,%d,%s] events", mPointerId,
|
+ "up[%d,%d,%s]/down[%d,%d,%s] events", mPointerId,
|
||||||
getDistance(x, y, lastX, lastY),
|
getDistance(x, y, lastX, lastY),
|
||||||
lastX, lastY, Keyboard.printableCode(oldKey.mCode),
|
lastX, lastY, Constants.printableCode(oldKey.mCode),
|
||||||
x, y, Keyboard.printableCode(key.mCode)));
|
x, y, Constants.printableCode(key.mCode)));
|
||||||
}
|
}
|
||||||
// TODO: This should be moved to outside of this nested if-clause?
|
// TODO: This should be moved to outside of this nested if-clause?
|
||||||
if (ProductionFlag.IS_EXPERIMENTAL) {
|
if (ProductionFlag.IS_EXPERIMENTAL) {
|
||||||
|
@ -978,8 +979,8 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
+ " bogus down-move-up event (raidus=%.2f key diagonal) is "
|
+ " bogus down-move-up event (raidus=%.2f key diagonal) is "
|
||||||
+ " translated to up[%d,%d,%s]/down[%d,%d,%s] events",
|
+ " translated to up[%d,%d,%s]/down[%d,%d,%s] events",
|
||||||
mPointerId, radiusRatio,
|
mPointerId, radiusRatio,
|
||||||
lastX, lastY, Keyboard.printableCode(oldKey.mCode),
|
lastX, lastY, Constants.printableCode(oldKey.mCode),
|
||||||
x, y, Keyboard.printableCode(key.mCode)));
|
x, y, Constants.printableCode(key.mCode)));
|
||||||
}
|
}
|
||||||
onUpEventInternal(eventTime);
|
onUpEventInternal(eventTime);
|
||||||
onDownEventInternal(x, y, eventTime);
|
onDownEventInternal(x, y, eventTime);
|
||||||
|
|
|
@ -172,7 +172,8 @@ public final class ProximityInfo {
|
||||||
Log.d(TAG, String.format(
|
Log.d(TAG, String.format(
|
||||||
" [%2d] row=%d x/y/r=%7.2f/%7.2f/%5.2f %s code=%s", i, row,
|
" [%2d] row=%d x/y/r=%7.2f/%7.2f/%5.2f %s code=%s", i, row,
|
||||||
sweetSpotCenterXs[i], sweetSpotCenterYs[i], sweetSpotRadii[i],
|
sweetSpotCenterXs[i], sweetSpotCenterYs[i], sweetSpotRadii[i],
|
||||||
row < rows ? "correct" : "default", Keyboard.printableCode(key.mCode)));
|
(row < rows ? "correct" : "default"),
|
||||||
|
Constants.printableCode(key.mCode)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -238,7 +239,7 @@ public final class ProximityInfo {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int index = 0;
|
int index = 0;
|
||||||
if (primaryKeyCode > Keyboard.CODE_SPACE) {
|
if (primaryKeyCode > Constants.CODE_SPACE) {
|
||||||
dest[index++] = primaryKeyCode;
|
dest[index++] = primaryKeyCode;
|
||||||
}
|
}
|
||||||
final Key[] nearestKeys = getNearestKeys(x, y);
|
final Key[] nearestKeys = getNearestKeys(x, y);
|
||||||
|
@ -247,7 +248,7 @@ public final class ProximityInfo {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
final int code = key.mCode;
|
final int code = key.mCode;
|
||||||
if (code <= Keyboard.CODE_SPACE) {
|
if (code <= Constants.CODE_SPACE) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
dest[index++] = code;
|
dest[index++] = code;
|
||||||
|
|
|
@ -16,12 +16,13 @@
|
||||||
|
|
||||||
package com.android.inputmethod.keyboard.internal;
|
package com.android.inputmethod.keyboard.internal;
|
||||||
|
|
||||||
import static com.android.inputmethod.keyboard.Keyboard.CODE_UNSPECIFIED;
|
import static com.android.inputmethod.latin.Constants.CODE_OUTPUT_TEXT;
|
||||||
|
import static com.android.inputmethod.latin.Constants.CODE_UNSPECIFIED;
|
||||||
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import com.android.inputmethod.keyboard.Keyboard;
|
|
||||||
import com.android.inputmethod.latin.CollectionUtils;
|
import com.android.inputmethod.latin.CollectionUtils;
|
||||||
|
import com.android.inputmethod.latin.Constants;
|
||||||
import com.android.inputmethod.latin.LatinImeLogger;
|
import com.android.inputmethod.latin.LatinImeLogger;
|
||||||
import com.android.inputmethod.latin.StringUtils;
|
import com.android.inputmethod.latin.StringUtils;
|
||||||
|
|
||||||
|
@ -172,7 +173,7 @@ public final class KeySpecParser {
|
||||||
if (indexOfLabelEnd(moreKeySpec, end + 1) >= 0) {
|
if (indexOfLabelEnd(moreKeySpec, end + 1) >= 0) {
|
||||||
throw new KeySpecParserError("Multiple " + LABEL_END + ": " + moreKeySpec);
|
throw new KeySpecParserError("Multiple " + LABEL_END + ": " + moreKeySpec);
|
||||||
}
|
}
|
||||||
return parseCode(moreKeySpec.substring(end + 1), codesSet, Keyboard.CODE_UNSPECIFIED);
|
return parseCode(moreKeySpec.substring(end + 1), codesSet, CODE_UNSPECIFIED);
|
||||||
}
|
}
|
||||||
final String outputText = getOutputTextInternal(moreKeySpec);
|
final String outputText = getOutputTextInternal(moreKeySpec);
|
||||||
if (outputText != null) {
|
if (outputText != null) {
|
||||||
|
@ -181,14 +182,14 @@ public final class KeySpecParser {
|
||||||
if (StringUtils.codePointCount(outputText) == 1) {
|
if (StringUtils.codePointCount(outputText) == 1) {
|
||||||
return outputText.codePointAt(0);
|
return outputText.codePointAt(0);
|
||||||
}
|
}
|
||||||
return Keyboard.CODE_OUTPUT_TEXT;
|
return CODE_OUTPUT_TEXT;
|
||||||
}
|
}
|
||||||
final String label = getLabel(moreKeySpec);
|
final String label = getLabel(moreKeySpec);
|
||||||
// Code is automatically generated for one letter label.
|
// Code is automatically generated for one letter label.
|
||||||
if (StringUtils.codePointCount(label) == 1) {
|
if (StringUtils.codePointCount(label) == 1) {
|
||||||
return label.codePointAt(0);
|
return label.codePointAt(0);
|
||||||
}
|
}
|
||||||
return Keyboard.CODE_OUTPUT_TEXT;
|
return CODE_OUTPUT_TEXT;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int parseCode(final String text, final KeyboardCodesSet codesSet,
|
public static int parseCode(final String text, final KeyboardCodesSet codesSet,
|
||||||
|
@ -468,7 +469,7 @@ public final class KeySpecParser {
|
||||||
|
|
||||||
public static int toUpperCaseOfCodeForLocale(final int code, final boolean needsToUpperCase,
|
public static int toUpperCaseOfCodeForLocale(final int code, final boolean needsToUpperCase,
|
||||||
final Locale locale) {
|
final Locale locale) {
|
||||||
if (!Keyboard.isLetterCode(code) || !needsToUpperCase) return code;
|
if (!Constants.isLetterCode(code) || !needsToUpperCase) return code;
|
||||||
final String text = new String(new int[] { code } , 0, 1);
|
final String text = new String(new int[] { code } , 0, 1);
|
||||||
final String casedText = KeySpecParser.toUpperCaseOfStringForLocale(
|
final String casedText = KeySpecParser.toUpperCaseOfStringForLocale(
|
||||||
text, needsToUpperCase, locale);
|
text, needsToUpperCase, locale);
|
||||||
|
|
|
@ -16,8 +16,8 @@
|
||||||
|
|
||||||
package com.android.inputmethod.keyboard.internal;
|
package com.android.inputmethod.keyboard.internal;
|
||||||
|
|
||||||
import com.android.inputmethod.keyboard.Keyboard;
|
|
||||||
import com.android.inputmethod.latin.CollectionUtils;
|
import com.android.inputmethod.latin.CollectionUtils;
|
||||||
|
import com.android.inputmethod.latin.Constants;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
@ -74,21 +74,21 @@ public final class KeyboardCodesSet {
|
||||||
private static final int CODE_RIGHT_CURLY_BRACKET = '}';
|
private static final int CODE_RIGHT_CURLY_BRACKET = '}';
|
||||||
|
|
||||||
private static final int[] DEFAULT = {
|
private static final int[] DEFAULT = {
|
||||||
Keyboard.CODE_TAB,
|
Constants.CODE_TAB,
|
||||||
Keyboard.CODE_ENTER,
|
Constants.CODE_ENTER,
|
||||||
Keyboard.CODE_SPACE,
|
Constants.CODE_SPACE,
|
||||||
Keyboard.CODE_SHIFT,
|
Constants.CODE_SHIFT,
|
||||||
Keyboard.CODE_SWITCH_ALPHA_SYMBOL,
|
Constants.CODE_SWITCH_ALPHA_SYMBOL,
|
||||||
Keyboard.CODE_OUTPUT_TEXT,
|
Constants.CODE_OUTPUT_TEXT,
|
||||||
Keyboard.CODE_DELETE,
|
Constants.CODE_DELETE,
|
||||||
Keyboard.CODE_SETTINGS,
|
Constants.CODE_SETTINGS,
|
||||||
Keyboard.CODE_SHORTCUT,
|
Constants.CODE_SHORTCUT,
|
||||||
Keyboard.CODE_ACTION_ENTER,
|
Constants.CODE_ACTION_ENTER,
|
||||||
Keyboard.CODE_ACTION_NEXT,
|
Constants.CODE_ACTION_NEXT,
|
||||||
Keyboard.CODE_ACTION_PREVIOUS,
|
Constants.CODE_ACTION_PREVIOUS,
|
||||||
Keyboard.CODE_LANGUAGE_SWITCH,
|
Constants.CODE_LANGUAGE_SWITCH,
|
||||||
Keyboard.CODE_RESEARCH,
|
Constants.CODE_RESEARCH,
|
||||||
Keyboard.CODE_UNSPECIFIED,
|
Constants.CODE_UNSPECIFIED,
|
||||||
CODE_LEFT_PARENTHESIS,
|
CODE_LEFT_PARENTHESIS,
|
||||||
CODE_RIGHT_PARENTHESIS,
|
CODE_RIGHT_PARENTHESIS,
|
||||||
CODE_LESS_THAN_SIGN,
|
CODE_LESS_THAN_SIGN,
|
||||||
|
|
|
@ -19,9 +19,9 @@ package com.android.inputmethod.keyboard.internal;
|
||||||
import android.util.SparseIntArray;
|
import android.util.SparseIntArray;
|
||||||
|
|
||||||
import com.android.inputmethod.keyboard.Key;
|
import com.android.inputmethod.keyboard.Key;
|
||||||
import com.android.inputmethod.keyboard.Keyboard;
|
|
||||||
import com.android.inputmethod.keyboard.KeyboardId;
|
import com.android.inputmethod.keyboard.KeyboardId;
|
||||||
import com.android.inputmethod.latin.CollectionUtils;
|
import com.android.inputmethod.latin.CollectionUtils;
|
||||||
|
import com.android.inputmethod.latin.Constants;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
@ -89,7 +89,7 @@ public class KeyboardParams {
|
||||||
mKeys.add(key);
|
mKeys.add(key);
|
||||||
updateHistogram(key);
|
updateHistogram(key);
|
||||||
}
|
}
|
||||||
if (key.mCode == Keyboard.CODE_SHIFT) {
|
if (key.mCode == Constants.CODE_SHIFT) {
|
||||||
mShiftKeys.add(key);
|
mShiftKeys.add(key);
|
||||||
}
|
}
|
||||||
if (key.altCodeWhileTyping()) {
|
if (key.altCodeWhileTyping()) {
|
||||||
|
|
|
@ -19,7 +19,6 @@ package com.android.inputmethod.keyboard.internal;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.android.inputmethod.keyboard.Keyboard;
|
|
||||||
import com.android.inputmethod.latin.Constants;
|
import com.android.inputmethod.latin.Constants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -300,12 +299,12 @@ public final class KeyboardState {
|
||||||
|
|
||||||
public void onPressKey(int code, boolean isSinglePointer, int autoCaps) {
|
public void onPressKey(int code, boolean isSinglePointer, int autoCaps) {
|
||||||
if (DEBUG_EVENT) {
|
if (DEBUG_EVENT) {
|
||||||
Log.d(TAG, "onPressKey: code=" + Keyboard.printableCode(code)
|
Log.d(TAG, "onPressKey: code=" + Constants.printableCode(code)
|
||||||
+ " single=" + isSinglePointer + " autoCaps=" + autoCaps + " " + this);
|
+ " single=" + isSinglePointer + " autoCaps=" + autoCaps + " " + this);
|
||||||
}
|
}
|
||||||
if (code == Keyboard.CODE_SHIFT) {
|
if (code == Constants.CODE_SHIFT) {
|
||||||
onPressShift();
|
onPressShift();
|
||||||
} else if (code == Keyboard.CODE_SWITCH_ALPHA_SYMBOL) {
|
} else if (code == Constants.CODE_SWITCH_ALPHA_SYMBOL) {
|
||||||
onPressSymbol();
|
onPressSymbol();
|
||||||
} else {
|
} else {
|
||||||
mSwitchActions.cancelDoubleTapTimer();
|
mSwitchActions.cancelDoubleTapTimer();
|
||||||
|
@ -333,12 +332,12 @@ public final class KeyboardState {
|
||||||
|
|
||||||
public void onReleaseKey(int code, boolean withSliding) {
|
public void onReleaseKey(int code, boolean withSliding) {
|
||||||
if (DEBUG_EVENT) {
|
if (DEBUG_EVENT) {
|
||||||
Log.d(TAG, "onReleaseKey: code=" + Keyboard.printableCode(code)
|
Log.d(TAG, "onReleaseKey: code=" + Constants.printableCode(code)
|
||||||
+ " sliding=" + withSliding + " " + this);
|
+ " sliding=" + withSliding + " " + this);
|
||||||
}
|
}
|
||||||
if (code == Keyboard.CODE_SHIFT) {
|
if (code == Constants.CODE_SHIFT) {
|
||||||
onReleaseShift(withSliding);
|
onReleaseShift(withSliding);
|
||||||
} else if (code == Keyboard.CODE_SWITCH_ALPHA_SYMBOL) {
|
} else if (code == Constants.CODE_SWITCH_ALPHA_SYMBOL) {
|
||||||
onReleaseSymbol(withSliding);
|
onReleaseSymbol(withSliding);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -365,9 +364,9 @@ public final class KeyboardState {
|
||||||
|
|
||||||
public void onLongPressTimeout(int code) {
|
public void onLongPressTimeout(int code) {
|
||||||
if (DEBUG_EVENT) {
|
if (DEBUG_EVENT) {
|
||||||
Log.d(TAG, "onLongPressTimeout: code=" + Keyboard.printableCode(code) + " " + this);
|
Log.d(TAG, "onLongPressTimeout: code=" + Constants.printableCode(code) + " " + this);
|
||||||
}
|
}
|
||||||
if (mIsAlphabetMode && code == Keyboard.CODE_SHIFT) {
|
if (mIsAlphabetMode && code == Constants.CODE_SHIFT) {
|
||||||
mLongPressShiftLockFired = true;
|
mLongPressShiftLockFired = true;
|
||||||
mSwitchActions.hapticAndAudioFeedback(code);
|
mSwitchActions.hapticAndAudioFeedback(code);
|
||||||
}
|
}
|
||||||
|
@ -434,7 +433,7 @@ public final class KeyboardState {
|
||||||
setShifted(MANUAL_SHIFT);
|
setShifted(MANUAL_SHIFT);
|
||||||
mShiftKeyState.onPress();
|
mShiftKeyState.onPress();
|
||||||
}
|
}
|
||||||
mSwitchActions.startLongPressTimer(Keyboard.CODE_SHIFT);
|
mSwitchActions.startLongPressTimer(Constants.CODE_SHIFT);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// In symbol mode, just toggle symbol and symbol more keyboard.
|
// In symbol mode, just toggle symbol and symbol more keyboard.
|
||||||
|
@ -514,7 +513,7 @@ public final class KeyboardState {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isSpaceCharacter(int c) {
|
private static boolean isSpaceCharacter(int c) {
|
||||||
return c == Keyboard.CODE_SPACE || c == Keyboard.CODE_ENTER;
|
return c == Constants.CODE_SPACE || c == Constants.CODE_ENTER;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isLayoutSwitchBackCharacter(int c) {
|
private boolean isLayoutSwitchBackCharacter(int c) {
|
||||||
|
@ -525,14 +524,14 @@ public final class KeyboardState {
|
||||||
|
|
||||||
public void onCodeInput(int code, boolean isSinglePointer, int autoCaps) {
|
public void onCodeInput(int code, boolean isSinglePointer, int autoCaps) {
|
||||||
if (DEBUG_EVENT) {
|
if (DEBUG_EVENT) {
|
||||||
Log.d(TAG, "onCodeInput: code=" + Keyboard.printableCode(code)
|
Log.d(TAG, "onCodeInput: code=" + Constants.printableCode(code)
|
||||||
+ " single=" + isSinglePointer
|
+ " single=" + isSinglePointer
|
||||||
+ " autoCaps=" + autoCaps + " " + this);
|
+ " autoCaps=" + autoCaps + " " + this);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (mSwitchState) {
|
switch (mSwitchState) {
|
||||||
case SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL:
|
case SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL:
|
||||||
if (code == Keyboard.CODE_SWITCH_ALPHA_SYMBOL) {
|
if (code == Constants.CODE_SWITCH_ALPHA_SYMBOL) {
|
||||||
// Detected only the mode change key has been pressed, and then released.
|
// Detected only the mode change key has been pressed, and then released.
|
||||||
if (mIsAlphabetMode) {
|
if (mIsAlphabetMode) {
|
||||||
mSwitchState = SWITCH_STATE_ALPHA;
|
mSwitchState = SWITCH_STATE_ALPHA;
|
||||||
|
@ -548,7 +547,7 @@ public final class KeyboardState {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SWITCH_STATE_MOMENTARY_SYMBOL_AND_MORE:
|
case SWITCH_STATE_MOMENTARY_SYMBOL_AND_MORE:
|
||||||
if (code == Keyboard.CODE_SHIFT) {
|
if (code == Constants.CODE_SHIFT) {
|
||||||
// Detected only the shift key has been pressed on symbol layout, and then released.
|
// Detected only the shift key has been pressed on symbol layout, and then released.
|
||||||
mSwitchState = SWITCH_STATE_SYMBOL_BEGIN;
|
mSwitchState = SWITCH_STATE_SYMBOL_BEGIN;
|
||||||
} else if (isSinglePointer) {
|
} else if (isSinglePointer) {
|
||||||
|
@ -559,8 +558,8 @@ public final class KeyboardState {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SWITCH_STATE_SYMBOL_BEGIN:
|
case SWITCH_STATE_SYMBOL_BEGIN:
|
||||||
if (!isSpaceCharacter(code) && (Keyboard.isLetterCode(code)
|
if (!isSpaceCharacter(code) && (Constants.isLetterCode(code)
|
||||||
|| code == Keyboard.CODE_OUTPUT_TEXT)) {
|
|| code == Constants.CODE_OUTPUT_TEXT)) {
|
||||||
mSwitchState = SWITCH_STATE_SYMBOL;
|
mSwitchState = SWITCH_STATE_SYMBOL;
|
||||||
}
|
}
|
||||||
// Switch back to alpha keyboard mode immediately if user types one of the switch back
|
// Switch back to alpha keyboard mode immediately if user types one of the switch back
|
||||||
|
@ -581,7 +580,7 @@ public final class KeyboardState {
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the code is a letter, update keyboard shift state.
|
// If the code is a letter, update keyboard shift state.
|
||||||
if (Keyboard.isLetterCode(code)) {
|
if (Constants.isLetterCode(code)) {
|
||||||
updateAlphabetShiftState(autoCaps);
|
updateAlphabetShiftState(autoCaps);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ package com.android.inputmethod.keyboard.internal;
|
||||||
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import com.android.inputmethod.keyboard.Keyboard;
|
import com.android.inputmethod.latin.Constants;
|
||||||
import com.android.inputmethod.latin.StringUtils;
|
import com.android.inputmethod.latin.StringUtils;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
@ -35,10 +35,10 @@ public final class MoreKeySpec {
|
||||||
KeySpecParser.getLabel(moreKeySpec), needsToUpperCase, locale);
|
KeySpecParser.getLabel(moreKeySpec), needsToUpperCase, locale);
|
||||||
final int code = KeySpecParser.toUpperCaseOfCodeForLocale(
|
final int code = KeySpecParser.toUpperCaseOfCodeForLocale(
|
||||||
KeySpecParser.getCode(moreKeySpec, codesSet), needsToUpperCase, locale);
|
KeySpecParser.getCode(moreKeySpec, codesSet), needsToUpperCase, locale);
|
||||||
if (code == Keyboard.CODE_UNSPECIFIED) {
|
if (code == Constants.CODE_UNSPECIFIED) {
|
||||||
// Some letter, for example German Eszett (U+00DF: "ß"), has multiple characters
|
// Some letter, for example German Eszett (U+00DF: "ß"), has multiple characters
|
||||||
// upper case representation ("SS").
|
// upper case representation ("SS").
|
||||||
mCode = Keyboard.CODE_OUTPUT_TEXT;
|
mCode = Constants.CODE_OUTPUT_TEXT;
|
||||||
mOutputText = mLabel;
|
mOutputText = mLabel;
|
||||||
} else {
|
} else {
|
||||||
mCode = code;
|
mCode = code;
|
||||||
|
@ -75,8 +75,8 @@ public final class MoreKeySpec {
|
||||||
public String toString() {
|
public String toString() {
|
||||||
final String label = (mIconId == KeyboardIconsSet.ICON_UNDEFINED ? mLabel
|
final String label = (mIconId == KeyboardIconsSet.ICON_UNDEFINED ? mLabel
|
||||||
: KeySpecParser.PREFIX_ICON + KeyboardIconsSet.getIconName(mIconId));
|
: KeySpecParser.PREFIX_ICON + KeyboardIconsSet.getIconName(mIconId));
|
||||||
final String output = (mCode == Keyboard.CODE_OUTPUT_TEXT ? mOutputText
|
final String output = (mCode == Constants.CODE_OUTPUT_TEXT ? mOutputText
|
||||||
: Keyboard.printableCode(mCode));
|
: Constants.printableCode(mCode));
|
||||||
if (StringUtils.codePointCount(label) == 1 && label.codePointAt(0) == mCode) {
|
if (StringUtils.codePointCount(label) == 1 && label.codePointAt(0) == mCode) {
|
||||||
return output;
|
return output;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -21,7 +21,6 @@ import android.media.AudioManager;
|
||||||
import android.view.HapticFeedbackConstants;
|
import android.view.HapticFeedbackConstants;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import com.android.inputmethod.keyboard.Keyboard;
|
|
||||||
import com.android.inputmethod.latin.VibratorUtils;
|
import com.android.inputmethod.latin.VibratorUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -62,13 +61,13 @@ public final class AudioAndHapticFeedbackManager {
|
||||||
if (mSoundOn) {
|
if (mSoundOn) {
|
||||||
final int sound;
|
final int sound;
|
||||||
switch (primaryCode) {
|
switch (primaryCode) {
|
||||||
case Keyboard.CODE_DELETE:
|
case Constants.CODE_DELETE:
|
||||||
sound = AudioManager.FX_KEYPRESS_DELETE;
|
sound = AudioManager.FX_KEYPRESS_DELETE;
|
||||||
break;
|
break;
|
||||||
case Keyboard.CODE_ENTER:
|
case Constants.CODE_ENTER:
|
||||||
sound = AudioManager.FX_KEYPRESS_RETURN;
|
sound = AudioManager.FX_KEYPRESS_RETURN;
|
||||||
break;
|
break;
|
||||||
case Keyboard.CODE_SPACE:
|
case Constants.CODE_SPACE:
|
||||||
sound = AudioManager.FX_KEYPRESS_SPACEBAR;
|
sound = AudioManager.FX_KEYPRESS_SPACEBAR;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -16,7 +16,11 @@
|
||||||
|
|
||||||
package com.android.inputmethod.latin;
|
package com.android.inputmethod.latin;
|
||||||
|
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
public final class Constants {
|
public final class Constants {
|
||||||
|
private static final String TAG = Constants.class.getSimpleName();
|
||||||
|
|
||||||
public static final class Color {
|
public static final class Color {
|
||||||
/**
|
/**
|
||||||
* The alpha value for fully opaque.
|
* The alpha value for fully opaque.
|
||||||
|
@ -141,6 +145,72 @@ public final class Constants {
|
||||||
public static final int SUGGESTION_STRIP_COORDINATE = -2;
|
public static final int SUGGESTION_STRIP_COORDINATE = -2;
|
||||||
public static final int SPELL_CHECKER_COORDINATE = -3;
|
public static final int SPELL_CHECKER_COORDINATE = -3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Some common keys code. Must be positive.
|
||||||
|
*/
|
||||||
|
public static final int CODE_ENTER = '\n';
|
||||||
|
public static final int CODE_TAB = '\t';
|
||||||
|
public static final int CODE_SPACE = ' ';
|
||||||
|
public static final int CODE_PERIOD = '.';
|
||||||
|
public static final int CODE_DASH = '-';
|
||||||
|
public static final int CODE_SINGLE_QUOTE = '\'';
|
||||||
|
public static final int CODE_DOUBLE_QUOTE = '"';
|
||||||
|
public static final int CODE_QUESTION_MARK = '?';
|
||||||
|
public static final int CODE_EXCLAMATION_MARK = '!';
|
||||||
|
// TODO: Check how this should work for right-to-left languages. It seems to stand
|
||||||
|
// that for rtl languages, a closing parenthesis is a left parenthesis. Is this
|
||||||
|
// managed by the font? Or is it a different char?
|
||||||
|
public static final int CODE_CLOSING_PARENTHESIS = ')';
|
||||||
|
public static final int CODE_CLOSING_SQUARE_BRACKET = ']';
|
||||||
|
public static final int CODE_CLOSING_CURLY_BRACKET = '}';
|
||||||
|
public static final int CODE_CLOSING_ANGLE_BRACKET = '>';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Special keys code. Must be negative.
|
||||||
|
* These should be aligned with KeyboardCodesSet.ID_TO_NAME[],
|
||||||
|
* KeyboardCodesSet.DEFAULT[] and KeyboardCodesSet.RTL[]
|
||||||
|
*/
|
||||||
|
public static final int CODE_SHIFT = -1;
|
||||||
|
public static final int CODE_SWITCH_ALPHA_SYMBOL = -2;
|
||||||
|
public static final int CODE_OUTPUT_TEXT = -3;
|
||||||
|
public static final int CODE_DELETE = -4;
|
||||||
|
public static final int CODE_SETTINGS = -5;
|
||||||
|
public static final int CODE_SHORTCUT = -6;
|
||||||
|
public static final int CODE_ACTION_ENTER = -7;
|
||||||
|
public static final int CODE_ACTION_NEXT = -8;
|
||||||
|
public static final int CODE_ACTION_PREVIOUS = -9;
|
||||||
|
public static final int CODE_LANGUAGE_SWITCH = -10;
|
||||||
|
public static final int CODE_RESEARCH = -11;
|
||||||
|
// Code value representing the code is not specified.
|
||||||
|
public static final int CODE_UNSPECIFIED = -12;
|
||||||
|
|
||||||
|
public static boolean isLetterCode(final int code) {
|
||||||
|
return code >= CODE_SPACE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String printableCode(final int code) {
|
||||||
|
switch (code) {
|
||||||
|
case CODE_SHIFT: return "shift";
|
||||||
|
case CODE_SWITCH_ALPHA_SYMBOL: return "symbol";
|
||||||
|
case CODE_OUTPUT_TEXT: return "text";
|
||||||
|
case CODE_DELETE: return "delete";
|
||||||
|
case CODE_SETTINGS: return "settings";
|
||||||
|
case CODE_SHORTCUT: return "shortcut";
|
||||||
|
case CODE_ACTION_ENTER: return "actionEnter";
|
||||||
|
case CODE_ACTION_NEXT: return "actionNext";
|
||||||
|
case CODE_ACTION_PREVIOUS: return "actionPrevious";
|
||||||
|
case CODE_LANGUAGE_SWITCH: return "languageSwitch";
|
||||||
|
case CODE_UNSPECIFIED: return "unspec";
|
||||||
|
case CODE_TAB: return "tab";
|
||||||
|
case CODE_ENTER: return "enter";
|
||||||
|
default:
|
||||||
|
if (code <= 0) Log.w(TAG, "Unknown non-positive key code=" + code);
|
||||||
|
if (code < CODE_SPACE) return String.format("'\\u%02x'", code);
|
||||||
|
if (code < 0x100) return String.format("'%c'", code);
|
||||||
|
return String.format("'\\u%04x'", code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Constants() {
|
private Constants() {
|
||||||
// This utility class is not publicly instantiable.
|
// This utility class is not publicly instantiable.
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,8 +24,6 @@ import android.provider.ContactsContract.Contacts;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.android.inputmethod.keyboard.Keyboard;
|
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
public class ContactsBinaryDictionary extends ExpandableBinaryDictionary {
|
public class ContactsBinaryDictionary extends ExpandableBinaryDictionary {
|
||||||
|
@ -194,7 +192,7 @@ public class ContactsBinaryDictionary extends ExpandableBinaryDictionary {
|
||||||
int cp = 0;
|
int cp = 0;
|
||||||
for (end = startIndex + 1; end < len; end += Character.charCount(cp)) {
|
for (end = startIndex + 1; end < len; end += Character.charCount(cp)) {
|
||||||
cp = string.codePointAt(end);
|
cp = string.codePointAt(end);
|
||||||
if (!(cp == Keyboard.CODE_DASH || cp == Keyboard.CODE_SINGLE_QUOTE
|
if (!(cp == Constants.CODE_DASH || cp == Constants.CODE_SINGLE_QUOTE
|
||||||
|| Character.isLetter(cp))) {
|
|| Character.isLetter(cp))) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@ package com.android.inputmethod.latin;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import com.android.inputmethod.keyboard.Keyboard;
|
|
||||||
import com.android.inputmethod.keyboard.ProximityInfo;
|
import com.android.inputmethod.keyboard.ProximityInfo;
|
||||||
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
|
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
|
||||||
import com.android.inputmethod.latin.UserHistoryForgettingCurveUtils.ForgettingCurveParams;
|
import com.android.inputmethod.latin.UserHistoryForgettingCurveUtils.ForgettingCurveParams;
|
||||||
|
@ -472,8 +471,8 @@ public class ExpandableDictionary extends Dictionary {
|
||||||
getWordsRec(children, codes, word, depth + 1, true, snr, inputIndex,
|
getWordsRec(children, codes, word, depth + 1, true, snr, inputIndex,
|
||||||
skipPos, suggestions);
|
skipPos, suggestions);
|
||||||
}
|
}
|
||||||
} else if ((c == Keyboard.CODE_SINGLE_QUOTE
|
} else if ((c == Constants.CODE_SINGLE_QUOTE
|
||||||
&& currentChars[0] != Keyboard.CODE_SINGLE_QUOTE) || depth == skipPos) {
|
&& currentChars[0] != Constants.CODE_SINGLE_QUOTE) || depth == skipPos) {
|
||||||
// Skip the ' and continue deeper
|
// Skip the ' and continue deeper
|
||||||
word[depth] = c;
|
word[depth] = c;
|
||||||
if (children != null) {
|
if (children != null) {
|
||||||
|
|
|
@ -1140,7 +1140,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
|
||||||
CharSequence lastTwo = mConnection.getTextBeforeCursor(2, 0);
|
CharSequence lastTwo = mConnection.getTextBeforeCursor(2, 0);
|
||||||
// It is guaranteed lastTwo.charAt(1) is a swapper - else this method is not called.
|
// It is guaranteed lastTwo.charAt(1) is a swapper - else this method is not called.
|
||||||
if (lastTwo != null && lastTwo.length() == 2
|
if (lastTwo != null && lastTwo.length() == 2
|
||||||
&& lastTwo.charAt(0) == Keyboard.CODE_SPACE) {
|
&& lastTwo.charAt(0) == Constants.CODE_SPACE) {
|
||||||
mConnection.deleteSurroundingText(2, 0);
|
mConnection.deleteSurroundingText(2, 0);
|
||||||
mConnection.commitText(lastTwo.charAt(1) + " ", 1);
|
mConnection.commitText(lastTwo.charAt(1) + " ", 1);
|
||||||
if (ProductionFlag.IS_EXPERIMENTAL) {
|
if (ProductionFlag.IS_EXPERIMENTAL) {
|
||||||
|
@ -1156,8 +1156,8 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
|
||||||
final CharSequence lastThree = mConnection.getTextBeforeCursor(3, 0);
|
final CharSequence lastThree = mConnection.getTextBeforeCursor(3, 0);
|
||||||
if (lastThree != null && lastThree.length() == 3
|
if (lastThree != null && lastThree.length() == 3
|
||||||
&& canBeFollowedByPeriod(lastThree.charAt(0))
|
&& canBeFollowedByPeriod(lastThree.charAt(0))
|
||||||
&& lastThree.charAt(1) == Keyboard.CODE_SPACE
|
&& lastThree.charAt(1) == Constants.CODE_SPACE
|
||||||
&& lastThree.charAt(2) == Keyboard.CODE_SPACE) {
|
&& lastThree.charAt(2) == Constants.CODE_SPACE) {
|
||||||
mHandler.cancelDoubleSpacesTimer();
|
mHandler.cancelDoubleSpacesTimer();
|
||||||
mConnection.deleteSurroundingText(2, 0);
|
mConnection.deleteSurroundingText(2, 0);
|
||||||
mConnection.commitText(". ", 1);
|
mConnection.commitText(". ", 1);
|
||||||
|
@ -1171,12 +1171,12 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
|
||||||
// TODO: Check again whether there really ain't a better way to check this.
|
// TODO: Check again whether there really ain't a better way to check this.
|
||||||
// TODO: This should probably be language-dependant...
|
// TODO: This should probably be language-dependant...
|
||||||
return Character.isLetterOrDigit(codePoint)
|
return Character.isLetterOrDigit(codePoint)
|
||||||
|| codePoint == Keyboard.CODE_SINGLE_QUOTE
|
|| codePoint == Constants.CODE_SINGLE_QUOTE
|
||||||
|| codePoint == Keyboard.CODE_DOUBLE_QUOTE
|
|| codePoint == Constants.CODE_DOUBLE_QUOTE
|
||||||
|| codePoint == Keyboard.CODE_CLOSING_PARENTHESIS
|
|| codePoint == Constants.CODE_CLOSING_PARENTHESIS
|
||||||
|| codePoint == Keyboard.CODE_CLOSING_SQUARE_BRACKET
|
|| codePoint == Constants.CODE_CLOSING_SQUARE_BRACKET
|
||||||
|| codePoint == Keyboard.CODE_CLOSING_CURLY_BRACKET
|
|| codePoint == Constants.CODE_CLOSING_CURLY_BRACKET
|
||||||
|| codePoint == Keyboard.CODE_CLOSING_ANGLE_BRACKET;
|
|| codePoint == Constants.CODE_CLOSING_ANGLE_BRACKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Callback for the {@link SuggestionStripView}, to call when the "add to dictionary" hint is
|
// Callback for the {@link SuggestionStripView}, to call when the "add to dictionary" hint is
|
||||||
|
@ -1271,7 +1271,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
|
||||||
|
|
||||||
// 16 is android.os.Build.VERSION_CODES.JELLY_BEAN but we can't write it because
|
// 16 is android.os.Build.VERSION_CODES.JELLY_BEAN but we can't write it because
|
||||||
// we want to be able to compile against the Ice Cream Sandwich SDK.
|
// we want to be able to compile against the Ice Cream Sandwich SDK.
|
||||||
if (Keyboard.CODE_ENTER == code && mTargetApplicationInfo != null
|
if (Constants.CODE_ENTER == code && mTargetApplicationInfo != null
|
||||||
&& mTargetApplicationInfo.targetSdkVersion < 16) {
|
&& mTargetApplicationInfo.targetSdkVersion < 16) {
|
||||||
// Backward compatibility mode. Before Jelly bean, the keyboard would simulate
|
// Backward compatibility mode. Before Jelly bean, the keyboard would simulate
|
||||||
// a hardware keyboard event on pressing enter or delete. This is bad for many
|
// a hardware keyboard event on pressing enter or delete. This is bad for many
|
||||||
|
@ -1288,7 +1288,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
|
||||||
@Override
|
@Override
|
||||||
public void onCodeInput(final int primaryCode, final int x, final int y) {
|
public void onCodeInput(final int primaryCode, final int x, final int y) {
|
||||||
final long when = SystemClock.uptimeMillis();
|
final long when = SystemClock.uptimeMillis();
|
||||||
if (primaryCode != Keyboard.CODE_DELETE || when > mLastKeyTime + QUICK_PRESS) {
|
if (primaryCode != Constants.CODE_DELETE || when > mLastKeyTime + QUICK_PRESS) {
|
||||||
mDeleteCount = 0;
|
mDeleteCount = 0;
|
||||||
}
|
}
|
||||||
mLastKeyTime = when;
|
mLastKeyTime = when;
|
||||||
|
@ -1303,13 +1303,13 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
|
||||||
if (!mWordComposer.isComposingWord()) mIsAutoCorrectionIndicatorOn = false;
|
if (!mWordComposer.isComposingWord()) mIsAutoCorrectionIndicatorOn = false;
|
||||||
|
|
||||||
// TODO: Consolidate the double space timer, mLastKeyTime, and the space state.
|
// TODO: Consolidate the double space timer, mLastKeyTime, and the space state.
|
||||||
if (primaryCode != Keyboard.CODE_SPACE) {
|
if (primaryCode != Constants.CODE_SPACE) {
|
||||||
mHandler.cancelDoubleSpacesTimer();
|
mHandler.cancelDoubleSpacesTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean didAutoCorrect = false;
|
boolean didAutoCorrect = false;
|
||||||
switch (primaryCode) {
|
switch (primaryCode) {
|
||||||
case Keyboard.CODE_DELETE:
|
case Constants.CODE_DELETE:
|
||||||
mSpaceState = SPACE_STATE_NONE;
|
mSpaceState = SPACE_STATE_NONE;
|
||||||
handleBackspace(spaceState);
|
handleBackspace(spaceState);
|
||||||
mDeleteCount++;
|
mDeleteCount++;
|
||||||
|
@ -1317,29 +1317,29 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
|
||||||
mShouldSwitchToLastSubtype = true;
|
mShouldSwitchToLastSubtype = true;
|
||||||
LatinImeLogger.logOnDelete(x, y);
|
LatinImeLogger.logOnDelete(x, y);
|
||||||
break;
|
break;
|
||||||
case Keyboard.CODE_SHIFT:
|
case Constants.CODE_SHIFT:
|
||||||
case Keyboard.CODE_SWITCH_ALPHA_SYMBOL:
|
case Constants.CODE_SWITCH_ALPHA_SYMBOL:
|
||||||
// Shift and symbol key is handled in onPressKey() and onReleaseKey().
|
// Shift and symbol key is handled in onPressKey() and onReleaseKey().
|
||||||
break;
|
break;
|
||||||
case Keyboard.CODE_SETTINGS:
|
case Constants.CODE_SETTINGS:
|
||||||
onSettingsKeyPressed();
|
onSettingsKeyPressed();
|
||||||
break;
|
break;
|
||||||
case Keyboard.CODE_SHORTCUT:
|
case Constants.CODE_SHORTCUT:
|
||||||
mSubtypeSwitcher.switchToShortcutIME(this);
|
mSubtypeSwitcher.switchToShortcutIME(this);
|
||||||
break;
|
break;
|
||||||
case Keyboard.CODE_ACTION_ENTER:
|
case Constants.CODE_ACTION_ENTER:
|
||||||
performEditorAction(getActionId(switcher.getKeyboard()));
|
performEditorAction(getActionId(switcher.getKeyboard()));
|
||||||
break;
|
break;
|
||||||
case Keyboard.CODE_ACTION_NEXT:
|
case Constants.CODE_ACTION_NEXT:
|
||||||
performEditorAction(EditorInfo.IME_ACTION_NEXT);
|
performEditorAction(EditorInfo.IME_ACTION_NEXT);
|
||||||
break;
|
break;
|
||||||
case Keyboard.CODE_ACTION_PREVIOUS:
|
case Constants.CODE_ACTION_PREVIOUS:
|
||||||
performEditorAction(EditorInfo.IME_ACTION_PREVIOUS);
|
performEditorAction(EditorInfo.IME_ACTION_PREVIOUS);
|
||||||
break;
|
break;
|
||||||
case Keyboard.CODE_LANGUAGE_SWITCH:
|
case Constants.CODE_LANGUAGE_SWITCH:
|
||||||
handleLanguageSwitchKey();
|
handleLanguageSwitchKey();
|
||||||
break;
|
break;
|
||||||
case Keyboard.CODE_RESEARCH:
|
case Constants.CODE_RESEARCH:
|
||||||
if (ProductionFlag.IS_EXPERIMENTAL) {
|
if (ProductionFlag.IS_EXPERIMENTAL) {
|
||||||
ResearchLogger.getInstance().onResearchKeySelected(this);
|
ResearchLogger.getInstance().onResearchKeySelected(this);
|
||||||
}
|
}
|
||||||
|
@ -1375,10 +1375,10 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
|
||||||
}
|
}
|
||||||
switcher.onCodeInput(primaryCode);
|
switcher.onCodeInput(primaryCode);
|
||||||
// Reset after any single keystroke, except shift and symbol-shift
|
// Reset after any single keystroke, except shift and symbol-shift
|
||||||
if (!didAutoCorrect && primaryCode != Keyboard.CODE_SHIFT
|
if (!didAutoCorrect && primaryCode != Constants.CODE_SHIFT
|
||||||
&& primaryCode != Keyboard.CODE_SWITCH_ALPHA_SYMBOL)
|
&& primaryCode != Constants.CODE_SWITCH_ALPHA_SYMBOL)
|
||||||
mLastComposedWord.deactivate();
|
mLastComposedWord.deactivate();
|
||||||
if (Keyboard.CODE_DELETE != primaryCode) {
|
if (Constants.CODE_DELETE != primaryCode) {
|
||||||
mEnteredText = null;
|
mEnteredText = null;
|
||||||
}
|
}
|
||||||
mConnection.endBatchEdit();
|
mConnection.endBatchEdit();
|
||||||
|
@ -1399,14 +1399,14 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
|
||||||
mHandler.postUpdateSuggestionStrip();
|
mHandler.postUpdateSuggestionStrip();
|
||||||
final String text = specificTldProcessingOnTextInput(rawText);
|
final String text = specificTldProcessingOnTextInput(rawText);
|
||||||
if (SPACE_STATE_PHANTOM == mSpaceState) {
|
if (SPACE_STATE_PHANTOM == mSpaceState) {
|
||||||
sendKeyCodePoint(Keyboard.CODE_SPACE);
|
sendKeyCodePoint(Constants.CODE_SPACE);
|
||||||
}
|
}
|
||||||
mConnection.commitText(text, 1);
|
mConnection.commitText(text, 1);
|
||||||
mConnection.endBatchEdit();
|
mConnection.endBatchEdit();
|
||||||
// Space state must be updated before calling updateShiftState
|
// Space state must be updated before calling updateShiftState
|
||||||
mSpaceState = SPACE_STATE_NONE;
|
mSpaceState = SPACE_STATE_NONE;
|
||||||
mKeyboardSwitcher.updateShiftState();
|
mKeyboardSwitcher.updateShiftState();
|
||||||
mKeyboardSwitcher.onCodeInput(Keyboard.CODE_OUTPUT_TEXT);
|
mKeyboardSwitcher.onCodeInput(Constants.CODE_OUTPUT_TEXT);
|
||||||
mEnteredText = text;
|
mEnteredText = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1562,7 +1562,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
|
||||||
mWordComposer.setBatchInputWord(batchInputText);
|
mWordComposer.setBatchInputWord(batchInputText);
|
||||||
mConnection.beginBatchEdit();
|
mConnection.beginBatchEdit();
|
||||||
if (SPACE_STATE_PHANTOM == mSpaceState) {
|
if (SPACE_STATE_PHANTOM == mSpaceState) {
|
||||||
sendKeyCodePoint(Keyboard.CODE_SPACE);
|
sendKeyCodePoint(Constants.CODE_SPACE);
|
||||||
}
|
}
|
||||||
mConnection.setComposingText(batchInputText, 1);
|
mConnection.setComposingText(batchInputText, 1);
|
||||||
mExpectingUpdateSelection = true;
|
mExpectingUpdateSelection = true;
|
||||||
|
@ -1573,7 +1573,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
|
||||||
}
|
}
|
||||||
|
|
||||||
private String specificTldProcessingOnTextInput(final String text) {
|
private String specificTldProcessingOnTextInput(final String text) {
|
||||||
if (text.length() <= 1 || text.charAt(0) != Keyboard.CODE_PERIOD
|
if (text.length() <= 1 || text.charAt(0) != Constants.CODE_PERIOD
|
||||||
|| !Character.isLetter(text.charAt(1))) {
|
|| !Character.isLetter(text.charAt(1))) {
|
||||||
// Not a tld: do nothing.
|
// Not a tld: do nothing.
|
||||||
return text;
|
return text;
|
||||||
|
@ -1584,7 +1584,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
|
||||||
// TODO: use getCodePointBeforeCursor instead to improve performance and simplify the code
|
// TODO: use getCodePointBeforeCursor instead to improve performance and simplify the code
|
||||||
final CharSequence lastOne = mConnection.getTextBeforeCursor(1, 0);
|
final CharSequence lastOne = mConnection.getTextBeforeCursor(1, 0);
|
||||||
if (lastOne != null && lastOne.length() == 1
|
if (lastOne != null && lastOne.length() == 1
|
||||||
&& lastOne.charAt(0) == Keyboard.CODE_PERIOD) {
|
&& lastOne.charAt(0) == Constants.CODE_PERIOD) {
|
||||||
return text.substring(1);
|
return text.substring(1);
|
||||||
} else {
|
} else {
|
||||||
return text;
|
return text;
|
||||||
|
@ -1689,7 +1689,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
|
||||||
|
|
||||||
private boolean maybeStripSpace(final int code,
|
private boolean maybeStripSpace(final int code,
|
||||||
final int spaceState, final boolean isFromSuggestionStrip) {
|
final int spaceState, final boolean isFromSuggestionStrip) {
|
||||||
if (Keyboard.CODE_ENTER == code && SPACE_STATE_SWAP_PUNCTUATION == spaceState) {
|
if (Constants.CODE_ENTER == code && SPACE_STATE_SWAP_PUNCTUATION == spaceState) {
|
||||||
mConnection.removeTrailingSpace();
|
mConnection.removeTrailingSpace();
|
||||||
return false;
|
return false;
|
||||||
} else if ((SPACE_STATE_WEAK == spaceState
|
} else if ((SPACE_STATE_WEAK == spaceState
|
||||||
|
@ -1718,7 +1718,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
|
||||||
// Sanity check
|
// Sanity check
|
||||||
throw new RuntimeException("Should not be composing here");
|
throw new RuntimeException("Should not be composing here");
|
||||||
}
|
}
|
||||||
sendKeyCodePoint(Keyboard.CODE_SPACE);
|
sendKeyCodePoint(Constants.CODE_SPACE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: isCursorTouchingWord() is a blocking IPC call, so it often takes several
|
// NOTE: isCursorTouchingWord() is a blocking IPC call, so it often takes several
|
||||||
|
@ -1732,7 +1732,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
|
||||||
// the character is a single quote. The idea here is, single quote is not a
|
// the character is a single quote. The idea here is, single quote is not a
|
||||||
// separator and it should be treated as a normal character, except in the first
|
// separator and it should be treated as a normal character, except in the first
|
||||||
// position where it should not start composing a word.
|
// position where it should not start composing a word.
|
||||||
isComposingWord = (Keyboard.CODE_SINGLE_QUOTE != primaryCode);
|
isComposingWord = (Constants.CODE_SINGLE_QUOTE != primaryCode);
|
||||||
// Here we don't need to reset the last composed word. It will be reset
|
// Here we don't need to reset the last composed word. It will be reset
|
||||||
// when we commit this one, if we ever do; if on the other hand we backspace
|
// when we commit this one, if we ever do; if on the other hand we backspace
|
||||||
// it entirely and resume suggestions on the previous word, we'd like to still
|
// it entirely and resume suggestions on the previous word, we'd like to still
|
||||||
|
@ -1796,11 +1796,11 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
|
||||||
|
|
||||||
if (SPACE_STATE_PHANTOM == spaceState &&
|
if (SPACE_STATE_PHANTOM == spaceState &&
|
||||||
mCurrentSettings.isPhantomSpacePromotingSymbol(primaryCode)) {
|
mCurrentSettings.isPhantomSpacePromotingSymbol(primaryCode)) {
|
||||||
sendKeyCodePoint(Keyboard.CODE_SPACE);
|
sendKeyCodePoint(Constants.CODE_SPACE);
|
||||||
}
|
}
|
||||||
sendKeyCodePoint(primaryCode);
|
sendKeyCodePoint(primaryCode);
|
||||||
|
|
||||||
if (Keyboard.CODE_SPACE == primaryCode) {
|
if (Constants.CODE_SPACE == primaryCode) {
|
||||||
if (mCurrentSettings.isSuggestionsRequested(mDisplayOrientation)) {
|
if (mCurrentSettings.isSuggestionsRequested(mDisplayOrientation)) {
|
||||||
if (maybeDoubleSpace()) {
|
if (maybeDoubleSpace()) {
|
||||||
mSpaceState = SPACE_STATE_DOUBLE;
|
mSpaceState = SPACE_STATE_DOUBLE;
|
||||||
|
@ -2060,7 +2060,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
|
||||||
int firstChar = Character.codePointAt(suggestion, 0);
|
int firstChar = Character.codePointAt(suggestion, 0);
|
||||||
if ((!mCurrentSettings.isWeakSpaceStripper(firstChar))
|
if ((!mCurrentSettings.isWeakSpaceStripper(firstChar))
|
||||||
&& (!mCurrentSettings.isWeakSpaceSwapper(firstChar))) {
|
&& (!mCurrentSettings.isWeakSpaceSwapper(firstChar))) {
|
||||||
sendKeyCodePoint(Keyboard.CODE_SPACE);
|
sendKeyCodePoint(Constants.CODE_SPACE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2105,7 +2105,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
|
||||||
&& !AutoCorrection.isValidWord(mSuggest.getUnigramDictionaries(), suggestion, true);
|
&& !AutoCorrection.isValidWord(mSuggest.getUnigramDictionaries(), suggestion, true);
|
||||||
|
|
||||||
if (ProductionFlag.IS_INTERNAL) {
|
if (ProductionFlag.IS_INTERNAL) {
|
||||||
Stats.onSeparator((char)Keyboard.CODE_SPACE,
|
Stats.onSeparator((char)Constants.CODE_SPACE,
|
||||||
Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE);
|
Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE);
|
||||||
}
|
}
|
||||||
if (showingAddToDictionaryHint && mIsUserDictionaryAvailable) {
|
if (showingAddToDictionaryHint && mIsUserDictionaryAvailable) {
|
||||||
|
@ -2276,16 +2276,16 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
|
||||||
// If accessibility is on, ensure the user receives keyboard state updates.
|
// If accessibility is on, ensure the user receives keyboard state updates.
|
||||||
if (AccessibilityUtils.getInstance().isTouchExplorationEnabled()) {
|
if (AccessibilityUtils.getInstance().isTouchExplorationEnabled()) {
|
||||||
switch (primaryCode) {
|
switch (primaryCode) {
|
||||||
case Keyboard.CODE_SHIFT:
|
case Constants.CODE_SHIFT:
|
||||||
AccessibleKeyboardViewProxy.getInstance().notifyShiftState();
|
AccessibleKeyboardViewProxy.getInstance().notifyShiftState();
|
||||||
break;
|
break;
|
||||||
case Keyboard.CODE_SWITCH_ALPHA_SYMBOL:
|
case Constants.CODE_SWITCH_ALPHA_SYMBOL:
|
||||||
AccessibleKeyboardViewProxy.getInstance().notifySymbolsState();
|
AccessibleKeyboardViewProxy.getInstance().notifySymbolsState();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Keyboard.CODE_DELETE == primaryCode) {
|
if (Constants.CODE_DELETE == primaryCode) {
|
||||||
// This is a stopgap solution to avoid leaving a high surrogate alone in a text view.
|
// This is a stopgap solution to avoid leaving a high surrogate alone in a text view.
|
||||||
// In the future, we need to deprecate deteleSurroundingText() and have a surrogate
|
// In the future, we need to deprecate deteleSurroundingText() and have a surrogate
|
||||||
// pair-friendly way of deleting characters in InputConnection.
|
// pair-friendly way of deleting characters in InputConnection.
|
||||||
|
|
|
@ -26,7 +26,6 @@ import android.view.inputmethod.ExtractedText;
|
||||||
import android.view.inputmethod.ExtractedTextRequest;
|
import android.view.inputmethod.ExtractedTextRequest;
|
||||||
import android.view.inputmethod.InputConnection;
|
import android.view.inputmethod.InputConnection;
|
||||||
|
|
||||||
import com.android.inputmethod.keyboard.Keyboard;
|
|
||||||
import com.android.inputmethod.latin.define.ProductionFlag;
|
import com.android.inputmethod.latin.define.ProductionFlag;
|
||||||
import com.android.inputmethod.research.ResearchLogger;
|
import com.android.inputmethod.research.ResearchLogger;
|
||||||
|
|
||||||
|
@ -590,7 +589,7 @@ public final class RichInputConnection {
|
||||||
if (DEBUG_BATCH_NESTING) checkBatchEdit();
|
if (DEBUG_BATCH_NESTING) checkBatchEdit();
|
||||||
final CharSequence lastOne = getTextBeforeCursor(1, 0);
|
final CharSequence lastOne = getTextBeforeCursor(1, 0);
|
||||||
if (lastOne != null && lastOne.length() == 1
|
if (lastOne != null && lastOne.length() == 1
|
||||||
&& lastOne.charAt(0) == Keyboard.CODE_SPACE) {
|
&& lastOne.charAt(0) == Constants.CODE_SPACE) {
|
||||||
deleteSurroundingText(1, 0);
|
deleteSurroundingText(1, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -616,7 +615,7 @@ public final class RichInputConnection {
|
||||||
CharSequence word = getWordAtCursor(settings.mWordSeparators);
|
CharSequence word = getWordAtCursor(settings.mWordSeparators);
|
||||||
// We don't suggest on leading single quotes, so we have to remove them from the word if
|
// We don't suggest on leading single quotes, so we have to remove them from the word if
|
||||||
// it starts with single quotes.
|
// it starts with single quotes.
|
||||||
while (!TextUtils.isEmpty(word) && Keyboard.CODE_SINGLE_QUOTE == word.charAt(0)) {
|
while (!TextUtils.isEmpty(word) && Constants.CODE_SINGLE_QUOTE == word.charAt(0)) {
|
||||||
word = word.subSequence(1, word.length());
|
word = word.subSequence(1, word.length());
|
||||||
}
|
}
|
||||||
if (TextUtils.isEmpty(word)) return null;
|
if (TextUtils.isEmpty(word)) return null;
|
||||||
|
@ -668,7 +667,7 @@ public final class RichInputConnection {
|
||||||
// NOTE: This does not work with surrogate pairs. Hopefully when the keyboard is able to
|
// NOTE: This does not work with surrogate pairs. Hopefully when the keyboard is able to
|
||||||
// enter surrogate pairs this code will have been removed.
|
// enter surrogate pairs this code will have been removed.
|
||||||
if (TextUtils.isEmpty(textBeforeCursor)
|
if (TextUtils.isEmpty(textBeforeCursor)
|
||||||
|| (Keyboard.CODE_SPACE != textBeforeCursor.charAt(1))) {
|
|| (Constants.CODE_SPACE != textBeforeCursor.charAt(1))) {
|
||||||
// We may only come here if the application is changing the text while we are typing.
|
// We may only come here if the application is changing the text while we are typing.
|
||||||
// This is quite a broken case, but not logically impossible, so we shouldn't crash,
|
// This is quite a broken case, but not logically impossible, so we shouldn't crash,
|
||||||
// but some debugging log may be in order.
|
// but some debugging log may be in order.
|
||||||
|
|
|
@ -19,9 +19,6 @@ package com.android.inputmethod.latin;
|
||||||
import android.text.InputType;
|
import android.text.InputType;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
//For character constants
|
|
||||||
import com.android.inputmethod.keyboard.Keyboard;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
@ -175,7 +172,7 @@ public final class StringUtils {
|
||||||
} else {
|
} else {
|
||||||
for (i = cs.length(); i > 0; i--) {
|
for (i = cs.length(); i > 0; i--) {
|
||||||
final char c = cs.charAt(i - 1);
|
final char c = cs.charAt(i - 1);
|
||||||
if (c != Keyboard.CODE_DOUBLE_QUOTE && c != Keyboard.CODE_SINGLE_QUOTE
|
if (c != Constants.CODE_DOUBLE_QUOTE && c != Constants.CODE_SINGLE_QUOTE
|
||||||
&& Character.getType(c) != Character.START_PUNCTUATION) {
|
&& Character.getType(c) != Character.START_PUNCTUATION) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -191,11 +188,11 @@ public final class StringUtils {
|
||||||
// if the first char that's not a space or tab is a start of line (as in \n, start of text,
|
// if the first char that's not a space or tab is a start of line (as in \n, start of text,
|
||||||
// or some other similar characters).
|
// or some other similar characters).
|
||||||
int j = i;
|
int j = i;
|
||||||
char prevChar = Keyboard.CODE_SPACE;
|
char prevChar = Constants.CODE_SPACE;
|
||||||
if (hasSpaceBefore) --j;
|
if (hasSpaceBefore) --j;
|
||||||
while (j > 0) {
|
while (j > 0) {
|
||||||
prevChar = cs.charAt(j - 1);
|
prevChar = cs.charAt(j - 1);
|
||||||
if (!Character.isSpaceChar(prevChar) && prevChar != Keyboard.CODE_TAB) break;
|
if (!Character.isSpaceChar(prevChar) && prevChar != Constants.CODE_TAB) break;
|
||||||
j--;
|
j--;
|
||||||
}
|
}
|
||||||
if (j <= 0 || Character.isWhitespace(prevChar)) {
|
if (j <= 0 || Character.isWhitespace(prevChar)) {
|
||||||
|
@ -234,7 +231,7 @@ public final class StringUtils {
|
||||||
// variants of English, the final period is placed within double quotes and maybe
|
// variants of English, the final period is placed within double quotes and maybe
|
||||||
// other closing punctuation signs. This is generally not true in other languages.
|
// other closing punctuation signs. This is generally not true in other languages.
|
||||||
final char c = cs.charAt(j - 1);
|
final char c = cs.charAt(j - 1);
|
||||||
if (c != Keyboard.CODE_DOUBLE_QUOTE && c != Keyboard.CODE_SINGLE_QUOTE
|
if (c != Constants.CODE_DOUBLE_QUOTE && c != Constants.CODE_SINGLE_QUOTE
|
||||||
&& Character.getType(c) != Character.END_PUNCTUATION) {
|
&& Character.getType(c) != Character.END_PUNCTUATION) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -248,10 +245,10 @@ public final class StringUtils {
|
||||||
// end of a sentence. If we have a question mark or an exclamation mark, it's the end of
|
// end of a sentence. If we have a question mark or an exclamation mark, it's the end of
|
||||||
// a sentence. If it's neither, the only remaining case is the period so we get the opposite
|
// a sentence. If it's neither, the only remaining case is the period so we get the opposite
|
||||||
// case out of the way.
|
// case out of the way.
|
||||||
if (c == Keyboard.CODE_QUESTION_MARK || c == Keyboard.CODE_EXCLAMATION_MARK) {
|
if (c == Constants.CODE_QUESTION_MARK || c == Constants.CODE_EXCLAMATION_MARK) {
|
||||||
return (TextUtils.CAP_MODE_CHARACTERS | TextUtils.CAP_MODE_SENTENCES) & reqModes;
|
return (TextUtils.CAP_MODE_CHARACTERS | TextUtils.CAP_MODE_SENTENCES) & reqModes;
|
||||||
}
|
}
|
||||||
if (c != Keyboard.CODE_PERIOD || j <= 0) {
|
if (c != Constants.CODE_PERIOD || j <= 0) {
|
||||||
return (TextUtils.CAP_MODE_CHARACTERS | TextUtils.CAP_MODE_WORDS) & reqModes;
|
return (TextUtils.CAP_MODE_CHARACTERS | TextUtils.CAP_MODE_WORDS) & reqModes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -301,7 +298,7 @@ public final class StringUtils {
|
||||||
case WORD:
|
case WORD:
|
||||||
if (Character.isLetter(c)) {
|
if (Character.isLetter(c)) {
|
||||||
state = WORD;
|
state = WORD;
|
||||||
} else if (c == Keyboard.CODE_PERIOD) {
|
} else if (c == Constants.CODE_PERIOD) {
|
||||||
state = PERIOD;
|
state = PERIOD;
|
||||||
} else {
|
} else {
|
||||||
return caps;
|
return caps;
|
||||||
|
@ -317,7 +314,7 @@ public final class StringUtils {
|
||||||
case LETTER:
|
case LETTER:
|
||||||
if (Character.isLetter(c)) {
|
if (Character.isLetter(c)) {
|
||||||
state = LETTER;
|
state = LETTER;
|
||||||
} else if (c == Keyboard.CODE_PERIOD) {
|
} else if (c == Constants.CODE_PERIOD) {
|
||||||
state = PERIOD;
|
state = PERIOD;
|
||||||
} else {
|
} else {
|
||||||
return noCaps;
|
return noCaps;
|
||||||
|
|
|
@ -20,7 +20,6 @@ import android.content.Context;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import com.android.inputmethod.annotations.UsedForTesting;
|
import com.android.inputmethod.annotations.UsedForTesting;
|
||||||
import com.android.inputmethod.keyboard.Keyboard;
|
|
||||||
import com.android.inputmethod.keyboard.ProximityInfo;
|
import com.android.inputmethod.keyboard.ProximityInfo;
|
||||||
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
|
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
|
||||||
|
|
||||||
|
@ -392,7 +391,7 @@ public final class Suggest {
|
||||||
sb.append(wordInfo.mWord);
|
sb.append(wordInfo.mWord);
|
||||||
}
|
}
|
||||||
for (int i = trailingSingleQuotesCount - 1; i >= 0; --i) {
|
for (int i = trailingSingleQuotesCount - 1; i >= 0; --i) {
|
||||||
sb.appendCodePoint(Keyboard.CODE_SINGLE_QUOTE);
|
sb.appendCodePoint(Constants.CODE_SINGLE_QUOTE);
|
||||||
}
|
}
|
||||||
return new SuggestedWordInfo(sb.toString(), wordInfo.mScore, wordInfo.mKind,
|
return new SuggestedWordInfo(sb.toString(), wordInfo.mScore, wordInfo.mKind,
|
||||||
wordInfo.mSourceDict);
|
wordInfo.mSourceDict);
|
||||||
|
|
|
@ -135,7 +135,7 @@ public final class WordComposer {
|
||||||
mTypedWord.appendCodePoint(primaryCode);
|
mTypedWord.appendCodePoint(primaryCode);
|
||||||
refreshSize();
|
refreshSize();
|
||||||
if (newIndex < BinaryDictionary.MAX_WORD_LENGTH) {
|
if (newIndex < BinaryDictionary.MAX_WORD_LENGTH) {
|
||||||
mPrimaryKeyCodes[newIndex] = primaryCode >= Keyboard.CODE_SPACE
|
mPrimaryKeyCodes[newIndex] = primaryCode >= Constants.CODE_SPACE
|
||||||
? Character.toLowerCase(primaryCode) : primaryCode;
|
? Character.toLowerCase(primaryCode) : primaryCode;
|
||||||
// In the batch input mode, the {@code mInputPointers} holds batch input points and
|
// In the batch input mode, the {@code mInputPointers} holds batch input points and
|
||||||
// shouldn't be overridden by the "typed key" coordinates
|
// shouldn't be overridden by the "typed key" coordinates
|
||||||
|
@ -149,7 +149,7 @@ public final class WordComposer {
|
||||||
newIndex, primaryCode, mIsFirstCharCapitalized);
|
newIndex, primaryCode, mIsFirstCharCapitalized);
|
||||||
if (Character.isUpperCase(primaryCode)) mCapsCount++;
|
if (Character.isUpperCase(primaryCode)) mCapsCount++;
|
||||||
if (Character.isDigit(primaryCode)) mDigitsCount++;
|
if (Character.isDigit(primaryCode)) mDigitsCount++;
|
||||||
if (Keyboard.CODE_SINGLE_QUOTE == primaryCode) {
|
if (Constants.CODE_SINGLE_QUOTE == primaryCode) {
|
||||||
++mTrailingSingleQuotesCount;
|
++mTrailingSingleQuotesCount;
|
||||||
} else {
|
} else {
|
||||||
mTrailingSingleQuotesCount = 0;
|
mTrailingSingleQuotesCount = 0;
|
||||||
|
@ -236,7 +236,7 @@ public final class WordComposer {
|
||||||
int i = mTypedWord.length();
|
int i = mTypedWord.length();
|
||||||
while (i > 0) {
|
while (i > 0) {
|
||||||
i = mTypedWord.offsetByCodePoints(i, -1);
|
i = mTypedWord.offsetByCodePoints(i, -1);
|
||||||
if (Keyboard.CODE_SINGLE_QUOTE != mTypedWord.codePointAt(i)) break;
|
if (Constants.CODE_SINGLE_QUOTE != mTypedWord.codePointAt(i)) break;
|
||||||
++mTrailingSingleQuotesCount;
|
++mTrailingSingleQuotesCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -870,7 +870,7 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
|
||||||
final long time = SystemClock.uptimeMillis();
|
final long time = SystemClock.uptimeMillis();
|
||||||
final ResearchLogger researchLogger = getInstance();
|
final ResearchLogger researchLogger = getInstance();
|
||||||
final Object[] values = {
|
final Object[] values = {
|
||||||
Keyboard.printableCode(scrubDigitFromCodePoint(code)), x, y
|
Constants.printableCode(scrubDigitFromCodePoint(code)), x, y
|
||||||
};
|
};
|
||||||
researchLogger.enqueuePotentiallyPrivateEvent(EVENTKEYS_LATINIME_ONCODEINPUT, values);
|
researchLogger.enqueuePotentiallyPrivateEvent(EVENTKEYS_LATINIME_ONCODEINPUT, values);
|
||||||
if (Character.isDigit(code)) {
|
if (Character.isDigit(code)) {
|
||||||
|
@ -1006,7 +1006,7 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
|
||||||
};
|
};
|
||||||
public static void latinIME_sendKeyCodePoint(final int code) {
|
public static void latinIME_sendKeyCodePoint(final int code) {
|
||||||
final Object[] values = {
|
final Object[] values = {
|
||||||
Keyboard.printableCode(scrubDigitFromCodePoint(code))
|
Constants.printableCode(scrubDigitFromCodePoint(code))
|
||||||
};
|
};
|
||||||
final ResearchLogger researchLogger = getInstance();
|
final ResearchLogger researchLogger = getInstance();
|
||||||
researchLogger.enqueuePotentiallyPrivateEvent(EVENTKEYS_LATINIME_SENDKEYCODEPOINT, values);
|
researchLogger.enqueuePotentiallyPrivateEvent(EVENTKEYS_LATINIME_SENDKEYCODEPOINT, values);
|
||||||
|
@ -1092,7 +1092,7 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
|
||||||
if (key != null) {
|
if (key != null) {
|
||||||
String outputText = key.getOutputText();
|
String outputText = key.getOutputText();
|
||||||
final Object[] values = {
|
final Object[] values = {
|
||||||
Keyboard.printableCode(scrubDigitFromCodePoint(code)), outputText == null ? null
|
Constants.printableCode(scrubDigitFromCodePoint(code)), outputText == null ? null
|
||||||
: scrubDigitsFromString(outputText.toString()),
|
: scrubDigitsFromString(outputText.toString()),
|
||||||
x, y, ignoreModifierKey, altersCode, key.isEnabled()
|
x, y, ignoreModifierKey, altersCode, key.isEnabled()
|
||||||
};
|
};
|
||||||
|
@ -1109,7 +1109,7 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
|
||||||
final boolean withSliding, final boolean ignoreModifierKey) {
|
final boolean withSliding, final boolean ignoreModifierKey) {
|
||||||
if (key != null) {
|
if (key != null) {
|
||||||
final Object[] values = {
|
final Object[] values = {
|
||||||
Keyboard.printableCode(scrubDigitFromCodePoint(primaryCode)), withSliding,
|
Constants.printableCode(scrubDigitFromCodePoint(primaryCode)), withSliding,
|
||||||
ignoreModifierKey, key.isEnabled()
|
ignoreModifierKey, key.isEnabled()
|
||||||
};
|
};
|
||||||
getInstance().enqueuePotentiallyPrivateEvent(
|
getInstance().enqueuePotentiallyPrivateEvent(
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
package com.android.inputmethod.research;
|
package com.android.inputmethod.research;
|
||||||
|
|
||||||
import com.android.inputmethod.keyboard.Keyboard;
|
import com.android.inputmethod.latin.Constants;
|
||||||
|
|
||||||
public class Statistics {
|
public class Statistics {
|
||||||
// Number of characters entered during a typing session
|
// Number of characters entered during a typing session
|
||||||
|
@ -104,7 +104,7 @@ public class Statistics {
|
||||||
|
|
||||||
public void recordChar(int codePoint, long time) {
|
public void recordChar(int codePoint, long time) {
|
||||||
final long delta = time - mLastTapTime;
|
final long delta = time - mLastTapTime;
|
||||||
if (codePoint == Keyboard.CODE_DELETE) {
|
if (codePoint == Constants.CODE_DELETE) {
|
||||||
mDeleteKeyCount++;
|
mDeleteKeyCount++;
|
||||||
if (delta < MIN_DELETION_INTERMISSION) {
|
if (delta < MIN_DELETION_INTERMISSION) {
|
||||||
if (mIsLastKeyDeleteKey) {
|
if (mIsLastKeyDeleteKey) {
|
||||||
|
|
|
@ -16,13 +16,13 @@
|
||||||
|
|
||||||
package com.android.inputmethod.keyboard.internal;
|
package com.android.inputmethod.keyboard.internal;
|
||||||
|
|
||||||
import static com.android.inputmethod.keyboard.Keyboard.CODE_OUTPUT_TEXT;
|
|
||||||
import static com.android.inputmethod.keyboard.Keyboard.CODE_UNSPECIFIED;
|
|
||||||
import static com.android.inputmethod.keyboard.internal.KeyboardIconsSet.ICON_UNDEFINED;
|
import static com.android.inputmethod.keyboard.internal.KeyboardIconsSet.ICON_UNDEFINED;
|
||||||
|
import static com.android.inputmethod.latin.Constants.CODE_OUTPUT_TEXT;
|
||||||
|
import static com.android.inputmethod.latin.Constants.CODE_UNSPECIFIED;
|
||||||
|
|
||||||
import android.test.AndroidTestCase;
|
import android.test.AndroidTestCase;
|
||||||
|
|
||||||
import com.android.inputmethod.keyboard.Keyboard;
|
import com.android.inputmethod.latin.Constants;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
@ -69,8 +69,8 @@ public class KeySpecParserTests extends AndroidTestCase {
|
||||||
KeyboardIconsSet.getIconName(expectedIcon),
|
KeyboardIconsSet.getIconName(expectedIcon),
|
||||||
KeyboardIconsSet.getIconName(spec.mIconId));
|
KeyboardIconsSet.getIconName(spec.mIconId));
|
||||||
assertEquals(message + " [code]",
|
assertEquals(message + " [code]",
|
||||||
Keyboard.printableCode(expectedCode),
|
Constants.printableCode(expectedCode),
|
||||||
Keyboard.printableCode(spec.mCode));
|
Constants.printableCode(spec.mCode));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertParserError(String message, String moreKeySpec, String expectedLabel,
|
private void assertParserError(String message, String moreKeySpec, String expectedLabel,
|
||||||
|
|
|
@ -19,7 +19,7 @@ package com.android.inputmethod.keyboard.internal;
|
||||||
import android.test.AndroidTestCase;
|
import android.test.AndroidTestCase;
|
||||||
|
|
||||||
public class KeyboardStateTestsBase extends AndroidTestCase
|
public class KeyboardStateTestsBase extends AndroidTestCase
|
||||||
implements MockKeyboardSwitcher.Constants {
|
implements MockKeyboardSwitcher.MockConstants {
|
||||||
protected MockKeyboardSwitcher mSwitcher;
|
protected MockKeyboardSwitcher mSwitcher;
|
||||||
|
|
||||||
private String mLayoutSwitchBackSymbols = "";
|
private String mLayoutSwitchBackSymbols = "";
|
||||||
|
|
|
@ -18,25 +18,24 @@ package com.android.inputmethod.keyboard.internal;
|
||||||
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import com.android.inputmethod.keyboard.Keyboard;
|
import com.android.inputmethod.latin.Constants;
|
||||||
|
|
||||||
public class MockKeyboardSwitcher implements KeyboardState.SwitchActions {
|
public class MockKeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||||
public interface Constants {
|
public interface MockConstants {
|
||||||
// Argument for {@link KeyboardState#onPressKey} and {@link KeyboardState#onReleaseKey}.
|
// Argument for {@link KeyboardState#onPressKey} and {@link KeyboardState#onReleaseKey}.
|
||||||
public static final boolean NOT_SLIDING = false;
|
public static final boolean NOT_SLIDING = false;
|
||||||
public static final boolean SLIDING = true;
|
public static final boolean SLIDING = true;
|
||||||
// Argument for {@link KeyboardState#onCodeInput}.
|
// Argument for {@link KeyboardState#onCodeInput}.
|
||||||
public static final boolean SINGLE = true;
|
public static final boolean SINGLE = true;
|
||||||
public static final boolean MULTI = false;
|
public static final boolean MULTI = false;
|
||||||
public static final int CAP_MODE_OFF =
|
public static final int CAP_MODE_OFF = Constants.TextUtils.CAP_MODE_OFF;
|
||||||
com.android.inputmethod.latin.Constants.TextUtils.CAP_MODE_OFF;
|
|
||||||
public static final int CAP_MODE_WORDS = TextUtils.CAP_MODE_WORDS;
|
public static final int CAP_MODE_WORDS = TextUtils.CAP_MODE_WORDS;
|
||||||
public static final int CAP_MODE_CHARACTERS = TextUtils.CAP_MODE_CHARACTERS;
|
public static final int CAP_MODE_CHARACTERS = TextUtils.CAP_MODE_CHARACTERS;
|
||||||
|
|
||||||
public static final int CODE_SHIFT = Keyboard.CODE_SHIFT;
|
public static final int CODE_SHIFT = Constants.CODE_SHIFT;
|
||||||
public static final int CODE_SYMBOL = Keyboard.CODE_SWITCH_ALPHA_SYMBOL;
|
public static final int CODE_SYMBOL = Constants.CODE_SWITCH_ALPHA_SYMBOL;
|
||||||
public static final int CODE_SPACE = Keyboard.CODE_SPACE;
|
public static final int CODE_SPACE = Constants.CODE_SPACE;
|
||||||
public static final int CODE_AUTO_CAPS_TRIGGER = Keyboard.CODE_SPACE;
|
public static final int CODE_AUTO_CAPS_TRIGGER = Constants.CODE_SPACE;
|
||||||
|
|
||||||
public static final int ALPHABET_UNSHIFTED = 0;
|
public static final int ALPHABET_UNSHIFTED = 0;
|
||||||
public static final int ALPHABET_MANUAL_SHIFTED = 1;
|
public static final int ALPHABET_MANUAL_SHIFTED = 1;
|
||||||
|
@ -47,11 +46,11 @@ public class MockKeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||||
public static final int SYMBOLS_SHIFTED = 6;
|
public static final int SYMBOLS_SHIFTED = 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int mLayout = Constants.ALPHABET_UNSHIFTED;
|
private int mLayout = MockConstants.ALPHABET_UNSHIFTED;
|
||||||
|
|
||||||
private int mAutoCapsMode = Constants.CAP_MODE_OFF;
|
private int mAutoCapsMode = MockConstants.CAP_MODE_OFF;
|
||||||
// Following InputConnection's behavior. Simulating InputType.TYPE_TEXT_FLAG_CAP_WORDS.
|
// Following InputConnection's behavior. Simulating InputType.TYPE_TEXT_FLAG_CAP_WORDS.
|
||||||
private int mAutoCapsState = Constants.CAP_MODE_OFF;
|
private int mAutoCapsState = MockConstants.CAP_MODE_OFF;
|
||||||
|
|
||||||
private boolean mIsInDoubleTapTimeout;
|
private boolean mIsInDoubleTapTimeout;
|
||||||
private int mLongPressTimeoutCode;
|
private int mLongPressTimeoutCode;
|
||||||
|
@ -64,13 +63,13 @@ public class MockKeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||||
|
|
||||||
public static String getLayoutName(int layoutId) {
|
public static String getLayoutName(int layoutId) {
|
||||||
switch (layoutId) {
|
switch (layoutId) {
|
||||||
case Constants.ALPHABET_UNSHIFTED: return "ALPHABET_UNSHIFTED";
|
case MockConstants.ALPHABET_UNSHIFTED: return "ALPHABET_UNSHIFTED";
|
||||||
case Constants.ALPHABET_MANUAL_SHIFTED: return "ALPHABET_MANUAL_SHIFTED";
|
case MockConstants.ALPHABET_MANUAL_SHIFTED: return "ALPHABET_MANUAL_SHIFTED";
|
||||||
case Constants.ALPHABET_AUTOMATIC_SHIFTED: return "ALPHABET_AUTOMATIC_SHIFTED";
|
case MockConstants.ALPHABET_AUTOMATIC_SHIFTED: return "ALPHABET_AUTOMATIC_SHIFTED";
|
||||||
case Constants.ALPHABET_SHIFT_LOCKED: return "ALPHABET_SHIFT_LOCKED";
|
case MockConstants.ALPHABET_SHIFT_LOCKED: return "ALPHABET_SHIFT_LOCKED";
|
||||||
case Constants.ALPHABET_SHIFT_LOCK_SHIFTED: return "ALPHABET_SHIFT_LOCK_SHIFTED";
|
case MockConstants.ALPHABET_SHIFT_LOCK_SHIFTED: return "ALPHABET_SHIFT_LOCK_SHIFTED";
|
||||||
case Constants.SYMBOLS_UNSHIFTED: return "SYMBOLS_UNSHIFTED";
|
case MockConstants.SYMBOLS_UNSHIFTED: return "SYMBOLS_UNSHIFTED";
|
||||||
case Constants.SYMBOLS_SHIFTED: return "SYMBOLS_SHIFTED";
|
case MockConstants.SYMBOLS_SHIFTED: return "SYMBOLS_SHIFTED";
|
||||||
default: return "UNKNOWN<" + layoutId + ">";
|
default: return "UNKNOWN<" + layoutId + ">";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -86,37 +85,37 @@ public class MockKeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setAlphabetKeyboard() {
|
public void setAlphabetKeyboard() {
|
||||||
mLayout = Constants.ALPHABET_UNSHIFTED;
|
mLayout = MockConstants.ALPHABET_UNSHIFTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setAlphabetManualShiftedKeyboard() {
|
public void setAlphabetManualShiftedKeyboard() {
|
||||||
mLayout = Constants.ALPHABET_MANUAL_SHIFTED;
|
mLayout = MockConstants.ALPHABET_MANUAL_SHIFTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setAlphabetAutomaticShiftedKeyboard() {
|
public void setAlphabetAutomaticShiftedKeyboard() {
|
||||||
mLayout = Constants.ALPHABET_AUTOMATIC_SHIFTED;
|
mLayout = MockConstants.ALPHABET_AUTOMATIC_SHIFTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setAlphabetShiftLockedKeyboard() {
|
public void setAlphabetShiftLockedKeyboard() {
|
||||||
mLayout = Constants.ALPHABET_SHIFT_LOCKED;
|
mLayout = MockConstants.ALPHABET_SHIFT_LOCKED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setAlphabetShiftLockShiftedKeyboard() {
|
public void setAlphabetShiftLockShiftedKeyboard() {
|
||||||
mLayout = Constants.ALPHABET_SHIFT_LOCK_SHIFTED;
|
mLayout = MockConstants.ALPHABET_SHIFT_LOCK_SHIFTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSymbolsKeyboard() {
|
public void setSymbolsKeyboard() {
|
||||||
mLayout = Constants.SYMBOLS_UNSHIFTED;
|
mLayout = MockConstants.SYMBOLS_UNSHIFTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSymbolsShiftedKeyboard() {
|
public void setSymbolsShiftedKeyboard() {
|
||||||
mLayout = Constants.SYMBOLS_SHIFTED;
|
mLayout = MockConstants.SYMBOLS_SHIFTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -186,10 +185,10 @@ public class MockKeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onCodeInput(int code, boolean isSinglePointer) {
|
public void onCodeInput(int code, boolean isSinglePointer) {
|
||||||
if (mAutoCapsMode == Constants.CAP_MODE_WORDS) {
|
if (mAutoCapsMode == MockConstants.CAP_MODE_WORDS) {
|
||||||
if (Keyboard.isLetterCode(code)) {
|
if (Constants.isLetterCode(code)) {
|
||||||
mAutoCapsState = (code == Constants.CODE_AUTO_CAPS_TRIGGER)
|
mAutoCapsState = (code == MockConstants.CODE_AUTO_CAPS_TRIGGER)
|
||||||
? mAutoCapsMode : Constants.CAP_MODE_OFF;
|
? mAutoCapsMode : MockConstants.CAP_MODE_OFF;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mAutoCapsState = mAutoCapsMode;
|
mAutoCapsState = mAutoCapsMode;
|
||||||
|
|
|
@ -16,8 +16,6 @@
|
||||||
|
|
||||||
package com.android.inputmethod.latin;
|
package com.android.inputmethod.latin;
|
||||||
|
|
||||||
import com.android.inputmethod.keyboard.Keyboard;
|
|
||||||
|
|
||||||
import android.text.style.SuggestionSpan;
|
import android.text.style.SuggestionSpan;
|
||||||
import android.text.style.UnderlineSpan;
|
import android.text.style.UnderlineSpan;
|
||||||
|
|
||||||
|
@ -67,13 +65,13 @@ public class BlueUnderlineTests extends InputTestsBase {
|
||||||
type(STRING_TO_TYPE);
|
type(STRING_TO_TYPE);
|
||||||
sleep(DELAY_TO_WAIT_FOR_UNDERLINE);
|
sleep(DELAY_TO_WAIT_FOR_UNDERLINE);
|
||||||
runMessages();
|
runMessages();
|
||||||
type(Keyboard.CODE_SPACE);
|
type(Constants.CODE_SPACE);
|
||||||
sleep(DELAY_TO_WAIT_FOR_UNDERLINE);
|
sleep(DELAY_TO_WAIT_FOR_UNDERLINE);
|
||||||
runMessages();
|
runMessages();
|
||||||
type(Keyboard.CODE_DELETE);
|
type(Constants.CODE_DELETE);
|
||||||
sleep(DELAY_TO_WAIT_FOR_UNDERLINE);
|
sleep(DELAY_TO_WAIT_FOR_UNDERLINE);
|
||||||
runMessages();
|
runMessages();
|
||||||
type(Keyboard.CODE_DELETE);
|
type(Constants.CODE_DELETE);
|
||||||
sleep(DELAY_TO_WAIT_FOR_UNDERLINE);
|
sleep(DELAY_TO_WAIT_FOR_UNDERLINE);
|
||||||
runMessages();
|
runMessages();
|
||||||
final SpanGetter suggestionSpan = new SpanGetter(mTextView.getText(), SuggestionSpan.class);
|
final SpanGetter suggestionSpan = new SpanGetter(mTextView.getText(), SuggestionSpan.class);
|
||||||
|
|
|
@ -16,8 +16,6 @@
|
||||||
|
|
||||||
package com.android.inputmethod.latin;
|
package com.android.inputmethod.latin;
|
||||||
|
|
||||||
import com.android.inputmethod.keyboard.Keyboard;
|
|
||||||
|
|
||||||
public class InputLogicTests extends InputTestsBase {
|
public class InputLogicTests extends InputTestsBase {
|
||||||
|
|
||||||
public void testTypeWord() {
|
public void testTypeWord() {
|
||||||
|
@ -32,7 +30,7 @@ public class InputLogicTests extends InputTestsBase {
|
||||||
type(WORD_TO_TYPE);
|
type(WORD_TO_TYPE);
|
||||||
pickSuggestionManually(0, WORD_TO_TYPE);
|
pickSuggestionManually(0, WORD_TO_TYPE);
|
||||||
mLatinIME.onUpdateSelection(0, 0, WORD_TO_TYPE.length(), WORD_TO_TYPE.length(), -1, -1);
|
mLatinIME.onUpdateSelection(0, 0, WORD_TO_TYPE.length(), WORD_TO_TYPE.length(), -1, -1);
|
||||||
type(Keyboard.CODE_DELETE);
|
type(Constants.CODE_DELETE);
|
||||||
assertEquals("press suggestion then backspace", EXPECTED_RESULT,
|
assertEquals("press suggestion then backspace", EXPECTED_RESULT,
|
||||||
mTextView.getText().toString());
|
mTextView.getText().toString());
|
||||||
}
|
}
|
||||||
|
@ -48,7 +46,7 @@ public class InputLogicTests extends InputTestsBase {
|
||||||
mLatinIME.onUpdateSelection(0, 0, WORD_TO_TYPE.length(), WORD_TO_TYPE.length(), -1, -1);
|
mLatinIME.onUpdateSelection(0, 0, WORD_TO_TYPE.length(), WORD_TO_TYPE.length(), -1, -1);
|
||||||
assertEquals("pick typed word over auto-correction then backspace", WORD_TO_PICK,
|
assertEquals("pick typed word over auto-correction then backspace", WORD_TO_PICK,
|
||||||
mTextView.getText().toString());
|
mTextView.getText().toString());
|
||||||
type(Keyboard.CODE_DELETE);
|
type(Constants.CODE_DELETE);
|
||||||
assertEquals("pick typed word over auto-correction then backspace", EXPECTED_RESULT,
|
assertEquals("pick typed word over auto-correction then backspace", EXPECTED_RESULT,
|
||||||
mTextView.getText().toString());
|
mTextView.getText().toString());
|
||||||
}
|
}
|
||||||
|
@ -63,7 +61,7 @@ public class InputLogicTests extends InputTestsBase {
|
||||||
mLatinIME.onUpdateSelection(0, 0, WORD_TO_TYPE.length(), WORD_TO_TYPE.length(), -1, -1);
|
mLatinIME.onUpdateSelection(0, 0, WORD_TO_TYPE.length(), WORD_TO_TYPE.length(), -1, -1);
|
||||||
assertEquals("pick typed word over auto-correction then backspace", WORD_TO_TYPE,
|
assertEquals("pick typed word over auto-correction then backspace", WORD_TO_TYPE,
|
||||||
mTextView.getText().toString());
|
mTextView.getText().toString());
|
||||||
type(Keyboard.CODE_DELETE);
|
type(Constants.CODE_DELETE);
|
||||||
assertEquals("pick typed word over auto-correction then backspace", EXPECTED_RESULT,
|
assertEquals("pick typed word over auto-correction then backspace", EXPECTED_RESULT,
|
||||||
mTextView.getText().toString());
|
mTextView.getText().toString());
|
||||||
}
|
}
|
||||||
|
@ -79,7 +77,7 @@ public class InputLogicTests extends InputTestsBase {
|
||||||
mLatinIME.onUpdateSelection(0, 0, WORD_TO_TYPE.length(), WORD_TO_TYPE.length(), -1, -1);
|
mLatinIME.onUpdateSelection(0, 0, WORD_TO_TYPE.length(), WORD_TO_TYPE.length(), -1, -1);
|
||||||
assertEquals("pick different suggestion then backspace", WORD_TO_PICK,
|
assertEquals("pick different suggestion then backspace", WORD_TO_PICK,
|
||||||
mTextView.getText().toString());
|
mTextView.getText().toString());
|
||||||
type(Keyboard.CODE_DELETE);
|
type(Constants.CODE_DELETE);
|
||||||
assertEquals("pick different suggestion then backspace", EXPECTED_RESULT,
|
assertEquals("pick different suggestion then backspace", EXPECTED_RESULT,
|
||||||
mTextView.getText().toString());
|
mTextView.getText().toString());
|
||||||
}
|
}
|
||||||
|
@ -100,7 +98,7 @@ public class InputLogicTests extends InputTestsBase {
|
||||||
// And now we simulate the user actually selecting some text.
|
// And now we simulate the user actually selecting some text.
|
||||||
mLatinIME.onUpdateSelection(typedLength, typedLength,
|
mLatinIME.onUpdateSelection(typedLength, typedLength,
|
||||||
SELECTION_START, SELECTION_END, -1, -1);
|
SELECTION_START, SELECTION_END, -1, -1);
|
||||||
type(Keyboard.CODE_DELETE);
|
type(Constants.CODE_DELETE);
|
||||||
assertEquals("delete selection", EXPECTED_RESULT, mTextView.getText().toString());
|
assertEquals("delete selection", EXPECTED_RESULT, mTextView.getText().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,7 +121,7 @@ public class InputLogicTests extends InputTestsBase {
|
||||||
final String EXPECTED_RESULT = "tgis.";
|
final String EXPECTED_RESULT = "tgis.";
|
||||||
type(STRING_TO_TYPE);
|
type(STRING_TO_TYPE);
|
||||||
mLatinIME.onUpdateSelection(0, 0, STRING_TO_TYPE.length(), STRING_TO_TYPE.length(), -1, -1);
|
mLatinIME.onUpdateSelection(0, 0, STRING_TO_TYPE.length(), STRING_TO_TYPE.length(), -1, -1);
|
||||||
type(Keyboard.CODE_DELETE);
|
type(Constants.CODE_DELETE);
|
||||||
assertEquals("auto-correct with period then revert", EXPECTED_RESULT,
|
assertEquals("auto-correct with period then revert", EXPECTED_RESULT,
|
||||||
mTextView.getText().toString());
|
mTextView.getText().toString());
|
||||||
}
|
}
|
||||||
|
@ -133,7 +131,7 @@ public class InputLogicTests extends InputTestsBase {
|
||||||
final String EXPECTED_RESULT = "tgis ";
|
final String EXPECTED_RESULT = "tgis ";
|
||||||
type(STRING_TO_TYPE);
|
type(STRING_TO_TYPE);
|
||||||
mLatinIME.onUpdateSelection(0, 0, STRING_TO_TYPE.length(), STRING_TO_TYPE.length(), -1, -1);
|
mLatinIME.onUpdateSelection(0, 0, STRING_TO_TYPE.length(), STRING_TO_TYPE.length(), -1, -1);
|
||||||
type(Keyboard.CODE_DELETE);
|
type(Constants.CODE_DELETE);
|
||||||
assertEquals("auto-correct with space then revert", EXPECTED_RESULT,
|
assertEquals("auto-correct with space then revert", EXPECTED_RESULT,
|
||||||
mTextView.getText().toString());
|
mTextView.getText().toString());
|
||||||
}
|
}
|
||||||
|
@ -143,7 +141,7 @@ public class InputLogicTests extends InputTestsBase {
|
||||||
final String EXPECTED_RESULT = "this";
|
final String EXPECTED_RESULT = "this";
|
||||||
type(STRING_TO_TYPE);
|
type(STRING_TO_TYPE);
|
||||||
mLatinIME.onUpdateSelection(0, 0, STRING_TO_TYPE.length(), STRING_TO_TYPE.length(), -1, -1);
|
mLatinIME.onUpdateSelection(0, 0, STRING_TO_TYPE.length(), STRING_TO_TYPE.length(), -1, -1);
|
||||||
type(Keyboard.CODE_DELETE);
|
type(Constants.CODE_DELETE);
|
||||||
assertEquals("auto-correct with space does not revert", EXPECTED_RESULT,
|
assertEquals("auto-correct with space does not revert", EXPECTED_RESULT,
|
||||||
mTextView.getText().toString());
|
mTextView.getText().toString());
|
||||||
}
|
}
|
||||||
|
@ -159,7 +157,7 @@ public class InputLogicTests extends InputTestsBase {
|
||||||
final String STRING_TO_TYPE = "this ";
|
final String STRING_TO_TYPE = "this ";
|
||||||
final String EXPECTED_RESULT = "this ";
|
final String EXPECTED_RESULT = "this ";
|
||||||
type(STRING_TO_TYPE);
|
type(STRING_TO_TYPE);
|
||||||
type(Keyboard.CODE_DELETE);
|
type(Constants.CODE_DELETE);
|
||||||
assertEquals("double space make a period", EXPECTED_RESULT, mTextView.getText().toString());
|
assertEquals("double space make a period", EXPECTED_RESULT, mTextView.getText().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,7 +171,7 @@ public class InputLogicTests extends InputTestsBase {
|
||||||
mInputConnection.setSelection(NEW_CURSOR_POSITION, NEW_CURSOR_POSITION);
|
mInputConnection.setSelection(NEW_CURSOR_POSITION, NEW_CURSOR_POSITION);
|
||||||
mLatinIME.onUpdateSelection(typedLength, typedLength,
|
mLatinIME.onUpdateSelection(typedLength, typedLength,
|
||||||
NEW_CURSOR_POSITION, NEW_CURSOR_POSITION, -1, -1);
|
NEW_CURSOR_POSITION, NEW_CURSOR_POSITION, -1, -1);
|
||||||
type(Keyboard.CODE_DELETE);
|
type(Constants.CODE_DELETE);
|
||||||
assertEquals("auto correct then move cursor to start of line then backspace",
|
assertEquals("auto correct then move cursor to start of line then backspace",
|
||||||
EXPECTED_RESULT, mTextView.getText().toString());
|
EXPECTED_RESULT, mTextView.getText().toString());
|
||||||
}
|
}
|
||||||
|
@ -188,7 +186,7 @@ public class InputLogicTests extends InputTestsBase {
|
||||||
mInputConnection.setSelection(NEW_CURSOR_POSITION, NEW_CURSOR_POSITION);
|
mInputConnection.setSelection(NEW_CURSOR_POSITION, NEW_CURSOR_POSITION);
|
||||||
mLatinIME.onUpdateSelection(typedLength, typedLength,
|
mLatinIME.onUpdateSelection(typedLength, typedLength,
|
||||||
NEW_CURSOR_POSITION, NEW_CURSOR_POSITION, -1, -1);
|
NEW_CURSOR_POSITION, NEW_CURSOR_POSITION, -1, -1);
|
||||||
type(Keyboard.CODE_DELETE);
|
type(Constants.CODE_DELETE);
|
||||||
assertEquals("auto correct then move cursor then backspace",
|
assertEquals("auto correct then move cursor then backspace",
|
||||||
EXPECTED_RESULT, mTextView.getText().toString());
|
EXPECTED_RESULT, mTextView.getText().toString());
|
||||||
}
|
}
|
||||||
|
@ -264,7 +262,7 @@ public class InputLogicTests extends InputTestsBase {
|
||||||
final String WORD_TO_TYPE = "this";
|
final String WORD_TO_TYPE = "this";
|
||||||
type(WORD_TO_TYPE);
|
type(WORD_TO_TYPE);
|
||||||
for (int i = 0; i < WORD_TO_TYPE.length(); ++i) {
|
for (int i = 0; i < WORD_TO_TYPE.length(); ++i) {
|
||||||
type(Keyboard.CODE_DELETE);
|
type(Constants.CODE_DELETE);
|
||||||
}
|
}
|
||||||
assertEquals("delete whole composing word", "", mTextView.getText().toString());
|
assertEquals("delete whole composing word", "", mTextView.getText().toString());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue