Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 47e6b1b5 authored by Jeff Brown's avatar Jeff Brown
Browse files

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
parent 735206f1
Loading
Loading
Loading
Loading
+14 −3
Original line number Diff line number Diff line
@@ -185610,7 +185610,7 @@
>
<parameter name="cap" type="android.text.method.TextKeyListener.Capitalize">
</parameter>
<parameter name="autotext" type="boolean">
<parameter name="autoText" type="boolean">
</parameter>
</constructor>
<method name="getInputType"
@@ -185634,11 +185634,22 @@
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="autotext" type="boolean">
<parameter name="autoText" type="boolean">
</parameter>
<parameter name="cap" type="android.text.method.TextKeyListener.Capitalize">
</parameter>
</method>
<method name="getInstanceForFullKeyboard"
 return="android.text.method.QwertyKeyListener"
 abstract="false"
 native="false"
 synchronized="false"
 static="true"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="markAsReplaced"
 return="void"
 abstract="false"
@@ -249324,7 +249335,7 @@
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="t" type="T">
<parameter name="arg0" type="T">
</parameter>
</method>
</interface>
+36 −16
Original line number Diff line number Diff line
@@ -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,6 +106,7 @@ public class QwertyKeyListener extends BaseKeyListener {

        int i = event.getUnicodeChar(event.getMetaState() | getMetaState(content));

        if (!mFullKeyboard) {
            int count = event.getRepeatCount();
            if (count > 0 && selStart == selEnd && selStart > 0) {
                char c = content.charAt(selStart - 1);
@@ -96,6 +118,7 @@ public class QwertyKeyListener extends BaseKeyListener {
                    }
                }
            }
        }

        if (i == KeyCharacterMap.PICKER_DIALOG_INPUT) {
            if (view != null) {
@@ -490,8 +513,5 @@ public class QwertyKeyListener extends BaseKeyListener {

        private char[] mText;
    }

    private Capitalize mAutoCap;
    private boolean mAutoText;
}
+6 −1
Original line number Diff line number Diff line
@@ -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();
+1 −1
Original line number Diff line number Diff line
@@ -101,7 +101,7 @@ key 108 DPAD_DOWN
key 109   PAGE_DOWN
key 110   NUMPAD_ENTER
key 111   FORWARD_DEL
key 113   VALUME_MUTE
key 113   VOLUME_MUTE
key 114   VOLUME_DOWN
key 115   VOLUME_UP
# key 120  switch applications
+1 −1
Original line number Diff line number Diff line
@@ -105,7 +105,7 @@ key 108 DPAD_DOWN
key 109   PAGE_DOWN
key 110   NUMPAD_ENTER
key 111   FORWARD_DEL
key 113   VALUME_MUTE
key 113   VOLUME_MUTE
key 114   VOLUME_DOWN
key 115   VOLUME_UP
key 119   MEDIA_PAUSE
Loading