am 68d600a5: Merge "Remove internal toggleShift calls"
* commit '68d600a5f66d5ba6a33c248a3b8825d65add9b9f': Remove internal toggleShift callsmain
commit
6f461a6a50
|
@ -381,6 +381,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setShifted(int shiftMode) {
|
private void setShifted(int shiftMode) {
|
||||||
|
mInputMethodService.mHandler.cancelUpdateShiftState();
|
||||||
LatinKeyboard latinKeyboard = getLatinKeyboard();
|
LatinKeyboard latinKeyboard = getLatinKeyboard();
|
||||||
if (latinKeyboard == null)
|
if (latinKeyboard == null)
|
||||||
return;
|
return;
|
||||||
|
@ -404,19 +405,25 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setShiftLocked(boolean shiftLocked) {
|
private void setShiftLocked(boolean shiftLocked) {
|
||||||
|
mInputMethodService.mHandler.cancelUpdateShiftState();
|
||||||
LatinKeyboard latinKeyboard = getLatinKeyboard();
|
LatinKeyboard latinKeyboard = getLatinKeyboard();
|
||||||
if (latinKeyboard == null)
|
if (latinKeyboard == null)
|
||||||
return;
|
return;
|
||||||
mState.setShiftLocked(shiftLocked);
|
mState.setShiftLocked(shiftLocked);
|
||||||
latinKeyboard.setShiftLocked(shiftLocked);
|
latinKeyboard.setShiftLocked(shiftLocked);
|
||||||
mKeyboardView.invalidateAllKeys();
|
mKeyboardView.invalidateAllKeys();
|
||||||
|
if (!shiftLocked) {
|
||||||
|
// To be able to turn off caps lock by "double tap" on shift key, we should ignore
|
||||||
|
// the second tap of the "double tap" from now for a while because we just have
|
||||||
|
// already turned off caps lock above.
|
||||||
|
mKeyboardView.startIgnoringDoubleTap();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Toggle keyboard shift state triggered by user touch event.
|
* Toggle keyboard shift state triggered by user touch event.
|
||||||
*/
|
*/
|
||||||
public void toggleShift() {
|
public void toggleShift() {
|
||||||
mInputMethodService.mHandler.cancelUpdateShiftState();
|
|
||||||
if (DEBUG_STATE) {
|
if (DEBUG_STATE) {
|
||||||
Log.d(TAG, "toggleShift: " + mState);
|
Log.d(TAG, "toggleShift: " + mState);
|
||||||
}
|
}
|
||||||
|
@ -428,16 +435,16 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
||||||
}
|
}
|
||||||
|
|
||||||
public void toggleCapsLock() {
|
public void toggleCapsLock() {
|
||||||
mInputMethodService.mHandler.cancelUpdateShiftState();
|
|
||||||
if (DEBUG_STATE) {
|
if (DEBUG_STATE) {
|
||||||
Log.d(TAG, "toggleCapsLock: " + mState);
|
Log.d(TAG, "toggleCapsLock: " + mState);
|
||||||
}
|
}
|
||||||
if (isAlphabetMode()) {
|
if (isAlphabetMode()) {
|
||||||
if (mState.isShiftLocked()) {
|
if (mState.isShiftLocked()) {
|
||||||
|
setShiftLocked(false);
|
||||||
|
// TODO: Remove this.
|
||||||
// Shift key is long pressed while caps lock state, we will toggle back to normal
|
// Shift key is long pressed while caps lock state, we will toggle back to normal
|
||||||
// state. And mark as if shift key is released.
|
// state. And mark as if shift key is released.
|
||||||
setShiftLocked(false);
|
mState.onReleaseCapsLock();
|
||||||
mState.onToggleCapsLock();
|
|
||||||
} else {
|
} else {
|
||||||
setShiftLocked(true);
|
setShiftLocked(true);
|
||||||
}
|
}
|
||||||
|
@ -451,12 +458,6 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
||||||
toggleAlphabetAndSymbols();
|
toggleAlphabetAndSymbols();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startIgnoringDoubleTap() {
|
|
||||||
if (mKeyboardView != null) {
|
|
||||||
mKeyboardView.startIgnoringDoubleTap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update keyboard shift state triggered by connected EditText status change.
|
* Update keyboard shift state triggered by connected EditText status change.
|
||||||
*/
|
*/
|
||||||
|
@ -504,7 +505,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
||||||
// shifted state.
|
// shifted state.
|
||||||
} else {
|
} else {
|
||||||
// In base layout, chording or manual temporary upper case mode is started.
|
// In base layout, chording or manual temporary upper case mode is started.
|
||||||
toggleShift();
|
setShifted(MANUAL_SHIFT);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// In symbol mode, just toggle symbol and symbol more keyboard.
|
// In symbol mode, just toggle symbol and symbol more keyboard.
|
||||||
|
@ -530,26 +531,22 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
||||||
if (isAlphabetMode) {
|
if (isAlphabetMode) {
|
||||||
if (mState.isShiftKeyMomentary()) {
|
if (mState.isShiftKeyMomentary()) {
|
||||||
// After chording input while normal state.
|
// After chording input while normal state.
|
||||||
toggleShift();
|
setShifted(UNSHIFT);
|
||||||
} else if (isShiftLocked && !isShiftLockShifted && (mState.isShiftKeyPressing()
|
} else if (isShiftLocked && !isShiftLockShifted && (mState.isShiftKeyPressing()
|
||||||
|| mState.isShiftKeyPressingOnShifted()) && !withSliding) {
|
|| mState.isShiftKeyPressingOnShifted()) && !withSliding) {
|
||||||
// Shift has been long pressed, ignore this release.
|
// Shift has been long pressed, ignore this release.
|
||||||
} else if (isShiftLocked && !mState.isShiftKeyIgnoring() && !withSliding) {
|
} else if (isShiftLocked && !mState.isShiftKeyIgnoring() && !withSliding) {
|
||||||
// Shift has been pressed without chording while caps lock state.
|
// Shift has been pressed without chording while caps lock state.
|
||||||
toggleCapsLock();
|
setShiftLocked(false);
|
||||||
// To be able to turn off caps lock by "double tap" on shift key, we should ignore
|
|
||||||
// the second tap of the "double tap" from now for a while because we just have
|
|
||||||
// already turned off caps lock above.
|
|
||||||
startIgnoringDoubleTap();
|
|
||||||
} else if (isShiftedOrShiftLocked && mState.isShiftKeyPressingOnShifted()
|
} else if (isShiftedOrShiftLocked && mState.isShiftKeyPressingOnShifted()
|
||||||
&& !withSliding) {
|
&& !withSliding) {
|
||||||
// Shift has been pressed without chording while shifted state.
|
// Shift has been pressed without chording while shifted state.
|
||||||
toggleShift();
|
setShifted(UNSHIFT);
|
||||||
} else if (isManualTemporaryUpperCaseFromAuto && mState.isShiftKeyPressing()
|
} else if (isManualTemporaryUpperCaseFromAuto && mState.isShiftKeyPressing()
|
||||||
&& !withSliding) {
|
&& !withSliding) {
|
||||||
// Shift has been pressed without chording while manual temporary upper case
|
// Shift has been pressed without chording while manual temporary upper case
|
||||||
// transited from automatic temporary upper case.
|
// transited from automatic temporary upper case.
|
||||||
toggleShift();
|
setShifted(UNSHIFT);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// In symbol mode, snap back to the previous keyboard mode if the user chords the shift
|
// In symbol mode, snap back to the previous keyboard mode if the user chords the shift
|
||||||
|
|
|
@ -98,7 +98,7 @@ public class KeyboardState {
|
||||||
return mShiftKeyState.isPressingOnShifted();
|
return mShiftKeyState.isPressingOnShifted();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onToggleCapsLock() {
|
public void onReleaseCapsLock() {
|
||||||
mShiftKeyState.onRelease();
|
mShiftKeyState.onRelease();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue