Loading java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java +24 −26 Original line number Diff line number Diff line Loading @@ -106,6 +106,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha private static final KeyboardSwitcher sInstance = new KeyboardSwitcher(); // TODO: Move this to KeyboardState. private class KeyboardLayoutState { private boolean mIsValid; private boolean mIsAlphabetMode; Loading @@ -113,43 +114,39 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha private boolean mIsShifted; public void save() { if (mCurrentId == null) { return; } mIsAlphabetMode = isAlphabetMode(); if (mIsAlphabetMode) { mIsShiftLocked = mState.isShiftLocked(); mIsShifted = !mIsShiftLocked && mState.isShiftedOrShiftLocked(); } else { mIsShiftLocked = false; mIsShifted = mCurrentId.equals(mSymbolsShiftedKeyboardId); mIsShifted = isSymbolShifted(); } mIsValid = true; } public KeyboardId getKeyboardId() { if (!mIsValid) return mMainKeyboardId; if (mIsAlphabetMode) { return mMainKeyboardId; } else { return mIsShifted ? mSymbolsShiftedKeyboardId : mSymbolsKeyboardId; public void restore(boolean forceRestore) { if (!mIsValid) { if (forceRestore) { setAlphabetKeyboard(); } return; } public void restore() { if (!mIsValid) return; mIsValid = false; if (mIsAlphabetMode) { final boolean isAlphabetMode = isAlphabetMode(); final boolean isShiftLocked = isAlphabetMode && mState.isShiftLocked(); final boolean isShifted = !isShiftLocked && mState.isShiftedOrShiftLocked(); if (mIsShiftLocked != isShiftLocked) { toggleCapsLock(); } else if (mIsShifted != isShifted) { onPressShift(false); onReleaseShift(false); setAlphabetKeyboard(); if (mIsShiftLocked) { setShiftLocked(true); } if (mIsShifted) { setShifted(MANUAL_SHIFT); } } else { if (mIsShifted) { setSymbolsShiftedKeyboard(); } else { setSymbolsKeyboard(); } } } Loading Loading @@ -207,8 +204,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha mSymbolsShiftedKeyboardId = getKeyboardId(editorInfo, true, true, settingsValues); mState.onLoadKeyboard(); mLayoutSwitchBackSymbols = mResources.getString(R.string.layout_switch_back_symbols); setKeyboard(getKeyboard(mSavedKeyboardState.getKeyboardId())); mSavedKeyboardState.restore(); mSavedKeyboardState.restore(mCurrentId == null); } catch (RuntimeException e) { Log.w(TAG, "loading keyboard failed: " + mMainKeyboardId, e); LatinImeLogger.logOnException(mMainKeyboardId.toString(), e); Loading @@ -216,8 +212,10 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha } public void saveKeyboardState() { if (mCurrentId != null) { mSavedKeyboardState.save(); } } public void onFinishInputView() { mIsAutoCorrectionActive = false; Loading Loading
java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java +24 −26 Original line number Diff line number Diff line Loading @@ -106,6 +106,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha private static final KeyboardSwitcher sInstance = new KeyboardSwitcher(); // TODO: Move this to KeyboardState. private class KeyboardLayoutState { private boolean mIsValid; private boolean mIsAlphabetMode; Loading @@ -113,43 +114,39 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha private boolean mIsShifted; public void save() { if (mCurrentId == null) { return; } mIsAlphabetMode = isAlphabetMode(); if (mIsAlphabetMode) { mIsShiftLocked = mState.isShiftLocked(); mIsShifted = !mIsShiftLocked && mState.isShiftedOrShiftLocked(); } else { mIsShiftLocked = false; mIsShifted = mCurrentId.equals(mSymbolsShiftedKeyboardId); mIsShifted = isSymbolShifted(); } mIsValid = true; } public KeyboardId getKeyboardId() { if (!mIsValid) return mMainKeyboardId; if (mIsAlphabetMode) { return mMainKeyboardId; } else { return mIsShifted ? mSymbolsShiftedKeyboardId : mSymbolsKeyboardId; public void restore(boolean forceRestore) { if (!mIsValid) { if (forceRestore) { setAlphabetKeyboard(); } return; } public void restore() { if (!mIsValid) return; mIsValid = false; if (mIsAlphabetMode) { final boolean isAlphabetMode = isAlphabetMode(); final boolean isShiftLocked = isAlphabetMode && mState.isShiftLocked(); final boolean isShifted = !isShiftLocked && mState.isShiftedOrShiftLocked(); if (mIsShiftLocked != isShiftLocked) { toggleCapsLock(); } else if (mIsShifted != isShifted) { onPressShift(false); onReleaseShift(false); setAlphabetKeyboard(); if (mIsShiftLocked) { setShiftLocked(true); } if (mIsShifted) { setShifted(MANUAL_SHIFT); } } else { if (mIsShifted) { setSymbolsShiftedKeyboard(); } else { setSymbolsKeyboard(); } } } Loading Loading @@ -207,8 +204,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha mSymbolsShiftedKeyboardId = getKeyboardId(editorInfo, true, true, settingsValues); mState.onLoadKeyboard(); mLayoutSwitchBackSymbols = mResources.getString(R.string.layout_switch_back_symbols); setKeyboard(getKeyboard(mSavedKeyboardState.getKeyboardId())); mSavedKeyboardState.restore(); mSavedKeyboardState.restore(mCurrentId == null); } catch (RuntimeException e) { Log.w(TAG, "loading keyboard failed: " + mMainKeyboardId, e); LatinImeLogger.logOnException(mMainKeyboardId.toString(), e); Loading @@ -216,8 +212,10 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha } public void saveKeyboardState() { if (mCurrentId != null) { mSavedKeyboardState.save(); } } public void onFinishInputView() { mIsAutoCorrectionActive = false; Loading