cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bows...@apache.org
Subject [04/13] android commit: [CB-1108] Make onload=true settable as a <feature> <param>
Date Fri, 10 May 2013 21:03:29 GMT
[CB-1108] Make onload=true settable as a <feature> <param>

Plus some simplification of code.


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

Branch: refs/heads/3.0.0
Commit: 373da39ac2c9abfbf7866d76e3ace3ecc360ec96
Parents: b7990b7
Author: Andrew Grieve <agrieve@chromium.org>
Authored: Fri May 3 12:18:21 2013 -0400
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Fri May 3 12:18:21 2013 -0400

----------------------------------------------------------------------
 .../src/org/apache/cordova/api/PluginManager.java  |   35 +++++----------
 1 files changed, 11 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/373da39a/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 4cf3450..36e286e 100755
--- a/framework/src/org/apache/cordova/api/PluginManager.java
+++ b/framework/src/org/apache/cordova/api/PluginManager.java
@@ -107,9 +107,8 @@ public class PluginManager {
         }
         XmlResourceParser xml = this.ctx.getActivity().getResources().getXml(id);
         int eventType = -1;
-        String service = "", pluginClass = "", paramType = "", featureName="";
+        String service = "", pluginClass = "", paramType = "";
         boolean onload = false;
-        PluginEntry entry = null;
         boolean insideFeature = false;
         while (eventType != XmlResourceParser.END_DOCUMENT) {
             if (eventType == XmlResourceParser.START_TAG) {
@@ -118,52 +117,40 @@ public class PluginManager {
                 if (strNode.equals("plugin")) {
                     service = xml.getAttributeValue(null, "name");
                     pluginClass = xml.getAttributeValue(null, "value");
-                    // System.out.println("Plugin: "+name+" => "+value);
                     Log.d(TAG, "<plugin> tags are deprecated, please use <features>
instead. <plugin> will no longer work as of Cordova 3.0");
                     onload = "true".equals(xml.getAttributeValue(null, "onload"));
-                    entry = new PluginEntry(service, pluginClass, onload);
-                    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  aka. plugins (Accelerometer, Geolocation,
etc)
                     //Set the bit for reading params
-                   featureName = xml.getAttributeValue(null,"name");
+                    insideFeature = true;
+                    service = xml.getAttributeValue(null, "name");
                 }
-                else if( insideFeature && strNode.equals("param")) {
+                else if (insideFeature && strNode.equals("param")) {
                     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"))
-                    {
-                        service = featureName;
+                    else if (paramType.equals("package") || paramType.equals("android-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 (paramType.equals("onload"))
+                        onload = "true".equals(xml.getAttributeValue(null, "onload"));
                 }
             }
             else if (eventType == XmlResourceParser.END_TAG)
             {
                 String strNode = xml.getName();
-                if(strNode.equals("feature"))
+                if (strNode.equals("feature") || strNode.equals("plugin"))
                 {
+                    PluginEntry entry = new PluginEntry(service, pluginClass, onload);
+                    this.addService(entry);
+
                     //Empty the strings to prevent plugin loading bugs
                     service = "";
                     pluginClass = "";
-                    featureName ="";
                     insideFeature = false;
                 }
             }


Mime
View raw message