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:
parent
56f96fe05b
commit
12e582c79c
2 changed files with 10 additions and 9 deletions
|
@ -70,14 +70,15 @@ public class KeyboardSwitcher {
|
||||||
mInputView = inputView;
|
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.
|
// 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
|
// If keyboards have already been made, check if we have a screen width change and
|
||||||
// create the keyboard layouts again at the correct orientation
|
// create the keyboard layouts again at the correct orientation
|
||||||
int displayWidth = mContext.getMaxWidth();
|
int displayWidth = mContext.getMaxWidth();
|
||||||
if (displayWidth == mLastDisplayWidth) return;
|
if (displayWidth == mLastDisplayWidth) return;
|
||||||
mLastDisplayWidth = displayWidth;
|
mLastDisplayWidth = displayWidth;
|
||||||
mKeyboards.clear();
|
if (!forceCreate) mKeyboards.clear();
|
||||||
mSymbolsId = new KeyboardId(R.xml.kbd_symbols);
|
mSymbolsId = new KeyboardId(R.xml.kbd_symbols);
|
||||||
mSymbolsShiftedId = new KeyboardId(R.xml.kbd_symbols_shift);
|
mSymbolsShiftedId = new KeyboardId(R.xml.kbd_symbols_shift);
|
||||||
}
|
}
|
||||||
|
|
|
@ -210,16 +210,16 @@ public class LatinIME extends InputMethodService
|
||||||
public void onConfigurationChanged(Configuration conf) {
|
public void onConfigurationChanged(Configuration conf) {
|
||||||
if (!TextUtils.equals(conf.locale.toString(), mLocale)) {
|
if (!TextUtils.equals(conf.locale.toString(), mLocale)) {
|
||||||
initSuggest(conf.locale.toString());
|
initSuggest(conf.locale.toString());
|
||||||
if (mKeyboardSwitcher == null) {
|
|
||||||
mKeyboardSwitcher = new KeyboardSwitcher(this);
|
|
||||||
}
|
|
||||||
mKeyboardSwitcher.makeKeyboards();
|
|
||||||
}
|
}
|
||||||
// If orientation changed while predicting, commit the change
|
// If orientation changed while predicting, commit the change
|
||||||
if (conf.orientation != mOrientation) {
|
if (conf.orientation != mOrientation) {
|
||||||
commitTyped(getCurrentInputConnection());
|
commitTyped(getCurrentInputConnection());
|
||||||
mOrientation = conf.orientation;
|
mOrientation = conf.orientation;
|
||||||
}
|
}
|
||||||
|
if (mKeyboardSwitcher == null) {
|
||||||
|
mKeyboardSwitcher = new KeyboardSwitcher(this);
|
||||||
|
}
|
||||||
|
mKeyboardSwitcher.makeKeyboards(true);
|
||||||
super.onConfigurationChanged(conf);
|
super.onConfigurationChanged(conf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,7 +228,7 @@ public class LatinIME extends InputMethodService
|
||||||
mInputView = (LatinKeyboardView) getLayoutInflater().inflate(
|
mInputView = (LatinKeyboardView) getLayoutInflater().inflate(
|
||||||
R.layout.input, null);
|
R.layout.input, null);
|
||||||
mKeyboardSwitcher.setInputView(mInputView);
|
mKeyboardSwitcher.setInputView(mInputView);
|
||||||
mKeyboardSwitcher.makeKeyboards();
|
mKeyboardSwitcher.makeKeyboards(true);
|
||||||
mInputView.setOnKeyboardActionListener(this);
|
mInputView.setOnKeyboardActionListener(this);
|
||||||
mKeyboardSwitcher.setKeyboardMode(KeyboardSwitcher.MODE_TEXT, 0);
|
mKeyboardSwitcher.setKeyboardMode(KeyboardSwitcher.MODE_TEXT, 0);
|
||||||
return mInputView;
|
return mInputView;
|
||||||
|
@ -236,7 +236,7 @@ public class LatinIME extends InputMethodService
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateCandidatesView() {
|
public View onCreateCandidatesView() {
|
||||||
mKeyboardSwitcher.makeKeyboards();
|
mKeyboardSwitcher.makeKeyboards(true);
|
||||||
mCandidateViewContainer = (CandidateViewContainer) getLayoutInflater().inflate(
|
mCandidateViewContainer = (CandidateViewContainer) getLayoutInflater().inflate(
|
||||||
R.layout.candidates, null);
|
R.layout.candidates, null);
|
||||||
mCandidateViewContainer.initViews();
|
mCandidateViewContainer.initViews();
|
||||||
|
@ -253,7 +253,7 @@ public class LatinIME extends InputMethodService
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mKeyboardSwitcher.makeKeyboards();
|
mKeyboardSwitcher.makeKeyboards(false);
|
||||||
|
|
||||||
TextEntryState.newSession(this);
|
TextEntryState.newSession(this);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue