You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by st...@apache.org on 2013/06/14 00:51:52 UTC

git commit: updated inappbrowser with latest native + js code

Updated Branches:
  refs/heads/master 9f8af5f46 -> 8c0c36d5b


updated inappbrowser with latest native + js code


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/commit/8c0c36d5
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/tree/8c0c36d5
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/diff/8c0c36d5

Branch: refs/heads/master
Commit: 8c0c36d5bfc1349e3b84726f5f190f7f31727458
Parents: 9f8af5f
Author: Steven Gill <st...@gmail.com>
Authored: Thu Jun 13 15:49:11 2013 -0700
Committer: Steven Gill <st...@gmail.com>
Committed: Thu Jun 13 15:49:11 2013 -0700

----------------------------------------------------------------------
 src/android/InAppBrowser.java | 27 +++++++++++++++++++++++++--
 src/ios/CDVInAppBrowser.h     |  2 ++
 src/ios/CDVInAppBrowser.m     | 15 ++++++++++++---
 www/InAppBrowser.js           |  3 +++
 4 files changed, 42 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/blob/8c0c36d5/src/android/InAppBrowser.java
----------------------------------------------------------------------
diff --git a/src/android/InAppBrowser.java b/src/android/InAppBrowser.java
index b60ec3b..6fa75bc 100644
--- a/src/android/InAppBrowser.java
+++ b/src/android/InAppBrowser.java
@@ -21,6 +21,7 @@ package org.apache.cordova.core;
 import java.util.HashMap;
 import java.util.StringTokenizer;
 
+
 import org.apache.cordova.Config;
 import org.apache.cordova.CordovaWebView;
 import org.apache.cordova.api.CallbackContext;
