From 2fbb9c285d52ce9ffd43359fa25e95edad074b13 Mon Sep 17 00:00:00 2001 From: Bryce Curtis Date: Wed, 16 May 2012 15:13:42 -0500 Subject: [PATCH 1/6] CB-369: Authentication Code doesn't seem to work. -- Verified basic auth works and provided test case. --- test/AndroidManifest.xml | 3 ++ test/assets/www/basicauth/index.html | 42 +++++++++++++++++ test/assets/www/index.html | 33 ++++++------- .../org/apache/cordova/test/basicauth.java | 46 +++++++++++++++++++ 4 files changed, 108 insertions(+), 16 deletions(-) mode change 100644 => 100755 test/AndroidManifest.xml create mode 100755 test/assets/www/basicauth/index.html create mode 100755 test/src/org/apache/cordova/test/basicauth.java diff --git a/test/AndroidManifest.xml b/test/AndroidManifest.xml old mode 100644 new mode 100755 index b8038c7d..4918fe51 --- a/test/AndroidManifest.xml +++ b/test/AndroidManifest.xml @@ -144,5 +144,8 @@ + + diff --git a/test/assets/www/basicauth/index.html b/test/assets/www/basicauth/index.html new file mode 100755 index 00000000..02ff0b2a --- /dev/null +++ b/test/assets/www/basicauth/index.html @@ -0,0 +1,42 @@ + + + + + + + Cordova Tests + + + + + +

Basic Auth

+
+

Platform:  , Version:  

+

UUID:  , Name:  

+

Width:  , Height:   + , Color Depth:

