You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ma...@apache.org on 2013/07/10 23:29:53 UTC

android commit: [CB-4103] Made config parameters case-insensitive.

Updated Branches:
  refs/heads/master 990d91360 -> b6a01a203


[CB-4103] Made config parameters case-insensitive.

For consistency with other platforms (and for readability), UpperCamelCasing is used by default in the code.

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

Branch: refs/heads/master
Commit: b6a01a203ac7adcac17410cb5b20a467a1405b00
Parents: 990d913
Author: Max Woghiren <ma...@gmail.com>
Authored: Wed Jul 10 17:27:13 2013 -0400
Committer: Max Woghiren <ma...@gmail.com>
Committed: Wed Jul 10 17:27:13 2013 -0400

----------------------------------------------------------------------
 framework/src/org/apache/cordova/Config.java    | 17 +++++-----
 .../src/org/apache/cordova/CordovaActivity.java | 33 +++++++++++---------
 2 files changed, 28 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/b6a01a20/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 4fa31f2..1a522de 100644
--- a/framework/src/org/apache/cordova/Config.java
+++ b/framework/src/org/apache/cordova/Config.java
@@ -24,6 +24,7 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.Locale;
 
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -102,7 +103,7 @@ public class Config {
                     }
                 }
                 else if (strNode.equals("preference")) {
-                    String name = xml.getAttributeValue(null, "name");
+                    String name = xml.getAttributeValue(null, "name").toLowerCase(Locale.getDefault());
                     /* 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.
@@ -112,10 +113,10 @@ public class Config {
                        
                        Note: We should probably pass in the classname for the variable splash on splashscreen!
                        */
-                    if (name.equals("loglevel")) {
+                    if (name.equalsIgnoreCase("LogLevel")) {
                         String level = xml.getAttributeValue(null, "value");
                         LOG.setLogLevel(level);
-                    } else if (name.equals("splashscreen")) {
+                    } else if (name.equalsIgnoreCase("SplashScreen")) {
                         String value = xml.getAttributeValue(null, "value");
                         int resource = 0;
                         if (value == null)
@@ -126,25 +127,25 @@ public class Config {
                         
                         action.getIntent().putExtra(name, resource);
                     }
-                    else if(name.equals("backgroundColor")) {
+                    else if(name.equalsIgnoreCase("BackgroundColor")) {
                         int value = xml.getAttributeIntValue(null, "value", Color.BLACK);
                         action.getIntent().putExtra(name, value);
                     }
-                    else if(name.equals("loadUrlTimeoutValue")) {
+                    else if(name.equalsIgnoreCase("LoadUrlTimeoutValue")) {
                         int value = xml.getAttributeIntValue(null, "value", 20000);
                         action.getIntent().putExtra(name, value);
                     }
-                    else if(name.equals("keepRunning"))
+                    else if(name.equalsIgnoreCase("KeepRunning"))
                     {
                         boolean value = xml.getAttributeValue(null, "value").equals("true");
                         action.getIntent().putExtra(name, value);
                     }
-                    else if(name.equals("InAppBrowserStorageEnabled"))
+                    else if(name.equalsIgnoreCase("InAppBrowserStorageEnabled"))
                     {
                         boolean value = xml.getAttributeValue(null, "value").equals("true");
                         action.getIntent().putExtra(name, value);
                     }
-                    else if(name.equals("disallowOverscroll"))
+                    else if(name.equalsIgnoreCase("DisallowOverscroll"))
                     {
                         boolean value = xml.getAttributeValue(null, "value").equals("true");
                         action.getIntent().putExtra(name, value);

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/b6a01a20/framework/src/org/apache/cordova/CordovaActivity.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CordovaActivity.java b/framework/src/org/apache/cordova/CordovaActivity.java
index 78c806d..fd6fc8e 100755
--- a/framework/src/org/apache/cordova/CordovaActivity.java
+++ b/framework/src/org/apache/cordova/CordovaActivity.java
@@ -19,6 +19,7 @@
 package org.apache.cordova;
 
 import java.util.HashMap;
+import java.util.Locale;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
@@ -281,12 +282,12 @@ public class CordovaActivity extends Activity implements CordovaInterface {
             initCallbackClass = savedInstanceState.getString("callbackClass");
         }
         
-        if(!this.getBooleanProperty("showTitle", false))
+        if(!this.getBooleanProperty("ShowTitle", false))
         {
             getWindow().requestFeature(Window.FEATURE_NO_TITLE);
         }
 
-        if(this.getBooleanProperty("setFullscreen", false))
+        if(this.getBooleanProperty("SetFullscreen", false))
         {
             getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                     WindowManager.LayoutParams.FLAG_FULLSCREEN);
@@ -362,7 +363,7 @@ public class CordovaActivity extends Activity implements CordovaInterface {
                 ViewGroup.LayoutParams.MATCH_PARENT,
                 1.0F));
 
-        if (this.getBooleanProperty("disallowOverscroll", false)) {
+        if (this.getBooleanProperty("DisallowOverscroll", false)) {
             if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.GINGERBREAD) {
                 this.appView.setOverScrollMode(CordovaWebView.OVER_SCROLL_NEVER);
             }
@@ -391,11 +392,11 @@ public class CordovaActivity extends Activity implements CordovaInterface {
         }
 
         // Set backgroundColor
-        this.backgroundColor = this.getIntegerProperty("backgroundColor", Color.BLACK);
+        this.backgroundColor = this.getIntegerProperty("BackgroundColor", Color.BLACK);
         this.root.setBackgroundColor(this.backgroundColor);
 
         // If keepRunning
-        this.keepRunning = this.getBooleanProperty("keepRunning", true);
+        this.keepRunning = this.getBooleanProperty("KeepRunning", true);
 
         // Then load the spinner
         this.loadSpinner();
@@ -411,10 +412,10 @@ public class CordovaActivity extends Activity implements CordovaInterface {
         // If loadingDialog property, then show the App loading dialog for first page of app
         String loading = null;
         if ((this.appView == null) || !this.appView.canGoBack()) {
-            loading = this.getStringProperty("loadingDialog", null);
+            loading = this.getStringProperty("LoadingDialog", null);
         }
         else {
-            loading = this.getStringProperty("loadingPageDialog", null);
+            loading = this.getStringProperty("LoadingPageDialog", null);
         }
         if (loading != null) {
 
@@ -451,7 +452,7 @@ public class CordovaActivity extends Activity implements CordovaInterface {
         }
 
         this.splashscreenTime = time;
-        this.splashscreen = this.getIntegerProperty("splashscreen", 0);
+        this.splashscreen = this.getIntegerProperty("SplashScreen", 0);
         this.showSplashScreen(this.splashscreenTime);
         this.appView.loadUrl(url, time);
     }
@@ -517,6 +518,7 @@ public class CordovaActivity extends Activity implements CordovaInterface {
         if (bundle == null) {
             return defaultValue;
         }
+        name = name.toLowerCase(Locale.getDefault());
         Boolean p;
         try {
             p = (Boolean) bundle.get(name);
@@ -547,6 +549,7 @@ public class CordovaActivity extends Activity implements CordovaInterface {
         if (bundle == null) {
             return defaultValue;
         }
+        name = name.toLowerCase(Locale.getDefault());
         Integer p;
         try {
             p = (Integer) bundle.get(name);
@@ -571,6 +574,7 @@ public class CordovaActivity extends Activity implements CordovaInterface {
         if (bundle == null) {
             return defaultValue;
         }
+        name = name.toLowerCase(Locale.getDefault());
         String p = bundle.getString(name);
         if (p == null) {
             return defaultValue;
@@ -590,6 +594,7 @@ public class CordovaActivity extends Activity implements CordovaInterface {
         if (bundle == null) {
             return defaultValue;
         }
+        name = name.toLowerCase(Locale.getDefault());
         Double p;
         try {
             p = (Double) bundle.get(name);
@@ -610,7 +615,7 @@ public class CordovaActivity extends Activity implements CordovaInterface {
      */
     public void setBooleanProperty(String name, boolean value) {
         Log.d(TAG, "Setting boolean properties in CordovaActivity will be deprecated in 3.0 on July 2013, please use config.xml");
-        this.getIntent().putExtra(name, value);
+        this.getIntent().putExtra(name.toLowerCase(), value);
     }
 
     /**
@@ -621,7 +626,7 @@ public class CordovaActivity extends Activity implements CordovaInterface {
      */
     public void setIntegerProperty(String name, int value) {
         Log.d(TAG, "Setting integer properties in CordovaActivity will be deprecated in 3.0 on July 2013, please use config.xml");
-        this.getIntent().putExtra(name, value);
+        this.getIntent().putExtra(name.toLowerCase(), value);
     }
 
     /**
@@ -632,7 +637,7 @@ public class CordovaActivity extends Activity implements CordovaInterface {
      */
     public void setStringProperty(String name, String value) {
         Log.d(TAG, "Setting string properties in CordovaActivity will be deprecated in 3.0 on July 2013, please use config.xml");
-        this.getIntent().putExtra(name, value);
+        this.getIntent().putExtra(name.toLowerCase(), value);
     }
 
     /**
@@ -643,7 +648,7 @@ public class CordovaActivity extends Activity implements CordovaInterface {
      */
     public void setDoubleProperty(String name, double value) {
         Log.d(TAG, "Setting double properties in CordovaActivity will be deprecated in 3.0 on July 2013, please use config.xml");
-        this.getIntent().putExtra(name, value);
+        this.getIntent().putExtra(name.toLowerCase(), value);
     }
 
     @Override
@@ -696,7 +701,7 @@ public class CordovaActivity extends Activity implements CordovaInterface {
         
 
         //Code to test CB-3064
-        String errorUrl = this.getStringProperty("errorUrl", null);
+        String errorUrl = this.getStringProperty("ErrorUrl", null);
         LOG.d(TAG, "CB-3064: The errorUrl is " + errorUrl);
           
         if (this.activityState == ACTIVITY_STARTING) {
@@ -1121,7 +1126,7 @@ public class CordovaActivity extends Activity implements CordovaInterface {
             else {
                 // If the splash dialog is showing don't try to show it again
                 if (this.splashDialog == null || !this.splashDialog.isShowing()) {
-                    this.splashscreen = this.getIntegerProperty("splashscreen", 0);
+                    this.splashscreen = this.getIntegerProperty("SplashScreen", 0);
                     this.showSplashScreen(this.splashscreenTime);
                 }
             }