Skip to content

Commit 33a5938

Browse files
authored
Merge pull request #2 from hogangnono/feature/HGNN-402
5.0.0 version rebase
2 parents 7c1366e + 7dc3db3 commit 33a5938

12 files changed

+71
-139
lines changed

.appveyor.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ environment:
1515
matrix:
1616
- nodejs_version: "10"
1717
- nodejs_version: "12"
18+
- nodejs_version: "14"
1819

1920
platform:
2021
- x86

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ env:
1717
- ANDROID_BUILD_TOOLS_VERSION=29.0.2
1818

1919
language: node_js
20-
node_js: 12
20+
node_js: 14
2121

2222
# yaml anchor/alias: https://medium.com/@tommyvn/travis-yml-dry-with-anchors-8b6a3ac1b027
2323

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ simply hook `window.open` during initialization. For example:
7171
### Preferences
7272

7373
#### <b>config.xml</b>
74-
- <b>InAppBrowserStatusBarStyle [iOS only]</b>: (string, options 'lightcontent' or 'default'. Defaults to 'default') set text color style for iOS.
74+
- <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.
7575
```
7676
<preference name="InAppBrowserStatusBarStyle" value="lightcontent" />
7777
```

RELEASENOTES.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@
2020
-->
2121
# Release Notes
2222

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

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cordova-plugin-inappbrowser",
3-
"version": "4.1.1-hogangnono",
3+
"version": "5.0.1-hogangnono",
44
"description": "Cordova InAppBrowser Plugin",
55
"types": "./types/index.d.ts",
66
"cordova": {
@@ -42,6 +42,11 @@
4242
"cordova-ios": ">=4.0.0"
4343
},
4444
"5.0.0": {
45+
"cordova-android": ">=9.0.0",
46+
"cordova-ios": ">=6.0.0",
47+
"cordova": ">=9.0.0"
48+
},
49+
"6.0.0": {
4550
"cordova": ">100"
4651
}
4752
}

plugin.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
2222
id="cordova-plugin-inappbrowser"
23-
version="4.1.1-hogangnono">
23+
version="5.0.1-hogangnono">
2424

2525
<name>InAppBrowser</name>
2626
<description>Cordova InAppBrowser Plugin</description>
@@ -30,8 +30,9 @@
3030
<issue>https://github.com/apache/cordova-plugin-inappbrowser/issues</issue>
3131

3232
<engines>
33-
<engine name="cordova" version=">=3.1.0" /><!-- Needs cordova/urlutil -->
34-
<engine name="cordova-ios" version=">=4.0.0" />
33+
<engine name="cordova" version=">=9.0.0"/>
34+
<engine name="cordova-android" version=">=9.0.0" />
35+
<engine name="cordova-ios" version=">=6.0.0" />
3536
</engines>
3637

3738
<!-- android -->

src/android/InAppBrowser.java

Lines changed: 33 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ Licensed to the Apache Software Foundation (ASF) under one
2020

2121
import android.annotation.SuppressLint;
2222
import android.annotation.TargetApi;
23-
import android.content.ActivityNotFoundException;
24-
import android.content.ComponentName;
2523
import android.content.Context;
2624
import android.content.Intent;
2725
import android.content.pm.PackageManager;
@@ -31,8 +29,6 @@ Licensed to the Apache Software Foundation (ASF) under one
3129
import android.content.res.Resources;
3230
import android.graphics.Bitmap;
3331
import android.graphics.drawable.Drawable;
34-
import android.graphics.PorterDuff;
35-
import android.graphics.PorterDuffColorFilter;
3632
import android.graphics.Color;
3733
import android.net.http.SslError;
3834
import android.net.Uri;
@@ -49,7 +45,6 @@ Licensed to the Apache Software Foundation (ASF) under one
4945
import android.view.inputmethod.EditorInfo;
5046
import android.view.inputmethod.InputMethodManager;
5147
import android.webkit.CookieManager;
52-
import android.webkit.CookieSyncManager;
5348
import android.webkit.HttpAuthHandler;
5449
import android.webkit.JavascriptInterface;
5550
import android.webkit.SslErrorHandler;
@@ -142,10 +137,8 @@ public class InAppBrowser extends CordovaPlugin {
142137
private boolean mediaPlaybackRequiresUserGesture = false;
143138
private boolean shouldPauseInAppBrowser = false;
144139
private boolean useWideViewPort = true;
145-
private ValueCallback<Uri> mUploadCallback;
146-
private ValueCallback<Uri[]> mUploadCallbackLollipop;
140+
private ValueCallback<Uri[]> mUploadCallback;
147141
private final static int FILECHOOSER_REQUESTCODE = 1;
148-
private final static int FILECHOOSER_REQUESTCODE_LOLLIPOP = 2;
149142
private String closeButtonCaption = "";
150143
private String closeButtonColor = "";
151144
private boolean leftToRight = false;
@@ -275,8 +268,12 @@ else if (action.equals("loadAfterBeforeload")) {
275268
@SuppressLint("NewApi")
276269
@Override
277270
public void run() {
278-
currentClient.waitForBeforeload = false;
279-
inAppWebView.setWebViewClient(currentClient);
271+
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.O) {
272+
currentClient.waitForBeforeload = false;
273+
inAppWebView.setWebViewClient(currentClient);
274+
} else {
275+
((InAppBrowserClient)inAppWebView.getWebViewClient()).waitForBeforeload = false;
276+
}
280277
inAppWebView.loadUrl(url);
281278
}
282279
});
@@ -416,12 +413,7 @@ private void injectDeferredObject(String source, String jsWrapper) {
416413
@SuppressLint("NewApi")
417414
@Override
418415
public void run() {
419-
if (Build.VERSION.SDK_INT < 19) {
420-
// This action will have the side-effect of blurring the currently focused element
421-
inAppWebView.loadUrl("javascript:" + finalScriptToInject);
422-
} else {
423-
inAppWebView.evaluateJavascript(finalScriptToInject, null);
424-
}
416+
inAppWebView.evaluateJavascript(finalScriptToInject, null);
425417
}
426418
});
427419
} else {
@@ -764,8 +756,7 @@ private View createCloseButton(int id) {
764756
if (closeButtonColor != "") close.setColorFilter(android.graphics.Color.parseColor(closeButtonColor));
765757
close.setImageDrawable(closeIcon);
766758
close.setScaleType(ImageView.ScaleType.FIT_CENTER);
767-
if (Build.VERSION.SDK_INT >= 16)
768-
close.getAdjustViewBounds();
759+
close.getAdjustViewBounds();
769760

770761
_close = close;
771762
}
@@ -774,11 +765,7 @@ private View createCloseButton(int id) {
774765
if (leftToRight) closeLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
775766
else closeLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
776767
_close.setLayoutParams(closeLayoutParams);
777-
778-
if (Build.VERSION.SDK_INT >= 16)
779-
_close.setBackground(null);
780-
else
781-
_close.setBackgroundDrawable(null);
768+
_close.setBackground(null);
782769

783770
_close.setContentDescription("Close Button");
784771
_close.setId(Integer.valueOf(id));
@@ -868,15 +855,11 @@ public void run() {
868855
int backResId = activityRes.getIdentifier("ic_action_previous_item", "drawable", cordova.getActivity().getPackageName());
869856
Drawable backIcon = activityRes.getDrawable(backResId);
870857
if (navigationButtonColor != "") back.setColorFilter(android.graphics.Color.parseColor(navigationButtonColor));
871-
if (Build.VERSION.SDK_INT >= 16)
872-
back.setBackground(null);
873-
else
874-
back.setBackgroundDrawable(null);
858+
back.setBackground(null);
875859
back.setImageDrawable(backIcon);
876860
back.setScaleType(ImageView.ScaleType.FIT_CENTER);
877861
back.setPadding(0, this.dpToPixels(10), 0, this.dpToPixels(10));
878-
if (Build.VERSION.SDK_INT >= 16)
879-
back.getAdjustViewBounds();
862+
back.getAdjustViewBounds();
880863

881864
back.setOnClickListener(new View.OnClickListener() {
882865
public void onClick(View v) {
@@ -894,15 +877,11 @@ public void onClick(View v) {
894877
int fwdResId = activityRes.getIdentifier("ic_action_next_item", "drawable", cordova.getActivity().getPackageName());
895878
Drawable fwdIcon = activityRes.getDrawable(fwdResId);
896879
if (navigationButtonColor != "") forward.setColorFilter(android.graphics.Color.parseColor(navigationButtonColor));
897-
if (Build.VERSION.SDK_INT >= 16)
898-
forward.setBackground(null);
899-
else
900-
forward.setBackgroundDrawable(null);
880+
forward.setBackground(null);
901881
forward.setImageDrawable(fwdIcon);
902882
forward.setScaleType(ImageView.ScaleType.FIT_CENTER);
903883
forward.setPadding(0, this.dpToPixels(10), 0, this.dpToPixels(10));
904-
if (Build.VERSION.SDK_INT >= 16)
905-
forward.getAdjustViewBounds();
884+
forward.getAdjustViewBounds();
906885

907886
forward.setOnClickListener(new View.OnClickListener() {
908887
public void onClick(View v) {
@@ -1019,46 +998,24 @@ public void onClick(View v) {
1019998
inAppWebView.setId(Integer.valueOf(6));
1020999
// File Chooser Implemented ChromeClient
10211000
inAppWebView.setWebChromeClient(new InAppChromeClient(thatWebView) {
1022-
// For Android 5.0+
10231001
public boolean onShowFileChooser (WebView webView, ValueCallback<Uri[]> filePathCallback, WebChromeClient.FileChooserParams fileChooserParams)
10241002
{
10251003
LOG.d(LOG_TAG, "File Chooser 5.0+");
10261004
// If callback exists, finish it.
1027-
if(mUploadCallbackLollipop != null) {
1028-
mUploadCallbackLollipop.onReceiveValue(null);
1005+
if(mUploadCallback != null) {
1006+
mUploadCallback.onReceiveValue(null);
10291007
}
1030-
mUploadCallbackLollipop = filePathCallback;
1008+
mUploadCallback = filePathCallback;
10311009

10321010
// Create File Chooser Intent
10331011
Intent content = new Intent(Intent.ACTION_GET_CONTENT);
10341012
content.addCategory(Intent.CATEGORY_OPENABLE);
10351013
content.setType("*/*");
10361014

10371015
// Run cordova startActivityForResult
1038-
cordova.startActivityForResult(InAppBrowser.this, Intent.createChooser(content, "Select File"), FILECHOOSER_REQUESTCODE_LOLLIPOP);
1039-
return true;
1040-
}
1041-
1042-
// For Android 4.1+
1043-
public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture)
1044-
{
1045-
LOG.d(LOG_TAG, "File Chooser 4.1+");
1046-
// Call file chooser for Android 3.0+
1047-
openFileChooser(uploadMsg, acceptType);
1048-
}
1049-
1050-
// For Android 3.0+
1051-
public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType)
1052-
{
1053-
LOG.d(LOG_TAG, "File Chooser 3.0+");
1054-
mUploadCallback = uploadMsg;
1055-
Intent content = new Intent(Intent.ACTION_GET_CONTENT);
1056-
content.addCategory(Intent.CATEGORY_OPENABLE);
1057-
1058-
// run startActivityForResult
10591016
cordova.startActivityForResult(InAppBrowser.this, Intent.createChooser(content, "Select File"), FILECHOOSER_REQUESTCODE);
1017+
return true;
10601018
}
1061-
10621019
});
10631020
currentClient = new InAppBrowserClient(thatWebView, edittext, beforeload);
10641021
inAppWebView.setWebViewClient(currentClient);
@@ -1083,10 +1040,8 @@ public void postMessage(String data) {
10831040
}
10841041
}
10851042

1086-
if(android.os.Build.VERSION.SDK_INT >= 17) {
1087-
settings.setMediaPlaybackRequiresUserGesture(mediaPlaybackRequiresUserGesture);
1088-
inAppWebView.addJavascriptInterface(new JsObject(), "cordova_iab");
1089-
}
1043+
settings.setMediaPlaybackRequiresUserGesture(mediaPlaybackRequiresUserGesture);
1044+
inAppWebView.addJavascriptInterface(new JsObject(), "cordova_iab");
10901045

10911046
String overrideUserAgent = preferences.getString("OverrideUserAgent", null);
10921047
String appendUserAgent = preferences.getString("AppendUserAgent", null);
@@ -1114,10 +1069,8 @@ public void postMessage(String data) {
11141069
CookieManager.getInstance().removeSessionCookie();
11151070
}
11161071

1117-
// Enable Thirdparty Cookies on >=Android 5.0 device
1118-
if (android.os.Build.VERSION.SDK_INT >= 21) {
1119-
CookieManager.getInstance().setAcceptThirdPartyCookies(inAppWebView,true);
1120-
}
1072+
// Enable Thirdparty Cookies
1073+
CookieManager.getInstance().setAcceptThirdPartyCookies(inAppWebView,true);
11211074

11221075
inAppWebView.loadUrl(url);
11231076
inAppWebView.setId(Integer.valueOf(6));
@@ -1209,32 +1162,14 @@ private void sendUpdate(JSONObject obj, boolean keepCallback, PluginResult.Statu
12091162
* @param intent the data from android file chooser
12101163
*/
12111164
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
1212-
// For Android >= 5.0
1213-
if(Build.VERSION.SDK_INT >= 21) {
1214-
LOG.d(LOG_TAG, "onActivityResult (For Android >= 5.0)");
1215-
// If RequestCode or Callback is Invalid
1216-
if(requestCode != FILECHOOSER_REQUESTCODE_LOLLIPOP || mUploadCallbackLollipop == null) {
1217-
super.onActivityResult(requestCode, resultCode, intent);
1218-
return;
1219-
}
1220-
mUploadCallbackLollipop.onReceiveValue(WebChromeClient.FileChooserParams.parseResult(resultCode, intent));
1221-
mUploadCallbackLollipop = null;
1222-
}
1223-
// For Android < 5.0
1224-
else {
1225-
LOG.d(LOG_TAG, "onActivityResult (For Android < 5.0)");
1226-
// If RequestCode or Callback is Invalid
1227-
if(requestCode != FILECHOOSER_REQUESTCODE || mUploadCallback == null) {
1228-
super.onActivityResult(requestCode, resultCode, intent);
1229-
return;
1230-
}
1231-
1232-
if (null == mUploadCallback) return;
1233-
Uri result = intent == null || resultCode != cordova.getActivity().RESULT_OK ? null : intent.getData();
1234-
1235-
mUploadCallback.onReceiveValue(result);
1236-
mUploadCallback = null;
1165+
LOG.d(LOG_TAG, "onActivityResult");
1166+
// If RequestCode or Callback is Invalid
1167+
if(requestCode != FILECHOOSER_REQUESTCODE || mUploadCallback == null) {
1168+
super.onActivityResult(requestCode, resultCode, intent);
1169+
return;
12371170
}
1171+
mUploadCallback.onReceiveValue(WebChromeClient.FileChooserParams.parseResult(resultCode, intent));
1172+
mUploadCallback = null;
12381173
}
12391174

12401175
/**
@@ -1283,7 +1218,7 @@ public boolean shouldOverrideUrlLoading(WebView webView, String url) {
12831218
* @param webView
12841219
* @param request
12851220
*/
1286-
@TargetApi(24)
1221+
@TargetApi(Build.VERSION_CODES.N)
12871222
@Override
12881223
public boolean shouldOverrideUrlLoading(WebView webView, WebResourceRequest request) {
12891224
return shouldOverrideUrlLoading(request.getUrl().toString(), request.getMethod());
@@ -1467,28 +1402,13 @@ private boolean sendBeforeLoad(String url, String method) {
14671402
return false;
14681403
}
14691404

1470-
1471-
/**
1472-
* Legacy (deprecated in API 21)
1473-
* For Android 4.4 and below.
1474-
* @param view
1475-
* @param url
1476-
* @return
1477-
*/
1478-
@SuppressWarnings("deprecation")
1479-
@Override
1480-
public WebResourceResponse shouldInterceptRequest (final WebView view, String url) {
1481-
return shouldInterceptRequest(url, super.shouldInterceptRequest(view, url), null);
1482-
}
1483-
14841405
/**
14851406
* New (added in API 21)
14861407
* For Android 5.0 and above.
14871408
*
1488-
* @param webView
1409+
* @param view
14891410
* @param request
14901411
*/
1491-
@TargetApi(21)
14921412
@Override
14931413
public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) {
14941414
return shouldInterceptRequest(request.getUrl().toString(), super.shouldInterceptRequest(view, request), request.getMethod());
@@ -1539,16 +1459,10 @@ public void onPageFinished(WebView view, String url) {
15391459
super.onPageFinished(view, url);
15401460

15411461
// Set the namespace for postMessage()
1542-
if (Build.VERSION.SDK_INT >= 17) {
1543-
injectDeferredObject("window.webkit={messageHandlers:{cordova_iab:cordova_iab}}", null);
1544-
}
1462+
injectDeferredObject("window.webkit={messageHandlers:{cordova_iab:cordova_iab}}", null);
15451463

15461464
// CB-10395 InAppBrowser's WebView not storing cookies reliable to local device storage
1547-
if (android.os.Build.VERSION.SDK_INT >= 21) {
1548-
CookieManager.getInstance().flush();
1549-
} else {
1550-
CookieSyncManager.getInstance().sync();
1551-
}
1465+
CookieManager.getInstance().flush();
15521466

15531467
// https://issues.apache.org/jira/browse/CB-11248
15541468
view.clearFocus();

src/android/InAppChromeClient.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ public boolean onCreateWindow(WebView view, boolean isDialog, boolean isUserGest
157157
WebView inAppWebView = view;
158158
final WebViewClient webViewClient =
159159
new WebViewClient() {
160-
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
161160
@Override
162161
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
163162
inAppWebView.loadUrl(request.getUrl().toString());

0 commit comments

Comments
 (0)