diff options
author | 2011-11-18 13:47:48 -0800 | |
---|---|---|
committer | 2011-11-18 14:40:05 -0800 | |
commit | 431ce9392561f42f49e55a531197d3d5d19252d4 (patch) | |
tree | 2f4304fc000938722d7d1fcf94c824408dea06e7 /java/src/com/android/inputmethod | |
parent | 18630d5fd681ab853befe7fffb67e3db9c9ea0f1 (diff) | |
download | latinime-431ce9392561f42f49e55a531197d3d5d19252d4.tar.gz latinime-431ce9392561f42f49e55a531197d3d5d19252d4.tar.xz latinime-431ce9392561f42f49e55a531197d3d5d19252d4.zip |
Introduce noKeyPreview Key attribute
This change also removes hacks in LatinKeyboardView by utilizing
noKeyPreview attribute.
Bug: 5638595
Change-Id: Icd8a3af3b7849b941f8f5532e2b432e126a909e6
Diffstat (limited to 'java/src/com/android/inputmethod')
5 files changed, 6 insertions, 35 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/Key.java b/java/src/com/android/inputmethod/keyboard/Key.java index f2014b771..5fefea77d 100644 --- a/java/src/com/android/inputmethod/keyboard/Key.java +++ b/java/src/com/android/inputmethod/keyboard/Key.java @@ -67,6 +67,7 @@ public class Key { private static final int LABEL_OPTION_WITH_ICON_LEFT = 0x1000; private static final int LABEL_OPTION_WITH_ICON_RIGHT = 0x2000; private static final int LABEL_OPTION_AUTO_X_SCALE = 0x4000; + private static final int LABEL_OPTION_NO_KEY_PREVIEW = 0x8000; /** Icon to display instead of a label. Icon takes precedence over a label */ private Drawable mIcon; @@ -386,6 +387,10 @@ public class Key { return (mLabelOption & LABEL_OPTION_AUTO_X_SCALE) != 0; } + public boolean noKeyPreview() { + return (mLabelOption & LABEL_OPTION_NO_KEY_PREVIEW) != 0; + } + public Drawable getIcon() { return mIcon; } diff --git a/java/src/com/android/inputmethod/keyboard/Keyboard.java b/java/src/com/android/inputmethod/keyboard/Keyboard.java index a8bc74551..4a28bf1de 100644 --- a/java/src/com/android/inputmethod/keyboard/Keyboard.java +++ b/java/src/com/android/inputmethod/keyboard/Keyboard.java @@ -217,10 +217,6 @@ public class Keyboard { return mId.isPhoneKeyboard(); } - public boolean isNumberKeyboard() { - return mId.isNumberKeyboard(); - } - public CharSequence adjustLabelCase(CharSequence label) { if (isShiftedOrShiftLocked() && !TextUtils.isEmpty(label) && label.length() < 3 && Character.isLowerCase(label.charAt(0))) { diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardId.java b/java/src/com/android/inputmethod/keyboard/KeyboardId.java index 2e4988fb0..cf0637124 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardId.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardId.java @@ -133,10 +133,6 @@ public class KeyboardId { return mXmlId == R.xml.kbd_phone_shift; } - public boolean isNumberKeyboard() { - return mMode == MODE_NUMBER; - } - @Override public boolean equals(Object other) { return other instanceof KeyboardId && equals((KeyboardId) other); diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java index b09628b3d..abf24ead2 100644 --- a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java @@ -263,20 +263,6 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke return mKeyTimerHandler; } - @Override - public void setKeyPreviewPopupEnabled(boolean previewEnabled, int delay) { - final Keyboard keyboard = getKeyboard(); - if (keyboard instanceof LatinKeyboard) { - final LatinKeyboard latinKeyboard = (LatinKeyboard)keyboard; - if (latinKeyboard.isPhoneKeyboard() || latinKeyboard.isNumberKeyboard()) { - // Phone and number keyboard never shows popup preview. - super.setKeyPreviewPopupEnabled(false, delay); - return; - } - } - super.setKeyPreviewPopupEnabled(previewEnabled, delay); - } - /** * Attaches a keyboard to this view. The keyboard can be switched at any time and the * view will re-layout itself to accommodate the keyboard. diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java index 5673bfc50..a3ec37c1b 100644 --- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java +++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java @@ -343,7 +343,7 @@ public class PointerTracker { private void setPressedKeyGraphics(int keyIndex) { final Key key = getKey(keyIndex); if (key != null && key.isEnabled()) { - if (isKeyPreviewRequired(key)) { + if (!key.noKeyPreview()) { mDrawingProxy.showKeyPreview(keyIndex, this); } key.onPressed(); @@ -351,18 +351,6 @@ public class PointerTracker { } } - // The modifier key, such as shift key, should not show its key preview. - private static boolean isKeyPreviewRequired(Key key) { - final int code = key.mCode; - // TODO: Stop hard-coding these key codes here, and add a new key attribute of a key. - if (code == Keyboard.CODE_SPACE || code == Keyboard.CODE_ENTER - || code == Keyboard.CODE_DELETE || isModifierCode(code) - || code == Keyboard.CODE_SETTINGS || code == Keyboard.CODE_SHORTCUT) { - return false; - } - return true; - } - public int getLastX() { return mLastX; } |