diff --git a/plugins/Android/webview-nofragment/src/main/java/net/gree/unitywebview/CUnityPlayerActivity.java b/plugins/Android/webview-nofragment/src/main/java/net/gree/unitywebview/CUnityPlayerActivity.java index 82bf2bf1..230b6fca 100644 --- a/plugins/Android/webview-nofragment/src/main/java/net/gree/unitywebview/CUnityPlayerActivity.java +++ b/plugins/Android/webview-nofragment/src/main/java/net/gree/unitywebview/CUnityPlayerActivity.java @@ -7,6 +7,7 @@ import android.os.Bundle; import android.util.Log; import android.view.MotionEvent; +import android.view.View; import android.webkit.WebView; import com.unity3d.player.*; import java.lang.reflect.Method; @@ -16,7 +17,7 @@ public class CUnityPlayerActivity extends UnityPlayerActivity { - private List _webViews = new ArrayList(); + private List _webViewPlugins = new ArrayList(); private List _masks = new ArrayList(); @Override @@ -51,22 +52,23 @@ public boolean dispatchTouchEvent(MotionEvent event) { } } } - for (WebView webView : _webViews) { + for (CWebViewPlugin webViewPlugin : _webViewPlugins) { // cf. https://stackoverflow.com/questions/17845545/custom-viewgroup-dispatchtouchevent-doesnt-work-correctly/17845670#17845670 MotionEvent cp = MotionEvent.obtain(event); - cp.offsetLocation(-webView.getLeft(), -webView.getTop()); - webView.dispatchTouchEvent(cp); + View view = (webViewPlugin.mVideoView != null) ? webViewPlugin.mVideoView : webViewPlugin.mWebView; + cp.offsetLocation(-view.getLeft(), -view.getTop()); + view.dispatchTouchEvent(cp); cp.recycle(); } return ret; } - void add(WebView webView) { - _webViews.add(webView); + void add(CWebViewPlugin webViewPlugin) { + _webViewPlugins.add(webViewPlugin); } - void remove(WebView webView) { - _webViews.remove(webView); + void remove(CWebViewPlugin webViewPlugin) { + _webViewPlugins.remove(webViewPlugin); } public void clearMasks() { diff --git a/plugins/Android/webview-nofragment/src/main/java/net/gree/unitywebview/CWebViewPlugin.java b/plugins/Android/webview-nofragment/src/main/java/net/gree/unitywebview/CWebViewPlugin.java index 776e7a36..af89ea86 100644 --- a/plugins/Android/webview-nofragment/src/main/java/net/gree/unitywebview/CWebViewPlugin.java +++ b/plugins/Android/webview-nofragment/src/main/java/net/gree/unitywebview/CWebViewPlugin.java @@ -104,8 +104,8 @@ public class CWebViewPlugin { private static boolean forceBringToFront; private static FrameLayout layout = null; private Queue mMessages = new ArrayDeque(); - private WebView mWebView; - private View mVideoView; + WebView mWebView; + View mVideoView; private OnGlobalLayoutListener mGlobalLayoutListener; private CWebViewPluginInterface mWebViewPlugin; private int progress; @@ -556,7 +556,7 @@ public boolean onTouch(View view, MotionEvent event) { LayoutParams.MATCH_PARENT, Gravity.NO_GRAVITY)); mWebView = webView; - ((CUnityPlayerActivity)a).add(mWebView); + ((CUnityPlayerActivity)a).add(self); }}); final View activityRootView = a.getWindow().getDecorView().getRootView(); @@ -605,7 +605,7 @@ public void onGlobalLayout() { public void Destroy() { final Activity a = UnityPlayer.currentActivity; - ((CUnityPlayerActivity)a).remove(mWebView); + ((CUnityPlayerActivity)a).remove(this); if (CWebViewPlugin.isDestroyed(a)) { return; } diff --git a/plugins/Android/webview/src/main/java/net/gree/unitywebview/CUnityPlayerActivity.java b/plugins/Android/webview/src/main/java/net/gree/unitywebview/CUnityPlayerActivity.java index 82bf2bf1..230b6fca 100644 --- a/plugins/Android/webview/src/main/java/net/gree/unitywebview/CUnityPlayerActivity.java +++ b/plugins/Android/webview/src/main/java/net/gree/unitywebview/CUnityPlayerActivity.java @@ -7,6 +7,7 @@ import android.os.Bundle; import android.util.Log; import android.view.MotionEvent; +import android.view.View; import android.webkit.WebView; import com.unity3d.player.*; import java.lang.reflect.Method; @@ -16,7 +17,7 @@ public class CUnityPlayerActivity extends UnityPlayerActivity { - private List _webViews = new ArrayList(); + private List _webViewPlugins = new ArrayList(); private List _masks = new ArrayList(); @Override @@ -51,22 +52,23 @@ public boolean dispatchTouchEvent(MotionEvent event) { } } } - for (WebView webView : _webViews) { + for (CWebViewPlugin webViewPlugin : _webViewPlugins) { // cf. https://stackoverflow.com/questions/17845545/custom-viewgroup-dispatchtouchevent-doesnt-work-correctly/17845670#17845670 MotionEvent cp = MotionEvent.obtain(event); - cp.offsetLocation(-webView.getLeft(), -webView.getTop()); - webView.dispatchTouchEvent(cp); + View view = (webViewPlugin.mVideoView != null) ? webViewPlugin.mVideoView : webViewPlugin.mWebView; + cp.offsetLocation(-view.getLeft(), -view.getTop()); + view.dispatchTouchEvent(cp); cp.recycle(); } return ret; } - void add(WebView webView) { - _webViews.add(webView); + void add(CWebViewPlugin webViewPlugin) { + _webViewPlugins.add(webViewPlugin); } - void remove(WebView webView) { - _webViews.remove(webView); + void remove(CWebViewPlugin webViewPlugin) { + _webViewPlugins.remove(webViewPlugin); } public void clearMasks() { diff --git a/plugins/Android/webview/src/main/java/net/gree/unitywebview/CWebViewPlugin.java b/plugins/Android/webview/src/main/java/net/gree/unitywebview/CWebViewPlugin.java index 0182f65a..da49e0fa 100644 --- a/plugins/Android/webview/src/main/java/net/gree/unitywebview/CWebViewPlugin.java +++ b/plugins/Android/webview/src/main/java/net/gree/unitywebview/CWebViewPlugin.java @@ -135,8 +135,8 @@ public class CWebViewPlugin extends Fragment { private static boolean forceBringToFront; private static FrameLayout layout = null; private Queue mMessages = new ArrayDeque(); - private WebView mWebView; - private View mVideoView; + WebView mWebView; + View mVideoView; private OnGlobalLayoutListener mGlobalLayoutListener; private CWebViewPluginInterface mWebViewPlugin; private int progress; @@ -810,7 +810,7 @@ public boolean onTouch(View view, MotionEvent event) { LayoutParams.MATCH_PARENT, Gravity.NO_GRAVITY)); mWebView = webView; - ((CUnityPlayerActivity)a).add(mWebView); + ((CUnityPlayerActivity)a).add(self); }}); final View activityRootView = a.getWindow().getDecorView().getRootView(); @@ -922,7 +922,7 @@ private File createImageFile() throws IOException { public void Destroy() { final Activity a = UnityPlayer.currentActivity; final CWebViewPlugin self = this; - ((CUnityPlayerActivity)a).remove(mWebView); + ((CUnityPlayerActivity)a).remove(self); mMessages.clear(); if (CWebViewPlugin.isDestroyed(a)) { return;