You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by GitBox <gi...@apache.org> on 2021/07/20 06:46:29 UTC
[GitHub] [cordova-plugin-inappbrowser] The-White-Fang opened a new pull request #892: Added fullscreen-video support
The-White-Fang opened a new pull request #892:
URL: https://github.com/apache/cordova-plugin-inappbrowser/pull/892
<!--
Please make sure the checklist boxes are all checked before submitting the PR. The checklist is intended as a quick reference, for complete details please see our Contributor Guidelines:
http://cordova.apache.org/contribute/contribute_guidelines.html
Thanks!
-->
### Platforms affected
Android
### Motivation and Context
<!-- Why is this change required? What problem does it solve? -->
Adds full-screen video view support
<!-- If it fixes an open issue, please link to the issue here. -->
[Issue 320](https://github.com/apache/cordova-plugin-inappbrowser/issues/320)
### Description
<!-- Describe your changes in detail -->
Updated InAppBrowser.java and InAppChromeClient.java
Added VideoEnabledWebChromeClient.java and VideoEnabledWebView.java
Code used to implement came from [here](https://github.com/matthid/cordova-plugin-inappbrowser) which was originally derived from [this](https://github.com/cprcrack/VideoEnabledWebView).
### Testing
Tested on Andoird 10 & Andoird 11
### Checklist
- [x] I've run the tests to see all new and existing tests pass
- [ ] I added automated test coverage as appropriate for this change
- [ ] Commit is prefixed with `(platform)` if this change only applies to one platform (e.g. `(android)`)
- [x] If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct [keyword to close issues using keywords](https://help.github.com/articles/closing-issues-using-keywords/))
- [x] I've updated the documentation if necessary
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org
[GitHub] [cordova-plugin-inappbrowser] timbru31 commented on a change in pull request #892: Added fullscreen-video support
Posted by GitBox <gi...@apache.org>.
timbru31 commented on a change in pull request #892:
URL: https://github.com/apache/cordova-plugin-inappbrowser/pull/892#discussion_r673212739
##########
File path: src/android/VideoEnabledWebChromeClient.java
##########
@@ -0,0 +1,294 @@
+package org.apache.cordova.inappbrowser;
+
+import android.media.MediaPlayer;
+import android.view.SurfaceView;
+import android.view.View;
+import android.view.ViewGroup;
+import android.webkit.WebChromeClient;
+import android.widget.FrameLayout;
+
+/**
+ * This class serves as a WebChromeClient to be set to a WebView, allowing it to play video.
+ * Video will play differently depending on target API level (in-line, fullscreen, or both).
+ *
+ * It has been tested with the following video classes:
+ * - android.widget.VideoView (typically API level <11)
+ * - android.webkit.HTML5VideoFullScreen$VideoSurfaceView/VideoTextureView (typically API level 11-18)
+ * - com.android.org.chromium.content.browser.ContentVideoView$VideoSurfaceView (typically API level 19+)
+ *
+ * Important notes:
+ * - For API level 11+, android:hardwareAccelerated="true" must be set in the application manifest.
+ * - The invoking activity must call VideoEnabledWebChromeClient's onBackPressed() inside of its own onBackPressed().
+ * - Tested in Android API levels 8-19. Only tested on http://m.youtube.com.
+ *
+ * @author Cristian Perez (http://cpr.name)
Review comment:
This seems copy/pasted from https://github.com/cprcrack/VideoEnabledWebView
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org
[GitHub] [cordova-plugin-inappbrowser] The-White-Fang commented on pull request #892: Added fullscreen-video support
Posted by GitBox <gi...@apache.org>.
The-White-Fang commented on pull request #892:
URL: https://github.com/apache/cordova-plugin-inappbrowser/pull/892#issuecomment-883500633
> Hi there,
>
> First I'd like to thank you for your time in preparing this PR. I was able to give this a glance over and there's a few main things that I want to point out.
>
> 1. There are new classes added that needs to be licensed under the Apache license for Apache to accept the code. If you have permission from the original author to re-license the code under the [Apache License](https://www.apache.org/licenses/LICENSE-2.0), then the Apache license headers needs to be added. Otherwise we cannot accept the Pr unfortunately.
> 2. This PR adds maintenance support for code going back as Android 3.0 (API 11). Cordova only supports API >= 22 and adding conditional logic to support anything less adds unnecessary complexity. I would like to see this simplified by removing any extra code required to support APIs < 22.
>
> Kind regards,
> Norman
Hey Norman,
I would gladly update the code as you have requested. But it might take me some time. Hope you understand.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org
[GitHub] [cordova-plugin-inappbrowser] breautek commented on a change in pull request #892: Added fullscreen-video support
Posted by GitBox <gi...@apache.org>.
breautek commented on a change in pull request #892:
URL: https://github.com/apache/cordova-plugin-inappbrowser/pull/892#discussion_r673171492
##########
File path: src/android/InAppBrowser.java
##########
@@ -6,9 +6,7 @@ Licensed to the Apache Software Foundation (ASF) under one
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
-
http://www.apache.org/licenses/LICENSE-2.0
-
Unless required by applicable law or agreed to in writing,
Review comment:
The deletion of these lines will probably cause problems with our release process where it checks for proper license headers. Please revert these deletions
##########
File path: src/android/InAppBrowser.java
##########
@@ -773,6 +778,38 @@ public void onClick(View v) {
return _close;
}
+ private void enableFullScreen(Activity activity, Window window) {
+ inFullScreen = true;
+ WindowManager.LayoutParams attrs = window.getAttributes();
+ attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
+ attrs.flags |= WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
+ window.setAttributes(attrs);
+ if (android.os.Build.VERSION.SDK_INT >= 14)
+ {
+ //noinspection all
+ int flags = View.SYSTEM_UI_FLAG_LOW_PROFILE;
+ if (android.os.Build.VERSION.SDK_INT >= 16)
Review comment:
Same situation above.
##########
File path: src/android/VideoEnabledWebChromeClient.java
##########
@@ -0,0 +1,294 @@
+package org.apache.cordova.inappbrowser;
+
+import android.media.MediaPlayer;
+import android.view.SurfaceView;
+import android.view.View;
+import android.view.ViewGroup;
+import android.webkit.WebChromeClient;
+import android.widget.FrameLayout;
+
+/**
+ * This class serves as a WebChromeClient to be set to a WebView, allowing it to play video.
+ * Video will play differently depending on target API level (in-line, fullscreen, or both).
+ *
+ * It has been tested with the following video classes:
+ * - android.widget.VideoView (typically API level <11)
+ * - android.webkit.HTML5VideoFullScreen$VideoSurfaceView/VideoTextureView (typically API level 11-18)
+ * - com.android.org.chromium.content.browser.ContentVideoView$VideoSurfaceView (typically API level 19+)
+ *
+ * Important notes:
+ * - For API level 11+, android:hardwareAccelerated="true" must be set in the application manifest.
+ * - The invoking activity must call VideoEnabledWebChromeClient's onBackPressed() inside of its own onBackPressed().
+ * - Tested in Android API levels 8-19. Only tested on http://m.youtube.com.
+ *
+ * @author Cristian Perez (http://cpr.name)
Review comment:
Are you Christian Perez? If not, do you have permission to submit this code under the Apache license?
If yes, then the Apache license needs to be added to this file.
##########
File path: src/android/InAppBrowser.java
##########
@@ -773,6 +778,38 @@ public void onClick(View v) {
return _close;
}
+ private void enableFullScreen(Activity activity, Window window) {
+ inFullScreen = true;
+ WindowManager.LayoutParams attrs = window.getAttributes();
+ attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
+ attrs.flags |= WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
+ window.setAttributes(attrs);
+ if (android.os.Build.VERSION.SDK_INT >= 14)
+ {
+ //noinspection all
+ int flags = View.SYSTEM_UI_FLAG_LOW_PROFILE;
+ if (android.os.Build.VERSION.SDK_INT >= 16)
+ {
+ flags = View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE;
+ }
+ window.getDecorView().setSystemUiVisibility(flags);
+ }
+
+ }
+
+ private void disableFullScreen(Activity activity, Window window) {
+ inFullScreen = false;
+ WindowManager.LayoutParams attrs = window.getAttributes();
+ attrs.flags &= ~WindowManager.LayoutParams.FLAG_FULLSCREEN;
+ attrs.flags &= ~WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
+ window.setAttributes(attrs);
+ if (android.os.Build.VERSION.SDK_INT >= 14)
Review comment:
See comment above
##########
File path: src/android/InAppBrowser.java
##########
@@ -132,8 +133,10 @@ Licensed to the Apache Software Foundation (ASF) under one
private boolean mediaPlaybackRequiresUserGesture = false;
private boolean shouldPauseInAppBrowser = false;
private boolean useWideViewPort = true;
- private ValueCallback<Uri[]> mUploadCallback;
+ private ValueCallback<Uri> mUploadCallback;
+ private ValueCallback<Uri[]> mUploadCallbackLollipop;
private final static int FILECHOOSER_REQUESTCODE = 1;
+ private final static int FILECHOOSER_REQUESTCODE_LOLLIPOP = 2;
Review comment:
Same thing here; see comment above.
##########
File path: src/android/InAppBrowser.java
##########
@@ -917,26 +971,73 @@ public boolean onKey(View v, int keyCode, KeyEvent event) {
inAppWebView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
inAppWebView.setId(Integer.valueOf(6));
// File Chooser Implemented ChromeClient
- inAppWebView.setWebChromeClient(new InAppChromeClient(thatWebView) {
+ InAppChromeClient inAppChromeClient = new InAppChromeClient(thatWebView, browserMain, fullScreenMain) {
+ // For Android 5.0+
public boolean onShowFileChooser (WebView webView, ValueCallback<Uri[]> filePathCallback, WebChromeClient.FileChooserParams fileChooserParams)
{
LOG.d(LOG_TAG, "File Chooser 5.0+");
// If callback exists, finish it.
- if(mUploadCallback != null) {
- mUploadCallback.onReceiveValue(null);
+ if(mUploadCallbackLollipop != null) {
+ mUploadCallbackLollipop.onReceiveValue(null);
}
- mUploadCallback = filePathCallback;
+ mUploadCallbackLollipop = filePathCallback;
// Create File Chooser Intent
Intent content = new Intent(Intent.ACTION_GET_CONTENT);
content.addCategory(Intent.CATEGORY_OPENABLE);
content.setType("*/*");
// Run cordova startActivityForResult
- cordova.startActivityForResult(InAppBrowser.this, Intent.createChooser(content, "Select File"), FILECHOOSER_REQUESTCODE);
+ cordova.startActivityForResult(InAppBrowser.this, Intent.createChooser(content, "Select File"), FILECHOOSER_REQUESTCODE_LOLLIPOP);
return true;
}
+
+ // For Android 4.1+
+ public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture)
Review comment:
We don't need to support android 4.x
##########
File path: src/android/InAppBrowser.java
##########
@@ -917,26 +971,73 @@ public boolean onKey(View v, int keyCode, KeyEvent event) {
inAppWebView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
inAppWebView.setId(Integer.valueOf(6));
// File Chooser Implemented ChromeClient
- inAppWebView.setWebChromeClient(new InAppChromeClient(thatWebView) {
+ InAppChromeClient inAppChromeClient = new InAppChromeClient(thatWebView, browserMain, fullScreenMain) {
+ // For Android 5.0+
public boolean onShowFileChooser (WebView webView, ValueCallback<Uri[]> filePathCallback, WebChromeClient.FileChooserParams fileChooserParams)
{
LOG.d(LOG_TAG, "File Chooser 5.0+");
// If callback exists, finish it.
- if(mUploadCallback != null) {
- mUploadCallback.onReceiveValue(null);
+ if(mUploadCallbackLollipop != null) {
+ mUploadCallbackLollipop.onReceiveValue(null);
}
- mUploadCallback = filePathCallback;
+ mUploadCallbackLollipop = filePathCallback;
// Create File Chooser Intent
Intent content = new Intent(Intent.ACTION_GET_CONTENT);
content.addCategory(Intent.CATEGORY_OPENABLE);
content.setType("*/*");
// Run cordova startActivityForResult
- cordova.startActivityForResult(InAppBrowser.this, Intent.createChooser(content, "Select File"), FILECHOOSER_REQUESTCODE);
+ cordova.startActivityForResult(InAppBrowser.this, Intent.createChooser(content, "Select File"), FILECHOOSER_REQUESTCODE_LOLLIPOP);
return true;
}
+
+ // For Android 4.1+
+ public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture)
+ {
+ LOG.d(LOG_TAG, "File Chooser 4.1+");
+ // Call file chooser for Android 3.0+
+ openFileChooser(uploadMsg, acceptType);
+ }
+
+ // For Android 3.0+
+ public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType)
Review comment:
We don't need to support android 3.x
##########
File path: src/android/InAppBrowser.java
##########
@@ -132,8 +133,10 @@ Licensed to the Apache Software Foundation (ASF) under one
private boolean mediaPlaybackRequiresUserGesture = false;
private boolean shouldPauseInAppBrowser = false;
private boolean useWideViewPort = true;
- private ValueCallback<Uri[]> mUploadCallback;
+ private ValueCallback<Uri> mUploadCallback;
+ private ValueCallback<Uri[]> mUploadCallbackLollipop;
Review comment:
Removing code that handles API < 21 should also eliminate the need to have two different class members to handle different API levels.
##########
File path: src/android/VideoEnabledWebView.java
##########
@@ -0,0 +1,139 @@
+package org.apache.cordova.inappbrowser;
+
+import android.annotation.SuppressLint;
+import android.content.Context;
+import android.os.Handler;
+import android.os.Looper;
+import android.util.AttributeSet;
+import android.util.Log;
+import android.webkit.WebChromeClient;
+import android.webkit.WebView;
+
+import java.util.Map;
+
+/**
+ * This class serves as a WebView to be used in conjunction with a VideoEnabledWebChromeClient.
+ * It makes possible:
+ * - To detect the HTML5 video ended event so that the VideoEnabledWebChromeClient can exit full-screen.
+ *
+ * Important notes:
+ * - Javascript is enabled by default and must not be disabled with getSettings().setJavaScriptEnabled(false).
+ * - setWebChromeClient() must be called before any loadData(), loadDataWithBaseURL() or loadUrl() method.
+ *
+ * @author Cristian Perez (http://cpr.name)
Review comment:
Same concern above regarding licensing.
##########
File path: src/android/InAppBrowser.java
##########
@@ -773,6 +778,38 @@ public void onClick(View v) {
return _close;
}
+ private void enableFullScreen(Activity activity, Window window) {
+ inFullScreen = true;
+ WindowManager.LayoutParams attrs = window.getAttributes();
+ attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
+ attrs.flags |= WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
+ window.setAttributes(attrs);
+ if (android.os.Build.VERSION.SDK_INT >= 14)
Review comment:
As of cordova-android@9, our [supported min SDK](https://github.com/apache/cordova-android/blob/0ce66249dafc916c5c2197d4c92cc51b555f777b/framework/cdv-gradle-config-defaults.json#L2) is 22.
We don't need to have defensive checks here, and can assume that the SDK will be at least 22.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org
[GitHub] [cordova-plugin-inappbrowser] breautek commented on pull request #892: Added fullscreen-video support
Posted by GitBox <gi...@apache.org>.
breautek commented on pull request #892:
URL: https://github.com/apache/cordova-plugin-inappbrowser/pull/892#issuecomment-883512942
> > Hi there,
> > First I'd like to thank you for your time in preparing this PR. I was able to give this a glance over and there's a few main things that I want to point out.
> >
> > 1. There are new classes added that needs to be licensed under the Apache license for Apache to accept the code. If you have permission from the original author to re-license the code under the [Apache License](https://www.apache.org/licenses/LICENSE-2.0), then the Apache license headers needs to be added. Otherwise we cannot accept the Pr unfortunately.
> > 2. This PR adds maintenance support for code going back as Android 3.0 (API 11). Cordova only supports API >= 22 and adding conditional logic to support anything less adds unnecessary complexity. I would like to see this simplified by removing any extra code required to support APIs < 22.
> >
> > Kind regards,
> > Norman
>
> Hey Norman,
> I would gladly update the code as you have requested. But it might take me some time. Hope you understand.
To hopefully save you some time, I think it would be best to analyse and see if you can fulfil the original requirements to solve https://github.com/apache/cordova-plugin-inappbrowser/issues/320 without using the code by Cristian Perez. The original code appears to be licensed under MIT, and while that may allow you to copy the code for your own use, all code submitted to Apache needs to be licensed under the Apache license. So either the code By Christian needs to be removed, or we need obtain written permission to be able to license that code under Apache. If this cannot be done, then we should close this PR.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org
[GitHub] [cordova-plugin-inappbrowser] The-White-Fang commented on a change in pull request #892: Added fullscreen-video support
Posted by GitBox <gi...@apache.org>.
The-White-Fang commented on a change in pull request #892:
URL: https://github.com/apache/cordova-plugin-inappbrowser/pull/892#discussion_r673245651
##########
File path: src/android/VideoEnabledWebChromeClient.java
##########
@@ -0,0 +1,294 @@
+package org.apache.cordova.inappbrowser;
+
+import android.media.MediaPlayer;
+import android.view.SurfaceView;
+import android.view.View;
+import android.view.ViewGroup;
+import android.webkit.WebChromeClient;
+import android.widget.FrameLayout;
+
+/**
+ * This class serves as a WebChromeClient to be set to a WebView, allowing it to play video.
+ * Video will play differently depending on target API level (in-line, fullscreen, or both).
+ *
+ * It has been tested with the following video classes:
+ * - android.widget.VideoView (typically API level <11)
+ * - android.webkit.HTML5VideoFullScreen$VideoSurfaceView/VideoTextureView (typically API level 11-18)
+ * - com.android.org.chromium.content.browser.ContentVideoView$VideoSurfaceView (typically API level 19+)
+ *
+ * Important notes:
+ * - For API level 11+, android:hardwareAccelerated="true" must be set in the application manifest.
+ * - The invoking activity must call VideoEnabledWebChromeClient's onBackPressed() inside of its own onBackPressed().
+ * - Tested in Android API levels 8-19. Only tested on http://m.youtube.com.
+ *
+ * @author Cristian Perez (http://cpr.name)
Review comment:
> This seems copy/pasted from https://github.com/cprcrack/VideoEnabledWebView
It actually is. I needed those changes in my current project so I forked the latest repo and modified it so, if anyone else wants to use it. They can.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org