Fix wrong keyboard width when orientation has changed while IME is not shown

Bug: 5084021
Change-Id: Ie42da40b8249eaf9cf29707058906949278eff6a
This commit is contained in:
Tadashi G. Takaoka 2011-07-27 15:32:25 -07:00
parent 0a5345c7b6
commit c3d175c01f
3 changed files with 10 additions and 9 deletions

View file

@ -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

View file

@ -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));
}

View file

@ -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()) {