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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]