+
+
+ Loading link below should be successful and show page indicating username=test & password=test.
+
+ Test password + + diff --git a/test/assets/www/index.html b/test/assets/www/index.html index 0fd4eafa..6838156f 100755 --- a/test/assets/www/index.html +++ b/test/assets/www/index.html @@ -1,20 +1,20 @@ @@ -49,6 +49,7 @@ $ + diff --git a/test/src/org/apache/cordova/test/basicauth.java b/test/src/org/apache/cordova/test/basicauth.java new file mode 100755 index 00000000..4007c97c --- /dev/null +++ b/test/src/org/apache/cordova/test/basicauth.java @@ -0,0 +1,46 @@ +/* + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +*/ +package org.apache.cordova.test; + +import android.os.Bundle; +import android.webkit.WebView; + +import org.apache.cordova.*; +import org.apache.cordova.api.LOG; + +public class basicauth extends DroidGap { + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + super.init(); + + // LogCat: onReceivedHttpAuthRequest(browserspy.dk:80,BrowserSpy.dk - HTTP Password Test) + AuthenticationToken token = new AuthenticationToken(); + token.setUserName("test"); + token.setPassword("test"); + super.setAuthenticationToken(token, "browserspy.dk:80", "BrowserSpy.dk - HTTP Password Test"); + + // Add web site to whitelist + super.appView.addWhiteListEntry("http://browserspy.dk*", true); + + // Load test + super.loadUrl("file:///android_asset/www/basicauth/index.html"); + } + +} From 2d7b7160c3f5ec5dfba5358552e030a74305edc2 Mon Sep 17 00:00:00 2001 From: Bryce Curtis Date: Wed, 16 May 2012 15:49:25 -0500 Subject: [PATCH 2/6] CB-779: Verify that fullscreen and backgroundColor preferences are set properly - This check-in enables fullscreen and adds test for it. --- .../org/apache/cordova/CordovaWebView.java | 60 ++++++++++--------- .../src/org/apache/cordova/DroidGap.java | 7 --- test/AndroidManifest.xml | 3 + test/assets/www/fullscreen/index.html | 41 +++++++++++++ test/assets/www/index.html | 1 + .../org/apache/cordova/test/fullscreen.java | 39 ++++++++++++ 6 files changed, 116 insertions(+), 35 deletions(-) create mode 100755 test/assets/www/fullscreen/index.html create mode 100755 test/src/org/apache/cordova/test/fullscreen.java diff --git a/framework/src/org/apache/cordova/CordovaWebView.java b/framework/src/org/apache/cordova/CordovaWebView.java index cdd2fbda..2ff342a9 100644 --- a/framework/src/org/apache/cordova/CordovaWebView.java +++ b/framework/src/org/apache/cordova/CordovaWebView.java @@ -39,6 +39,7 @@ import android.net.Uri; import android.os.Bundle; import android.util.AttributeSet; import android.util.Log; +import android.view.WindowManager; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebSettings.LayoutAlgorithm; @@ -76,40 +77,38 @@ public class CordovaWebView extends WebView { */ public CordovaWebView(Context context) { super(context); - if(CordovaInterface.class.isInstance(context)) + if (CordovaInterface.class.isInstance(context)) { - this.mCtx = (CordovaInterface) context; + this.mCtx = (CordovaInterface) context; } else { - Log.d(TAG, "Your activity must implement CordovaInterface to work"); + Log.d(TAG, "Your activity must implement CordovaInterface to work"); } this.loadConfiguration(); this.setup(); } - /** * Constructor. * - * * @param context * @param attrs */ public CordovaWebView(Context context, AttributeSet attrs) { - super(context, attrs); - if(CordovaInterface.class.isInstance(context)) - { - this.mCtx = (CordovaInterface) context; - } - else - { - Log.d(TAG, "Your activity must implement CordovaInterface to work"); - } - this.setWebChromeClient(new CordovaChromeClient(this.mCtx, this)); - this.setWebViewClient(new CordovaWebViewClient(this.mCtx, this)); - this.loadConfiguration(); - this.setup(); + super(context, attrs); + if (CordovaInterface.class.isInstance(context)) + { + this.mCtx = (CordovaInterface) context; + } + else + { + Log.d(TAG, "Your activity must implement CordovaInterface to work"); + } + this.setWebChromeClient(new CordovaChromeClient(this.mCtx, this)); + this.setWebViewClient(new CordovaWebViewClient(this.mCtx, this)); + this.loadConfiguration(); + this.setup(); } /** @@ -120,15 +119,15 @@ public class CordovaWebView extends WebView { * @param defStyle * */ - public CordovaWebView(Context context, AttributeSet attrs, int defStyle) { + public CordovaWebView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); - if(CordovaInterface.class.isInstance(context)) + if (CordovaInterface.class.isInstance(context)) { - this.mCtx = (CordovaInterface) context; + this.mCtx = (CordovaInterface) context; } else { - Log.d(TAG, "Your activity must implement CordovaInterface to work"); + Log.d(TAG, "Your activity must implement CordovaInterface to work"); } this.setWebChromeClient(new CordovaChromeClient(this.mCtx, this)); this.setWebViewClient(new CordovaWebViewClient(this.mCtx, this)); @@ -146,13 +145,13 @@ public class CordovaWebView extends WebView { */ public CordovaWebView(Context context, AttributeSet attrs, int defStyle, boolean privateBrowsing) { super(context, attrs, defStyle, privateBrowsing); - if(CordovaInterface.class.isInstance(context)) + if (CordovaInterface.class.isInstance(context)) { - this.mCtx = (CordovaInterface) context; + this.mCtx = (CordovaInterface) context; } else { - Log.d(TAG, "Your activity must implement CordovaInterface to work"); + Log.d(TAG, "Your activity must implement CordovaInterface to work"); } this.setWebChromeClient(new CordovaChromeClient(this.mCtx)); this.setWebViewClient(new CordovaWebViewClient(this.mCtx)); @@ -192,10 +191,10 @@ public class CordovaWebView extends WebView { //Start up the plugin manager try { - this.pluginManager = new PluginManager(this, mCtx); + this.pluginManager = new PluginManager(this, this.mCtx); } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); + // TODO Auto-generated catch block + e.printStackTrace(); } } @@ -637,6 +636,11 @@ public class CordovaWebView extends WebView { else { this.useBrowserHistory = false; } + + if ("true".equals(this.getProperty("fullscreen", "false"))) { + this.mCtx.getActivity().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); + this.mCtx.getActivity().getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); + } } /** diff --git a/framework/src/org/apache/cordova/DroidGap.java b/framework/src/org/apache/cordova/DroidGap.java index aeca772b..2af6c9cc 100755 --- a/framework/src/org/apache/cordova/DroidGap.java +++ b/framework/src/org/apache/cordova/DroidGap.java @@ -250,15 +250,8 @@ public class DroidGap extends Activity implements CordovaInterface { super.onCreate(savedInstanceState); getWindow().requestFeature(Window.FEATURE_NO_TITLE); - - // TODO @bc - What about fullscreen? - //if (preferences.prefMatches("fullscreen", "true")) { - // getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, - // WindowManager.LayoutParams.FLAG_FULLSCREEN); - //} else { getWindow().setFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN, WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); - //} // This builds the view. We could probably get away with NOT having a LinearLayout, but I like having a bucket! Display display = getWindowManager().getDefaultDisplay(); diff --git a/test/AndroidManifest.xml b/test/AndroidManifest.xml index 4918fe51..0d280ba6 100755 --- a/test/AndroidManifest.xml +++ b/test/AndroidManifest.xml @@ -147,5 +147,8 @@ + + diff --git a/test/assets/www/fullscreen/index.html b/test/assets/www/fullscreen/index.html new file mode 100755 index 00000000..ab910acc --- /dev/null +++ b/test/assets/www/fullscreen/index.html @@ -0,0 +1,41 @@ + + + + + + + Cordova Tests + + + + + +

Full Screen Test

+
+

Platform:  , Version:  

+

UUID:  , Name:  

+

Width:  , Height:   + , Color Depth:

+
+
+ The app should take over the entire screen. The top Android status bar should not be shown.
+
+ + diff --git a/test/assets/www/index.html b/test/assets/www/index.html index 6838156f..d1a770a1 100755 --- a/test/assets/www/index.html +++ b/test/assets/www/index.html @@ -51,6 +51,7 @@ + diff --git a/test/src/org/apache/cordova/test/fullscreen.java b/test/src/org/apache/cordova/test/fullscreen.java new file mode 100755 index 00000000..8b146247 --- /dev/null +++ b/test/src/org/apache/cordova/test/fullscreen.java @@ -0,0 +1,39 @@ +/* + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +*/ +package org.apache.cordova.test; + +import android.os.Bundle; +import android.webkit.WebView; + +import org.apache.cordova.*; +import org.apache.cordova.api.LOG; + +public class fullscreen extends DroidGap { + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + // Properties must be set before init() is called, since some are processed during init(). + super.setBooleanProperty("fullscreen", true); + + super.init(); + super.loadUrl("file:///android_asset/www/fullscreen/index.html"); + } + +} From ac504768b2ae1393f15ce955b0c2b254137ae4c2 Mon Sep 17 00:00:00 2001 From: Bryce Curtis Date: Wed, 16 May 2012 16:47:02 -0500 Subject: [PATCH 3/6] CB-779: Verify that fullscreen and backgroundColor preferences are set properly - This check-in enables background color and adds test for it. --- .../src/org/apache/cordova/DroidGap.java | 31 +++++++++++--- test/AndroidManifest.xml | 3 ++ test/assets/www/backgroundcolor/index.html | 41 +++++++++++++++++++ .../apache/cordova/test/backgroundcolor.java | 40 ++++++++++++++++++ 4 files changed, 109 insertions(+), 6 deletions(-) create mode 100755 test/assets/www/backgroundcolor/index.html create mode 100755 test/src/org/apache/cordova/test/backgroundcolor.java diff --git a/framework/src/org/apache/cordova/DroidGap.java b/framework/src/org/apache/cordova/DroidGap.java index 2af6c9cc..d00d5b50 100755 --- a/framework/src/org/apache/cordova/DroidGap.java +++ b/framework/src/org/apache/cordova/DroidGap.java @@ -330,10 +330,8 @@ public class DroidGap extends Activity implements CordovaInterface { this.init(); } - // TODO @bc - background color doesn't work - // If backgroundColor + // Set backgroundColor this.backgroundColor = this.getIntegerProperty("backgroundColor", Color.BLACK); - LOG.e(TAG, "Setting background color=" + this.backgroundColor); this.root.setBackgroundColor(this.backgroundColor); // If keepRunning @@ -457,7 +455,18 @@ public class DroidGap extends Activity implements CordovaInterface { if (bundle == null) { return defaultValue; } - Boolean p = (Boolean) bundle.get(name); + Boolean p; + try { + p = (Boolean) bundle.get(name); + } catch (ClassCastException e) { + String s = bundle.get(name).toString(); + if ("true".equals(s)) { + p = true; + } + else { + p = false; + } + } if (p == null) { return defaultValue; } @@ -476,7 +485,12 @@ public class DroidGap extends Activity implements CordovaInterface { if (bundle == null) { return defaultValue; } - Integer p = (Integer) bundle.get(name); + Integer p; + try { + p = (Integer) bundle.get(name); + } catch (ClassCastException e) { + p = Integer.parseInt(bundle.get(name).toString()); + } if (p == null) { return defaultValue; } @@ -514,7 +528,12 @@ public class DroidGap extends Activity implements CordovaInterface { if (bundle == null) { return defaultValue; } - Double p = (Double) bundle.get(name); + Double p; + try { + p = (Double) bundle.get(name); + } catch (ClassCastException e) { + p = Double.parseDouble(bundle.get(name).toString()); + } if (p == null) { return defaultValue; } diff --git a/test/AndroidManifest.xml b/test/AndroidManifest.xml index 0d280ba6..06216ece 100755 --- a/test/AndroidManifest.xml +++ b/test/AndroidManifest.xml @@ -150,5 +150,8 @@ + + diff --git a/test/assets/www/backgroundcolor/index.html b/test/assets/www/backgroundcolor/index.html new file mode 100755 index 00000000..0746dcf6 --- /dev/null +++ b/test/assets/www/backgroundcolor/index.html @@ -0,0 +1,41 @@ + + + + + + + Cordova Tests + + + + + +

Background Color Test

+
+

Platform:  , Version:  

+

UUID:  , Name:  

+

Width:  , Height:   + , Color Depth:

+
+
+ Before this page was show, you should have seen the background flash green.
+
+ + diff --git a/test/src/org/apache/cordova/test/backgroundcolor.java b/test/src/org/apache/cordova/test/backgroundcolor.java new file mode 100755 index 00000000..f40a6732 --- /dev/null +++ b/test/src/org/apache/cordova/test/backgroundcolor.java @@ -0,0 +1,40 @@ +/* + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +*/ +package org.apache.cordova.test; + +import android.graphics.Color; +import android.os.Bundle; +import org.apache.cordova.*; + +public class backgroundcolor extends DroidGap { + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + // Properties must be set before init() is called, since some are processed during init(). + + // backgroundColor can also be set in cordova.xml, but you must use the number equivalent of the color. For example, Color.RED is + // + super.setIntegerProperty("backgroundColor", Color.GREEN); + + super.init(); + super.loadUrl("file:///android_asset/www/backgroundcolor/index.html"); + } + +} From dd624ccd9c0e628e46eefb763c3e01b73d90723d Mon Sep 17 00:00:00 2001 From: Bryce Curtis Date: Wed, 16 May 2012 16:47:24 -0500 Subject: [PATCH 4/6] CB-779: Verify that fullscreen and backgroundColor preferences are set properly - This check-in enables background color and adds test for it. --- test/assets/www/index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/test/assets/www/index.html b/test/assets/www/index.html index d1a770a1..563cbf8c 100755 --- a/test/assets/www/index.html +++ b/test/assets/www/index.html @@ -49,6 +49,7 @@ + From 20db6984750e935b7246ee9d7b21691b21c91776 Mon Sep 17 00:00:00 2001 From: Bryce Curtis Date: Wed, 16 May 2012 16:47:37 -0500 Subject: [PATCH 5/6] Add usage comment. --- test/assets/www/fullscreen/index.html | 3 ++- test/src/org/apache/cordova/test/fullscreen.java | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/test/assets/www/fullscreen/index.html b/test/assets/www/fullscreen/index.html index ab910acc..8fa24dad 100755 --- a/test/assets/www/fullscreen/index.html +++ b/test/assets/www/fullscreen/index.html @@ -35,7 +35,8 @@ , Color Depth:
- The app should take over the entire screen. The top Android status bar should not be shown.
+ The app should take over the entire screen.
+ The top Android status bar should not be shown.
diff --git a/test/src/org/apache/cordova/test/fullscreen.java b/test/src/org/apache/cordova/test/fullscreen.java index 8b146247..7fcd79b9 100755 --- a/test/src/org/apache/cordova/test/fullscreen.java +++ b/test/src/org/apache/cordova/test/fullscreen.java @@ -19,10 +19,7 @@ package org.apache.cordova.test; import android.os.Bundle; -import android.webkit.WebView; - import org.apache.cordova.*; -import org.apache.cordova.api.LOG; public class fullscreen extends DroidGap { @Override @@ -30,6 +27,9 @@ public class fullscreen extends DroidGap { super.onCreate(savedInstanceState); // Properties must be set before init() is called, since some are processed during init(). + + // fullscreen can also be set in cordova.xml. For example, + // super.setBooleanProperty("fullscreen", true); super.init(); From c178031f060380fc1db7ea1d6922c195e62011a7 Mon Sep 17 00:00:00 2001 From: Bryce Curtis Date: Wed, 16 May 2012 16:48:06 -0500 Subject: [PATCH 6/6] Remove unused imports. --- test/src/org/apache/cordova/test/background.java | 1 - test/src/org/apache/cordova/test/basicauth.java | 3 --- 2 files changed, 4 deletions(-) diff --git a/test/src/org/apache/cordova/test/background.java b/test/src/org/apache/cordova/test/background.java index 2b95a5fc..7a0ba89b 100755 --- a/test/src/org/apache/cordova/test/background.java +++ b/test/src/org/apache/cordova/test/background.java @@ -19,7 +19,6 @@ package org.apache.cordova.test; import android.os.Bundle; -import android.webkit.WebView; import org.apache.cordova.*; diff --git a/test/src/org/apache/cordova/test/basicauth.java b/test/src/org/apache/cordova/test/basicauth.java index 4007c97c..a1a71de6 100755 --- a/test/src/org/apache/cordova/test/basicauth.java +++ b/test/src/org/apache/cordova/test/basicauth.java @@ -19,10 +19,7 @@ package org.apache.cordova.test; import android.os.Bundle; -import android.webkit.WebView; - import org.apache.cordova.*; -import org.apache.cordova.api.LOG; public class basicauth extends DroidGap { @Override