mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-22 08:53:24 +08:00
[CB-1108] Convert config.xml from <plugin> to <feature>
This unifies the config.xml used by iOS and Android. Now <feature> tags can be used to add plugins. The changes are non-intrusive so the older versions of the config.xml can still be used after this change. The value of a param named "android-package" determines the class for the plugin.
This commit is contained in:
parent
d226818be3
commit
4b9047b7d8
@ -1,60 +1,85 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!--
|
<widget xmlns = "http://www.w3.org/ns/widgets"
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
id = "io.cordova.helloCordova"
|
||||||
or more contributor license agreements. See the NOTICE file
|
version = "2.0.0">
|
||||||
distributed with this work for additional information
|
<name>Hello Cordova</name>
|
||||||
regarding copyright ownership. The ASF licenses this file
|
|
||||||
to you under the Apache License, Version 2.0 (the
|
|
||||||
"License"); you may not use this file except in compliance
|
|
||||||
with the License. You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
<description>
|
||||||
|
A sample Apache Cordova application that responds to the deviceready event.
|
||||||
|
</description>
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing,
|
<author href="http://cordova.io" email="callback-dev@incubator.apache.org">
|
||||||
software distributed under the License is distributed on an
|
Apache Cordova Team
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
</author>
|
||||||
KIND, either express or implied. See the License for the
|
|
||||||
specific language governing permissions and limitations
|
|
||||||
under the License.
|
|
||||||
-->
|
|
||||||
<cordova>
|
|
||||||
<!--
|
|
||||||
access elements control the Android whitelist.
|
|
||||||
Domains are assumed blocked unless set otherwise
|
|
||||||
-->
|
|
||||||
|
|
||||||
<access origin="http://127.0.0.1*"/> <!-- allow local pages -->
|
<access origin="*"/>
|
||||||
|
|
||||||
<!-- <access origin="https://example.com" /> allow any secure requests to example.com -->
|
|
||||||
<!-- <access origin="https://example.com" subdomains="true" /> such as above, but including subdomains, such as www -->
|
|
||||||
<access origin=".*"/>
|
|
||||||
|
|
||||||
<!-- <content src="http://mysite.com/myapp.html" /> for external pages -->
|
<!-- <content src="http://mysite.com/myapp.html" /> for external pages -->
|
||||||
<content src="index.html" />
|
<content src="index.html" />
|
||||||
|
|
||||||
<log level="DEBUG"/>
|
<log level="DEBUG"/>
|
||||||
|
|
||||||
|
<!-- Preferences for Android -->
|
||||||
<preference name="useBrowserHistory" value="true" />
|
<preference name="useBrowserHistory" value="true" />
|
||||||
<preference name="exit-on-suspend" value="false" />
|
<preference name="exit-on-suspend" value="false" />
|
||||||
<plugins>
|
|
||||||
<plugin name="App" value="org.apache.cordova.App"/>
|
|
||||||
<plugin name="Geolocation" value="org.apache.cordova.GeoBroker"/>
|
|
||||||
<plugin name="Device" value="org.apache.cordova.Device"/>
|
|
||||||
<plugin name="Accelerometer" value="org.apache.cordova.AccelListener"/>
|
|
||||||
<plugin name="Compass" value="org.apache.cordova.CompassListener"/>
|
|
||||||
<plugin name="Media" value="org.apache.cordova.AudioHandler"/>
|
|
||||||
<plugin name="Camera" value="org.apache.cordova.CameraLauncher"/>
|
|
||||||
<plugin name="Contacts" value="org.apache.cordova.ContactManager"/>
|
|
||||||
<plugin name="File" value="org.apache.cordova.FileUtils"/>
|
|
||||||
<plugin name="NetworkStatus" value="org.apache.cordova.NetworkManager"/>
|
|
||||||
<plugin name="Notification" value="org.apache.cordova.Notification"/>
|
|
||||||
<plugin name="Storage" value="org.apache.cordova.Storage"/>
|
|
||||||
<plugin name="FileTransfer" value="org.apache.cordova.FileTransfer"/>
|
|
||||||
<plugin name="Capture" value="org.apache.cordova.Capture"/>
|
|
||||||
<plugin name="Battery" value="org.apache.cordova.BatteryListener"/>
|
|
||||||
<plugin name="SplashScreen" value="org.apache.cordova.SplashScreen"/>
|
|
||||||
<plugin name="Echo" value="org.apache.cordova.Echo" />
|
|
||||||
<plugin name="Globalization" value="org.apache.cordova.Globalization"/>
|
|
||||||
<plugin name="InAppBrowser" value="org.apache.cordova.InAppBrowser"/>
|
|
||||||
</plugins>
|
|
||||||
</cordova>
|
|
||||||
|
|
||||||
|
<feature name="App">
|
||||||
|
<param name="android-package" value="org.apache.cordova.App"/>
|
||||||
|
</feature>
|
||||||
|
<feature name="Geolocation">
|
||||||
|
<param name="android-package" value="org.apache.cordova.GeoBroker"/>
|
||||||
|
</feature>
|
||||||
|
<feature name="Device">
|
||||||
|
<param name="android-package" value="org.apache.cordova.Device"/>
|
||||||
|
</feature>
|
||||||
|
<feature name="Accelerometer">
|
||||||
|
<param name="android-package" value="org.apache.cordova.AccelListener"/>
|
||||||
|
</feature>
|
||||||
|
<feature name="Compass">
|
||||||
|
<param name="android-package" value="org.apache.cordova.CompassListener"/>
|
||||||
|
</feature>
|
||||||
|
<feature name="Media">
|
||||||
|
<param name="android-package" value="org.apache.cordova.AudioHandler"/>
|
||||||
|
</feature>
|
||||||
|
<feature name="Camera">
|
||||||
|
<param name="android-package" value="org.apache.cordova.CameraLauncher"/>
|
||||||
|
</feature>
|
||||||
|
<feature name="Contacts">
|
||||||
|
<param name="android-package" value="org.apache.cordova.ContactManager"/>
|
||||||
|
</feature>
|
||||||
|
<feature name="File">
|
||||||
|
<param name="android-package" value="org.apache.cordova.FileUtils"/>
|
||||||
|
</feature>
|
||||||
|
<feature name="NetworkStatus">
|
||||||
|
<param name="android-package" value="org.apache.cordova.NetworkManager"/>
|
||||||
|
</feature>
|
||||||
|
<feature name="Notification">
|
||||||
|
<param name="android-package" value="org.apache.cordova.Notification"/>
|
||||||
|
</feature>
|
||||||
|
<feature name="Storage">
|
||||||
|
<param name="android-package" value="org.apache.cordova.Storage"/>
|
||||||
|
</feature>
|
||||||
|
<feature name="FileTransfer">
|
||||||
|
<param name="android-package" value="org.apache.cordova.FileTransfer"/>
|
||||||
|
</feature>
|
||||||
|
<feature name="Capture">
|
||||||
|
<param name="android-package" value="org.apache.cordova.Capture"/>
|
||||||
|
</feature>
|
||||||
|
<feature name="Battery">
|
||||||
|
<param name="android-package" value="org.apache.cordova.BatteryListener"/>
|
||||||
|
</feature>
|
||||||
|
<feature name="SplashScreen">
|
||||||
|
<param name="android-package" value="org.apache.cordova.SplashScreen"/>
|
||||||
|
</feature>
|
||||||
|
<feature name="Echo">
|
||||||
|
<param name="android-package" value="org.apache.cordova.Echo"/>
|
||||||
|
</feature>
|
||||||
|
<feature name="Globalization">
|
||||||
|
<param name="android-package" value="org.apache.cordova.Globalization"/>
|
||||||
|
</feature>
|
||||||
|
<feature name="InAppBrowser">
|
||||||
|
<param name="android-package" value="org.apache.cordova.InAppBrowser"/>
|
||||||
|
</feature>
|
||||||
|
|
||||||
|
</widget>
|
||||||
|
@ -107,7 +107,7 @@ 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 = "", paramType = "";
|
String service = "", pluginClass = "", paramType = "", featureName="";
|
||||||
boolean onload = false;
|
boolean onload = false;
|
||||||
PluginEntry entry = null;
|
PluginEntry entry = null;
|
||||||
boolean insideFeature = false;
|
boolean insideFeature = false;
|
||||||
@ -130,26 +130,28 @@ public class PluginManager {
|
|||||||
}
|
}
|
||||||
else if (strNode.equals("feature")) {
|
else if (strNode.equals("feature")) {
|
||||||
insideFeature = true;
|
insideFeature = true;
|
||||||
//Check for supported feature sets (Accelerometer, Geolocation, etc)
|
//Check for supported feature sets aka. plugins (Accelerometer, Geolocation, etc)
|
||||||
//Set the bit for reading params
|
//Set the bit for reading params
|
||||||
String uri = xml.getAttributeValue(null,"name");
|
featureName = xml.getAttributeValue(null,"name");
|
||||||
}
|
}
|
||||||
else if(strNode.equals("param")) {
|
else if( insideFeature && strNode.equals("param")) {
|
||||||
if(insideFeature)
|
paramType = xml.getAttributeValue(null, "name");
|
||||||
|
if (paramType.equals("service")) // check if it is using the older service param
|
||||||
|
service = xml.getAttributeValue(null, "value");
|
||||||
|
else if (paramType.equals("package"))
|
||||||
|
pluginClass = xml.getAttributeValue(null, "value");
|
||||||
|
else if (paramType.equals("android-package"))
|
||||||
{
|
{
|
||||||
paramType = xml.getAttributeValue(null, "name");
|
service = featureName;
|
||||||
if(paramType.equals("service"))
|
pluginClass = xml.getAttributeValue(null,"value");
|
||||||
service = xml.getAttributeValue(null, "value");
|
}
|
||||||
else if(paramType.equals("package"))
|
if (service.length() > 0 && pluginClass.length() > 0) {
|
||||||
pluginClass = xml.getAttributeValue(null, "value");
|
onload = "true".equals(xml.getAttributeValue(null,
|
||||||
if(service.length() > 0 && pluginClass.length() > 0)
|
"onload"));
|
||||||
{
|
entry = new PluginEntry(service, pluginClass, onload);
|
||||||
onload = "true".equals(xml.getAttributeValue(null, "onload"));
|
this.addService(entry);
|
||||||
entry = new PluginEntry(service, pluginClass, onload);
|
service = "";
|
||||||
this.addService(entry);
|
pluginClass = "";
|
||||||
service = "";
|
|
||||||
pluginClass = "";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -161,6 +163,7 @@ public class PluginManager {
|
|||||||
//Empty the strings to prevent plugin loading bugs
|
//Empty the strings to prevent plugin loading bugs
|
||||||
service = "";
|
service = "";
|
||||||
pluginClass = "";
|
pluginClass = "";
|
||||||
|
featureName ="";
|
||||||
insideFeature = false;
|
insideFeature = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,57 +1,86 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!--
|
<widget xmlns = "http://www.w3.org/ns/widgets"
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
id = "io.cordova.helloCordova"
|
||||||
or more contributor license agreements. See the NOTICE file
|
version = "2.0.0">
|
||||||
distributed with this work for additional information
|
<name>Hello Cordova</name>
|
||||||
regarding copyright ownership. The ASF licenses this file
|
|
||||||
to you under the Apache License, Version 2.0 (the
|
|
||||||
"License"); you may not use this file except in compliance
|
|
||||||
with the License. You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
<description>
|
||||||
|
A sample Apache Cordova application that responds to the deviceready event.
|
||||||
|
</description>
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing,
|
<author href="http://cordova.io" email="callback-dev@incubator.apache.org">
|
||||||
software distributed under the License is distributed on an
|
Apache Cordova Team
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
</author>
|
||||||
KIND, either express or implied. See the License for the
|
|
||||||
specific language governing permissions and limitations
|
|
||||||
under the License.
|
|
||||||
-->
|
|
||||||
<cordova>
|
|
||||||
<!--
|
|
||||||
access elements control the Android whitelist.
|
|
||||||
Domains are assumed blocked unless set otherwise
|
|
||||||
-->
|
|
||||||
|
|
||||||
<access origin="http://127.0.0.1*"/> <!-- allow local pages -->
|
<access origin="*"/>
|
||||||
|
|
||||||
|
|
||||||
<!-- <access origin="https://example.com" /> allow any secure requests to example.com -->
|
<!-- <content src="http://mysite.com/myapp.html" /> for external pages -->
|
||||||
<!-- <access origin="https://example.com" subdomains="true" /> such as above, but including subdomains, such as www -->
|
<content src="index.html" />
|
||||||
<access origin=".*"/>
|
|
||||||
|
|
||||||
<log level="DEBUG"/>
|
<log level="DEBUG"/>
|
||||||
<preference name="useBrowserHistory" value="true" />
|
|
||||||
<plugins>
|
<!-- Preferences for Android -->
|
||||||
<plugin name="App" value="org.apache.cordova.App"/>
|
<preference name="useBrowserHistory" value="true" />
|
||||||
<plugin name="Activity" value="org.apache.cordova.test.ActivityPlugin"/>
|
<preference name="exit-on-suspend" value="false" />
|
||||||
<plugin name="Geolocation" value="org.apache.cordova.GeoBroker"/>
|
|
||||||
<plugin name="Device" value="org.apache.cordova.Device"/>
|
<feature name="App">
|
||||||
<plugin name="Accelerometer" value="org.apache.cordova.AccelListener"/>
|
<param name="android-package" value="org.apache.cordova.App"/>
|
||||||
<plugin name="Compass" value="org.apache.cordova.CompassListener"/>
|
</feature>
|
||||||
<plugin name="Media" value="org.apache.cordova.AudioHandler"/>
|
<feature name="Geolocation">
|
||||||
<plugin name="Camera" value="org.apache.cordova.CameraLauncher"/>
|
<param name="android-package" value="org.apache.cordova.GeoBroker"/>
|
||||||
<plugin name="Contacts" value="org.apache.cordova.ContactManager"/>
|
</feature>
|
||||||
<plugin name="File" value="org.apache.cordova.FileUtils"/>
|
<feature name="Device">
|
||||||
<plugin name="NetworkStatus" value="org.apache.cordova.NetworkManager"/>
|
<param name="android-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="Accelerometer">
|
||||||
<plugin name="FileTransfer" value="org.apache.cordova.FileTransfer"/>
|
<param name="android-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="Compass">
|
||||||
<plugin name="SplashScreen" value="org.apache.cordova.SplashScreen"/>
|
<param name="android-package" value="org.apache.cordova.CompassListener"/>
|
||||||
<plugin name="Echo" value="org.apache.cordova.Echo" />
|
</feature>
|
||||||
<plugin name="Globalization" value="org.apache.cordova.Globalization"/>
|
<feature name="Media">
|
||||||
<plugin name="InAppBrowser" value="org.apache.cordova.InAppBrowser"/>
|
<param name="android-package" value="org.apache.cordova.AudioHandler"/>
|
||||||
</plugins>
|
</feature>
|
||||||
</cordova>
|
<feature name="Camera">
|
||||||
|
<param name="android-package" value="org.apache.cordova.CameraLauncher"/>
|
||||||
|
</feature>
|
||||||
|
<feature name="Contacts">
|
||||||
|
<param name="android-package" value="org.apache.cordova.ContactManager"/>
|
||||||
|
</feature>
|
||||||
|
<feature name="File">
|
||||||
|
<param name="android-package" value="org.apache.cordova.FileUtils"/>
|
||||||
|
</feature>
|
||||||
|
<feature name="NetworkStatus">
|
||||||
|
<param name="android-package" value="org.apache.cordova.NetworkManager"/>
|
||||||
|
</feature>
|
||||||
|
<feature name="Notification">
|
||||||
|
<param name="android-package" value="org.apache.cordova.Notification"/>
|
||||||
|
</feature>
|
||||||
|
<feature name="Storage">
|
||||||
|
<param name="android-package" value="org.apache.cordova.Storage"/>
|
||||||
|
</feature>
|
||||||
|
<feature name="FileTransfer">
|
||||||
|
<param name="android-package" value="org.apache.cordova.FileTransfer"/>
|
||||||
|
</feature>
|
||||||
|
<feature name="Capture">
|
||||||
|
<param name="android-package" value="org.apache.cordova.Capture"/>
|
||||||
|
</feature>
|
||||||
|
<feature name="Battery">
|
||||||
|
<param name="android-package" value="org.apache.cordova.BatteryListener"/>
|
||||||
|
</feature>
|
||||||
|
<feature name="SplashScreen">
|
||||||
|
<param name="android-package" value="org.apache.cordova.SplashScreen"/>
|
||||||
|
</feature>
|
||||||
|
<feature name="Echo">
|
||||||
|
<param name="android-package" value="org.apache.cordova.Echo"/>
|
||||||
|
</feature>
|
||||||
|
<feature name="Globalization">
|
||||||
|
<param name="android-package" value="org.apache.cordova.Globalization"/>
|
||||||
|
</feature>
|
||||||
|
<feature name="InAppBrowser">
|
||||||
|
<param name="android-package" value="org.apache.cordova.InAppBrowser"/>
|
||||||
|
</feature>
|
||||||
|
|
||||||
|
</widget>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user