CB-993: Android plugin problems upgrading to 1.9.0

This commit is contained in:
macdonst 2012-07-10 16:26:52 -04:00
parent b97748d3dc
commit 0180342dff
2 changed files with 85 additions and 7 deletions

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) {