diff --git a/bin/templates/project/Activity.java b/bin/templates/project/Activity.java
index 4f87f9fd..0f42d8e8 100644
--- a/bin/templates/project/Activity.java
+++ b/bin/templates/project/Activity.java
@@ -29,7 +29,8 @@ public class __ACTIVITY__ extends DroidGap
{
super.onCreate(savedInstanceState);
Config.init(this);
- super.loadUrl("file:///android_asset/www/index.html");
+ super.loadUrl(Config.getStartUrl());
+ //super.loadUrl("file:///android_asset/www/index.html")
}
}
diff --git a/framework/res/xml/config.xml b/framework/res/xml/config.xml
index b6900078..bc6ca0c7 100644
--- a/framework/res/xml/config.xml
+++ b/framework/res/xml/config.xml
@@ -29,6 +29,9 @@
+
+
+
diff --git a/framework/src/org/apache/cordova/Config.java b/framework/src/org/apache/cordova/Config.java
index 1713d448..83536685 100644
--- a/framework/src/org/apache/cordova/Config.java
+++ b/framework/src/org/apache/cordova/Config.java
@@ -44,6 +44,7 @@ public class Config {
private ArrayList whiteList = new ArrayList();
private HashMap whiteListCache = new HashMap();
+ private String startUrl;
private static Config self = null;
@@ -90,7 +91,7 @@ public class Config {
String origin = xml.getAttributeValue(null, "origin");
String subdomains = xml.getAttributeValue(null, "subdomains");
if (origin != null) {
- addWhiteListEntry(origin, (subdomains != null) && (subdomains.compareToIgnoreCase("true") == 0));
+ this._addWhiteListEntry(origin, (subdomains != null) && (subdomains.compareToIgnoreCase("true") == 0));
}
}
else if (strNode.equals("log")) {
@@ -109,6 +110,25 @@ public class Config {
action.getIntent().putExtra(name, value);
}
+ else if (strNode.equals("content")) {
+ String src = xml.getAttributeValue(null, "src");
+
+ LOG.i("CordovaLog", "Found start page location: %s", src);
+
+ if (src != null) {
+ Pattern schemeRegex = Pattern.compile("^[a-z]+://");
+ Matcher matcher = schemeRegex.matcher(src);
+ if (matcher.find()) {
+ startUrl = src;
+ } else {
+ if (src.charAt(0) == '/') {
+ src = src.substring(1);
+ }
+ startUrl = "file:///android_asset/www/" + src;
+ }
+ }
+ }
+
}
try {
@@ -132,28 +152,33 @@ public class Config {
return;
}
+ self._addWhiteListEntry(origin, subdomains);
+ }
+
+
+ private void _addWhiteListEntry(String origin, boolean subdomains) {
try {
// Unlimited access to network resources
if (origin.compareTo("*") == 0) {
LOG.d(TAG, "Unlimited access to network resources");
- self.whiteList.add(Pattern.compile(".*"));
+ this.whiteList.add(Pattern.compile(".*"));
} else { // specific access
// check if subdomains should be included
// TODO: we should not add more domains if * has already been added
if (subdomains) {
// XXX making it stupid friendly for people who forget to include protocol/SSL
if (origin.startsWith("http")) {
- self.whiteList.add(Pattern.compile(origin.replaceFirst("https?://", "^https?://(.*\\.)?")));
+ this.whiteList.add(Pattern.compile(origin.replaceFirst("https?://", "^https?://(.*\\.)?")));
} else {
- self.whiteList.add(Pattern.compile("^https?://(.*\\.)?" + origin));
+ this.whiteList.add(Pattern.compile("^https?://(.*\\.)?" + origin));
}
LOG.d(TAG, "Origin to allow with subdomains: %s", origin);
} else {
// XXX making it stupid friendly for people who forget to include protocol/SSL
if (origin.startsWith("http")) {
- self.whiteList.add(Pattern.compile(origin.replaceFirst("https?://", "^https?://")));
+ this.whiteList.add(Pattern.compile(origin.replaceFirst("https?://", "^https?://")));
} else {
- self.whiteList.add(Pattern.compile("^https?://" + origin));
+ this.whiteList.add(Pattern.compile("^https?://" + origin));
}
LOG.d(TAG, "Origin to allow: %s", origin);
}
@@ -193,4 +218,11 @@ public class Config {
}
return false;
}
+
+ public static String getStartUrl() {
+ if (self == null || self.startUrl == null) {
+ return "file:///android_asset/www/index.html";
+ }
+ return self.startUrl;
+ }
}