Follow-up change to revise Caps Lock sequence.
bug: 3122877 Change-Id: I44c539d7c041443f3ad027de4b75a67adf6b2c87main
parent
eec7bb9386
commit
276845c7a9
|
@ -28,7 +28,7 @@
|
|||
<integer name="config_delay_before_key_repeat_start">400</integer>
|
||||
<integer name="config_key_repeat_interval">50</integer>
|
||||
<integer name="config_long_press_key_timeout">400</integer>
|
||||
<integer name="config_long_press_shift_key_timeout">1000</integer>
|
||||
<integer name="config_long_press_shift_key_timeout">1200</integer>
|
||||
<integer name="config_multi_tap_key_timeout">800</integer>
|
||||
<string-array name="auto_complete_threshold_values">
|
||||
<!-- Off, When auto completing setting is Off, this value is not used. -->
|
||||
|
|
|
@ -391,19 +391,18 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
|||
}
|
||||
|
||||
public void setShifted(boolean shifted) {
|
||||
if (mInputView != null) {
|
||||
if (mInputView == null) return;
|
||||
LatinKeyboard latinKeyboard = mInputView.getLatinKeyboard();
|
||||
if (latinKeyboard != null && latinKeyboard.setShifted(shifted)) {
|
||||
if (latinKeyboard == null) return;
|
||||
if (latinKeyboard.setShifted(shifted)) {
|
||||
mInputView.invalidateAllKeys();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setShiftLocked(boolean shiftLocked) {
|
||||
if (mInputView != null) {
|
||||
if (mInputView == null) return;
|
||||
mInputView.setShiftLocked(shiftLocked);
|
||||
}
|
||||
}
|
||||
|
||||
public void toggleShift() {
|
||||
if (isAlphabetMode())
|
||||
|
|
|
@ -151,7 +151,6 @@ public class LatinIME extends InputMethodService
|
|||
private static final int POS_METHOD = 0;
|
||||
private static final int POS_SETTINGS = 1;
|
||||
|
||||
//private LatinKeyboardView mInputView;
|
||||
private LinearLayout mCandidateViewContainer;
|
||||
private CandidateView mCandidateView;
|
||||
private Suggest mSuggest;
|
||||
|
@ -1056,7 +1055,8 @@ public class LatinIME extends InputMethodService
|
|||
if (inputView == null) return;
|
||||
LatinKeyboard latinKeyboard = inputView.getLatinKeyboard();
|
||||
if (latinKeyboard == null) return;
|
||||
if (ic != null && attr != null && mKeyboardSwitcher.isAlphabetMode()) {
|
||||
if (ic != null && attr != null && mKeyboardSwitcher.isAlphabetMode()
|
||||
&& !mShiftKeyState.isIgnoring()) {
|
||||
mKeyboardSwitcher.setShifted(mShiftKeyState.isMomentary()
|
||||
|| latinKeyboard.isShiftLocked() || getCursorCapsMode(ic, attr) != 0);
|
||||
}
|
||||
|
@ -2331,9 +2331,12 @@ public class LatinIME extends InputMethodService
|
|||
LatinKeyboard latinKeyboard = inputView.getLatinKeyboard();
|
||||
if (latinKeyboard == null) return;
|
||||
if (distinctMultiTouch && primaryCode == BaseKeyboard.KEYCODE_SHIFT) {
|
||||
// In alphabet mode, we call handleShift() to go into the shifted mode in this
|
||||
// method, onPress(), only when we are in the small letter mode.
|
||||
if (mKeyboardSwitcher.isAlphabetMode() && latinKeyboard.isShifted()) {
|
||||
mShiftKeyState.onPressOnShifted();
|
||||
} else {
|
||||
mShiftKeyState.onPress();
|
||||
// Not in caps lock mode, shift key is in effect on pressed.
|
||||
if (mKeyboardSwitcher.isAlphabetMode() && !latinKeyboard.isShiftLocked()) {
|
||||
handleShift();
|
||||
}
|
||||
} else if (distinctMultiTouch && primaryCode == BaseKeyboard.KEYCODE_MODE_CHANGE) {
|
||||
|
@ -2345,6 +2348,8 @@ public class LatinIME extends InputMethodService
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: Bug - onRelease() could be dropped if the user slides finger out of the key. It's OK
|
||||
// for general keys, but we need to obtain onRelease() for the shift key even in such case.
|
||||
public void onRelease(int primaryCode) {
|
||||
// Reset any drag flags in the keyboard
|
||||
LatinKeyboardView inputView = mKeyboardSwitcher.getInputView();
|
||||
|
@ -2358,10 +2363,14 @@ public class LatinIME extends InputMethodService
|
|||
if (mShiftKeyState.isMomentary()) {
|
||||
resetShift();
|
||||
}
|
||||
// In caps lock mode, shift key is in effect on released.
|
||||
if (mKeyboardSwitcher.isAlphabetMode() && latinKeyboard.isShiftLocked()) {
|
||||
if (mKeyboardSwitcher.isAlphabetMode()) {
|
||||
// In alphabet mode, we call handleShift() to go into the small letter mode in this
|
||||
// method, onRelease(), only when we are in the shifted modes -- temporary shifted
|
||||
// mode or caps lock mode.
|
||||
if (latinKeyboard.isShifted() && mShiftKeyState.isPressingOnShifted()) {
|
||||
handleShift();
|
||||
}
|
||||
}
|
||||
mShiftKeyState.onRelease();
|
||||
} else if (distinctMultiTouch && primaryCode == BaseKeyboard.KEYCODE_MODE_CHANGE) {
|
||||
if (mSymbolKeyState.isMomentary()) {
|
||||
|
|
|
@ -19,7 +19,9 @@ package com.android.inputmethod.latin;
|
|||
class ModifierKeyState {
|
||||
private static final int RELEASING = 0;
|
||||
private static final int PRESSING = 1;
|
||||
private static final int MOMENTARY = 2;
|
||||
private static final int PRESSING_ON_SHIFTED = 2; // both temporary shifted & shift locked
|
||||
private static final int MOMENTARY = 3;
|
||||
private static final int IGNORING = 4;
|
||||
|
||||
private int mState = RELEASING;
|
||||
|
||||
|
@ -27,16 +29,31 @@ class ModifierKeyState {
|
|||
mState = PRESSING;
|
||||
}
|
||||
|
||||
public void onPressOnShifted() {
|
||||
mState = PRESSING_ON_SHIFTED;
|
||||
}
|
||||
|
||||
public void onRelease() {
|
||||
mState = RELEASING;
|
||||
}
|
||||
|
||||
public void onOtherKeyPressed() {
|
||||
if (mState == PRESSING)
|
||||
if (mState == PRESSING) {
|
||||
mState = MOMENTARY;
|
||||
} else if (mState == PRESSING_ON_SHIFTED) {
|
||||
mState = IGNORING;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isMomentary() {
|
||||
return mState == MOMENTARY;
|
||||
}
|
||||
|
||||
public boolean isPressingOnShifted() {
|
||||
return mState == PRESSING_ON_SHIFTED;
|
||||
}
|
||||
|
||||
public boolean isIgnoring() {
|
||||
return mState == IGNORING;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue