You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by bo...@apache.org on 2013/01/30 20:13:54 UTC

[1/2] android commit: CB-2296: Added parsing for Integer and Boolean parameters in config.xml

CB-2296: Added parsing for Integer and Boolean parameters in config.xml


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

Branch: refs/heads/master
Commit: 80b369d6d5257b7fb835d404187a90c06c4e7292
Parents: 381ce53
Author: Joe Bowser <bo...@apache.org>
Authored: Wed Jan 30 11:13:07 2013 -0800
Committer: Joe Bowser <bo...@apache.org>
Committed: Wed Jan 30 11:13:07 2013 -0800

----------------------------------------------------------------------
 framework/src/org/apache/cordova/Config.java |   46 +++++++++++++++++++--
 1 files changed, 42 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/80b369d6/framework/src/org/apache/cordova/Config.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/Config.java b/framework/src/org/apache/cordova/Config.java
index 8353668..7ecb927 100644
--- a/framework/src/org/apache/cordova/Config.java
+++ b/framework/src/org/apache/cordova/Config.java
@@ -35,6 +35,7 @@ import org.xmlpull.v1.XmlPullParserException;
 import android.app.Activity;
 
 import android.content.res.XmlResourceParser;
+import android.graphics.Color;
 
 import android.util.Log;
 
@@ -103,12 +104,49 @@ public class Config {
                 }
                 else if (strNode.equals("preference")) {
                     String name = xml.getAttributeValue(null, "name");
-                    String value = xml.getAttributeValue(null, "value");
-
+                    /* Java 1.6 does not support switch-based strings
+                       Java 7 does, but we're using Dalvik, which is apparently not Java.
+                       Since we're reading XML, this has to be an ugly if/else.
+                       
+                       Also, due to cast issues, each of them has to call their separate putExtra!  
+                       Wheee!!! Isn't Java FUN!?!?!?
+                       
+                       Note: We should probably pass in the classname for the variable splash on splashscreen!
+                       */
+                    if(name.equals("splashscreen")) {
+                        int value = xml.getAttributeIntValue(null, "value", R.drawable.splash);
+                        action.getIntent().putExtra(name, value);
+                        LOG.i("CordovaLog", "Found preference for %s=%d", name, value);
+                        Log.d("CordovaLog", "Found preference for " + name + "=" + Integer.toString(value));
+                    }
+                    else if(name.equals("backgroundColor")) {
+                        int value = xml.getAttributeIntValue(null, "value", Color.BLACK);
+                        action.getIntent().putExtra(name, value);
+                        LOG.i("CordovaLog", "Found preference for %s=%d", name, value);
+                        Log.d("CordovaLog", "Found preference for " + name + "=" + Integer.toString(value));
+                    }
+                    else if(name.equals("loadUrlTimeoutValue")) {
+                        int value = xml.getAttributeIntValue(null, "value", 20000);
+                        action.getIntent().putExtra(name, value);
+                        LOG.i("CordovaLog", "Found preference for %s=%d", name, value);
+                        Log.d("CordovaLog", "Found preference for " + name + "=" + Integer.toString(value));
+                    }
+                    else if(name.equals("keepRunning"))
+                    {
+                        boolean value = xml.getAttributeValue(null, "value").equals("true");
+                        action.getIntent().putExtra(name, value);
+                    }
+                    else
+                    {
+                        String value = xml.getAttributeValue(null, "value");
+                        action.getIntent().putExtra(name, value);
+                        LOG.i("CordovaLog", "Found preference for %s=%s", name, value);
+                        Log.d("CordovaLog", "Found preference for " + name + "=" + value);
+                    }
+                    /*
                     LOG.i("CordovaLog", "Found preference for %s=%s", name, value);
                     Log.d("CordovaLog", "Found preference for " + name + "=" + value);
-
-                    action.getIntent().putExtra(name, value);
+                     */
                 }
                 else if (strNode.equals("content")) {
                     String src = xml.getAttributeValue(null, "src");