Fixing conflict

This commit is contained in:
Joe Bowser 2011-06-24 14:08:26 -07:00
parent a5039f021d
commit 7bc0d624ac
3 changed files with 41 additions and 13 deletions

View File

@ -12,12 +12,10 @@ import org.json.JSONException;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.widget.EditText;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.Rect; import android.graphics.Rect;
import android.media.AudioManager; import android.media.AudioManager;
@ -30,19 +28,21 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.Window; import android.view.Window;
import android.view.WindowManager; import android.view.WindowManager;
import android.webkit.GeolocationPermissions.Callback;
import android.webkit.JsPromptResult;
import android.webkit.JsResult; import android.webkit.JsResult;
import android.webkit.WebChromeClient; import android.webkit.WebChromeClient;
import android.webkit.JsPromptResult;
import android.webkit.WebSettings; import android.webkit.WebSettings;
import android.webkit.WebSettings.LayoutAlgorithm;
import android.webkit.WebStorage; import android.webkit.WebStorage;
import android.webkit.WebView; import android.webkit.WebView;
import android.webkit.WebViewClient; import android.webkit.WebViewClient;
import android.webkit.GeolocationPermissions.Callback; import android.widget.EditText;
import android.webkit.WebSettings.LayoutAlgorithm;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import com.phonegap.api.PhonegapActivity;
import com.phonegap.api.Plugin; import com.phonegap.api.Plugin;
import com.phonegap.api.PluginManager; import com.phonegap.api.PluginManager;
import com.phonegap.api.PhonegapActivity;
/** /**
* This class is the main Android activity that represents the PhoneGap * This class is the main Android activity that represents the PhoneGap
@ -616,17 +616,28 @@ public class DroidGap extends PhonegapActivity {
// Send pause event to JavaScript // Send pause event to JavaScript
this.appView.loadUrl("javascript:try{PhoneGap.onPause.fire();}catch(e){};"); 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 app doesn't want to run in background
if (!this.keepRunning) { if (!this.keepRunning) {
// Forward to plugins
this.pluginManager.onPause();
// Pause JavaScript timers (including setInterval) // Pause JavaScript timers (including setInterval)
this.appView.pauseTimers(); 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 @Override
/** /**
* Called when the activity will start interacting with the user. * Called when the activity will start interacting with the user.
@ -640,6 +651,9 @@ public class DroidGap extends PhonegapActivity {
// Send resume event to JavaScript // Send resume event to JavaScript
this.appView.loadUrl("javascript:try{PhoneGap.onResume.fire();}catch(e){};"); 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 app doesn't want to run in background
if (!this.keepRunning || this.activityResultKeepRunning) { if (!this.keepRunning || this.activityResultKeepRunning) {
@ -649,9 +663,6 @@ public class DroidGap extends PhonegapActivity {
this.activityResultKeepRunning = false; this.activityResultKeepRunning = false;
} }
// Forward to plugins
this.pluginManager.onResume();
// Resume JavaScript timers (including setInterval) // Resume JavaScript timers (including setInterval)
this.appView.resumeTimers(); this.appView.resumeTimers();
} }

View File

@ -74,6 +74,12 @@ public abstract class Plugin implements IPlugin {
public void onResume() { 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. * The final call you receive before your activity is destroyed.
*/ */

View File

@ -13,6 +13,7 @@ import java.util.Map.Entry;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import android.content.Intent;
import android.webkit.WebView; import android.webkit.WebView;
/** /**
@ -265,4 +266,14 @@ public final class PluginManager {
plugin.onDestroy(); plugin.onDestroy();
} }
} }
public void onNewIntent(Intent intent) {
java.util.Set<Entry<String,Plugin>> s = this.plugins.entrySet();
java.util.Iterator<Entry<String,Plugin>> it = s.iterator();
while(it.hasNext()) {
Entry<String,Plugin> entry = it.next();
Plugin plugin = entry.getValue();
plugin.onNewIntent(intent);
}
}
} }