Skip to content
Snippets Groups Projects
Commit 05c0fc61 authored by Tadashi G. Takaoka's avatar Tadashi G. Takaoka
Browse files

Fix NPE in LatinKeyboard

Bug: 4727778
Change-Id: I9d5b7185d75408a8af6d302fb348e118c0f9721e
parent cdc12db4
No related branches found
No related tags found
No related merge requests found
......@@ -136,12 +136,16 @@ public class LatinKeyboard extends Keyboard {
// The threshold is "key width" x 1.25
mSpacebarLanguageSwitchThreshold = (getMostCommonKeyWidth() * 5) / 4;
final int spaceKeyWidth = Math.max(mSpaceKey.mWidth,
(int)(getMinWidth() * SPACEBAR_POPUP_MIN_RATIO));
final int spaceKeyheight = mSpacePreviewIcon.getIntrinsicHeight();
mSlidingLocaleIcon = new SlidingLocaleDrawable(
context, mSpacePreviewIcon, spaceKeyWidth, spaceKeyheight);
mSlidingLocaleIcon.setBounds(0, 0, spaceKeyWidth, spaceKeyheight);
if (mSpaceKey != null) {
final int slidingIconWidth = Math.max(mSpaceKey.mWidth,
(int)(getMinWidth() * SPACEBAR_POPUP_MIN_RATIO));
final int spaceKeyheight = mSpacePreviewIcon.getIntrinsicHeight();
mSlidingLocaleIcon = new SlidingLocaleDrawable(
context, mSpacePreviewIcon, slidingIconWidth, spaceKeyheight);
mSlidingLocaleIcon.setBounds(0, 0, slidingIconWidth, spaceKeyheight);
} else {
mSlidingLocaleIcon = null;
}
}
public void setSpacebarTextFadeFactor(float fadeFactor, LatinKeyboardView view) {
......@@ -350,6 +354,8 @@ public class LatinKeyboard extends Keyboard {
if (mSpacebarSlidingLanguageSwitchDiff == diff)
return;
mSpacebarSlidingLanguageSwitchDiff = diff;
if (mSlidingLocaleIcon == null)
return;
mSlidingLocaleIcon.setDiff(diff);
if (Math.abs(diff) == Integer.MAX_VALUE) {
mSpaceKey.setPreviewIcon(mSpacePreviewIcon);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment