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

Added fullscreen-video support #892

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

The-White-Fang
Copy link

Platforms affected

Android

Motivation and Context

Adds full-screen video view support

Issue 320

Description

Updated InAppBrowser.java and InAppChromeClient.java
Added VideoEnabledWebChromeClient.java and VideoEnabledWebView.java
Code used to implement came from here which was originally derived from this.

Testing

Tested on Andoird 10 & Andoird 11

Checklist

  • 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))
  • 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)
  • I've updated the documentation if necessary

Copy link
Contributor

@breautek breautek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, 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

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The deletion of these lines will probably cause problems with our release process where it checks for proper license headers. Please revert these deletions

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As of cordova-android@9, our supported min SDK is 22.

We don't need to have defensive checks here, and can assume that the SDK will be at least 22.

{
//noinspection all
int flags = View.SYSTEM_UI_FLAG_LOW_PROFILE;
if (android.os.Build.VERSION.SDK_INT >= 16)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same situation above.

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment above

}

// For Android 3.0+
public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to support android 3.x

return true;
}

// For Android 4.1+
public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to support android 4.x

* - 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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

* - 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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same concern above regarding licensing.

@@ -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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing code that handles API < 21 should also eliminate the need to have two different class members to handle different API levels.

private final static int FILECHOOSER_REQUESTCODE = 1;
private final static int FILECHOOSER_REQUESTCODE_LOLLIPOP = 2;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing here; see comment above.

@The-White-Fang
Copy link
Author

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, 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.

@breautek
Copy link
Contributor

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, 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 #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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants