diff options
author | Jeff Brown <jeffbrown@google.com> | 2010-11-29 17:37:49 -0800 |
---|---|---|
committer | Jeff Brown <jeffbrown@google.com> | 2010-11-30 17:15:49 -0800 |
commit | 47e6b1b5eef8ee99872f278f66bc498c4fcca0d8 (patch) | |
tree | ef5a7c87b8dca433ea9707c1289ae7c8d2ba3787 /core/java/android/text/method | |
parent | 735206f121cb2a11b3397870e6565178627e0aa3 (diff) | |
download | frameworks_base-47e6b1b5eef8ee99872f278f66bc498c4fcca0d8.zip frameworks_base-47e6b1b5eef8ee99872f278f66bc498c4fcca0d8.tar.gz frameworks_base-47e6b1b5eef8ee99872f278f66bc498c4fcca0d8.tar.bz2 |
Support non-orientation aware keyboards and other devices.
Fixed a bug with dpad keys on external keyboards being rotated
according to the display orientation by adding a new input device
configuration property called "keyboard.orientationAware".
Added a mechanism for overriding the key layout and key character
map in the input device configuration file using the new
"keyboard.layout" and "keyboard.characterMap" properties.
Also added "trackball.orientationAware", "touch.orientationAware" and
"touch.deviceType" configuration properties.
Rewrote the configuration property reading code in native code
so that it can be used by EventHub and other components.
Added basic support for installable idc, kl, and kcm files
in /data/system/devices. However, there is no provision for
copying files there yet.
Disabled long-press character pickers on full keyboards so that
key repeating works as expected.
Change-Id: I1bd9f0c3d344421db444e7d271eb09bc8bab4791
Diffstat (limited to 'core/java/android/text/method')
-rw-r--r-- | core/java/android/text/method/QwertyKeyListener.java | 52 | ||||
-rw-r--r-- | core/java/android/text/method/TextKeyListener.java | 7 |
2 files changed, 42 insertions, 17 deletions
diff --git a/core/java/android/text/method/QwertyKeyListener.java b/core/java/android/text/method/QwertyKeyListener.java index 3308172..09388c0 100644 --- a/core/java/android/text/method/QwertyKeyListener.java +++ b/core/java/android/text/method/QwertyKeyListener.java @@ -31,27 +31,48 @@ import android.view.View; public class QwertyKeyListener extends BaseKeyListener { private static QwertyKeyListener[] sInstance = new QwertyKeyListener[Capitalize.values().length * 2]; + private static QwertyKeyListener sFullKeyboardInstance; - public QwertyKeyListener(Capitalize cap, boolean autotext) { + private Capitalize mAutoCap; + private boolean mAutoText; + private boolean mFullKeyboard; + + private QwertyKeyListener(Capitalize cap, boolean autoText, boolean fullKeyboard) { mAutoCap = cap; - mAutoText = autotext; + mAutoText = autoText; + mFullKeyboard = fullKeyboard; + } + + public QwertyKeyListener(Capitalize cap, boolean autoText) { + this(cap, autoText, false); } /** * Returns a new or existing instance with the specified capitalization * and correction properties. */ - public static QwertyKeyListener getInstance(boolean autotext, - Capitalize cap) { - int off = cap.ordinal() * 2 + (autotext ? 1 : 0); + public static QwertyKeyListener getInstance(boolean autoText, Capitalize cap) { + int off = cap.ordinal() * 2 + (autoText ? 1 : 0); if (sInstance[off] == null) { - sInstance[off] = new QwertyKeyListener(cap, autotext); + sInstance[off] = new QwertyKeyListener(cap, autoText); } return sInstance[off]; } + /** + * Gets an instance of the listener suitable for use with full keyboards. + * Disables auto-capitalization, auto-text and long-press initiated on-screen + * character pickers. + */ + public static QwertyKeyListener getInstanceForFullKeyboard() { + if (sFullKeyboardInstance == null) { + sFullKeyboardInstance = new QwertyKeyListener(Capitalize.NONE, false, true); + } + return sFullKeyboardInstance; + } + public int getInputType() { return makeTextContentType(mAutoCap, mAutoText); } @@ -85,14 +106,16 @@ public class QwertyKeyListener extends BaseKeyListener { int i = event.getUnicodeChar(event.getMetaState() | getMetaState(content)); - int count = event.getRepeatCount(); - if (count > 0 && selStart == selEnd && selStart > 0) { - char c = content.charAt(selStart - 1); + if (!mFullKeyboard) { + int count = event.getRepeatCount(); + if (count > 0 && selStart == selEnd && selStart > 0) { + char c = content.charAt(selStart - 1); - if (c == i || c == Character.toUpperCase(i) && view != null) { - if (showCharacterPicker(view, content, c, false, count)) { - resetMetaState(content); - return true; + if (c == i || c == Character.toUpperCase(i) && view != null) { + if (showCharacterPicker(view, content, c, false, count)) { + resetMetaState(content); + return true; + } } } } @@ -490,8 +513,5 @@ public class QwertyKeyListener extends BaseKeyListener { private char[] mText; } - - private Capitalize mAutoCap; - private boolean mAutoText; } diff --git a/core/java/android/text/method/TextKeyListener.java b/core/java/android/text/method/TextKeyListener.java index 8ad6f50..8312fe1 100644 --- a/core/java/android/text/method/TextKeyListener.java +++ b/core/java/android/text/method/TextKeyListener.java @@ -189,7 +189,12 @@ public class TextKeyListener extends BaseKeyListener implements SpanWatcher { return MultiTapKeyListener.getInstance(mAutoText, mAutoCap); } else if (kind == KeyCharacterMap.FULL || kind == KeyCharacterMap.SPECIAL_FUNCTION) { - return QwertyKeyListener.getInstance(false, Capitalize.NONE); + // We consider special function keyboards full keyboards as a workaround for + // devices that do not have built-in keyboards. Applications may try to inject + // key events using the built-in keyboard device id which may be configured as + // a special function keyboard using a default key map. Ideally, as of Honeycomb, + // these applications should be modified to use KeyCharacterMap.VIRTUAL_KEYBOARD. + return QwertyKeyListener.getInstanceForFullKeyboard(); } return NullKeyListener.getInstance(); |