mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-01 02:12:58 +08:00
Fix CordovaPreferences not correctly parsing hex values (valueOf->decode)
This commit is contained in:
parent
af77977fda
commit
965e4e9b19
@ -48,7 +48,7 @@ public class CordovaPreferences {
|
|||||||
name = name.toLowerCase(Locale.ENGLISH);
|
name = name.toLowerCase(Locale.ENGLISH);
|
||||||
String value = prefs.get(name);
|
String value = prefs.get(name);
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
return "true".equals(value);
|
return Boolean.parseBoolean(value);
|
||||||
} else if (preferencesBundleExtras != null) {
|
} else if (preferencesBundleExtras != null) {
|
||||||
Object bundleValue = preferencesBundleExtras.get(name);
|
Object bundleValue = preferencesBundleExtras.get(name);
|
||||||
if (bundleValue instanceof String) {
|
if (bundleValue instanceof String) {
|
||||||
@ -64,7 +64,8 @@ public class CordovaPreferences {
|
|||||||
name = name.toLowerCase(Locale.ENGLISH);
|
name = name.toLowerCase(Locale.ENGLISH);
|
||||||
String value = prefs.get(name);
|
String value = prefs.get(name);
|
||||||
if (value != null) {
|
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) {
|
} else if (preferencesBundleExtras != null) {
|
||||||
Object bundleValue = preferencesBundleExtras.get(name);
|
Object bundleValue = preferencesBundleExtras.get(name);
|
||||||
if (bundleValue instanceof String) {
|
if (bundleValue instanceof String) {
|
||||||
@ -123,30 +124,30 @@ public class CordovaPreferences {
|
|||||||
action.getIntent().putExtra(name, resource);
|
action.getIntent().putExtra(name, resource);
|
||||||
}
|
}
|
||||||
else if(name.equals("backgroundcolor")) {
|
else if(name.equals("backgroundcolor")) {
|
||||||
int asInt = Integer.valueOf(value);
|
int asInt = (int)(long)Long.decode(value);
|
||||||
action.getIntent().putExtra(name, asInt);
|
action.getIntent().putExtra(name, asInt);
|
||||||
}
|
}
|
||||||
else if(name.equals("loadurltimeoutvalue")) {
|
else if(name.equals("loadurltimeoutvalue")) {
|
||||||
int asInt = Integer.valueOf(value);
|
int asInt = Integer.decode(value);
|
||||||
action.getIntent().putExtra(name, asInt);
|
action.getIntent().putExtra(name, asInt);
|
||||||
}
|
}
|
||||||
else if(name.equals("splashscreendelay")) {
|
else if(name.equals("splashscreendelay")) {
|
||||||
int asInt = Integer.valueOf(value);
|
int asInt = Integer.decode(value);
|
||||||
action.getIntent().putExtra(name, asInt);
|
action.getIntent().putExtra(name, asInt);
|
||||||
}
|
}
|
||||||
else if(name.equals("keeprunning"))
|
else if(name.equals("keeprunning"))
|
||||||
{
|
{
|
||||||
boolean asBool = "true".equals(value);
|
boolean asBool = Boolean.parseBoolean(value);
|
||||||
action.getIntent().putExtra(name, asBool);
|
action.getIntent().putExtra(name, asBool);
|
||||||
}
|
}
|
||||||
else if(name.equals("inappbrowserstorageenabled"))
|
else if(name.equals("inappbrowserstorageenabled"))
|
||||||
{
|
{
|
||||||
boolean asBool = "true".equals(value);
|
boolean asBool = Boolean.parseBoolean(value);
|
||||||
action.getIntent().putExtra(name, asBool);
|
action.getIntent().putExtra(name, asBool);
|
||||||
}
|
}
|
||||||
else if(name.equals("disallowoverscroll"))
|
else if(name.equals("disallowoverscroll"))
|
||||||
{
|
{
|
||||||
boolean asBool = "true".equals(value);
|
boolean asBool = Boolean.parseBoolean(value);
|
||||||
action.getIntent().putExtra(name, asBool);
|
action.getIntent().putExtra(name, asBool);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -154,5 +155,9 @@ public class CordovaPreferences {
|
|||||||
action.getIntent().putExtra(name, value);
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user