diff options
Diffstat (limited to 'java/src/com/android/inputmethod/latin/LatinIME.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/LatinIME.java | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 4b6ab7e27..737bd0d3e 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -16,6 +16,8 @@ package com.android.inputmethod.latin; +import static android.view.Display.INVALID_DISPLAY; + import static com.android.inputmethod.latin.common.Constants.ImeOption.FORCE_ASCII; import static com.android.inputmethod.latin.common.Constants.ImeOption.NO_MICROPHONE; import static com.android.inputmethod.latin.common.Constants.ImeOption.NO_MICROPHONE_COMPAT; @@ -107,6 +109,7 @@ import java.util.Locale; import java.util.concurrent.TimeUnit; import javax.annotation.Nonnull; +import javax.annotation.Nullable; /** * Input method implementation for Qwerty'ish keyboard. @@ -118,7 +121,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen static final String TAG = LatinIME.class.getSimpleName(); private static final boolean TRACE = false; - private static final int EXTENDED_TOUCHABLE_REGION_HEIGHT = 100; private static final int PERIOD_FOR_AUDIO_AND_HAPTIC_FEEDBACK_IN_KEY_REPEAT = 2; private static final int PENDING_IMS_CALLBACK_DURATION_MILLIS = 800; static final long DELAY_WAIT_FOR_DICTIONARY_LOAD_MILLIS = TimeUnit.SECONDS.toMillis(2); @@ -166,6 +168,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen // {@link #onEvaluateInputViewShown()}. private boolean mIsExecutingStartShowingInputView; + // Used for re-initialize keyboard layout after onConfigurationChange. + @Nullable private Context mDisplayContext; + private int mCurDisplayId = INVALID_DISPLAY; + // Object for reacting to adding/removing a dictionary pack. private final BroadcastReceiver mDictionaryPackInstallReceiver = new DictionaryPackInstallBroadcastReceiver(this); @@ -594,10 +600,13 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen DebugFlags.init(PreferenceManager.getDefaultSharedPreferences(this)); RichInputMethodManager.init(this); mRichImm = RichInputMethodManager.getInstance(); - KeyboardSwitcher.init(this); AudioAndHapticFeedbackManager.init(this); AccessibilityUtils.init(this); mStatsUtilsManager.onCreate(this /* context */, mDictionaryFacilitator); + final WindowManager wm = getSystemService(WindowManager.class); + mDisplayContext = createDisplayContext(wm.getDefaultDisplay()); + mCurDisplayId = wm.getDefaultDisplay().getDisplayId(); + KeyboardSwitcher.init(this); super.onCreate(); mHandler.onCreate(); @@ -785,9 +794,27 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen } @Override + public void onInitializeInterface() { + // TODO (b/133825283): Non-activity components Resources / DisplayMetrics update when + // moving to external display. + // An issue in Q that non-activity components Resources / DisplayMetrics in + // Context doesn't well updated when moving to external display. + // Currently we do a workaround is to check if IME is moving to new display, if so, + // create new display context and re-init keyboard layout with this context. + final WindowManager wm = getSystemService(WindowManager.class); + final int newDisplayId = wm.getDefaultDisplay().getDisplayId(); + if (mCurDisplayId != newDisplayId) { + mCurDisplayId = newDisplayId; + mDisplayContext = createDisplayContext(wm.getDefaultDisplay()); + mKeyboardSwitcher.updateKeyboardTheme(mDisplayContext); + } + } + + @Override public View onCreateInputView() { StatsUtils.onCreateInputView(); - return mKeyboardSwitcher.onCreateInputView(mIsHardwareAcceleratedDrawingEnabled); + return mKeyboardSwitcher.onCreateInputView(mDisplayContext, + mIsHardwareAcceleratedDrawingEnabled); } @Override @@ -870,7 +897,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen mGestureConsumer = GestureConsumer.NULL_GESTURE_CONSUMER; mRichImm.refreshSubtypeCaches(); final KeyboardSwitcher switcher = mKeyboardSwitcher; - switcher.updateKeyboardTheme(); + switcher.updateKeyboardTheme(mDisplayContext); final MainKeyboardView mainKeyboardView = switcher.getMainKeyboardView(); // If we are starting input in a different text field from before, we'll have to reload // settings, so currentSettingsValues can't be final. @@ -1212,9 +1239,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen final int touchLeft = 0; final int touchTop = mKeyboardSwitcher.isShowingMoreKeysPanel() ? 0 : visibleTopY; final int touchRight = visibleKeyboardView.getWidth(); - final int touchBottom = inputHeight - // Extend touchable region below the keyboard. - + EXTENDED_TOUCHABLE_REGION_HEIGHT; + final int touchBottom = inputHeight; outInsets.touchableInsets = InputMethodService.Insets.TOUCHABLE_INSETS_REGION; outInsets.touchableRegion.set(touchLeft, touchTop, touchRight, touchBottom); } |