Compare commits

..

24 Commits
3.1.0 ... 3.2.0

Author SHA1 Message Date
Niklas Merz
81aa8ba5a9 (ios) fix regression in injectScriptFile
Fixes issue introduced in #584
2020-01-06 07:20:07 +01:00
Niklas Merz
2cd868e99f chore(release): release notes for 3.2.0 2020-01-04 09:43:11 +01:00
Niklas Merz
6aca3f7fb4 chore(release): 3.2.0 (version string) 2020-01-04 09:24:36 +01:00
Niklas Merz
7b42f3e105 Merge pull request #503 from alexyazvinsky/def-fix
(android) Defensive code to prevent NULL reference exceptions for async
2020-01-04 08:57:52 +01:00
Maik Hummel
82bbe29986 (ios) add compile-time decision for disabling UIWebView (#584) 2020-01-04 08:55:28 +01:00
Niklas Merz
785fc4c83d chore(release): 3.2.0-dev 2020-01-02 21:27:59 +01:00
Niklas Merz
d4338bd64a (android) improve defensive code for NULL check 2020-01-02 19:53:36 +01:00
Alex Yaz
0411a287b8 (android) defensive code to prevent NULL reference exceptions for async
Signed-off-by: Niklas Merz <niklasmerz@apache.org>
2020-01-02 19:50:26 +01:00
Lorenzo B
416b05c1e5 Replace "beforeload" with BEFORELOAD (#524)
Improve code formatting
2019-12-30 10:47:37 +01:00
mosababubakr
9a15737577 Update missing closed brace to the insert.CSS (#568) 2019-11-04 15:23:44 +00:00
Norman Breau
7b6f95964a Merge pull request #567 from mosababubakr/patch-1
Update missing closed brace to the insert.CSS
2019-11-03 11:09:54 -04:00
mosababubakr
1e16c50b1a Update missing closed brace to the insert.CSS 2019-11-03 16:56:59 +02:00
Dave Alden
80feff6cf8 Merge pull request #401 from GEDYSIntraWare/bridge
Move bridge creation to injectDeferredObject
2019-09-24 16:21:19 +01:00
Dave Alden
ba345b0159 Merge pull request #534 from GEDYSIntraWare/fix-show-ios13
Fix inappbrowser not opening on iOS 13 by using reusable window. Resolves #492
2019-09-24 15:43:48 +01:00
Niklas Merz
855394628e Fix unresponsive main window after hide 2019-09-24 16:28:07 +02:00
Niklas Merz
79b1bb61a0 Move window hiding to 'browserExit'
Fixes close, hide and toolbar 'done' and makes cordova window responsive
2019-09-23 10:29:31 +02:00
Niklas Merz
4376ddabcd New fix attempt 2019-09-20 15:48:27 +02:00
Niklas Merz
82d496ae5c Use tmpWindow and hide on close 2019-09-20 13:43:57 +02:00
Niklas Merz
81bec09526 (ios) Fix iOS 13 show not working
Removed tmpWindow and controller.
This was introduced to fix IAB with WKWebView before WKIAB existed.
2019-09-06 14:14:51 +02:00
Niklas Merz
8805f5d46a Finish revert and correct Xcode warnings 2019-09-06 13:53:36 +02:00
Niklas Merz
8810c6a8a0 (ios) Fix inappbrowser not opening on iOS 13 by using reusable window
Closes #492
2019-09-06 13:49:44 +02:00
Jan Piotrowski
2b59941514 ci(travis): upgrade to node8 2019-07-01 20:26:57 +02:00
Jan Piotrowski
84dfb09edd chore(release): 3.1.1-dev 2019-06-28 23:12:38 +02:00
Niklas Merz
e3db974080 (ios) Move createIframeBridge to injectDeferredObject
Avoid failed script injections for pages which did not finish loading.
2019-01-16 14:22:51 +01:00
13 changed files with 164 additions and 92 deletions

View File

@@ -12,12 +12,12 @@ addons:
env:
global:
- SAUCE_USERNAME=snay
- TRAVIS_NODE_VERSION=6
- TRAVIS_NODE_VERSION=8
- ANDROID_API_LEVEL=28
- ANDROID_BUILD_TOOLS_VERSION=28.0.3
language: node_js
node_js: 6
node_js: 8
# yaml anchor/alias: https://medium.com/@tommyvn/travis-yml-dry-with-anchors-8b6a3ac1b027

View File

@@ -256,7 +256,7 @@ function loadStopCallBack() {
if (inAppBrowserRef != undefined) {
inAppBrowserRef.insertCSS({ code: "body{font-size: 25px;" });
inAppBrowserRef.insertCSS({ code: "body{font-size: 25px;}" });
inAppBrowserRef.executeScript({ code: "\
var message = 'this is the message';\
@@ -621,7 +621,7 @@ function loadStopCallBack() {
if (inAppBrowserRef != undefined) {
inAppBrowserRef.insertCSS({ code: "body{font-size: 25px;" });
inAppBrowserRef.insertCSS({ code: "body{font-size: 25px;}" });
$('#status-message').text("");

View File

@@ -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))

View File

@@ -1,6 +1,6 @@
{
"name": "cordova-plugin-inappbrowser",
"version": "3.1.0",
"version": "3.2.0",
"description": "Cordova InAppBrowser Plugin",
"types": "./types/index.d.ts",
"cordova": {

View File

@@ -20,7 +20,7 @@
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
id="cordova-plugin-inappbrowser"
version="3.1.0">
version="3.2.0">
<name>InAppBrowser</name>
<description>Cordova InAppBrowser Plugin</description>

View File

@@ -313,7 +313,9 @@ public class InAppBrowser extends CordovaPlugin {
this.cordova.getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
dialog.show();
if (dialog != null) {
dialog.show();
}
}
});
PluginResult pluginResult = new PluginResult(PluginResult.Status.OK);
@@ -324,7 +326,9 @@ public class InAppBrowser extends CordovaPlugin {
this.cordova.getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
dialog.hide();
if (dialog != null) {
dialog.hide();
}
}
});
PluginResult pluginResult = new PluginResult(PluginResult.Status.OK);
@@ -437,7 +441,7 @@ public class InAppBrowser extends CordovaPlugin {
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);
@@ -616,7 +620,7 @@ public class InAppBrowser extends CordovaPlugin {
return this.showLocationBar;
}
private InAppBrowser getInAppBrowser(){
private InAppBrowser getInAppBrowser() {
return this;
}
@@ -730,7 +734,7 @@ public class InAppBrowser extends CordovaPlugin {
return value;
}
private View createCloseButton(int id){
private View createCloseButton(int id) {
View _close;
Resources activityRes = cordova.getActivity().getResources();
@@ -906,9 +910,9 @@ public class InAppBrowser extends CordovaPlugin {
// 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);
@@ -1065,12 +1069,14 @@ public class InAppBrowser extends CordovaPlugin {
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();
}
}
@@ -1208,26 +1214,26 @@ public class InAppBrowser extends CordovaPlugin {
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();
@@ -1236,7 +1242,7 @@ public class InAppBrowser extends CordovaPlugin {
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());
}
}
@@ -1322,12 +1328,12 @@ public class InAppBrowser extends CordovaPlugin {
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);
@@ -1365,7 +1371,7 @@ public class InAppBrowser extends CordovaPlugin {
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;
}
@@ -1406,13 +1412,11 @@ public class InAppBrowser extends CordovaPlugin {
}
}
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);
}

View File

@@ -19,7 +19,9 @@
#import "CDVInAppBrowser.h"
#import "CDVInAppBrowserOptions.h"
#if !WK_WEB_VIEW_ONLY
#import "CDVUIInAppBrowser.h"
#endif
#import "CDVWKInAppBrowser.h"
#import <Cordova/CDVPluginResult.h>
@@ -49,86 +51,122 @@
return;
}
self.usewkwebview = browserOptions.usewkwebview;
if(self.usewkwebview){
[[CDVWKInAppBrowser getInstance] open:command];
}else{
[[CDVUIInAppBrowser getInstance] open:command];
}
#if WK_WEB_VIEW_ONLY
[[CDVWKInAppBrowser getInstance] open:command];
#else
if(self.usewkwebview){
[[CDVWKInAppBrowser getInstance] open:command];
}else{
[[CDVUIInAppBrowser getInstance] open:command];
}
#endif
}
- (void)close:(CDVInvokedUrlCommand*)command
{
if(self.usewkwebview){
[[CDVWKInAppBrowser getInstance] close:command];
}else{
[[CDVUIInAppBrowser getInstance] close:command];
}
#if WK_WEB_VIEW_ONLY
[[CDVWKInAppBrowser getInstance] close:command];
#else
if(self.usewkwebview){
[[CDVWKInAppBrowser getInstance] close:command];
}else{
[[CDVUIInAppBrowser getInstance] close:command];
}
#endif
}
- (void)show:(CDVInvokedUrlCommand*)command
{
if(self.usewkwebview){
[[CDVWKInAppBrowser getInstance] show:command];
}else{
[[CDVUIInAppBrowser getInstance] show:command];
}
#if WK_WEB_VIEW_ONLY
[[CDVWKInAppBrowser getInstance] show:command];
#else
if(self.usewkwebview){
[[CDVWKInAppBrowser getInstance] show:command];
}else{
[[CDVUIInAppBrowser getInstance] show:command];
}
#endif
}
- (void)hide:(CDVInvokedUrlCommand*)command
{
if(self.usewkwebview){
[[CDVWKInAppBrowser getInstance] hide:command];
}else{
[[CDVUIInAppBrowser getInstance] hide:command];
}
#if WK_WEB_VIEW_ONLY
[[CDVWKInAppBrowser getInstance] hide:command];
#else
if(self.usewkwebview){
[[CDVWKInAppBrowser getInstance] hide:command];
}else{
[[CDVUIInAppBrowser getInstance] hide:command];
}
#endif
}
- (void)injectScriptCode:(CDVInvokedUrlCommand*)command
{
if(self.usewkwebview){
[[CDVWKInAppBrowser getInstance] injectScriptCode:command];
}else{
[[CDVUIInAppBrowser getInstance] injectScriptCode:command];
}
#if WK_WEB_VIEW_ONLY
[[CDVWKInAppBrowser getInstance] injectScriptCode:command];
#else
if(self.usewkwebview){
[[CDVWKInAppBrowser getInstance] injectScriptCode:command];
}else{
[[CDVUIInAppBrowser getInstance] injectScriptCode:command];
}
#endif
}
- (void)injectScriptFile:(CDVInvokedUrlCommand*)command
{
if(self.usewkwebview){
[[CDVWKInAppBrowser getInstance] injectScriptFile:command];
}else{
[[CDVUIInAppBrowser getInstance] injectScriptFile:command];
}
#if WK_WEB_VIEW_ONLY
[[CDVWKInAppBrowser getInstance] injectScriptFile:command];
#else
if(self.usewkwebview){
[[CDVWKInAppBrowser getInstance] injectScriptFile:command];
}else{
[[CDVUIInAppBrowser getInstance] injectScriptFile:command];
}
#endif
}
- (void)injectStyleCode:(CDVInvokedUrlCommand*)command
{
if(self.usewkwebview){
[[CDVWKInAppBrowser getInstance] injectStyleCode:command];
}else{
[[CDVUIInAppBrowser getInstance] injectStyleCode:command];
}
#if WK_WEB_VIEW_ONLY
[[CDVWKInAppBrowser getInstance] injectStyleCode:command];
#else
if(self.usewkwebview){
[[CDVWKInAppBrowser getInstance] injectStyleCode:command];
}else{
[[CDVUIInAppBrowser getInstance] injectStyleCode:command];
}
#endif
}
- (void)injectStyleFile:(CDVInvokedUrlCommand*)command
{
if(self.usewkwebview){
[[CDVWKInAppBrowser getInstance] injectStyleFile:command];
}else{
[[CDVUIInAppBrowser getInstance] injectStyleFile:command];
}
#if WK_WEB_VIEW_ONLY
[[CDVWKInAppBrowser getInstance] injectStyleFile:command];
#else
if(self.usewkwebview){
[[CDVWKInAppBrowser getInstance] injectStyleFile:command];
}else{
[[CDVUIInAppBrowser getInstance] injectStyleFile:command];
}
#endif
}
- (void)loadAfterBeforeload:(CDVInvokedUrlCommand*)command
{
if(self.usewkwebview){
[[CDVWKInAppBrowser getInstance] loadAfterBeforeload:command];
}else{
[[CDVUIInAppBrowser getInstance] loadAfterBeforeload:command];
}
#if WK_WEB_VIEW_ONLY
[[CDVWKInAppBrowser getInstance] loadAfterBeforeload:command];
#else
if(self.usewkwebview){
[[CDVWKInAppBrowser getInstance] loadAfterBeforeload:command];
}else{
[[CDVUIInAppBrowser getInstance] loadAfterBeforeload:command];
}
#endif
}
@end
@end

View File

@@ -17,6 +17,8 @@
under the License.
*/
#if !WK_WEB_VIEW_ONLY
#import <Cordova/CDVPlugin.h>
#import <Cordova/CDVInvokedUrlCommand.h>
#import <Cordova/CDVScreenOrientationDelegate.h>
@@ -89,3 +91,5 @@
- (id)initWithUserAgent:(NSString*)userAgent prevUserAgent:(NSString*)prevUserAgent browserOptions: (CDVInAppBrowserOptions*) browserOptions;
@end
#endif

View File

@@ -17,6 +17,8 @@
under the License.
*/
#if !WK_WEB_VIEW_ONLY
#import "CDVUIInAppBrowser.h"
#import <Cordova/CDVPluginResult.h>
#import <Cordova/CDVUserAgentUtil.h>
@@ -363,6 +365,7 @@ static CDVUIInAppBrowser* instance = nil;
- (void)injectDeferredObject:(NSString*)source withWrapper:(NSString*)jsWrapper
{
[self createIframeBridge];
if (jsWrapper != nil) {
NSData* jsonData = [NSJSONSerialization dataWithJSONObject:@[source] options:0 error:nil];
NSString* sourceArrayString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
@@ -565,7 +568,6 @@ static CDVUIInAppBrowser* instance = nil;
- (void)webViewDidFinishLoad:(UIWebView*)theWebView
{
[self createIframeBridge];
if (self.callbackId != nil) {
// TODO: It would be more useful to return the URL the page is actually on (e.g. if it's been redirected).
NSString* url = [self.inAppBrowserViewController.currentURL absoluteString];
@@ -1126,4 +1128,4 @@ static CDVUIInAppBrowser* instance = nil;
@end
#endif

View File

@@ -27,6 +27,8 @@
@class CDVWKInAppBrowserViewController;
@interface CDVWKInAppBrowser : CDVPlugin {
UIWindow * tmpWindow;
@private
NSString* _beforeload;
BOOL _waitForBeforeload;

View File

@@ -80,6 +80,7 @@ static CDVWKInAppBrowser* instance = nil;
NSLog(@"IAB.close() called but it was already closed.");
return;
}
// Things are cleaned up in browserExit.
[self.inAppBrowserViewController close];
}
@@ -275,7 +276,9 @@ static CDVWKInAppBrowser* instance = nil;
_waitForBeforeload = ![_beforeload isEqualToString:@""];
[self.inAppBrowserViewController navigateTo:url];
[self show:nil withNoAnimate:browserOptions.hidden];
if (!browserOptions.hidden) {
[self show:nil withNoAnimate:browserOptions.hidden];
}
}
- (void)show:(CDVInvokedUrlCommand*)command{
@@ -314,19 +317,21 @@ static CDVWKInAppBrowser* instance = nil;
dispatch_async(dispatch_get_main_queue(), ^{
if (weakSelf.inAppBrowserViewController != nil) {
float osVersion = [[[UIDevice currentDevice] systemVersion] floatValue];
CGRect frame = [[UIScreen mainScreen] bounds];
if(initHidden && osVersion < 11){
frame.origin.x = -10000;
__strong __typeof(weakSelf) strongSelf = weakSelf;
if (!strongSelf->tmpWindow) {
CGRect frame = [[UIScreen mainScreen] bounds];
if(initHidden && osVersion < 11){
frame.origin.x = -10000;
}
strongSelf->tmpWindow = [[UIWindow alloc] initWithFrame:frame];
}
UIWindow *tmpWindow = [[UIWindow alloc] initWithFrame:frame];
UIViewController *tmpController = [[UIViewController alloc] init];
[tmpWindow setRootViewController:tmpController];
[tmpWindow setWindowLevel:UIWindowLevelNormal];
[strongSelf->tmpWindow setRootViewController:tmpController];
[strongSelf->tmpWindow setWindowLevel:UIWindowLevelNormal];
if(!initHidden || osVersion < 11){
[tmpWindow makeKeyAndVisible];
[self->tmpWindow makeKeyAndVisible];
}
[tmpController presentViewController:nav animated:!noAnimate completion:nil];
}
@@ -335,6 +340,10 @@ static CDVWKInAppBrowser* instance = nil;
- (void)hide:(CDVInvokedUrlCommand*)command
{
// Set tmpWindow to hidden to make main webview responsive to touch again
// https://stackoverflow.com/questions/4544489/how-to-remove-a-uiwindow
self->tmpWindow.hidden = YES;
if (self.inAppBrowserViewController == nil) {
NSLog(@"Tried to hide IAB after it was closed.");
return;
@@ -690,6 +699,10 @@ static CDVWKInAppBrowser* instance = nil;
// Set navigationDelegate to nil to ensure no callbacks are received from it.
self.inAppBrowserViewController.navigationDelegate = nil;
self.inAppBrowserViewController = nil;
// Set tmpWindow to hidden to make main webview responsive to touch again
// Based on https://stackoverflow.com/questions/4544489/how-to-remove-a-uiwindow
self->tmpWindow.hidden = YES;
if (IsAtLeastiOSVersion(@"7.0")) {
if (_previousStatusBarStyle != -1) {
@@ -786,7 +799,7 @@ BOOL isExiting = FALSE;
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000
if (@available(iOS 11.0, *)) {
[self.webView.scrollView setContentInsetAdjustmentBehavior:UIScrollViewContentInsetAdjustmentNever];
[self.webView.scrollView setContentInsetAdjustmentBehavior:UIScrollViewContentInsetAdjustmentNever];
}
#endif

View File

@@ -1,6 +1,6 @@
{
"name": "cordova-plugin-inappbrowser-tests",
"version": "3.1.0",
"version": "3.2.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="3.1.0">
version="3.2.0">
<name>Cordova InAppBrowser Plugin Tests</name>
<license>Apache 2.0</license>