You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2015/03/18 15:47:56 UTC

android commit: Add `CordovaPlugin.getServiceName()`

Repository: cordova-android
Updated Branches:
  refs/heads/master f6e56b345 -> 15530a482


Add `CordovaPlugin.getServiceName()`


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

Branch: refs/heads/master
Commit: 15530a4820001dc6e4e831e7cac66feeda0632de
Parents: f6e56b3
Author: Andrew Grieve <ag...@chromium.org>
Authored: Wed Mar 18 10:47:23 2015 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Wed Mar 18 10:47:23 2015 -0400

----------------------------------------------------------------------
 framework/src/org/apache/cordova/CordovaPlugin.java | 11 ++++++++++-
 framework/src/org/apache/cordova/PluginManager.java |  4 ++--
 2 files changed, 12 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/15530a48/framework/src/org/apache/cordova/CordovaPlugin.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CordovaPlugin.java b/framework/src/org/apache/cordova/CordovaPlugin.java
index e4b3ace..ee111bc 100644
--- a/framework/src/org/apache/cordova/CordovaPlugin.java
+++ b/framework/src/org/apache/cordova/CordovaPlugin.java
@@ -35,13 +35,15 @@ public class CordovaPlugin {
     public CordovaWebView webView;
     public CordovaInterface cordova;
     protected CordovaPreferences preferences;
+    private String serviceName;
 
     /**
      * Call this after constructing to initialize the plugin.
      * Final because we want to be able to change args without breaking plugins.
      */
-    public final void privateInitialize(CordovaInterface cordova, CordovaWebView webView, CordovaPreferences preferences) {
+    public final void privateInitialize(String serviceName, CordovaInterface cordova, CordovaWebView webView, CordovaPreferences preferences) {
         assert this.cordova == null;
+        this.serviceName = serviceName;
         this.cordova = cordova;
         this.webView = webView;
         this.preferences = preferences;
@@ -62,6 +64,13 @@ public class CordovaPlugin {
      */
     protected void pluginInitialize() {
     }
+
+    /**
+     * Returns the plugin's service name (what you'd use when calling pluginManger.getPlugin())
+     */
+    public String getServiceName() {
+        return serviceName;
+    }
     
     /**
      * Executes the request.

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/15530a48/framework/src/org/apache/cordova/PluginManager.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/PluginManager.java b/framework/src/org/apache/cordova/PluginManager.java
index 72ce8d0..9306009 100755
--- a/framework/src/org/apache/cordova/PluginManager.java
+++ b/framework/src/org/apache/cordova/PluginManager.java
@@ -165,7 +165,7 @@ public class PluginManager {
             } else {
                 ret = instantiatePlugin(pe.pluginClass);
             }
-            ret.privateInitialize(ctx, app, app.getPreferences());
+            ret.privateInitialize(service, ctx, app, app.getPreferences());
             pluginMap.put(service, ret);
         }
         return ret;
@@ -192,7 +192,7 @@ public class PluginManager {
     public void addService(PluginEntry entry) {
         this.entryMap.put(entry.service, entry);
         if (entry.plugin != null) {
-            entry.plugin.privateInitialize(ctx, app, app.getPreferences());
+            entry.plugin.privateInitialize(entry.service, ctx, app, app.getPreferences());
             pluginMap.put(entry.service, entry.plugin);
         }
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org