Merge "Minor refactoring of Keyboard"
This commit is contained in:
commit
ec52fb6dbb
4 changed files with 18 additions and 29 deletions
|
@ -112,7 +112,8 @@ public class Keyboard {
|
|||
public final KeyboardIconsSet mIconsSet;
|
||||
|
||||
private final Map<Integer, Key> mKeyCache = new HashMap<Integer, Key>();
|
||||
private final KeyboardShiftState mShiftState = new KeyboardShiftState();
|
||||
// TODO: Move this state to KeyboardSwitcher
|
||||
/* package for debug */ final KeyboardShiftState mShiftState = new KeyboardShiftState();
|
||||
|
||||
private final ProximityInfo mProximityInfo;
|
||||
|
||||
|
@ -211,27 +212,15 @@ public class Keyboard {
|
|||
}
|
||||
|
||||
public boolean isAutomaticTemporaryUpperCase() {
|
||||
return isAlphaKeyboard() && mShiftState.isAutomaticTemporaryUpperCase();
|
||||
return mId.isAlphabetKeyboard() && mShiftState.isAutomaticTemporaryUpperCase();
|
||||
}
|
||||
|
||||
public boolean isManualTemporaryUpperCase() {
|
||||
return isAlphaKeyboard() && mShiftState.isManualTemporaryUpperCase();
|
||||
return mId.isAlphabetKeyboard() && mShiftState.isManualTemporaryUpperCase();
|
||||
}
|
||||
|
||||
public boolean isManualTemporaryUpperCaseFromAuto() {
|
||||
return isAlphaKeyboard() && mShiftState.isManualTemporaryUpperCaseFromAuto();
|
||||
}
|
||||
|
||||
public KeyboardShiftState getKeyboardShiftState() {
|
||||
return mShiftState;
|
||||
}
|
||||
|
||||
public boolean isAlphaKeyboard() {
|
||||
return mId.isAlphabetKeyboard();
|
||||
}
|
||||
|
||||
public boolean isPhoneKeyboard() {
|
||||
return mId.isPhoneKeyboard();
|
||||
return mId.isAlphabetKeyboard() && mShiftState.isManualTemporaryUpperCaseFromAuto();
|
||||
}
|
||||
|
||||
public CharSequence adjustLabelCase(CharSequence label) {
|
||||
|
|
|
@ -451,7 +451,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
|||
mInputMethodService.mHandler.cancelUpdateShiftState();
|
||||
if (DEBUG_STATE) {
|
||||
Log.d(TAG, "toggleShift:"
|
||||
+ " keyboard=" + getLatinKeyboard().getKeyboardShiftState()
|
||||
+ " keyboard=" + getLatinKeyboard().mShiftState
|
||||
+ " state=" + mState);
|
||||
}
|
||||
if (isAlphabetMode()) {
|
||||
|
@ -465,7 +465,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
|||
mInputMethodService.mHandler.cancelUpdateShiftState();
|
||||
if (DEBUG_STATE) {
|
||||
Log.d(TAG, "toggleCapsLock:"
|
||||
+ " keyboard=" + getLatinKeyboard().getKeyboardShiftState()
|
||||
+ " keyboard=" + getLatinKeyboard().mShiftState
|
||||
+ " state=" + mState);
|
||||
}
|
||||
if (isAlphabetMode()) {
|
||||
|
@ -483,7 +483,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
|||
public void changeKeyboardMode() {
|
||||
if (DEBUG_STATE) {
|
||||
Log.d(TAG, "changeKeyboardMode:"
|
||||
+ " keyboard=" + getLatinKeyboard().getKeyboardShiftState()
|
||||
+ " keyboard=" + getLatinKeyboard().mShiftState
|
||||
+ " state=" + mState);
|
||||
}
|
||||
toggleKeyboardMode();
|
||||
|
@ -508,7 +508,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
|||
if (DEBUG_STATE) {
|
||||
Log.d(TAG, "updateShiftState:"
|
||||
+ " autoCaps=" + mInputMethodService.getCurrentAutoCapsState()
|
||||
+ " keyboard=" + getLatinKeyboard().getKeyboardShiftState()
|
||||
+ " keyboard=" + getLatinKeyboard().mShiftState
|
||||
+ " isAlphabetMode=" + isAlphabetMode
|
||||
+ " isShiftLocked=" + isShiftLocked
|
||||
+ " state=" + mState);
|
||||
|
@ -531,7 +531,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
|||
return;
|
||||
if (DEBUG_STATE) {
|
||||
Log.d(TAG, "onPressShift:"
|
||||
+ " keyboard=" + getLatinKeyboard().getKeyboardShiftState()
|
||||
+ " keyboard=" + getLatinKeyboard().mShiftState
|
||||
+ " state=" + mState + " sliding=" + withSliding);
|
||||
}
|
||||
final boolean isAlphabetMode = isAlphabetMode();
|
||||
|
@ -568,7 +568,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
|||
return;
|
||||
if (DEBUG_STATE) {
|
||||
Log.d(TAG, "onReleaseShift:"
|
||||
+ " keyboard=" + getLatinKeyboard().getKeyboardShiftState()
|
||||
+ " keyboard=" + getLatinKeyboard().mShiftState
|
||||
+ " state=" + mState + " sliding=" + withSliding);
|
||||
}
|
||||
final boolean isAlphabetMode = isAlphabetMode();
|
||||
|
@ -613,7 +613,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
|||
public void onPressSymbol() {
|
||||
if (DEBUG_STATE) {
|
||||
Log.d(TAG, "onPressSymbol:"
|
||||
+ " keyboard=" + getLatinKeyboard().getKeyboardShiftState()
|
||||
+ " keyboard=" + getLatinKeyboard().mShiftState
|
||||
+ " state=" + mState);
|
||||
}
|
||||
changeKeyboardMode();
|
||||
|
@ -624,7 +624,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
|||
public void onReleaseSymbol() {
|
||||
if (DEBUG_STATE) {
|
||||
Log.d(TAG, "onReleaseSymbol:"
|
||||
+ " keyboard=" + getLatinKeyboard().getKeyboardShiftState()
|
||||
+ " keyboard=" + getLatinKeyboard().mShiftState
|
||||
+ " state=" + mState);
|
||||
}
|
||||
// Snap back to the previous keyboard mode if the user chords the mode change key and
|
||||
|
@ -638,7 +638,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
|||
public void onOtherKeyPressed() {
|
||||
if (DEBUG_STATE) {
|
||||
Log.d(TAG, "onOtherKeyPressed:"
|
||||
+ " keyboard=" + getLatinKeyboard().getKeyboardShiftState()
|
||||
+ " keyboard=" + getLatinKeyboard().mShiftState
|
||||
+ " state=" + mState);
|
||||
}
|
||||
mState.onOtherKeyPressed();
|
||||
|
|
|
@ -176,7 +176,7 @@ public class LatinKeyboard extends Keyboard {
|
|||
|
||||
@Override
|
||||
public CharSequence adjustLabelCase(CharSequence label) {
|
||||
if (isAlphaKeyboard() && isShiftedOrShiftLocked() && !TextUtils.isEmpty(label)
|
||||
if (mId.isAlphabetKeyboard() && isShiftedOrShiftLocked() && !TextUtils.isEmpty(label)
|
||||
&& label.length() < 3 && Character.isLowerCase(label.charAt(0))) {
|
||||
return label.toString().toUpperCase(mId.mLocale);
|
||||
}
|
||||
|
|
|
@ -177,7 +177,7 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
|
|||
public boolean onDoubleTap(MotionEvent firstDown) {
|
||||
final Keyboard keyboard = getKeyboard();
|
||||
if (ENABLE_CAPSLOCK_BY_DOUBLETAP && keyboard instanceof LatinKeyboard
|
||||
&& ((LatinKeyboard) keyboard).isAlphaKeyboard()) {
|
||||
&& ((LatinKeyboard) keyboard).mId.isAlphabetKeyboard()) {
|
||||
final int pointerIndex = firstDown.getActionIndex();
|
||||
final int id = firstDown.getPointerId(pointerIndex);
|
||||
final PointerTracker tracker = getPointerTracker(id);
|
||||
|
@ -396,14 +396,14 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
|
|||
final Keyboard keyboard = getKeyboard();
|
||||
if (keyboard instanceof LatinKeyboard) {
|
||||
final LatinKeyboard latinKeyboard = (LatinKeyboard) keyboard;
|
||||
if (primaryCode == Keyboard.CODE_DIGIT0 && latinKeyboard.isPhoneKeyboard()) {
|
||||
if (primaryCode == Keyboard.CODE_DIGIT0 && latinKeyboard.mId.isPhoneKeyboard()) {
|
||||
tracker.onLongPressed();
|
||||
// Long pressing on 0 in phone number keypad gives you a '+'.
|
||||
invokeCodeInput(Keyboard.CODE_PLUS);
|
||||
invokeReleaseKey(primaryCode);
|
||||
return true;
|
||||
}
|
||||
if (primaryCode == Keyboard.CODE_SHIFT && latinKeyboard.isAlphaKeyboard()) {
|
||||
if (primaryCode == Keyboard.CODE_SHIFT && latinKeyboard.mId.isAlphabetKeyboard()) {
|
||||
tracker.onLongPressed();
|
||||
invokeCodeInput(Keyboard.CODE_CAPSLOCK);
|
||||
invokeReleaseKey(primaryCode);
|
||||
|
|
Loading…
Reference in a new issue