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 2014/07/14 20:18:32 UTC

[01/10] android commit: Displaying error when regex does not match.

Repository: cordova-android
Updated Branches:
  refs/heads/4.0.x b27720283 -> e2b3f76a1
  refs/heads/master 62101e85f -> b934c1be6


Displaying error when regex does not match.

On my ubuntu when `android` is not found typical output is:

```
   /bin/sh: 1: android: not found
```
close #104


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

Branch: refs/heads/4.0.x
Commit: 86a2830d75af5008f239583ccc2231a670092f29
Parents: 9300e97
Author: Ankit Jain <an...@gmail.com>
Authored: Mon Jun 30 23:59:53 2014 +0530
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Mon Jul 14 10:28:13 2014 -0400

----------------------------------------------------------------------
 bin/lib/check_reqs.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/86a2830d/bin/lib/check_reqs.js
----------------------------------------------------------------------
diff --git a/bin/lib/check_reqs.js b/bin/lib/check_reqs.js
index 1c6f0f8..3296acc 100644
--- a/bin/lib/check_reqs.js
+++ b/bin/lib/check_reqs.js
@@ -84,7 +84,7 @@ module.exports.check_android = function() {
         if (stderr.match(/command\snot\sfound/)) {
             return Q.reject(new Error('The command \"android\" failed. Make sure you have the latest Android SDK installed, and the \"android\" command (inside the tools/ folder) is added to your path.'));
         } else {
-            return Q.reject(new Error('An error occurred while listing Android targets'));
+            return Q.reject(new Error('An error occurred while listing Android targets. Error: ' + stderr ));
         }
     });
 }


[10/10] android commit: Merge branch 'master' into 4.0.x (PluginEntry refactor)

Posted by ag...@apache.org.
Merge branch 'master' into 4.0.x (PluginEntry refactor)

Conflicts:
	framework/src/org/apache/cordova/PluginEntry.java
	framework/src/org/apache/cordova/PluginManager.java
	test/src/org/apache/cordova/test/CordovaWebViewTestActivity.java


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

Branch: refs/heads/4.0.x
Commit: e2b3f76a106a3bcc8f822f32275007d63657954f
Parents: b277202 b934c1b
Author: Andrew Grieve <ag...@chromium.org>
Authored: Mon Jul 14 14:18:10 2014 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Mon Jul 14 14:18:10 2014 -0400

----------------------------------------------------------------------
 bin/lib/check_reqs.js                           |   8 +-
 .../src/org/apache/cordova/PluginEntry.java     |  75 ++---------
 .../src/org/apache/cordova/PluginManager.java   | 135 +++++++++++--------
 .../test/CordovaWebViewTestActivity.java        |   3 +-
 4 files changed, 99 insertions(+), 122 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/e2b3f76a/bin/lib/check_reqs.js
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/e2b3f76a/framework/src/org/apache/cordova/PluginEntry.java
----------------------------------------------------------------------
diff --cc framework/src/org/apache/cordova/PluginEntry.java
index e0acfac,03a44da..9782825
--- a/framework/src/org/apache/cordova/PluginEntry.java
+++ b/framework/src/org/apache/cordova/PluginEntry.java
@@@ -18,11 -18,10 +18,8 @@@
   */
  package org.apache.cordova;
  
- import org.apache.cordova.CordovaWebView;
- import org.apache.cordova.CordovaInterface;
 -import java.util.List;
 -
  import org.apache.cordova.CordovaPlugin;
  
- 
  /**
   * This class represents a service entry object.
   */
@@@ -48,15 -45,16 +43,13 @@@ public class PluginEntry 
      /**
       * Flag that indicates the plugin object should be created when PluginManager is initialized.
       */
