mirror of
https://github.com/apache/cordova-android.git
synced 2025-03-04 00:13:20 +08:00
Prevent exit fullscreen mode from closing application (#823)
* (android) wrap custom view in FrameLayout Wraps the custom view in a FrameLayout in order to capture key events and redirect them to SystemWebView's dispatchKeyEvent. * Update framework/src/org/apache/cordova/CordovaWebViewImpl.java Co-Authored-By: エリス <erisu@users.noreply.github.com> * Update framework/src/org/apache/cordova/CordovaWebViewImpl.java Co-Authored-By: エリス <erisu@users.noreply.github.com> * Update framework/src/org/apache/cordova/CordovaWebViewImpl.java Co-Authored-By: エリス <erisu@users.noreply.github.com> * remove empty line below @override Co-authored-by: Norman Breau <norman@normanbreau.com> Co-authored-by: エリス <erisu@users.noreply.github.com>
This commit is contained in:
parent
8d47cd73c0
commit
71f63d7b33
@ -244,6 +244,21 @@ public class CordovaWebViewImpl implements CordovaWebView {
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
@ -255,13 +270,16 @@ public class CordovaWebViewImpl implements CordovaWebView {
|
||||
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));
|
||||
|
Loading…
Reference in New Issue
Block a user