You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by bo...@apache.org on 2012/06/07 22:20:55 UTC
[50/50] [abbrv] android commit: Formating and removal of commented
code.
Formating and removal of commented code.
Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/commit/3829df66
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/tree/3829df66
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/diff/3829df66
Branch: refs/heads/master
Commit: 3829df665fa67f9ccac2c7f08fa1a6e1f194f600
Parents: c8fafa6
Author: Bryce Curtis <cu...@gmail.com>
Authored: Mon May 14 22:06:33 2012 -0500
Committer: Bryce Curtis <cu...@gmail.com>
Committed: Mon May 14 22:06:33 2012 -0500
----------------------------------------------------------------------
framework/src/org/apache/cordova/App.java | 12 +-
framework/src/org/apache/cordova/AudioHandler.java | 5 +-
.../src/org/apache/cordova/CallbackServer.java | 591 +++++++--------
framework/src/org/apache/cordova/Capture.java | 2 -
.../src/org/apache/cordova/CordovaException.java | 5 +
.../src/org/apache/cordova/CordovaWebView.java | 29 +-
.../org/apache/cordova/CordovaWebViewClient.java | 9 -
.../src/org/apache/cordova/DirectoryManager.java | 199 +++---
framework/src/org/apache/cordova/DroidGap.java | 272 +-------
framework/src/org/apache/cordova/FileTransfer.java | 1 +
framework/src/org/apache/cordova/FileUtils.java | 5 +-
framework/src/org/apache/cordova/HttpHandler.java | 4 +-
.../org/apache/cordova/api/CordovaInterface.java | 140 ----
framework/src/org/apache/cordova/api/IPlugin.java | 2 -
framework/src/org/apache/cordova/api/Plugin.java | 6 +-
.../src/org/apache/cordova/api/PluginManager.java | 14 -
16 files changed, 414 insertions(+), 882 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/3829df66/framework/src/org/apache/cordova/App.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/App.java b/framework/src/org/apache/cordova/App.java
index 75460d5..7df0aa9 100755
--- a/framework/src/org/apache/cordova/App.java
+++ b/framework/src/org/apache/cordova/App.java
@@ -25,11 +25,6 @@ import org.apache.cordova.api.PluginResult;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
-
-//import android.webkit.WebView;
-import android.app.Activity;
-import android.view.View;
-
import java.util.HashMap;
/**
@@ -59,12 +54,6 @@ public class App extends Plugin {
webView.postMessage("spinner", "stop");
}
});
-// final CordovaWebView wv = this.webView;
-// ((Activity) this.ctx).runOnUiThread(new Runnable() {
-// public void run() {
-// wv.setVisibility(View.VISIBLE);
-// }
-// });
}
else if (action.equals("loadUrl")) {
this.loadUrl(args.getString(0), args.optJSONObject(1));
@@ -168,6 +157,7 @@ public class App extends Plugin {
/**
* Cancel loadUrl before it has been loaded (Only works on a CordovaInterface class)
*/
+ @Deprecated
public void cancelLoadUrl() {
this.ctx.cancelLoadUrl();
}
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/3829df66/framework/src/org/apache/cordova/AudioHandler.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/AudioHandler.java b/framework/src/org/apache/cordova/AudioHandler.java
index 644640c..8acb52c 100755
--- a/framework/src/org/apache/cordova/AudioHandler.java
+++ b/framework/src/org/apache/cordova/AudioHandler.java
@@ -22,16 +22,13 @@ import android.content.Context;
import android.media.AudioManager;
import java.util.ArrayList;
-import org.apache.cordova.api.LOG;
+//import org.apache.cordova.api.LOG;
import org.apache.cordova.api.Plugin;
import org.apache.cordova.api.PluginResult;
import org.json.JSONArray;
import org.json.JSONException;
-
import java.util.HashMap;
-//import java.util.Map.Entry;
-
/**
* This class called by CordovaActivity to play and record audio.
* The file can be local or over a network using http.
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/3829df66/framework/src/org/apache/cordova/CallbackServer.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CallbackServer.java b/framework/src/org/apache/cordova/CallbackServer.java
index fbf5a98..f533722 100755
--- a/framework/src/org/apache/cordova/CallbackServer.java
+++ b/framework/src/org/apache/cordova/CallbackServer.java
@@ -25,11 +25,8 @@ import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.ServerSocket;
import java.net.Socket;
-import java.net.URLEncoder;
import java.util.LinkedList;
-import android.util.Log;
-
/**
* This class provides a way for Java to run JavaScript in the web page that has loaded Cordova.
* The CallbackServer class implements an XHR server and a polling server with a list of JavaScript
@@ -55,307 +52,309 @@ import android.util.Log;
* 3. The client repeats #1 in loop.
*/
public class CallbackServer implements Runnable {
-
- private static final String LOG_TAG = "CallbackServer";
-
- /**
- * The list of JavaScript statements to be sent to JavaScript.
- */
- private LinkedList<String> javascript;
-
- /**
- * The port to listen on.
- */
- private int port;
-
- /**
- * The server thread.
- */
- private Thread serverThread;
-
- /**
- * Indicates the server is running.
- */
- private boolean active;
-
- /**
- * Indicates that the JavaScript statements list is empty
- */
- private boolean empty;
-
- /**
- * Indicates that polling should be used instead of XHR.
- */
- private boolean usePolling = true;
-
- /**
- * Security token to prevent other apps from accessing this callback server via XHR
- */
- private String token;
-
- /**
- * Constructor.
- */
- public CallbackServer() {
- //Log.d(LOG_TAG, "CallbackServer()");
- this.active = false;
- this.empty = true;
- this.port = 0;
- this.javascript = new LinkedList<String>();
- }
-
- /**
- * Init callback server and start XHR if running local app.
- *
- * If Cordova app is loaded from file://, then we can use XHR
- * otherwise we have to use polling due to cross-domain security restrictions.
- *
- * @param url The URL of the Cordova app being loaded
- */
- public void init(String url) {
- //Log.d(LOG_TAG, "CallbackServer.start("+url+")");
- this.active = false;
- this.empty = true;
- this.port = 0;
- this.javascript = new LinkedList<String>();
-
- // Determine if XHR or polling is to be used
- if ((url != null) && !url.startsWith("file://")) {
- this.usePolling = true;
- this.stopServer();
- }
- else if (android.net.Proxy.getDefaultHost() != null) {
- this.usePolling = true;
- this.stopServer();
- }
- else {
- this.usePolling = false;
- this.startServer();
- }
- }
-
+
+ @SuppressWarnings("unused")
+ private static final String LOG_TAG = "CallbackServer";
+
+ /**
+ * The list of JavaScript statements to be sent to JavaScript.
+ */
+ private LinkedList<String> javascript;
+
+ /**
+ * The port to listen on.
+ */
+ private int port;
+
+ /**
+ * The server thread.
+ */
+ private Thread serverThread;
+
+ /**
+ * Indicates the server is running.
+ */
+ private boolean active;
+
+ /**
+ * Indicates that the JavaScript statements list is empty
+ */
+ private boolean empty;
+
+ /**
+ * Indicates that polling should be used instead of XHR.
+ */
+ private boolean usePolling = true;
+
+ /**
+ * Security token to prevent other apps from accessing this callback server via XHR
+ */
+ private String token;
+
+ /**
+ * Constructor.
+ */
+ public CallbackServer() {
+ //Log.d(LOG_TAG, "CallbackServer()");
+ this.active = false;
+ this.empty = true;
+ this.port = 0;
+ this.javascript = new LinkedList<String>();
+ }
+
+ /**
+ * Init callback server and start XHR if running local app.
+ *
+ * If Cordova app is loaded from file://, then we can use XHR
+ * otherwise we have to use polling due to cross-domain security restrictions.
+ *
+ * @param url The URL of the Cordova app being loaded
+ */
+ @SuppressWarnings("deprecation")
+ public void init(String url) {
+ //Log.d(LOG_TAG, "CallbackServer.start("+url+")");
+ this.active = false;
+ this.empty = true;
+ this.port = 0;
+ this.javascript = new LinkedList<String>();
+
+ // Determine if XHR or polling is to be used
+ if ((url != null) && !url.startsWith("file://")) {
+ this.usePolling = true;
+ this.stopServer();
+ }
+ else if (android.net.Proxy.getDefaultHost() != null) {
+ this.usePolling = true;
+ this.stopServer();
+ }
+ else {
+ this.usePolling = false;
+ this.startServer();
+ }
+ }
+
/**
* Re-init when loading a new HTML page into webview.
*
* @param url The URL of the Cordova app being loaded
*/
- public void reinit(String url) {
- this.stopServer();
- this.init(url);
- }
-
- /**
- * Return if polling is being used instead of XHR.
- *
- * @return
- */
- public boolean usePolling() {
- return this.usePolling;
- }
-
- /**
- * Get the port that this server is running on.
- *
- * @return
- */
- public int getPort() {
- return this.port;
- }
-
- /**
- * Get the security token that this server requires when calling getJavascript().
- *
- * @return
- */
- public String getToken() {
- return this.token;
- }
-
- /**
- * Start the server on a new thread.
- */
- public void startServer() {
- //Log.d(LOG_TAG, "CallbackServer.startServer()");
- this.active = false;
-
- // Start server on new thread
- this.serverThread = new Thread(this);
- this.serverThread.start();
- }
-
- /**
- * Restart the server on a new thread.
- */
- public void restartServer() {
-
- // Stop server
- this.stopServer();
-
- // Start server again
- this.startServer();
- }
-
- /**
- * Start running the server.
- * This is called automatically when the server thread is started.
- */
- public void run() {
-
- // Start server
- try {
- this.active = true;
- String request;
- ServerSocket waitSocket = new ServerSocket(0);
- this.port = waitSocket.getLocalPort();
- //Log.d(LOG_TAG, "CallbackServer -- using port " +this.port);
- this.token = java.util.UUID.randomUUID().toString();
- //Log.d(LOG_TAG, "CallbackServer -- using token "+this.token);
-
- while (this.active) {
- //Log.d(LOG_TAG, "CallbackServer: Waiting for data on socket");
- Socket connection = waitSocket.accept();
- BufferedReader xhrReader = new BufferedReader(new InputStreamReader(connection.getInputStream()),40);
- DataOutputStream output = new DataOutputStream(connection.getOutputStream());
- request = xhrReader.readLine();
- String response = "";
- //Log.d(LOG_TAG, "CallbackServerRequest="+request);
- if (this.active && (request != null)) {
- if (request.contains("GET")) {
-
- // Get requested file
- String[] requestParts = request.split(" ");
-
- // Must have security token
- if ((requestParts.length == 3) && (requestParts[1].substring(1).equals(this.token))) {
- //Log.d(LOG_TAG, "CallbackServer -- Processing GET request");
-
- // Wait until there is some data to send, or send empty data every 10 sec
- // to prevent XHR timeout on the client
- synchronized (this) {
- while (this.empty) {
- try {
- this.wait(10000); // prevent timeout from happening
- //Log.d(LOG_TAG, "CallbackServer>>> break <<<");
- break;
- }
- catch (Exception e) { }
- }
- }
-
- // If server is still running
- if (this.active) {
-
- // If no data, then send 404 back to client before it times out
- if (this.empty) {
- //Log.d(LOG_TAG, "CallbackServer -- sending data 0");
- response = "HTTP/1.1 404 NO DATA\r\n\r\n "; // need to send content otherwise some Android devices fail, so send space
- }
- else {
- //Log.d(LOG_TAG, "CallbackServer -- sending item");
- response = "HTTP/1.1 200 OK\r\n\r\n";
- String js = this.getJavascript();
- if (js != null) {
- response += encode(js, "UTF-8");
- }
- }
- }
- else {
- response = "HTTP/1.1 503 Service Unavailable\r\n\r\n ";
- }
- }
- else {
- response = "HTTP/1.1 403 Forbidden\r\n\r\n ";
- }
- }
- else {
- response = "HTTP/1.1 400 Bad Request\r\n\r\n ";
- }
- //Log.d(LOG_TAG, "CallbackServer: response="+response);
- //Log.d(LOG_TAG, "CallbackServer: closing output");
- output.writeBytes(response);
- output.flush();
- }
- output.close();
- xhrReader.close();
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- this.active = false;
- //Log.d(LOG_TAG, "CallbackServer.startServer() - EXIT");
- }
-
- /**
- * Stop server.
- * This stops the thread that the server is running on.
- */
- public void stopServer() {
- //Log.d(LOG_TAG, "CallbackServer.stopServer()");
- if (this.active) {
- this.active = false;
-
- // Break out of server wait
- synchronized (this) {
- this.notify();
- }
- }
- }
+ public void reinit(String url) {
+ this.stopServer();
+ this.init(url);
+ }
+
+ /**
+ * Return if polling is being used instead of XHR.
+ *
+ * @return
+ */
+ public boolean usePolling() {
+ return this.usePolling;
+ }
+
+ /**
+ * Get the port that this server is running on.
+ *
+ * @return
+ */
+ public int getPort() {
+ return this.port;
+ }
+
+ /**
+ * Get the security token that this server requires when calling getJavascript().
+ *
+ * @return
+ */
+ public String getToken() {
+ return this.token;
+ }
+
+ /**
+ * Start the server on a new thread.
+ */
+ public void startServer() {
+ //Log.d(LOG_TAG, "CallbackServer.startServer()");
+ this.active = false;
+
+ // Start server on new thread
+ this.serverThread = new Thread(this);
+ this.serverThread.start();
+ }
+
+ /**
+ * Restart the server on a new thread.
+ */
+ public void restartServer() {
+
+ // Stop server
+ this.stopServer();
+
+ // Start server again
+ this.startServer();
+ }
+
+ /**
+ * Start running the server.
+ * This is called automatically when the server thread is started.
+ */
+ public void run() {
+
+ // Start server
+ try {
+ this.active = true;
+ String request;
+ ServerSocket waitSocket = new ServerSocket(0);
+ this.port = waitSocket.getLocalPort();
+ //Log.d(LOG_TAG, "CallbackServer -- using port " +this.port);
+ this.token = java.util.UUID.randomUUID().toString();
+ //Log.d(LOG_TAG, "CallbackServer -- using token "+this.token);
+
+ while (this.active) {
+ //Log.d(LOG_TAG, "CallbackServer: Waiting for data on socket");
+ Socket connection = waitSocket.accept();
+ BufferedReader xhrReader = new BufferedReader(new InputStreamReader(connection.getInputStream()), 40);
+ DataOutputStream output = new DataOutputStream(connection.getOutputStream());
+ request = xhrReader.readLine();
+ String response = "";
+ //Log.d(LOG_TAG, "CallbackServerRequest="+request);
+ if (this.active && (request != null)) {
+ if (request.contains("GET")) {
+
+ // Get requested file
+ String[] requestParts = request.split(" ");
+
+ // Must have security token
+ if ((requestParts.length == 3) && (requestParts[1].substring(1).equals(this.token))) {
+ //Log.d(LOG_TAG, "CallbackServer -- Processing GET request");
+
+ // Wait until there is some data to send, or send empty data every 10 sec
+ // to prevent XHR timeout on the client
+ synchronized (this) {
+ while (this.empty) {
+ try {
+ this.wait(10000); // prevent timeout from happening
+ //Log.d(LOG_TAG, "CallbackServer>>> break <<<");
+ break;
+ } catch (Exception e) {
+ }
+ }
+ }
+
+ // If server is still running
+ if (this.active) {
+
+ // If no data, then send 404 back to client before it times out
+ if (this.empty) {
+ //Log.d(LOG_TAG, "CallbackServer -- sending data 0");
+ response = "HTTP/1.1 404 NO DATA\r\n\r\n "; // need to send content otherwise some Android devices fail, so send space
+ }
+ else {
+ //Log.d(LOG_TAG, "CallbackServer -- sending item");
+ response = "HTTP/1.1 200 OK\r\n\r\n";
+ String js = this.getJavascript();
+ if (js != null) {
+ response += encode(js, "UTF-8");
+ }
+ }
+ }
+ else {
+ response = "HTTP/1.1 503 Service Unavailable\r\n\r\n ";
+ }
+ }
+ else {
+ response = "HTTP/1.1 403 Forbidden\r\n\r\n ";
+ }
+ }
+ else {
+ response = "HTTP/1.1 400 Bad Request\r\n\r\n ";
+ }
+ //Log.d(LOG_TAG, "CallbackServer: response="+response);
+ //Log.d(LOG_TAG, "CallbackServer: closing output");
+ output.writeBytes(response);
+ output.flush();
+ }
+ output.close();
+ xhrReader.close();
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ this.active = false;
+ //Log.d(LOG_TAG, "CallbackServer.startServer() - EXIT");
+ }
+
+ /**
+ * Stop server.
+ * This stops the thread that the server is running on.
+ */
+ public void stopServer() {
+ //Log.d(LOG_TAG, "CallbackServer.stopServer()");
+ if (this.active) {
+ this.active = false;
+
+ // Break out of server wait
+ synchronized (this) {
+ this.notify();
+ }
+ }
+ }
/**
* Destroy
*/
public void destroy() {
- this.stopServer();
+ this.stopServer();
+ }
+
+ /**
+ * Get the number of JavaScript statements.
+ *
+ * @return int
+ */
+ public int getSize() {
+ synchronized (this) {
+ int size = this.javascript.size();
+ return size;
+ }
}
- /**
- * Get the number of JavaScript statements.
- *
- * @return int
- */
- public int getSize() {
- synchronized(this) {
- int size = this.javascript.size();
- return size;
- }
- }
-
- /**
- * Get the next JavaScript statement and remove from list.
- *
- * @return String
- */
- public String getJavascript() {
- synchronized(this) {
- if (this.javascript.size() == 0) {
- return null;
- }
- String statement = this.javascript.remove(0);
- if (this.javascript.size() == 0) {
- this.empty = true;
- }
- return statement;
- }
- }
-
- /**
- * Add a JavaScript statement to the list.
- *
- * @param statement
- */
- public void sendJavascript(String statement) {
- synchronized (this) {
- this.javascript.add(statement);
- this.empty = false;
- this.notify();
- }
- }
-
- /* The Following code has been modified from original implementation of URLEncoder */
-
- /* start */
-
- /*
+ /**
+ * Get the next JavaScript statement and remove from list.
+ *
+ * @return String
+ */
+ public String getJavascript() {
+ synchronized (this) {
+ if (this.javascript.size() == 0) {
+ return null;
+ }
+ String statement = this.javascript.remove(0);
+ if (this.javascript.size() == 0) {
+ this.empty = true;
+ }
+ return statement;
+ }
+ }
+
+ /**
+ * Add a JavaScript statement to the list.
+ *
+ * @param statement
+ */
+ public void sendJavascript(String statement) {
+ synchronized (this) {
+ this.javascript.add(statement);
+ this.empty = false;
+ this.notify();
+ }
+ }
+
+ /* The Following code has been modified from original implementation of URLEncoder */
+
+ /* start */
+
+ /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
@@ -371,7 +370,7 @@ public class CallbackServer implements Runnable {
* See the License for the specific language governing permissions and
* limitations under the License.
*/
- static final String digits = "0123456789ABCDEF";
+ static final String digits = "0123456789ABCDEF";
/**
* This will encode the return value to JavaScript. We revert the encoding for
@@ -382,13 +381,13 @@ public class CallbackServer implements Runnable {
* @param enc encoding type
* @return encoded string
*/
- public static String encode(String s, String enc) throws UnsupportedEncodingException {
+ public static String encode(String s, String enc) throws UnsupportedEncodingException {
if (s == null || enc == null) {
throw new NullPointerException();
}
// check for UnsupportedEncodingException
"".getBytes(enc);
-
+
// Guess a bit bigger for encoded form
StringBuilder buf = new StringBuilder(s.length() + 16);
int start = -1;
@@ -426,6 +425,6 @@ public class CallbackServer implements Runnable {
buf.append(digits.charAt(bytes[j] & 0xf));
}
}
-
+
/* end */
}
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/3829df66/framework/src/org/apache/cordova/Capture.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/Capture.java b/framework/src/org/apache/cordova/Capture.java
index bfb5307..ca81b00 100644
--- a/framework/src/org/apache/cordova/Capture.java
+++ b/framework/src/org/apache/cordova/Capture.java
@@ -22,7 +22,6 @@ import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
-import org.apache.cordova.api.CordovaInterface;
import org.apache.cordova.api.LOG;
import org.apache.cordova.api.Plugin;
import org.apache.cordova.api.PluginResult;
@@ -32,7 +31,6 @@ import org.json.JSONObject;
import android.app.Activity;
import android.content.ContentValues;
-//import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/3829df66/framework/src/org/apache/cordova/CordovaException.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CordovaException.java b/framework/src/org/apache/cordova/CordovaException.java
index da02497..01db3c4 100755
--- a/framework/src/org/apache/cordova/CordovaException.java
+++ b/framework/src/org/apache/cordova/CordovaException.java
@@ -20,4 +20,9 @@
package org.apache.cordova;
public class CordovaException extends Exception {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1373339564758328799L;
}
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/3829df66/framework/src/org/apache/cordova/CordovaWebView.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CordovaWebView.java b/framework/src/org/apache/cordova/CordovaWebView.java
index 594b7bf..a6f152e 100644
--- a/framework/src/org/apache/cordova/CordovaWebView.java
+++ b/framework/src/org/apache/cordova/CordovaWebView.java
@@ -22,7 +22,6 @@ package org.apache.cordova;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.Hashtable;
import java.util.Iterator;
import java.util.Stack;
import java.util.regex.Matcher;
@@ -47,9 +46,6 @@ public class CordovaWebView extends WebView {
public static final String TAG = "CordovaWebView";
- /** The authorization tokens. */
- //private Hashtable<String, AuthenticationToken> authenticationTokens = new Hashtable<String, AuthenticationToken>();
-
/** The whitelist **/
private ArrayList<Pattern> whiteList = new ArrayList<Pattern>();
private HashMap<String, Boolean> whiteListCache = new HashMap<String, Boolean>();
@@ -59,6 +55,7 @@ public class CordovaWebView extends WebView {
/** Actvities and other important classes **/
private CordovaInterface mCtx;
CordovaWebViewClient viewClient;
+ @SuppressWarnings("unused")
private CordovaChromeClient chromeClient;
//This is for the polyfil history
@@ -71,12 +68,6 @@ public class CordovaWebView extends WebView {
// Flag to track that a loadUrl timeout occurred
int loadUrlTimeout = 0;
- // LoadUrl timeout value in msec (default of 20 sec)
- //protected int loadUrlTimeoutValue = 20000;
-
- //preferences read from cordova.xml
- //protected PreferenceSet preferences;
-
/**
* Constructor.
*
@@ -85,7 +76,6 @@ public class CordovaWebView extends WebView {
public CordovaWebView(CordovaInterface context) {
super(context.getActivity());
this.mCtx = context;
- //preferences = new PreferenceSet();
this.loadConfiguration();
this.setup();
}
@@ -99,7 +89,6 @@ public class CordovaWebView extends WebView {
public CordovaWebView(CordovaInterface context, AttributeSet attrs) {
super(context.getActivity(), attrs);
this.mCtx = context;
- //preferences = new PreferenceSet();
this.loadConfiguration();
this.setup();
}
@@ -114,7 +103,6 @@ public class CordovaWebView extends WebView {
public CordovaWebView(CordovaInterface context, AttributeSet attrs, int defStyle) {
super(context.getActivity(), attrs, defStyle);
this.mCtx = context;
- //preferences = new PreferenceSet();
this.loadConfiguration();
this.setup();
}
@@ -130,7 +118,6 @@ public class CordovaWebView extends WebView {
public CordovaWebView(CordovaInterface context, AttributeSet attrs, int defStyle, boolean privateBrowsing) {
super(context.getActivity(), attrs, defStyle, privateBrowsing);
this.mCtx = context;
- //preferences = new PreferenceSet();
this.loadConfiguration();
this.setup();
}
@@ -138,6 +125,7 @@ public class CordovaWebView extends WebView {
/**
* Initialize webview.
*/
+ @SuppressWarnings("deprecation")
private void setup() {
this.setInitialScale(0);
@@ -158,10 +146,6 @@ public class CordovaWebView extends WebView {
String databasePath = this.mCtx.getActivity().getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath();
settings.setDatabasePath(databasePath);
- //Setup the WebChromeClient and WebViewClient
- //setWebViewClient(new CordovaWebViewClient(mCtx, this));
- //setWebChromeClient(new CordovaChromeClient(mCtx, this));
-
// Enable DOM storage
settings.setDomStorageEnabled(true);
@@ -588,16 +572,8 @@ public class CordovaWebView extends WebView {
String name = xml.getAttributeValue(null, "name");
String value = xml.getAttributeValue(null, "value");
- // TODO @bc Is preferences needed? Just use Intent.putExtra?
- //String readonlyString = xml.getAttributeValue(null, "readonly");
-
- //boolean readonly = (readonlyString != null &&
- // readonlyString.equals("true"));
-
LOG.i("CordovaLog", "Found preference for %s=%s", name, value);
- //preferences.add(new PreferenceNode(name, value, readonly));
-
// Save preferences in Intent
this.mCtx.getActivity().getIntent().putExtra(name, value);
}
@@ -612,7 +588,6 @@ public class CordovaWebView extends WebView {
}
// Init preferences
- //this.useBrowserHistory = preferences.prefMatches("useBrowserHistory", "true");
if ("true".equals(this.getProperty("useBrowserHistory", "true"))) {
this.useBrowserHistory = true;
}
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/3829df66/framework/src/org/apache/cordova/CordovaWebViewClient.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CordovaWebViewClient.java b/framework/src/org/apache/cordova/CordovaWebViewClient.java
index 21af000..227e251 100755
--- a/framework/src/org/apache/cordova/CordovaWebViewClient.java
+++ b/framework/src/org/apache/cordova/CordovaWebViewClient.java
@@ -25,8 +25,6 @@ import org.apache.cordova.api.LOG;
import org.json.JSONException;
import org.json.JSONObject;
-//import android.app.Activity;
-//import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
@@ -34,7 +32,6 @@ import android.content.pm.PackageManager.NameNotFoundException;
import android.graphics.Bitmap;
import android.net.Uri;
import android.net.http.SslError;
-//import android.util.Log;
import android.view.View;
import android.webkit.HttpAuthHandler;
import android.webkit.SslErrorHandler;
@@ -274,7 +271,6 @@ public class CordovaWebViewClient extends WebViewClient {
Thread.sleep(2000);
ctx.getActivity().runOnUiThread(new Runnable() {
public void run() {
- //appView.setVisibility(View.VISIBLE);
appView.postMessage("spinner", "stop");
}
});
@@ -290,7 +286,6 @@ public class CordovaWebViewClient extends WebViewClient {
if (this.appView.callbackServer != null) {
this.appView.callbackServer.destroy();
}
- //this.ctx.endActivity();
this.ctx.getActivity().finish();
}
}
@@ -311,11 +306,7 @@ public class CordovaWebViewClient extends WebViewClient {
// Clear timeout flag
this.appView.loadUrlTimeout++;
- // Stop "app loading" spinner if showing
- //this.ctx.spinnerStop();
-
// Handle error
- //this.ctx.onReceivedError(errorCode, description, failingUrl);
JSONObject data = new JSONObject();
try {
data.put("errorCode", errorCode);
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/3829df66/framework/src/org/apache/cordova/DirectoryManager.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/DirectoryManager.java b/framework/src/org/apache/cordova/DirectoryManager.java
index 7b8e03f..c888d42 100644
--- a/framework/src/org/apache/cordova/DirectoryManager.java
+++ b/framework/src/org/apache/cordova/DirectoryManager.java
@@ -31,107 +31,108 @@ import android.os.StatFs;
* It is used by the FileUtils class.
*/
public class DirectoryManager {
-
- private static final String LOG_TAG = "DirectoryManager";
-
- /**
- * Determine if a file or directory exists.
- *
- * @param name The name of the file to check.
- * @return T=exists, F=not found
- */
- protected static boolean testFileExists(String name) {
- boolean status;
-
- // If SD card exists
- if ((testSaveLocationExists()) && (!name.equals(""))) {
- File path = Environment.getExternalStorageDirectory();
+
+ @SuppressWarnings("unused")
+ private static final String LOG_TAG = "DirectoryManager";
+
+ /**
+ * Determine if a file or directory exists.
+ *
+ * @param name The name of the file to check.
+ * @return T=exists, F=not found
+ */
+ protected static boolean testFileExists(String name) {
+ boolean status;
+
+ // If SD card exists
+ if ((testSaveLocationExists()) && (!name.equals(""))) {
+ File path = Environment.getExternalStorageDirectory();
File newPath = constructFilePaths(path.toString(), name);
status = newPath.exists();
- }
- // If no SD card
- else{
- status = false;
- }
- return status;
- }
-
- /**
- * Get the free disk space
- *
- * @return Size in KB or -1 if not available
- */
- protected static long getFreeDiskSpace(boolean checkInternal) {
- String status = Environment.getExternalStorageState();
- long freeSpace = 0;
-
- // If SD card exists
- if (status.equals(Environment.MEDIA_MOUNTED)) {
- freeSpace = freeSpaceCalculation(Environment.getExternalStorageDirectory().getPath());
- }
- else if (checkInternal) {
- freeSpace = freeSpaceCalculation("/");
- }
- // If no SD card and we haven't been asked to check the internal directory then return -1
- else {
- return -1;
- }
-
- return freeSpace;
- }
-
- /**
- * Given a path return the number of free KB
- *
- * @param path to the file system
- * @return free space in KB
- */
- private static long freeSpaceCalculation(String path) {
+ }
+ // If no SD card
+ else {
+ status = false;
+ }
+ return status;
+ }
+
+ /**
+ * Get the free disk space
+ *
+ * @return Size in KB or -1 if not available
+ */
+ protected static long getFreeDiskSpace(boolean checkInternal) {
+ String status = Environment.getExternalStorageState();
+ long freeSpace = 0;
+
+ // If SD card exists
+ if (status.equals(Environment.MEDIA_MOUNTED)) {
+ freeSpace = freeSpaceCalculation(Environment.getExternalStorageDirectory().getPath());
+ }
+ else if (checkInternal) {
+ freeSpace = freeSpaceCalculation("/");
+ }
+ // If no SD card and we haven't been asked to check the internal directory then return -1
+ else {
+ return -1;
+ }
+
+ return freeSpace;
+ }
+
+ /**
+ * Given a path return the number of free KB
+ *
+ * @param path to the file system
+ * @return free space in KB
+ */
+ private static long freeSpaceCalculation(String path) {
StatFs stat = new StatFs(path);
long blockSize = stat.getBlockSize();
long availableBlocks = stat.getAvailableBlocks();
- return availableBlocks*blockSize/1024;
- }
-
- /**
- * Determine if SD card exists.
- *
- * @return T=exists, F=not found
- */
- protected static boolean testSaveLocationExists() {
- String sDCardStatus = Environment.getExternalStorageState();
- boolean status;
-
- // If SD card is mounted
- if (sDCardStatus.equals(Environment.MEDIA_MOUNTED)) {
- status = true;
- }
-
- // If no SD card
- else {
- status = false;
- }
- return status;
- }
-
- /**
- * Create a new file object from two file paths.
- *
- * @param file1 Base file path
- * @param file2 Remaining file path
- * @return File object
- */
- private static File constructFilePaths (String file1, String file2) {
- File newPath;
- if (file2.startsWith(file1)) {
- newPath = new File(file2);
- }
- else {
- newPath = new File(file1+"/"+file2);
- }
- return newPath;
- }
-
+ return availableBlocks * blockSize / 1024;
+ }
+
+ /**
+ * Determine if SD card exists.
+ *
+ * @return T=exists, F=not found
+ */
+ protected static boolean testSaveLocationExists() {
+ String sDCardStatus = Environment.getExternalStorageState();
+ boolean status;
+
+ // If SD card is mounted
+ if (sDCardStatus.equals(Environment.MEDIA_MOUNTED)) {
+ status = true;
+ }
+
+ // If no SD card
+ else {
+ status = false;
+ }
+ return status;
+ }
+
+ /**
+ * Create a new file object from two file paths.
+ *
+ * @param file1 Base file path
+ * @param file2 Remaining file path
+ * @return File object
+ */
+ private static File constructFilePaths(String file1, String file2) {
+ File newPath;
+ if (file2.startsWith(file1)) {
+ newPath = new File(file2);
+ }
+ else {
+ newPath = new File(file1 + "/" + file2);
+ }
+ return newPath;
+ }
+
/**
* Determine if we can use the SD Card to store the temporary file. If not then use
* the internal cache directory.
@@ -140,12 +141,12 @@ public class DirectoryManager {
*/
protected static String getTempDirectoryPath(Context ctx) {
File cache = null;
-
+
// SD Card Mounted
if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
- cache = new File(Environment.getExternalStorageDirectory().getAbsolutePath() +
+ cache = new File(Environment.getExternalStorageDirectory().getAbsolutePath() +
"/Android/data/" + ctx.getPackageName() + "/cache/");
- }
+ }
// Use internal storage
else {
cache = ctx.getCacheDir();
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/3829df66/framework/src/org/apache/cordova/DroidGap.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/DroidGap.java b/framework/src/org/apache/cordova/DroidGap.java
index 5be0fa9..a1c3adb 100755
--- a/framework/src/org/apache/cordova/DroidGap.java
+++ b/framework/src/org/apache/cordova/DroidGap.java
@@ -18,24 +18,13 @@
*/
package org.apache.cordova;
-//import java.io.IOException;
-//import java.util.ArrayList;
import java.util.HashMap;
-//import java.util.Hashtable;
-//import java.util.Iterator;
-//import java.util.Stack;
-//import java.util.regex.Matcher;
-//import java.util.regex.Pattern;
-
-//import org.apache.cordova.PreferenceNode;
-//import org.apache.cordova.PreferenceSet;
+
import org.apache.cordova.api.IPlugin;
import org.apache.cordova.api.LOG;
import org.apache.cordova.api.CordovaInterface;
import org.json.JSONException;
import org.json.JSONObject;
-//import org.apache.cordova.api.PluginManager;
-//import org.xmlpull.v1.XmlPullParserException;
import android.app.Activity;
import android.app.AlertDialog;
@@ -45,10 +34,8 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Configuration;
-//import android.content.res.XmlResourceParser;
import android.graphics.Color;
import android.media.AudioManager;
-//import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.view.Display;
@@ -59,10 +46,6 @@ import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
-//import android.webkit.WebChromeClient;
-//import android.webkit.WebSettings;
-//import android.webkit.WebSettings.LayoutAlgorithm;
-//import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.LinearLayout;
@@ -161,11 +144,7 @@ public class DroidGap extends Activity implements CordovaInterface {
// The initial URL for our app
// ie http://server/path/index.html#abc?query
- private String url = null;
- //private Stack<String> urls = new Stack<String>();
-
- // Url was specified from extras (activity was started programmatically)
- //private String initUrl = null;
+ //private String url = null;
private static int ACTIVITY_STARTING = 0;
private static int ACTIVITY_RUNNING = 1;
@@ -181,9 +160,6 @@ public class DroidGap extends Activity implements CordovaInterface {
protected IPlugin activityResultCallback = null;
protected boolean activityResultKeepRunning;
- // Flag indicates that a loadUrl timeout occurred
- //int loadUrlTimeout = 0;
-
// Default background color for activity
// (this is not the color for the webview, which is set in HTML)
private int backgroundColor = Color.BLACK;
@@ -197,20 +173,11 @@ public class DroidGap extends Activity implements CordovaInterface {
protected int splashscreen = 0;
protected int splashscreenTime = 0;
- // LoadUrl timeout value in msec (default of 20 sec)
- //protected int loadUrlTimeoutValue = 20000;
-
// Keep app running when pause is received. (default = true)
// If true, then the JavaScript and native code continue to run in the background
// when another application (activity) is started.
protected boolean keepRunning = true;
- // Store the useBrowserHistory preference until we actually need it.
- //private boolean useBrowserHistory = false;
-
- // preferences read from cordova.xml
- //protected PreferenceSet preferences;
-
/**
* Sets the authentication token.
*
@@ -298,14 +265,6 @@ public class DroidGap extends Activity implements CordovaInterface {
root.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT, 0.0F));
- // If url was passed in to intent, then init webview, which will load the url
-// Bundle bundle = this.getIntent().getExtras();
-// if (bundle != null) {
-// String url = bundle.getString("url");
-// if (url != null) {
-// this.initUrl = url;
-// }
-// }
// Setup the hardware volume controls to handle volume control
setVolumeControlStream(AudioManager.STREAM_MUSIC);
}
@@ -346,15 +305,6 @@ public class DroidGap extends Activity implements CordovaInterface {
webViewClient.setWebView(this.appView);
webChromeClient.setWebView(this.appView);
- // Load Cordova configuration:
- // white list of allowed URLs
- // debug setting
- //this.loadConfiguration();
- //Now we can check the preference
- //this.appView.useBrowserHistory = preferences.prefMatches("useBrowserHistory", "true");
-
- //
-
this.appView.setLayoutParams(new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT,
@@ -370,30 +320,6 @@ public class DroidGap extends Activity implements CordovaInterface {
}
/**
- * Look at activity parameters and process them.
- * This must be called from the main UI thread.
- */
- //private void handleActivityParameters() {
-
- // If backgroundColor
- //this.backgroundColor = this.getIntegerProperty("backgroundColor", Color.BLACK);
- //LOG.e(TAG, "Setting background color=" + this.backgroundColor);
- //this.root.setBackgroundColor(this.backgroundColor);
-
- // If spashscreen
- //this.splashscreen = this.getIntegerProperty("splashscreen", 0);
-
- // If loadUrlTimeoutValue
- //int timeout = this.getIntegerProperty("loadUrlTimeoutValue", 0);
- //if (timeout > 0) {
- // this.loadUrlTimeoutValue = timeout;
- //}
-
- // If keepRunning
- //this.keepRunning = this.getBooleanProperty("keepRunning", true);
- //}
-
- /**
* Load the url into the webview.
*
* @param url
@@ -405,9 +331,6 @@ public class DroidGap extends Activity implements CordovaInterface {
this.init();
}
- // Handle activity parameters
- //this.handleActivityParameters();
-
// If backgroundColor
this.backgroundColor = this.getIntegerProperty("backgroundColor", Color.BLACK);
LOG.e(TAG, "Setting background color=" + this.backgroundColor);
@@ -420,15 +343,6 @@ public class DroidGap extends Activity implements CordovaInterface {
this.loadSpinner();
this.appView.loadUrl(url);
-
-// // If first page of app, then set URL to load to be the one passed in
-// if (this.initUrl == null || (this.urls.size() > 0)) {
-// this.loadUrlIntoView(url);
-// }
-// // Otherwise use the URL specified in the activity's extras bundle
-// else {
-// this.loadUrlIntoView(this.initUrl);
-// }
}
/*
@@ -465,71 +379,6 @@ public class DroidGap extends Activity implements CordovaInterface {
}
/**
- * Load the url into the webview.
- *
- * @param url
- */
-// private void loadUrlIntoView(final String url) {
-// if (!url.startsWith("javascript:")) {
-// LOG.d(TAG, "DroidGap.loadUrl(%s)", url);
-// }
-//
-// if (!url.startsWith("javascript:")) {
-// LOG.d(TAG, "DroidGap: url=%s baseUrl=%s", url, baseUrl);
-// }
-//
-// // Load URL on UI thread
-// final DroidGap me = this;
-//
-//// final Runnable loadError = new Runnable() {
-//// public void run() {
-//// me.appView.stopLoading();
-//// LOG.e(TAG, "DroidGap: TIMEOUT ERROR! - calling webViewClient");
-//// appView.viewClient.onReceivedError(me.appView, -6, "The connection to the server was unsuccessful.", url);
-//// }
-//// };
-//
-// this.runOnUiThread(new Runnable() {
-// public void run() {
-//
-// // Init web view if not already done
-// if (me.appView == null) {
-// me.init();
-// }
-//
-// // Handle activity parameters (TODO: Somehow abstract this)
-// me.handleActivityParameters();
-//
-// // Then load the spinner
-// me.loadSpinner();
-//
-//// // Create a timeout timer for loadUrl
-//// final int currentLoadUrlTimeout = me.loadUrlTimeout;
-//// Runnable runnable = new Runnable() {
-//// public void run() {
-//// try {
-//// synchronized (this) {
-//// wait(me.loadUrlTimeoutValue);
-//// }
-//// } catch (InterruptedException e) {
-//// e.printStackTrace();
-//// }
-////
-//// // If timeout, then stop loading and handle error
-//// if (me.loadUrlTimeout == currentLoadUrlTimeout) {
-//// me.runOnUiThread(loadError);
-////
-//// }
-//// }
-//// };
-//// Thread thread = new Thread(runnable);
-//// thread.start();
-// me.appView.loadUrl(url);
-// }
-// });
-// }
-
- /**
* Load the url into the webview after waiting for period of time.
* This is used to display the splashscreen for certain amount of time.
*
@@ -545,46 +394,9 @@ public class DroidGap extends Activity implements CordovaInterface {
this.splashscreenTime = time;
this.appView.loadUrl(url, time);
-
-// // If first page of app, then set URL to load to be the one passed in
-// if (this.initUrl == null || (this.urls.size() > 0)) {
-// this.loadUrlIntoView(url, time);
-// }
-// // Otherwise use the URL specified in the activity's extras bundle
-// else {
-// this.loadUrlIntoView(this.initUrl);
-// }
}
/**
- * Load the url into the webview after waiting for period of time.
- * This is used to display the splashscreen for certain amount of time.
- *
- * @param url
- * @param time The number of ms to wait before showing webview
- */
-// private void loadUrlIntoView(final String url, final int time) {
-//
-// // Clear cancel flag
-// this.cancelLoadUrl = false;
-//
-// // If not first page of app, then load immediately
-// if (this.urls.size() > 0) {
-// this.loadUrlIntoView(url);
-// }
-//
-// if (!url.startsWith("javascript:")) {
-// LOG.d(TAG, "DroidGap.loadUrl(%s, %d)", url, time);
-// }
-//
-// this.handleActivityParameters();
-// if (this.splashscreen != 0) {
-// this.showSplashScreen(time);
-// }
-// this.loadUrlIntoView(url);
-// }
-
- /**
* Cancel loadUrl before it has been loaded.
*/
// TODO NO-OP
@@ -607,13 +419,6 @@ public class DroidGap extends Activity implements CordovaInterface {
*/
public void clearHistory() {
this.appView.clearHistory();
-// this.urls.clear();
-// this.appView.clearHistory();
-//
-// // Leave current url on history stack
-// if (this.url != null) {
-// this.urls.push(this.url);
-// }
}
/**
@@ -939,7 +744,6 @@ public class DroidGap extends Activity implements CordovaInterface {
* End this activity by calling finish for activity
*/
public void endActivity() {
- //this.activityState = ACTIVITY_EXITING;
this.finish();
}
@@ -999,23 +803,6 @@ public class DroidGap extends Activity implements CordovaInterface {
}
/**
- * Any calls to Activity.startActivityForResult must use method below, so
- * the result can be routed to them correctly.
- *
- * This is done to eliminate the need to modify DroidGap.java to receive activity results.
- *
- * @param intent The intent to start
- * @param requestCode Identifies who to send the result to
- *
- * @throws RuntimeException
- */
- //@Override
- //public void startActivityForResult(Intent intent, int requestCode) throws RuntimeException {
- // LOG.d(TAG, "DroidGap.startActivityForResult(intent,%d)", requestCode);
- // super.startActivityForResult(intent, requestCode);
- //}
-
- /**
* Launch an activity for which you would like a result when it finished. When this activity exits,
* your onActivityResult() method will be called.
*
@@ -1130,61 +917,6 @@ public class DroidGap extends Activity implements CordovaInterface {
}
/**
- * Load Cordova configuration from res/xml/cordova.xml.
- * Approved list of URLs that can be loaded into DroidGap
- * <access origin="http://server regexp" subdomains="true" />
- * Log level: ERROR, WARN, INFO, DEBUG, VERBOSE (default=ERROR)
- * <log level="DEBUG" />
- */
-// private void loadConfiguration() {
-// int id = getResources().getIdentifier("cordova", "xml", getPackageName());
-// if (id == 0) {
-// LOG.i("CordovaLog", "cordova.xml missing. Ignoring...");
-// return;
-// }
-// XmlResourceParser xml = getResources().getXml(id);
-// int eventType = -1;
-// while (eventType != XmlResourceParser.END_DOCUMENT) {
-// if (eventType == XmlResourceParser.START_TAG) {
-// String strNode = xml.getName();
-// if (strNode.equals("access")) {
-// String origin = xml.getAttributeValue(null, "origin");
-// String subdomains = xml.getAttributeValue(null, "subdomains");
-// if (origin != null) {
-// appView.addWhiteListEntry(origin, (subdomains != null) && (subdomains.compareToIgnoreCase("true") == 0));
-// }
-// }
-// else if (strNode.equals("log")) {
-// String level = xml.getAttributeValue(null, "level");
-// LOG.i("CordovaLog", "Found log level %s", level);
-// if (level != null) {
-// LOG.setLogLevel(level);
-// }
-// }
-// else if (strNode.equals("preference")) {
-// String name = xml.getAttributeValue(null, "name");
-// String value = xml.getAttributeValue(null, "value");
-// String readonlyString = xml.getAttributeValue(null, "readonly");
-//
-// boolean readonly = (readonlyString != null &&
-// readonlyString.equals("true"));
-//
-// LOG.i("CordovaLog", "Found preference for %s", name);
-//
-// preferences.add(new PreferenceNode(name, value, readonly));
-// }
-// }
-// try {
-// eventType = xml.next();
-// } catch (XmlPullParserException e) {
-// e.printStackTrace();
-// } catch (IOException e) {
-// e.printStackTrace();
-// }
-// }
-// }
-
- /**
* Determine if URL is in approved list of URLs to load.
*
* @param url
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/3829df66/framework/src/org/apache/cordova/FileTransfer.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/FileTransfer.java b/framework/src/org/apache/cordova/FileTransfer.java
index c3456e0..e006230 100644
--- a/framework/src/org/apache/cordova/FileTransfer.java
+++ b/framework/src/org/apache/cordova/FileTransfer.java
@@ -217,6 +217,7 @@ public class FileTransfer extends Plugin {
* @param params key:value pairs of user-defined parameters
* @return FileUploadResult containing result of upload request
*/
+ @SuppressWarnings("deprecation")
public FileUploadResult upload(String file, String server, final String fileKey, final String fileName,
final String mimeType, JSONObject params, boolean trustEveryone, boolean chunkedMode) throws IOException, SSLException {
// Create return object
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/3829df66/framework/src/org/apache/cordova/FileUtils.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/FileUtils.java b/framework/src/org/apache/cordova/FileUtils.java
index 5a73c80..df6b37f 100755
--- a/framework/src/org/apache/cordova/FileUtils.java
+++ b/framework/src/org/apache/cordova/FileUtils.java
@@ -52,6 +52,7 @@ import android.webkit.MimeTypeMap;
* Only files on the SD card can be accessed.
*/
public class FileUtils extends Plugin {
+ @SuppressWarnings("unused")
private static final String LOG_TAG = "FileUtils";
private static final String _DATA = "_data"; // The column name where the file path is stored
@@ -222,7 +223,7 @@ public class FileUtils extends Plugin {
* @param filePath the path to check
*/
private void notifyDelete(String filePath) {
- int result = this.ctx.getActivity().getContentResolver().delete(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
+ this.ctx.getActivity().getContentResolver().delete(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
MediaStore.Images.Media.DATA + " = ?",
new String[] { filePath });
}
@@ -237,6 +238,7 @@ public class FileUtils extends Plugin {
* @throws IOException if the user can't read the file
* @throws JSONException
*/
+ @SuppressWarnings("deprecation")
private JSONObject resolveLocalFileSystemURI(String url) throws IOException, JSONException {
String decoded = URLDecoder.decode(url, "UTF-8");
@@ -1039,6 +1041,7 @@ public class FileUtils extends Plugin {
* @param ctx) the current applicaiton context
* @return the full path to the file
*/
+ @SuppressWarnings("deprecation")
protected static String getRealPathFromURI(Uri contentUri, CordovaInterface ctx) {
String[] proj = { _DATA };
Cursor cursor = ctx.getActivity().managedQuery(contentUri, proj, null, null, null);
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/3829df66/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 4799e31..b005e5d 100755
--- a/framework/src/org/apache/cordova/HttpHandler.java
+++ b/framework/src/org/apache/cordova/HttpHandler.java
@@ -70,7 +70,7 @@ public class HttpHandler {
* writes a HTTP entity to the specified filename and location on disk
*/
{
- int i = 0;
+ //int i = 0;
String FilePath = "/sdcard/" + file;
InputStream in = entity.getContent();
byte buff[] = new byte[1024];
@@ -81,7 +81,7 @@ public class HttpHandler {
if (numread <= 0)
break;
out.write(buff, 0, numread);
- i++;
+ //i++;
} while (true);
out.flush();
out.close();
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/3829df66/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 5d56039..c4a1925 100755
--- a/framework/src/org/apache/cordova/api/CordovaInterface.java
+++ b/framework/src/org/apache/cordova/api/CordovaInterface.java
@@ -18,22 +18,8 @@
*/
package org.apache.cordova.api;
-//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.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;
/**
* The Cordova activity abstract class that is extended by DroidGap.
@@ -72,17 +58,6 @@ public interface CordovaInterface {
*/
public abstract boolean isBackButtonBound();
- /*
- * 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);
-
/**
* Get the Android activity.
*
@@ -90,114 +65,9 @@ public interface CordovaInterface {
*/
public abstract Activity getActivity();
- /**
- * @deprecated
- * Add services to res/xml/plugins.xml instead.
- *
- * Add a class that implements a service.
- *
- * @param serviceType
- * @param 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
- * Launch an activity for which you would not like a result when it finished.
- *
- * @param intent The intent to start
- */
-// @Deprecated
-// abstract public void startActivity(Intent intent);
-
- /**
- * @deprecated
- * Load the specified URL in the Cordova webview.
- *
- * @param url The URL to load.
- */
-// @Deprecated
-// abstract public void loadUrl(String url);
-
- /**
- * @deprecated
- * Send a message to all plugins.
- *
- * @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
-// public abstract String getPackageName();
-
-// @Deprecated
-// public abstract Object getSystemService(String service);
-
-// @Deprecated
-// public abstract Context getContext();
-
-// @Deprecated
-// public abstract Context getBaseContext();
-
-// @Deprecated
-// public abstract Intent registerReceiver(BroadcastReceiver receiver,
-// IntentFilter intentFilter);
-
-// @Deprecated
-// public abstract ContentResolver getContentResolver();
-
-// @Deprecated
-// public abstract void unregisterReceiver(BroadcastReceiver receiver);
-
-// @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 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 Context getApplicationContext();
-
-// @Deprecated
-// public abstract boolean isUrlWhiteListed(String source);
-
/**
* Called when a message is sent to plugin.
*
@@ -206,14 +76,4 @@ public interface CordovaInterface {
*/
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);
-
}
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/3829df66/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 82d9bb7..173a304 100755
--- a/framework/src/org/apache/cordova/api/IPlugin.java
+++ b/framework/src/org/apache/cordova/api/IPlugin.java
@@ -24,8 +24,6 @@ import org.json.JSONArray;
//import android.content.Context;
import android.content.Intent;
-//import android.webkit.WebView;
-
/**
* Plugin interface must be implemented by any plugin classes.
*
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/3829df66/framework/src/org/apache/cordova/api/Plugin.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/api/Plugin.java b/framework/src/org/apache/cordova/api/Plugin.java
index f7c1865..2e6d462 100755
--- a/framework/src/org/apache/cordova/api/Plugin.java
+++ b/framework/src/org/apache/cordova/api/Plugin.java
@@ -21,12 +21,8 @@ package org.apache.cordova.api;
import org.apache.cordova.CordovaWebView;
import org.json.JSONArray;
import org.json.JSONObject;
-
-//import android.content.Context;
import android.content.Intent;
-//import android.webkit.WebView;
-
/**
* Plugin interface must be implemented by any plugin classes.
*
@@ -36,7 +32,7 @@ public abstract class Plugin implements IPlugin {
public String id;
public CordovaWebView webView; // WebView object
- public CordovaInterface ctx; // CordovaActivity object
+ public CordovaInterface ctx; // CordovaActivity object
/**
* Executes the request and returns PluginResult.
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/3829df66/framework/src/org/apache/cordova/api/PluginManager.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/api/PluginManager.java b/framework/src/org/apache/cordova/api/PluginManager.java
index c931477..fa40e07 100755
--- a/framework/src/org/apache/cordova/api/PluginManager.java
+++ b/framework/src/org/apache/cordova/api/PluginManager.java
@@ -65,20 +65,6 @@ public class PluginManager {
this.firstRun = true;
}
- // Called by com.phonegap.api.PluginManager only
-// public PluginManager(WebView mApp, CordovaInterface mCtx) throws Exception {
-// this.ctx = mCtx; //mCtx.getContext();
-// if (CordovaWebView.class.isInstance(mApp))
-// {
-// this.app = (CordovaWebView) mApp;
-// }
-// else
-// {
-// //Throw an exception here
-// throw new Exception();
-// }
-// }
-
/**
* Init when loading a new HTML page into webview.
*/