am 46831d5a: Renaming KeyboardSwitcher.getPointerCount to isSinglePointer
* commit '46831d5a4b135e5c21f2212d1d8aef09806800ed': Renaming KeyboardSwitcher.getPointerCount to isSinglePointermain
commit
ec6369dd14
|
@ -428,6 +428,14 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setAutomaticTemporaryUpperCase() {
|
||||||
|
LatinKeyboard latinKeyboard = getLatinKeyboard();
|
||||||
|
if (latinKeyboard != null) {
|
||||||
|
latinKeyboard.setAutomaticTemporaryUpperCase();
|
||||||
|
mKeyboardView.invalidateAllKeys();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void setShiftLocked(boolean shiftLocked) {
|
private void setShiftLocked(boolean shiftLocked) {
|
||||||
LatinKeyboard latinKeyboard = getLatinKeyboard();
|
LatinKeyboard latinKeyboard = getLatinKeyboard();
|
||||||
if (latinKeyboard != null && latinKeyboard.setShiftLocked(shiftLocked)) {
|
if (latinKeyboard != null && latinKeyboard.setShiftLocked(shiftLocked)) {
|
||||||
|
@ -471,12 +479,23 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setAutomaticTemporaryUpperCase() {
|
public void changeKeyboardMode() {
|
||||||
if (mKeyboardView == null) return;
|
if (DEBUG_STATE) {
|
||||||
final Keyboard keyboard = mKeyboardView.getKeyboard();
|
Log.d(TAG, "changeKeyboardMode:"
|
||||||
if (keyboard == null) return;
|
+ " keyboard=" + getLatinKeyboard().getKeyboardShiftState()
|
||||||
keyboard.setAutomaticTemporaryUpperCase();
|
+ " state=" + mState);
|
||||||
mKeyboardView.invalidateAllKeys();
|
}
|
||||||
|
toggleKeyboardMode();
|
||||||
|
if (isShiftLocked() && isAlphabetMode()) {
|
||||||
|
setShiftLocked(true);
|
||||||
|
}
|
||||||
|
updateShiftState();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void startIgnoringDoubleTap() {
|
||||||
|
if (mKeyboardView != null) {
|
||||||
|
mKeyboardView.startIgnoringDoubleTap();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -506,18 +525,6 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
||||||
mState.onUpdateShiftState(isAlphabetMode);
|
mState.onUpdateShiftState(isAlphabetMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void changeKeyboardMode() {
|
|
||||||
if (DEBUG_STATE) {
|
|
||||||
Log.d(TAG, "changeKeyboardMode:"
|
|
||||||
+ " keyboard=" + getLatinKeyboard().getKeyboardShiftState()
|
|
||||||
+ " state=" + mState);
|
|
||||||
}
|
|
||||||
toggleKeyboardMode();
|
|
||||||
if (isShiftLocked() && isAlphabetMode())
|
|
||||||
setShiftLocked(true);
|
|
||||||
updateShiftState();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onPressShift(boolean withSliding) {
|
public void onPressShift(boolean withSliding) {
|
||||||
if (!isKeyboardAvailable())
|
if (!isKeyboardAvailable())
|
||||||
return;
|
return;
|
||||||
|
@ -581,7 +588,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
||||||
// To be able to turn off caps lock by "double tap" on shift key, we should ignore
|
// 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
|
// the second tap of the "double tap" from now for a while because we just have
|
||||||
// already turned off caps lock above.
|
// already turned off caps lock above.
|
||||||
mKeyboardView.startIgnoringDoubleTap();
|
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.
|
||||||
|
@ -638,7 +645,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
||||||
|
|
||||||
public void onCancelInput() {
|
public void onCancelInput() {
|
||||||
// Snap back to the previous keyboard mode if the user cancels sliding input.
|
// Snap back to the previous keyboard mode if the user cancels sliding input.
|
||||||
if (getPointerCount() == 1) {
|
if (isSinglePointer()) {
|
||||||
if (mSwitchState == SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL) {
|
if (mSwitchState == SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL) {
|
||||||
changeKeyboardMode();
|
changeKeyboardMode();
|
||||||
} else if (mSwitchState == SWITCH_STATE_MOMENTARY_SYMBOL_AND_MORE) {
|
} else if (mSwitchState == SWITCH_STATE_MOMENTARY_SYMBOL_AND_MORE) {
|
||||||
|
@ -647,6 +654,19 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean mPrevMainKeyboardWasShiftLocked;
|
||||||
|
|
||||||
|
private void toggleKeyboardMode() {
|
||||||
|
if (mCurrentId.equals(mMainKeyboardId)) {
|
||||||
|
mPrevMainKeyboardWasShiftLocked = isShiftLocked();
|
||||||
|
setKeyboard(getKeyboard(mSymbolsKeyboardId));
|
||||||
|
} else {
|
||||||
|
setKeyboard(getKeyboard(mMainKeyboardId));
|
||||||
|
setShiftLocked(mPrevMainKeyboardWasShiftLocked);
|
||||||
|
mPrevMainKeyboardWasShiftLocked = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void toggleShiftInSymbol() {
|
private void toggleShiftInSymbol() {
|
||||||
if (isAlphabetMode())
|
if (isAlphabetMode())
|
||||||
return;
|
return;
|
||||||
|
@ -669,21 +689,8 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
||||||
return mKeyboardView != null && !mKeyboardView.isInSlidingKeyInput();
|
return mKeyboardView != null && !mKeyboardView.isInSlidingKeyInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getPointerCount() {
|
private boolean isSinglePointer() {
|
||||||
return mKeyboardView == null ? 0 : mKeyboardView.getPointerCount();
|
return mKeyboardView != null && mKeyboardView.getPointerCount() == 1;
|
||||||
}
|
|
||||||
|
|
||||||
private boolean mPrevMainKeyboardWasShiftLocked;
|
|
||||||
|
|
||||||
private void toggleKeyboardMode() {
|
|
||||||
if (mCurrentId.equals(mMainKeyboardId)) {
|
|
||||||
mPrevMainKeyboardWasShiftLocked = isShiftLocked();
|
|
||||||
setKeyboard(getKeyboard(mSymbolsKeyboardId));
|
|
||||||
} else {
|
|
||||||
setKeyboard(getKeyboard(mMainKeyboardId));
|
|
||||||
setShiftLocked(mPrevMainKeyboardWasShiftLocked);
|
|
||||||
mPrevMainKeyboardWasShiftLocked = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasDistinctMultitouch() {
|
public boolean hasDistinctMultitouch() {
|
||||||
|
@ -704,9 +711,10 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
||||||
* Updates state machine to figure out when to automatically snap back to the previous mode.
|
* Updates state machine to figure out when to automatically snap back to the previous mode.
|
||||||
*/
|
*/
|
||||||
public void onKey(int code) {
|
public void onKey(int code) {
|
||||||
if (DEBUG_STATE)
|
if (DEBUG_STATE) {
|
||||||
Log.d(TAG, "onKey: code=" + code + " switchState=" + mSwitchState
|
Log.d(TAG, "onKey: code=" + code + " switchState=" + mSwitchState
|
||||||
+ " pointers=" + getPointerCount());
|
+ " isSinglePointer=" + isSinglePointer());
|
||||||
|
}
|
||||||
switch (mSwitchState) {
|
switch (mSwitchState) {
|
||||||
case SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL:
|
case SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL:
|
||||||
// Only distinct multi touch devices can be in this state.
|
// Only distinct multi touch devices can be in this state.
|
||||||
|
@ -722,7 +730,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
||||||
} else {
|
} else {
|
||||||
mSwitchState = SWITCH_STATE_SYMBOL_BEGIN;
|
mSwitchState = SWITCH_STATE_SYMBOL_BEGIN;
|
||||||
}
|
}
|
||||||
} else if (getPointerCount() == 1) {
|
} else if (isSinglePointer()) {
|
||||||
// Snap back to the previous keyboard mode if the user pressed the mode change key
|
// Snap back to the previous keyboard mode if the user pressed the mode change key
|
||||||
// and slid to other key, then released the finger.
|
// and slid to other key, then released the finger.
|
||||||
// If the user cancels the sliding input, snapping back to the previous keyboard
|
// If the user cancels the sliding input, snapping back to the previous keyboard
|
||||||
|
@ -738,7 +746,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
||||||
if (code == Keyboard.CODE_SHIFT) {
|
if (code == Keyboard.CODE_SHIFT) {
|
||||||
// Detected only the shift key has been pressed on symbol layout, and then released.
|
// Detected only the shift key has been pressed on symbol layout, and then released.
|
||||||
mSwitchState = SWITCH_STATE_SYMBOL_BEGIN;
|
mSwitchState = SWITCH_STATE_SYMBOL_BEGIN;
|
||||||
} else if (getPointerCount() == 1) {
|
} else if (isSinglePointer()) {
|
||||||
// Snap back to the previous keyboard mode if the user pressed the shift key on
|
// Snap back to the previous keyboard mode if the user pressed the shift key on
|
||||||
// symbol mode and slid to other key, then released the finger.
|
// symbol mode and slid to other key, then released the finger.
|
||||||
toggleShift();
|
toggleShift();
|
||||||
|
|
|
@ -20,7 +20,7 @@ import android.util.Log;
|
||||||
|
|
||||||
import com.android.inputmethod.keyboard.KeyboardSwitcher;
|
import com.android.inputmethod.keyboard.KeyboardSwitcher;
|
||||||
|
|
||||||
class ModifierKeyState {
|
/* package */ class ModifierKeyState {
|
||||||
protected static final String TAG = "ModifierKeyState";
|
protected static final String TAG = "ModifierKeyState";
|
||||||
protected static final boolean DEBUG = KeyboardSwitcher.DEBUG_STATE;
|
protected static final boolean DEBUG = KeyboardSwitcher.DEBUG_STATE;
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ package com.android.inputmethod.keyboard.internal;
|
||||||
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
class ShiftKeyState extends ModifierKeyState {
|
/* package */ class ShiftKeyState extends ModifierKeyState {
|
||||||
private static final int PRESSING_ON_SHIFTED = 3; // both temporary shifted & shift locked
|
private static final int PRESSING_ON_SHIFTED = 3; // both temporary shifted & shift locked
|
||||||
private static final int IGNORING = 4;
|
private static final int IGNORING = 4;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue