mirror of
https://github.com/apache/cordova-android.git
synced 2026-04-23 00:00:09 +08:00
Adding functionality to read a config.xml file with plugin details implemented inside of it
This commit is contained in:
@@ -105,22 +105,61 @@ public class PluginManager {
|
||||
}
|
||||
XmlResourceParser xml = this.ctx.getActivity().getResources().getXml(id);
|
||||
int eventType = -1;
|
||||
String service = "", pluginClass = "";
|
||||
String service = "", pluginClass = "", paramType = "";
|
||||
boolean onload = false;
|
||||
PluginEntry entry = null;
|
||||
boolean insideFeature = false;
|
||||
while (eventType != XmlResourceParser.END_DOCUMENT) {
|
||||
if (eventType == XmlResourceParser.START_TAG) {
|
||||
String strNode = xml.getName();
|
||||
//This is for the old scheme
|
||||
if (strNode.equals("plugin")) {
|
||||
service = xml.getAttributeValue(null, "name");
|
||||
pluginClass = xml.getAttributeValue(null, "value");
|
||||
// System.out.println("Plugin: "+name+" => "+value);
|
||||
onload = "true".equals(xml.getAttributeValue(null, "onload"));
|
||||
entry = new PluginEntry(service, pluginClass, onload);
|
||||
this.addService(entry);
|
||||
} else if (strNode.equals("url-filter")) {
|
||||
this.addService(entry);
|
||||
}
|
||||
//What is this?
|
||||
else if (strNode.equals("url-filter")) {
|
||||
this.urlMap.put(xml.getAttributeValue(null, "value"), service);
|
||||
}
|
||||
else if (strNode.equals("feature")) {
|
||||
insideFeature = true;
|
||||
//Check for supported feature sets (Accelerometer, Geolocation, etc)
|
||||
//Set the bit for reading params
|
||||
String uri = xml.getAttributeValue(null,"name");
|
||||
}
|
||||
else if(strNode.equals("param")) {
|
||||
if(insideFeature)
|
||||
{
|
||||
paramType = xml.getAttributeValue(null, "name");
|
||||
if(paramType.equals("service"))
|
||||
service = xml.getAttributeValue(null, "value");
|
||||
else if(paramType.equals("package"))
|
||||
pluginClass = xml.getAttributeValue(null, "value");
|
||||
if(service.length() > 0 && pluginClass.length() > 0)
|
||||
{
|
||||
onload = "true".equals(xml.getAttributeValue(null, "onload"));
|
||||
entry = new PluginEntry(service, pluginClass, onload);
|
||||
this.addService(entry);
|
||||
service = "";
|
||||
pluginClass = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (eventType == XmlResourceParser.END_TAG)
|
||||
{
|
||||
String strNode = xml.getName();
|
||||
if(strNode.equals("feature"))
|
||||
{
|
||||
//Empty the strings to prevent plugin loading bugs
|
||||
service = "";
|
||||
pluginClass = "";
|
||||
insideFeature = false;
|
||||
}
|
||||
}
|
||||
try {
|
||||
eventType = xml.next();
|
||||
|
||||
Reference in New Issue
Block a user