mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-22 00:32:55 +08:00
Changing to CordovaInterface in preparation of CordovaWebView
This commit is contained in:
parent
52a3a919f9
commit
77547f8826
@ -22,5 +22,5 @@ package com.phonegap.api;
|
|||||||
* The Cordova activity abstract class that is extended by DroidGap.
|
* The Cordova activity abstract class that is extended by DroidGap.
|
||||||
* It is used to isolate plugin development, and remove dependency on entire Cordova library.
|
* It is used to isolate plugin development, and remove dependency on entire Cordova library.
|
||||||
*/
|
*/
|
||||||
public abstract class PhonegapActivity extends org.apache.cordova.api.CordovaActivity {
|
public abstract class PhonegapActivity extends org.apache.cordova.api.CordovaInterface {
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.phonegap.api;
|
package com.phonegap.api;
|
||||||
|
|
||||||
import org.apache.cordova.api.CordovaActivity;
|
import org.apache.cordova.api.CordovaInterface;
|
||||||
|
|
||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ import android.webkit.WebView;
|
|||||||
*/
|
*/
|
||||||
public class PluginManager extends org.apache.cordova.api.PluginManager {
|
public class PluginManager extends org.apache.cordova.api.PluginManager {
|
||||||
|
|
||||||
public PluginManager(WebView app, CordovaActivity ctx) {
|
public PluginManager(WebView app, CordovaInterface ctx) {
|
||||||
super(app, ctx);
|
super(app, ctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ package org.apache.cordova;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.cordova.api.CordovaActivity;
|
import org.apache.cordova.api.CordovaInterface;
|
||||||
import org.apache.cordova.api.Plugin;
|
import org.apache.cordova.api.Plugin;
|
||||||
import org.apache.cordova.api.PluginResult;
|
import org.apache.cordova.api.PluginResult;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
@ -72,7 +72,7 @@ public class AccelListener extends Plugin implements SensorEventListener {
|
|||||||
*
|
*
|
||||||
* @param ctx The context of the main Activity.
|
* @param ctx The context of the main Activity.
|
||||||
*/
|
*/
|
||||||
public void setContext(CordovaActivity ctx) {
|
public void setContext(CordovaInterface ctx) {
|
||||||
super.setContext(ctx);
|
super.setContext(ctx);
|
||||||
this.sensorManager = (SensorManager) ctx.getSystemService(Context.SENSOR_SERVICE);
|
this.sensorManager = (SensorManager) ctx.getSystemService(Context.SENSOR_SERVICE);
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ package org.apache.cordova;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.cordova.api.CordovaActivity;
|
import org.apache.cordova.api.CordovaInterface;
|
||||||
import org.apache.cordova.api.Plugin;
|
import org.apache.cordova.api.Plugin;
|
||||||
import org.apache.cordova.api.PluginResult;
|
import org.apache.cordova.api.PluginResult;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
@ -69,7 +69,7 @@ public class CompassListener extends Plugin implements SensorEventListener {
|
|||||||
*
|
*
|
||||||
* @param ctx The context of the main Activity.
|
* @param ctx The context of the main Activity.
|
||||||
*/
|
*/
|
||||||
public void setContext(CordovaActivity ctx) {
|
public void setContext(CordovaInterface ctx) {
|
||||||
super.setContext(ctx);
|
super.setContext(ctx);
|
||||||
this.sensorManager = (SensorManager) ctx.getSystemService(Context.SENSOR_SERVICE);
|
this.sensorManager = (SensorManager) ctx.getSystemService(Context.SENSOR_SERVICE);
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ package org.apache.cordova;
|
|||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
|
||||||
import org.apache.cordova.api.LOG;
|
import org.apache.cordova.api.LOG;
|
||||||
import org.apache.cordova.api.CordovaActivity;
|
import org.apache.cordova.api.CordovaInterface;
|
||||||
import org.apache.cordova.api.Plugin;
|
import org.apache.cordova.api.Plugin;
|
||||||
import org.apache.cordova.api.PluginResult;
|
import org.apache.cordova.api.PluginResult;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
@ -56,7 +56,7 @@ public class Device extends Plugin {
|
|||||||
*
|
*
|
||||||
* @param ctx The context of the main Activity.
|
* @param ctx The context of the main Activity.
|
||||||
*/
|
*/
|
||||||
public void setContext(CordovaActivity ctx) {
|
public void setContext(CordovaInterface ctx) {
|
||||||
super.setContext(ctx);
|
super.setContext(ctx);
|
||||||
Device.uuid = getUuid();
|
Device.uuid = getUuid();
|
||||||
this.initTelephonyReceiver();
|
this.initTelephonyReceiver();
|
||||||
@ -125,7 +125,7 @@ public class Device extends Plugin {
|
|||||||
private void initTelephonyReceiver() {
|
private void initTelephonyReceiver() {
|
||||||
IntentFilter intentFilter = new IntentFilter() ;
|
IntentFilter intentFilter = new IntentFilter() ;
|
||||||
intentFilter.addAction(TelephonyManager.ACTION_PHONE_STATE_CHANGED);
|
intentFilter.addAction(TelephonyManager.ACTION_PHONE_STATE_CHANGED);
|
||||||
final CordovaActivity myctx = this.ctx;
|
final CordovaInterface myctx = this.ctx;
|
||||||
this.telephonyReceiver = new BroadcastReceiver() {
|
this.telephonyReceiver = new BroadcastReceiver() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -31,7 +31,7 @@ import org.apache.cordova.PreferenceNode;
|
|||||||
import org.apache.cordova.PreferenceSet;
|
import org.apache.cordova.PreferenceSet;
|
||||||
import org.apache.cordova.api.IPlugin;
|
import org.apache.cordova.api.IPlugin;
|
||||||
import org.apache.cordova.api.LOG;
|
import org.apache.cordova.api.LOG;
|
||||||
import org.apache.cordova.api.CordovaActivity;
|
import org.apache.cordova.api.CordovaInterface;
|
||||||
import org.apache.cordova.api.PluginManager;
|
import org.apache.cordova.api.PluginManager;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
@ -159,7 +159,7 @@ import android.widget.LinearLayout;
|
|||||||
* ...
|
* ...
|
||||||
* </plugins>
|
* </plugins>
|
||||||
*/
|
*/
|
||||||
public class DroidGap extends CordovaActivity {
|
public class DroidGap extends CordovaInterface {
|
||||||
public static String TAG = "DroidGap";
|
public static String TAG = "DroidGap";
|
||||||
|
|
||||||
// The webview for our app
|
// The webview for our app
|
||||||
|
@ -25,7 +25,7 @@ import java.net.URLDecoder;
|
|||||||
import java.nio.channels.FileChannel;
|
import java.nio.channels.FileChannel;
|
||||||
|
|
||||||
import org.apache.commons.codec.binary.Base64;
|
import org.apache.commons.codec.binary.Base64;
|
||||||
import org.apache.cordova.api.CordovaActivity;
|
import org.apache.cordova.api.CordovaInterface;
|
||||||
import org.apache.cordova.api.Plugin;
|
import org.apache.cordova.api.Plugin;
|
||||||
import org.apache.cordova.api.PluginResult;
|
import org.apache.cordova.api.PluginResult;
|
||||||
import org.apache.cordova.file.EncodingException;
|
import org.apache.cordova.file.EncodingException;
|
||||||
@ -1014,7 +1014,7 @@ public class FileUtils extends Plugin {
|
|||||||
* @param ctx the current applicaiton context
|
* @param ctx the current applicaiton context
|
||||||
* @return the full path to the file
|
* @return the full path to the file
|
||||||
*/
|
*/
|
||||||
protected static String getRealPathFromURI(Uri contentUri, CordovaActivity ctx) {
|
protected static String getRealPathFromURI(Uri contentUri, CordovaInterface ctx) {
|
||||||
String[] proj = { _DATA };
|
String[] proj = { _DATA };
|
||||||
Cursor cursor = ctx.managedQuery(contentUri, proj, null, null, null);
|
Cursor cursor = ctx.managedQuery(contentUri, proj, null, null, null);
|
||||||
int column_index = cursor.getColumnIndexOrThrow(_DATA);
|
int column_index = cursor.getColumnIndexOrThrow(_DATA);
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
package org.apache.cordova;
|
package org.apache.cordova;
|
||||||
|
|
||||||
import org.apache.cordova.api.CordovaActivity;
|
import org.apache.cordova.api.CordovaInterface;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.location.Location;
|
import android.location.Location;
|
||||||
@ -33,7 +33,7 @@ import android.os.Bundle;
|
|||||||
*/
|
*/
|
||||||
public class GpsListener implements LocationListener {
|
public class GpsListener implements LocationListener {
|
||||||
|
|
||||||
private CordovaActivity mCtx; // CordovaActivity object
|
private CordovaInterface mCtx; // CordovaActivity object
|
||||||
|
|
||||||
private LocationManager mLocMan; // Location manager object
|
private LocationManager mLocMan; // Location manager object
|
||||||
private GeoListener owner; // Geolistener object (parent)
|
private GeoListener owner; // Geolistener object (parent)
|
||||||
@ -49,7 +49,7 @@ public class GpsListener implements LocationListener {
|
|||||||
* @param interval
|
* @param interval
|
||||||
* @param m
|
* @param m
|
||||||
*/
|
*/
|
||||||
public GpsListener(CordovaActivity ctx, int interval, GeoListener m) {
|
public GpsListener(CordovaInterface ctx, int interval, GeoListener m) {
|
||||||
this.owner = m;
|
this.owner = m;
|
||||||
this.mCtx = ctx;
|
this.mCtx = ctx;
|
||||||
this.mLocMan = (LocationManager) this.mCtx.getSystemService(Context.LOCATION_SERVICE);
|
this.mLocMan = (LocationManager) this.mCtx.getSystemService(Context.LOCATION_SERVICE);
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.cordova;
|
package org.apache.cordova;
|
||||||
|
|
||||||
import org.apache.cordova.api.CordovaActivity;
|
import org.apache.cordova.api.CordovaInterface;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.location.Location;
|
import android.location.Location;
|
||||||
@ -28,7 +28,7 @@ import android.os.Bundle;
|
|||||||
|
|
||||||
public class NetworkListener implements LocationListener {
|
public class NetworkListener implements LocationListener {
|
||||||
|
|
||||||
private CordovaActivity mCtx; // CordovaActivity object
|
private CordovaInterface mCtx; // CordovaActivity object
|
||||||
|
|
||||||
private LocationManager mLocMan; // Location manager object
|
private LocationManager mLocMan; // Location manager object
|
||||||
private GeoListener owner; // Geolistener object (parent)
|
private GeoListener owner; // Geolistener object (parent)
|
||||||
@ -44,7 +44,7 @@ public class NetworkListener implements LocationListener {
|
|||||||
* @param interval
|
* @param interval
|
||||||
* @param m
|
* @param m
|
||||||
*/
|
*/
|
||||||
public NetworkListener(CordovaActivity ctx, int interval, GeoListener m) {
|
public NetworkListener(CordovaInterface ctx, int interval, GeoListener m) {
|
||||||
this.owner = m;
|
this.owner = m;
|
||||||
this.mCtx = ctx;
|
this.mCtx = ctx;
|
||||||
this.mLocMan = (LocationManager) this.mCtx.getSystemService(Context.LOCATION_SERVICE);
|
this.mLocMan = (LocationManager) this.mCtx.getSystemService(Context.LOCATION_SERVICE);
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.cordova;
|
package org.apache.cordova;
|
||||||
|
|
||||||
import org.apache.cordova.api.CordovaActivity;
|
import org.apache.cordova.api.CordovaInterface;
|
||||||
import org.apache.cordova.api.Plugin;
|
import org.apache.cordova.api.Plugin;
|
||||||
import org.apache.cordova.api.PluginResult;
|
import org.apache.cordova.api.PluginResult;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
@ -87,7 +87,7 @@ public class NetworkManager extends Plugin {
|
|||||||
*
|
*
|
||||||
* @param ctx The context of the main Activity.
|
* @param ctx The context of the main Activity.
|
||||||
*/
|
*/
|
||||||
public void setContext(CordovaActivity ctx) {
|
public void setContext(CordovaInterface ctx) {
|
||||||
super.setContext(ctx);
|
super.setContext(ctx);
|
||||||
this.sockMan = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE);
|
this.sockMan = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
this.connectionCallbackId = null;
|
this.connectionCallbackId = null;
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.cordova;
|
package org.apache.cordova;
|
||||||
|
|
||||||
import org.apache.cordova.api.CordovaActivity;
|
import org.apache.cordova.api.CordovaInterface;
|
||||||
import org.apache.cordova.api.Plugin;
|
import org.apache.cordova.api.Plugin;
|
||||||
import org.apache.cordova.api.PluginResult;
|
import org.apache.cordova.api.PluginResult;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
@ -184,7 +184,7 @@ public class Notification extends Plugin {
|
|||||||
*/
|
*/
|
||||||
public synchronized void alert(final String message, final String title, final String buttonLabel, final String callbackId) {
|
public synchronized void alert(final String message, final String title, final String buttonLabel, final String callbackId) {
|
||||||
|
|
||||||
final CordovaActivity ctx = this.ctx;
|
final CordovaInterface ctx = this.ctx;
|
||||||
final Notification notification = this;
|
final Notification notification = this;
|
||||||
|
|
||||||
Runnable runnable = new Runnable() {
|
Runnable runnable = new Runnable() {
|
||||||
@ -220,7 +220,7 @@ public class Notification extends Plugin {
|
|||||||
*/
|
*/
|
||||||
public synchronized void confirm(final String message, final String title, String buttonLabels, final String callbackId) {
|
public synchronized void confirm(final String message, final String title, String buttonLabels, final String callbackId) {
|
||||||
|
|
||||||
final CordovaActivity ctx = this.ctx;
|
final CordovaInterface ctx = this.ctx;
|
||||||
final Notification notification = this;
|
final Notification notification = this;
|
||||||
final String[] fButtons = buttonLabels.split(",");
|
final String[] fButtons = buttonLabels.split(",");
|
||||||
|
|
||||||
@ -284,7 +284,7 @@ public class Notification extends Plugin {
|
|||||||
this.spinnerDialog = null;
|
this.spinnerDialog = null;
|
||||||
}
|
}
|
||||||
final Notification notification = this;
|
final Notification notification = this;
|
||||||
final CordovaActivity ctx = this.ctx;
|
final CordovaInterface ctx = this.ctx;
|
||||||
Runnable runnable = new Runnable() {
|
Runnable runnable = new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
notification.spinnerDialog = ProgressDialog.show(ctx, title , message, true, true,
|
notification.spinnerDialog = ProgressDialog.show(ctx, title , message, true, true,
|
||||||
@ -320,7 +320,7 @@ public class Notification extends Plugin {
|
|||||||
this.progressDialog = null;
|
this.progressDialog = null;
|
||||||
}
|
}
|
||||||
final Notification notification = this;
|
final Notification notification = this;
|
||||||
final CordovaActivity ctx = this.ctx;
|
final CordovaInterface ctx = this.ctx;
|
||||||
Runnable runnable = new Runnable() {
|
Runnable runnable = new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
notification.progressDialog = new ProgressDialog(ctx);
|
notification.progressDialog = new ProgressDialog(ctx);
|
||||||
|
@ -20,7 +20,7 @@ package org.apache.cordova;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.cordova.api.CordovaActivity;
|
import org.apache.cordova.api.CordovaInterface;
|
||||||
import org.apache.cordova.api.Plugin;
|
import org.apache.cordova.api.Plugin;
|
||||||
import org.apache.cordova.api.PluginResult;
|
import org.apache.cordova.api.PluginResult;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
@ -49,7 +49,7 @@ public class TempListener extends Plugin implements SensorEventListener {
|
|||||||
*
|
*
|
||||||
* @param ctx The context of the main Activity.
|
* @param ctx The context of the main Activity.
|
||||||
*/
|
*/
|
||||||
public void setContext(CordovaActivity ctx) {
|
public void setContext(CordovaInterface ctx) {
|
||||||
super.setContext(ctx);
|
super.setContext(ctx);
|
||||||
this.sensorManager = (SensorManager) ctx.getSystemService(Context.SENSOR_SERVICE);
|
this.sensorManager = (SensorManager) ctx.getSystemService(Context.SENSOR_SERVICE);
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ import android.content.Intent;
|
|||||||
* The Cordova activity abstract class that is extended by DroidGap.
|
* The Cordova activity abstract class that is extended by DroidGap.
|
||||||
* It is used to isolate plugin development, and remove dependency on entire Cordova library.
|
* It is used to isolate plugin development, and remove dependency on entire Cordova library.
|
||||||
*/
|
*/
|
||||||
public abstract class CordovaActivity extends Activity {
|
public abstract class CordovaInterface extends Activity {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated
|
* @deprecated
|
@ -53,7 +53,7 @@ public interface IPlugin {
|
|||||||
*
|
*
|
||||||
* @param ctx The context of the main Activity.
|
* @param ctx The context of the main Activity.
|
||||||
*/
|
*/
|
||||||
void setContext(CordovaActivity ctx);
|
void setContext(CordovaInterface ctx);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
||||||
|
@ -33,7 +33,7 @@ public abstract class Plugin implements IPlugin {
|
|||||||
|
|
||||||
public String id;
|
public String id;
|
||||||
public WebView webView; // WebView object
|
public WebView webView; // WebView object
|
||||||
public CordovaActivity ctx; // CordovaActivity object
|
public CordovaInterface ctx; // CordovaActivity object
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes the request and returns PluginResult.
|
* Executes the request and returns PluginResult.
|
||||||
@ -61,7 +61,7 @@ public abstract class Plugin implements IPlugin {
|
|||||||
*
|
*
|
||||||
* @param ctx The context of the main Activity.
|
* @param ctx The context of the main Activity.
|
||||||
*/
|
*/
|
||||||
public void setContext(CordovaActivity ctx) {
|
public void setContext(CordovaInterface ctx) {
|
||||||
this.ctx = ctx;
|
this.ctx = ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ public class PluginManager {
|
|||||||
private HashMap<String, IPlugin> plugins = new HashMap<String,IPlugin>();
|
private HashMap<String, IPlugin> plugins = new HashMap<String,IPlugin>();
|
||||||
private HashMap<String, String> services = new HashMap<String,String>();
|
private HashMap<String, String> services = new HashMap<String,String>();
|
||||||
|
|
||||||
private final CordovaActivity ctx;
|
private final CordovaInterface ctx;
|
||||||
private final WebView app;
|
private final WebView app;
|
||||||
|
|
||||||
// Map URL schemes like foo: to plugins that want to handle those schemes
|
// Map URL schemes like foo: to plugins that want to handle those schemes
|
||||||
@ -56,7 +56,7 @@ public class PluginManager {
|
|||||||
* @param app
|
* @param app
|
||||||
* @param ctx
|
* @param ctx
|
||||||
*/
|
*/
|
||||||
public PluginManager(WebView app, CordovaActivity ctx) {
|
public PluginManager(WebView app, CordovaInterface ctx) {
|
||||||
this.ctx = ctx;
|
this.ctx = ctx;
|
||||||
this.app = app;
|
this.app = app;
|
||||||
this.loadPlugins();
|
this.loadPlugins();
|
||||||
@ -138,7 +138,7 @@ public class PluginManager {
|
|||||||
try {
|
try {
|
||||||
final JSONArray args = new JSONArray(jsonArgs);
|
final JSONArray args = new JSONArray(jsonArgs);
|
||||||
final IPlugin plugin = this.getPlugin(service);
|
final IPlugin plugin = this.getPlugin(service);
|
||||||
final CordovaActivity ctx = this.ctx;
|
final CordovaInterface ctx = this.ctx;
|
||||||
if (plugin != null) {
|
if (plugin != null) {
|
||||||
runAsync = async && !plugin.isSynch(action);
|
runAsync = async && !plugin.isSynch(action);
|
||||||
if (runAsync) {
|
if (runAsync) {
|
||||||
|
Loading…
Reference in New Issue
Block a user