Merge "Add CODE_CAPSLOCK for long press shift key"
This commit is contained in:
commit
0bfc2bc419
15 changed files with 99 additions and 143 deletions
|
@ -36,34 +36,38 @@
|
||||||
</default>
|
</default>
|
||||||
</switch>
|
</switch>
|
||||||
<!-- Functional key styles -->
|
<!-- Functional key styles -->
|
||||||
|
<!-- Base style for shift key. A single space is used for dummy label in moreKeys. -->
|
||||||
|
<key-style
|
||||||
|
latin:styleName="baseForShiftKeyStyle"
|
||||||
|
latin:code="!code/key_shift"
|
||||||
|
latin:keyActionFlags="noKeyPreview"
|
||||||
|
latin:keyLabelFlags="preserveCase"
|
||||||
|
latin:moreKeys="!noPanelAutoMoreKey!, |!code/key_capslock" />
|
||||||
<switch>
|
<switch>
|
||||||
<case
|
<case
|
||||||
latin:keyboardLayoutSetElement="alphabetManualShifted|alphabetAutomaticShifted"
|
latin:keyboardLayoutSetElement="alphabetManualShifted|alphabetAutomaticShifted"
|
||||||
>
|
>
|
||||||
<key-style
|
<key-style
|
||||||
latin:styleName="shiftKeyStyle"
|
latin:styleName="shiftKeyStyle"
|
||||||
latin:code="!code/key_shift"
|
|
||||||
latin:keyIcon="!icon/shift_key_shifted"
|
latin:keyIcon="!icon/shift_key_shifted"
|
||||||
latin:keyActionFlags="noKeyPreview"
|
latin:backgroundType="stickyOff"
|
||||||
latin:backgroundType="stickyOff" />
|
latin:parentStyle="baseForShiftKeyStyle" />
|
||||||
</case>
|
</case>
|
||||||
<case
|
<case
|
||||||
latin:keyboardLayoutSetElement="alphabetShiftLocked|alphabetShiftLockShifted"
|
latin:keyboardLayoutSetElement="alphabetShiftLocked|alphabetShiftLockShifted"
|
||||||
>
|
>
|
||||||
<key-style
|
<key-style
|
||||||
latin:styleName="shiftKeyStyle"
|
latin:styleName="shiftKeyStyle"
|
||||||
latin:code="!code/key_shift"
|
|
||||||
latin:keyIcon="!icon/shift_key_shifted"
|
latin:keyIcon="!icon/shift_key_shifted"
|
||||||
latin:keyActionFlags="noKeyPreview"
|
latin:backgroundType="stickyOn"
|
||||||
latin:backgroundType="stickyOn" />
|
latin:parentStyle="baseForShiftKeyStyle" />
|
||||||
</case>
|
</case>
|
||||||
<default>
|
<default>
|
||||||
<key-style
|
<key-style
|
||||||
latin:styleName="shiftKeyStyle"
|
latin:styleName="shiftKeyStyle"
|
||||||
latin:code="!code/key_shift"
|
|
||||||
latin:keyIcon="!icon/shift_key"
|
latin:keyIcon="!icon/shift_key"
|
||||||
latin:keyActionFlags="noKeyPreview"
|
latin:backgroundType="stickyOff"
|
||||||
latin:backgroundType="stickyOff" />
|
latin:parentStyle="baseForShiftKeyStyle" />
|
||||||
</default>
|
</default>
|
||||||
</switch>
|
</switch>
|
||||||
<key-style
|
<key-style
|
||||||
|
|
|
@ -35,34 +35,38 @@
|
||||||
latin:keyLabelFlags="hasShiftedLetterHint" />
|
latin:keyLabelFlags="hasShiftedLetterHint" />
|
||||||
</default>
|
</default>
|
||||||
</switch>
|
</switch>
|
||||||
|
<!-- Base style for shift key. A single space is used for dummy label in moreKeys. -->
|
||||||
|
<key-style
|
||||||
|
latin:styleName="baseForShiftKeyStyle"
|
||||||
|
latin:code="!code/key_shift"
|
||||||
|
latin:keyActionFlags="noKeyPreview"
|
||||||
|
latin:keyLabelFlags="preserveCase"
|
||||||
|
latin:moreKeys="!noPanelAutoMoreKey!, |!code/key_capslock" />
|
||||||
<switch>
|
<switch>
|
||||||
<case
|
<case
|
||||||
latin:keyboardLayoutSetElement="alphabetManualShifted|alphabetAutomaticShifted"
|
latin:keyboardLayoutSetElement="alphabetManualShifted|alphabetAutomaticShifted"
|
||||||
>
|
>
|
||||||
<key-style
|
<key-style
|
||||||
latin:styleName="shiftKeyStyle"
|
latin:styleName="shiftKeyStyle"
|
||||||
latin:code="!code/key_shift"
|
|
||||||
latin:keyIcon="!icon/shift_key_shifted"
|
latin:keyIcon="!icon/shift_key_shifted"
|
||||||
latin:keyActionFlags="noKeyPreview"
|
latin:backgroundType="stickyOff"
|
||||||
latin:backgroundType="stickyOff" />
|
latin:parentStyle="baseForShiftKeyStyle" />
|
||||||
</case>
|
</case>
|
||||||
<case
|
<case
|
||||||
latin:keyboardLayoutSetElement="alphabetShiftLocked|alphabetShiftLockShifted"
|
latin:keyboardLayoutSetElement="alphabetShiftLocked|alphabetShiftLockShifted"
|
||||||
>
|
>
|
||||||
<key-style
|
<key-style
|
||||||
latin:styleName="shiftKeyStyle"
|
latin:styleName="shiftKeyStyle"
|
||||||
latin:code="!code/key_shift"
|
|
||||||
latin:keyIcon="!icon/shift_key_shifted"
|
latin:keyIcon="!icon/shift_key_shifted"
|
||||||
latin:keyActionFlags="noKeyPreview"
|
latin:backgroundType="stickyOn"
|
||||||
latin:backgroundType="stickyOn" />
|
latin:parentStyle="baseForShiftKeyStyle" />
|
||||||
</case>
|
</case>
|
||||||
<default>
|
<default>
|
||||||
<key-style
|
<key-style
|
||||||
latin:styleName="shiftKeyStyle"
|
latin:styleName="shiftKeyStyle"
|
||||||
latin:code="!code/key_shift"
|
|
||||||
latin:keyIcon="!icon/shift_key"
|
latin:keyIcon="!icon/shift_key"
|
||||||
latin:keyActionFlags="noKeyPreview"
|
latin:backgroundType="stickyOff"
|
||||||
latin:backgroundType="stickyOff" />
|
latin:parentStyle="baseForShiftKeyStyle" />
|
||||||
</default>
|
</default>
|
||||||
</switch>
|
</switch>
|
||||||
<key-style
|
<key-style
|
||||||
|
|
|
@ -25,34 +25,38 @@
|
||||||
<include
|
<include
|
||||||
latin:keyboardLayout="@xml/key_styles_f1" />
|
latin:keyboardLayout="@xml/key_styles_f1" />
|
||||||
<!-- Functional key styles -->
|
<!-- Functional key styles -->
|
||||||
|
<!-- Base style for shift key. A single space is used for dummy label in moreKeys. -->
|
||||||
|
<key-style
|
||||||
|
latin:styleName="baseForShiftKeyStyle"
|
||||||
|
latin:code="!code/key_shift"
|
||||||
|
latin:keyActionFlags="noKeyPreview"
|
||||||
|
latin:keyLabelFlags="preserveCase"
|
||||||
|
latin:moreKeys="!noPanelAutoMoreKey!, |!code/key_capslock" />
|
||||||
<switch>
|
<switch>
|
||||||
<case
|
<case
|
||||||
latin:keyboardLayoutSetElement="alphabetManualShifted|alphabetAutomaticShifted"
|
latin:keyboardLayoutSetElement="alphabetManualShifted|alphabetAutomaticShifted"
|
||||||
>
|
>
|
||||||
<key-style
|
<key-style
|
||||||
latin:styleName="shiftKeyStyle"
|
latin:styleName="shiftKeyStyle"
|
||||||
latin:code="!code/key_shift"
|
|
||||||
latin:keyIcon="!icon/shift_key_shifted"
|
latin:keyIcon="!icon/shift_key_shifted"
|
||||||
latin:keyActionFlags="noKeyPreview"
|
latin:backgroundType="stickyOff"
|
||||||
latin:backgroundType="stickyOff" />
|
latin:parentStyle="baseForShiftKeyStyle" />
|
||||||
</case>
|
</case>
|
||||||
<case
|
<case
|
||||||
latin:keyboardLayoutSetElement="alphabetShiftLocked|alphabetShiftLockShifted"
|
latin:keyboardLayoutSetElement="alphabetShiftLocked|alphabetShiftLockShifted"
|
||||||
>
|
>
|
||||||
<key-style
|
<key-style
|
||||||
latin:styleName="shiftKeyStyle"
|
latin:styleName="shiftKeyStyle"
|
||||||
latin:code="!code/key_shift"
|
|
||||||
latin:keyIcon="!icon/shift_key_shifted"
|
latin:keyIcon="!icon/shift_key_shifted"
|
||||||
latin:keyActionFlags="noKeyPreview"
|
latin:backgroundType="stickyOn"
|
||||||
latin:backgroundType="stickyOn" />
|
latin:parentStyle="baseForShiftKeyStyle" />
|
||||||
</case>
|
</case>
|
||||||
<default>
|
<default>
|
||||||
<key-style
|
<key-style
|
||||||
latin:styleName="shiftKeyStyle"
|
latin:styleName="shiftKeyStyle"
|
||||||
latin:code="!code/key_shift"
|
|
||||||
latin:keyIcon="!icon/shift_key"
|
latin:keyIcon="!icon/shift_key"
|
||||||
latin:keyActionFlags="noKeyPreview"
|
latin:backgroundType="stickyOff"
|
||||||
latin:backgroundType="stickyOff" />
|
latin:parentStyle="baseForShiftKeyStyle" />
|
||||||
</default>
|
</default>
|
||||||
</switch>
|
</switch>
|
||||||
<key-style
|
<key-style
|
||||||
|
|
|
@ -117,7 +117,7 @@
|
||||||
<Key
|
<Key
|
||||||
latin:code="0x002F"
|
latin:code="0x002F"
|
||||||
latin:keyLabel="/ :"
|
latin:keyLabel="/ :"
|
||||||
latin:moreKeys="!embeddedMoreKey!,:"
|
latin:moreKeys="!noPanelAutoMoreKey!,:"
|
||||||
latin:keyStyle="numKeyStyle" />
|
latin:keyStyle="numKeyStyle" />
|
||||||
</case>
|
</case>
|
||||||
<default>
|
<default>
|
||||||
|
|
|
@ -70,7 +70,7 @@
|
||||||
latin:keyStyle="num0KeyStyle"
|
latin:keyStyle="num0KeyStyle"
|
||||||
latin:code="0x0030"
|
latin:code="0x0030"
|
||||||
latin:keyLabel="0 +"
|
latin:keyLabel="0 +"
|
||||||
latin:moreKeys="!embeddedMoreKey!,+" />
|
latin:moreKeys="!noPanelAutoMoreKey!,+" />
|
||||||
<Key
|
<Key
|
||||||
latin:keyStyle="numSpaceKeyStyle" />
|
latin:keyStyle="numSpaceKeyStyle" />
|
||||||
<Key
|
<Key
|
||||||
|
|
|
@ -113,12 +113,12 @@ public class Key implements Comparable<Key> {
|
||||||
private static final int MORE_KEYS_FLAGS_FIXED_COLUMN_ORDER = 0x80000000;
|
private static final int MORE_KEYS_FLAGS_FIXED_COLUMN_ORDER = 0x80000000;
|
||||||
private static final int MORE_KEYS_FLAGS_HAS_LABELS = 0x40000000;
|
private static final int MORE_KEYS_FLAGS_HAS_LABELS = 0x40000000;
|
||||||
private static final int MORE_KEYS_FLAGS_NEEDS_DIVIDERS = 0x20000000;
|
private static final int MORE_KEYS_FLAGS_NEEDS_DIVIDERS = 0x20000000;
|
||||||
private static final int MORE_KEYS_FLAGS_EMBEDDED_MORE_KEY = 0x10000000;
|
private static final int MORE_KEYS_FLAGS_NO_PANEL_AUTO_MORE_KEY = 0x10000000;
|
||||||
private static final String MORE_KEYS_AUTO_COLUMN_ORDER = "!autoColumnOrder!";
|
private static final String MORE_KEYS_AUTO_COLUMN_ORDER = "!autoColumnOrder!";
|
||||||
private static final String MORE_KEYS_FIXED_COLUMN_ORDER = "!fixedColumnOrder!";
|
private static final String MORE_KEYS_FIXED_COLUMN_ORDER = "!fixedColumnOrder!";
|
||||||
private static final String MORE_KEYS_HAS_LABELS = "!hasLabels!";
|
private static final String MORE_KEYS_HAS_LABELS = "!hasLabels!";
|
||||||
private static final String MORE_KEYS_NEEDS_DIVIDERS = "!needsDividers!";
|
private static final String MORE_KEYS_NEEDS_DIVIDERS = "!needsDividers!";
|
||||||
private static final String MORE_KEYS_EMBEDDED_MORE_KEY = "!embeddedMoreKey!";
|
private static final String MORE_KEYS_NO_PANEL_AUTO_MORE_KEY = "!noPanelAutoMoreKey!";
|
||||||
|
|
||||||
/** Background type that represents different key background visual than normal one. */
|
/** Background type that represents different key background visual than normal one. */
|
||||||
public final int mBackgroundType;
|
public final int mBackgroundType;
|
||||||
|
@ -281,8 +281,8 @@ public class Key implements Comparable<Key> {
|
||||||
if (KeySpecParser.getBooleanValue(moreKeys, MORE_KEYS_NEEDS_DIVIDERS)) {
|
if (KeySpecParser.getBooleanValue(moreKeys, MORE_KEYS_NEEDS_DIVIDERS)) {
|
||||||
moreKeysColumn |= MORE_KEYS_FLAGS_NEEDS_DIVIDERS;
|
moreKeysColumn |= MORE_KEYS_FLAGS_NEEDS_DIVIDERS;
|
||||||
}
|
}
|
||||||
if (KeySpecParser.getBooleanValue(moreKeys, MORE_KEYS_EMBEDDED_MORE_KEY)) {
|
if (KeySpecParser.getBooleanValue(moreKeys, MORE_KEYS_NO_PANEL_AUTO_MORE_KEY)) {
|
||||||
moreKeysColumn |= MORE_KEYS_FLAGS_EMBEDDED_MORE_KEY;
|
moreKeysColumn |= MORE_KEYS_FLAGS_NO_PANEL_AUTO_MORE_KEY;
|
||||||
}
|
}
|
||||||
mMoreKeysColumnAndFlags = moreKeysColumn;
|
mMoreKeysColumnAndFlags = moreKeysColumn;
|
||||||
|
|
||||||
|
@ -657,8 +657,8 @@ public class Key implements Comparable<Key> {
|
||||||
return (mMoreKeysColumnAndFlags & MORE_KEYS_FLAGS_NEEDS_DIVIDERS) != 0;
|
return (mMoreKeysColumnAndFlags & MORE_KEYS_FLAGS_NEEDS_DIVIDERS) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final boolean hasEmbeddedMoreKey() {
|
public final boolean hasNoPanelAutoMoreKey() {
|
||||||
return (mMoreKeysColumnAndFlags & MORE_KEYS_FLAGS_EMBEDDED_MORE_KEY) != 0;
|
return (mMoreKeysColumnAndFlags & MORE_KEYS_FLAGS_NO_PANEL_AUTO_MORE_KEY) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final String getOutputText() {
|
public final String getOutputText() {
|
||||||
|
|
|
@ -32,7 +32,6 @@ import com.android.inputmethod.keyboard.KeyboardLayoutSet.KeyboardLayoutSetExcep
|
||||||
import com.android.inputmethod.keyboard.PointerTracker.TimerProxy;
|
import com.android.inputmethod.keyboard.PointerTracker.TimerProxy;
|
||||||
import com.android.inputmethod.keyboard.internal.KeyboardState;
|
import com.android.inputmethod.keyboard.internal.KeyboardState;
|
||||||
import com.android.inputmethod.latin.AudioAndHapticFeedbackManager;
|
import com.android.inputmethod.latin.AudioAndHapticFeedbackManager;
|
||||||
import com.android.inputmethod.latin.Constants;
|
|
||||||
import com.android.inputmethod.latin.InputView;
|
import com.android.inputmethod.latin.InputView;
|
||||||
import com.android.inputmethod.latin.LatinIME;
|
import com.android.inputmethod.latin.LatinIME;
|
||||||
import com.android.inputmethod.latin.LatinImeLogger;
|
import com.android.inputmethod.latin.LatinImeLogger;
|
||||||
|
@ -300,26 +299,6 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||||
? keyboardView.getTimerProxy().isInDoubleTapShiftKeyTimeout() : false;
|
? keyboardView.getTimerProxy().isInDoubleTapShiftKeyTimeout() : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements {@link KeyboardState.SwitchActions}.
|
|
||||||
@Override
|
|
||||||
public void startLongPressTimer(final int code) {
|
|
||||||
final MainKeyboardView keyboardView = getMainKeyboardView();
|
|
||||||
if (keyboardView != null) {
|
|
||||||
final TimerProxy timer = keyboardView.getTimerProxy();
|
|
||||||
timer.startLongPressTimer(code);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Implements {@link KeyboardState.SwitchActions}.
|
|
||||||
@Override
|
|
||||||
public void cancelLongPressTimer() {
|
|
||||||
final MainKeyboardView keyboardView = getMainKeyboardView();
|
|
||||||
if (keyboardView != null) {
|
|
||||||
final TimerProxy timer = keyboardView.getTimerProxy();
|
|
||||||
timer.cancelLongPressTimer();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void hapticAndAudioFeedback(final int code) {
|
private void hapticAndAudioFeedback(final int code) {
|
||||||
if (mKeyboardView == null || mKeyboardView.isInSlidingKeyInput()) {
|
if (mKeyboardView == null || mKeyboardView.isInSlidingKeyInput()) {
|
||||||
return;
|
return;
|
||||||
|
@ -327,14 +306,6 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||||
AudioAndHapticFeedbackManager.getInstance().hapticAndAudioFeedback(code, mKeyboardView);
|
AudioAndHapticFeedbackManager.getInstance().hapticAndAudioFeedback(code, mKeyboardView);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onLongPressTimeout(final int code) {
|
|
||||||
mState.onLongPressTimeout(code);
|
|
||||||
final Keyboard keyboard = getKeyboard();
|
|
||||||
if (keyboard != null && keyboard.mId.isAlphabetKeyboard() && code == Constants.CODE_SHIFT) {
|
|
||||||
hapticAndAudioFeedback(code);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates state machine to figure out when to automatically switch back to the previous mode.
|
* Updates state machine to figure out when to automatically switch back to the previous mode.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -248,11 +248,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MSG_LONGPRESS_KEY:
|
case MSG_LONGPRESS_KEY:
|
||||||
if (tracker != null) {
|
keyboardView.onLongPress(tracker);
|
||||||
keyboardView.onLongPress(tracker);
|
|
||||||
} else {
|
|
||||||
KeyboardSwitcher.getInstance().onLongPressTimeout(msg.arg1);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case MSG_UPDATE_BATCH_INPUT:
|
case MSG_UPDATE_BATCH_INPUT:
|
||||||
tracker.updateBatchInputByTimer(SystemClock.uptimeMillis());
|
tracker.updateBatchInputByTimer(SystemClock.uptimeMillis());
|
||||||
|
@ -283,23 +279,6 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
return hasMessages(MSG_REPEAT_KEY);
|
return hasMessages(MSG_REPEAT_KEY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void startLongPressTimer(final int code) {
|
|
||||||
cancelLongPressTimer();
|
|
||||||
final int delay;
|
|
||||||
switch (code) {
|
|
||||||
case Constants.CODE_SHIFT:
|
|
||||||
delay = mLongPressShiftLockTimeout;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
delay = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (delay > 0) {
|
|
||||||
sendMessageDelayed(obtainMessage(MSG_LONGPRESS_KEY, code, 0), delay);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startLongPressTimer(final PointerTracker tracker) {
|
public void startLongPressTimer(final PointerTracker tracker) {
|
||||||
cancelLongPressTimer();
|
cancelLongPressTimer();
|
||||||
|
@ -1002,7 +981,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
ResearchLogger.mainKeyboardView_onLongPress();
|
ResearchLogger.mainKeyboardView_onLongPress();
|
||||||
}
|
}
|
||||||
final int code = key.mCode;
|
final int code = key.mCode;
|
||||||
if (key.hasEmbeddedMoreKey()) {
|
if (key.hasNoPanelAutoMoreKey()) {
|
||||||
final int embeddedCode = key.mMoreKeys[0].mCode;
|
final int embeddedCode = key.mMoreKeys[0].mCode;
|
||||||
tracker.onLongPressed();
|
tracker.onLongPressed();
|
||||||
invokeCodeInput(embeddedCode);
|
invokeCodeInput(embeddedCode);
|
||||||
|
|
|
@ -92,7 +92,6 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
public boolean isTypingState();
|
public boolean isTypingState();
|
||||||
public void startKeyRepeatTimer(PointerTracker tracker);
|
public void startKeyRepeatTimer(PointerTracker tracker);
|
||||||
public void startLongPressTimer(PointerTracker tracker);
|
public void startLongPressTimer(PointerTracker tracker);
|
||||||
public void startLongPressTimer(int code);
|
|
||||||
public void cancelLongPressTimer();
|
public void cancelLongPressTimer();
|
||||||
public void startDoubleTapShiftKeyTimer();
|
public void startDoubleTapShiftKeyTimer();
|
||||||
public void cancelDoubleTapShiftKeyTimer();
|
public void cancelDoubleTapShiftKeyTimer();
|
||||||
|
@ -112,8 +111,6 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
@Override
|
@Override
|
||||||
public void startLongPressTimer(PointerTracker tracker) {}
|
public void startLongPressTimer(PointerTracker tracker) {}
|
||||||
@Override
|
@Override
|
||||||
public void startLongPressTimer(int code) {}
|
|
||||||
@Override
|
|
||||||
public void cancelLongPressTimer() {}
|
public void cancelLongPressTimer() {}
|
||||||
@Override
|
@Override
|
||||||
public void startDoubleTapShiftKeyTimer() {}
|
public void startDoubleTapShiftKeyTimer() {}
|
||||||
|
|
|
@ -43,6 +43,7 @@ public final class KeyboardCodesSet {
|
||||||
"key_enter",
|
"key_enter",
|
||||||
"key_space",
|
"key_space",
|
||||||
"key_shift",
|
"key_shift",
|
||||||
|
"key_capslock",
|
||||||
"key_switch_alpha_symbol",
|
"key_switch_alpha_symbol",
|
||||||
"key_output_text",
|
"key_output_text",
|
||||||
"key_delete",
|
"key_delete",
|
||||||
|
@ -79,6 +80,7 @@ public final class KeyboardCodesSet {
|
||||||
Constants.CODE_ENTER,
|
Constants.CODE_ENTER,
|
||||||
Constants.CODE_SPACE,
|
Constants.CODE_SPACE,
|
||||||
Constants.CODE_SHIFT,
|
Constants.CODE_SHIFT,
|
||||||
|
Constants.CODE_CAPSLOCK,
|
||||||
Constants.CODE_SWITCH_ALPHA_SYMBOL,
|
Constants.CODE_SWITCH_ALPHA_SYMBOL,
|
||||||
Constants.CODE_OUTPUT_TEXT,
|
Constants.CODE_OUTPUT_TEXT,
|
||||||
Constants.CODE_DELETE,
|
Constants.CODE_DELETE,
|
||||||
|
@ -116,6 +118,7 @@ public final class KeyboardCodesSet {
|
||||||
DEFAULT[12],
|
DEFAULT[12],
|
||||||
DEFAULT[13],
|
DEFAULT[13],
|
||||||
DEFAULT[14],
|
DEFAULT[14],
|
||||||
|
DEFAULT[15],
|
||||||
CODE_RIGHT_PARENTHESIS,
|
CODE_RIGHT_PARENTHESIS,
|
||||||
CODE_LEFT_PARENTHESIS,
|
CODE_LEFT_PARENTHESIS,
|
||||||
CODE_GREATER_THAN_SIGN,
|
CODE_GREATER_THAN_SIGN,
|
||||||
|
|
|
@ -30,7 +30,7 @@ import com.android.inputmethod.latin.RecapitalizeStatus;
|
||||||
* The input events are {@link #onLoadKeyboard()}, {@link #onSaveKeyboardState()},
|
* The input events are {@link #onLoadKeyboard()}, {@link #onSaveKeyboardState()},
|
||||||
* {@link #onPressKey(int,boolean,int)}, {@link #onReleaseKey(int,boolean)},
|
* {@link #onPressKey(int,boolean,int)}, {@link #onReleaseKey(int,boolean)},
|
||||||
* {@link #onCodeInput(int,int)}, {@link #onFinishSlidingInput()}, {@link #onCancelInput()},
|
* {@link #onCodeInput(int,int)}, {@link #onFinishSlidingInput()}, {@link #onCancelInput()},
|
||||||
* {@link #onUpdateShiftState(int,int)}, {@link #onLongPressTimeout(int)}.
|
* {@link #onUpdateShiftState(int,int)}.
|
||||||
*
|
*
|
||||||
* The actions are {@link SwitchActions}'s methods.
|
* The actions are {@link SwitchActions}'s methods.
|
||||||
*/
|
*/
|
||||||
|
@ -56,8 +56,6 @@ public final class KeyboardState {
|
||||||
public void startDoubleTapShiftKeyTimer();
|
public void startDoubleTapShiftKeyTimer();
|
||||||
public boolean isInDoubleTapShiftKeyTimeout();
|
public boolean isInDoubleTapShiftKeyTimeout();
|
||||||
public void cancelDoubleTapShiftKeyTimer();
|
public void cancelDoubleTapShiftKeyTimer();
|
||||||
public void startLongPressTimer(int code);
|
|
||||||
public void cancelLongPressTimer();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private final SwitchActions mSwitchActions;
|
private final SwitchActions mSwitchActions;
|
||||||
|
@ -320,13 +318,16 @@ public final class KeyboardState {
|
||||||
Log.d(TAG, "onPressKey: code=" + Constants.printableCode(code)
|
Log.d(TAG, "onPressKey: code=" + Constants.printableCode(code)
|
||||||
+ " single=" + isSinglePointer + " autoCaps=" + autoCaps + " " + this);
|
+ " single=" + isSinglePointer + " autoCaps=" + autoCaps + " " + this);
|
||||||
}
|
}
|
||||||
|
if (code != Constants.CODE_SHIFT) {
|
||||||
|
// Because the double tap shift key timer is to detect two consecutive shift key press,
|
||||||
|
// it should be canceled when a non-shift key is pressed.
|
||||||
|
mSwitchActions.cancelDoubleTapShiftKeyTimer();
|
||||||
|
}
|
||||||
if (code == Constants.CODE_SHIFT) {
|
if (code == Constants.CODE_SHIFT) {
|
||||||
onPressShift();
|
onPressShift();
|
||||||
} else if (code == Constants.CODE_SWITCH_ALPHA_SYMBOL) {
|
} else if (code == Constants.CODE_SWITCH_ALPHA_SYMBOL) {
|
||||||
onPressSymbol();
|
onPressSymbol();
|
||||||
} else {
|
} else {
|
||||||
mSwitchActions.cancelDoubleTapShiftKeyTimer();
|
|
||||||
mSwitchActions.cancelLongPressTimer();
|
|
||||||
mLongPressShiftLockFired = false;
|
mLongPressShiftLockFired = false;
|
||||||
mShiftKeyState.onOtherKeyPressed();
|
mShiftKeyState.onOtherKeyPressed();
|
||||||
mSymbolKeyState.onOtherKeyPressed();
|
mSymbolKeyState.onOtherKeyPressed();
|
||||||
|
@ -380,15 +381,6 @@ public final class KeyboardState {
|
||||||
mSymbolKeyState.onRelease();
|
mSymbolKeyState.onRelease();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onLongPressTimeout(final int code) {
|
|
||||||
if (DEBUG_EVENT) {
|
|
||||||
Log.d(TAG, "onLongPressTimeout: code=" + Constants.printableCode(code) + " " + this);
|
|
||||||
}
|
|
||||||
if (mIsAlphabetMode && code == Constants.CODE_SHIFT) {
|
|
||||||
mLongPressShiftLockFired = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onUpdateShiftState(final int autoCaps, final int recapitalizeMode) {
|
public void onUpdateShiftState(final int autoCaps, final int recapitalizeMode) {
|
||||||
if (DEBUG_EVENT) {
|
if (DEBUG_EVENT) {
|
||||||
Log.d(TAG, "onUpdateShiftState: autoCaps=" + autoCaps + ", recapitalizeMode="
|
Log.d(TAG, "onUpdateShiftState: autoCaps=" + autoCaps + ", recapitalizeMode="
|
||||||
|
@ -448,7 +440,9 @@ public final class KeyboardState {
|
||||||
mLongPressShiftLockFired = false;
|
mLongPressShiftLockFired = false;
|
||||||
// If we are recapitalizing, we don't do any of the normal processing, including
|
// If we are recapitalizing, we don't do any of the normal processing, including
|
||||||
// importantly the double tap timer.
|
// importantly the double tap timer.
|
||||||
if (RecapitalizeStatus.NOT_A_RECAPITALIZE_MODE != mRecapitalizeMode) return;
|
if (RecapitalizeStatus.NOT_A_RECAPITALIZE_MODE != mRecapitalizeMode) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (mIsAlphabetMode) {
|
if (mIsAlphabetMode) {
|
||||||
mIsInDoubleTapShiftKey = mSwitchActions.isInDoubleTapShiftKeyTimeout();
|
mIsInDoubleTapShiftKey = mSwitchActions.isInDoubleTapShiftKeyTimeout();
|
||||||
if (!mIsInDoubleTapShiftKey) {
|
if (!mIsInDoubleTapShiftKey) {
|
||||||
|
@ -484,7 +478,6 @@ public final class KeyboardState {
|
||||||
setShifted(MANUAL_SHIFT);
|
setShifted(MANUAL_SHIFT);
|
||||||
mShiftKeyState.onPress();
|
mShiftKeyState.onPress();
|
||||||
}
|
}
|
||||||
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.
|
||||||
|
@ -617,6 +610,12 @@ public final class KeyboardState {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (code == Constants.CODE_CAPSLOCK) {
|
||||||
|
// Changing shift lock state will be handled at {@link #onPressShift()} when the shift
|
||||||
|
// key is released.
|
||||||
|
mLongPressShiftLockFired = true;
|
||||||
|
}
|
||||||
|
|
||||||
// If the code is a letter, update keyboard shift state.
|
// If the code is a letter, update keyboard shift state.
|
||||||
if (Constants.isLetterCode(code)) {
|
if (Constants.isLetterCode(code)) {
|
||||||
updateAlphabetShiftState(autoCaps, RecapitalizeStatus.NOT_A_RECAPITALIZE_MODE);
|
updateAlphabetShiftState(autoCaps, RecapitalizeStatus.NOT_A_RECAPITALIZE_MODE);
|
||||||
|
|
|
@ -172,22 +172,23 @@ public final class Constants {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Special keys code. Must be negative.
|
* Special keys code. Must be negative.
|
||||||
* These should be aligned with KeyboardCodesSet.ID_TO_NAME[],
|
* These should be aligned with {@link KeyboardCodesSet#ID_TO_NAME},
|
||||||
* KeyboardCodesSet.DEFAULT[] and KeyboardCodesSet.RTL[]
|
* {@link KeyboardCodesSet#DEFAULT}, and {@link KeyboardCodesSet#RTL}.
|
||||||
*/
|
*/
|
||||||
public static final int CODE_SHIFT = -1;
|
public static final int CODE_SHIFT = -1;
|
||||||
public static final int CODE_SWITCH_ALPHA_SYMBOL = -2;
|
public static final int CODE_CAPSLOCK = -2;
|
||||||
public static final int CODE_OUTPUT_TEXT = -3;
|
public static final int CODE_SWITCH_ALPHA_SYMBOL = -3;
|
||||||
public static final int CODE_DELETE = -4;
|
public static final int CODE_OUTPUT_TEXT = -4;
|
||||||
public static final int CODE_SETTINGS = -5;
|
public static final int CODE_DELETE = -5;
|
||||||
public static final int CODE_SHORTCUT = -6;
|
public static final int CODE_SETTINGS = -6;
|
||||||
public static final int CODE_ACTION_NEXT = -7;
|
public static final int CODE_SHORTCUT = -7;
|
||||||
public static final int CODE_ACTION_PREVIOUS = -8;
|
public static final int CODE_ACTION_NEXT = -8;
|
||||||
public static final int CODE_LANGUAGE_SWITCH = -9;
|
public static final int CODE_ACTION_PREVIOUS = -9;
|
||||||
public static final int CODE_RESEARCH = -10;
|
public static final int CODE_LANGUAGE_SWITCH = -10;
|
||||||
public static final int CODE_SHIFT_ENTER = -11;
|
public static final int CODE_RESEARCH = -11;
|
||||||
|
public static final int CODE_SHIFT_ENTER = -12;
|
||||||
// Code value representing the code is not specified.
|
// Code value representing the code is not specified.
|
||||||
public static final int CODE_UNSPECIFIED = -12;
|
public static final int CODE_UNSPECIFIED = -13;
|
||||||
|
|
||||||
public static boolean isLetterCode(final int code) {
|
public static boolean isLetterCode(final int code) {
|
||||||
return code >= CODE_SPACE;
|
return code >= CODE_SPACE;
|
||||||
|
@ -196,6 +197,7 @@ public final class Constants {
|
||||||
public static String printableCode(final int code) {
|
public static String printableCode(final int code) {
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case CODE_SHIFT: return "shift";
|
case CODE_SHIFT: return "shift";
|
||||||
|
case CODE_CAPSLOCK: return "capslock";
|
||||||
case CODE_SWITCH_ALPHA_SYMBOL: return "symbol";
|
case CODE_SWITCH_ALPHA_SYMBOL: return "symbol";
|
||||||
case CODE_OUTPUT_TEXT: return "text";
|
case CODE_OUTPUT_TEXT: return "text";
|
||||||
case CODE_DELETE: return "delete";
|
case CODE_DELETE: return "delete";
|
||||||
|
|
|
@ -1420,8 +1420,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
LatinImeLogger.logOnDelete(x, y);
|
LatinImeLogger.logOnDelete(x, y);
|
||||||
break;
|
break;
|
||||||
case Constants.CODE_SHIFT:
|
case Constants.CODE_SHIFT:
|
||||||
// Note: calling back to the keyboard on Shift key is handled in onPressKey()
|
// Note: Calling back to the keyboard on Shift key is handled in
|
||||||
// and onReleaseKey().
|
// {@link #onPressKey(int,boolean)} and {@link #onReleaseKey(int,boolean)}.
|
||||||
final Keyboard currentKeyboard = switcher.getKeyboard();
|
final Keyboard currentKeyboard = switcher.getKeyboard();
|
||||||
if (null != currentKeyboard && currentKeyboard.mId.isAlphabetKeyboard()) {
|
if (null != currentKeyboard && currentKeyboard.mId.isAlphabetKeyboard()) {
|
||||||
// TODO: Instead of checking for alphabetic keyboard here, separate keycodes for
|
// TODO: Instead of checking for alphabetic keyboard here, separate keycodes for
|
||||||
|
@ -1429,9 +1429,13 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
handleRecapitalize();
|
handleRecapitalize();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case Constants.CODE_CAPSLOCK:
|
||||||
|
// Note: Changing keyboard to shift lock state is handled in
|
||||||
|
// {@link KeyboardSwitcher#onCodeInput(int)}.
|
||||||
|
break;
|
||||||
case Constants.CODE_SWITCH_ALPHA_SYMBOL:
|
case Constants.CODE_SWITCH_ALPHA_SYMBOL:
|
||||||
// Note: calling back to the keyboard on symbol key is handled in onPressKey()
|
// Note: Calling back to the keyboard on symbol key is handled in
|
||||||
// and onReleaseKey().
|
// {@link #onPressKey(int,boolean)} and {@link #onReleaseKey(int,boolean)}.
|
||||||
break;
|
break;
|
||||||
case Constants.CODE_SETTINGS:
|
case Constants.CODE_SETTINGS:
|
||||||
onSettingsKeyPressed();
|
onSettingsKeyPressed();
|
||||||
|
@ -1484,8 +1488,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
switcher.onCodeInput(primaryCode);
|
switcher.onCodeInput(primaryCode);
|
||||||
// Reset after any single keystroke, except shift and symbol-shift
|
// Reset after any single keystroke, except shift, capslock, and symbol-shift
|
||||||
if (!didAutoCorrect && primaryCode != Constants.CODE_SHIFT
|
if (!didAutoCorrect && primaryCode != Constants.CODE_SHIFT
|
||||||
|
&& primaryCode != Constants.CODE_CAPSLOCK
|
||||||
&& primaryCode != Constants.CODE_SWITCH_ALPHA_SYMBOL)
|
&& primaryCode != Constants.CODE_SWITCH_ALPHA_SYMBOL)
|
||||||
mLastComposedWord.deactivate();
|
mLastComposedWord.deactivate();
|
||||||
if (Constants.CODE_DELETE != primaryCode) {
|
if (Constants.CODE_DELETE != primaryCode) {
|
||||||
|
|
|
@ -18,6 +18,8 @@ package com.android.inputmethod.keyboard.internal;
|
||||||
|
|
||||||
import android.test.AndroidTestCase;
|
import android.test.AndroidTestCase;
|
||||||
|
|
||||||
|
import com.android.inputmethod.latin.Constants;
|
||||||
|
|
||||||
public class KeyboardStateTestsBase extends AndroidTestCase
|
public class KeyboardStateTestsBase extends AndroidTestCase
|
||||||
implements MockKeyboardSwitcher.MockConstants {
|
implements MockKeyboardSwitcher.MockConstants {
|
||||||
protected MockKeyboardSwitcher mSwitcher;
|
protected MockKeyboardSwitcher mSwitcher;
|
||||||
|
@ -119,7 +121,11 @@ public class KeyboardStateTestsBase extends AndroidTestCase
|
||||||
|
|
||||||
public void longPressKey(final int code, final int afterPress, final int afterLongPress) {
|
public void longPressKey(final int code, final int afterPress, final int afterLongPress) {
|
||||||
pressKey(code, afterPress);
|
pressKey(code, afterPress);
|
||||||
mSwitcher.onLongPressTimeout(code);
|
// Long press shift key will register {@link Constants#CODE_CAPS_LOCK}. See
|
||||||
|
// {@link R.xml#key_styles_common} and its baseForShiftKeyStyle. We thus emulate the
|
||||||
|
// behavior here.
|
||||||
|
final int longPressCode = code == CODE_SHIFT ? Constants.CODE_CAPSLOCK : code;
|
||||||
|
mSwitcher.onCodeInput(longPressCode);
|
||||||
assertLayout("afterLongPress", afterLongPress, mSwitcher.getLayoutId());
|
assertLayout("afterLongPress", afterLongPress, mSwitcher.getLayoutId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -139,24 +139,6 @@ public class MockKeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||||
return mIsInDoubleTapShiftKeyTimeout;
|
return mIsInDoubleTapShiftKeyTimeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void startLongPressTimer(final int code) {
|
|
||||||
mLongPressTimeoutCode = code;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cancelLongPressTimer() {
|
|
||||||
mLongPressTimeoutCode = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onLongPressTimeout(final int code) {
|
|
||||||
// TODO: Handle simultaneous long presses.
|
|
||||||
if (mLongPressTimeoutCode == code) {
|
|
||||||
mLongPressTimeoutCode = 0;
|
|
||||||
mState.onLongPressTimeout(code);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateShiftState() {
|
public void updateShiftState() {
|
||||||
mState.onUpdateShiftState(mAutoCapsState, RecapitalizeStatus.NOT_A_RECAPITALIZE_MODE);
|
mState.onUpdateShiftState(mAutoCapsState, RecapitalizeStatus.NOT_A_RECAPITALIZE_MODE);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue