Fix NPE by disabling key preview popup of Emoji palette
Bug: 15579928 Change-Id: I6bcf885f2c1aa37b337a85978409ccf41e459c2a
This commit is contained in:
parent
89899e14df
commit
a68e0dd437
4 changed files with 10 additions and 7 deletions
|
@ -195,7 +195,8 @@ public class Key implements Comparable<Key> {
|
||||||
mHintLabel = hintLabel;
|
mHintLabel = hintLabel;
|
||||||
mLabelFlags = labelFlags;
|
mLabelFlags = labelFlags;
|
||||||
mBackgroundType = backgroundType;
|
mBackgroundType = backgroundType;
|
||||||
mActionFlags = 0;
|
// TODO: Pass keyActionFlags as an argument.
|
||||||
|
mActionFlags = ACTION_FLAGS_NO_KEY_PREVIEW;
|
||||||
mMoreKeys = null;
|
mMoreKeys = null;
|
||||||
mMoreKeysColumnAndFlags = 0;
|
mMoreKeysColumnAndFlags = 0;
|
||||||
mLabel = label;
|
mLabel = label;
|
||||||
|
|
|
@ -446,15 +446,15 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void showKeyPreview(final Key key) {
|
public void showKeyPreview(final Key key) {
|
||||||
// If key is invalid or IME is already closed, we must not show key preview.
|
// If the key is invalid or has no key preview, we must not show key preview.
|
||||||
// Trying to show key preview while root window is closed causes
|
if (key == null || key.noKeyPreview()) {
|
||||||
// WindowManager.BadTokenException.
|
|
||||||
if (key == null) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final KeyPreviewDrawParams previewParams = mKeyPreviewDrawParams;
|
|
||||||
final Keyboard keyboard = getKeyboard();
|
final Keyboard keyboard = getKeyboard();
|
||||||
|
if (keyboard == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final KeyPreviewDrawParams previewParams = mKeyPreviewDrawParams;
|
||||||
if (!previewParams.isPopupEnabled()) {
|
if (!previewParams.isPopupEnabled()) {
|
||||||
previewParams.setVisibleOffset(-keyboard.mVerticalGap);
|
previewParams.setVisibleOffset(-keyboard.mVerticalGap);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -444,6 +444,7 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
final int labelFlags = row.getDefaultKeyLabelFlags();
|
final int labelFlags = row.getDefaultKeyLabelFlags();
|
||||||
|
// TODO: Should be able to assign default keyActionFlags as well.
|
||||||
final int backgroundType = row.getDefaultBackgroundType();
|
final int backgroundType = row.getDefaultBackgroundType();
|
||||||
final int x = (int)row.getKeyX(null);
|
final int x = (int)row.getKeyX(null);
|
||||||
final int y = row.getKeyY();
|
final int y = row.getKeyY();
|
||||||
|
|
|
@ -45,6 +45,7 @@ public final class KeyboardRow {
|
||||||
|
|
||||||
private final ArrayDeque<RowAttributes> mRowAttributesStack = new ArrayDeque<>();
|
private final ArrayDeque<RowAttributes> mRowAttributesStack = new ArrayDeque<>();
|
||||||
|
|
||||||
|
// TODO: Add keyActionFlags.
|
||||||
private static class RowAttributes {
|
private static class RowAttributes {
|
||||||
/** Default width of a key in this row. */
|
/** Default width of a key in this row. */
|
||||||
public final float mDefaultKeyWidth;
|
public final float mDefaultKeyWidth;
|
||||||
|
|
Loading…
Reference in a new issue