Fix 2146178: On-screen keyboard is wider than screen

Sometimes the keyboard is getting confused about it's width when switching
between hard keyboard open and close state and portrait-forced home. Force
creation of keyboard layouts after a configuration change to fix the
inconsistent state.

Don't force create when just switching between input fields, too expensive.

Also fixes the problem of keyboard not changing layout after a locale change,
unless there's an orientation change.
This commit is contained in:
Amith Yamasani 2009-09-30 21:15:47 -07:00
parent 56f96fe05b
commit 12e582c79c
2 changed files with 10 additions and 9 deletions

View file

@ -70,14 +70,15 @@ public class KeyboardSwitcher {
mInputView = inputView;
}
void makeKeyboards() {
void makeKeyboards(boolean forceCreate) {
if (forceCreate) mKeyboards.clear();
// Configuration change is coming after the keyboard gets recreated. So don't rely on that.
// If keyboards have already been made, check if we have a screen width change and
// create the keyboard layouts again at the correct orientation
int displayWidth = mContext.getMaxWidth();
if (displayWidth == mLastDisplayWidth) return;
mLastDisplayWidth = displayWidth;
mKeyboards.clear();
if (!forceCreate) mKeyboards.clear();
mSymbolsId = new KeyboardId(R.xml.kbd_symbols);
mSymbolsShiftedId = new KeyboardId(R.xml.kbd_symbols_shift);
}

View file

@ -210,16 +210,16 @@ public class LatinIME extends InputMethodService
public void onConfigurationChanged(Configuration conf) {
if (!TextUtils.equals(conf.locale.toString(), mLocale)) {
initSuggest(conf.locale.toString());
if (mKeyboardSwitcher == null) {
mKeyboardSwitcher = new KeyboardSwitcher(this);
}
mKeyboardSwitcher.makeKeyboards();
}
// If orientation changed while predicting, commit the change
if (conf.orientation != mOrientation) {
commitTyped(getCurrentInputConnection());
mOrientation = conf.orientation;
}
if (mKeyboardSwitcher == null) {
mKeyboardSwitcher = new KeyboardSwitcher(this);
}
mKeyboardSwitcher.makeKeyboards(true);
super.onConfigurationChanged(conf);
}
@ -228,7 +228,7 @@ public class LatinIME extends InputMethodService
mInputView = (LatinKeyboardView) getLayoutInflater().inflate(
R.layout.input, null);
mKeyboardSwitcher.setInputView(mInputView);
mKeyboardSwitcher.makeKeyboards();
mKeyboardSwitcher.makeKeyboards(true);
mInputView.setOnKeyboardActionListener(this);
mKeyboardSwitcher.setKeyboardMode(KeyboardSwitcher.MODE_TEXT, 0);
return mInputView;
@ -236,7 +236,7 @@ public class LatinIME extends InputMethodService
@Override
public View onCreateCandidatesView() {
mKeyboardSwitcher.makeKeyboards();
mKeyboardSwitcher.makeKeyboards(true);
mCandidateViewContainer = (CandidateViewContainer) getLayoutInflater().inflate(
R.layout.candidates, null);
mCandidateViewContainer.initViews();
@ -253,7 +253,7 @@ public class LatinIME extends InputMethodService
return;
}
mKeyboardSwitcher.makeKeyboards();
mKeyboardSwitcher.makeKeyboards(false);
TextEntryState.newSession(this);