summaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/LatinIME.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/com/android/inputmethod/latin/LatinIME.java')
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java27
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);