You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ti...@apache.org on 2020/04/14 18:48:20 UTC

[cordova-android] branch master updated: Prevent exit fullscreen mode from closing application (#823)

This is an automated email from the ASF dual-hosted git repository.

timbru31 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cordova-android.git


The following commit(s) were added to refs/heads/master by this push:
     new 71f63d7  Prevent exit fullscreen mode from closing application (#823)
71f63d7 is described below

commit 71f63d7b331af07bdcbb236f28474a874383f4e8
Author: João Gonçalves <ch...@gmail.com>
AuthorDate: Tue Apr 14 19:48:06 2020 +0100

    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: エリス <er...@users.noreply.github.com>
    
    * Update framework/src/org/apache/cordova/CordovaWebViewImpl.java
    
    Co-Authored-By: エリス <er...@users.noreply.github.com>
    
    * Update framework/src/org/apache/cordova/CordovaWebViewImpl.java
    
    Co-Authored-By: エリス <er...@users.noreply.github.com>
    
    * remove empty line below @override
    
    Co-authored-by: Norman Breau <no...@normanbreau.com>
    Co-authored-by: エリス <er...@users.noreply.github.com>
---
 .../src/org/apache/cordova/CordovaWebViewImpl.java | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/framework/src/org/apache/cordova/CordovaWebViewImpl.java b/framework/src/org/apache/cordova/CordovaWebViewImpl.java
index 1db2e95..a77502d 100644
--- a/framework/src/org/apache/cordova/CordovaWebViewImpl.java
+++ b/framework/src/org/apache/cordova/CordovaWebViewImpl.java
@@ -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));


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org