diff options
author | 2015-09-10 15:51:05 -0700 | |
---|---|---|
committer | 2015-10-15 12:47:32 -0700 | |
commit | 1fdb8f31562eeef78167585a878eb0450310036b (patch) | |
tree | b6aeeb57abce26c843a2c03cf336fdb59650f402 /java/src/com/android/inputmethod/latin/LatinIME.java | |
parent | de674ac02ee0090078f1ec0d286f26ef19cdeebb (diff) | |
download | latinime-1fdb8f31562eeef78167585a878eb0450310036b.tar.gz latinime-1fdb8f31562eeef78167585a878eb0450310036b.tar.xz latinime-1fdb8f31562eeef78167585a878eb0450310036b.zip |
Define shortcuts for toggling IME layouts.
Out of the box, we want Alt-Left to toggle Emojis, while Alt-Right
toggles the shifted symbols layout.
Bug: 23954008
Bug: 24369173
Change-Id: I93dd66fb469e5d0a831359ff3a786fe68e1d73ea
(cherry picked from commit 411841b374aa04e333ea5a438dfd539f49ec589a)
Diffstat (limited to 'java/src/com/android/inputmethod/latin/LatinIME.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/LatinIME.java | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 1f2b6f25d..25a5de250 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -142,8 +142,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen private RichInputMethodManager mRichImm; @UsedForTesting final KeyboardSwitcher mKeyboardSwitcher; private final SubtypeState mSubtypeState = new SubtypeState(); - private final EmojiAltPhysicalKeyDetector mEmojiAltPhysicalKeyDetector = - new EmojiAltPhysicalKeyDetector(mInputLogic.mConnection); + private EmojiAltPhysicalKeyDetector mEmojiAltPhysicalKeyDetector; private StatsUtilsManager mStatsUtilsManager; // Working variable for {@link #startShowingInputView()} and // {@link #onEvaluateInputViewShown()}. @@ -702,6 +701,12 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen mInputLogic.recycle(); } + private boolean isImeSuppressedByHardwareKeyboard() { + final KeyboardSwitcher switcher = KeyboardSwitcher.getInstance(); + return switcher.isImeSuppressedByHardwareKeyboard( + mSettings.getCurrent(), switcher.getKeyboardSwitchState()); + } + @Override public void onConfigurationChanged(final Configuration conf) { SettingsValues settingsValues = mSettings.getCurrent(); @@ -716,7 +721,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen // have a change in hardware keyboard configuration. loadSettings(); settingsValues = mSettings.getCurrent(); - if (settingsValues.mHasHardwareKeyboard) { + if (isImeSuppressedByHardwareKeyboard()) { // We call cleanupInternalStateForFinishInput() because it's the right thing to do; // however, it seems at the moment the framework is passing us a seemingly valid // but actually non-functional InputConnection object. So if this bug ever gets @@ -874,7 +879,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen // can go into the correct mode, so we need to do some housekeeping here. final boolean needToCallLoadKeyboardLater; final Suggest suggest = mInputLogic.mSuggest; - if (!currentSettingsValues.mHasHardwareKeyboard) { + if (!isImeSuppressedByHardwareKeyboard()) { // The app calling setText() has the effect of clearing the composing // span, so we should reset our state unconditionally, even if restarting is true. // We also tell the input logic about the combining rules for the current subtype, so @@ -1118,8 +1123,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen return; } final int inputHeight = mInputView.getHeight(); - final boolean hasHardwareKeyboard = settingsValues.mHasHardwareKeyboard; - if (hasHardwareKeyboard && visibleKeyboardView.getVisibility() == View.GONE) { + if (isImeSuppressedByHardwareKeyboard() && !visibleKeyboardView.isShown()) { // If there is a hardware keyboard and a visible software keyboard view has been hidden, // no visual element will be shown on the screen. outInsets.contentTopInsets = inputHeight; @@ -1165,7 +1169,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen @Override public boolean onShowInputRequested(final int flags, final boolean configChange) { - if (Settings.getInstance().getCurrent().mHasHardwareKeyboard) { + if (isImeSuppressedByHardwareKeyboard()) { return true; } return super.onShowInputRequested(flags, configChange); @@ -1182,7 +1186,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen @Override public boolean onEvaluateFullscreenMode() { final SettingsValues settingsValues = mSettings.getCurrent(); - if (settingsValues.mHasHardwareKeyboard) { + if (isImeSuppressedByHardwareKeyboard()) { // If there is a hardware keyboard, disable full screen mode. return false; } @@ -1646,8 +1650,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen // Hooks for hardware keyboard @Override public boolean onKeyDown(final int keyCode, final KeyEvent keyEvent) { - // TODO: This should be processed in {@link InputLogic}. - mEmojiAltPhysicalKeyDetector.onKeyDown(keyEvent); if (!ProductionFlags.IS_HARDWARE_KEYBOARD_SUPPORTED) { return super.onKeyDown(keyCode, keyEvent); } @@ -1668,7 +1670,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen @Override public boolean onKeyUp(final int keyCode, final KeyEvent keyEvent) { - // TODO: This should be processed in {@link InputLogic}. + if (mEmojiAltPhysicalKeyDetector == null) { + mEmojiAltPhysicalKeyDetector = new EmojiAltPhysicalKeyDetector( + getApplicationContext().getResources()); + } mEmojiAltPhysicalKeyDetector.onKeyUp(keyEvent); if (!ProductionFlags.IS_HARDWARE_KEYBOARD_SUPPORTED) { return super.onKeyUp(keyCode, keyEvent); |