Fix NPE by disabling key preview popup of Emoji palette

Bug: 15579928
Change-Id: I6bcf885f2c1aa37b337a85978409ccf41e459c2a
main
Tadashi G. Takaoka 2014-06-13 11:01:36 +09:00
parent 89899e14df
commit a68e0dd437
4 changed files with 10 additions and 7 deletions

View File

@ -195,7 +195,8 @@ public class Key implements Comparable<Key> {
mHintLabel = hintLabel;
mLabelFlags = labelFlags;
mBackgroundType = backgroundType;
mActionFlags = 0;
// TODO: Pass keyActionFlags as an argument.
mActionFlags = ACTION_FLAGS_NO_KEY_PREVIEW;
mMoreKeys = null;
mMoreKeysColumnAndFlags = 0;
mLabel = label;

View File

@ -446,15 +446,15 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
@Override
public void showKeyPreview(final Key key) {
// If key is invalid or IME is already closed, we must not show key preview.
// Trying to show key preview while root window is closed causes
// WindowManager.BadTokenException.
if (key == null) {
// If the key is invalid or has no key preview, we must not show key preview.
if (key == null || key.noKeyPreview()) {
return;
}
final KeyPreviewDrawParams previewParams = mKeyPreviewDrawParams;
final Keyboard keyboard = getKeyboard();
if (keyboard == null) {
return;
}
final KeyPreviewDrawParams previewParams = mKeyPreviewDrawParams;
if (!previewParams.isPopupEnabled()) {
previewParams.setVisibleOffset(-keyboard.mVerticalGap);
return;

View File

@ -444,6 +444,7 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
continue;
}
final int labelFlags = row.getDefaultKeyLabelFlags();
// TODO: Should be able to assign default keyActionFlags as well.
final int backgroundType = row.getDefaultBackgroundType();
final int x = (int)row.getKeyX(null);
final int y = row.getKeyY();

View File

@ -45,6 +45,7 @@ public final class KeyboardRow {
private final ArrayDeque<RowAttributes> mRowAttributesStack = new ArrayDeque<>();
// TODO: Add keyActionFlags.
private static class RowAttributes {
/** Default width of a key in this row. */
public final float mDefaultKeyWidth;