Fix CordovaPreferences not correctly parsing hex values (valueOf->decode)
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/965e4e9b Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/965e4e9b Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/965e4e9b Branch: refs/heads/4.0.x Commit: 965e4e9b19a25cd14edab6705804893e81a3b292 Parents: af77977 Author: Andrew Grieve <[email protected]> Authored: Fri Jul 4 16:27:16 2014 -0400 Committer: Andrew Grieve <[email protected]> Committed: Fri Jul 4 16:27:16 2014 -0400 ---------------------------------------------------------------------- .../org/apache/cordova/CordovaPreferences.java | 21 ++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-android/blob/965e4e9b/framework/src/org/apache/cordova/CordovaPreferences.java ---------------------------------------------------------------------- diff --git a/framework/src/org/apache/cordova/CordovaPreferences.java b/framework/src/org/apache/cordova/CordovaPreferences.java index 9fa1898..4b9eb37 100644 --- a/framework/src/org/apache/cordova/CordovaPreferences.java +++ b/framework/src/org/apache/cordova/CordovaPreferences.java @@ -48,7 +48,7 @@ public class CordovaPreferences { name = name.toLowerCase(Locale.ENGLISH); String value = prefs.get(name); if (value != null) { - return "true".equals(value); + return Boolean.parseBoolean(value); } else if (preferencesBundleExtras != null) { Object bundleValue = preferencesBundleExtras.get(name); if (bundleValue instanceof String) { @@ -64,7 +64,8 @@ public class CordovaPreferences { name = name.toLowerCase(Locale.ENGLISH); String value = prefs.get(name); if (value != null) { - return Integer.valueOf(value); + // Use Integer.decode() can't handle it if the highest bit is set. + return (int)(long)Long.decode(value); } else if (preferencesBundleExtras != null) { Object bundleValue = preferencesBundleExtras.get(name); if (bundleValue instanceof String) { @@ -123,30 +124,30 @@ public class CordovaPreferences { action.getIntent().putExtra(name, resource); } else if(name.equals("backgroundcolor")) { - int asInt = Integer.valueOf(value); + int asInt = (int)(long)Long.decode(value); action.getIntent().putExtra(name, asInt); } else if(name.equals("loadurltimeoutvalue")) { - int asInt = Integer.valueOf(value); + int asInt = Integer.decode(value); action.getIntent().putExtra(name, asInt); } else if(name.equals("splashscreendelay")) { - int asInt = Integer.valueOf(value); + int asInt = Integer.decode(value); action.getIntent().putExtra(name, asInt); } else if(name.equals("keeprunning")) { - boolean asBool = "true".equals(value); + boolean asBool = Boolean.parseBoolean(value); action.getIntent().putExtra(name, asBool); } else if(name.equals("inappbrowserstorageenabled")) { - boolean asBool = "true".equals(value); + boolean asBool = Boolean.parseBoolean(value); action.getIntent().putExtra(name, asBool); } else if(name.equals("disallowoverscroll")) { - boolean asBool = "true".equals(value); + boolean asBool = Boolean.parseBoolean(value); action.getIntent().putExtra(name, asBool); } else @@ -154,5 +155,9 @@ public class CordovaPreferences { action.getIntent().putExtra(name, value); } } + // In the normal case, the intent extras are null until the first call to putExtra(). + if (preferencesBundleExtras == null) { + preferencesBundleExtras = action.getIntent().getExtras(); + } } }
