Merge conflict on the plugins

This commit is contained in:
Joe Bowser 2012-09-06 15:26:38 -07:00
commit d4b248fbe3
2 changed files with 112 additions and 25 deletions

View File

@ -17,7 +17,7 @@
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
--> -->
<cordova> <widget xmlns="http://www.w3.org/ns/widgets">
<!-- <!--
access elements control the Android whitelist. access elements control the Android whitelist.
Domains are assumed blocked unless set otherwise Domains are assumed blocked unless set otherwise
@ -31,25 +31,73 @@
<log level="DEBUG"/> <log level="DEBUG"/>
<preference name="useBrowserHistory" value="false" /> <preference name="useBrowserHistory" value="false" />
<plugins> <feature name="http://example.org/api/app">
<plugin name="App" value="org.apache.cordova.App"/> <param name="service" value="App" />
<plugin name="Geolocation" value="org.apache.cordova.GeoBroker"/> <param name="package" value="org.apache.cordova.App" />
<plugin name="Device" value="org.apache.cordova.Device"/> </feature>
<plugin name="Accelerometer" value="org.apache.cordova.AccelListener"/> <feature name="http://example.org/api/geolocation">
<plugin name="Compass" value="org.apache.cordova.CompassListener"/> <param name="service" value="Geolocation" />
<plugin name="Media" value="org.apache.cordova.AudioHandler"/> <param name="package" value="org.apache.cordova.GeoBroker" />
<plugin name="Camera" value="org.apache.cordova.CameraLauncher"/> </feature>
<plugin name="Contacts" value="org.apache.cordova.ContactManager"/> <feature name="http://example.org/api/device">
<plugin name="File" value="org.apache.cordova.FileUtils"/> <param name="service" value="Device" />
<plugin name="NetworkStatus" value="org.apache.cordova.NetworkManager"/> <param name="package" value="org.apache.cordova.Device" />
<plugin name="Notification" value="org.apache.cordova.Notification"/> </feature>
<plugin name="Storage" value="org.apache.cordova.Storage"/> <feature name="http://example.org/api/accelerometer">
<plugin name="Temperature" value="org.apache.cordova.TempListener"/> <param name="service" value="Accelerometer" />
<plugin name="FileTransfer" value="org.apache.cordova.FileTransfer"/> <param name="package" value="org.apache.cordova.AccelListener" />
<plugin name="Capture" value="org.apache.cordova.Capture"/> </feature>
<plugin name="Battery" value="org.apache.cordova.BatteryListener"/> <feature name="http://example.org/api/compass">
<plugin name="SplashScreen" value="org.apache.cordova.SplashScreen"/> <param name="service" value="Compass" />
<plugin name="Echo" value="org.apache.cordova.Echo"/> <param name="package" value="org.apache.cordova.CompassListener" />
</plugins> </feature>
</cordova> <feature name="http://example.org/api/media">
<param name="service" value="Media" />
<param name="package" value="org.apache.cordova.Media" />
</feature>
<feature name="http://example.org/api/camera">
<param name="service" value="Camera" />
<param name="package" value="org.apache.cordova.Camera" />
</feature>
<feature name="http://example.org/api/contacts">
<param name="service" value="Contacts" />
<param name="package" value="org.apache.cordova.ContactManager" />
</feature>
<feature name="http://example.org/api/file">
<param name="service" value="File" />
<param name="package" value="org.apache.cordova.FileUtils" />
</feature>
<feature name="http://example.org/api/networkstatus">
<param name="service" value="NetworkStatus" />
<param name="package" value="org.apache.cordova.NetworkManager" />
</feature>
<feature name="http://example.org/api/notification">
<param name="service" value="Notification" />
<param name="package" value="org.apache.cordova.Notification" />
</feature>
<feature name="http://example.org/api/storage">
<param name="service" value="Storage" />
<param name="package" value="org.apache.cordova.Storage" />
</feature>
<feature name="http://example.org/api/temperature">
<param name="service" value="Temperature" />
<param name="package" value="org.apache.cordova.TempListener" />
</feature>
<feature name="http://example.org/api/filetransfer">
<param name="service" value="FileTransfer" />
<param name="package" value="org.apache.cordova.FileTransfer" />
</feature>
<feature name="http://example.org/api/capture">
<param name="service" value="Capture" />
<param name="package" value="org.apache.cordova.Capture" />
</feature>
<feature name="http://example.org/api/battery">
<param name="service" value="Battery" />
<param name="package" value="org.apache.cordova.BatteryListener" />
</feature>
<feature name="http://example.org/api/splashscreen">
<param name="service" value="SpashScreen" />
<param name="package" value="org.apache.cordova.SplashScreen" />
</feature>
</widget>

View File

@ -105,12 +105,14 @@ public class PluginManager {
} }
XmlResourceParser xml = this.ctx.getActivity().getResources().getXml(id); XmlResourceParser xml = this.ctx.getActivity().getResources().getXml(id);
int eventType = -1; int eventType = -1;
String service = "", pluginClass = ""; String service = "", pluginClass = "", paramType = "";
boolean onload = false; boolean onload = false;
PluginEntry entry = null; PluginEntry entry = null;
boolean insideFeature = false;
while (eventType != XmlResourceParser.END_DOCUMENT) { while (eventType != XmlResourceParser.END_DOCUMENT) {
if (eventType == XmlResourceParser.START_TAG) { if (eventType == XmlResourceParser.START_TAG) {
String strNode = xml.getName(); String strNode = xml.getName();
//This is for the old scheme
if (strNode.equals("plugin")) { if (strNode.equals("plugin")) {
service = xml.getAttributeValue(null, "name"); service = xml.getAttributeValue(null, "name");
pluginClass = xml.getAttributeValue(null, "value"); pluginClass = xml.getAttributeValue(null, "value");
@ -118,9 +120,46 @@ public class PluginManager {
onload = "true".equals(xml.getAttributeValue(null, "onload")); onload = "true".equals(xml.getAttributeValue(null, "onload"));
entry = new PluginEntry(service, pluginClass, onload); entry = new PluginEntry(service, pluginClass, onload);
this.addService(entry); this.addService(entry);
} else if (strNode.equals("url-filter")) { }
//What is this?
else if (strNode.equals("url-filter")) {
this.urlMap.put(xml.getAttributeValue(null, "value"), service); 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 { try {
eventType = xml.next(); eventType = xml.next();