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/06 23:36:05 UTC

[3/10] Massive Merge Commit of DEATH TO SPACES

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/81195db8/framework/src/org/apache/cordova/CordovaChromeClient.java
----------------------------------------------------------------------
diff --cc framework/src/org/apache/cordova/CordovaChromeClient.java
index 691c276,1125e62..04cda62
--- a/framework/src/org/apache/cordova/CordovaChromeClient.java
+++ b/framework/src/org/apache/cordova/CordovaChromeClient.java
@@@ -50,31 -48,11 +50,31 @@@ public class CordovaChromeClient extend
  
      /**
       * Constructor.
-      * 
+      *
       * @param ctx
       */
 -    public CordovaChromeClient(Context ctx) {
 -        this.ctx = (DroidGap) ctx;
 +    public CordovaChromeClient(CordovaInterface ctx) {
 +        this.ctx = ctx;
 +    }
 +
 +    /**
 +     * Constructor.
 +     * 
 +     * @param ctx
 +     * @param app
 +     */
 +    public CordovaChromeClient(CordovaInterface ctx, CordovaWebView app) {
 +        this.ctx = ctx;
 +        this.appView = app;
 +    }
 +
 +    /**
 +     * Constructor.
 +     * 
 +     * @param view
 +     */
 +    public void setWebView(CordovaWebView view) {
 +        this.appView = view;
      }
  
      /**

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/81195db8/framework/src/org/apache/cordova/CordovaWebViewClient.java
----------------------------------------------------------------------
diff --cc framework/src/org/apache/cordova/CordovaWebViewClient.java
index bda0330,e2bd344..3cda1b1
--- a/framework/src/org/apache/cordova/CordovaWebViewClient.java
+++ b/framework/src/org/apache/cordova/CordovaWebViewClient.java
@@@ -44,40 -39,16 +44,40 @@@ import android.webkit.WebViewClient
  public class CordovaWebViewClient extends WebViewClient {
  
      private static final String TAG = "Cordova";
 -    DroidGap ctx;
 +    CordovaInterface ctx;
 +    CordovaWebView appView;
      private boolean doClearHistory = false;
  
 +    /** The authorization tokens. */
 +    private Hashtable<String, AuthenticationToken> authenticationTokens = new Hashtable<String, AuthenticationToken>();
 +
      /**
       * Constructor.
-      * 
+      *
       * @param ctx
       */
 -    public CordovaWebViewClient(DroidGap ctx) {
 +    public CordovaWebViewClient(CordovaInterface ctx) {
 +        this.ctx = ctx;
 +    }
 +
 +    /**
 +     * Constructor.
 +     * 
 +     * @param ctx
 +     * @param view
 +     */
 +    public CordovaWebViewClient(CordovaInterface ctx, CordovaWebView view) {
          this.ctx = ctx;
 +        this.appView = view;
 +    }
 +
 +    /**
 +     * Constructor.
 +     * 
 +     * @param view
 +     */
 +    public void setWebView(CordovaWebView view) {
 +        this.appView = view;
      }
  
      /**
@@@ -189,52 -156,36 +189,52 @@@
  
      /**
       * On received http auth request.
-      * The method reacts on all registered authentication tokens. There is one and only one authentication token for any host + realm combination 
-      * 
+      * The method reacts on all registered authentication tokens. There is one and only one authentication token for any host + realm combination
+      *
       * @param view
 -     *            the view
       * @param handler
 -     *            the handler
       * @param host
 -     *            the host
       * @param realm
 -     *            the realm
       */
      @Override
 -    public void onReceivedHttpAuthRequest(WebView view, HttpAuthHandler handler, String host,
 -            String realm) {
 -
 -        // get the authentication token
 -        AuthenticationToken token = ctx.getAuthenticationToken(host,realm);
 +    public void onReceivedHttpAuthRequest(WebView view, HttpAuthHandler handler, String host, String realm) {
  
 -        if(token != null) {
 +        // Get the authentication token
 +        AuthenticationToken token = this.getAuthenticationToken(host, realm);
 +        if (token != null) {
              handler.proceed(token.getUserName(), token.getPassword());
          }
      }
  
 -
 +    /**
 +     * Notify the host application that a page has started loading. 
 +     * This method is called once for each main frame load so a page with iframes or framesets will call onPageStarted 
 +     * one time for the main frame. This also means that onPageStarted will not be called when the contents of an 
 +     * embedded frame changes, i.e. clicking a link whose target is an iframe. 
 +     * 
 +     * @param view          The webview initiating the callback.
 +     * @param url           The url of the page.
 +     */
      @Override
      public void onPageStarted(WebView view, String url, Bitmap favicon) {
-         // Clear history so history.back() doesn't do anything.  
+         // Clear history so history.back() doesn't do anything.
          // So we can reinit() native side CallbackServer & PluginManager.
 -        view.clearHistory();
 -        this.doClearHistory = true;
 +        if (!this.appView.useBrowserHistory) {
 +            view.clearHistory();
 +            this.doClearHistory = true;
 +        }
 +
 +        // Create callback server and plugin manager
 +        if (this.appView.callbackServer == null) {
 +            this.appView.callbackServer = new CallbackServer();
 +            this.appView.callbackServer.init(url);
 +        }
 +        else {
 +            this.appView.callbackServer.reinit(url);
 +        }
 +
 +        // Broadcast message that page has loaded
 +        this.appView.postMessage("onPageStarted", url);
      }
  
      /**
@@@ -247,11 -197,10 +247,11 @@@
      @Override
      public void onPageFinished(WebView view, String url) {
          super.onPageFinished(view, url);
 +        LOG.d(TAG, "onPageFinished(" + url + ")");
  
          /**
-          * Because of a timing issue we need to clear this history in onPageFinished as well as 
-          * onPageStarted. However we only want to do this if the doClearHistory boolean is set to 
+          * Because of a timing issue we need to clear this history in onPageFinished as well as
+          * onPageStarted. However we only want to do this if the doClearHistory boolean is set to
           * true. You see when you load a url with a # in it which is common in jQuery applications
           * onPageStared is not called. Clearing the history at that point would break jQuery apps.
           */
@@@ -361,16 -296,9 +361,16 @@@
          }
      }
  
 +    /**
 +     * Notify the host application to update its visited links database.
 +     * 
 +     * @param view          The WebView that is initiating the callback.
 +     * @param url           The url being visited.
 +     * @param isReload      True if this url is being reloaded.
 +     */
      @Override
      public void doUpdateVisitedHistory(WebView view, String url, boolean isReload) {
-         /* 
+         /*
           * If you do a document.location.href the url does not get pushed on the stack
           * so we do a check here to see if the url should be pushed.
           */

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/81195db8/framework/src/org/apache/cordova/Device.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/81195db8/framework/src/org/apache/cordova/DirectoryManager.java
----------------------------------------------------------------------
diff --cc framework/src/org/apache/cordova/DirectoryManager.java
index c888d42,4696d00..292f402
--- a/framework/src/org/apache/cordova/DirectoryManager.java
+++ b/framework/src/org/apache/cordova/DirectoryManager.java
@@@ -37,7 -36,7 +37,6 @@@ public class DirectoryManager 
  
      /**
       * Determine if a file or directory exists.
-      * 
 -     *
       * @param name				The name of the file to check.
       * @return					T=exists, F=not found
       */

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/81195db8/framework/src/org/apache/cordova/DroidGap.java
----------------------------------------------------------------------
diff --cc framework/src/org/apache/cordova/DroidGap.java
index d00d5b5,ddd50a6..7c452e7
--- a/framework/src/org/apache/cordova/DroidGap.java
+++ b/framework/src/org/apache/cordova/DroidGap.java
@@@ -171,8 -202,10 +171,11 @@@ public class DroidGap extends Activity 
      // Draw a splash screen using an image located in the drawable resource directory.
      // This is not the same as calling super.loadSplashscreen(url)
      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.
@@@ -193,10 -239,11 +196,10 @@@
  
      /**
       * Removes the authentication token.
-      * 
+      *
       * @param host
 -     *            the host
       * @param realm
 -     *            the realm
 +     * 
       * @return the authentication token or null if did not exist
       */
      public AuthenticationToken removeAuthenticationToken(String host, String realm) {
@@@ -214,10 -258,11 +217,10 @@@
       * 2- host
       * 3- realm
       * 4- no host, no realm
-      * 
+      *
       * @param host
 -     *            the host
       * @param realm
 -     *            the realm
 +     * 
       * @return the authentication token
       */
      public AuthenticationToken getAuthenticationToken(String host, String realm) {
@@@ -665,10 -881,9 +668,10 @@@
  
      @Override
      /**
-      * The final call you receive before your activity is destroyed. 
+      * The final call you receive before your activity is destroyed.
       */
      public void onDestroy() {
 +        LOG.d(TAG, "onDestroy()");
          super.onDestroy();
  
          if (this.appView != null) {
@@@ -723,9 -942,66 +726,8 @@@
       * @param message
       */
      public void sendJavascript(String statement) {
-         //We need to check for the null case on the Kindle Fire because it changes the width and height on load
 -        //We need to check for the null case on the Kindle Fire beacuse it changes the width and height on load
 -        if(this.callbackServer != null)
 -          this.callbackServer.sendJavascript(statement);
 -    }
 -
 -    /**
 -     * Load the specified URL in the Cordova webview or a new browser instance.
 -     *
 -     * NOTE: If openExternal is false, only URLs listed in whitelist can be loaded.
 -     *
 -     * @param url           The url to load.
 -     * @param openExternal  Load url in browser instead of Cordova webview.
 -     * @param clearHistory  Clear the history stack, so new page becomes top of history
 -     * @param params        DroidGap parameters for new app
 -     */
 -    public void showWebPage(String url, boolean openExternal, boolean clearHistory, HashMap<String, Object> params) { //throws android.content.ActivityNotFoundException {
 -        LOG.d(TAG, "showWebPage(%s, %b, %b, HashMap", url, openExternal, clearHistory);
 -
 -        // If clearing history
 -        if (clearHistory) {
 -            this.clearHistory();
 -        }
 -
 -        // If loading into our webview
 -        if (!openExternal) {
 -
 -            // Make sure url is in whitelist
 -            if (url.startsWith("file://") || url.indexOf(this.baseUrl) == 0 || isUrlWhiteListed(url)) {
 -                // TODO: What about params?
 -
 -                // Clear out current url from history, since it will be replacing it
 -                if (clearHistory) {
 -                    this.urls.clear();
 -                }
 -
 -                // Load new URL
 -                this.loadUrl(url);
 -            }
 -            // Load in default viewer if not
 -            else {
 -                LOG.w(TAG, "showWebPage: Cannot load URL into webview since it is not in white list.  Loading into browser instead. (URL="+url+")");
 -                try {
 -                    Intent intent = new Intent(Intent.ACTION_VIEW);
 -                    intent.setData(Uri.parse(url));
 -                    this.startActivity(intent);
 -                } catch (android.content.ActivityNotFoundException e) {
 -                    LOG.e(TAG, "Error loading url "+url, e);
 -                }
 -            }
 -        }
 -
 -        // Load in default view intent
 -        else {
 -            try {
 -                Intent intent = new Intent(Intent.ACTION_VIEW);
 -                intent.setData(Uri.parse(url));
 -                this.startActivity(intent);
 -            } catch (android.content.ActivityNotFoundException e) {
 -                LOG.e(TAG, "Error loading url "+url, e);
 -            }
 +        if (this.appView != null && this.appView.callbackServer != null) {
 +            this.appView.callbackServer.sendJavascript(statement);
          }
      }
  
@@@ -815,9 -1091,26 +817,9 @@@
      }
  
      /**
 -     * 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,
 +     * Launch an activity for which you would like a result when it finished. When this activity exits, 
       * your onActivityResult() method will be called.
-      *  
+      *
       * @param command           The command object
       * @param intent            The intent to start
       * @param requestCode       The request code that is passed to callback to identify the activity
@@@ -835,12 -1128,12 +837,12 @@@
          super.startActivityForResult(intent, requestCode);
      }
  
 -     @Override
 +    @Override
      /**
       * Called when an activity you launched exits, giving you the requestCode you started it with,
-      * the resultCode it returned, and any additional data from it. 
-      * 
-      * @param requestCode       The request code originally supplied to startActivityForResult(), 
+      * the resultCode it returned, and any additional data from it.
+      *
+      * @param requestCode       The request code originally supplied to startActivityForResult(),
       *                          allowing you to identify who this result came from.
       * @param resultCode        The integer result code returned by the child activity through its setResult().
       * @param data              An Intent, which can return result data to the caller (various data can be attached to Intent "extras").
@@@ -946,10 -1340,35 +948,10 @@@
          return false;
      }
  
 -    /*
 -     * URL stack manipulators
 -     */
 -
 -    /**
 -     * Returns the top url on the stack without removing it from
 -     * the stack.
 -     */
 -    public String peekAtUrlStack() {
 -        if (urls.size() > 0) {
 -            return urls.peek();
 -        }
 -        return "";
 -    }
 -
 -    /**
 -     * Add a url to the stack
 -     *
 -     * @param url
 -     */
 -    public void pushUrl(String url) {
 -        urls.push(url);
 -    }
 -
 -    /*
 +    /* 
       * Hook in DroidGap for menu plugins
-      * 
+      *
       */
 -
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          this.postMessage("onCreateOptionsMenu", menu);

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/81195db8/framework/src/org/apache/cordova/FileTransfer.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/81195db8/framework/src/org/apache/cordova/FileUtils.java
----------------------------------------------------------------------
diff --cc framework/src/org/apache/cordova/FileUtils.java
index 9b4eda6,4d2b31e..825fabe
--- a/framework/src/org/apache/cordova/FileUtils.java
+++ b/framework/src/org/apache/cordova/FileUtils.java
@@@ -42,10 -41,8 +42,9 @@@ import android.database.Cursor
  import android.net.Uri;
  import android.os.Environment;
  import android.provider.MediaStore;
- //import android.util.Log;
  import android.webkit.MimeTypeMap;
  
 +//import android.app.Activity;
  
  /**
   * This class provides SD card file and directory services to JavaScript.

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/81195db8/framework/src/org/apache/cordova/GeoBroker.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/81195db8/framework/src/org/apache/cordova/HttpHandler.java
----------------------------------------------------------------------
diff --cc framework/src/org/apache/cordova/HttpHandler.java
index b005e5d,3ced2de..1de8302
--- a/framework/src/org/apache/cordova/HttpHandler.java
+++ b/framework/src/org/apache/cordova/HttpHandler.java
@@@ -70,13 -61,13 +67,13 @@@ public class HttpHandler 
       * writes a HTTP entity to the specified filename and location on disk
       */
      {
 -        int i=0;
 -        String FilePath="/sdcard/" + file;
 +        //int i = 0;
 +        String FilePath = "/sdcard/" + file;
          InputStream in = entity.getContent();
          byte buff[] = new byte[1024];
 -        FileOutputStream out=
 -            new FileOutputStream(FilePath);
 -        do {
 +        FileOutputStream out =
 +                new FileOutputStream(FilePath);
-         do {
++       do {
              int numread = in.read(buff);
              if (numread <= 0)
                  break;

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/81195db8/framework/src/org/apache/cordova/LinearLayoutSoftKeyboardDetect.java
----------------------------------------------------------------------
diff --cc framework/src/org/apache/cordova/LinearLayoutSoftKeyboardDetect.java
index de70020,c6d9353..280269b
--- a/framework/src/org/apache/cordova/LinearLayoutSoftKeyboardDetect.java
+++ b/framework/src/org/apache/cordova/LinearLayoutSoftKeyboardDetect.java
@@@ -84,17 -82,17 +84,17 @@@ public class LinearLayoutSoftKeyboardDe
              screenWidth = tmp_var;
              LOG.v(TAG, "Orientation Change");
          }
-         // If the height as gotten bigger then we will assume the soft keyboard has 
+         // 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
 +        // 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/81195db8/framework/src/org/apache/cordova/NetworkManager.java
----------------------------------------------------------------------
diff --cc framework/src/org/apache/cordova/NetworkManager.java
index 36fbbb3,8b50869..4661ddb
--- a/framework/src/org/apache/cordova/NetworkManager.java
+++ b/framework/src/org/apache/cordova/NetworkManager.java
@@@ -157,9 -157,10 +157,9 @@@ public class NetworkManager extends Plu
      // LOCAL METHODS
      //--------------------------------------------------------------------------
  
 -
      /**
       * Updates the JavaScript side whenever the connection changes
-      * 
+      *
       * @param info the current active network info
       * @return
       */

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/81195db8/framework/src/org/apache/cordova/Storage.java
----------------------------------------------------------------------
diff --cc framework/src/org/apache/cordova/Storage.java
index 40521f6,18fbcaf..ef87b45
--- a/framework/src/org/apache/cordova/Storage.java
+++ b/framework/src/org/apache/cordova/Storage.java
@@@ -37,203 -37,203 +37,203 @@@ 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.getActivity().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').failQuery('" + 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.getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath();
++            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').failQuery('" + 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/81195db8/framework/src/org/apache/cordova/TempListener.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/81195db8/framework/src/org/apache/cordova/api/IPlugin.java
----------------------------------------------------------------------
diff --cc framework/src/org/apache/cordova/api/IPlugin.java
index e410ac9,c23cc3a..870bb9e
--- a/framework/src/org/apache/cordova/api/IPlugin.java
+++ b/framework/src/org/apache/cordova/api/IPlugin.java
@@@ -58,16 -56,16 +58,16 @@@ public interface IPlugin 
      void setContext(CordovaInterface ctx);
  
      /**
 -     * Sets the main View of the application, this is the WebView within which
 +     * Sets the main View of the application, this is the WebView within which 
       * a Cordova app runs.
 -     *
 +     * 
       * @param webView The Cordova WebView
       */
 -    void setView(WebView webView);
 +    void setView(CordovaWebView webView);
  
      /**
-      * Called when the system is about to start resuming a previous activity. 
-      * 
+      * Called when the system is about to start resuming a previous activity.
+      *
       * @param multitasking		Flag indicating if multitasking is turned on for app
       */
      void onPause(boolean multitasking);
@@@ -90,13 -88,12 +90,13 @@@
      void onDestroy();
  
      /**
-      * Called when a message is sent to plugin. 
-      * 
+      * Called when a message is sent to plugin.
+      *
       * @param id            The message id
       * @param data          The message data
 +     * @return              Object to stop propagation or null
       */
 -    public void onMessage(String id, Object data);
 +    public Object onMessage(String id, Object data);
  
      /**
       * Called when an activity you launched exits, giving you the requestCode you started it with,

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/81195db8/framework/src/org/apache/cordova/api/Plugin.java
----------------------------------------------------------------------
diff --cc framework/src/org/apache/cordova/api/Plugin.java
index 871a964,05c880f..143655b
--- a/framework/src/org/apache/cordova/api/Plugin.java
+++ b/framework/src/org/apache/cordova/api/Plugin.java
@@@ -103,14 -104,12 +103,14 @@@ public abstract class Plugin implement
      }
  
      /**
-      * Called when a message is sent to plugin. 
-      * 
+      * Called when a message is sent to plugin.
+      *
       * @param id            The message id
       * @param data          The message data
 +     * @return              Object to stop propagation or null
       */
 -    public void onMessage(String id, Object data) {
 +    public Object onMessage(String id, Object data) {
 +        return null;
      }
  
      /**

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/81195db8/framework/src/org/apache/cordova/api/PluginEntry.java
----------------------------------------------------------------------
diff --cc framework/src/org/apache/cordova/api/PluginEntry.java
index 057c005,5cbba08..857d4dd
--- a/framework/src/org/apache/cordova/api/PluginEntry.java
+++ b/framework/src/org/apache/cordova/api/PluginEntry.java
@@@ -66,10 -63,11 +66,10 @@@ public class PluginEntry 
      /**
       * Create plugin object.
       * If plugin is already created, then just return it.
-      * 
+      *
       * @return                      The plugin object
       */
 -    @SuppressWarnings("unchecked")
 -    public IPlugin createPlugin(WebView webView, CordovaInterface ctx) {
 +    public IPlugin createPlugin(CordovaWebView webView, CordovaInterface ctx) {
          if (this.plugin != null) {
              return this.plugin;
          }

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/81195db8/framework/src/org/apache/cordova/api/PluginManager.java
----------------------------------------------------------------------
diff --cc framework/src/org/apache/cordova/api/PluginManager.java
index 1714eb8,486ff29..b9df52d
--- a/framework/src/org/apache/cordova/api/PluginManager.java
+++ b/framework/src/org/apache/cordova/api/PluginManager.java
@@@ -162,11 -162,12 +162,11 @@@ public class PluginManager 
       * @param args          An Array literal string containing any arguments needed in the
       *                      plugin execute method.
       * @param async         Boolean indicating whether the calling JavaScript code is expecting an
-      *                      immediate return value. If true, either Cordova.callbackSuccess(...) or 
+      *                      immediate return value. If true, either Cordova.callbackSuccess(...) or
       *                      Cordova.callbackError(...) is called once the plugin code has executed.
-      * 
+      *
       * @return              JSON encoded string with a response message and status.
       */
 -    @SuppressWarnings("unchecked")
      public String exec(final String service, final String action, final String callbackId, final String jsonArgs, final boolean async) {
          PluginResult cr = null;
          boolean runAsync = async;
@@@ -311,25 -312,16 +311,25 @@@
  
      /**
       * Send a message to all plugins.
-      * 
+      *
       * @param id                The message id
       * @param data              The message data
 +     * @return
       */
 -    public void postMessage(String id, Object data) {
 +    public Object postMessage(String id, Object data) {
 +        Object obj = this.ctx.onMessage(id, data);
 +        if (obj != null) {
 +            return obj;
 +        }
          for (PluginEntry entry : this.entries.values()) {
              if (entry.plugin != null) {
 -                entry.plugin.onMessage(id, data);
 +                obj = entry.plugin.onMessage(id, data);
 +                if (obj != null) {
 +                    return obj;
 +                }
              }
          }
 +        return null;
      }
  
      /**

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/81195db8/framework/src/org/apache/cordova/api/PluginResult.java
----------------------------------------------------------------------
diff --cc framework/src/org/apache/cordova/api/PluginResult.java
index 4d05ddd,8c1b775..9ec24d9
--- a/framework/src/org/apache/cordova/api/PluginResult.java
+++ b/framework/src/org/apache/cordova/api/PluginResult.java
@@@ -27,7 -25,7 +25,8 @@@ public class PluginResult 
      private final int status;
      private final String message;
      private boolean keepCallback = false;
 +    
+ 
      public PluginResult(Status status) {
          this.status = status.ordinal();
          this.message = "'" + PluginResult.StatusMessages[this.status] + "'";