mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-20 23:56:20 +08:00
CB-993: Android plugin problems upgrading to 1.9.0
This commit is contained in:
parent
b97748d3dc
commit
0180342dff
78
framework/src/org/apache/cordova/api/LegacyContext.java
Normal file
78
framework/src/org/apache/cordova/api/LegacyContext.java
Normal 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();
|
||||
}
|
||||
}
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user