cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject [23/32] android commit: CB-3420: add hidden option to InAppBrowser
Date Tue, 11 Jun 2013 00:15:38 GMT
CB-3420: add hidden option to InAppBrowser


Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/c3b8b279
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/c3b8b279
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/c3b8b279

Branch: refs/heads/3.0.0
Commit: c3b8b279b091c4394dcf297566cfe453f58a1f82
Parents: 0dd4951
Author: David Kemp <drkemp@dhcp-172-23-180-121.wat.corp.google.com>
Authored: Tue Jun 4 13:37:26 2013 -0400
Committer: Ian Clelland <iclelland@chromium.org>
Committed: Wed Jun 5 10:19:56 2013 -0400

----------------------------------------------------------------------
 .../src/org/apache/cordova/InAppBrowser.java    | 26 ++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c3b8b279/framework/src/org/apache/cordova/InAppBrowser.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/InAppBrowser.java b/framework/src/org/apache/cordova/InAppBrowser.java
index 8e78baa..7a39c5b 100644
--- a/framework/src/org/apache/cordova/InAppBrowser.java
+++ b/framework/src/org/apache/cordova/InAppBrowser.java
@@ -69,8 +69,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";
@@ -80,8 +81,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";
     
     /**
@@ -185,6 +187,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;
             }
@@ -361,11 +373,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;
@@ -549,6 +566,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);


Mime
View raw message