am ac4bd598: Merge "Fix long press caps lock handling"
* commit 'ac4bd598645ff0f12a59e225122ba5fc87e91e8c': Fix long press caps lock handlingmain
commit
f8a97a2552
|
@ -169,6 +169,10 @@ public class Keyboard {
|
||||||
return mShiftState.isShiftLocked();
|
return mShiftState.isShiftLocked();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isShiftLockShifted() {
|
||||||
|
return mShiftState.isShiftLockShifted();
|
||||||
|
}
|
||||||
|
|
||||||
public boolean setShifted(boolean newShiftState) {
|
public boolean setShifted(boolean newShiftState) {
|
||||||
for (final Key key : mShiftKeys) {
|
for (final Key key : mShiftKeys) {
|
||||||
if (!newShiftState && !mShiftState.isShiftLocked()) {
|
if (!newShiftState && !mShiftState.isShiftLocked()) {
|
||||||
|
|
|
@ -386,6 +386,13 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isShiftLockShifted() {
|
||||||
|
LatinKeyboard latinKeyboard = getLatinKeyboard();
|
||||||
|
if (latinKeyboard != null)
|
||||||
|
return latinKeyboard.isShiftLockShifted();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isAutomaticTemporaryUpperCase() {
|
public boolean isAutomaticTemporaryUpperCase() {
|
||||||
LatinKeyboard latinKeyboard = getLatinKeyboard();
|
LatinKeyboard latinKeyboard = getLatinKeyboard();
|
||||||
if (latinKeyboard != null)
|
if (latinKeyboard != null)
|
||||||
|
@ -559,6 +566,9 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
||||||
if (shiftKeyState.isMomentary()) {
|
if (shiftKeyState.isMomentary()) {
|
||||||
// After chording input while normal state.
|
// After chording input while normal state.
|
||||||
toggleShift();
|
toggleShift();
|
||||||
|
} else if (isShiftLocked() && !isShiftLockShifted() && shiftKeyState.isPressing()
|
||||||
|
&& !withSliding) {
|
||||||
|
// Shift has been long pressed, ignore this release.
|
||||||
} else if (isShiftLocked() && !shiftKeyState.isIgnoring() && !withSliding) {
|
} else if (isShiftLocked() && !shiftKeyState.isIgnoring() && !withSliding) {
|
||||||
// Shift has been pressed without chording while caps lock state.
|
// Shift has been pressed without chording while caps lock state.
|
||||||
toggleCapsLock();
|
toggleCapsLock();
|
||||||
|
|
|
@ -400,18 +400,22 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
|
||||||
if (primaryCode == Keyboard.CODE_DIGIT0 && latinKeyboard.isPhoneKeyboard()) {
|
if (primaryCode == Keyboard.CODE_DIGIT0 && latinKeyboard.isPhoneKeyboard()) {
|
||||||
tracker.onLongPressed();
|
tracker.onLongPressed();
|
||||||
// Long pressing on 0 in phone number keypad gives you a '+'.
|
// Long pressing on 0 in phone number keypad gives you a '+'.
|
||||||
return invokeOnKey(Keyboard.CODE_PLUS);
|
invokeCodeInput(Keyboard.CODE_PLUS);
|
||||||
|
invokeReleaseKey(primaryCode);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
if (primaryCode == Keyboard.CODE_SHIFT && latinKeyboard.isAlphaKeyboard()) {
|
if (primaryCode == Keyboard.CODE_SHIFT && latinKeyboard.isAlphaKeyboard()) {
|
||||||
tracker.onLongPressed();
|
tracker.onLongPressed();
|
||||||
return invokeOnKey(Keyboard.CODE_CAPSLOCK);
|
invokeCodeInput(Keyboard.CODE_CAPSLOCK);
|
||||||
|
invokeReleaseKey(primaryCode);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (primaryCode == Keyboard.CODE_SETTINGS || primaryCode == Keyboard.CODE_SPACE) {
|
if (primaryCode == Keyboard.CODE_SETTINGS || primaryCode == Keyboard.CODE_SPACE) {
|
||||||
// Both long pressing settings key and space key invoke IME switcher dialog.
|
// Both long pressing settings key and space key invoke IME switcher dialog.
|
||||||
if (getKeyboardActionListener().onCustomRequest(
|
if (invokeCustomRequest(LatinIME.CODE_SHOW_INPUT_METHOD_PICKER)) {
|
||||||
LatinIME.CODE_SHOW_INPUT_METHOD_PICKER)) {
|
|
||||||
tracker.onLongPressed();
|
tracker.onLongPressed();
|
||||||
|
invokeReleaseKey(primaryCode);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return openMoreKeysPanel(parentKey, tracker);
|
return openMoreKeysPanel(parentKey, tracker);
|
||||||
|
@ -421,11 +425,18 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean invokeOnKey(int primaryCode) {
|
private boolean invokeCustomRequest(int code) {
|
||||||
|
return getKeyboardActionListener().onCustomRequest(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void invokeCodeInput(int primaryCode) {
|
||||||
getKeyboardActionListener().onCodeInput(primaryCode, null,
|
getKeyboardActionListener().onCodeInput(primaryCode, null,
|
||||||
KeyboardActionListener.NOT_A_TOUCH_COORDINATE,
|
KeyboardActionListener.NOT_A_TOUCH_COORDINATE,
|
||||||
KeyboardActionListener.NOT_A_TOUCH_COORDINATE);
|
KeyboardActionListener.NOT_A_TOUCH_COORDINATE);
|
||||||
return true;
|
}
|
||||||
|
|
||||||
|
private void invokeReleaseKey(int primaryCode) {
|
||||||
|
getKeyboardActionListener().onRelease(primaryCode, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean openMoreKeysPanel(Key parentKey, PointerTracker tracker) {
|
private boolean openMoreKeysPanel(Key parentKey, PointerTracker tracker) {
|
||||||
|
|
|
@ -103,6 +103,10 @@ public class KeyboardShiftState {
|
||||||
return mState == SHIFT_LOCKED || mState == SHIFT_LOCK_SHIFTED;
|
return mState == SHIFT_LOCKED || mState == SHIFT_LOCK_SHIFTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isShiftLockShifted() {
|
||||||
|
return mState == SHIFT_LOCK_SHIFTED;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isAutomaticTemporaryUpperCase() {
|
public boolean isAutomaticTemporaryUpperCase() {
|
||||||
return mState == AUTO_SHIFTED;
|
return mState == AUTO_SHIFTED;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue