Skip to content

Commit

Permalink
merge upstream master(original repo) into this
Browse files Browse the repository at this point in the history
  • Loading branch information
Andythurlow committed Mar 12, 2020
2 parents e503da5 + 6c55e61 commit 4db0b9c
Show file tree
Hide file tree
Showing 15 changed files with 70 additions and 405 deletions.
11 changes: 4 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,26 +131,23 @@ instance, or the system browser.

iOS supports these additional options:

- __usewkwebview__: set to `yes` to use WKWebView engine for the InappBrowser. Omit or set to `no` (default) to use UIWebView. Note: Using `usewkwebview=yes` requires that a WKWebView engine plugin be installed in the Cordova project (e.g. [cordova-plugin-wkwebview-engine](https://github.com/apache/cordova-plugin-wkwebview-engine) or [cordova-plugin-ionic-webview](https://github.com/ionic-team/cordova-plugin-ionic-webview)).
- __hidden__: set to `yes` to create the browser and load the page, but not show it. The loadstop event fires when loading is complete. Omit or set to `no` (default) to have the browser open and load normally.
- __beforeload__: set to enable the `beforeload` event to modify which pages are actually loaded in the browser. Accepted values are `get` to intercept only GET requests, `post` to intercept on POST requests or `yes` to intercept both GET & POST requests. Note that POST requests are not currently supported and will be ignored (if you set `beforeload=post` it will raise an error).
- __clearcache__: set to `yes` to have the browser's cookie cache cleared before the new window is opened
- __clearsessioncache__: set to `yes` to have the session cookie cache cleared before the new window is opened. For WKWebView, requires iOS 11+ on target device.
- __cleardata__: set to `yes` to have the browser's entire local storage cleared (cookies, HTML5 local storage, IndexedDB, etc.) before the new window is opened
- __closebuttoncolor__: set as a valid hex color string, for example: `#00ff00`, to change from the default __Done__ button's color. Only applicable if toolbar is not disabled.
- __closebuttoncaption__: set to a string to use as the __Done__ button's caption. Note that you need to localize this value yourself.
- __disallowoverscroll__: Set to `yes` or `no` (default is `no`). Turns on/off the UIWebViewBounce property.
- __disallowoverscroll__: Set to `yes` or `no` (default is `no`). Turns on/off the the bounce of the WKWebView's UIScrollView.
- __hidenavigationbuttons__: set to `yes` or `no` to turn the toolbar navigation buttons on or off (defaults to `no`). Only applicable if toolbar is not disabled.
- __navigationbuttoncolor__: set as a valid hex color string, for example: `#00ff00`, to change from the default color. Only applicable if navigation buttons are visible.
- __toolbar__: set to `yes` or `no` to turn the toolbar on or off for the InAppBrowser (defaults to `yes`)
- __toolbarcolor__: set as a valid hex color string, for example: `#00ff00`, to change from the default color of the toolbar. Only applicable if toolbar is not disabled.
- __toolbartranslucent__: set to `yes` or `no` to make the toolbar translucent(semi-transparent) (defaults to `yes`). Only applicable if toolbar is not disabled.
- __lefttoright__: Set to `yes` to swap positions of the navigation buttons and the close button. Specifically, close button goes to the right and navigation buttons to the left.
- __enableViewportScale__: Set to `yes` or `no` to prevent viewport scaling through a meta tag (defaults to `no`). Only applicable to UIWebView (`usewkwebview=no`) and WKWebView (`usewkwebview=yes`) on iOS 10+.
- __mediaPlaybackRequiresUserAction__: Set to `yes` to prevent HTML5 audio or video from autoplaying (defaults to `no`). Applicable to UIWebView (`usewkwebview=no`) and WKWebView (`usewkwebview=yes`).
- __allowInlineMediaPlayback__: Set to `yes` or `no` to allow in-line HTML5 media playback, displaying within the browser window rather than a device-specific playback interface. The HTML's `video` element must also include the `webkit-playsinline` attribute (defaults to `no`). Applicable to UIWebView (`usewkwebview=no`) and WKWebView (`usewkwebview=yes`).
- __keyboardDisplayRequiresUserAction__: Set to `yes` or `no` to open the keyboard when form elements receive focus via JavaScript's `focus()` call (defaults to `yes`). Only applicable to UIWebView (`usewkwebview=no`).
- __suppressesIncrementalRendering__: Set to `yes` or `no` to wait until all new view content is received before being rendered (defaults to `no`). Only applicable to UIWebView (`usewkwebview=no`).
- __enableViewportScale__: Set to `yes` or `no` to prevent viewport scaling through a meta tag (defaults to `no`).
- __mediaPlaybackRequiresUserAction__: Set to `yes` to prevent HTML5 audio or video from autoplaying (defaults to `no`).
- __allowInlineMediaPlayback__: Set to `yes` or `no` to allow in-line HTML5 media playback, displaying within the browser window rather than a device-specific playback interface. The HTML's `video` element must also include the `webkit-playsinline` attribute (defaults to `no`).
- __presentationstyle__: Set to `pagesheet`, `formsheet` or `fullscreen` to set the [presentation style](http://developer.apple.com/library/ios/documentation/UIKit/Reference/UIViewController_Class/Reference/Reference.html#//apple_ref/occ/instp/UIViewController/modalPresentationStyle) (defaults to `fullscreen`).
- __transitionstyle__: Set to `fliphorizontal`, `crossdissolve` or `coververtical` to set the [transition style](http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIViewController_Class/Reference/Reference.html#//apple_ref/occ/instp/UIViewController/modalTransitionStyle) (defaults to `coververtical`).
- __toolbarposition__: Set to `top` or `bottom` (default is `bottom`). Causes the toolbar to be at the top or bottom of the window.
Expand Down
9 changes: 9 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@
-->
# Release Notes

### 3.2.0 (Jan 04, 2020)
* [GH-503](https://github.com/apache/cordova-plugin-inappbrowser/pull/503) Defensive code to prevent NULL reference exceptions for async
* [GH-584](https://github.com/apache/cordova-plugin-inappbrowser/pull/584) Add compile-time decision for disabling UIWebView
* [GH-524](https://github.com/apache/cordova-plugin-inappbrowser/pull/524) Replace "beforeload" with BEFORELOAD
* [GH-568](https://github.com/apache/cordova-plugin-inappbrowser/pull/568) Update missing closed brace to the insert.CSS
* [GH-401](https://github.com/apache/cordova-plugin-inappbrowser/pull/401) Move createIframeBridge to injectDeferredObject
* [GH-534](https://github.com/apache/cordova-plugin-inappbrowser/pull/534) Fix `InAppBrowser` not opening on **iOS** 13
* ci(travis) Upgrade to node8

### 3.1.0 (Jun 27, 2019)

- chore: fix repo and issue urls and license in package.json and plugin.xml ([`8edfb9e`](https://github.com/apache/cordova-plugin-inappbrowser/commit/8edfb9e))
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cordova-plugin-inappbrowser",
"version": "3.1.1-dev",
"version": "3.2.1-dev",
"description": "Cordova InAppBrowser Plugin",
"types": "./types/index.d.ts",
"cordova": {
Expand Down
15 changes: 1 addition & 14 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
id="cordova-plugin-inappbrowser"
version="3.1.1-dev">
version="3.2.1-dev">

<name>InAppBrowser</name>
<description>Cordova InAppBrowser Plugin</description>
Expand Down Expand Up @@ -75,27 +75,14 @@
</js-module>
<config-file target="config.xml" parent="/*">
<feature name="InAppBrowser">
<param name="ios-package" value="CDVInAppBrowser" />
<param name="onload" value="true" />
</feature>
<feature name="UIInAppBrowser">
<param name="ios-package" value="CDVUIInAppBrowser" />
<param name="onload" value="true" />
</feature>
<feature name="WKInAppBrowser">
<param name="ios-package" value="CDVWKInAppBrowser" />
<param name="onload" value="true" />
</feature>
</config-file>

<header-file src="src/ios/CDVInAppBrowser.h" />
<source-file src="src/ios/CDVInAppBrowser.m" />
<header-file src="src/ios/CDVInAppBrowserOptions.h" />
<source-file src="src/ios/CDVInAppBrowserOptions.m" />
<header-file src="src/ios/CDVInAppBrowserNavigationController.h" />
<source-file src="src/ios/CDVInAppBrowserNavigationController.m" />
<header-file src="src/ios/CDVUIInAppBrowser.h" />
<source-file src="src/ios/CDVUIInAppBrowser.m" />
<header-file src="src/ios/CDVWKInAppBrowser.h" />
<source-file src="src/ios/CDVWKInAppBrowser.m" />
<header-file src="src/ios/CDVWKInAppBrowserUIDelegate.h" />
Expand Down
52 changes: 28 additions & 24 deletions src/android/InAppBrowser.java
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,9 @@ else if (action.equals("show")) {
this.cordova.getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
dialog.show();
if (dialog != null) {
dialog.show();
}
}
});
PluginResult pluginResult = new PluginResult(PluginResult.Status.OK);
Expand All @@ -324,7 +326,9 @@ else if (action.equals("hide")) {
this.cordova.getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
dialog.hide();
if (dialog != null) {
dialog.hide();
}
}
});
PluginResult pluginResult = new PluginResult(PluginResult.Status.OK);
Expand Down Expand Up @@ -437,7 +441,7 @@ private HashMap<String, String> parseFeature(String optString) {
if (option.hasMoreElements()) {
String key = option.nextToken();
String value = option.nextToken();
if (!customizableOptions.contains(key)){
if (!customizableOptions.contains(key)) {
value = value.equals("yes") || value.equals("no") ? value : "yes";
}
map.put(key, value);
Expand Down Expand Up @@ -616,7 +620,7 @@ private boolean getShowLocationBar() {
return this.showLocationBar;
}

private InAppBrowser getInAppBrowser(){
private InAppBrowser getInAppBrowser() {
return this;
}

Expand Down Expand Up @@ -730,7 +734,7 @@ private int dpToPixels(int dipValue) {
return value;
}

private View createCloseButton(int id){
private View createCloseButton(int id) {
View _close;
Resources activityRes = cordova.getActivity().getResources();

Expand Down Expand Up @@ -906,9 +910,9 @@ public boolean onKey(View v, int keyCode, KeyEvent event) {
// Footer
RelativeLayout footer = new RelativeLayout(cordova.getActivity());
int _footerColor;
if(footerColor != ""){
if(footerColor != "") {
_footerColor = Color.parseColor(footerColor);
}else{
} else {
_footerColor = android.graphics.Color.LTGRAY;
}
footer.setBackgroundColor(_footerColor);
Expand Down Expand Up @@ -1065,12 +1069,14 @@ public void postMessage(String data) {
lp.width = WindowManager.LayoutParams.MATCH_PARENT;
lp.height = WindowManager.LayoutParams.MATCH_PARENT;

dialog.setContentView(main);
dialog.show();
dialog.getWindow().setAttributes(lp);
if (dialog != null) {
dialog.setContentView(main);
dialog.show();
dialog.getWindow().setAttributes(lp);
}
// the goal of openhidden is to load the url and not display it
// Show() needs to be called to cause the URL to be loaded
if(openWindowHidden) {
if (openWindowHidden && dialog != null) {
dialog.hide();
}
}
Expand Down Expand Up @@ -1208,26 +1214,26 @@ public boolean shouldOverrideUrlLoading(String url, String method) {

if (beforeload.equals("yes") && method == null) {
useBeforeload = true;
}else if(beforeload.equals("yes")
} else if(beforeload.equals("yes")
//TODO handle POST requests then this condition can be removed:
&& !method.equals("POST"))
{
useBeforeload = true;
}else if(beforeload.equals("get") && (method == null || method.equals("GET"))){
} else if(beforeload.equals("get") && (method == null || method.equals("GET"))) {
useBeforeload = true;
}else if(beforeload.equals("post") && (method == null || method.equals("POST"))){
} else if(beforeload.equals("post") && (method == null || method.equals("POST"))) {
//TODO handle POST requests
errorMessage = "beforeload doesn't yet support POST requests";
}

// On first URL change, initiate JS callback. Only after the beforeload event, continue.
if (useBeforeload && this.waitForBeforeload) {
if(sendBeforeLoad(url, method)){
if(sendBeforeLoad(url, method)) {
return true;
}
}

if(errorMessage != null){
if(errorMessage != null) {
try {
LOG.e(LOG_TAG, errorMessage);
JSONObject obj = new JSONObject();
Expand All @@ -1236,7 +1242,7 @@ public boolean shouldOverrideUrlLoading(String url, String method) {
obj.put("code", -1);
obj.put("message", errorMessage);
sendUpdate(obj, true, PluginResult.Status.ERROR);
}catch(Exception e){
} catch(Exception e) {
LOG.e(LOG_TAG, "Error sending loaderror for " + url + ": " + e.toString());
}
}
Expand Down Expand Up @@ -1322,12 +1328,12 @@ else if (!url.startsWith("http:") && !url.startsWith("https:") && url.matches("^
return override;
}

private boolean sendBeforeLoad(String url, String method){
private boolean sendBeforeLoad(String url, String method) {
try {
JSONObject obj = new JSONObject();
obj.put("type", "beforeload");
obj.put("type", BEFORELOAD);
obj.put("url", url);
if(method != null){
if(method != null) {
obj.put("method", method);
}
sendUpdate(obj, true);
Expand Down Expand Up @@ -1365,7 +1371,7 @@ public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceReque
return shouldInterceptRequest(request.getUrl().toString(), super.shouldInterceptRequest(view, request), request.getMethod());
}

public WebResourceResponse shouldInterceptRequest(String url, WebResourceResponse response, String method){
public WebResourceResponse shouldInterceptRequest(String url, WebResourceResponse response, String method) {
return response;
}

Expand Down Expand Up @@ -1406,13 +1412,11 @@ public void onPageStarted(WebView view, String url, Bitmap favicon) {
}
}



public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);

// Set the namespace for postMessage()
if (Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1){
if (Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) {
injectDeferredObject("window.webkit={messageHandlers:{cordova_iab:cordova_iab}}", null);
}

Expand Down
36 changes: 0 additions & 36 deletions src/ios/CDVInAppBrowser.h

This file was deleted.

Loading

0 comments on commit 4db0b9c

Please sign in to comment.