From c978341d837764073c33ad5e7f8114362cfb2615 Mon Sep 17 00:00:00 2001 From: Kevin Griffin Date: Tue, 21 Jun 2011 11:32:18 -0400 Subject: [PATCH 1/4] made the mistake of opening anything in finder --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 5c53ca30..afa78b8d 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ local.properties framework/phonegap.jar framework/bin framework/assets/www/.DS_Store +.DS_Store \ No newline at end of file From 327bda49a0d228da83e3ab94c183e8f1be4386f6 Mon Sep 17 00:00:00 2001 From: Kevin Griffin Date: Tue, 21 Jun 2011 11:32:22 -0400 Subject: [PATCH 2/4] Sending pause/resume notifcations to plugins regardless of 'keepRunning' state. Not sure why you wouldn't want to send them Added a OnNewIntent override for Plugins to use. --- framework/src/com/phonegap/DroidGap.java | 38 ++++++++++++------- framework/src/com/phonegap/api/Plugin.java | 6 +++ .../src/com/phonegap/api/PluginManager.java | 11 ++++++ 3 files changed, 42 insertions(+), 13 deletions(-) diff --git a/framework/src/com/phonegap/DroidGap.java b/framework/src/com/phonegap/DroidGap.java index 7dc2aed0..fefbc144 100755 --- a/framework/src/com/phonegap/DroidGap.java +++ b/framework/src/com/phonegap/DroidGap.java @@ -9,13 +9,12 @@ package com.phonegap; import org.json.JSONArray; import org.json.JSONException; + import android.app.AlertDialog; -import android.widget.EditText; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.res.Configuration; -import android.graphics.Bitmap; import android.graphics.Color; import android.media.AudioManager; import android.net.Uri; @@ -26,19 +25,21 @@ import android.view.View; import android.view.ViewGroup; import android.view.Window; import android.view.WindowManager; +import android.webkit.GeolocationPermissions.Callback; +import android.webkit.JsPromptResult; import android.webkit.JsResult; import android.webkit.WebChromeClient; -import android.webkit.JsPromptResult; import android.webkit.WebSettings; +import android.webkit.WebSettings.LayoutAlgorithm; import android.webkit.WebStorage; import android.webkit.WebView; import android.webkit.WebViewClient; -import android.webkit.GeolocationPermissions.Callback; -import android.webkit.WebSettings.LayoutAlgorithm; +import android.widget.EditText; import android.widget.LinearLayout; + +import com.phonegap.api.PhonegapActivity; import com.phonegap.api.Plugin; import com.phonegap.api.PluginManager; -import com.phonegap.api.PhonegapActivity; /** * This class is the main Android activity that represents the PhoneGap @@ -608,17 +609,28 @@ public class DroidGap extends PhonegapActivity { // Send pause event to JavaScript this.appView.loadUrl("javascript:try{PhoneGap.onPause.fire();}catch(e){};"); + // Forward to plugins + this.pluginManager.onPause(); + // If app doesn't want to run in background if (!this.keepRunning) { - - // Forward to plugins - this.pluginManager.onPause(); // Pause JavaScript timers (including setInterval) this.appView.pauseTimers(); } } - + + @Override + /** + * Called when the activity receives a new intent + **/ + protected void onNewIntent(Intent intent) { + super.onNewIntent(intent); + + //Forward to plugins + this.pluginManager.onNewIntent(intent); + } + @Override /** * Called when the activity will start interacting with the user. @@ -632,6 +644,9 @@ public class DroidGap extends PhonegapActivity { // Send resume event to JavaScript this.appView.loadUrl("javascript:try{PhoneGap.onResume.fire();}catch(e){};"); + // Forward to plugins + this.pluginManager.onResume(); + // If app doesn't want to run in background if (!this.keepRunning || this.activityResultKeepRunning) { @@ -641,9 +656,6 @@ public class DroidGap extends PhonegapActivity { this.activityResultKeepRunning = false; } - // Forward to plugins - this.pluginManager.onResume(); - // Resume JavaScript timers (including setInterval) this.appView.resumeTimers(); } diff --git a/framework/src/com/phonegap/api/Plugin.java b/framework/src/com/phonegap/api/Plugin.java index a527159a..39da4b89 100755 --- a/framework/src/com/phonegap/api/Plugin.java +++ b/framework/src/com/phonegap/api/Plugin.java @@ -74,6 +74,12 @@ public abstract class Plugin implements IPlugin { public void onResume() { } + /** + * Called when the activity receives a new intent. + */ + public void onNewIntent(Intent intent) { + } + /** * The final call you receive before your activity is destroyed. */ diff --git a/framework/src/com/phonegap/api/PluginManager.java b/framework/src/com/phonegap/api/PluginManager.java index ad1cf20b..616ee856 100755 --- a/framework/src/com/phonegap/api/PluginManager.java +++ b/framework/src/com/phonegap/api/PluginManager.java @@ -13,6 +13,7 @@ import java.util.Map.Entry; import org.json.JSONArray; import org.json.JSONException; +import android.content.Intent; import android.webkit.WebView; /** @@ -265,4 +266,14 @@ public final class PluginManager { plugin.onDestroy(); } } + + public void onNewIntent(Intent intent) { + java.util.Set> s = this.plugins.entrySet(); + java.util.Iterator> it = s.iterator(); + while(it.hasNext()) { + Entry entry = it.next(); + Plugin plugin = entry.getValue(); + plugin.onNewIntent(intent); + } + } } \ No newline at end of file From 517b5e0db9ea547bf79d1f4a136b1a8c4832c3f6 Mon Sep 17 00:00:00 2001 From: Kevin Griffin Date: Tue, 21 Jun 2011 11:46:54 -0400 Subject: [PATCH 3/4] formattage --- framework/src/com/phonegap/DroidGap.java | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/framework/src/com/phonegap/DroidGap.java b/framework/src/com/phonegap/DroidGap.java index fefbc144..cafc0ef0 100755 --- a/framework/src/com/phonegap/DroidGap.java +++ b/framework/src/com/phonegap/DroidGap.java @@ -620,16 +620,16 @@ public class DroidGap extends PhonegapActivity { } } - @Override - /** - * Called when the activity receives a new intent - **/ - protected void onNewIntent(Intent intent) { - super.onNewIntent(intent); - - //Forward to plugins - this.pluginManager.onNewIntent(intent); - } + @Override + /** + * Called when the activity receives a new intent + **/ + protected void onNewIntent(Intent intent) { + super.onNewIntent(intent); + + //Forward to plugins + this.pluginManager.onNewIntent(intent); + } @Override /** From c15971253fa891d5d360bd97307059a8adc6946f Mon Sep 17 00:00:00 2001 From: Kevin Griffin Date: Wed, 22 Jun 2011 11:05:33 -0400 Subject: [PATCH 4/4] formatting - sigh --- framework/src/com/phonegap/DroidGap.java | 24 +++++++++---------- framework/src/com/phonegap/api/Plugin.java | 4 ++-- .../src/com/phonegap/api/PluginManager.java | 3 +++ 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/framework/src/com/phonegap/DroidGap.java b/framework/src/com/phonegap/DroidGap.java index cafc0ef0..042f83d8 100755 --- a/framework/src/com/phonegap/DroidGap.java +++ b/framework/src/com/phonegap/DroidGap.java @@ -619,18 +619,18 @@ public class DroidGap extends PhonegapActivity { this.appView.pauseTimers(); } } - - @Override - /** - * Called when the activity receives a new intent - **/ - protected void onNewIntent(Intent intent) { - super.onNewIntent(intent); - - //Forward to plugins - this.pluginManager.onNewIntent(intent); - } - + + @Override + /** + * Called when the activity receives a new intent + **/ + protected void onNewIntent(Intent intent) { + super.onNewIntent(intent); + + //Forward to plugins + this.pluginManager.onNewIntent(intent); + } + @Override /** * Called when the activity will start interacting with the user. diff --git a/framework/src/com/phonegap/api/Plugin.java b/framework/src/com/phonegap/api/Plugin.java index 39da4b89..502552c6 100755 --- a/framework/src/com/phonegap/api/Plugin.java +++ b/framework/src/com/phonegap/api/Plugin.java @@ -77,8 +77,8 @@ public abstract class Plugin implements IPlugin { /** * Called when the activity receives a new intent. */ - public void onNewIntent(Intent intent) { - } + public void onNewIntent(Intent intent) { + } /** * The final call you receive before your activity is destroyed. diff --git a/framework/src/com/phonegap/api/PluginManager.java b/framework/src/com/phonegap/api/PluginManager.java index 616ee856..7dafa564 100755 --- a/framework/src/com/phonegap/api/PluginManager.java +++ b/framework/src/com/phonegap/api/PluginManager.java @@ -267,6 +267,9 @@ public final class PluginManager { } } + /** + * Called when the activity receives a new intent. + */ public void onNewIntent(Intent intent) { java.util.Set> s = this.plugins.entrySet(); java.util.Iterator> it = s.iterator();