You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by bc...@apache.org on 2012/05/15 06:38:02 UTC
[14/15] Updates.
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/c8fafa6b/framework/src/org/apache/cordova/GpsListener.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/GpsListener.java b/framework/src/org/apache/cordova/GpsListener.java
index 264c00c..6cd85fb 100755
--- a/framework/src/org/apache/cordova/GpsListener.java
+++ b/framework/src/org/apache/cordova/GpsListener.java
@@ -32,132 +32,132 @@ import android.os.Bundle;
*
*/
public class GpsListener implements LocationListener {
-
- private Context mCtx; // CordovaActivity object
-
- private LocationManager mLocMan; // Location manager object
- private GeoListener owner; // Geolistener object (parent)
- private boolean hasData = false; // Flag indicates if location data is available in cLoc
- private Location cLoc; // Last recieved location
- private boolean running = false; // Flag indicates if listener is running
-
- /**
- * Constructor.
- * Automatically starts listening.
- *
- * @param ctx
- * @param interval
- * @param m
- */
- public GpsListener(Context ctx, int interval, GeoListener m) {
- this.owner = m;
- this.mCtx = ctx;
- this.mLocMan = (LocationManager) this.mCtx.getSystemService(Context.LOCATION_SERVICE);
- this.running = false;
- this.start(interval);
- }
-
- /**
- * Get last location.
- *
- * @return Location object
- */
- public Location getLocation() {
- this.cLoc = this.mLocMan.getLastKnownLocation(LocationManager.GPS_PROVIDER);
- if (this.cLoc != null) {
- this.hasData = true;
- }
- return this.cLoc;
- }
-
- /**
- * Called when the provider is disabled by the user.
- *
- * @param provider
- */
- public void onProviderDisabled(String provider) {
- this.owner.fail(GeoListener.POSITION_UNAVAILABLE, "GPS provider disabled.");
- }
-
- /**
- * Called when the provider is enabled by the user.
- *
- * @param provider
- */
- public void onProviderEnabled(String provider) {
- System.out.println("GpsListener: The provider "+ provider + " is enabled");
- }
-
- /**
- * Called when the provider status changes. This method is called when a
- * provider is unable to fetch a location or if the provider has recently
- * become available after a period of unavailability.
- *
- * @param provider
- * @param status
- * @param extras
- */
- public void onStatusChanged(String provider, int status, Bundle extras) {
- System.out.println("GpsListener: The status of the provider " + provider + " has changed");
- if (status == 0) {
- System.out.println("GpsListener: " + provider + " is OUT OF SERVICE");
- this.owner.fail(GeoListener.POSITION_UNAVAILABLE, "GPS out of service.");
- }
- else if (status == 1) {
- System.out.println("GpsListener: " + provider + " is TEMPORARILY_UNAVAILABLE");
- }
- else {
- System.out.println("GpsListener: " + provider + " is Available");
- }
- }
-
- /**
- * Called when the location has changed.
- *
- * @param location
- */
- public void onLocationChanged(Location location) {
- System.out.println("GpsListener: The location has been updated!");
- this.hasData = true;
- this.cLoc = location;
- this.owner.success(location);
- }
-
- /**
- * Determine if location data is available.
- *
- * @return
- */
- public boolean hasLocation() {
- return this.hasData;
- }
-
- /**
- * Start requesting location updates.
- *
- * @param interval
- */
- public void start(int interval) {
- if (!this.running) {
- this.running = true;
- this.mLocMan.requestLocationUpdates(LocationManager.GPS_PROVIDER, interval, 0, this);
- this.getLocation();
-
- // If GPS provider has data, then send now
- if (this.hasData) {
- this.owner.success(this.cLoc);
- }
- }
- }
-
- /**
- * Stop receiving location updates.
- */
- public void stop() {
- if (this.running) {
- this.mLocMan.removeUpdates(this);
- }
- this.running = false;
- }
-
+
+ private CordovaInterface mCtx; // CordovaActivity object
+
+ private LocationManager mLocMan; // Location manager object
+ private GeoListener owner; // Geolistener object (parent)
+ private boolean hasData = false; // Flag indicates if location data is available in cLoc
+ private Location cLoc; // Last recieved location
+ private boolean running = false; // Flag indicates if listener is running
+
+ /**
+ * Constructor.
+ * Automatically starts listening.
+ *
+ * @param ctx
+ * @param interval
+ * @param m
+ */
+ public GpsListener(CordovaInterface ctx, int interval, GeoListener m) {
+ this.owner = m;
+ this.mCtx = ctx;
+ this.mLocMan = (LocationManager) this.mCtx.getActivity().getSystemService(Context.LOCATION_SERVICE);
+ this.running = false;
+ this.start(interval);
+ }
+
+ /**
+ * Get last location.
+ *
+ * @return Location object
+ */
+ public Location getLocation() {
+ this.cLoc = this.mLocMan.getLastKnownLocation(LocationManager.GPS_PROVIDER);
+ if (this.cLoc != null) {
+ this.hasData = true;
+ }
+ return this.cLoc;
+ }
+
+ /**
+ * Called when the provider is disabled by the user.
+ *
+ * @param provider
+ */
+ public void onProviderDisabled(String provider) {
+ this.owner.fail(GeoListener.POSITION_UNAVAILABLE, "GPS provider disabled.");
+ }
+
+ /**
+ * Called when the provider is enabled by the user.
+ *
+ * @param provider
+ */
+ public void onProviderEnabled(String provider) {
+ System.out.println("GpsListener: The provider " + provider + " is enabled");
+ }
+
+ /**
+ * Called when the provider status changes. This method is called when a
+ * provider is unable to fetch a location or if the provider has recently
+ * become available after a period of unavailability.
+ *
+ * @param provider
+ * @param status
+ * @param extras
+ */
+ public void onStatusChanged(String provider, int status, Bundle extras) {
+ System.out.println("GpsListener: The status of the provider " + provider + " has changed");
+ if (status == 0) {
+ System.out.println("GpsListener: " + provider + " is OUT OF SERVICE");
+ this.owner.fail(GeoListener.POSITION_UNAVAILABLE, "GPS out of service.");
+ }
+ else if (status == 1) {
+ System.out.println("GpsListener: " + provider + " is TEMPORARILY_UNAVAILABLE");
+ }
+ else {
+ System.out.println("GpsListener: " + provider + " is Available");
+ }
+ }
+
+ /**
+ * Called when the location has changed.
+ *
+ * @param location
+ */
+ public void onLocationChanged(Location location) {
+ System.out.println("GpsListener: The location has been updated!");
+ this.hasData = true;
+ this.cLoc = location;
+ this.owner.success(location);
+ }
+
+ /**
+ * Determine if location data is available.
+ *
+ * @return
+ */
+ public boolean hasLocation() {
+ return this.hasData;
+ }
+
+ /**
+ * Start requesting location updates.
+ *
+ * @param interval
+ */
+ public void start(int interval) {
+ if (!this.running) {
+ this.running = true;
+ this.mLocMan.requestLocationUpdates(LocationManager.GPS_PROVIDER, interval, 0, this);
+ this.getLocation();
+
+ // If GPS provider has data, then send now
+ if (this.hasData) {
+ this.owner.success(this.cLoc);
+ }
+ }
+ }
+
+ /**
+ * Stop receiving location updates.
+ */
+ public void stop() {
+ if (this.running) {
+ this.mLocMan.removeUpdates(this);
+ }
+ this.running = false;
+ }
+
}
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/c8fafa6b/framework/src/org/apache/cordova/HttpHandler.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/HttpHandler.java b/framework/src/org/apache/cordova/HttpHandler.java
index f64b5fd..4799e31 100755
--- a/framework/src/org/apache/cordova/HttpHandler.java
+++ b/framework/src/org/apache/cordova/HttpHandler.java
@@ -29,52 +29,61 @@ import org.apache.http.impl.client.DefaultHttpClient;
public class HttpHandler {
- protected Boolean get(String url, String file)
- {
- HttpEntity entity = getHttpEntity(url);
- try {
- writeToDisk(entity, file);
- } catch (Exception e) { e.printStackTrace(); return false; }
- try {
- entity.consumeContent();
- } catch (Exception e) { e.printStackTrace(); return false; }
- return true;
- }
-
- private HttpEntity getHttpEntity(String url)
- /**
- * get the http entity at a given url
- */
- {
- HttpEntity entity=null;
- try {
- DefaultHttpClient httpclient = new DefaultHttpClient();
- HttpGet httpget = new HttpGet(url);
- HttpResponse response = httpclient.execute(httpget);
- entity = response.getEntity();
- } catch (Exception e) { e.printStackTrace(); return null; }
- return entity;
- }
-
- private void writeToDisk(HttpEntity entity, String file) throws IllegalStateException, IOException
- /**
- * writes a HTTP entity to the specified filename and location on disk
- */
- {
- int i=0;
- String FilePath="/sdcard/" + file;
- InputStream in = entity.getContent();
- byte buff[] = new byte[1024];
- FileOutputStream out=
- new FileOutputStream(FilePath);
- do {
- int numread = in.read(buff);
- if (numread <= 0)
- break;
- out.write(buff, 0, numread);
- i++;
- } while (true);
- out.flush();
- out.close();
- }
+ protected Boolean get(String url, String file)
+ {
+ HttpEntity entity = getHttpEntity(url);
+ try {
+ writeToDisk(entity, file);
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ try {
+ entity.consumeContent();
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ return true;
+ }
+
+ private HttpEntity getHttpEntity(String url)
+ /**
+ * get the http entity at a given url
+ */
+ {
+ HttpEntity entity = null;
+ try {
+ DefaultHttpClient httpclient = new DefaultHttpClient();
+ HttpGet httpget = new HttpGet(url);
+ HttpResponse response = httpclient.execute(httpget);
+ entity = response.getEntity();
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ return entity;
+ }
+
+ private void writeToDisk(HttpEntity entity, String file) throws IllegalStateException, IOException
+ /**
+ * writes a HTTP entity to the specified filename and location on disk
+ */
+ {
+ int i = 0;
+ String FilePath = "/sdcard/" + file;
+ InputStream in = entity.getContent();
+ byte buff[] = new byte[1024];
+ FileOutputStream out =
+ new FileOutputStream(FilePath);
+ do {
+ int numread = in.read(buff);
+ if (numread <= 0)
+ break;
+ out.write(buff, 0, numread);
+ i++;
+ } while (true);
+ out.flush();
+ out.close();
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/c8fafa6b/framework/src/org/apache/cordova/LinearLayoutSoftKeyboardDetect.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/LinearLayoutSoftKeyboardDetect.java b/framework/src/org/apache/cordova/LinearLayoutSoftKeyboardDetect.java
index a024b23..de70020 100755
--- a/framework/src/org/apache/cordova/LinearLayoutSoftKeyboardDetect.java
+++ b/framework/src/org/apache/cordova/LinearLayoutSoftKeyboardDetect.java
@@ -17,10 +17,11 @@
under the License.
*/
package org.apache.cordova;
+
import org.apache.cordova.api.LOG;
import android.content.Context;
-import android.view.View.MeasureSpec;
+//import android.view.View.MeasureSpec;
import android.widget.LinearLayout;
/**
@@ -29,15 +30,15 @@ import android.widget.LinearLayout;
public class LinearLayoutSoftKeyboardDetect extends LinearLayout {
private static final String TAG = "SoftKeyboardDetect";
-
+
private int oldHeight = 0; // Need to save the old height as not to send redundant events
private int oldWidth = 0; // Need to save old width for orientation change
private int screenWidth = 0;
private int screenHeight = 0;
private DroidGap app = null;
-
+
public LinearLayoutSoftKeyboardDetect(Context context, int width, int height) {
- super(context);
+ super(context);
screenWidth = width;
screenHeight = height;
app = (DroidGap) context;
@@ -55,8 +56,8 @@ public class LinearLayoutSoftKeyboardDetect extends LinearLayout {
* @param heightMeasureSpec
*/
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- super.onMeasure(widthMeasureSpec, heightMeasureSpec);
-
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+
LOG.v(TAG, "We are in our onMeasure method");
// Get the current height of the visible part of the screen.
@@ -66,7 +67,7 @@ public class LinearLayoutSoftKeyboardDetect extends LinearLayout {
height = MeasureSpec.getSize(heightMeasureSpec);
width = MeasureSpec.getSize(widthMeasureSpec);
LOG.v(TAG, "Old Height = %d", oldHeight);
- LOG.v(TAG, "Height = %d", height);
+ LOG.v(TAG, "Height = %d", height);
LOG.v(TAG, "Old Width = %d", oldWidth);
LOG.v(TAG, "Width = %d", width);
@@ -76,7 +77,7 @@ public class LinearLayoutSoftKeyboardDetect extends LinearLayout {
LOG.d(TAG, "Ignore this event");
}
// Account for orientation change and ignore this event/Fire orientation change
- else if(screenHeight == width)
+ else if (screenHeight == width)
{
int tmp_var = screenHeight;
screenHeight = screenWidth;
@@ -86,14 +87,14 @@ public class LinearLayoutSoftKeyboardDetect extends LinearLayout {
// If the height as gotten bigger then we will assume the soft keyboard has
// gone away.
else if (height > oldHeight) {
- if(app != null)
- app.sendJavascript("cordova.fireDocumentEvent('hidekeyboard');");
- }
+ if (app != null)
+ app.appView.sendJavascript("cordova.fireDocumentEvent('hidekeyboard');");
+ }
// If the height as gotten smaller then we will assume the soft keyboard has
// been displayed.
else if (height < oldHeight) {
- if(app != null)
- app.sendJavascript("cordova.fireDocumentEvent('showkeyboard');");
+ if (app != null)
+ app.appView.sendJavascript("cordova.fireDocumentEvent('showkeyboard');");
}
// Update the old height for the next event
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/c8fafa6b/framework/src/org/apache/cordova/NetworkListener.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/NetworkListener.java b/framework/src/org/apache/cordova/NetworkListener.java
index 1b70cd7..7fa135f 100755
--- a/framework/src/org/apache/cordova/NetworkListener.java
+++ b/framework/src/org/apache/cordova/NetworkListener.java
@@ -27,127 +27,127 @@ import android.location.LocationListener;
import android.os.Bundle;
public class NetworkListener implements LocationListener {
-
- private Context mCtx; // CordovaActivity object
-
- private LocationManager mLocMan; // Location manager object
- private GeoListener owner; // Geolistener object (parent)
- private boolean hasData = false; // Flag indicates if location data is available in cLoc
- private Location cLoc; // Last recieved location
- private boolean running = false; // Flag indicates if listener is running
-
- /**
- * Constructor.
- * Automatically starts listening.
- *
- * @param ctx
- * @param interval
- * @param m
- */
- public NetworkListener(Context ctx, int interval, GeoListener m) {
- this.owner = m;
- this.mCtx = ctx;
- this.mLocMan = (LocationManager) this.mCtx.getSystemService(Context.LOCATION_SERVICE);
- this.running = false;
- this.start(interval);
- }
-
- /**
- * Get last location.
- *
- * @return Location object
- */
- public Location getLocation() {
- this.cLoc = this.mLocMan.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
- if (this.cLoc != null) {
- this.hasData = true;
- }
- return this.cLoc;
- }
-
- /**
- * Called when the provider is disabled by the user.
- *
- * @param provider
- */
- public void onProviderDisabled(String provider) {
- System.out.println("NetworkListener: The provider " + provider + " is disabled");
- }
-
- /**
- * Called when the provider is enabled by the user.
- *
- * @param provider
- */
- public void onProviderEnabled(String provider) {
- System.out.println("NetworkListener: The provider "+ provider + " is enabled");
- }
-
- /**
- * Called when the provider status changes. This method is called when a
- * provider is unable to fetch a location or if the provider has recently
- * become available after a period of unavailability.
- *
- * @param provider
- * @param status
- * @param extras
- */
- public void onStatusChanged(String provider, int status, Bundle extras) {
- System.out.println("NetworkListener: The status of the provider " + provider + " has changed");
- if (status == 0) {
- System.out.println("NetworkListener: " + provider + " is OUT OF SERVICE");
- }
- else if (status == 1) {
- System.out.println("NetworkListener: " + provider + " is TEMPORARILY_UNAVAILABLE");
- }
- else {
- System.out.println("NetworkListener: " + provider + " is Available");
- }
- }
-
- /**
- * Called when the location has changed.
- *
- * @param location
- */
- public void onLocationChanged(Location location) {
- System.out.println("NetworkListener: The location has been updated!");
- this.hasData = true;
- this.cLoc = location;
-
- // The GPS is the primary form of Geolocation in Cordova.
- // Only fire the success variables if the GPS is down for some reason.
- if (!this.owner.mGps.hasLocation()) {
- this.owner.success(location);
- }
- }
-
- /**
- * Start requesting location updates.
- *
- * @param interval
- */
- public void start(int interval) {
- if (!this.running) {
- this.running = true;
- this.mLocMan.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, interval, 0, this);
- this.getLocation();
-
- // If Network provider has data but GPS provider doesn't, then send ours
- if (this.hasData && !this.owner.mGps.hasLocation()) {
- this.owner.success(this.cLoc);
- }
- }
- }
-
- /**
- * Stop receiving location updates.
- */
- public void stop() {
- if (this.running) {
- this.mLocMan.removeUpdates(this);
- }
- this.running = false;
- }
-
+
+ private CordovaInterface mCtx; // CordovaActivity object
+
+ private LocationManager mLocMan; // Location manager object
+ private GeoListener owner; // Geolistener object (parent)
+ private boolean hasData = false; // Flag indicates if location data is available in cLoc
+ private Location cLoc; // Last recieved location
+ private boolean running = false; // Flag indicates if listener is running
+
+ /**
+ * Constructor.
+ * Automatically starts listening.
+ *
+ * @param ctx
+ * @param interval
+ * @param m
+ */
+ public NetworkListener(CordovaInterface ctx, int interval, GeoListener m) {
+ this.owner = m;
+ this.mCtx = ctx;
+ this.mLocMan = (LocationManager) this.mCtx.getActivity().getSystemService(Context.LOCATION_SERVICE);
+ this.running = false;
+ this.start(interval);
+ }
+
+ /**
+ * Get last location.
+ *
+ * @return Location object
+ */
+ public Location getLocation() {
+ this.cLoc = this.mLocMan.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
+ if (this.cLoc != null) {
+ this.hasData = true;
+ }
+ return this.cLoc;
+ }
+
+ /**
+ * Called when the provider is disabled by the user.
+ *
+ * @param provider
+ */
+ public void onProviderDisabled(String provider) {
+ System.out.println("NetworkListener: The provider " + provider + " is disabled");
+ }
+
+ /**
+ * Called when the provider is enabled by the user.
+ *
+ * @param provider
+ */
+ public void onProviderEnabled(String provider) {
+ System.out.println("NetworkListener: The provider " + provider + " is enabled");
+ }
+
+ /**
+ * Called when the provider status changes. This method is called when a
+ * provider is unable to fetch a location or if the provider has recently
+ * become available after a period of unavailability.
+ *
+ * @param provider
+ * @param status
+ * @param extras
+ */
+ public void onStatusChanged(String provider, int status, Bundle extras) {
+ System.out.println("NetworkListener: The status of the provider " + provider + " has changed");
+ if (status == 0) {
+ System.out.println("NetworkListener: " + provider + " is OUT OF SERVICE");
+ }
+ else if (status == 1) {
+ System.out.println("NetworkListener: " + provider + " is TEMPORARILY_UNAVAILABLE");
+ }
+ else {
+ System.out.println("NetworkListener: " + provider + " is Available");
+ }
+ }
+
+ /**
+ * Called when the location has changed.
+ *
+ * @param location
+ */
+ public void onLocationChanged(Location location) {
+ System.out.println("NetworkListener: The location has been updated!");
+ this.hasData = true;
+ this.cLoc = location;
+
+ // The GPS is the primary form of Geolocation in Cordova.
+ // Only fire the success variables if the GPS is down for some reason.
+ if (!this.owner.mGps.hasLocation()) {
+ this.owner.success(location);
+ }
+ }
+
+ /**
+ * Start requesting location updates.
+ *
+ * @param interval
+ */
+ public void start(int interval) {
+ if (!this.running) {
+ this.running = true;
+ this.mLocMan.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, interval, 0, this);
+ this.getLocation();
+
+ // If Network provider has data but GPS provider doesn't, then send ours
+ if (this.hasData && !this.owner.mGps.hasLocation()) {
+ this.owner.success(this.cLoc);
+ }
+ }
+ }
+
+ /**
+ * Stop receiving location updates.
+ */
+ public void stop() {
+ if (this.running) {
+ this.mLocMan.removeUpdates(this);
+ }
+ this.running = false;
+ }
+
}
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/c8fafa6b/framework/src/org/apache/cordova/NetworkManager.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/NetworkManager.java b/framework/src/org/apache/cordova/NetworkManager.java
index 6ef0c3e..36fbbb3 100755
--- a/framework/src/org/apache/cordova/NetworkManager.java
+++ b/framework/src/org/apache/cordova/NetworkManager.java
@@ -23,7 +23,6 @@ import org.apache.cordova.api.Plugin;
import org.apache.cordova.api.PluginResult;
import org.json.JSONArray;
-
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -33,7 +32,7 @@ import android.net.NetworkInfo;
import android.util.Log;
public class NetworkManager extends Plugin {
-
+
public static int NOT_REACHABLE = 0;
public static int REACHABLE_VIA_CARRIER_DATA_NETWORK = 1;
public static int REACHABLE_VIA_WIFI_NETWORK = 2;
@@ -66,18 +65,18 @@ public class NetworkManager extends Plugin {
public static final String TYPE_3G = "3g";
public static final String TYPE_4G = "4g";
public static final String TYPE_NONE = "none";
-
+
private static final String LOG_TAG = "NetworkManager";
private String connectionCallbackId;
ConnectivityManager sockMan;
BroadcastReceiver receiver;
-
+
/**
* Constructor.
*/
- public NetworkManager() {
+ public NetworkManager() {
this.receiver = null;
}
@@ -87,26 +86,27 @@ public class NetworkManager extends Plugin {
*
* @param ctx The context of the main Activity.
*/
- public void setContext(Context ctx) {
+ public void setContext(CordovaInterface ctx) {
super.setContext(ctx);
- this.sockMan = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE);
+ this.sockMan = (ConnectivityManager) ctx.getActivity().getSystemService(Context.CONNECTIVITY_SERVICE);
this.connectionCallbackId = null;
-
+
// We need to listen to connectivity events to update navigator.connection
- IntentFilter intentFilter = new IntentFilter() ;
+ IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
if (this.receiver == null) {
this.receiver = new BroadcastReceiver() {
+ @SuppressWarnings("deprecation")
@Override
public void onReceive(Context context, Intent intent) {
- updateConnectionInfo((NetworkInfo) intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO));
+ updateConnectionInfo((NetworkInfo) intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO));
}
};
- ctx.registerReceiver(this.receiver, intentFilter);
+ ctx.getActivity().registerReceiver(this.receiver, intentFilter);
}
}
-
+
/**
* Executes the request and returns PluginResult.
*
@@ -118,7 +118,7 @@ public class NetworkManager extends Plugin {
public PluginResult execute(String action, JSONArray args, String callbackId) {
PluginResult.Status status = PluginResult.Status.INVALID_ACTION;
String result = "Unsupported Operation: " + action;
-
+
if (action.equals("getConnectionInfo")) {
this.connectionCallbackId = callbackId;
NetworkInfo info = sockMan.getActiveNetworkInfo();
@@ -126,7 +126,7 @@ public class NetworkManager extends Plugin {
pluginResult.setKeepCallback(true);
return pluginResult;
}
-
+
return new PluginResult(status, result);
}
@@ -139,14 +139,14 @@ public class NetworkManager extends Plugin {
public boolean isSynch(String action) {
return true;
}
-
+
/**
* Stop network receiver.
*/
public void onDestroy() {
if (this.receiver != null) {
try {
- this.ctx.unregisterReceiver(this.receiver);
+ this.ctx.getActivity().unregisterReceiver(this.receiver);
} catch (Exception e) {
Log.e(LOG_TAG, "Error unregistering network receiver: " + e.getMessage(), e);
}
@@ -157,14 +157,13 @@ public class NetworkManager extends Plugin {
// LOCAL METHODS
//--------------------------------------------------------------------------
-
/**
* Updates the JavaScript side whenever the connection changes
*
* @param info the current active network info
* @return
*/
- private void updateConnectionInfo(NetworkInfo info) {
+ private void updateConnectionInfo(NetworkInfo info) {
// send update to javascript "navigator.network.connection"
sendUpdate(this.getConnectionInfo(info));
}
@@ -188,7 +187,7 @@ public class NetworkManager extends Plugin {
}
return type;
}
-
+
/**
* Create a new plugin result and send it back to JavaScript
*
@@ -198,11 +197,11 @@ public class NetworkManager extends Plugin {
PluginResult result = new PluginResult(PluginResult.Status.OK, type);
result.setKeepCallback(true);
this.success(result, this.connectionCallbackId);
-
+
// Send to all plugins
webView.postMessage("networkconnection", type);
}
-
+
/**
* Determine the type of connection
*
@@ -218,13 +217,13 @@ public class NetworkManager extends Plugin {
}
else if (type.toLowerCase().equals(MOBILE)) {
type = info.getSubtypeName();
- if (type.toLowerCase().equals(GSM) ||
+ if (type.toLowerCase().equals(GSM) ||
type.toLowerCase().equals(GPRS) ||
type.toLowerCase().equals(EDGE)) {
return TYPE_2G;
}
- else if (type.toLowerCase().startsWith(CDMA) ||
- type.toLowerCase().equals(UMTS) ||
+ else if (type.toLowerCase().startsWith(CDMA) ||
+ type.toLowerCase().equals(UMTS) ||
type.toLowerCase().equals(ONEXRTT) ||
type.toLowerCase().equals(EHRPD) ||
type.toLowerCase().equals(HSUPA) ||
@@ -232,13 +231,13 @@ public class NetworkManager extends Plugin {
type.toLowerCase().equals(HSPA)) {
return TYPE_3G;
}
- else if (type.toLowerCase().equals(LTE) ||
+ else if (type.toLowerCase().equals(LTE) ||
type.toLowerCase().equals(UMB) ||
type.toLowerCase().equals(HSPA_PLUS)) {
return TYPE_4G;
}
}
- }
+ }
else {
return TYPE_NONE;
}
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/c8fafa6b/framework/src/org/apache/cordova/Notification.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/Notification.java b/framework/src/org/apache/cordova/Notification.java
index 8d5e758..ed0b436 100755
--- a/framework/src/org/apache/cordova/Notification.java
+++ b/framework/src/org/apache/cordova/Notification.java
@@ -31,337 +31,336 @@ import android.media.Ringtone;
import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Vibrator;
-import android.app.Activity;
/**
* This class provides access to notifications on the device.
*/
public class Notification extends Plugin {
-
- public int confirmResult = -1;
- public ProgressDialog spinnerDialog = null;
- public ProgressDialog progressDialog = null;
-
- /**
- * Constructor.
- */
- public Notification() {
- }
- /**
- * 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.
- * @return A PluginResult object with a status and message.
- */
- public PluginResult execute(String action, JSONArray args, String callbackId) {
- PluginResult.Status status = PluginResult.Status.OK;
- String result = "";
-
- try {
- if (action.equals("beep")) {
- this.beep(args.getLong(0));
- }
- else if (action.equals("vibrate")) {
- this.vibrate(args.getLong(0));
- }
- else if (action.equals("alert")) {
- this.alert(args.getString(0),args.getString(1),args.getString(2), callbackId);
- PluginResult r = new PluginResult(PluginResult.Status.NO_RESULT);
- r.setKeepCallback(true);
- return r;
- }
- else if (action.equals("confirm")) {
- this.confirm(args.getString(0),args.getString(1),args.getString(2), callbackId);
- PluginResult r = new PluginResult(PluginResult.Status.NO_RESULT);
- r.setKeepCallback(true);
- return r;
- }
- else if (action.equals("activityStart")) {
- this.activityStart(args.getString(0),args.getString(1));
- }
- else if (action.equals("activityStop")) {
- this.activityStop();
- }
- else if (action.equals("progressStart")) {
- this.progressStart(args.getString(0),args.getString(1));
- }
- else if (action.equals("progressValue")) {
- this.progressValue(args.getInt(0));
- }
- else if (action.equals("progressStop")) {
- this.progressStop();
- }
- return new PluginResult(status, result);
- } catch (JSONException e) {
- return new PluginResult(PluginResult.Status.JSON_EXCEPTION);
- }
- }
+ public int confirmResult = -1;
+ public ProgressDialog spinnerDialog = null;
+ public ProgressDialog progressDialog = null;
- /**
- * Identifies if action to be executed returns a value and should be run synchronously.
- *
- * @param action The action to execute
- * @return T=returns value
- */
- public boolean isSynch(String action) {
- if (action.equals("alert")) {
- return true;
- }
- else if (action.equals("confirm")) {
- return true;
- }
- else if (action.equals("activityStart")) {
- return true;
- }
- else if (action.equals("activityStop")) {
- return true;
+ /**
+ * Constructor.
+ */
+ public Notification() {
}
- else if (action.equals("progressStart")) {
- return true;
- }
- else if (action.equals("progressValue")) {
- return true;
- }
- else if (action.equals("progressStop")) {
- return true;
+
+ /**
+ * 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.
+ * @return A PluginResult object with a status and message.
+ */
+ public PluginResult execute(String action, JSONArray args, String callbackId) {
+ PluginResult.Status status = PluginResult.Status.OK;
+ String result = "";
+
+ try {
+ if (action.equals("beep")) {
+ this.beep(args.getLong(0));
+ }
+ else if (action.equals("vibrate")) {
+ this.vibrate(args.getLong(0));
+ }
+ else if (action.equals("alert")) {
+ this.alert(args.getString(0), args.getString(1), args.getString(2), callbackId);
+ PluginResult r = new PluginResult(PluginResult.Status.NO_RESULT);
+ r.setKeepCallback(true);
+ return r;
+ }
+ else if (action.equals("confirm")) {
+ this.confirm(args.getString(0), args.getString(1), args.getString(2), callbackId);
+ PluginResult r = new PluginResult(PluginResult.Status.NO_RESULT);
+ r.setKeepCallback(true);
+ return r;
+ }
+ else if (action.equals("activityStart")) {
+ this.activityStart(args.getString(0), args.getString(1));
+ }
+ else if (action.equals("activityStop")) {
+ this.activityStop();
+ }
+ else if (action.equals("progressStart")) {
+ this.progressStart(args.getString(0), args.getString(1));
+ }
+ else if (action.equals("progressValue")) {
+ this.progressValue(args.getInt(0));
+ }
+ else if (action.equals("progressStop")) {
+ this.progressStop();
+ }
+ return new PluginResult(status, result);
+ } catch (JSONException e) {
+ return new PluginResult(PluginResult.Status.JSON_EXCEPTION);
+ }
}
- else {
- return false;
+
+ /**
+ * Identifies if action to be executed returns a value and should be run synchronously.
+ *
+ * @param action The action to execute
+ * @return T=returns value
+ */
+ public boolean isSynch(String action) {
+ if (action.equals("alert")) {
+ return true;
+ }
+ else if (action.equals("confirm")) {
+ return true;
+ }
+ else if (action.equals("activityStart")) {
+ return true;
+ }
+ else if (action.equals("activityStop")) {
+ return true;
+ }
+ else if (action.equals("progressStart")) {
+ return true;
+ }
+ else if (action.equals("progressValue")) {
+ return true;
+ }
+ else if (action.equals("progressStop")) {
+ return true;
+ }
+ else {
+ return false;
+ }
}
- }
//--------------------------------------------------------------------------
// LOCAL METHODS
//--------------------------------------------------------------------------
- /**
- * Beep plays the default notification ringtone.
- *
- * @param count Number of times to play notification
- */
- public void beep(long count) {
- Uri ringtone = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
- Ringtone notification = RingtoneManager.getRingtone(this.ctx, ringtone);
-
- // If phone is not set to silent mode
- if (notification != null) {
- for (long i = 0; i < count; ++i) {
- notification.play();
- long timeout = 5000;
- while (notification.isPlaying() && (timeout > 0)) {
- timeout = timeout - 100;
- try {
- Thread.sleep(100);
- } catch (InterruptedException e) {
- }
+ /**
+ * Beep plays the default notification ringtone.
+ *
+ * @param count Number of times to play notification
+ */
+ public void beep(long count) {
+ Uri ringtone = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
+ Ringtone notification = RingtoneManager.getRingtone(this.ctx.getActivity().getBaseContext(), ringtone);
+
+ // If phone is not set to silent mode
+ if (notification != null) {
+ for (long i = 0; i < count; ++i) {
+ notification.play();
+ long timeout = 5000;
+ while (notification.isPlaying() && (timeout > 0)) {
+ timeout = timeout - 100;
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ }
+ }
+ }
}
- }
}
- }
-
- /**
- * Vibrates the device for the specified amount of time.
- *
- * @param time Time to vibrate in ms.
- */
- public void vibrate(long time){
+
+ /**
+ * Vibrates the device for the specified amount of time.
+ *
+ * @param time Time to vibrate in ms.
+ */
+ public void vibrate(long time) {
// Start the vibration, 0 defaults to half a second.
- if (time == 0) {
- time = 500;
- }
- Vibrator vibrator = (Vibrator) this.ctx.getSystemService(Context.VIBRATOR_SERVICE);
+ if (time == 0) {
+ time = 500;
+ }
+ Vibrator vibrator = (Vibrator) this.ctx.getActivity().getSystemService(Context.VIBRATOR_SERVICE);
vibrator.vibrate(time);
- }
-
- /**
- * Builds and shows a native Android alert with given Strings
- * @param message The message the alert should display
- * @param title The title of the alert
- * @param buttonLabel The label of the button
- * @param callbackId The callback id
- */
- public synchronized void alert(final String message, final String title, final String buttonLabel, final String callbackId) {
+ }
+
+ /**
+ * Builds and shows a native Android alert with given Strings
+ * @param message The message the alert should display
+ * @param title The title of the alert
+ * @param buttonLabel The label of the button
+ * @param callbackId The callback id
+ */
+ public synchronized void alert(final String message, final String title, final String buttonLabel, final String callbackId) {
- final Context ctx = this.ctx;
- final Notification notification = this;
-
- Runnable runnable = new Runnable() {
- public void run() {
-
- AlertDialog.Builder dlg = new AlertDialog.Builder(ctx);
- dlg.setMessage(message);
- dlg.setTitle(title);
- dlg.setCancelable(false);
- dlg.setPositiveButton(buttonLabel,
- new AlertDialog.OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- dialog.dismiss();
- notification.success(new PluginResult(PluginResult.Status.OK, 0), callbackId);
- }
- });
- dlg.create();
- dlg.show();
- };
- };
- ((Activity) this.ctx).runOnUiThread(runnable);
- }
+ final CordovaInterface ctx = this.ctx;
+ final Notification notification = this;
- /**
- * Builds and shows a native Android confirm dialog with given title, message, buttons.
- * This dialog only shows up to 3 buttons. Any labels after that will be ignored.
- * The index of the button pressed will be returned to the JavaScript callback identified by callbackId.
- *
- * @param message The message the dialog should display
- * @param title The title of the dialog
- * @param buttonLabels A comma separated list of button labels (Up to 3 buttons)
- * @param callbackId The callback id
- */
- public synchronized void confirm(final String message, final String title, String buttonLabels, final String callbackId) {
+ Runnable runnable = new Runnable() {
+ public void run() {
- final Context ctx = this.ctx;
- final Notification notification = this;
- final String[] fButtons = buttonLabels.split(",");
+ AlertDialog.Builder dlg = new AlertDialog.Builder(ctx.getActivity());
+ dlg.setMessage(message);
+ dlg.setTitle(title);
+ dlg.setCancelable(false);
+ dlg.setPositiveButton(buttonLabel,
+ new AlertDialog.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.dismiss();
+ notification.success(new PluginResult(PluginResult.Status.OK, 0), callbackId);
+ }
+ });
+ dlg.create();
+ dlg.show();
+ };
+ };
+ this.ctx.getActivity().runOnUiThread(runnable);
+ }
- Runnable runnable = new Runnable() {
- public void run() {
- AlertDialog.Builder dlg = new AlertDialog.Builder(ctx);
- dlg.setMessage(message);
- dlg.setTitle(title);
- dlg.setCancelable(false);
+ /**
+ * Builds and shows a native Android confirm dialog with given title, message, buttons.
+ * This dialog only shows up to 3 buttons. Any labels after that will be ignored.
+ * The index of the button pressed will be returned to the JavaScript callback identified by callbackId.
+ *
+ * @param message The message the dialog should display
+ * @param title The title of the dialog
+ * @param buttonLabels A comma separated list of button labels (Up to 3 buttons)
+ * @param callbackId The callback id
+ */
+ public synchronized void confirm(final String message, final String title, String buttonLabels, final String callbackId) {
- // First button
- if (fButtons.length > 0) {
- dlg.setNegativeButton(fButtons[0],
- new AlertDialog.OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- dialog.dismiss();
- notification.success(new PluginResult(PluginResult.Status.OK, 1), callbackId);
- }
- });
- }
+ final CordovaInterface ctx = this.ctx;
+ final Notification notification = this;
+ final String[] fButtons = buttonLabels.split(",");
- // Second button
- if (fButtons.length > 1) {
- dlg.setNeutralButton(fButtons[1],
- new AlertDialog.OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- dialog.dismiss();
- notification.success(new PluginResult(PluginResult.Status.OK, 2), callbackId);
- }
- });
- }
+ Runnable runnable = new Runnable() {
+ public void run() {
+ AlertDialog.Builder dlg = new AlertDialog.Builder(ctx.getActivity());
+ dlg.setMessage(message);
+ dlg.setTitle(title);
+ dlg.setCancelable(false);
- // Third button
- if (fButtons.length > 2) {
- dlg.setPositiveButton(fButtons[2],
- new AlertDialog.OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- dialog.dismiss();
- notification.success(new PluginResult(PluginResult.Status.OK, 3), callbackId);
- }
- }
- );
- }
+ // First button
+ if (fButtons.length > 0) {
+ dlg.setNegativeButton(fButtons[0],
+ new AlertDialog.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.dismiss();
+ notification.success(new PluginResult(PluginResult.Status.OK, 1), callbackId);
+ }
+ });
+ }
- dlg.create();
- dlg.show();
- };
- };
- ((Activity) this.ctx).runOnUiThread(runnable);
- }
+ // Second button
+ if (fButtons.length > 1) {
+ dlg.setNeutralButton(fButtons[1],
+ new AlertDialog.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.dismiss();
+ notification.success(new PluginResult(PluginResult.Status.OK, 2), callbackId);
+ }
+ });
+ }
- /**
- * Show the spinner.
- *
- * @param title Title of the dialog
- * @param message The message of the dialog
- */
- public synchronized void activityStart(final String title, final String message) {
- if (this.spinnerDialog != null) {
- this.spinnerDialog.dismiss();
- this.spinnerDialog = null;
+ // Third button
+ if (fButtons.length > 2) {
+ dlg.setPositiveButton(fButtons[2],
+ new AlertDialog.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.dismiss();
+ notification.success(new PluginResult(PluginResult.Status.OK, 3), callbackId);
+ }
+ }
+ );
+ }
+
+ dlg.create();
+ dlg.show();
+ };
+ };
+ this.ctx.getActivity().runOnUiThread(runnable);
}
- final Notification notification = this;
- final Activity ctx = (Activity) this.ctx;
- Runnable runnable = new Runnable() {
- public void run() {
- notification.spinnerDialog = ProgressDialog.show(ctx, title , message, true, true,
- new DialogInterface.OnCancelListener() {
- public void onCancel(DialogInterface dialog) {
- notification.spinnerDialog = null;
- }
- });
+
+ /**
+ * Show the spinner.
+ *
+ * @param title Title of the dialog
+ * @param message The message of the dialog
+ */
+ public synchronized void activityStart(final String title, final String message) {
+ if (this.spinnerDialog != null) {
+ this.spinnerDialog.dismiss();
+ this.spinnerDialog = null;
}
- };
- ctx.runOnUiThread(runnable);
- }
-
- /**
- * Stop spinner.
- */
- public synchronized void activityStop() {
- if (this.spinnerDialog != null) {
- this.spinnerDialog.dismiss();
- this.spinnerDialog = null;
+ final Notification notification = this;
+ final CordovaInterface ctx = this.ctx;
+ Runnable runnable = new Runnable() {
+ public void run() {
+ notification.spinnerDialog = ProgressDialog.show(ctx.getActivity(), title, message, true, true,
+ new DialogInterface.OnCancelListener() {
+ public void onCancel(DialogInterface dialog) {
+ notification.spinnerDialog = null;
+ }
+ });
+ }
+ };
+ this.ctx.getActivity().runOnUiThread(runnable);
}
- }
- /**
- * Show the progress dialog.
- *
- * @param title Title of the dialog
- * @param message The message of the dialog
- */
- public synchronized void progressStart(final String title, final String message) {
- if (this.progressDialog != null) {
- this.progressDialog.dismiss();
- this.progressDialog = null;
+ /**
+ * Stop spinner.
+ */
+ public synchronized void activityStop() {
+ if (this.spinnerDialog != null) {
+ this.spinnerDialog.dismiss();
+ this.spinnerDialog = null;
+ }
}
- final Notification notification = this;
- final Activity ctx = (Activity) this.ctx;
- Runnable runnable = new Runnable() {
- public void run() {
- notification.progressDialog = new ProgressDialog(ctx);
- notification.progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
- notification.progressDialog.setTitle(title);
- notification.progressDialog.setMessage(message);
- notification.progressDialog.setCancelable(true);
- notification.progressDialog.setMax(100);
- notification.progressDialog.setProgress(0);
- notification.progressDialog.setOnCancelListener(
- new DialogInterface.OnCancelListener() {
- public void onCancel(DialogInterface dialog) {
- notification.progressDialog = null;
+
+ /**
+ * Show the progress dialog.
+ *
+ * @param title Title of the dialog
+ * @param message The message of the dialog
+ */
+ public synchronized void progressStart(final String title, final String message) {
+ if (this.progressDialog != null) {
+ this.progressDialog.dismiss();
+ this.progressDialog = null;
+ }
+ final Notification notification = this;
+ final CordovaInterface ctx = this.ctx;
+ Runnable runnable = new Runnable() {
+ public void run() {
+ notification.progressDialog = new ProgressDialog(ctx.getActivity());
+ notification.progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
+ notification.progressDialog.setTitle(title);
+ notification.progressDialog.setMessage(message);
+ notification.progressDialog.setCancelable(true);
+ notification.progressDialog.setMax(100);
+ notification.progressDialog.setProgress(0);
+ notification.progressDialog.setOnCancelListener(
+ new DialogInterface.OnCancelListener() {
+ public void onCancel(DialogInterface dialog) {
+ notification.progressDialog = null;
+ }
+ });
+ notification.progressDialog.show();
}
- });
- notification.progressDialog.show();
- }
- };
- ctx.runOnUiThread(runnable);
- }
-
- /**
- * Set value of progress bar.
- *
- * @param value 0-100
- */
- public synchronized void progressValue(int value) {
- if (this.progressDialog != null) {
- this.progressDialog.setProgress(value);
- }
- }
-
- /**
- * Stop progress dialog.
- */
- public synchronized void progressStop() {
- if (this.progressDialog != null) {
- this.progressDialog.dismiss();
- this.progressDialog = null;
+ };
+ this.ctx.getActivity().runOnUiThread(runnable);
+ }
+
+ /**
+ * Set value of progress bar.
+ *
+ * @param value 0-100
+ */
+ public synchronized void progressValue(int value) {
+ if (this.progressDialog != null) {
+ this.progressDialog.setProgress(value);
+ }
+ }
+
+ /**
+ * Stop progress dialog.
+ */
+ public synchronized void progressStop() {
+ if (this.progressDialog != null) {
+ this.progressDialog.dismiss();
+ this.progressDialog = null;
+ }
}
- }
}
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/c8fafa6b/framework/src/org/apache/cordova/SplashScreen.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/SplashScreen.java b/framework/src/org/apache/cordova/SplashScreen.java
index a53bb71..9fca9b2 100644
--- a/framework/src/org/apache/cordova/SplashScreen.java
+++ b/framework/src/org/apache/cordova/SplashScreen.java
@@ -31,7 +31,8 @@ public class SplashScreen extends Plugin {
String result = "";
if (action.equals("hide")) {
- ((DroidGap)this.ctx).removeSplashScreen();
+ //((DroidGap)this.ctx).removeSplashScreen();
+ this.webView.postMessage("splashscreen", "hide");
}
else {
status = PluginResult.Status.INVALID_ACTION;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/c8fafa6b/framework/src/org/apache/cordova/StandAlone.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/StandAlone.java b/framework/src/org/apache/cordova/StandAlone.java
index d41771d..82d95f2 100644
--- a/framework/src/org/apache/cordova/StandAlone.java
+++ b/framework/src/org/apache/cordova/StandAlone.java
@@ -18,18 +18,18 @@
*/
package org.apache.cordova;
-import java.lang.reflect.Field;
+//import java.lang.reflect.Field;
-import android.app.Activity;
+//import android.app.Activity;
import android.os.Bundle;
public class StandAlone extends DroidGap {
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
-
- super.loadUrl("file:///android_asset/www/index.html");
- }
-
+
+ super.loadUrl("file:///android_asset/www/index.html");
+ }
+
}
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/c8fafa6b/framework/src/org/apache/cordova/Storage.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/Storage.java b/framework/src/org/apache/cordova/Storage.java
index 98ec422..f57621b 100755
--- a/framework/src/org/apache/cordova/Storage.java
+++ b/framework/src/org/apache/cordova/Storage.java
@@ -37,203 +37,202 @@ import android.database.sqlite.*;
*/
public class Storage extends Plugin {
- // Data Definition Language
- private static final String ALTER = "alter";
- private static final String CREATE = "create";
- private static final String DROP = "drop";
- private static final String TRUNCATE = "truncate";
-
- SQLiteDatabase myDb = null; // Database object
- String path = null; // Database path
- String dbName = null; // Database name
-
- /**
- * Constructor.
- */
- public Storage() {
- }
-
- /**
- * 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.
- * @return A PluginResult object with a status and message.
- */
- public PluginResult execute(String action, JSONArray args, String callbackId) {
- PluginResult.Status status = PluginResult.Status.OK;
- String result = "";
-
- try {
- if (action.equals("openDatabase")) {
- this.openDatabase(args.getString(0), args.getString(1),
- args.getString(2), args.getLong(3));
- } else if (action.equals("executeSql")) {
- String[] s = null;
- if (args.isNull(1)) {
- s = new String[0];
- } else {
- JSONArray a = args.getJSONArray(1);
- int len = a.length();
- s = new String[len];
- for (int i = 0; i < len; i++) {
- s[i] = a.getString(i);
- }
- }
- this.executeSql(args.getString(0), s, args.getString(2));
- }
- return new PluginResult(status, result);
- } catch (JSONException e) {
- return new PluginResult(PluginResult.Status.JSON_EXCEPTION);
- }
- }
-
- /**
- * Identifies if action to be executed returns a value and should be run
- * synchronously.
- *
- * @param action
- * The action to execute
- * @return T=returns value
- */
- public boolean isSynch(String action) {
- return true;
- }
-
- /**
- * Clean up and close database.
- */
- @Override
- public void onDestroy() {
- if (this.myDb != null) {
- this.myDb.close();
- this.myDb = null;
- }
- }
-
- // --------------------------------------------------------------------------
- // LOCAL METHODS
- // --------------------------------------------------------------------------
-
- /**
- * Open database.
- *
- * @param db
- * The name of the database
- * @param version
- * The version
- * @param display_name
- * The display name
- * @param size
- * The size in bytes
- */
- public void openDatabase(String db, String version, String display_name,
- long size) {
-
- // If database is open, then close it
- if (this.myDb != null) {
- this.myDb.close();
- }
-
- // If no database path, generate from application package
- if (this.path == null) {
- this.path = this.ctx.getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath();
- }
-
- this.dbName = this.path + File.pathSeparator + db + ".db";
- this.myDb = SQLiteDatabase.openOrCreateDatabase(this.dbName, null);
- }
-
- /**
- * Execute SQL statement.
- *
- * @param query
- * The SQL query
- * @param params
- * Parameters for the query
- * @param tx_id
- * Transaction id
- */
- public void executeSql(String query, String[] params, String tx_id) {
- try {
- if (isDDL(query)) {
- this.myDb.execSQL(query);
- this.sendJavascript("cordova.require('cordova/plugin/android/storage').completeQuery('" + tx_id + "', '');");
- }
- else {
- Cursor myCursor = this.myDb.rawQuery(query, params);
- this.processResults(myCursor, tx_id);
- myCursor.close();
- }
- }
- catch (SQLiteException ex) {
- ex.printStackTrace();
- System.out.println("Storage.executeSql(): Error=" + ex.getMessage());
-
- // Send error message back to JavaScript
- this.sendJavascript("cordova.require('cordova/plugin/android/storage').fail('" + ex.getMessage() + "','" + tx_id + "');");
- }
- }
-
- /**
- * Checks to see the the query is a Data Definintion command
- *
- * @param query to be executed
- * @return true if it is a DDL command, false otherwise
- */
- private boolean isDDL(String query) {
- String cmd = query.toLowerCase();
- if (cmd.startsWith(DROP) || cmd.startsWith(CREATE) || cmd.startsWith(ALTER) || cmd.startsWith(TRUNCATE)) {
- return true;
- }
- return false;
- }
-
- /**
- * Process query results.
- *
- * @param cur
- * Cursor into query results
- * @param tx_id
- * Transaction id
- */
- public void processResults(Cursor cur, String tx_id) {
-
- String result = "[]";
- // If query result has rows
-
- if (cur.moveToFirst()) {
- JSONArray fullresult = new JSONArray();
- String key = "";
- String value = "";
- int colCount = cur.getColumnCount();
-
- // Build up JSON result object for each row
- do {
- JSONObject row = new JSONObject();
- try {
- for (int i = 0; i < colCount; ++i) {
- key = cur.getColumnName(i);
- value = cur.getString(i);
- row.put(key, value);
- }
- fullresult.put(row);
-
- } catch (JSONException e) {
- e.printStackTrace();
- }
-
- } while (cur.moveToNext());
-
- result = fullresult.toString();
- }
-
- // Let JavaScript know that there are no more rows
- this.sendJavascript("cordova.require('cordova/plugin/android/storage').completeQuery('" + tx_id + "', " + result + ");");
- }
+ // Data Definition Language
+ private static final String ALTER = "alter";
+ private static final String CREATE = "create";
+ private static final String DROP = "drop";
+ private static final String TRUNCATE = "truncate";
+
+ SQLiteDatabase myDb = null; // Database object
+ String path = null; // Database path
+ String dbName = null; // Database name
+
+ /**
+ * Constructor.
+ */
+ public Storage() {
+ }
+
+ /**
+ * 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.
+ * @return A PluginResult object with a status and message.
+ */
+ public PluginResult execute(String action, JSONArray args, String callbackId) {
+ PluginResult.Status status = PluginResult.Status.OK;
+ String result = "";
+
+ try {
+ if (action.equals("openDatabase")) {
+ this.openDatabase(args.getString(0), args.getString(1),
+ args.getString(2), args.getLong(3));
+ } else if (action.equals("executeSql")) {
+ String[] s = null;
+ if (args.isNull(1)) {
+ s = new String[0];
+ } else {
+ JSONArray a = args.getJSONArray(1);
+ int len = a.length();
+ s = new String[len];
+ for (int i = 0; i < len; i++) {
+ s[i] = a.getString(i);
+ }
+ }
+ this.executeSql(args.getString(0), s, args.getString(2));
+ }
+ return new PluginResult(status, result);
+ } catch (JSONException e) {
+ return new PluginResult(PluginResult.Status.JSON_EXCEPTION);
+ }
+ }
+
+ /**
+ * Identifies if action to be executed returns a value and should be run
+ * synchronously.
+ *
+ * @param action
+ * The action to execute
+ * @return T=returns value
+ */
+ public boolean isSynch(String action) {
+ return true;
+ }
+
+ /**
+ * Clean up and close database.
+ */
+ @Override
+ public void onDestroy() {
+ if (this.myDb != null) {
+ this.myDb.close();
+ this.myDb = null;
+ }
+ }
+
+ // --------------------------------------------------------------------------
+ // LOCAL METHODS
+ // --------------------------------------------------------------------------
+
+ /**
+ * Open database.
+ *
+ * @param db
+ * The name of the database
+ * @param version
+ * The version
+ * @param display_name
+ * The display name
+ * @param size
+ * The size in bytes
+ */
+ public void openDatabase(String db, String version, String display_name,
+ long size) {
+
+ // If database is open, then close it
+ if (this.myDb != null) {
+ this.myDb.close();
+ }
+
+ // If no database path, generate from application package
+ if (this.path == null) {
+ this.path = this.ctx.getActivity().getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath();
+ }
+
+ this.dbName = this.path + File.pathSeparator + db + ".db";
+ this.myDb = SQLiteDatabase.openOrCreateDatabase(this.dbName, null);
+ }
+
+ /**
+ * Execute SQL statement.
+ *
+ * @param query
+ * The SQL query
+ * @param params
+ * Parameters for the query
+ * @param tx_id
+ * Transaction id
+ */
+ public void executeSql(String query, String[] params, String tx_id) {
+ try {
+ if (isDDL(query)) {
+ this.myDb.execSQL(query);
+ this.sendJavascript("cordova.require('cordova/plugin/android/storage').completeQuery('" + tx_id + "', '');");
+ }
+ else {
+ Cursor myCursor = this.myDb.rawQuery(query, params);
+ this.processResults(myCursor, tx_id);
+ myCursor.close();
+ }
+ } catch (SQLiteException ex) {
+ ex.printStackTrace();
+ System.out.println("Storage.executeSql(): Error=" + ex.getMessage());
+
+ // Send error message back to JavaScript
+ this.sendJavascript("cordova.require('cordova/plugin/android/storage').fail('" + ex.getMessage() + "','" + tx_id + "');");
+ }
+ }
+
+ /**
+ * Checks to see the the query is a Data Definintion command
+ *
+ * @param query to be executed
+ * @return true if it is a DDL command, false otherwise
+ */
+ private boolean isDDL(String query) {
+ String cmd = query.toLowerCase();
+ if (cmd.startsWith(DROP) || cmd.startsWith(CREATE) || cmd.startsWith(ALTER) || cmd.startsWith(TRUNCATE)) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Process query results.
+ *
+ * @param cur
+ * Cursor into query results
+ * @param tx_id
+ * Transaction id
+ */
+ public void processResults(Cursor cur, String tx_id) {
+
+ String result = "[]";
+ // If query result has rows
+
+ if (cur.moveToFirst()) {
+ JSONArray fullresult = new JSONArray();
+ String key = "";
+ String value = "";
+ int colCount = cur.getColumnCount();
+
+ // Build up JSON result object for each row
+ do {
+ JSONObject row = new JSONObject();
+ try {
+ for (int i = 0; i < colCount; ++i) {
+ key = cur.getColumnName(i);
+ value = cur.getString(i);
+ row.put(key, value);
+ }
+ fullresult.put(row);
+
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+
+ } while (cur.moveToNext());
+
+ result = fullresult.toString();
+ }
+
+ // Let JavaScript know that there are no more rows
+ this.sendJavascript("cordova.require('cordova/plugin/android/storage').completeQuery('" + tx_id + "', " + result + ");");
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/c8fafa6b/framework/src/org/apache/cordova/TempListener.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/TempListener.java b/framework/src/org/apache/cordova/TempListener.java
index 936343a..0b5b002 100755
--- a/framework/src/org/apache/cordova/TempListener.java
+++ b/framework/src/org/apache/cordova/TempListener.java
@@ -25,7 +25,6 @@ import org.apache.cordova.api.Plugin;
import org.apache.cordova.api.PluginResult;
import org.json.JSONArray;
-
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
@@ -33,80 +32,81 @@ import android.hardware.SensorManager;
import android.content.Context;
public class TempListener extends Plugin implements SensorEventListener {
-
- Sensor mSensor;
- private SensorManager sensorManager;
-
- /**
- * Constructor.
- */
- public TempListener() {
- }
-
- /**
- * Sets the context of the Command. This can then be used to do things like
- * get file paths associated with the Activity.
- *
- * @param ctx The context of the main Activity.
- */
- public void setContext(Context ctx) {
- super.setContext(ctx);
- this.sensorManager = (SensorManager) ctx.getSystemService(Context.SENSOR_SERVICE);
- }
-
- /**
- * 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.
- * @return A PluginResult object with a status and message.
- */
- public PluginResult execute(String action, JSONArray args, String callbackId) {
- PluginResult.Status status = PluginResult.Status.OK;
- String result = "";
-
- if (action.equals("start")) {
- this.start();
- }
- else if (action.equals("stop")) {
- this.stop();
- }
- return new PluginResult(status, result);
- }
-
+
+ Sensor mSensor;
+ private SensorManager sensorManager;
+
+ /**
+ * Constructor.
+ */
+ public TempListener() {
+ }
+
+ /**
+ * Sets the context of the Command. This can then be used to do things like
+ * get file paths associated with the Activity.
+ *
+ * @param ctx The context of the main Activity.
+ */
+ public void setContext(CordovaInterface ctx) {
+ super.setContext(ctx);
+ this.sensorManager = (SensorManager) ctx.getActivity().getSystemService(Context.SENSOR_SERVICE);
+ }
+
+ /**
+ * 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.
+ * @return A PluginResult object with a status and message.
+ */
+ public PluginResult execute(String action, JSONArray args, String callbackId) {
+ PluginResult.Status status = PluginResult.Status.OK;
+ String result = "";
+
+ if (action.equals("start")) {
+ this.start();
+ }
+ else if (action.equals("stop")) {
+ this.stop();
+ }
+ return new PluginResult(status, result);
+ }
+
/**
* Called by AccelBroker when listener is to be shut down.
* Stop listener.
*/
public void onDestroy() {
- this.stop();
+ this.stop();
}
//--------------------------------------------------------------------------
// LOCAL METHODS
//--------------------------------------------------------------------------
- public void start() {
- List<Sensor> list = this.sensorManager.getSensorList(Sensor.TYPE_TEMPERATURE);
- if (list.size() > 0) {
- this.mSensor = list.get(0);
- this.sensorManager.registerListener(this, this.mSensor, SensorManager.SENSOR_DELAY_NORMAL);
- }
- }
-
- public void stop() {
- this.sensorManager.unregisterListener(this);
- }
-
- public void onAccuracyChanged(Sensor sensor, int accuracy) {
- // TODO Auto-generated method stub
- }
-
- public void onSensorChanged(SensorEvent event) {
- // We want to know what temp this is.
- float temp = event.values[0];
- this.sendJavascript("gotTemp(" + temp + ");");
- }
+ public void start() {
+ @SuppressWarnings("deprecation")
+ List<Sensor> list = this.sensorManager.getSensorList(Sensor.TYPE_TEMPERATURE);
+ if (list.size() > 0) {
+ this.mSensor = list.get(0);
+ this.sensorManager.registerListener(this, this.mSensor, SensorManager.SENSOR_DELAY_NORMAL);
+ }
+ }
+
+ public void stop() {
+ this.sensorManager.unregisterListener(this);
+ }
+
+ public void onAccuracyChanged(Sensor sensor, int accuracy) {
+ // TODO Auto-generated method stub
+ }
+
+ public void onSensorChanged(SensorEvent event) {
+ // We want to know what temp this is.
+ float temp = event.values[0];
+ this.sendJavascript("gotTemp(" + temp + ");");
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/c8fafa6b/framework/src/org/apache/cordova/api/CordovaInterface.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/api/CordovaInterface.java b/framework/src/org/apache/cordova/api/CordovaInterface.java
index b25e972..5d56039 100755
--- a/framework/src/org/apache/cordova/api/CordovaInterface.java
+++ b/framework/src/org/apache/cordova/api/CordovaInterface.java
@@ -18,23 +18,22 @@
*/
package org.apache.cordova.api;
-import java.util.HashMap;
+//import java.util.HashMap;
import android.app.Activity;
-import android.app.Service;
-import android.content.BroadcastReceiver;
-import android.content.ContentResolver;
-import android.content.Context;
+//import android.app.Service;
+//import android.content.BroadcastReceiver;
+//import android.content.ContentResolver;
+//import android.content.Context;
import android.content.Intent;
-import android.content.IntentFilter;
-import android.content.res.AssetManager;
-import android.content.res.Resources;
-import android.database.Cursor;
-import android.hardware.SensorManager;
-import android.net.Uri;
-import android.view.Menu;
-import android.view.MenuItem;
-
+//import android.content.IntentFilter;
+//import android.content.res.AssetManager;
+//import android.content.res.Resources;
+//import android.database.Cursor;
+//import android.hardware.SensorManager;
+//import android.net.Uri;
+//import android.view.Menu;
+//import android.view.MenuItem;
/**
* The Cordova activity abstract class that is extended by DroidGap.
@@ -42,7 +41,6 @@ import android.view.MenuItem;
*/
public interface CordovaInterface {
-
/**
* Launch an activity for which you would like a result when it finished. When this activity exits,
* your onActivityResult() method will be called.
@@ -52,22 +50,24 @@ public interface CordovaInterface {
* @param requestCode The request code that is passed to callback to identify the activity
*/
abstract public void startActivityForResult(IPlugin command, Intent intent, int requestCode);
-
+
/**
* Set the plugin to be called when a sub-activity exits.
*
* @param plugin The plugin on which onActivityResult is to be called
*/
abstract public void setActivityResultCallback(IPlugin plugin);
-
+
/**
- * Causes the Activity to override the back button behaviour
+ * Causes the Activity to override the back button behavior.
+ *
* @param override
*/
public abstract void bindBackButton(boolean override);
/**
- * A hook required to check if the Back Button is bound
+ * A hook required to check if the Back Button is bound.
+ *
* @return
*/
public abstract boolean isBackButtonBound();
@@ -76,16 +76,20 @@ public interface CordovaInterface {
* Hook in DroidGap for menu plugins
* (This is in the Android SDK, do we need this on the Interface?)
*/
-
- public abstract boolean onCreateOptionsMenu(Menu menu);
-
- public abstract boolean onPrepareOptionsMenu(Menu menu);
-
- public abstract boolean onOptionsItemSelected(MenuItem item);
-
-
-
-
+
+ //public abstract boolean onCreateOptionsMenu(Menu menu);
+
+ //public abstract boolean onPrepareOptionsMenu(Menu menu);
+
+ //public abstract boolean onOptionsItemSelected(MenuItem item);
+
+ /**
+ * Get the Android activity.
+ *
+ * @return
+ */
+ public abstract Activity getActivity();
+
/**
* @deprecated
* Add services to res/xml/plugins.xml instead.
@@ -95,17 +99,17 @@ public interface CordovaInterface {
* @param serviceType
* @param className
*/
- @Deprecated
- abstract public void addService(String serviceType, String className);
-
+// @Deprecated
+// abstract public void addService(String serviceType, String className);
+
/**
* @deprecated
* Send JavaScript statement back to JavaScript.
*
* @param message
*/
- @Deprecated
- abstract public void sendJavascript(String statement);
+// @Deprecated
+// abstract public void sendJavascript(String statement);
/**
* @deprecated
@@ -113,9 +117,8 @@ public interface CordovaInterface {
*
* @param intent The intent to start
*/
- @Deprecated
- abstract public void startActivity(Intent intent);
-
+// @Deprecated
+// abstract public void startActivity(Intent intent);
/**
* @deprecated
@@ -123,9 +126,9 @@ public interface CordovaInterface {
*
* @param url The URL to load.
*/
- @Deprecated
- abstract public void loadUrl(String url);
-
+// @Deprecated
+// abstract public void loadUrl(String url);
+
/**
* @deprecated
* Send a message to all plugins.
@@ -133,66 +136,84 @@ public interface CordovaInterface {
* @param id The message id
* @param data The message data
*/
- @Deprecated
- abstract public void postMessage(String id, Object data);
-
- @Deprecated
- public abstract Resources getResources();
+// @Deprecated
+// abstract public void postMessage(String id, Object data);
- @Deprecated
- public abstract String getPackageName();
+// @Deprecated
+// public abstract Resources getResources();
- @Deprecated
- public abstract Object getSystemService(String service);
+// @Deprecated
+// public abstract String getPackageName();
- @Deprecated
- public abstract Context getContext();
-
- @Deprecated
- public abstract Context getBaseContext();
+// @Deprecated
+// public abstract Object getSystemService(String service);
- @Deprecated
- public abstract Intent registerReceiver(BroadcastReceiver receiver,
- IntentFilter intentFilter);
+// @Deprecated
+// public abstract Context getContext();
- @Deprecated
- public abstract ContentResolver getContentResolver();
+// @Deprecated
+// public abstract Context getBaseContext();
- @Deprecated
- public abstract void unregisterReceiver(BroadcastReceiver receiver);
+// @Deprecated
+// public abstract Intent registerReceiver(BroadcastReceiver receiver,
+// IntentFilter intentFilter);
- @Deprecated
- public abstract Cursor managedQuery(Uri uri, String[] projection, String selection,
- String[] selectionArgs, String sortOrder);
-
- @Deprecated
- public abstract void runOnUiThread(Runnable runnable);
+// @Deprecated
+// public abstract ContentResolver getContentResolver();
- @Deprecated
- public abstract AssetManager getAssets();
+// @Deprecated
+// public abstract void unregisterReceiver(BroadcastReceiver receiver);
- @Deprecated
- public abstract void clearCache();
+// @Deprecated
+// public abstract Cursor managedQuery(Uri uri, String[] projection, String selection,
+// String[] selectionArgs, String sortOrder);
- @Deprecated
- public abstract void clearHistory();
+// @Deprecated
+// public abstract void runOnUiThread(Runnable runnable);
- @Deprecated
- public abstract boolean backHistory();
+// @Deprecated
+// public abstract AssetManager getAssets();
+
+// @Deprecated
+// public abstract void clearCache();
+
+// @Deprecated
+// public abstract void clearHistory();
+
+// @Deprecated
+// public abstract boolean backHistory();
//public abstract void addWhiteListEntry(String origin, boolean subdomains);
@Deprecated
public abstract void cancelLoadUrl();
- @Deprecated
- public abstract void showWebPage(String url, boolean openExternal,
- boolean clearHistory, HashMap<String, Object> params);
+// @Deprecated
+// public abstract void showWebPage(String url, boolean openExternal,
+// boolean clearHistory, HashMap<String, Object> params);
- @Deprecated
- public abstract Context getApplicationContext();
+// @Deprecated
+// public abstract Context getApplicationContext();
+
+// @Deprecated
+// public abstract boolean isUrlWhiteListed(String source);
+
+ /**
+ * Called when a message is sent to plugin.
+ *
+ * @param id The message id
+ * @param data The message data
+ */
+ public void onMessage(String id, Object data);
+
+ /**
+ * Report an error to the host application. These errors are unrecoverable (i.e. the main resource is unavailable).
+ * The errorCode parameter corresponds to one of the ERROR_* constants.
+ *
+ * @param errorCode The error code corresponding to an ERROR_* value.
+ * @param description A String describing the error.
+ * @param failingUrl The url that failed to load.
+ */
+ //public void onReceivedError(final int errorCode, final String description, final String failingUrl);
- @Deprecated
- public abstract boolean isUrlWhiteListed(String source);
-
}
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/c8fafa6b/framework/src/org/apache/cordova/api/IPlugin.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/api/IPlugin.java b/framework/src/org/apache/cordova/api/IPlugin.java
index 7757963..82d9bb7 100755
--- a/framework/src/org/apache/cordova/api/IPlugin.java
+++ b/framework/src/org/apache/cordova/api/IPlugin.java
@@ -21,9 +21,10 @@ package org.apache.cordova.api;
import org.apache.cordova.CordovaWebView;
import org.json.JSONArray;
-import android.content.Context;
+//import android.content.Context;
import android.content.Intent;
-import android.webkit.WebView;
+
+//import android.webkit.WebView;
/**
* Plugin interface must be implemented by any plugin classes.
@@ -31,40 +32,40 @@ import android.webkit.WebView;
* The execute method is called by the PluginManager.
*/
public interface IPlugin {
-
- /**
- * 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.
- * @return A PluginResult object with a status and message.
- */
- PluginResult execute(String action, JSONArray args, String callbackId);
-
- /**
- * Identifies if action to be executed returns a value and should be run synchronously.
- *
- * @param action The action to execute
- * @return T=returns value
- */
- public boolean isSynch(String action);
-
- /**
- * Sets the context of the Plugin. This can then be used to do things like
- * get file paths associated with the Activity.
- *
- * @param ctx The context of the main Activity.
- */
- void setContext(Context ctx);
-
- /**
- * Sets the main View of the application, this is the WebView within which
- * a Cordova app runs.
- *
- * @param webView The Cordova WebView
- */
- void setView(CordovaWebView webView);
+
+ /**
+ * 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.
+ * @return A PluginResult object with a status and message.
+ */
+ PluginResult execute(String action, JSONArray args, String callbackId);
+
+ /**
+ * Identifies if action to be executed returns a value and should be run synchronously.
+ *
+ * @param action The action to execute
+ * @return T=returns value
+ */
+ public boolean isSynch(String action);
+
+ /**
+ * Sets the context of the Plugin. This can then be used to do things like
+ * get file paths associated with the Activity.
+ *
+ * @param ctx The context of the main Activity.
+ */
+ void setContext(CordovaInterface ctx);
+
+ /**
+ * Sets the main View of the application, this is the WebView within which
+ * a Cordova app runs.
+ *
+ * @param webView The Cordova WebView
+ */
+ void setView(CordovaWebView webView);
/**
* Called when the system is about to start resuming a previous activity.
@@ -79,7 +80,7 @@ public interface IPlugin {
* @param multitasking Flag indicating if multitasking is turned on for app
*/
void onResume(boolean multitasking);
-
+
/**
* Called when the activity receives a new intent.
*/
@@ -89,7 +90,7 @@ public interface IPlugin {
* The final call you receive before your activity is destroyed.
*/
void onDestroy();
-
+
/**
* Called when a message is sent to plugin.
*