am 82ffc9fe: am 16950d65: Reset automatic upper case when chroding key is pressed
* commit '82ffc9fe5f7255c902e371bb5353bdef97205fd6': Reset automatic upper case when chroding key is pressedmain
commit
d4577f738b
|
@ -71,7 +71,7 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||||
|
|
||||||
private InputView mCurrentInputView;
|
private InputView mCurrentInputView;
|
||||||
private LatinKeyboardView mKeyboardView;
|
private LatinKeyboardView mKeyboardView;
|
||||||
private LatinIME mInputMethodService;
|
private LatinIME mLatinIME;
|
||||||
private Resources mResources;
|
private Resources mResources;
|
||||||
|
|
||||||
private KeyboardState mState;
|
private KeyboardState mState;
|
||||||
|
@ -95,17 +95,17 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||||
// Intentional empty constructor for singleton.
|
// Intentional empty constructor for singleton.
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void init(LatinIME ims, SharedPreferences prefs) {
|
public static void init(LatinIME latinIme, SharedPreferences prefs) {
|
||||||
sInstance.initInternal(ims, prefs);
|
sInstance.initInternal(latinIme, prefs);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initInternal(LatinIME ims, SharedPreferences prefs) {
|
private void initInternal(LatinIME latinIme, SharedPreferences prefs) {
|
||||||
mInputMethodService = ims;
|
mLatinIME = latinIme;
|
||||||
mResources = ims.getResources();
|
mResources = latinIme.getResources();
|
||||||
mPrefs = prefs;
|
mPrefs = prefs;
|
||||||
mSubtypeSwitcher = SubtypeSwitcher.getInstance();
|
mSubtypeSwitcher = SubtypeSwitcher.getInstance();
|
||||||
mState = new KeyboardState(this);
|
mState = new KeyboardState(this);
|
||||||
setContextThemeWrapper(ims, getKeyboardTheme(ims, prefs));
|
setContextThemeWrapper(latinIme, getKeyboardTheme(latinIme, prefs));
|
||||||
mForceNonDistinctMultitouch = prefs.getBoolean(
|
mForceNonDistinctMultitouch = prefs.getBoolean(
|
||||||
DebugSettings.FORCE_NON_DISTINCT_MULTITOUCH_KEY, false);
|
DebugSettings.FORCE_NON_DISTINCT_MULTITOUCH_KEY, false);
|
||||||
}
|
}
|
||||||
|
@ -194,14 +194,14 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||||
* Update keyboard shift state triggered by connected EditText status change.
|
* Update keyboard shift state triggered by connected EditText status change.
|
||||||
*/
|
*/
|
||||||
public void updateShiftState() {
|
public void updateShiftState() {
|
||||||
mState.onUpdateShiftState(mInputMethodService.getCurrentAutoCapsState());
|
mState.onUpdateShiftState(mLatinIME.getCurrentAutoCapsState());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPressKey(int code) {
|
public void onPressKey(int code) {
|
||||||
if (isVibrateAndSoundFeedbackRequired()) {
|
if (isVibrateAndSoundFeedbackRequired()) {
|
||||||
mInputMethodService.hapticAndAudioFeedback(code);
|
mLatinIME.hapticAndAudioFeedback(code);
|
||||||
}
|
}
|
||||||
mState.onPressKey(code);
|
mState.onPressKey(code, isSinglePointer(), mLatinIME.getCurrentAutoCapsState());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onReleaseKey(int code, boolean withSliding) {
|
public void onReleaseKey(int code, boolean withSliding) {
|
||||||
|
@ -257,7 +257,7 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||||
// Implements {@link KeyboardState.SwitchActions}.
|
// Implements {@link KeyboardState.SwitchActions}.
|
||||||
@Override
|
@Override
|
||||||
public void requestUpdatingShiftState() {
|
public void requestUpdatingShiftState() {
|
||||||
mState.onUpdateShiftState(mInputMethodService.getCurrentAutoCapsState());
|
mState.onUpdateShiftState(mLatinIME.getCurrentAutoCapsState());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements {@link KeyboardState.SwitchActions}.
|
// Implements {@link KeyboardState.SwitchActions}.
|
||||||
|
@ -311,7 +311,7 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||||
// Implements {@link KeyboardState.SwitchActions}.
|
// Implements {@link KeyboardState.SwitchActions}.
|
||||||
@Override
|
@Override
|
||||||
public void hapticAndAudioFeedback(int code) {
|
public void hapticAndAudioFeedback(int code) {
|
||||||
mInputMethodService.hapticAndAudioFeedback(code);
|
mLatinIME.hapticAndAudioFeedback(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onLongPressTimeout(int code) {
|
public void onLongPressTimeout(int code) {
|
||||||
|
@ -338,7 +338,7 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||||
* 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.
|
||||||
*/
|
*/
|
||||||
public void onCodeInput(int code) {
|
public void onCodeInput(int code) {
|
||||||
mState.onCodeInput(code, isSinglePointer(), mInputMethodService.getCurrentAutoCapsState());
|
mState.onCodeInput(code, isSinglePointer(), mLatinIME.getCurrentAutoCapsState());
|
||||||
}
|
}
|
||||||
|
|
||||||
public LatinKeyboardView getKeyboardView() {
|
public LatinKeyboardView getKeyboardView() {
|
||||||
|
@ -354,7 +354,7 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||||
boolean tryGC = true;
|
boolean tryGC = true;
|
||||||
for (int i = 0; i < Utils.GCUtils.GC_TRY_LOOP_MAX && tryGC; ++i) {
|
for (int i = 0; i < Utils.GCUtils.GC_TRY_LOOP_MAX && tryGC; ++i) {
|
||||||
try {
|
try {
|
||||||
setContextThemeWrapper(mInputMethodService, mKeyboardTheme);
|
setContextThemeWrapper(mLatinIME, mKeyboardTheme);
|
||||||
mCurrentInputView = (InputView)LayoutInflater.from(mThemeContext).inflate(
|
mCurrentInputView = (InputView)LayoutInflater.from(mThemeContext).inflate(
|
||||||
R.layout.input_view, null);
|
R.layout.input_view, null);
|
||||||
tryGC = false;
|
tryGC = false;
|
||||||
|
@ -368,7 +368,7 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||||
}
|
}
|
||||||
|
|
||||||
mKeyboardView = (LatinKeyboardView) mCurrentInputView.findViewById(R.id.keyboard_view);
|
mKeyboardView = (LatinKeyboardView) mCurrentInputView.findViewById(R.id.keyboard_view);
|
||||||
mKeyboardView.setKeyboardActionListener(mInputMethodService);
|
mKeyboardView.setKeyboardActionListener(mLatinIME);
|
||||||
if (mForceNonDistinctMultitouch) {
|
if (mForceNonDistinctMultitouch) {
|
||||||
mKeyboardView.setDistinctMultitouch(false);
|
mKeyboardView.setDistinctMultitouch(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -389,11 +389,6 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
|
||||||
* @param keyboard the keyboard to display in this view
|
* @param keyboard the keyboard to display in this view
|
||||||
*/
|
*/
|
||||||
public void setKeyboard(Keyboard keyboard) {
|
public void setKeyboard(Keyboard keyboard) {
|
||||||
// Remove any pending messages.
|
|
||||||
mDrawingHandler.cancelAllMessages();
|
|
||||||
if (mKeyboard != null) {
|
|
||||||
PointerTracker.dismissAllKeyPreviews();
|
|
||||||
}
|
|
||||||
mKeyboard = keyboard;
|
mKeyboard = keyboard;
|
||||||
LatinImeLogger.onSetKeyboard(keyboard);
|
LatinImeLogger.onSetKeyboard(keyboard);
|
||||||
requestLayout();
|
requestLayout();
|
||||||
|
|
|
@ -30,7 +30,7 @@ import com.android.inputmethod.latin.define.ProductionFlag;
|
||||||
* This class contains all keyboard state transition logic.
|
* This class contains all keyboard state transition logic.
|
||||||
*
|
*
|
||||||
* The input events are {@link #onLoadKeyboard(String)}, {@link #onSaveKeyboardState()},
|
* The input events are {@link #onLoadKeyboard(String)}, {@link #onSaveKeyboardState()},
|
||||||
* {@link #onPressKey(int)}, {@link #onReleaseKey(int, boolean)},
|
* {@link #onPressKey(int, boolean, int)}, {@link #onReleaseKey(int, boolean)},
|
||||||
* {@link #onCodeInput(int, boolean, int)}, {@link #onCancelInput(boolean)},
|
* {@link #onCodeInput(int, boolean, int)}, {@link #onCancelInput(boolean)},
|
||||||
* {@link #onUpdateShiftState(int)}, {@link #onLongPressTimeout(int)}.
|
* {@link #onUpdateShiftState(int)}, {@link #onLongPressTimeout(int)}.
|
||||||
*
|
*
|
||||||
|
@ -297,9 +297,10 @@ public class KeyboardState {
|
||||||
mSwitchState = SWITCH_STATE_SYMBOL_BEGIN;
|
mSwitchState = SWITCH_STATE_SYMBOL_BEGIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPressKey(int code) {
|
public void onPressKey(int code, boolean isSinglePointer, int autoCaps) {
|
||||||
if (DEBUG_EVENT) {
|
if (DEBUG_EVENT) {
|
||||||
Log.d(TAG, "onPressKey: code=" + Keyboard.printableCode(code) + " " + this);
|
Log.d(TAG, "onPressKey: code=" + Keyboard.printableCode(code)
|
||||||
|
+ " single=" + isSinglePointer + " autoCaps=" + autoCaps + " " + this);
|
||||||
}
|
}
|
||||||
if (ProductionFlag.IS_EXPERIMENTAL) {
|
if (ProductionFlag.IS_EXPERIMENTAL) {
|
||||||
ResearchLogger.keyboardState_onPressKey(code, this);
|
ResearchLogger.keyboardState_onPressKey(code, this);
|
||||||
|
@ -313,6 +314,21 @@ public class KeyboardState {
|
||||||
mSwitchActions.cancelLongPressTimer();
|
mSwitchActions.cancelLongPressTimer();
|
||||||
mShiftKeyState.onOtherKeyPressed();
|
mShiftKeyState.onOtherKeyPressed();
|
||||||
mSymbolKeyState.onOtherKeyPressed();
|
mSymbolKeyState.onOtherKeyPressed();
|
||||||
|
// It is required to reset the auto caps state when all of the following conditions
|
||||||
|
// are met:
|
||||||
|
// 1) two or more fingers are in action
|
||||||
|
// 2) in alphabet layout
|
||||||
|
// 3) not in all characters caps mode
|
||||||
|
// As for #3, please note that it's required to check even when the auto caps mode is
|
||||||
|
// off because, for example, we may be in the #1 state within the manual temporary
|
||||||
|
// shifted mode.
|
||||||
|
if (!isSinglePointer && mIsAlphabetMode && autoCaps != TextUtils.CAP_MODE_CHARACTERS) {
|
||||||
|
final boolean needsToResetAutoCaps = mAlphabetShiftState.isAutomaticShifted()
|
||||||
|
|| (mAlphabetShiftState.isManualShifted() && mShiftKeyState.isReleasing());
|
||||||
|
if (needsToResetAutoCaps) {
|
||||||
|
mSwitchActions.setAlphabetKeyboard();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1065,6 +1065,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
| InputType.TYPE_TEXT_FLAG_CAP_WORDS)) == 0;
|
| InputType.TYPE_TEXT_FLAG_CAP_WORDS)) == 0;
|
||||||
if (noNeedToCheckCapsMode) return Constants.TextUtils.CAP_MODE_OFF;
|
if (noNeedToCheckCapsMode) return Constants.TextUtils.CAP_MODE_OFF;
|
||||||
|
|
||||||
|
// Avoid making heavy round-trip IPC calls of {@link InputConnection#getCursorCapsMode}
|
||||||
|
// unless needed.
|
||||||
|
if (mWordComposer.isComposingWord()) return Constants.TextUtils.CAP_MODE_OFF;
|
||||||
|
|
||||||
final InputConnection ic = getCurrentInputConnection();
|
final InputConnection ic = getCurrentInputConnection();
|
||||||
if (ic == null) return Constants.TextUtils.CAP_MODE_OFF;
|
if (ic == null) return Constants.TextUtils.CAP_MODE_OFF;
|
||||||
// TODO: This blocking IPC call is heavy. Consider doing this without using IPC calls.
|
// TODO: This blocking IPC call is heavy. Consider doing this without using IPC calls.
|
||||||
|
|
|
@ -268,13 +268,12 @@ public class KeyboardStateMultiTouchTests extends KeyboardStateTestsBase {
|
||||||
|
|
||||||
// Press 'X' key and hold
|
// Press 'X' key and hold
|
||||||
pressKey('X', ALPHABET_MANUAL_SHIFTED);
|
pressKey('X', ALPHABET_MANUAL_SHIFTED);
|
||||||
// TODO: The following test fails due to a bug. Temporarily commented out.
|
// Press 'z' key and hold, switch back to alphabet unshifted.
|
||||||
// // Press 'z' key and hold, switch back to alphabet unshifted.
|
chordingPressKey('z', ALPHABET_UNSHIFTED);
|
||||||
// chordingPressKey('z', ALPHABET_UNSHIFTED);
|
// Release 'X' key
|
||||||
// // Release 'X' key
|
releaseKey('X', ALPHABET_UNSHIFTED);
|
||||||
// releaseKey('X', ALPHABET_UNSHIFTED);
|
// Release 'z' key
|
||||||
// // Release 'z' key
|
releaseKey('z', ALPHABET_UNSHIFTED);
|
||||||
// releaseKey('z', ALPHABET_UNSHIFTED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Multi touch input in automatic upper case.
|
// Multi touch input in automatic upper case.
|
||||||
|
@ -286,13 +285,12 @@ public class KeyboardStateMultiTouchTests extends KeyboardStateTestsBase {
|
||||||
|
|
||||||
// Press 'X' key and hold
|
// Press 'X' key and hold
|
||||||
pressKey('X', ALPHABET_AUTOMATIC_SHIFTED);
|
pressKey('X', ALPHABET_AUTOMATIC_SHIFTED);
|
||||||
// TODO: The following test fails due to a bug. Temporarily commented out.
|
// Press 'z' key and hold, switch back to alphabet unshifted.
|
||||||
// // Press 'z' key and hold, switch back to alphabet unshifted.
|
chordingPressKey('z', ALPHABET_UNSHIFTED);
|
||||||
// chordingPressKey('z', ALPHABET_UNSHIFTED);
|
// Release 'X' key
|
||||||
// // Release 'X' key
|
releaseKey('X', ALPHABET_UNSHIFTED);
|
||||||
// releaseKey('X', ALPHABET_UNSHIFTED);
|
// Release 'z' key
|
||||||
// // Release 'z' key
|
releaseKey('z', ALPHABET_UNSHIFTED);
|
||||||
// releaseKey('z', ALPHABET_UNSHIFTED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Multi touch input in capitalize character mode.
|
// Multi touch input in capitalize character mode.
|
||||||
|
|
|
@ -64,14 +64,14 @@ public class KeyboardStateTestsBase extends AndroidTestCase
|
||||||
assertLayout(afterRotate, mSwitcher.getLayoutId());
|
assertLayout(afterRotate, mSwitcher.getLayoutId());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void pressKeyWithoutTimerExpire(int code, int afterPress) {
|
private void pressKeyWithoutTimerExpire(int code, boolean isSinglePointer, int afterPress) {
|
||||||
mSwitcher.onPressKey(code);
|
mSwitcher.onPressKey(code, isSinglePointer);
|
||||||
assertLayout(afterPress, mSwitcher.getLayoutId());
|
assertLayout(afterPress, mSwitcher.getLayoutId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void pressKey(int code, int afterPress) {
|
public void pressKey(int code, int afterPress) {
|
||||||
mSwitcher.expireDoubleTapTimeout();
|
mSwitcher.expireDoubleTapTimeout();
|
||||||
pressKeyWithoutTimerExpire(code, afterPress);
|
pressKeyWithoutTimerExpire(code, true, afterPress);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void releaseKey(int code, int afterRelease) {
|
public void releaseKey(int code, int afterRelease) {
|
||||||
|
@ -86,7 +86,8 @@ public class KeyboardStateTestsBase extends AndroidTestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
public void chordingPressKey(int code, int afterPress) {
|
public void chordingPressKey(int code, int afterPress) {
|
||||||
pressKey(code, afterPress);
|
mSwitcher.expireDoubleTapTimeout();
|
||||||
|
pressKeyWithoutTimerExpire(code, false, afterPress);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void chordingReleaseKey(int code, int afterRelease) {
|
public void chordingReleaseKey(int code, int afterRelease) {
|
||||||
|
@ -114,7 +115,7 @@ public class KeyboardStateTestsBase extends AndroidTestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
public void secondPressAndReleaseKey(int code, int afterPress, int afterRelease) {
|
public void secondPressAndReleaseKey(int code, int afterPress, int afterRelease) {
|
||||||
pressKeyWithoutTimerExpire(code, afterPress);
|
pressKeyWithoutTimerExpire(code, true, afterPress);
|
||||||
releaseKey(code, afterRelease);
|
releaseKey(code, afterRelease);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -174,8 +174,8 @@ public class MockKeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||||
mState.onSaveKeyboardState();
|
mState.onSaveKeyboardState();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPressKey(int code) {
|
public void onPressKey(int code, boolean isSinglePointer) {
|
||||||
mState.onPressKey(code);
|
mState.onPressKey(code, isSinglePointer, mAutoCapsState);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onReleaseKey(int code, boolean withSliding) {
|
public void onReleaseKey(int code, boolean withSliding) {
|
||||||
|
|
Loading…
Reference in New Issue