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

Commit d7678a16 authored by Teng-Hui Zhu's avatar Teng-Hui Zhu
Browse files

Support javascript to exit full screen video.

When javascript request exit full screen, WebViewCore need to handle the
message from webkit thread and hide the custom view.

Webkit part:
https://android-git.corp.google.com/g/#/c/158652/

Change-Id: I9edbb5a4059f330fb29df116ae076ec52f81a1af
parent 50ba5a26
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -162,6 +162,16 @@ class HTML5VideoViewProxy extends Handler
                mHTML5VideoView.enterFullScreenVideoState(layerId, proxy, webView);
        }

        public static void exitFullScreenVideo(HTML5VideoViewProxy proxy,
                WebView webView) {
            if (!mHTML5VideoView.fullScreenExited() && mHTML5VideoView.isFullScreenMode()) {
                WebChromeClient client = webView.getWebChromeClient();
                if (client != null) {
                    client.onHideCustomView();
                }
            }
        }

        // This is on the UI thread.
        // When native tell Java to play, we need to check whether or not it is
        // still the same video by using videoLayerId and treat it differently.
@@ -682,6 +692,10 @@ class HTML5VideoViewProxy extends Handler
        VideoPlayer.enterFullScreenVideo(layerId, url, this, mWebView);
    }

    public void exitFullScreenVideo() {
        VideoPlayer.exitFullScreenVideo(this, mWebView);
    }

    /**
     * The factory for HTML5VideoViewProxy instances.
     * @param webViewCore is the WebViewCore that is requesting the proxy.
+7 −0
Original line number Diff line number Diff line
@@ -796,6 +796,7 @@ public class WebView extends AbsoluteLayout
    static final int ENTER_FULLSCREEN_VIDEO             = 137;
    static final int UPDATE_SELECTION                   = 138;
    static final int UPDATE_ZOOM_DENSITY                = 139;
    static final int EXIT_FULLSCREEN_VIDEO              = 140;

    private static final int FIRST_PACKAGE_MSG_ID = SCROLL_TO_MSG_ID;
    private static final int LAST_PACKAGE_MSG_ID = HIT_TEST_RESULT;
@@ -8752,6 +8753,12 @@ public class WebView extends AbsoluteLayout
                    }
                    break;

                case EXIT_FULLSCREEN_VIDEO:
                    if (mHTML5VideoViewProxy != null) {
                        mHTML5VideoViewProxy.exitFullScreenVideo();
                    }
                    break;

                case SHOW_FULLSCREEN: {
                    View view = (View) msg.obj;
                    int orientation = msg.arg1;
+11 −0
Original line number Diff line number Diff line
@@ -501,6 +501,17 @@ public final class WebViewCore {
        message.sendToTarget();
    }

    /**
     * Notify the webview that we want to exit the video fullscreen.
     * This is called through JNI by webcore.
     */
    protected void exitFullscreenVideo() {
        if (mWebView == null) return;
        Message message = Message.obtain(mWebView.mPrivateHandler,
                       WebView.EXIT_FULLSCREEN_VIDEO);
        message.sendToTarget();
    }

    /**
     * Clear the picture set. To be called only on the WebCore thread.
     */