Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,60 @@ public void onProgressChanged(WebView view, int progress) {
FlutterWebviewPlugin.channel.invokeMethod("onProgressChanged", args);
}

// Allow switching to fullscreen e.g when playing a video

private View customView;
private CustomViewCallback customViewCallback;

@Override
public void onShowCustomView(View view, int requestedOrientation, CustomViewCallback callback) {
onShowCustomView(view, callback);
}

@Override
public void onShowCustomView(View view, CustomViewCallback callback) {
// if a view already exists then immediately terminate the new one
if (customView != null) {
callback.onCustomViewHidden();
return;
}

// add custom view to container and save reference
customView = view;
customViewCallback = callback;

FrameLayout rootView = (FrameLayout)webView.getRootView();
rootView.addView(customView);

// hide webview and show custom view
customView.setVisibility(View.VISIBLE);
FrameLayout contentView = (FrameLayout)rootView.findViewById(android.R.id.content);
contentView.setVisibility(View.GONE);
}

@Override
public void onHideCustomView() {
super.onHideCustomView();
if (customView == null)
return;

// Hide the custom view and show Webview
FrameLayout rootView = (FrameLayout)webView.getRootView();
FrameLayout contentView = (FrameLayout)rootView.findViewById(android.R.id.content);
contentView.setVisibility(View.VISIBLE);
customView.setVisibility(View.GONE);

// Remove the custom view from its container and clear reference
rootView.removeView(customView);
customViewCallback.onCustomViewHidden();
customView = null;
}

public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) {
callback.invoke(origin, true, false);

}

});
}

Expand Down