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

Commit f2e17a86 authored by Leon Scroggins's avatar Leon Scroggins
Browse files

Hide the soft keyboard when a textfield is blurred.

Bug: 2953257

Requires a change to external/webkit

Change-Id: I8ca82dc7cb6bc1494400f5e5c38050023c94a513
parent 698fcc12
Loading
Loading
Loading
Loading
+11 −6
Original line number Original line Diff line number Diff line
@@ -607,7 +607,7 @@ public class WebView extends AbsoluteLayout
    static final int HIDE_FULLSCREEN                    = 121;
    static final int HIDE_FULLSCREEN                    = 121;
    static final int DOM_FOCUS_CHANGED                  = 122;
    static final int DOM_FOCUS_CHANGED                  = 122;
    static final int REPLACE_BASE_CONTENT               = 123;
    static final int REPLACE_BASE_CONTENT               = 123;
    // 124;
    static final int FORM_DID_BLUR                      = 124;
    static final int RETURN_LABEL                       = 125;
    static final int RETURN_LABEL                       = 125;
    static final int FIND_AGAIN                         = 126;
    static final int FIND_AGAIN                         = 126;
    static final int CENTER_FIT_RECT                    = 127;
    static final int CENTER_FIT_RECT                    = 127;
@@ -659,7 +659,7 @@ public class WebView extends AbsoluteLayout
        "HIDE_FULLSCREEN", //                = 121;
        "HIDE_FULLSCREEN", //                = 121;
        "DOM_FOCUS_CHANGED", //              = 122;
        "DOM_FOCUS_CHANGED", //              = 122;
        "REPLACE_BASE_CONTENT", //           = 123;
        "REPLACE_BASE_CONTENT", //           = 123;
        "124", //                            = 124;
        "FORM_DID_BLUR", //                  = 124;
        "RETURN_LABEL", //                   = 125;
        "RETURN_LABEL", //                   = 125;
        "FIND_AGAIN", //                     = 126;
        "FIND_AGAIN", //                     = 126;
        "CENTER_FIT_RECT", //                = 127;
        "CENTER_FIT_RECT", //                = 127;
@@ -3854,10 +3854,9 @@ public class WebView extends AbsoluteLayout


    // Called by WebKit to instruct the UI to hide the keyboard
    // Called by WebKit to instruct the UI to hide the keyboard
    private void hideSoftKeyboard() {
    private void hideSoftKeyboard() {
        InputMethodManager imm = (InputMethodManager)
        InputMethodManager imm = InputMethodManager.peekInstance();
                getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
        if (imm != null && (imm.isActive(this)
        if (imm.isActive(this)
                || (inEditingMode() && imm.isActive(mWebTextView)))) {
                || (inEditingMode() && imm.isActive(mWebTextView))) {
            imm.hideSoftInputFromWindow(this.getWindowToken(), 0);
            imm.hideSoftInputFromWindow(this.getWindowToken(), 0);
        }
        }
    }
    }
@@ -6688,6 +6687,12 @@ public class WebView extends AbsoluteLayout
                    updateTextSelectionFromMessage(msg.arg1, msg.arg2,
                    updateTextSelectionFromMessage(msg.arg1, msg.arg2,
                            (WebViewCore.TextSelectionData) msg.obj);
                            (WebViewCore.TextSelectionData) msg.obj);
                    break;
                    break;
                case FORM_DID_BLUR:
                    if (inEditingMode()
                            && mWebTextView.isSameTextField(msg.arg1)) {
                        hideSoftKeyboard();
                    }
                    break;
                case RETURN_LABEL:
                case RETURN_LABEL:
                    if (inEditingMode()
                    if (inEditingMode()
                            && mWebTextView.isSameTextField(msg.arg1)) {
                            && mWebTextView.isSameTextField(msg.arg1)) {
+10 −0
Original line number Original line Diff line number Diff line
@@ -273,6 +273,16 @@ final class WebViewCore {
        mCallbackProxy.onJsAlert(url, message);
        mCallbackProxy.onJsAlert(url, message);
    }
    }


    /**
     * Called by JNI.  Send a message to the UI thread to hide the soft keyboard
     * if the node pointed to by nodePointer is still in focus.
     * @param nodePointer The node which just blurred.
     */
    private void formDidBlur(int nodePointer) {
        if (mWebView == null) return;
        Message.obtain(mWebView.mPrivateHandler, WebView.FORM_DID_BLUR,
                nodePointer, 0).sendToTarget();
    }


    /**
    /**
     * Called by JNI.  Open a file chooser to upload a file.
     * Called by JNI.  Open a file chooser to upload a file.