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

Commit 5f9c2ab7 authored by Android (Google) Code Review's avatar Android (Google) Code Review
Browse files

Merge change 5648

* changes:
  Adding support for webkit to request the keyboard.
parents c2188ff5 4c41e8dc
Loading
Loading
Loading
Loading
+38 −14
Original line number Diff line number Diff line
@@ -467,6 +467,7 @@ public class WebView extends AbsoluteLayout
    static final int WEBCORE_NEED_TOUCH_EVENTS          = 25;
    // obj=Rect in doc coordinates
    static final int INVAL_RECT_MSG_ID                  = 26;
    static final int REQUEST_KEYBOARD                   = 27;

    static final String[] HandlerDebugString = {
        "REMEMBER_PASSWORD", //              = 1;
@@ -494,7 +495,8 @@ public class WebView extends AbsoluteLayout
        "LONG_PRESS_CENTER", //              = 23;
        "PREVENT_TOUCH_ID", //               = 24;
        "WEBCORE_NEED_TOUCH_EVENTS", //      = 25;
        "INVAL_RECT_MSG_ID" //               = 26;
        "INVAL_RECT_MSG_ID", //              = 26;
        "REQUEST_KEYBOARD" //                = 27;
    };

    // width which view is considered to be fully zoomed out
@@ -3002,9 +3004,11 @@ public class WebView extends AbsoluteLayout
    }

    // Called by JNI when a touch event puts a textfield into focus.
    private void displaySoftKeyboard() {
    private void displaySoftKeyboard(boolean isTextView) {
        InputMethodManager imm = (InputMethodManager)
                getContext().getSystemService(Context.INPUT_METHOD_SERVICE);

        if (isTextView) {
            imm.showSoftInput(mWebTextView, 0);
            mWebTextView.enableScrollOnScreen(true);
            // Now we need to fake a touch event to place the cursor where the
@@ -3019,6 +3023,18 @@ public class WebView extends AbsoluteLayout
                mWebTextView.fakeTouchEvent(x, y);
            }
        }
        else { // used by plugins
            imm.showSoftInput(this, 0);
        }
    }

    // Called by WebKit to instruct the UI to hide the keyboard
    private void hideSoftKeyboard() {
        InputMethodManager imm = (InputMethodManager)
                getContext().getSystemService(Context.INPUT_METHOD_SERVICE);

        imm.hideSoftInputFromWindow(this.getWindowToken(), 0);
    }

    /*
     * This method checks the current focus and cursor and potentially rebuilds
@@ -4920,6 +4936,14 @@ public class WebView extends AbsoluteLayout
                    }
                    break;

                case REQUEST_KEYBOARD:
                    if (msg.arg1 == 0) {
                        hideSoftKeyboard();
                    } else {
                        displaySoftKeyboard(false);
                    }
                    break;

                default:
                    super.handleMessage(msg);
                    break;
+9 −0
Original line number Diff line number Diff line
@@ -1780,6 +1780,15 @@ final class WebViewCore {

    }

    // called by JNI
    private void requestKeyboard(boolean showKeyboard) {
        if (mWebView != null) {
            Message.obtain(mWebView.mPrivateHandler,
                    WebView.REQUEST_KEYBOARD, showKeyboard ? 1 : 0, 0)
                    .sendToTarget();
        }
    }

    private native void nativePause();
    private native void nativeResume();
    private native void nativeFreeMemory();