Follow-up change to revise Caps Lock sequence.

bug: 3122877
Change-Id: I44c539d7c041443f3ad027de4b75a67adf6b2c87
main
Ken Wakasa 2010-10-26 19:04:48 +09:00
parent eec7bb9386
commit 276845c7a9
4 changed files with 44 additions and 19 deletions

View File

@ -28,7 +28,7 @@
<integer name="config_delay_before_key_repeat_start">400</integer> <integer name="config_delay_before_key_repeat_start">400</integer>
<integer name="config_key_repeat_interval">50</integer> <integer name="config_key_repeat_interval">50</integer>
<integer name="config_long_press_key_timeout">400</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> <integer name="config_multi_tap_key_timeout">800</integer>
<string-array name="auto_complete_threshold_values"> <string-array name="auto_complete_threshold_values">
<!-- Off, When auto completing setting is Off, this value is not used. --> <!-- Off, When auto completing setting is Off, this value is not used. -->

View File

@ -391,18 +391,17 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
} }
public void setShifted(boolean shifted) { public void setShifted(boolean shifted) {
if (mInputView != null) { if (mInputView == null) return;
LatinKeyboard latinKeyboard = mInputView.getLatinKeyboard(); LatinKeyboard latinKeyboard = mInputView.getLatinKeyboard();
if (latinKeyboard != null && latinKeyboard.setShifted(shifted)) { if (latinKeyboard == null) return;
mInputView.invalidateAllKeys(); if (latinKeyboard.setShifted(shifted)) {
} mInputView.invalidateAllKeys();
} }
} }
public void setShiftLocked(boolean shiftLocked) { public void setShiftLocked(boolean shiftLocked) {
if (mInputView != null) { if (mInputView == null) return;
mInputView.setShiftLocked(shiftLocked); mInputView.setShiftLocked(shiftLocked);
}
} }
public void toggleShift() { public void toggleShift() {

View File

@ -151,7 +151,6 @@ public class LatinIME extends InputMethodService
private static final int POS_METHOD = 0; private static final int POS_METHOD = 0;
private static final int POS_SETTINGS = 1; private static final int POS_SETTINGS = 1;
//private LatinKeyboardView mInputView;
private LinearLayout mCandidateViewContainer; private LinearLayout mCandidateViewContainer;
private CandidateView mCandidateView; private CandidateView mCandidateView;
private Suggest mSuggest; private Suggest mSuggest;
@ -1056,7 +1055,8 @@ public class LatinIME extends InputMethodService
if (inputView == null) return; if (inputView == null) return;
LatinKeyboard latinKeyboard = inputView.getLatinKeyboard(); LatinKeyboard latinKeyboard = inputView.getLatinKeyboard();
if (latinKeyboard == null) return; if (latinKeyboard == null) return;
if (ic != null && attr != null && mKeyboardSwitcher.isAlphabetMode()) { if (ic != null && attr != null && mKeyboardSwitcher.isAlphabetMode()
&& !mShiftKeyState.isIgnoring()) {
mKeyboardSwitcher.setShifted(mShiftKeyState.isMomentary() mKeyboardSwitcher.setShifted(mShiftKeyState.isMomentary()
|| latinKeyboard.isShiftLocked() || getCursorCapsMode(ic, attr) != 0); || latinKeyboard.isShiftLocked() || getCursorCapsMode(ic, attr) != 0);
} }
@ -2331,9 +2331,12 @@ public class LatinIME extends InputMethodService
LatinKeyboard latinKeyboard = inputView.getLatinKeyboard(); LatinKeyboard latinKeyboard = inputView.getLatinKeyboard();
if (latinKeyboard == null) return; if (latinKeyboard == null) return;
if (distinctMultiTouch && primaryCode == BaseKeyboard.KEYCODE_SHIFT) { if (distinctMultiTouch && primaryCode == BaseKeyboard.KEYCODE_SHIFT) {
mShiftKeyState.onPress(); // In alphabet mode, we call handleShift() to go into the shifted mode in this
// Not in caps lock mode, shift key is in effect on pressed. // method, onPress(), only when we are in the small letter mode.
if (mKeyboardSwitcher.isAlphabetMode() && !latinKeyboard.isShiftLocked()) { if (mKeyboardSwitcher.isAlphabetMode() && latinKeyboard.isShifted()) {
mShiftKeyState.onPressOnShifted();
} else {
mShiftKeyState.onPress();
handleShift(); handleShift();
} }
} else if (distinctMultiTouch && primaryCode == BaseKeyboard.KEYCODE_MODE_CHANGE) { } 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) { public void onRelease(int primaryCode) {
// Reset any drag flags in the keyboard // Reset any drag flags in the keyboard
LatinKeyboardView inputView = mKeyboardSwitcher.getInputView(); LatinKeyboardView inputView = mKeyboardSwitcher.getInputView();
@ -2358,9 +2363,13 @@ public class LatinIME extends InputMethodService
if (mShiftKeyState.isMomentary()) { if (mShiftKeyState.isMomentary()) {
resetShift(); resetShift();
} }
// In caps lock mode, shift key is in effect on released. if (mKeyboardSwitcher.isAlphabetMode()) {
if (mKeyboardSwitcher.isAlphabetMode() && latinKeyboard.isShiftLocked()) { // In alphabet mode, we call handleShift() to go into the small letter mode in this
handleShift(); // 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(); mShiftKeyState.onRelease();
} else if (distinctMultiTouch && primaryCode == BaseKeyboard.KEYCODE_MODE_CHANGE) { } else if (distinctMultiTouch && primaryCode == BaseKeyboard.KEYCODE_MODE_CHANGE) {

View File

@ -19,7 +19,9 @@ package com.android.inputmethod.latin;
class ModifierKeyState { class ModifierKeyState {
private static final int RELEASING = 0; private static final int RELEASING = 0;
private static final int PRESSING = 1; 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; private int mState = RELEASING;
@ -27,16 +29,31 @@ class ModifierKeyState {
mState = PRESSING; mState = PRESSING;
} }
public void onPressOnShifted() {
mState = PRESSING_ON_SHIFTED;
}
public void onRelease() { public void onRelease() {
mState = RELEASING; mState = RELEASING;
} }
public void onOtherKeyPressed() { public void onOtherKeyPressed() {
if (mState == PRESSING) if (mState == PRESSING) {
mState = MOMENTARY; mState = MOMENTARY;
} else if (mState == PRESSING_ON_SHIFTED) {
mState = IGNORING;
}
} }
public boolean isMomentary() { public boolean isMomentary() {
return mState == MOMENTARY; return mState == MOMENTARY;
} }
public boolean isPressingOnShifted() {
return mState == PRESSING_ON_SHIFTED;
}
public boolean isIgnoring() {
return mState == IGNORING;
}
} }