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

Commit aa86ac82 authored by Cary Clark's avatar Cary Clark
Browse files

map keyboard for webview

Treat the numeric keypad enter as the regular enter for the
purposes of completing a text entry or activating the currently
selected link.

Add a little keyboard-related debugging.

Don't call select text to extend the selection if the tap
point hasn't moved.

A separate change to the Browser app adds more keyboard
accelerators.

bug:3270434
bug:3191699
Change-Id: I8a38b26196e93e344dc2a4b39a6968fe0c158d47
parent 2990594e
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -238,7 +238,8 @@ import junit.framework.Assert;
            }
        }

        if ((mSingle && KeyEvent.KEYCODE_ENTER == keyCode)) {
        if (mSingle && (KeyEvent.KEYCODE_ENTER == keyCode
                    || KeyEvent.KEYCODE_NUMPAD_ENTER == keyCode)) {
            if (isPopupShowing()) {
                return super.dispatchKeyEvent(event);
            }
@@ -296,7 +297,8 @@ import junit.framework.Assert;
            // so do not pass down to javascript, and instead
            // return true.  If it is an arrow key or a delete key, we can go
            // ahead and pass it down.
            if (KeyEvent.KEYCODE_ENTER == keyCode) {
            if (KeyEvent.KEYCODE_ENTER == keyCode
                        || KeyEvent.KEYCODE_NUMPAD_ENTER == keyCode) {
                // For multi-line text boxes, newlines will
                // trigger onTextChanged for key down (which will send both
                // key up and key down) but not key up.
+13 −4
Original line number Diff line number Diff line
@@ -4471,10 +4471,17 @@ public class WebView extends AbsoluteLayout
        return false;
    }

    private boolean isEnterActionKey(int keyCode) {
        return keyCode == KeyEvent.KEYCODE_DPAD_CENTER
                || keyCode == KeyEvent.KEYCODE_ENTER
                || keyCode == KeyEvent.KEYCODE_NUMPAD_ENTER;
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (DebugFlags.WEB_VIEW) {
            Log.v(LOGTAG, "keyDown at " + System.currentTimeMillis()
                    + "keyCode=" + keyCode
                    + ", " + event + ", unicode=" + event.getUnicodeChar());
        }

@@ -4543,7 +4550,7 @@ public class WebView extends AbsoluteLayout
            return false;
        }

        if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) {
        if (isEnterActionKey(keyCode)) {
            switchOutDrawHistory();
            if (event.getRepeatCount() == 0) {
                if (mSelectingText) {
@@ -4672,7 +4679,7 @@ public class WebView extends AbsoluteLayout
            return false;
        }

        if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) {
        if (isEnterActionKey(keyCode)) {
            // remove the long press message first
            mPrivateHandler.removeMessages(LONG_PRESS_CENTER);
            mGotCenterDown = false;
@@ -5464,8 +5471,10 @@ public class WebView extends AbsoluteLayout
                    } else {
                        // TODO: allow scrollable overflow div to autoscroll
                    }
                    if (deltaX != 0 || deltaY != 0) {
                        nativeExtendSelection(contentX, contentY);
                        invalidate();
                    }
                    break;
                }