Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent exit fullscreen mode from closing application #823

Merged
merged 5 commits into from
Apr 14, 2020
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
22 changes: 20 additions & 2 deletions framework/src/org/apache/cordova/CordovaWebViewImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,21 @@ public void showWebPage(String url, boolean openExternal, boolean clearHistory,
}
}

private static class WrapperView extends FrameLayout {

private final CordovaWebViewEngine engine;

public WrapperView(Context context, CordovaWebViewEngine engine) {
super(context);
this.engine = engine;
}

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
return engine.getView().dispatchKeyEvent(event);
}
}

@Override
@Deprecated
public void showCustomView(View view, WebChromeClient.CustomViewCallback callback) {
Expand All @@ -255,13 +270,16 @@ public void showCustomView(View view, WebChromeClient.CustomViewCallback callbac
return;
}

WrapperView wrapperView = new WrapperView(getContext(), engine);
wrapperView.addView(view);

// Store the view and its callback for later (to kill it properly)
mCustomView = view;
mCustomView = wrapperView;
mCustomViewCallback = callback;

// Add the custom view to its container.
ViewGroup parent = (ViewGroup) engine.getView().getParent();
parent.addView(view, new FrameLayout.LayoutParams(
parent.addView(wrapperView, new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT,
Gravity.CENTER));
Expand Down