am ec52fb6d: Merge "Minor refactoring of Keyboard"
* commit 'ec52fb6dbb0794d9872bb3e83ea166c6996acf4e': Minor refactoring of Keyboardmain
commit
3f77a69850
|
@ -112,7 +112,8 @@ public class Keyboard {
|
||||||
public final KeyboardIconsSet mIconsSet;
|
public final KeyboardIconsSet mIconsSet;
|
||||||
|
|
||||||
private final Map<Integer, Key> mKeyCache = new HashMap<Integer, Key>();
|
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;
|
private final ProximityInfo mProximityInfo;
|
||||||
|
|
||||||
|
@ -211,27 +212,15 @@ public class Keyboard {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAutomaticTemporaryUpperCase() {
|
public boolean isAutomaticTemporaryUpperCase() {
|
||||||
return isAlphaKeyboard() && mShiftState.isAutomaticTemporaryUpperCase();
|
return mId.isAlphabetKeyboard() && mShiftState.isAutomaticTemporaryUpperCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isManualTemporaryUpperCase() {
|
public boolean isManualTemporaryUpperCase() {
|
||||||
return isAlphaKeyboard() && mShiftState.isManualTemporaryUpperCase();
|
return mId.isAlphabetKeyboard() && mShiftState.isManualTemporaryUpperCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isManualTemporaryUpperCaseFromAuto() {
|
public boolean isManualTemporaryUpperCaseFromAuto() {
|
||||||
return isAlphaKeyboard() && mShiftState.isManualTemporaryUpperCaseFromAuto();
|
return mId.isAlphabetKeyboard() && mShiftState.isManualTemporaryUpperCaseFromAuto();
|
||||||
}
|
|
||||||
|
|
||||||
public KeyboardShiftState getKeyboardShiftState() {
|
|
||||||
return mShiftState;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isAlphaKeyboard() {
|
|
||||||
return mId.isAlphabetKeyboard();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isPhoneKeyboard() {
|
|
||||||
return mId.isPhoneKeyboard();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public CharSequence adjustLabelCase(CharSequence label) {
|
public CharSequence adjustLabelCase(CharSequence label) {
|
||||||
|
|
|
@ -451,7 +451,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
||||||
mInputMethodService.mHandler.cancelUpdateShiftState();
|
mInputMethodService.mHandler.cancelUpdateShiftState();
|
||||||
if (DEBUG_STATE) {
|
if (DEBUG_STATE) {
|
||||||
Log.d(TAG, "toggleShift:"
|
Log.d(TAG, "toggleShift:"
|
||||||
+ " keyboard=" + getLatinKeyboard().getKeyboardShiftState()
|
+ " keyboard=" + getLatinKeyboard().mShiftState
|
||||||
+ " state=" + mState);
|
+ " state=" + mState);
|
||||||
}
|
}
|
||||||
if (isAlphabetMode()) {
|
if (isAlphabetMode()) {
|
||||||
|
@ -465,7 +465,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
||||||
mInputMethodService.mHandler.cancelUpdateShiftState();
|
mInputMethodService.mHandler.cancelUpdateShiftState();
|
||||||
if (DEBUG_STATE) {
|
if (DEBUG_STATE) {
|
||||||
Log.d(TAG, "toggleCapsLock:"
|
Log.d(TAG, "toggleCapsLock:"
|
||||||
+ " keyboard=" + getLatinKeyboard().getKeyboardShiftState()
|
+ " keyboard=" + getLatinKeyboard().mShiftState
|
||||||
+ " state=" + mState);
|
+ " state=" + mState);
|
||||||
}
|
}
|
||||||
if (isAlphabetMode()) {
|
if (isAlphabetMode()) {
|
||||||
|
@ -483,7 +483,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
||||||
public void changeKeyboardMode() {
|
public void changeKeyboardMode() {
|
||||||
if (DEBUG_STATE) {
|
if (DEBUG_STATE) {
|
||||||
Log.d(TAG, "changeKeyboardMode:"
|
Log.d(TAG, "changeKeyboardMode:"
|
||||||
+ " keyboard=" + getLatinKeyboard().getKeyboardShiftState()
|
+ " keyboard=" + getLatinKeyboard().mShiftState
|
||||||
+ " state=" + mState);
|
+ " state=" + mState);
|
||||||
}
|
}
|
||||||
toggleKeyboardMode();
|
toggleKeyboardMode();
|
||||||
|
@ -508,7 +508,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
||||||
if (DEBUG_STATE) {
|
if (DEBUG_STATE) {
|
||||||
Log.d(TAG, "updateShiftState:"
|
Log.d(TAG, "updateShiftState:"
|
||||||
+ " autoCaps=" + mInputMethodService.getCurrentAutoCapsState()
|
+ " autoCaps=" + mInputMethodService.getCurrentAutoCapsState()
|
||||||
+ " keyboard=" + getLatinKeyboard().getKeyboardShiftState()
|
+ " keyboard=" + getLatinKeyboard().mShiftState
|
||||||
+ " isAlphabetMode=" + isAlphabetMode
|
+ " isAlphabetMode=" + isAlphabetMode
|
||||||
+ " isShiftLocked=" + isShiftLocked
|
+ " isShiftLocked=" + isShiftLocked
|
||||||
+ " state=" + mState);
|
+ " state=" + mState);
|
||||||
|
@ -531,7 +531,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
||||||
return;
|
return;
|
||||||
if (DEBUG_STATE) {
|
if (DEBUG_STATE) {
|
||||||
Log.d(TAG, "onPressShift:"
|
Log.d(TAG, "onPressShift:"
|
||||||
+ " keyboard=" + getLatinKeyboard().getKeyboardShiftState()
|
+ " keyboard=" + getLatinKeyboard().mShiftState
|
||||||
+ " state=" + mState + " sliding=" + withSliding);
|
+ " state=" + mState + " sliding=" + withSliding);
|
||||||
}
|
}
|
||||||
final boolean isAlphabetMode = isAlphabetMode();
|
final boolean isAlphabetMode = isAlphabetMode();
|
||||||
|
@ -568,7 +568,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
||||||
return;
|
return;
|
||||||
if (DEBUG_STATE) {
|
if (DEBUG_STATE) {
|
||||||
Log.d(TAG, "onReleaseShift:"
|
Log.d(TAG, "onReleaseShift:"
|
||||||
+ " keyboard=" + getLatinKeyboard().getKeyboardShiftState()
|
+ " keyboard=" + getLatinKeyboard().mShiftState
|
||||||
+ " state=" + mState + " sliding=" + withSliding);
|
+ " state=" + mState + " sliding=" + withSliding);
|
||||||
}
|
}
|
||||||
final boolean isAlphabetMode = isAlphabetMode();
|
final boolean isAlphabetMode = isAlphabetMode();
|
||||||
|
@ -613,7 +613,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
||||||
public void onPressSymbol() {
|
public void onPressSymbol() {
|
||||||
if (DEBUG_STATE) {
|
if (DEBUG_STATE) {
|
||||||
Log.d(TAG, "onPressSymbol:"
|
Log.d(TAG, "onPressSymbol:"
|
||||||
+ " keyboard=" + getLatinKeyboard().getKeyboardShiftState()
|
+ " keyboard=" + getLatinKeyboard().mShiftState
|
||||||
+ " state=" + mState);
|
+ " state=" + mState);
|
||||||
}
|
}
|
||||||
changeKeyboardMode();
|
changeKeyboardMode();
|
||||||
|
@ -624,7 +624,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
||||||
public void onReleaseSymbol() {
|
public void onReleaseSymbol() {
|
||||||
if (DEBUG_STATE) {
|
if (DEBUG_STATE) {
|
||||||
Log.d(TAG, "onReleaseSymbol:"
|
Log.d(TAG, "onReleaseSymbol:"
|
||||||
+ " keyboard=" + getLatinKeyboard().getKeyboardShiftState()
|
+ " keyboard=" + getLatinKeyboard().mShiftState
|
||||||
+ " state=" + mState);
|
+ " state=" + mState);
|
||||||
}
|
}
|
||||||
// Snap back to the previous keyboard mode if the user chords the mode change key and
|
// 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() {
|
public void onOtherKeyPressed() {
|
||||||
if (DEBUG_STATE) {
|
if (DEBUG_STATE) {
|
||||||
Log.d(TAG, "onOtherKeyPressed:"
|
Log.d(TAG, "onOtherKeyPressed:"
|
||||||
+ " keyboard=" + getLatinKeyboard().getKeyboardShiftState()
|
+ " keyboard=" + getLatinKeyboard().mShiftState
|
||||||
+ " state=" + mState);
|
+ " state=" + mState);
|
||||||
}
|
}
|
||||||
mState.onOtherKeyPressed();
|
mState.onOtherKeyPressed();
|
||||||
|
|
|
@ -176,7 +176,7 @@ public class LatinKeyboard extends Keyboard {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CharSequence adjustLabelCase(CharSequence label) {
|
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))) {
|
&& label.length() < 3 && Character.isLowerCase(label.charAt(0))) {
|
||||||
return label.toString().toUpperCase(mId.mLocale);
|
return label.toString().toUpperCase(mId.mLocale);
|
||||||
}
|
}
|
||||||
|
|
|
@ -177,7 +177,7 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
|
||||||
public boolean onDoubleTap(MotionEvent firstDown) {
|
public boolean onDoubleTap(MotionEvent firstDown) {
|
||||||
final Keyboard keyboard = getKeyboard();
|
final Keyboard keyboard = getKeyboard();
|
||||||
if (ENABLE_CAPSLOCK_BY_DOUBLETAP && keyboard instanceof LatinKeyboard
|
if (ENABLE_CAPSLOCK_BY_DOUBLETAP && keyboard instanceof LatinKeyboard
|
||||||
&& ((LatinKeyboard) keyboard).isAlphaKeyboard()) {
|
&& ((LatinKeyboard) keyboard).mId.isAlphabetKeyboard()) {
|
||||||
final int pointerIndex = firstDown.getActionIndex();
|
final int pointerIndex = firstDown.getActionIndex();
|
||||||
final int id = firstDown.getPointerId(pointerIndex);
|
final int id = firstDown.getPointerId(pointerIndex);
|
||||||
final PointerTracker tracker = getPointerTracker(id);
|
final PointerTracker tracker = getPointerTracker(id);
|
||||||
|
@ -396,14 +396,14 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
|
||||||
final Keyboard keyboard = getKeyboard();
|
final Keyboard keyboard = getKeyboard();
|
||||||
if (keyboard instanceof LatinKeyboard) {
|
if (keyboard instanceof LatinKeyboard) {
|
||||||
final LatinKeyboard latinKeyboard = (LatinKeyboard) keyboard;
|
final LatinKeyboard latinKeyboard = (LatinKeyboard) keyboard;
|
||||||
if (primaryCode == Keyboard.CODE_DIGIT0 && latinKeyboard.isPhoneKeyboard()) {
|
if (primaryCode == Keyboard.CODE_DIGIT0 && latinKeyboard.mId.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 '+'.
|
||||||
invokeCodeInput(Keyboard.CODE_PLUS);
|
invokeCodeInput(Keyboard.CODE_PLUS);
|
||||||
invokeReleaseKey(primaryCode);
|
invokeReleaseKey(primaryCode);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (primaryCode == Keyboard.CODE_SHIFT && latinKeyboard.isAlphaKeyboard()) {
|
if (primaryCode == Keyboard.CODE_SHIFT && latinKeyboard.mId.isAlphabetKeyboard()) {
|
||||||
tracker.onLongPressed();
|
tracker.onLongPressed();
|
||||||
invokeCodeInput(Keyboard.CODE_CAPSLOCK);
|
invokeCodeInput(Keyboard.CODE_CAPSLOCK);
|
||||||
invokeReleaseKey(primaryCode);
|
invokeReleaseKey(primaryCode);
|
||||||
|
|
Loading…
Reference in New Issue