This commit is contained in:
Joe Bowser 2012-07-11 09:14:04 -07:00
commit 6415848383
4 changed files with 93 additions and 9 deletions

1
.gitignore vendored
View File

@ -2,6 +2,7 @@
default.properties
gen
assets/www/cordova.js
framework/assets/www/.tmp*
local.properties
framework/proguard.cfg
framework/cordova.jar

View File

@ -619,10 +619,12 @@ public class DroidGap extends Activity implements CordovaInterface {
// If app doesn't want to run in background
if (!this.keepRunning) {
// Pause JavaScript timers (including setInterval)
this.appView.pauseTimers();
}
// hide the splash screen to avoid leaking a window
this.removeSplashScreen();
}
@Override
@ -684,6 +686,9 @@ public class DroidGap extends Activity implements CordovaInterface {
LOG.d(TAG, "onDestroy()");
super.onDestroy();
// hide the splash screen to avoid leaking a window
this.removeSplashScreen();
if (this.appView != null) {
// Send destroy event to JavaScript
@ -966,7 +971,7 @@ public class DroidGap extends Activity implements CordovaInterface {
* Removes the Dialog that displays the splash screen
*/
public void removeSplashScreen() {
if (splashDialog != null) {
if (splashDialog != null && splashDialog.isShowing()) {
splashDialog.dismiss();
splashDialog = null;
}

View File

@ -0,0 +1,78 @@
package org.apache.cordova.api;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.res.AssetManager;
import android.content.res.Resources;
public class LegacyContext implements CordovaInterface {
private CordovaInterface cordova;
public LegacyContext(CordovaInterface cordova) {
this.cordova = cordova;
}
public void cancelLoadUrl() {
this.cordova.cancelLoadUrl();
}
public Activity getActivity() {
return this.cordova.getActivity();
}
public Context getContext() {
return this.cordova.getContext();
}
public Object onMessage(String arg0, Object arg1) {
return this.cordova.onMessage(arg0, arg1);
}
public void setActivityResultCallback(IPlugin arg0) {
this.cordova.setActivityResultCallback(arg0);
}
public void startActivityForResult(IPlugin arg0, Intent arg1, int arg2) {
this.cordova.startActivityForResult(arg0, arg1, arg2);
}
public void startActivity(Intent intent) {
this.cordova.getActivity().startActivity(intent);
}
public Object getSystemService(String name) {
return this.cordova.getActivity().getSystemService(name);
}
public AssetManager getAssets() {
return this.cordova.getActivity().getAssets();
}
public void runOnUiThread(Runnable runnable) {
this.cordova.getActivity().runOnUiThread(runnable);
}
public Context getApplicationContext() {
return this.cordova.getActivity().getApplicationContext();
}
public PackageManager getPackageManager() {
return this.cordova.getActivity().getPackageManager();
}
public SharedPreferences getSharedPreferences(String name, int mode) {
return this.cordova.getActivity().getSharedPreferences(name, mode);
}
public void unregisterReceiver(BroadcastReceiver receiver) {
this.cordova.getActivity().unregisterReceiver(receiver);
}
public Resources getResources() {
return this.cordova.getActivity().getResources();
}
}

View File

@ -32,12 +32,12 @@ public abstract class Plugin implements IPlugin {
public String id;
public CordovaWebView webView; // WebView object
public CordovaInterface ctx; // CordovaActivity object
public LegacyContext ctx; // LegacyContext object
public CordovaInterface cordova;
/**
* Executes the request and returns PluginResult.
*
*
* @param action The action to execute.
* @param args JSONArry of arguments for the plugin.
* @param callbackId The callback id used when calling back into JavaScript.
@ -63,13 +63,13 @@ public abstract class Plugin implements IPlugin {
*/
public void setContext(CordovaInterface ctx) {
this.cordova = ctx;
this.ctx = cordova;
this.ctx = new LegacyContext(cordova);
}
/**
* Sets the main View of the application, this is the WebView within which
* Sets the main View of the application, this is the WebView within which
* a Cordova app runs.
*
*
* @param webView The Cordova WebView
*/
public void setView(CordovaWebView webView) {
@ -77,8 +77,8 @@ public abstract class Plugin implements IPlugin {
}
/**
* Called when the system is about to start resuming a previous activity.
*
* Called when the system is about to start resuming a previous activity.
*
* @param multitasking Flag indicating if multitasking is turned on for app
*/
public void onPause(boolean multitasking) {