From c3d175c01ff1956ddb1c2d608d69af1793b4ad8a Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Wed, 27 Jul 2011 15:32:25 -0700 Subject: [PATCH] Fix wrong keyboard width when orientation has changed while IME is not shown Bug: 5084021 Change-Id: Ie42da40b8249eaf9cf29707058906949278eff6a --- .../android/inputmethod/keyboard/KeyboardId.java | 2 +- .../inputmethod/keyboard/KeyboardSwitcher.java | 15 ++++++++------- .../com/android/inputmethod/latin/LatinIME.java | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardId.java b/java/src/com/android/inputmethod/keyboard/KeyboardId.java index 3f30165aa..75fba947e 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardId.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardId.java @@ -160,7 +160,7 @@ public class KeyboardId { return other instanceof KeyboardId && equals((KeyboardId) other); } - boolean equals(KeyboardId other) { + private boolean equals(KeyboardId other) { return other.mLocale.equals(this.mLocale) && other.mOrientation == this.mOrientation && other.mWidth == this.mWidth diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java index 552a3cd30..a4080f1be 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java @@ -161,24 +161,25 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha } } + public void onHideWindow() { + mWindowWidth = 0; + mIsAutoCorrectionActive = false; + } + @SuppressWarnings("unused") public void onSizeChanged(int w, int h, int oldw, int oldh) { + // TODO: This hack should be removed when display metric returns a proper width. + // Until then, the behavior of KeyboardSwitcher is suboptimal on a device that has a + // vertical system navigation bar in landscape screen orientation, for instance. final int width = mInputMethodService.getWindow().getWindow().getDecorView().getWidth(); // If the window width hasn't fixed yet or keyboard doesn't exist, nothing to do with. if (width == 0 || mCurrentId == null) return; // The window width is fixed. mWindowWidth = width; - // If this is the first time the {@link KeyboardView} has been shown, no need to reload - // keyboard. - if (oldw == 0 && oldh == 0) - return; // Reload keyboard with new width. final int orientation = mInputMethodService.getResources().getConfiguration().orientation; final KeyboardId newId = mCurrentId.cloneWithNewGeometry(orientation, width); - // If the new keyboard is the same as the current one, no need to reload it. - if (newId.equals(mCurrentId)) - return; setKeyboard(getKeyboard(newId)); } diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index d9d421411..ddc69f123 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -872,7 +872,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar @Override public void hideWindow() { LatinImeLogger.commit(); - mKeyboardSwitcher.onAutoCorrectionStateChanged(false); + mKeyboardSwitcher.onHideWindow(); if (TRACE) Debug.stopMethodTracing(); if (mOptionsDialog != null && mOptionsDialog.isShowing()) {