You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by bo...@apache.org on 2012/07/11 20:24:05 UTC

android commit: Combining plugins.xml and cordova.xml to make config.xml

Updated Branches:
  refs/heads/master 2eb4c5e96 -> b486711d6


Combining plugins.xml and cordova.xml to make config.xml


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/commit/b486711d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/tree/b486711d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/diff/b486711d

Branch: refs/heads/master
Commit: b486711d68dc6426b58142143f938090605afbeb
Parents: 2eb4c5e
Author: Joe Bowser <bo...@apache.org>
Authored: Wed Jul 11 11:23:31 2012 -0700
Committer: Joe Bowser <bo...@apache.org>
Committed: Wed Jul 11 11:23:31 2012 -0700

----------------------------------------------------------------------
 framework/res/xml/config.xml                       |   54 +++++++++++++++
 .../src/org/apache/cordova/CordovaWebView.java     |    7 ++-
 .../src/org/apache/cordova/api/PluginManager.java  |   17 +++--
 3 files changed, 72 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/b486711d/framework/res/xml/config.xml
----------------------------------------------------------------------
diff --git a/framework/res/xml/config.xml b/framework/res/xml/config.xml
new file mode 100644
index 0000000..d37aba5
--- /dev/null
+++ b/framework/res/xml/config.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+       Licensed to the Apache Software Foundation (ASF) under one
+       or more contributor license agreements.  See the NOTICE file
+       distributed with this work for additional information
+       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
+
+       Unless required by applicable law or agreed to in writing,
+       software distributed under the License is distributed on an
+       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+       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="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=".*"/> Allow all domains, suggested development use only -->
+
+    <log level="DEBUG"/>
+    <preference name="useBrowserHistory" 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="Temperature" value="org.apache.cordova.TempListener"/>
+    <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"/>
+</plugins>
+</cordova>
+

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/b486711d/framework/src/org/apache/cordova/CordovaWebView.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CordovaWebView.java b/framework/src/org/apache/cordova/CordovaWebView.java
index ca0dd6d..b3ad35c 100755
--- a/framework/src/org/apache/cordova/CordovaWebView.java
+++ b/framework/src/org/apache/cordova/CordovaWebView.java
@@ -596,7 +596,12 @@ public class CordovaWebView extends WebView {
      *      <log level="DEBUG" />
      */
     private void loadConfiguration() {
-        int id = getResources().getIdentifier("cordova", "xml", this.cordova.getActivity().getPackageName());
+        int id = getResources().getIdentifier("config", "xml", this.cordova.getActivity().getPackageName());
+        if(id == 0)
+        {
+            id = getResources().getIdentifier("cordova", "xml", this.cordova.getActivity().getPackageName());   
+            Log.i("CordovaLog", "config.xml missing, reverting to cordova.xml");
+        }
         if (id == 0) {
             LOG.i("CordovaLog", "cordova.xml missing. Ignoring...");
             return;

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/b486711d/framework/src/org/apache/cordova/api/PluginManager.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/api/PluginManager.java b/framework/src/org/apache/cordova/api/PluginManager.java
index b9df52d..a48de67 100755
--- a/framework/src/org/apache/cordova/api/PluginManager.java
+++ b/framework/src/org/apache/cordova/api/PluginManager.java
@@ -92,9 +92,16 @@ public class PluginManager {
      * Load plugins from res/xml/plugins.xml
      */
     public void loadPlugins() {
-        int id = this.ctx.getActivity().getResources().getIdentifier("plugins", "xml", this.ctx.getActivity().getPackageName());
+        int id = this.ctx.getActivity().getResources().getIdentifier("config", "xml", this.ctx.getActivity().getPackageName());
+        if(id == 0)
+        {
+            id = this.ctx.getActivity().getResources().getIdentifier("plugins", "xml", this.ctx.getActivity().getPackageName());
+            LOG.i(TAG, "Using plugins.xml instead of config.xml.  plugins.xml will eventually be deprecated");
+        }
         if (id == 0) {
             this.pluginConfigurationMissing();
+            //We have the error, we need to exit without crashing!
+            return;
         }
         XmlResourceParser xml = this.ctx.getActivity().getResources().getXml(id);
         int eventType = -1;
@@ -361,9 +368,9 @@ public class PluginManager {
     }
 
     private void pluginConfigurationMissing() {
-        System.err.println("=====================================================================================");
-        System.err.println("ERROR: plugin.xml is missing.  Add res/xml/plugins.xml to your project.");
-        System.err.println("https://git-wip-us.apache.org/repos/asf?p=incubator-cordova-android.git;a=blob;f=framework/res/xml/plugins.xml");
-        System.err.println("=====================================================================================");
+        LOG.e(TAG, "=====================================================================================");
+        LOG.e(TAG, "ERROR: plugin.xml is missing.  Add res/xml/plugins.xml to your project.");
+        LOG.e(TAG, "https://git-wip-us.apache.org/repos/asf?p=incubator-cordova-android.git;a=blob;f=framework/res/xml/plugins.xml");
+        LOG.e(TAG, "=====================================================================================");
     }
 }