Updated Branches: refs/heads/CordovaWebView c37b2d236 -> 8b93e87e3
Merge commit with master, we need to kill all tabs 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/8b93e87e Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/tree/8b93e87e Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/diff/8b93e87e Branch: refs/heads/CordovaWebView Commit: 8b93e87e3e2533c123b0b55c7ccef29f4d23bec2 Parents: c37b2d2 ccd4365 Author: Joe Bowser <bows...@apache.org> Authored: Mon May 28 13:45:25 2012 -0700 Committer: Joe Bowser <bows...@apache.org> Committed: Mon May 28 13:45:25 2012 -0700 ---------------------------------------------------------------------- VERSION | 2 +- .../templates/project/assets/www/index.html | 2 +- framework/assets/js/cordova.android.js | 76 ++++++++++++++- framework/assets/www/index.html | 2 +- .../src/org/apache/cordova/CameraLauncher.java | 6 +- framework/src/org/apache/cordova/Device.java | 2 +- framework/src/org/apache/cordova/Storage.java | 15 ++-- 7 files changed, 88 insertions(+), 17 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/8b93e87e/framework/assets/js/cordova.android.js ---------------------------------------------------------------------- diff --cc framework/assets/js/cordova.android.js index dc716fd,0988151..acf6472 --- a/framework/assets/js/cordova.android.js +++ b/framework/assets/js/cordova.android.js @@@ -5661,4 -5729,4 +5729,4 @@@ window.cordova = require('cordova') }(window)); --})(); ++})(); http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/8b93e87e/framework/src/org/apache/cordova/CameraLauncher.java ---------------------------------------------------------------------- diff --cc framework/src/org/apache/cordova/CameraLauncher.java index 94d7e9c,e6fe153..d1156e0 --- a/framework/src/org/apache/cordova/CameraLauncher.java +++ b/framework/src/org/apache/cordova/CameraLauncher.java @@@ -274,10 -255,12 +274,12 @@@ public class CameraLauncher extends Plu newWidth = (newHeight * origWidth) / origHeight; } } - - return Bitmap.createScaledBitmap(bitmap, newWidth, newHeight, true); + + Bitmap retval = Bitmap.createScaledBitmap(bitmap, newWidth, newHeight, true); + bitmap.recycle(); + return retval; } - + /** * Called when the camera view exits. * http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/8b93e87e/framework/src/org/apache/cordova/Device.java ---------------------------------------------------------------------- diff --cc framework/src/org/apache/cordova/Device.java index 2d67b95,a843356..33d3595 --- a/framework/src/org/apache/cordova/Device.java +++ b/framework/src/org/apache/cordova/Device.java @@@ -38,10 -38,10 +38,10 @@@ import android.telephony.TelephonyManag public class Device extends Plugin { public static final String TAG = "Device"; - public static String cordovaVersion = "1.7.0"; // Cordova version + public static String cordovaVersion = "1.8.0rc1"; // Cordova version public static String platform = "Android"; // Device OS public static String uuid; // Device UUID - + BroadcastReceiver telephonyReceiver = null; /** http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/8b93e87e/framework/src/org/apache/cordova/Storage.java ---------------------------------------------------------------------- diff --cc framework/src/org/apache/cordova/Storage.java index f57621b,8cc29b7..59041cf --- a/framework/src/org/apache/cordova/Storage.java +++ b/framework/src/org/apache/cordova/Storage.java @@@ -37,202 -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.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 + ");"); - } + // Data Definition Language + private static final String ALTER = "alter"; + private static final String CREATE = "create"; + private static final String DROP = "drop"; + private static final String TRUNCATE = "truncate"; - ++ + SQLiteDatabase myDb = null; // Database object + String path = null; // Database path + String dbName = null; // Database name + + /** + * Constructor. + */ + public Storage() { + } + + /** + * Executes the request and returns PluginResult. + * + * @param action + * The action to execute. + * @param args + * JSONArry of arguments for the plugin. + * @param callbackId + * The callback id used when calling back into JavaScript. + * @return A PluginResult object with a status and message. + */ + public PluginResult execute(String action, JSONArray args, String callbackId) { + PluginResult.Status status = PluginResult.Status.OK; + String result = ""; + + try { + if (action.equals("openDatabase")) { + this.openDatabase(args.getString(0), args.getString(1), + args.getString(2), args.getLong(3)); + } else if (action.equals("executeSql")) { + String[] s = null; + if (args.isNull(1)) { + s = new String[0]; + } else { + JSONArray a = args.getJSONArray(1); + int len = a.length(); + s = new String[len]; + for (int i = 0; i < len; i++) { + s[i] = a.getString(i); + } + } + this.executeSql(args.getString(0), s, args.getString(2)); + } + return new PluginResult(status, result); + } catch (JSONException e) { + return new PluginResult(PluginResult.Status.JSON_EXCEPTION); + } + } + + /** + * Identifies if action to be executed returns a value and should be run + * synchronously. + * + * @param action + * The action to execute + * @return T=returns value + */ + public boolean isSynch(String action) { + return true; + } + + /** + * Clean up and close database. + */ + @Override + public void onDestroy() { + if (this.myDb != null) { + this.myDb.close(); + this.myDb = null; + } + } + + // -------------------------------------------------------------------------- + // LOCAL METHODS + // -------------------------------------------------------------------------- + + /** + * Open database. + * + * @param db + * The name of the database + * @param version + * The version + * @param display_name + * The display name + * @param size + * The size in bytes + */ + public void openDatabase(String db, String version, String display_name, + long size) { + + // If database is open, then close it + if (this.myDb != null) { + this.myDb.close(); + } + + // If no database path, generate from application package + if (this.path == null) { - this.path = this.ctx.getActivity().getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath(); ++ this.path = this.ctx.getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath(); + } + + this.dbName = this.path + File.pathSeparator + db + ".db"; + this.myDb = SQLiteDatabase.openOrCreateDatabase(this.dbName, null); + } + + /** + * Execute SQL statement. + * + * @param query + * The SQL query + * @param params + * Parameters for the query + * @param tx_id + * Transaction id + */ + public void executeSql(String query, String[] params, String tx_id) { + try { + if (isDDL(query)) { + this.myDb.execSQL(query); + this.sendJavascript("cordova.require('cordova/plugin/android/storage').completeQuery('" + tx_id + "', '');"); - } ++ } + else { + Cursor myCursor = this.myDb.rawQuery(query, params); + this.processResults(myCursor, tx_id); + myCursor.close(); + } - } catch (SQLiteException ex) { ++ } ++ catch (SQLiteException ex) { + ex.printStackTrace(); - System.out.println("Storage.executeSql(): Error=" + ex.getMessage()); - ++ System.out.println("Storage.executeSql(): Error=" + ex.getMessage()); ++ + // Send error message back to JavaScript - this.sendJavascript("cordova.require('cordova/plugin/android/storage').fail('" + ex.getMessage() + "','" + tx_id + "');"); ++ 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 + ");"); + } }