mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-12 10:42:58 +08:00
[CB-4103] Made config parameters case-insensitive.
For consistency with other platforms (and for readability), UpperCamelCasing is used by default in the code.
This commit is contained in:
parent
7cde444ffe
commit
1167da2027
@ -24,6 +24,7 @@ import java.io.IOException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
@ -102,7 +103,7 @@ public class Config {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (strNode.equals("preference")) {
|
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 1.6 does not support switch-based strings
|
||||||
Java 7 does, but we're using Dalvik, which is apparently not Java.
|
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.
|
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!
|
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");
|
String level = xml.getAttributeValue(null, "value");
|
||||||
LOG.setLogLevel(level);
|
LOG.setLogLevel(level);
|
||||||
} else if (name.equals("splashscreen")) {
|
} else if (name.equalsIgnoreCase("SplashScreen")) {
|
||||||
String value = xml.getAttributeValue(null, "value");
|
String value = xml.getAttributeValue(null, "value");
|
||||||
int resource = 0;
|
int resource = 0;
|
||||||
if (value == null)
|
if (value == null)
|
||||||
@ -126,25 +127,25 @@ public class Config {
|
|||||||
|
|
||||||
action.getIntent().putExtra(name, resource);
|
action.getIntent().putExtra(name, resource);
|
||||||
}
|
}
|
||||||
else if(name.equals("backgroundColor")) {
|
else if(name.equalsIgnoreCase("BackgroundColor")) {
|
||||||
int value = xml.getAttributeIntValue(null, "value", Color.BLACK);
|
int value = xml.getAttributeIntValue(null, "value", Color.BLACK);
|
||||||
action.getIntent().putExtra(name, value);
|
action.getIntent().putExtra(name, value);
|
||||||
}
|
}
|
||||||
else if(name.equals("loadUrlTimeoutValue")) {
|
else if(name.equalsIgnoreCase("LoadUrlTimeoutValue")) {
|
||||||
int value = xml.getAttributeIntValue(null, "value", 20000);
|
int value = xml.getAttributeIntValue(null, "value", 20000);
|
||||||
action.getIntent().putExtra(name, value);
|
action.getIntent().putExtra(name, value);
|
||||||
}
|
}
|
||||||
else if(name.equals("keepRunning"))
|
else if(name.equalsIgnoreCase("KeepRunning"))
|
||||||
{
|
{
|
||||||
boolean value = xml.getAttributeValue(null, "value").equals("true");
|
boolean value = xml.getAttributeValue(null, "value").equals("true");
|
||||||
action.getIntent().putExtra(name, value);
|
action.getIntent().putExtra(name, value);
|
||||||
}
|
}
|
||||||
else if(name.equals("InAppBrowserStorageEnabled"))
|
else if(name.equalsIgnoreCase("InAppBrowserStorageEnabled"))
|
||||||
{
|
{
|
||||||
boolean value = xml.getAttributeValue(null, "value").equals("true");
|
boolean value = xml.getAttributeValue(null, "value").equals("true");
|
||||||
action.getIntent().putExtra(name, value);
|
action.getIntent().putExtra(name, value);
|
||||||
}
|
}
|
||||||
else if(name.equals("disallowOverscroll"))
|
else if(name.equalsIgnoreCase("DisallowOverscroll"))
|
||||||
{
|
{
|
||||||
boolean value = xml.getAttributeValue(null, "value").equals("true");
|
boolean value = xml.getAttributeValue(null, "value").equals("true");
|
||||||
action.getIntent().putExtra(name, value);
|
action.getIntent().putExtra(name, value);
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
package org.apache.cordova;
|
package org.apache.cordova;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
|
|
||||||
@ -281,12 +282,12 @@ public class CordovaActivity extends Activity implements CordovaInterface {
|
|||||||
initCallbackClass = savedInstanceState.getString("callbackClass");
|
initCallbackClass = savedInstanceState.getString("callbackClass");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!this.getBooleanProperty("showTitle", false))
|
if(!this.getBooleanProperty("ShowTitle", false))
|
||||||
{
|
{
|
||||||
getWindow().requestFeature(Window.FEATURE_NO_TITLE);
|
getWindow().requestFeature(Window.FEATURE_NO_TITLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.getBooleanProperty("setFullscreen", false))
|
if(this.getBooleanProperty("SetFullscreen", false))
|
||||||
{
|
{
|
||||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||||
@ -362,7 +363,7 @@ public class CordovaActivity extends Activity implements CordovaInterface {
|
|||||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||||
1.0F));
|
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) {
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.GINGERBREAD) {
|
||||||
this.appView.setOverScrollMode(CordovaWebView.OVER_SCROLL_NEVER);
|
this.appView.setOverScrollMode(CordovaWebView.OVER_SCROLL_NEVER);
|
||||||
}
|
}
|
||||||
@ -391,11 +392,11 @@ public class CordovaActivity extends Activity implements CordovaInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set backgroundColor
|
// Set backgroundColor
|
||||||
this.backgroundColor = this.getIntegerProperty("backgroundColor", Color.BLACK);
|
this.backgroundColor = this.getIntegerProperty("BackgroundColor", Color.BLACK);
|
||||||
this.root.setBackgroundColor(this.backgroundColor);
|
this.root.setBackgroundColor(this.backgroundColor);
|
||||||
|
|
||||||
// If keepRunning
|
// If keepRunning
|
||||||
this.keepRunning = this.getBooleanProperty("keepRunning", true);
|
this.keepRunning = this.getBooleanProperty("KeepRunning", true);
|
||||||
|
|
||||||
// Then load the spinner
|
// Then load the spinner
|
||||||
this.loadSpinner();
|
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
|
// If loadingDialog property, then show the App loading dialog for first page of app
|
||||||
String loading = null;
|
String loading = null;
|
||||||
if ((this.appView == null) || !this.appView.canGoBack()) {
|
if ((this.appView == null) || !this.appView.canGoBack()) {
|
||||||
loading = this.getStringProperty("loadingDialog", null);
|
loading = this.getStringProperty("LoadingDialog", null);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
loading = this.getStringProperty("loadingPageDialog", null);
|
loading = this.getStringProperty("LoadingPageDialog", null);
|
||||||
}
|
}
|
||||||
if (loading != null) {
|
if (loading != null) {
|
||||||
|
|
||||||
@ -451,7 +452,7 @@ public class CordovaActivity extends Activity implements CordovaInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.splashscreenTime = time;
|
this.splashscreenTime = time;
|
||||||
this.splashscreen = this.getIntegerProperty("splashscreen", 0);
|
this.splashscreen = this.getIntegerProperty("SplashScreen", 0);
|
||||||
this.showSplashScreen(this.splashscreenTime);
|
this.showSplashScreen(this.splashscreenTime);
|
||||||
this.appView.loadUrl(url, time);
|
this.appView.loadUrl(url, time);
|
||||||
}
|
}
|
||||||
@ -517,6 +518,7 @@ public class CordovaActivity extends Activity implements CordovaInterface {
|
|||||||
if (bundle == null) {
|
if (bundle == null) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
name = name.toLowerCase(Locale.getDefault());
|
||||||
Boolean p;
|
Boolean p;
|
||||||
try {
|
try {
|
||||||
p = (Boolean) bundle.get(name);
|
p = (Boolean) bundle.get(name);
|
||||||
@ -547,6 +549,7 @@ public class CordovaActivity extends Activity implements CordovaInterface {
|
|||||||
if (bundle == null) {
|
if (bundle == null) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
name = name.toLowerCase(Locale.getDefault());
|
||||||
Integer p;
|
Integer p;
|
||||||
try {
|
try {
|
||||||
p = (Integer) bundle.get(name);
|
p = (Integer) bundle.get(name);
|
||||||
@ -571,6 +574,7 @@ public class CordovaActivity extends Activity implements CordovaInterface {
|
|||||||
if (bundle == null) {
|
if (bundle == null) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
name = name.toLowerCase(Locale.getDefault());
|
||||||
String p = bundle.getString(name);
|
String p = bundle.getString(name);
|
||||||
if (p == null) {
|
if (p == null) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
@ -590,6 +594,7 @@ public class CordovaActivity extends Activity implements CordovaInterface {
|
|||||||
if (bundle == null) {
|
if (bundle == null) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
name = name.toLowerCase(Locale.getDefault());
|
||||||
Double p;
|
Double p;
|
||||||
try {
|
try {
|
||||||
p = (Double) bundle.get(name);
|
p = (Double) bundle.get(name);
|
||||||
@ -610,7 +615,7 @@ public class CordovaActivity extends Activity implements CordovaInterface {
|
|||||||
*/
|
*/
|
||||||
public void setBooleanProperty(String name, boolean value) {
|
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");
|
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) {
|
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");
|
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) {
|
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");
|
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) {
|
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");
|
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
|
@Override
|
||||||
@ -696,7 +701,7 @@ public class CordovaActivity extends Activity implements CordovaInterface {
|
|||||||
|
|
||||||
|
|
||||||
//Code to test CB-3064
|
//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);
|
LOG.d(TAG, "CB-3064: The errorUrl is " + errorUrl);
|
||||||
|
|
||||||
if (this.activityState == ACTIVITY_STARTING) {
|
if (this.activityState == ACTIVITY_STARTING) {
|
||||||
@ -1121,7 +1126,7 @@ public class CordovaActivity extends Activity implements CordovaInterface {
|
|||||||
else {
|
else {
|
||||||
// If the splash dialog is showing don't try to show it again
|
// If the splash dialog is showing don't try to show it again
|
||||||
if (this.splashDialog == null || !this.splashDialog.isShowing()) {
|
if (this.splashDialog == null || !this.splashDialog.isShowing()) {
|
||||||
this.splashscreen = this.getIntegerProperty("splashscreen", 0);
|
this.splashscreen = this.getIntegerProperty("SplashScreen", 0);
|
||||||
this.showSplashScreen(this.splashscreenTime);
|
this.showSplashScreen(this.splashscreenTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user