Compare commits

..

10 Commits
4.1.x ... 5.0.x

Author SHA1 Message Date
Niklas Merz
10f2ad72a0 Updated version and RELEASENOTES.md for release 5.0.0 (cordova-plugin-inappbrowser-5.0.0) 2021-02-10 17:56:58 +01:00
Niklas Merz
6b920849cc feat(ios): add InAppBrowserStatusBarStyle 'darkcontent' configuration option (#828)
Co-authored-by: Tim Brust <github@timbrust.de>
2021-02-09 08:24:56 +01:00
jcesarmobile
07862603eb chore: bump engines requirements (#823)
* chore: bump engines requirements

* bump cordova-ios to >=6.0.0
2021-02-09 08:24:17 +01:00
jcesarmobile
b496e03169 breaking: cleanup code for old android versions (#824) 2021-01-20 17:43:28 +01:00
jcesarmobile
80720a0850 chore: bump version to 5.0.0-dev (#822) 2021-01-20 17:30:10 +01:00
Niklas Merz
de31942e6c (ios): rename CDVWKProcessPoolFactory (#825)
* (ios): rename CDVWKProcessPoolFactory

CDVWKProcessPoolFactory was integrated from the WKWebView plugin with
the new name: CDVWebViewProcessPoolFactory

* (ios): Allow both processpool imports
2021-01-07 19:21:57 +01:00
エリス
8bdbd18d16 ci: add node-14.x to workflow (#826) 2020-11-28 19:50:04 +09:00
jcesarmobile
11b1347812 breaking(android): replace magic numbers with android.os.Build constants (#821) 2020-11-24 15:49:09 +01:00
Niklas Merz
85acc2a12a ci(ios): remove wkwebview plugin (#717)
cordova-ios@6.x makes the WKWebView plugin obsolete.

Co-authored-by: Erisu <ellis.bryan@gmail.com>
2020-11-23 10:21:18 +01:00
Niklas Merz
02909a7f16 Incremented plugin version. (cordova-plugin-inappbrowser-4.1.0) 2020-11-17 19:22:20 +01:00
12 changed files with 71 additions and 138 deletions

View File

@@ -15,6 +15,7 @@ environment:
matrix:
- nodejs_version: "10"
- nodejs_version: "12"
- nodejs_version: "14"
platform:
- x86

View File

@@ -17,7 +17,7 @@ env:
- ANDROID_BUILD_TOOLS_VERSION=29.0.2
language: node_js
node_js: 12
node_js: 14
# yaml anchor/alias: https://medium.com/@tommyvn/travis-yml-dry-with-anchors-8b6a3ac1b027

View File

@@ -71,7 +71,7 @@ simply hook `window.open` during initialization. For example:
### Preferences
#### <b>config.xml</b>
- <b>InAppBrowserStatusBarStyle [iOS only]</b>: (string, options 'lightcontent' or 'default'. Defaults to 'default') set text color style for iOS.
- <b>InAppBrowserStatusBarStyle [iOS only]</b>: (string, options 'lightcontent', 'darkcontent' or 'default'. Defaults to 'default') set text color style for iOS. 'lightcontent' is intended for use on dark backgrounds. 'darkcontent' is only available since iOS 13 and intended for use on light backgrounds.
```
<preference name="InAppBrowserStatusBarStyle" value="lightcontent" />
```

View File

@@ -20,6 +20,15 @@
-->
# Release Notes
### 5.0.0 (Feb 10, 2021)
* [GH-828](https://github.com/apache/cordova-plugin-inappbrowser/pull/828) feat(ios): add `InAppBrowser`StatusBarStyle 'darkcontent' configuration option
* [GH-823](https://github.com/apache/cordova-plugin-inappbrowser/pull/823) chore: bump engines requirements
* [GH-824](https://github.com/apache/cordova-plugin-inappbrowser/pull/824) breaking: cleanup code for old **Android** versions
* [GH-825](https://github.com/apache/cordova-plugin-inappbrowser/pull/825) (ios): rename CDVWKProcessPoolFactory
* [GH-826](https://github.com/apache/cordova-plugin-inappbrowser/pull/826) ci: add node-14.x to workflow
* [GH-821](https://github.com/apache/cordova-plugin-inappbrowser/pull/821) breaking(android): replace magic numbers with **Android**.os.Build constants
* [GH-717](https://github.com/apache/cordova-plugin-inappbrowser/pull/717) ci(ios): remove wkwebview plugin
### 4.1.0 (Nov 17, 2020)
* [GH-792](https://github.com/apache/cordova-plugin-inappbrowser/pull/792) fix(android): Add mitigation strategy for CVE-2020-6506
* [GH-817](https://github.com/apache/cordova-plugin-inappbrowser/pull/817) Updated typings

2
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{
"name": "cordova-plugin-inappbrowser",
"version": "4.0.1-dev",
"version": "5.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@@ -1,6 +1,6 @@
{
"name": "cordova-plugin-inappbrowser",
"version": "4.1.0",
"version": "5.0.0",
"description": "Cordova InAppBrowser Plugin",
"types": "./types/index.d.ts",
"cordova": {
@@ -42,6 +42,11 @@
"cordova-ios": ">=4.0.0"
},
"5.0.0": {
"cordova-android": ">=9.0.0",
"cordova-ios": ">=6.0.0",
"cordova": ">=9.0.0"
},
"6.0.0": {
"cordova": ">100"
}
}

View File

@@ -20,7 +20,7 @@
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
id="cordova-plugin-inappbrowser"
version="4.1.0">
version="5.0.0">
<name>InAppBrowser</name>
<description>Cordova InAppBrowser Plugin</description>
@@ -30,8 +30,9 @@
<issue>https://github.com/apache/cordova-plugin-inappbrowser/issues</issue>
<engines>
<engine name="cordova" version=">=3.1.0" /><!-- Needs cordova/urlutil -->
<engine name="cordova-ios" version=">=4.0.0" />
<engine name="cordova" version=">=9.0.0"/>
<engine name="cordova-android" version=">=9.0.0" />
<engine name="cordova-ios" version=">=6.0.0" />
</engines>
<!-- android -->

View File

@@ -20,7 +20,6 @@ package org.apache.cordova.inappbrowser;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
@@ -30,8 +29,6 @@ import android.provider.Browser;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.Color;
import android.net.http.SslError;
import android.net.Uri;
@@ -48,7 +45,6 @@ import android.view.WindowManager.LayoutParams;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.webkit.CookieManager;
import android.webkit.CookieSyncManager;
import android.webkit.HttpAuthHandler;
import android.webkit.JavascriptInterface;
import android.webkit.SslErrorHandler;
@@ -136,10 +132,8 @@ public class InAppBrowser extends CordovaPlugin {
private boolean mediaPlaybackRequiresUserGesture = false;
private boolean shouldPauseInAppBrowser = false;
private boolean useWideViewPort = true;
private ValueCallback<Uri> mUploadCallback;
private ValueCallback<Uri[]> mUploadCallbackLollipop;
private ValueCallback<Uri[]> mUploadCallback;
private final static int FILECHOOSER_REQUESTCODE = 1;
private final static int FILECHOOSER_REQUESTCODE_LOLLIPOP = 2;
private String closeButtonCaption = "";
private String closeButtonColor = "";
private boolean leftToRight = false;
@@ -269,8 +263,12 @@ public class InAppBrowser extends CordovaPlugin {
@SuppressLint("NewApi")
@Override
public void run() {
currentClient.waitForBeforeload = false;
inAppWebView.setWebViewClient(currentClient);
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.O) {
currentClient.waitForBeforeload = false;
inAppWebView.setWebViewClient(currentClient);
} else {
((InAppBrowserClient)inAppWebView.getWebViewClient()).waitForBeforeload = false;
}
inAppWebView.loadUrl(url);
}
});
@@ -410,12 +408,7 @@ public class InAppBrowser extends CordovaPlugin {
@SuppressLint("NewApi")
@Override
public void run() {
if (Build.VERSION.SDK_INT < 19) {
// This action will have the side-effect of blurring the currently focused element
inAppWebView.loadUrl("javascript:" + finalScriptToInject);
} else {
inAppWebView.evaluateJavascript(finalScriptToInject, null);
}
inAppWebView.evaluateJavascript(finalScriptToInject, null);
}
});
} else {
@@ -758,8 +751,7 @@ public class InAppBrowser extends CordovaPlugin {
if (closeButtonColor != "") close.setColorFilter(android.graphics.Color.parseColor(closeButtonColor));
close.setImageDrawable(closeIcon);
close.setScaleType(ImageView.ScaleType.FIT_CENTER);
if (Build.VERSION.SDK_INT >= 16)
close.getAdjustViewBounds();
close.getAdjustViewBounds();
_close = close;
}
@@ -768,11 +760,7 @@ public class InAppBrowser extends CordovaPlugin {
if (leftToRight) closeLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
else closeLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
_close.setLayoutParams(closeLayoutParams);
if (Build.VERSION.SDK_INT >= 16)
_close.setBackground(null);
else
_close.setBackgroundDrawable(null);
_close.setBackground(null);
_close.setContentDescription("Close Button");
_close.setId(Integer.valueOf(id));
@@ -841,15 +829,11 @@ public class InAppBrowser extends CordovaPlugin {
int backResId = activityRes.getIdentifier("ic_action_previous_item", "drawable", cordova.getActivity().getPackageName());
Drawable backIcon = activityRes.getDrawable(backResId);
if (navigationButtonColor != "") back.setColorFilter(android.graphics.Color.parseColor(navigationButtonColor));
if (Build.VERSION.SDK_INT >= 16)
back.setBackground(null);
else
back.setBackgroundDrawable(null);
back.setBackground(null);
back.setImageDrawable(backIcon);
back.setScaleType(ImageView.ScaleType.FIT_CENTER);
back.setPadding(0, this.dpToPixels(10), 0, this.dpToPixels(10));
if (Build.VERSION.SDK_INT >= 16)
back.getAdjustViewBounds();
back.getAdjustViewBounds();
back.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
@@ -867,15 +851,11 @@ public class InAppBrowser extends CordovaPlugin {
int fwdResId = activityRes.getIdentifier("ic_action_next_item", "drawable", cordova.getActivity().getPackageName());
Drawable fwdIcon = activityRes.getDrawable(fwdResId);
if (navigationButtonColor != "") forward.setColorFilter(android.graphics.Color.parseColor(navigationButtonColor));
if (Build.VERSION.SDK_INT >= 16)
forward.setBackground(null);
else
forward.setBackgroundDrawable(null);
forward.setBackground(null);
forward.setImageDrawable(fwdIcon);
forward.setScaleType(ImageView.ScaleType.FIT_CENTER);
forward.setPadding(0, this.dpToPixels(10), 0, this.dpToPixels(10));
if (Build.VERSION.SDK_INT >= 16)
forward.getAdjustViewBounds();
forward.getAdjustViewBounds();
forward.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
@@ -938,15 +918,14 @@ public class InAppBrowser extends CordovaPlugin {
inAppWebView.setId(Integer.valueOf(6));
// File Chooser Implemented ChromeClient
inAppWebView.setWebChromeClient(new InAppChromeClient(thatWebView) {
// 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(mUploadCallbackLollipop != null) {
mUploadCallbackLollipop.onReceiveValue(null);
if(mUploadCallback != null) {
mUploadCallback.onReceiveValue(null);
}
mUploadCallbackLollipop = filePathCallback;
mUploadCallback = filePathCallback;
// Create File Chooser Intent
Intent content = new Intent(Intent.ACTION_GET_CONTENT);
@@ -954,30 +933,9 @@ public class InAppBrowser extends CordovaPlugin {
content.setType("*/*");
// Run cordova startActivityForResult
cordova.startActivityForResult(InAppBrowser.this, Intent.createChooser(content, "Select File"), FILECHOOSER_REQUESTCODE_LOLLIPOP);
cordova.startActivityForResult(InAppBrowser.this, Intent.createChooser(content, "Select File"), FILECHOOSER_REQUESTCODE);
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)
{
LOG.d(LOG_TAG, "File Chooser 3.0+");
mUploadCallback = uploadMsg;
Intent content = new Intent(Intent.ACTION_GET_CONTENT);
content.addCategory(Intent.CATEGORY_OPENABLE);
// run startActivityForResult
cordova.startActivityForResult(InAppBrowser.this, Intent.createChooser(content, "Select File"), FILECHOOSER_REQUESTCODE);
}
});
currentClient = new InAppBrowserClient(thatWebView, edittext, beforeload);
inAppWebView.setWebViewClient(currentClient);
@@ -1002,10 +960,8 @@ public class InAppBrowser extends CordovaPlugin {
}
}
if(android.os.Build.VERSION.SDK_INT >= 17) {
settings.setMediaPlaybackRequiresUserGesture(mediaPlaybackRequiresUserGesture);
inAppWebView.addJavascriptInterface(new JsObject(), "cordova_iab");
}
settings.setMediaPlaybackRequiresUserGesture(mediaPlaybackRequiresUserGesture);
inAppWebView.addJavascriptInterface(new JsObject(), "cordova_iab");
String overrideUserAgent = preferences.getString("OverrideUserAgent", null);
String appendUserAgent = preferences.getString("AppendUserAgent", null);
@@ -1033,10 +989,8 @@ public class InAppBrowser extends CordovaPlugin {
CookieManager.getInstance().removeSessionCookie();
}
// Enable Thirdparty Cookies on >=Android 5.0 device
if (android.os.Build.VERSION.SDK_INT >= 21) {
CookieManager.getInstance().setAcceptThirdPartyCookies(inAppWebView,true);
}
// Enable Thirdparty Cookies
CookieManager.getInstance().setAcceptThirdPartyCookies(inAppWebView,true);
inAppWebView.loadUrl(url);
inAppWebView.setId(Integer.valueOf(6));
@@ -1127,32 +1081,14 @@ public class InAppBrowser extends CordovaPlugin {
* @param intent the data from android file chooser
*/
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
// For Android >= 5.0
if(Build.VERSION.SDK_INT >= 21) {
LOG.d(LOG_TAG, "onActivityResult (For Android >= 5.0)");
// If RequestCode or Callback is Invalid
if(requestCode != FILECHOOSER_REQUESTCODE_LOLLIPOP || mUploadCallbackLollipop == null) {
super.onActivityResult(requestCode, resultCode, intent);
return;
}
mUploadCallbackLollipop.onReceiveValue(WebChromeClient.FileChooserParams.parseResult(resultCode, intent));
mUploadCallbackLollipop = null;
}
// For Android < 5.0
else {
LOG.d(LOG_TAG, "onActivityResult (For Android < 5.0)");
// If RequestCode or Callback is Invalid
if(requestCode != FILECHOOSER_REQUESTCODE || mUploadCallback == null) {
super.onActivityResult(requestCode, resultCode, intent);
return;
}
if (null == mUploadCallback) return;
Uri result = intent == null || resultCode != cordova.getActivity().RESULT_OK ? null : intent.getData();
mUploadCallback.onReceiveValue(result);
mUploadCallback = null;
LOG.d(LOG_TAG, "onActivityResult");
// If RequestCode or Callback is Invalid
if(requestCode != FILECHOOSER_REQUESTCODE || mUploadCallback == null) {
super.onActivityResult(requestCode, resultCode, intent);
return;
}
mUploadCallback.onReceiveValue(WebChromeClient.FileChooserParams.parseResult(resultCode, intent));
mUploadCallback = null;
}
/**
@@ -1201,7 +1137,7 @@ public class InAppBrowser extends CordovaPlugin {
* @param webView
* @param request
*/
@TargetApi(24)
@TargetApi(Build.VERSION_CODES.N)
@Override
public boolean shouldOverrideUrlLoading(WebView webView, WebResourceRequest request) {
return shouldOverrideUrlLoading(request.getUrl().toString(), request.getMethod());
@@ -1352,28 +1288,13 @@ public class InAppBrowser extends CordovaPlugin {
return false;
}
/**
* Legacy (deprecated in API 21)
* For Android 4.4 and below.
* @param view
* @param url
* @return
*/
@SuppressWarnings("deprecation")
@Override
public WebResourceResponse shouldInterceptRequest (final WebView view, String url) {
return shouldInterceptRequest(url, super.shouldInterceptRequest(view, url), null);
}
/**
* New (added in API 21)
* For Android 5.0 and above.
*
* @param webView
* @param view
* @param request
*/
@TargetApi(21)
@Override
public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) {
return shouldInterceptRequest(request.getUrl().toString(), super.shouldInterceptRequest(view, request), request.getMethod());
@@ -1424,16 +1345,10 @@ public class InAppBrowser extends CordovaPlugin {
super.onPageFinished(view, url);
// Set the namespace for postMessage()
if (Build.VERSION.SDK_INT >= 17) {
injectDeferredObject("window.webkit={messageHandlers:{cordova_iab:cordova_iab}}", null);
}
injectDeferredObject("window.webkit={messageHandlers:{cordova_iab:cordova_iab}}", null);
// CB-10395 InAppBrowser's WebView not storing cookies reliable to local device storage
if (android.os.Build.VERSION.SDK_INT >= 21) {
CookieManager.getInstance().flush();
} else {
CookieSyncManager.getInstance().sync();
}
CookieManager.getInstance().flush();
// https://issues.apache.org/jira/browse/CB-11248
view.clearFocus();

View File

@@ -157,7 +157,6 @@ public class InAppChromeClient extends WebChromeClient {
WebView inAppWebView = view;
final WebViewClient webViewClient =
new WebViewClient() {
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
inAppWebView.loadUrl(request.getUrl().toString());

View File

@@ -19,8 +19,10 @@
#import "CDVWKInAppBrowser.h"
#if __has_include("CDVWKProcessPoolFactory.h")
#import "CDVWKProcessPoolFactory.h"
#if __has_include(<Cordova/CDVWebViewProcessPoolFactory.h>) // Cordova-iOS >=6
#import <Cordova/CDVWebViewProcessPoolFactory.h>
#elif __has_include("CDVWKProcessPoolFactory.h") // Cordova-iOS <6 with WKWebView plugin
#import "CDVWKProcessPoolFactory.h"
#endif
#import <Cordova/CDVPluginResult.h>
@@ -739,7 +741,9 @@ BOOL isExiting = FALSE;
}
configuration.applicationNameForUserAgent = userAgent;
configuration.userContentController = userContentController;
#if __has_include("CDVWKProcessPoolFactory.h")
#if __has_include(<Cordova/CDVWebViewProcessPoolFactory.h>)
configuration.processPool = [[CDVWebViewProcessPoolFactory sharedFactory] sharedProcessPool];
#elif __has_include("CDVWKProcessPoolFactory.h")
configuration.processPool = [[CDVWKProcessPoolFactory sharedFactory] sharedProcessPool];
#endif
[configuration.userContentController addScriptMessageHandler:self name:IAB_BRIDGE_NAME];
@@ -1067,6 +1071,12 @@ BOOL isExiting = FALSE;
NSString* statusBarStylePreference = [self settingForKey:@"InAppBrowserStatusBarStyle"];
if (statusBarStylePreference && [statusBarStylePreference isEqualToString:@"lightcontent"]) {
return UIStatusBarStyleLightContent;
} else if (statusBarStylePreference && [statusBarStylePreference isEqualToString:@"darkcontent"]) {
if (@available(iOS 13.0, *)) {
return UIStatusBarStyleDarkContent;
} else {
return UIStatusBarStyleDefault;
}
} else {
return UIStatusBarStyleDefault;
}

View File

@@ -1,6 +1,6 @@
{
"name": "cordova-plugin-inappbrowser-tests",
"version": "4.1.0",
"version": "5.0.0",
"description": "",
"cordova": {
"id": "cordova-plugin-inappbrowser-tests",

View File

@@ -20,7 +20,7 @@
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
id="cordova-plugin-inappbrowser-tests"
version="4.1.0">
version="5.0.0">
<name>Cordova InAppBrowser Plugin Tests</name>
<license>Apache 2.0</license>
@@ -29,12 +29,5 @@
<js-module src="tests.js" name="tests">
</js-module>
<platform name="ios">
<!-- The WKWebView implementation for inappbrowser requires the presence of this plugin -->
<dependency id="cordova-plugin-wkwebview-engine" />
<dependency id="cordova-plugin-wkwebview-engine-allowfileaccess" url="https://github.com/knight9999/cordova-plugin-wkwebview-engine-allowfileaccess.git" />
</platform>
<asset src="resources" target="cdvtests/iab-resources" />
</plugin>