incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bcur...@apache.org
Subject [4/4] android commit: CB-779: Verify that fullscreen and backgroundColor preferences are set properly - This check-in enables background color and adds test for it.
Date Wed, 16 May 2012 21:48:16 GMT
CB-779: Verify that fullscreen and backgroundColor preferences are set properly - This check-in
enables background color and adds test for it.


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

Branch: refs/heads/CordovaWebView
Commit: ac504768b2ae1393f15ce955b0c2b254137ae4c2
Parents: 2d7b716
Author: Bryce Curtis <curtis.bryce@gmail.com>
Authored: Wed May 16 16:47:02 2012 -0500
Committer: Bryce Curtis <curtis.bryce@gmail.com>
Committed: Wed May 16 16:47:02 2012 -0500

----------------------------------------------------------------------
 framework/src/org/apache/cordova/DroidGap.java     |   31 +++++++++--
 test/AndroidManifest.xml                           |    3 +
 test/assets/www/backgroundcolor/index.html         |   41 +++++++++++++++
 .../org/apache/cordova/test/backgroundcolor.java   |   40 ++++++++++++++
 4 files changed, 109 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/ac504768/framework/src/org/apache/cordova/DroidGap.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/DroidGap.java b/framework/src/org/apache/cordova/DroidGap.java
index 2af6c9c..d00d5b5 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;
         }

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/ac504768/test/AndroidManifest.xml
----------------------------------------------------------------------
diff --git a/test/AndroidManifest.xml b/test/AndroidManifest.xml
index 0d280ba..06216ec 100755
--- a/test/AndroidManifest.xml
+++ b/test/AndroidManifest.xml
@@ -150,5 +150,8 @@
         <activity android:name="fullscreen" android:label="@string/app_name" 
                   android:configChanges="orientation|keyboardHidden">
         </activity>
+        <activity android:name="backgroundcolor" android:label="@string/app_name" 
+                  android:configChanges="orientation|keyboardHidden">
+        </activity>
         </application>
 </manifest> 

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/ac504768/test/assets/www/backgroundcolor/index.html
----------------------------------------------------------------------
diff --git a/test/assets/www/backgroundcolor/index.html b/test/assets/www/backgroundcolor/index.html
new file mode 100755
index 0000000..0746dcf
--- /dev/null
+++ b/test/assets/www/backgroundcolor/index.html
@@ -0,0 +1,41 @@
+<!--
+         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.
+-->
+<!DOCTYPE HTML>
+<html>
+  <head>
+    <meta name="viewport" content="width=320; user-scalable=no" />
+    <meta http-equiv="Content-type" content="text/html; charset=utf-8">
+    <title>Cordova Tests</title>
+      <link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no
title">
+      <script type="text/javascript" charset="utf-8" src="../cordova.js"></script>
+      <script type="text/javascript" charset="utf-8" src="../main.js"></script>
+  </head>
+  <body onload="init();" id="stage" class="theme">
+    <h1>Background Color Test</h1>
+    <div id="info">
+        <h4>Platform: <span id="platform"> &nbsp;</span>,   Version:
<span id="version">&nbsp;</span></h4>
+        <h4>UUID: <span id="uuid"> &nbsp;</span>,   Name: <span
id="name">&nbsp;</span></h4>
+        <h4>Width: <span id="width"> &nbsp;</span>,   Height: <span
id="height">&nbsp;
+                   </span>, Color Depth: <span id="colorDepth"></span></h4>
+     </div>
+     <div id="info">
+     Before this page was show, you should have seen the background flash green.</br>
+     </div>
+  </body>
+</html>

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/ac504768/test/src/org/apache/cordova/test/backgroundcolor.java
----------------------------------------------------------------------
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 0000000..f40a673
--- /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
+        //      <preference name="backgroundColor" value="-65536" />
+        super.setIntegerProperty("backgroundColor", Color.GREEN);
+
+        super.init();
+        super.loadUrl("file:///android_asset/www/backgroundcolor/index.html");
+    }
+
+}


Mime
View raw message