-     public boolean onload = false;
+     public boolean onload;
  
 -    private List<String> urlFilters;
 -
 -
      /**
-      * @param service               The name of the service
-      * @param plugin                The plugin associated with this entry
+      * Constructs with a CordovaPlugin already instantiated.
       */
      public PluginEntry(String service, CordovaPlugin plugin) {
-         this(service, plugin.getClass().getName(), true);
-         this.plugin = plugin;
 -        this(service, plugin.getClass().getName(), true, plugin, null);
++        this(service, plugin.getClass().getName(), true, plugin);
      }
  
      /**
@@@ -65,57 -63,27 +58,13 @@@
       * @param onload                Create plugin object when HTML page is loaded
       */
      public PluginEntry(String service, String pluginClass, boolean onload) {
 -        this(service, pluginClass, onload, null, null);
 -    }
 -    
 -    @Deprecated // urlFilters are going away
 -    public PluginEntry(String service, String pluginClass, boolean onload, List<String> urlFilters) {
 -        this.service = service;
 -        this.pluginClass = pluginClass;
 -        this.onload = onload;
 -        this.urlFilters = urlFilters;
 -        plugin = null;
++        this(service, pluginClass, onload, null);
+     }
+ 
 -    private PluginEntry(String service, String pluginClass, boolean onload, CordovaPlugin plugin, List<String> urlFilters) {
++    private PluginEntry(String service, String pluginClass, boolean onload, CordovaPlugin plugin) {
          this.service = service;
          this.pluginClass = pluginClass;
          this.onload = onload;
-     }
-     
-     /**
-      * Create plugin object.
-      * If plugin is already created, then just return it.
-      *
-      * @return                      The plugin object
-      */
-     public CordovaPlugin createPlugin(CordovaWebView webView, CordovaInterface ctx) {
-         if (this.plugin != null) {
-             return this.plugin;
-         }
-         try {
-             Class<?> c = getClassByName(this.pluginClass);
-             if (isCordovaPlugin(c)) {
-                 this.plugin = (CordovaPlugin) c.newInstance();
-                 this.plugin.privateInitialize(ctx, webView, webView.getPreferences());
-                 return plugin;
-             }
-         } catch (Exception e) {
-             e.printStackTrace();
-             System.out.println("Error adding plugin " + this.pluginClass + ".");
-         }
-         return null;
-     }
- 
-     /**
-      * Get the class.
-      *
-      * @param clazz
-      * @return a reference to the named class
-      * @throws ClassNotFoundException
-      */
-     private Class<?> getClassByName(final String clazz) throws ClassNotFoundException {
-         Class<?> c = null;
-         if ((clazz != null) && !("".equals(clazz))) {
-             c = Class.forName(clazz);
-         }
-         return c;
-     }
- 
-     /**
-      * Returns whether the given class extends CordovaPlugin.
-      */
-     private boolean isCordovaPlugin(Class<?> c) {
-         if (c != null) {
-             return CordovaPlugin.class.isAssignableFrom(c);
-         }
-         return false;
 -        this.urlFilters = urlFilters;
+         this.plugin = plugin;
      }
 -
 -    public List<String> getUrlFilters() {
 -        return urlFilters;
 -    }
  }

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/e2b3f76a/framework/src/org/apache/cordova/PluginManager.java
----------------------------------------------------------------------
diff --cc framework/src/org/apache/cordova/PluginManager.java
index 23be8e4,689c3c8..9530fef
--- a/framework/src/org/apache/cordova/PluginManager.java
+++ b/framework/src/org/apache/cordova/PluginManager.java
@@@ -56,15 -66,16 +57,15 @@@ public class PluginManager 
          setPluginEntries(pluginEntries);
      }
  
 -    public void setPluginEntries(List<PluginEntry> pluginEntries) {
 +    public Collection<PluginEntry> getPluginEntries() {
-         return entries.values();
++        return entryMap.values();
 +    }
 +
 +    public void setPluginEntries(Collection<PluginEntry> pluginEntries) {
          this.onPause(false);
          this.onDestroy();
-         this.clearPluginObjects();
-         entries.clear();
+         pluginMap.clear();
 -        urlMap.clear();
++        entryMap.clear();
          for (PluginEntry entry : pluginEntries) {
              addService(entry);
          }
@@@ -187,7 -214,16 +195,11 @@@
       * @param entry             The plugin entry
       */
      public void addService(PluginEntry entry) {
-         this.entries.put(entry.service, entry);
+         this.entryMap.put(entry.service, entry);
 -        List<String> urlFilters = entry.getUrlFilters();
 -        if (urlFilters != null) {
 -            urlMap.put(entry.service, urlFilters);
 -        }
+         if (entry.plugin != null) {
+             entry.plugin.privateInitialize(ctx, app, app.getPreferences());
+             pluginMap.put(entry.service, entry.plugin);
+         }
 -
      }
  
      /**
@@@ -272,11 -303,19 +279,10 @@@
          // Instead, plugins should not include <url-filter> and instead ensure
          // that they are loaded before this function is called (either by setting
          // the onload <param> or by making an exec() call to them)
-         for (PluginEntry entry : this.entries.values()) {
-             if (entry.plugin != null) {
-                 if (entry.plugin.onOverrideUrlLoading(url)) {
-                     return true;
-                 }
+         for (PluginEntry entry : this.entryMap.values()) {
 -            List<String> urlFilters = urlMap.get(entry.service);
 -            if (urlFilters != null) {
 -                for (String s : urlFilters) {
 -                    if (url.startsWith(s)) {
 -                        return getPlugin(entry.service).onOverrideUrlLoading(url);
 -                    }
 -                }
 -            } else {
 -                CordovaPlugin plugin = pluginMap.get(entry.service);
 -                if (plugin != null && plugin.onOverrideUrlLoading(url)) {
 -                    return true;
 -                }
++            CordovaPlugin plugin = pluginMap.get(entry.service);
++            if (plugin != null && plugin.onOverrideUrlLoading(url)) {
++                return true;
              }
          }
          return false;

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/e2b3f76a/test/src/org/apache/cordova/test/CordovaWebViewTestActivity.java
----------------------------------------------------------------------
diff --cc test/src/org/apache/cordova/test/CordovaWebViewTestActivity.java
index a078f21,06070cc..6f96e83
--- a/test/src/org/apache/cordova/test/CordovaWebViewTestActivity.java
+++ b/test/src/org/apache/cordova/test/CordovaWebViewTestActivity.java
@@@ -46,7 -48,8 +46,8 @@@ public class CordovaWebViewTestActivit
          setContentView(R.layout.main);
  
          cordovaWebView = (CordovaWebView) findViewById(R.id.cordovaWebView);
+         Config.init(this);
 -        cordovaWebView.init(this, new CordovaWebViewClient(this, cordovaWebView), new CordovaChromeClient(this, cordovaWebView),
 +        cordovaWebView.init(this,
                  Config.getPluginEntries(), Config.getWhitelist(), Config.getPreferences());
  
          cordovaWebView.loadUrl("file:///android_asset/www/index.html");
@@@ -100,4 -103,4 +101,4 @@@
              cordovaWebView.handleDestroy();
          }
      }
--}
++}


[05/10] android commit: Fix broken unit test due to missing Config.init() call

Posted by ag...@apache.org.
Fix broken unit test due to missing Config.init() call


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

Branch: refs/heads/master
Commit: a33cdc9c7b106313eb0952c54a4c07e690e4426c
Parents: 62101e8
Author: Andrew Grieve <ag...@chromium.org>
Authored: Mon Jul 14 14:06:47 2014 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Mon Jul 14 14:06:47 2014 -0400

----------------------------------------------------------------------
 test/src/org/apache/cordova/test/CordovaWebViewTestActivity.java | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/a33cdc9c/test/src/org/apache/cordova/test/CordovaWebViewTestActivity.java
----------------------------------------------------------------------
diff --git a/test/src/org/apache/cordova/test/CordovaWebViewTestActivity.java b/test/src/org/apache/cordova/test/CordovaWebViewTestActivity.java
index e35b6e7..06070cc 100644
--- a/test/src/org/apache/cordova/test/CordovaWebViewTestActivity.java
+++ b/test/src/org/apache/cordova/test/CordovaWebViewTestActivity.java
@@ -48,6 +48,7 @@ public class CordovaWebViewTestActivity extends Activity implements CordovaInter
         setContentView(R.layout.main);
 
         cordovaWebView = (CordovaWebView) findViewById(R.id.cordovaWebView);
+        Config.init(this);
         cordovaWebView.init(this, new CordovaWebViewClient(this, cordovaWebView), new CordovaChromeClient(this, cordovaWebView),
                 Config.getPluginEntries(), Config.getWhitelist(), Config.getPreferences());
 


[08/10] android commit: @Deprecate methods of PluginManager that were never meant to be public

Posted by ag...@apache.org.
@Deprecate methods of PluginManager that were never meant to be public


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

Branch: refs/heads/4.0.x
Commit: b934c1be6a90ac88c077d5bd922c66fa1cf32363
Parents: 145b50a
Author: Andrew Grieve <ag...@chromium.org>
Authored: Mon Jul 14 14:10:19 2014 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Mon Jul 14 14:10:19 2014 -0400

----------------------------------------------------------------------
 framework/src/org/apache/cordova/PluginManager.java | 9 +++++++++
 1 file changed, 9 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/b934c1be/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 eb3e6f9..689c3c8 100755
--- a/framework/src/org/apache/cordova/PluginManager.java
+++ b/framework/src/org/apache/cordova/PluginManager.java
@@ -84,6 +84,7 @@ public class PluginManager {
     /**
      * Init when loading a new HTML page into webview.
      */
+    @Deprecated // Should not be exposed as public.
     public void init() {
         LOG.d(TAG, "init()");
         this.onPause(false);
@@ -99,6 +100,7 @@ public class PluginManager {
     /**
      * Delete all plugin objects.
      */
+    @Deprecated // Should not be exposed as public.
     public void clearPluginObjects() {
         pluginMap.clear();
     }
@@ -106,6 +108,7 @@ public class PluginManager {
     /**
      * Create plugins objects that have onload set.
      */
+    @Deprecated // Should not be exposed as public.
     public void startupPlugins() {
         for (PluginEntry entry : entryMap.values()) {
             if (entry.onload) {
@@ -228,6 +231,7 @@ public class PluginManager {
      *
      * @param multitasking      Flag indicating if multitasking is turned on for app
      */
+    @Deprecated // Should not be public
     public void onPause(boolean multitasking) {
         for (CordovaPlugin plugin : this.pluginMap.values()) {
             plugin.onPause(multitasking);
@@ -239,6 +243,7 @@ public class PluginManager {
      *
      * @param multitasking      Flag indicating if multitasking is turned on for app
      */
+    @Deprecated // Should not be public
     public void onResume(boolean multitasking) {
         for (CordovaPlugin plugin : this.pluginMap.values()) {
             plugin.onResume(multitasking);
@@ -248,6 +253,7 @@ public class PluginManager {
     /**
      * The final call you receive before your activity is destroyed.
      */
+    @Deprecated // Should not be public
     public void onDestroy() {
         for (CordovaPlugin plugin : this.pluginMap.values()) {
             plugin.onDestroy();
@@ -278,6 +284,7 @@ public class PluginManager {
     /**
      * Called when the activity receives a new intent.
      */
+    @Deprecated // Should not be public
     public void onNewIntent(Intent intent) {
         for (CordovaPlugin plugin : this.pluginMap.values()) {
             plugin.onNewIntent(intent);
@@ -290,6 +297,7 @@ public class PluginManager {
      * @param url               The URL that is being changed to.
      * @return                  Return false to allow the URL to load, return true to prevent the URL from loading.
      */
+    @Deprecated // Should not be public
     public boolean onOverrideUrlLoading(String url) {
         // Deprecated way to intercept URLs. (process <url-filter> tags).
         // Instead, plugins should not include <url-filter> and instead ensure
@@ -316,6 +324,7 @@ public class PluginManager {
     /**
      * Called when the app navigates or refreshes.
      */
+    @Deprecated // Should not be public
     public void onReset() {
         for (CordovaPlugin plugin : this.pluginMap.values()) {
             plugin.onReset();


[06/10] android commit: Move plugin instantiation and instance storing logic PluginEntry->PluginManager

Posted by ag...@apache.org.
Move plugin instantiation and instance storing logic PluginEntry->PluginManager

Instantiation and storing of the instance should be owned privately by
PluginManager, not exposed via an unprotected public API. That said,
this refactoring does not make any breaking changes to the public API,
except for removing the createPlugin call in PluginEntry, which should
not be called by anyone other than PluginManager anyway.


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

Branch: refs/heads/4.0.x
Commit: 145b50a320edfa8b5397849fc20a6295f8823ff6
Parents: a33cdc9
Author: Andrew Grieve <ag...@chromium.org>
Authored: Mon Jul 14 14:08:27 2014 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Mon Jul 14 14:08:27 2014 -0400

----------------------------------------------------------------------
 .../src/org/apache/cordova/PluginEntry.java     |  84 +++----------
 .../src/org/apache/cordova/PluginManager.java   | 122 +++++++++++--------
 2 files changed, 88 insertions(+), 118 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/145b50a3/framework/src/org/apache/cordova/PluginEntry.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/PluginEntry.java b/framework/src/org/apache/cordova/PluginEntry.java
index e94cf1c..03a44da 100755
--- a/framework/src/org/apache/cordova/PluginEntry.java
+++ b/framework/src/org/apache/cordova/PluginEntry.java
@@ -20,11 +20,8 @@ package org.apache.cordova;
 
 import java.util.List;
 
-import org.apache.cordova.CordovaWebView;
-import org.apache.cordova.CordovaInterface;
 import org.apache.cordova.CordovaPlugin;
 
-
 /**
  * This class represents a service entry object.
  */
@@ -33,34 +30,31 @@ public class PluginEntry {
     /**
      * The name of the service that this plugin implements
      */
-    public String service = "";
+    public String service;
 
     /**
      * The plugin class name that implements the service.
      */
-    public String pluginClass = "";
+    public String pluginClass;
 
     /**
-     * The plugin object.
-     * Plugin objects are only created when they are called from JavaScript.  (see PluginManager.exec)
-     * The exception is if the onload flag is set, then they are created when PluginManager is initialized.
+     * The pre-instantiated plugin to use for this entry.
      */
-    public CordovaPlugin plugin = null;
+    public CordovaPlugin plugin;
 
     /**
      * Flag that indicates the plugin object should be created when PluginManager is initialized.
      */
-    public boolean onload = false;
+    public boolean onload;
 
     private List<String> urlFilters;
 
+
     /**
-     * @param service               The name of the service
-     * @param plugin                The plugin associated with this entry
+     * Constructs with a CordovaPlugin already instantiated.
      */
     public PluginEntry(String service, CordovaPlugin plugin) {
-        this(service, plugin.getClass().getName(), true, null);
-        this.plugin = plugin;
+        this(service, plugin.getClass().getName(), true, plugin, null);
     }
 
     /**
@@ -69,67 +63,27 @@ public class PluginEntry {
      * @param onload                Create plugin object when HTML page is loaded
      */
     public PluginEntry(String service, String pluginClass, boolean onload) {
-        this(service, pluginClass, onload, null);
+        this(service, pluginClass, onload, null, null);
     }
     
-
+    @Deprecated // urlFilters are going away
     public PluginEntry(String service, String pluginClass, boolean onload, List<String> urlFilters) {
         this.service = service;
         this.pluginClass = pluginClass;
         this.onload = onload;
         this.urlFilters = urlFilters;
+        plugin = null;
     }
 
-    public List<String> getUrlFilters() {
-        return urlFilters;
-    }
-
-    /**
-     * Create plugin object.
-     * If plugin is already created, then just return it.
-     *
-     * @return                      The plugin object
-     */
-    public CordovaPlugin createPlugin(CordovaWebView webView, CordovaInterface ctx) {
-        if (this.plugin != null) {
-            return this.plugin;
-        }
-        try {
-            Class<?> c = getClassByName(this.pluginClass);
-            if (isCordovaPlugin(c)) {
-                this.plugin = (CordovaPlugin) c.newInstance();
-                this.plugin.privateInitialize(ctx, webView, webView.getPreferences());
-                return plugin;
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-            System.out.println("Error adding plugin " + this.pluginClass + ".");
-        }
-        return null;
-    }
-
-    /**
-     * Get the class.
-     *
-     * @param clazz
-     * @return a reference to the named class
-     * @throws ClassNotFoundException
-     */
-    private Class<?> getClassByName(final String clazz) throws ClassNotFoundException {
-        Class<?> c = null;
-        if ((clazz != null) && !("".equals(clazz))) {
-            c = Class.forName(clazz);
-        }
-        return c;
+    private PluginEntry(String service, String pluginClass, boolean onload, CordovaPlugin plugin, List<String> urlFilters) {
+        this.service = service;
+        this.pluginClass = pluginClass;
+        this.onload = onload;
+        this.urlFilters = urlFilters;
+        this.plugin = plugin;
     }
 
-    /**
-     * Returns whether the given class extends CordovaPlugin.
-     */
-    private boolean isCordovaPlugin(Class<?> c) {
-        if (c != null) {
-            return CordovaPlugin.class.isAssignableFrom(c);
-        }
-        return false;
+    public List<String> getUrlFilters() {
+        return urlFilters;
     }
 }

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/145b50a3/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 02d45ab..eb3e6f9 100755
--- a/framework/src/org/apache/cordova/PluginManager.java
+++ b/framework/src/org/apache/cordova/PluginManager.java
@@ -45,7 +45,8 @@ public class PluginManager {
     private static final int SLOW_EXEC_WARNING_THRESHOLD = Debug.isDebuggerConnected() ? 60 : 16;
 
     // List of service entries
-    private final HashMap<String, PluginEntry> entries = new HashMap<String, PluginEntry>();
+    private final HashMap<String, CordovaPlugin> pluginMap = new HashMap<String, CordovaPlugin>();
+    private final HashMap<String, PluginEntry> entryMap = new HashMap<String, PluginEntry>();
 
     private final CordovaInterface ctx;
     private final CordovaWebView app;
@@ -73,8 +74,7 @@ public class PluginManager {
     public void setPluginEntries(List<PluginEntry> pluginEntries) {
         this.onPause(false);
         this.onDestroy();
-        this.clearPluginObjects();
-        entries.clear();
+        pluginMap.clear();
         urlMap.clear();
         for (PluginEntry entry : pluginEntries) {
             addService(entry);
@@ -88,7 +88,7 @@ public class PluginManager {
         LOG.d(TAG, "init()");
         this.onPause(false);
         this.onDestroy();
-        this.clearPluginObjects();
+        pluginMap.clear();
         this.startupPlugins();
     }
 
@@ -100,18 +100,16 @@ public class PluginManager {
      * Delete all plugin objects.
      */
     public void clearPluginObjects() {
-        for (PluginEntry entry : this.entries.values()) {
-            entry.plugin = null;
-        }
+        pluginMap.clear();
     }
 
     /**
      * Create plugins objects that have onload set.
      */
     public void startupPlugins() {
-        for (PluginEntry entry : this.entries.values()) {
+        for (PluginEntry entry : entryMap.values()) {
             if (entry.onload) {
-                entry.createPlugin(this.app, this.ctx);
+                getPlugin(entry.service);
             }
         }
     }
@@ -177,15 +175,21 @@ public class PluginManager {
      * @return              CordovaPlugin or null
      */
     public CordovaPlugin getPlugin(String service) {
-        PluginEntry entry = this.entries.get(service);
-        if (entry == null) {
-            return null;
-        }
-        CordovaPlugin plugin = entry.plugin;
-        if (plugin == null) {
-            plugin = entry.createPlugin(this.app, this.ctx);
+        CordovaPlugin ret = pluginMap.get(service);
+        if (ret == null) {
+            PluginEntry pe = entryMap.get(service);
+            if (pe == null) {
+                return null;
+            }
+            if (pe.plugin != null) {
+                ret = pe.plugin;
+            } else {
+                ret = instantiatePlugin(pe.pluginClass);
+            }
+            ret.privateInitialize(ctx, app, app.getPreferences());
+            pluginMap.put(service, ret);
         }
-        return plugin;
+        return ret;
     }
 
     /**
@@ -207,11 +211,16 @@ public class PluginManager {
      * @param entry             The plugin entry
      */
     public void addService(PluginEntry entry) {
-        this.entries.put(entry.service, entry);
+        this.entryMap.put(entry.service, entry);
         List<String> urlFilters = entry.getUrlFilters();
         if (urlFilters != null) {
             urlMap.put(entry.service, urlFilters);
         }
+        if (entry.plugin != null) {
+            entry.plugin.privateInitialize(ctx, app, app.getPreferences());
+            pluginMap.put(entry.service, entry.plugin);
+        }
+
     }
 
     /**
@@ -220,10 +229,8 @@ public class PluginManager {
      * @param multitasking      Flag indicating if multitasking is turned on for app
      */
     public void onPause(boolean multitasking) {
-        for (PluginEntry entry : this.entries.values()) {
-            if (entry.plugin != null) {
-                entry.plugin.onPause(multitasking);
-            }
+        for (CordovaPlugin plugin : this.pluginMap.values()) {
+            plugin.onPause(multitasking);
         }
     }
 
@@ -233,10 +240,8 @@ public class PluginManager {
      * @param multitasking      Flag indicating if multitasking is turned on for app
      */
     public void onResume(boolean multitasking) {
-        for (PluginEntry entry : this.entries.values()) {
-            if (entry.plugin != null) {
-                entry.plugin.onResume(multitasking);
-            }
+        for (CordovaPlugin plugin : this.pluginMap.values()) {
+            plugin.onResume(multitasking);
         }
     }
 
@@ -244,10 +249,8 @@ public class PluginManager {
      * The final call you receive before your activity is destroyed.
      */
     public void onDestroy() {
-        for (PluginEntry entry : this.entries.values()) {
-            if (entry.plugin != null) {
-                entry.plugin.onDestroy();
-            }
+        for (CordovaPlugin plugin : this.pluginMap.values()) {
+            plugin.onDestroy();
         }
     }
 
@@ -263,12 +266,10 @@ public class PluginManager {
         if (obj != null) {
             return obj;
         }
-        for (PluginEntry entry : this.entries.values()) {
-            if (entry.plugin != null) {
-                obj = entry.plugin.onMessage(id, data);
-                if (obj != null) {
-                    return obj;
-                }
+        for (CordovaPlugin plugin : this.pluginMap.values()) {
+            obj = plugin.onMessage(id, data);
+            if (obj != null) {
+                return obj;
             }
         }
         return null;
@@ -278,10 +279,8 @@ public class PluginManager {
      * Called when the activity receives a new intent.
      */
     public void onNewIntent(Intent intent) {
-        for (PluginEntry entry : this.entries.values()) {
-            if (entry.plugin != null) {
-                entry.plugin.onNewIntent(intent);
-            }
+        for (CordovaPlugin plugin : this.pluginMap.values()) {
+            plugin.onNewIntent(intent);
         }
     }
 
@@ -296,7 +295,7 @@ public class PluginManager {
         // Instead, plugins should not include <url-filter> and instead ensure
         // that they are loaded before this function is called (either by setting
         // the onload <param> or by making an exec() call to them)
-        for (PluginEntry entry : this.entries.values()) {
+        for (PluginEntry entry : this.entryMap.values()) {
             List<String> urlFilters = urlMap.get(entry.service);
             if (urlFilters != null) {
                 for (String s : urlFilters) {
@@ -304,8 +303,9 @@ public class PluginManager {
                         return getPlugin(entry.service).onOverrideUrlLoading(url);
                     }
                 }
-            } else if (entry.plugin != null) {
-                if (entry.plugin.onOverrideUrlLoading(url)) {
+            } else {
+                CordovaPlugin plugin = pluginMap.get(entry.service);
+                if (plugin != null && plugin.onOverrideUrlLoading(url)) {
                     return true;
                 }
             }
@@ -317,22 +317,38 @@ public class PluginManager {
      * Called when the app navigates or refreshes.
      */
     public void onReset() {
-        for (PluginEntry entry : this.entries.values()) {
-            if (entry.plugin != null) {
-                entry.plugin.onReset();
-            }
+        for (CordovaPlugin plugin : this.pluginMap.values()) {
+            plugin.onReset();
         }
     }
 
     Uri remapUri(Uri uri) {
-        for (PluginEntry entry : this.entries.values()) {
-            if (entry.plugin != null) {
-                Uri ret = entry.plugin.remapUri(uri);
-                if (ret != null) {
-                    return ret;
-                }
+        for (CordovaPlugin plugin : this.pluginMap.values()) {
+            Uri ret = plugin.remapUri(uri);
+            if (ret != null) {
+                return ret;
             }
         }
         return null;
     }
+
+    /**
+     * Create a plugin based on class name.
+     */
+    private CordovaPlugin instantiatePlugin(String className) {
+        CordovaPlugin ret = null;
+        try {
+            Class<?> c = null;
+            if ((className != null) && !("".equals(className))) {
+                c = Class.forName(className);
+            }
+            if (c != null & CordovaPlugin.class.isAssignableFrom(c)) {
+                ret = (CordovaPlugin) c.newInstance();
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            System.out.println("Error adding plugin " + className + ".");
+        }
+        return ret;
+    }
 }


[07/10] android commit: Move plugin instantiation and instance storing logic PluginEntry->PluginManager

Posted by ag...@apache.org.
Move plugin instantiation and instance storing logic PluginEntry->PluginManager

Instantiation and storing of the instance should be owned privately by
PluginManager, not exposed via an unprotected public API. That said,
this refactoring does not make any breaking changes to the public API,
except for removing the createPlugin call in PluginEntry, which should
not be called by anyone other than PluginManager anyway.


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

Branch: refs/heads/master
Commit: 145b50a320edfa8b5397849fc20a6295f8823ff6
Parents: a33cdc9
Author: Andrew Grieve <ag...@chromium.org>
Authored: Mon Jul 14 14:08:27 2014 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Mon Jul 14 14:08:27 2014 -0400

----------------------------------------------------------------------
 .../src/org/apache/cordova/PluginEntry.java     |  84 +++----------
 .../src/org/apache/cordova/PluginManager.java   | 122 +++++++++++--------
 2 files changed, 88 insertions(+), 118 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/145b50a3/framework/src/org/apache/cordova/PluginEntry.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/PluginEntry.java b/framework/src/org/apache/cordova/PluginEntry.java
index e94cf1c..03a44da 100755
--- a/framework/src/org/apache/cordova/PluginEntry.java
+++ b/framework/src/org/apache/cordova/PluginEntry.java
@@ -20,11 +20,8 @@ package org.apache.cordova;
 
 import java.util.List;
 
-import org.apache.cordova.CordovaWebView;
-import org.apache.cordova.CordovaInterface;
 import org.apache.cordova.CordovaPlugin;
 
-
 /**
  * This class represents a service entry object.
  */
@@ -33,34 +30,31 @@ public class PluginEntry {
     /**
      * The name of the service that this plugin implements
      */
-    public String service = "";
+    public String service;
 
     /**
      * The plugin class name that implements the service.
      */
-    public String pluginClass = "";
+    public String pluginClass;
 
     /**
-     * The plugin object.
-     * Plugin objects are only created when they are called from JavaScript.  (see PluginManager.exec)
-     * The exception is if the onload flag is set, then they are created when PluginManager is initialized.
+     * The pre-instantiated plugin to use for this entry.
      */
-    public CordovaPlugin plugin = null;
+    public CordovaPlugin plugin;
 
     /**
      * Flag that indicates the plugin object should be created when PluginManager is initialized.
      */
-    public boolean onload = false;
+    public boolean onload;
 
     private List<String> urlFilters;
 
+
     /**
-     * @param service               The name of the service
-     * @param plugin                The plugin associated with this entry
+     * Constructs with a CordovaPlugin already instantiated.
      */
     public PluginEntry(String service, CordovaPlugin plugin) {
-        this(service, plugin.getClass().getName(), true, null);
-        this.plugin = plugin;
+        this(service, plugin.getClass().getName(), true, plugin, null);
     }
 
     /**
@@ -69,67 +63,27 @@ public class PluginEntry {
      * @param onload                Create plugin object when HTML page is loaded
      */
     public PluginEntry(String service, String pluginClass, boolean onload) {
-        this(service, pluginClass, onload, null);
+        this(service, pluginClass, onload, null, null);
     }
     
-
+    @Deprecated // urlFilters are going away
     public PluginEntry(String service, String pluginClass, boolean onload, List<String> urlFilters) {
         this.service = service;
         this.pluginClass = pluginClass;
         this.onload = onload;
         this.urlFilters = urlFilters;
+        plugin = null;
     }
 
-    public List<String> getUrlFilters() {
-        return urlFilters;
-    }
-
-    /**
-     * Create plugin object.
-     * If plugin is already created, then just return it.
-     *
-     * @return                      The plugin object
-     */
-    public CordovaPlugin createPlugin(CordovaWebView webView, CordovaInterface ctx) {
-        if (this.plugin != null) {
-            return this.plugin;
-        }
-        try {
-            Class<?> c = getClassByName(this.pluginClass);
-            if (isCordovaPlugin(c)) {
-                this.plugin = (CordovaPlugin) c.newInstance();
-                this.plugin.privateInitialize(ctx, webView, webView.getPreferences());
-                return plugin;
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-            System.out.println("Error adding plugin " + this.pluginClass + ".");
-        }
-        return null;
-    }
-
-    /**
-     * Get the class.
-     *
-     * @param clazz
-     * @return a reference to the named class
-     * @throws ClassNotFoundException
-     */
-    private Class<?> getClassByName(final String clazz) throws ClassNotFoundException {
-        Class<?> c = null;
-        if ((clazz != null) && !("".equals(clazz))) {
-            c = Class.forName(clazz);
-        }
-        return c;
+    private PluginEntry(String service, String pluginClass, boolean onload, CordovaPlugin plugin, List<String> urlFilters) {
+        this.service = service;
+        this.pluginClass = pluginClass;
+        this.onload = onload;
+        this.urlFilters = urlFilters;
+        this.plugin = plugin;
     }
 
-    /**
-     * Returns whether the given class extends CordovaPlugin.
-     */
-    private boolean isCordovaPlugin(Class<?> c) {
-        if (c != null) {
-            return CordovaPlugin.class.isAssignableFrom(c);
-        }
-        return false;
+    public List<String> getUrlFilters() {
+        return urlFilters;
     }
 }

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/145b50a3/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 02d45ab..eb3e6f9 100755
--- a/framework/src/org/apache/cordova/PluginManager.java
+++ b/framework/src/org/apache/cordova/PluginManager.java
@@ -45,7 +45,8 @@ public class PluginManager {
     private static final int SLOW_EXEC_WARNING_THRESHOLD = Debug.isDebuggerConnected() ? 60 : 16;
 
     // List of service entries
-    private final HashMap<String, PluginEntry> entries = new HashMap<String, PluginEntry>();
+    private final HashMap<String, CordovaPlugin> pluginMap = new HashMap<String, CordovaPlugin>();
+    private final HashMap<String, PluginEntry> entryMap = new HashMap<String, PluginEntry>();
 
     private final CordovaInterface ctx;
     private final CordovaWebView app;
@@ -73,8 +74,7 @@ public class PluginManager {
     public void setPluginEntries(List<PluginEntry> pluginEntries) {
         this.onPause(false);
         this.onDestroy();
-        this.clearPluginObjects();
-        entries.clear();
+        pluginMap.clear();
         urlMap.clear();
         for (PluginEntry entry : pluginEntries) {
             addService(entry);
@@ -88,7 +88,7 @@ public class PluginManager {
         LOG.d(TAG, "init()");
         this.onPause(false);
         this.onDestroy();
-        this.clearPluginObjects();
+        pluginMap.clear();
         this.startupPlugins();
     }
 
@@ -100,18 +100,16 @@ public class PluginManager {
      * Delete all plugin objects.
      */
     public void clearPluginObjects() {
-        for (PluginEntry entry : this.entries.values()) {
-            entry.plugin = null;
-        }
+        pluginMap.clear();
     }
 
     /**
      * Create plugins objects that have onload set.
      */
     public void startupPlugins() {
-        for (PluginEntry entry : this.entries.values()) {
+        for (PluginEntry entry : entryMap.values()) {
             if (entry.onload) {
-                entry.createPlugin(this.app, this.ctx);
+                getPlugin(entry.service);
             }
         }
     }
@@ -177,15 +175,21 @@ public class PluginManager {
      * @return              CordovaPlugin or null
      */
     public CordovaPlugin getPlugin(String service) {
-        PluginEntry entry = this.entries.get(service);
-        if (entry == null) {
-            return null;
-        }
-        CordovaPlugin plugin = entry.plugin;
-        if (plugin == null) {
-            plugin = entry.createPlugin(this.app, this.ctx);
+        CordovaPlugin ret = pluginMap.get(service);
+        if (ret == null) {
+            PluginEntry pe = entryMap.get(service);
+            if (pe == null) {
+                return null;
+            }
+            if (pe.plugin != null) {
+                ret = pe.plugin;
+            } else {
+                ret = instantiatePlugin(pe.pluginClass);
+            }
+            ret.privateInitialize(ctx, app, app.getPreferences());
+            pluginMap.put(service, ret);
         }
-        return plugin;
+        return ret;
     }
 
     /**
@@ -207,11 +211,16 @@ public class PluginManager {
      * @param entry             The plugin entry
      */
     public void addService(PluginEntry entry) {
-        this.entries.put(entry.service, entry);
+        this.entryMap.put(entry.service, entry);
         List<String> urlFilters = entry.getUrlFilters();
         if (urlFilters != null) {
             urlMap.put(entry.service, urlFilters);
         }
+        if (entry.plugin != null) {
+            entry.plugin.privateInitialize(ctx, app, app.getPreferences());
+            pluginMap.put(entry.service, entry.plugin);
+        }
+
     }
 
     /**
@@ -220,10 +229,8 @@ public class PluginManager {
      * @param multitasking      Flag indicating if multitasking is turned on for app
      */
     public void onPause(boolean multitasking) {
-        for (PluginEntry entry : this.entries.values()) {
-            if (entry.plugin != null) {
-                entry.plugin.onPause(multitasking);
-            }
+        for (CordovaPlugin plugin : this.pluginMap.values()) {
+            plugin.onPause(multitasking);
         }
     }
 
@@ -233,10 +240,8 @@ public class PluginManager {
      * @param multitasking      Flag indicating if multitasking is turned on for app
      */
     public void onResume(boolean multitasking) {
-        for (PluginEntry entry : this.entries.values()) {
-            if (entry.plugin != null) {
-                entry.plugin.onResume(multitasking);
-            }
+        for (CordovaPlugin plugin : this.pluginMap.values()) {
+            plugin.onResume(multitasking);
         }
     }
 
@@ -244,10 +249,8 @@ public class PluginManager {
      * The final call you receive before your activity is destroyed.
      */
     public void onDestroy() {
-        for (PluginEntry entry : this.entries.values()) {
-            if (entry.plugin != null) {
-                entry.plugin.onDestroy();
-            }
+        for (CordovaPlugin plugin : this.pluginMap.values()) {
+            plugin.onDestroy();
         }
     }
 
@@ -263,12 +266,10 @@ public class PluginManager {
         if (obj != null) {
             return obj;
         }
-        for (PluginEntry entry : this.entries.values()) {
-            if (entry.plugin != null) {
-                obj = entry.plugin.onMessage(id, data);
-                if (obj != null) {
-                    return obj;
-                }
+        for (CordovaPlugin plugin : this.pluginMap.values()) {
+            obj = plugin.onMessage(id, data);
+            if (obj != null) {
+                return obj;
             }
         }
         return null;
@@ -278,10 +279,8 @@ public class PluginManager {
      * Called when the activity receives a new intent.
      */
     public void onNewIntent(Intent intent) {
-        for (PluginEntry entry : this.entries.values()) {
-            if (entry.plugin != null) {
-                entry.plugin.onNewIntent(intent);
-            }
+        for (CordovaPlugin plugin : this.pluginMap.values()) {
+            plugin.onNewIntent(intent);
         }
     }
 
@@ -296,7 +295,7 @@ public class PluginManager {
         // Instead, plugins should not include <url-filter> and instead ensure
         // that they are loaded before this function is called (either by setting
         // the onload <param> or by making an exec() call to them)
-        for (PluginEntry entry : this.entries.values()) {
+        for (PluginEntry entry : this.entryMap.values()) {
             List<String> urlFilters = urlMap.get(entry.service);
             if (urlFilters != null) {
                 for (String s : urlFilters) {
@@ -304,8 +303,9 @@ public class PluginManager {
                         return getPlugin(entry.service).onOverrideUrlLoading(url);
                     }
                 }
-            } else if (entry.plugin != null) {
-                if (entry.plugin.onOverrideUrlLoading(url)) {
+            } else {
+                CordovaPlugin plugin = pluginMap.get(entry.service);
+                if (plugin != null && plugin.onOverrideUrlLoading(url)) {
                     return true;
                 }
             }
@@ -317,22 +317,38 @@ public class PluginManager {
      * Called when the app navigates or refreshes.
      */
     public void onReset() {
-        for (PluginEntry entry : this.entries.values()) {
-            if (entry.plugin != null) {
-                entry.plugin.onReset();
-            }
+        for (CordovaPlugin plugin : this.pluginMap.values()) {
+            plugin.onReset();
         }
     }
 
     Uri remapUri(Uri uri) {
-        for (PluginEntry entry : this.entries.values()) {
-            if (entry.plugin != null) {
-                Uri ret = entry.plugin.remapUri(uri);
-                if (ret != null) {
-                    return ret;
-                }
+        for (CordovaPlugin plugin : this.pluginMap.values()) {
+            Uri ret = plugin.remapUri(uri);
+            if (ret != null) {
+                return ret;
             }
         }
         return null;
     }
+
+    /**
+     * Create a plugin based on class name.
+     */
+    private CordovaPlugin instantiatePlugin(String className) {
+        CordovaPlugin ret = null;
+        try {
+            Class<?> c = null;
+            if ((className != null) && !("".equals(className))) {
+                c = Class.forName(className);
+            }
+            if (c != null & CordovaPlugin.class.isAssignableFrom(c)) {
+                ret = (CordovaPlugin) c.newInstance();
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            System.out.println("Error adding plugin " + className + ".");
+        }
+        return ret;
+    }
 }


[04/10] android commit: Fix broken unit test due to missing Config.init() call

Posted by ag...@apache.org.
Fix broken unit test due to missing Config.init() call


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

Branch: refs/heads/4.0.x
Commit: a33cdc9c7b106313eb0952c54a4c07e690e4426c
Parents: 62101e8
Author: Andrew Grieve <ag...@chromium.org>
Authored: Mon Jul 14 14:06:47 2014 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Mon Jul 14 14:06:47 2014 -0400

----------------------------------------------------------------------
 test/src/org/apache/cordova/test/CordovaWebViewTestActivity.java | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/a33cdc9c/test/src/org/apache/cordova/test/CordovaWebViewTestActivity.java
----------------------------------------------------------------------
diff --git a/test/src/org/apache/cordova/test/CordovaWebViewTestActivity.java b/test/src/org/apache/cordova/test/CordovaWebViewTestActivity.java
index e35b6e7..06070cc 100644
--- a/test/src/org/apache/cordova/test/CordovaWebViewTestActivity.java
+++ b/test/src/org/apache/cordova/test/CordovaWebViewTestActivity.java
@@ -48,6 +48,7 @@ public class CordovaWebViewTestActivity extends Activity implements CordovaInter
         setContentView(R.layout.main);
 
         cordovaWebView = (CordovaWebView) findViewById(R.id.cordovaWebView);
+        Config.init(this);
         cordovaWebView.init(this, new CordovaWebViewClient(this, cordovaWebView), new CordovaChromeClient(this, cordovaWebView),
                 Config.getPluginEntries(), Config.getWhitelist(), Config.getPreferences());
 


[09/10] android commit: @Deprecate methods of PluginManager that were never meant to be public

Posted by ag...@apache.org.
@Deprecate methods of PluginManager that were never meant to be public


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

Branch: refs/heads/master
Commit: b934c1be6a90ac88c077d5bd922c66fa1cf32363
Parents: 145b50a
Author: Andrew Grieve <ag...@chromium.org>
Authored: Mon Jul 14 14:10:19 2014 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Mon Jul 14 14:10:19 2014 -0400

----------------------------------------------------------------------
 framework/src/org/apache/cordova/PluginManager.java | 9 +++++++++
 1 file changed, 9 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/b934c1be/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 eb3e6f9..689c3c8 100755
--- a/framework/src/org/apache/cordova/PluginManager.java
+++ b/framework/src/org/apache/cordova/PluginManager.java
@@ -84,6 +84,7 @@ public class PluginManager {
     /**
      * Init when loading a new HTML page into webview.
      */
+    @Deprecated // Should not be exposed as public.
     public void init() {
         LOG.d(TAG, "init()");
         this.onPause(false);
@@ -99,6 +100,7 @@ public class PluginManager {
     /**
      * Delete all plugin objects.
      */
+    @Deprecated // Should not be exposed as public.
     public void clearPluginObjects() {
         pluginMap.clear();
     }
@@ -106,6 +108,7 @@ public class PluginManager {
     /**
      * Create plugins objects that have onload set.
      */
+    @Deprecated // Should not be exposed as public.
     public void startupPlugins() {
         for (PluginEntry entry : entryMap.values()) {
             if (entry.onload) {
@@ -228,6 +231,7 @@ public class PluginManager {
      *
      * @param multitasking      Flag indicating if multitasking is turned on for app
      */
+    @Deprecated // Should not be public
     public void onPause(boolean multitasking) {
         for (CordovaPlugin plugin : this.pluginMap.values()) {
             plugin.onPause(multitasking);
@@ -239,6 +243,7 @@ public class PluginManager {
      *
      * @param multitasking      Flag indicating if multitasking is turned on for app
      */
+    @Deprecated // Should not be public
     public void onResume(boolean multitasking) {
         for (CordovaPlugin plugin : this.pluginMap.values()) {
             plugin.onResume(multitasking);
@@ -248,6 +253,7 @@ public class PluginManager {
     /**
      * The final call you receive before your activity is destroyed.
      */
+    @Deprecated // Should not be public
     public void onDestroy() {
         for (CordovaPlugin plugin : this.pluginMap.values()) {
             plugin.onDestroy();
@@ -278,6 +284,7 @@ public class PluginManager {
     /**
      * Called when the activity receives a new intent.
      */
+    @Deprecated // Should not be public
     public void onNewIntent(Intent intent) {
         for (CordovaPlugin plugin : this.pluginMap.values()) {
             plugin.onNewIntent(intent);
@@ -290,6 +297,7 @@ public class PluginManager {
      * @param url               The URL that is being changed to.
      * @return                  Return false to allow the URL to load, return true to prevent the URL from loading.
      */
+    @Deprecated // Should not be public
     public boolean onOverrideUrlLoading(String url) {
         // Deprecated way to intercept URLs. (process <url-filter> tags).
         // Instead, plugins should not include <url-filter> and instead ensure
@@ -316,6 +324,7 @@ public class PluginManager {
     /**
      * Called when the app navigates or refreshes.
      */
+    @Deprecated // Should not be public
     public void onReset() {
         for (CordovaPlugin plugin : this.pluginMap.values()) {
             plugin.onReset();


[02/10] android commit: Fix for `android` not being in PATH check on Windows

Posted by ag...@apache.org.
Fix for `android` not being in PATH check on Windows

close #103


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

Branch: refs/heads/4.0.x
Commit: 0a3714e5e0f6046caf9468395aa0587888eb8408
Parents: 86a2830
Author: Eion Robb <ei...@robbmob.com>
Authored: Sun Jun 22 09:43:30 2014 +1200
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Mon Jul 14 10:28:27 2014 -0400

----------------------------------------------------------------------
 bin/lib/check_reqs.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/0a3714e5/bin/lib/check_reqs.js
----------------------------------------------------------------------
diff --git a/bin/lib/check_reqs.js b/bin/lib/check_reqs.js
index 3296acc..91875f5 100644
--- a/bin/lib/check_reqs.js
+++ b/bin/lib/check_reqs.js
@@ -81,7 +81,7 @@ module.exports.check_android = function() {
         }
         return Q();
     }, function(stderr) {
-        if (stderr.match(/command\snot\sfound/)) {
+        if (stderr.match(/command\snot\sfound/) || stderr.match(/is not recognized as an internal or external command/)) {
             return Q.reject(new Error('The command \"android\" failed. Make sure you have the latest Android SDK installed, and the \"android\" command (inside the tools/ folder) is added to your path.'));
         } else {
             return Q.reject(new Error('An error occurred while listing Android targets. Error: ' + stderr ));


[03/10] android commit: Update to check for Google Glass APIs

Posted by ag...@apache.org.
Update to check for Google Glass APIs

This prevents the 'cordova build android' process from blowing up on this step if you assign the GDK as the target and want to rebuild via the CLI.

close #100


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

Branch: refs/heads/4.0.x
Commit: 62101e85ffeed6620ae940f76cf51149aec54cf2
Parents: 0a3714e
Author: Matt Ray <th...@gmail.com>
Authored: Thu May 8 15:37:09 2014 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Mon Jul 14 10:30:23 2014 -0400

----------------------------------------------------------------------
 bin/lib/check_reqs.js | 4 ++++
 1 file changed, 4 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/62101e85/bin/lib/check_reqs.js
----------------------------------------------------------------------
diff --git a/bin/lib/check_reqs.js b/bin/lib/check_reqs.js
index 91875f5..a4ad3ad 100644
--- a/bin/lib/check_reqs.js
+++ b/bin/lib/check_reqs.js
@@ -36,6 +36,10 @@ module.exports.get_target = function() {
         // this is called on the project itself, and can support Google APIs AND Vanilla Android
         var target = shell.grep(/target=android-[\d+]/, path.join(ROOT, 'project.properties')) ||
           shell.grep(/target=Google Inc.:Google APIs:[\d+]/, path.join(ROOT, 'project.properties'));
+        if(target == "" || !target) {
+          // Try Google Glass APIs
+          target = shell.grep(/target=Google Inc.:Glass Development Kit Preview:[\d+]/, path.join(ROOT, 'project.properties'));
+        }
         return target.split('=')[1].replace('\n', '').replace('\r', '');
     }
 }