@@ -71,8 +72,9 @@ public class InAppBrowser extends CordovaPlugin {
     private static final String SELF = "_self";
     private static final String SYSTEM = "_system";
     // private static final String BLANK = "_blank";
-    private static final String LOCATION = "location";
     private static final String EXIT_EVENT = "exit";
+    private static final String LOCATION = "location";
+    private static final String HIDDEN = "hidden";
     private static final String LOAD_START_EVENT = "loadstart";
     private static final String LOAD_STOP_EVENT = "loadstop";
     private static final String LOAD_ERROR_EVENT = "loaderror";
@@ -82,8 +84,9 @@ public class InAppBrowser extends CordovaPlugin {
     private Dialog dialog;
     private WebView inAppWebView;
     private EditText edittext;
-    private boolean showLocationBar = true;
     private CallbackContext callbackContext;
+    private boolean showLocationBar = true;
+    private boolean openWindowHidden = false;
     private String buttonLabel = "Done";
     
     /**
@@ -187,6 +190,16 @@ public class InAppBrowser extends CordovaPlugin {
                 }
                 injectDeferredObject(args.getString(0), jsWrapper);
             }
+            else if (action.equals("show")) {
+                Runnable runnable = new Runnable() {
+                    @Override
+                    public void run() {
+                        dialog.show();
+                    }
+                };
+                this.cordova.getActivity().runOnUiThread(runnable);
+                this.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK));
+            }
             else {
                 return false;
             }
@@ -363,11 +376,16 @@ public class InAppBrowser extends CordovaPlugin {
     public String showWebPage(final String url, HashMap<String, Boolean> features) {
         // Determine if we should hide the location bar.
         showLocationBar = true;
+        openWindowHidden = false;
         if (features != null) {
             Boolean show = features.get(LOCATION);
             if (show != null) {
                 showLocationBar = show.booleanValue();
             }
+            Boolean hidden = features.get(HIDDEN);
+            if(hidden != null) {
+                openWindowHidden = hidden.booleanValue();
+            }
         }
         
         final CordovaWebView thatWebView = this.webView;
@@ -551,6 +569,11 @@ public class InAppBrowser extends CordovaPlugin {
                 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) {
+                	dialog.hide();
+                }
             }
         };
         this.cordova.getActivity().runOnUiThread(runnable);

http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/blob/8c0c36d5/src/ios/CDVInAppBrowser.h
----------------------------------------------------------------------
diff --git a/src/ios/CDVInAppBrowser.h b/src/ios/CDVInAppBrowser.h
index 0352144..059edb0 100644
--- a/src/ios/CDVInAppBrowser.h
+++ b/src/ios/CDVInAppBrowser.h
@@ -34,6 +34,7 @@
 - (void)open:(CDVInvokedUrlCommand*)command;
 - (void)close:(CDVInvokedUrlCommand*)command;
 - (void)injectScriptCode:(CDVInvokedUrlCommand*)command;
+- (void)show:(CDVInvokedUrlCommand*)command;
 
 @end
 
@@ -81,6 +82,7 @@
 @property (nonatomic, assign) BOOL allowinlinemediaplayback;
 @property (nonatomic, assign) BOOL keyboarddisplayrequiresuseraction;
 @property (nonatomic, assign) BOOL suppressesincrementalrendering;
+@property (nonatomic, assign) BOOL hidden;
 
 + (CDVInAppBrowserOptions*)parseOptions:(NSString*)options;
 

http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/blob/8c0c36d5/src/ios/CDVInAppBrowser.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVInAppBrowser.m b/src/ios/CDVInAppBrowser.m
index d7c51c2..b8724cb 100644
--- a/src/ios/CDVInAppBrowser.m
+++ b/src/ios/CDVInAppBrowser.m
@@ -101,13 +101,13 @@
         }
     }
 
+
     CDVInAppBrowserOptions* browserOptions = [CDVInAppBrowserOptions parseOptions:options];
     [self.inAppBrowserViewController showLocationBar:browserOptions.location];
     [self.inAppBrowserViewController showToolBar:browserOptions.toolbar];
     if (browserOptions.closebuttoncaption != nil) {
         [self.inAppBrowserViewController setCloseButtonTitle:browserOptions.closebuttoncaption];
     }
-
     // Set Presentation Style
     UIModalPresentationStyle presentationStyle = UIModalPresentationFullScreen; // default
     if (browserOptions.presentationstyle != nil) {
@@ -130,6 +130,7 @@
     }
     self.inAppBrowserViewController.modalTransitionStyle = transitionStyle;
 
+  
     // UIWebView options
     self.inAppBrowserViewController.webView.scalesPageToFit = browserOptions.enableviewportscale;
     self.inAppBrowserViewController.webView.mediaPlaybackRequiresUserAction = browserOptions.mediaplaybackrequiresuseraction;
@@ -138,13 +139,20 @@
         self.inAppBrowserViewController.webView.keyboardDisplayRequiresUserAction = browserOptions.keyboarddisplayrequiresuseraction;
         self.inAppBrowserViewController.webView.suppressesIncrementalRendering = browserOptions.suppressesincrementalrendering;
     }
-
-    if (self.viewController.modalViewController != self.inAppBrowserViewController) {
+  
+    if (! browserOptions.hidden) {
+      if (self.viewController.modalViewController != self.inAppBrowserViewController) {
         [self.viewController presentModalViewController:self.inAppBrowserViewController animated:YES];
+      }
     }
     [self.inAppBrowserViewController navigateTo:url];
 }
 
+- (void)show:(CDVInvokedUrlCommand*)command
+{
+  [self.viewController presentModalViewController:self.inAppBrowserViewController animated:YES];
+}
+
 - (void)openInCordovaWebView:(NSURL*)url withOptions:(NSString*)options
 {
     if ([self.commandDelegate URLIsWhitelisted:url]) {
@@ -764,6 +772,7 @@
         self.allowinlinemediaplayback = NO;
         self.keyboarddisplayrequiresuseraction = YES;
         self.suppressesincrementalrendering = NO;
+        self.hidden = NO;
     }
 
     return self;

http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/blob/8c0c36d5/www/InAppBrowser.js
----------------------------------------------------------------------
diff --git a/www/InAppBrowser.js b/www/InAppBrowser.js
index 1640a82..5da53fd 100644
--- a/www/InAppBrowser.js
+++ b/www/InAppBrowser.js
@@ -41,6 +41,9 @@ InAppBrowser.prototype = {
     close: function (eventname) {
         exec(null, null, "InAppBrowser", "close", []);
     },
+    show: function (eventname) {
+      exec(null, null, "InAppBrowser", "show", []);
+    },
     addEventListener: function (eventname,f) {
         if (eventname in this.channels) {
             this.channels[eventname].subscribe(f);