From 95fa0f4461dd955dff72a6dbc847b2d52fb9a58a Mon Sep 17 00:00:00 2001 From: macdonst Date: Fri, 18 May 2012 15:22:05 -0400 Subject: [PATCH 1/3] CB-808: CameraLauncher leaks bitmaps in Android --- framework/src/org/apache/cordova/CameraLauncher.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/framework/src/org/apache/cordova/CameraLauncher.java b/framework/src/org/apache/cordova/CameraLauncher.java index ba5d9243..e6fe1531 100755 --- a/framework/src/org/apache/cordova/CameraLauncher.java +++ b/framework/src/org/apache/cordova/CameraLauncher.java @@ -256,7 +256,9 @@ public class CameraLauncher extends Plugin { } } - return Bitmap.createScaledBitmap(bitmap, newWidth, newHeight, true); + Bitmap retval = Bitmap.createScaledBitmap(bitmap, newWidth, newHeight, true); + bitmap.recycle(); + return retval; } /** From d7b79f50423ca5cc4c18941958da5ffb39f44410 Mon Sep 17 00:00:00 2001 From: macdonst Date: Thu, 24 May 2012 21:39:45 -0400 Subject: [PATCH 2/3] Upping version to 1.8.0rc1 --- VERSION | 2 +- .../templates/project/assets/www/index.html | 2 +- framework/assets/js/cordova.android.js | 492 +++++++++++++++++- framework/assets/www/index.html | 2 +- framework/src/org/apache/cordova/Device.java | 2 +- 5 files changed, 489 insertions(+), 11 deletions(-) diff --git a/VERSION b/VERSION index bd8bf882..92f201f4 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.7.0 +1.8.0rc1 diff --git a/bin/templates/project/cordova/templates/project/assets/www/index.html b/bin/templates/project/cordova/templates/project/assets/www/index.html index 2bf3dda5..39368e0d 100644 --- a/bin/templates/project/cordova/templates/project/assets/www/index.html +++ b/bin/templates/project/cordova/templates/project/assets/www/index.html @@ -23,7 +23,7 @@ PhoneGap - + diff --git a/framework/assets/js/cordova.android.js b/framework/assets/js/cordova.android.js index cdf619df..09881515 100644 --- a/framework/assets/js/cordova.android.js +++ b/framework/assets/js/cordova.android.js @@ -1,6 +1,6 @@ -// commit 4a4ba9985c920850fe3f229abc60de984e196ab5 +// commit 95f199e1c207dc89b84e79a9a7b27d6a3cc8fe14 -// File generated at :: Fri May 18 2012 13:43:11 GMT-0700 (PDT) +// File generated at :: Thu May 24 2012 21:36:17 GMT-0400 (EDT) /* Licensed to the Apache Software Foundation (ASF) under one @@ -711,6 +711,9 @@ module.exports = { children: { exec: { path: 'cordova/exec' + }, + logger: { + path: 'cordova/plugin/logger' } } }, @@ -1170,7 +1173,7 @@ for (var key in Camera) { * Gets a picture from source defined by "options.sourceType", and returns the * image as defined by the "options.destinationType" option. - * The defaults are sourceType=CAMERA and destinationType=FILE_URL. + * The defaults are sourceType=CAMERA and destinationType=FILE_URI. * * @param {Function} successCallback * @param {Function} errorCallback @@ -2116,7 +2119,7 @@ Entry.prototype.toURL = function() { Entry.prototype.toURI = function(mimeType) { console.log("DEPRECATED: Update your code to use 'toURL'"); // fullPath attribute contains the full URI - return this.fullPath; + return this.toURL(); }; /** @@ -4530,6 +4533,177 @@ var exec = require('cordova/exec'), module.exports = compass; }); +// file: lib/common/plugin/console-via-logger.js +define("cordova/plugin/console-via-logger", function(require, exports, module) { +//------------------------------------------------------------------------------ + +var logger = require("cordova/plugin/logger"); +var utils = require("cordova/utils"); + +//------------------------------------------------------------------------------ +// object that we're exporting +//------------------------------------------------------------------------------ +var console = module.exports; + +//------------------------------------------------------------------------------ +// copy of the original console object +//------------------------------------------------------------------------------ +var WinConsole = window.console; + +//------------------------------------------------------------------------------ +// whether to use the logger +//------------------------------------------------------------------------------ +var UseLogger = false; + +//------------------------------------------------------------------------------ +// Timers +//------------------------------------------------------------------------------ +var Timers = {}; + +//------------------------------------------------------------------------------ +// used for unimplemented methods +//------------------------------------------------------------------------------ +function noop() {} + +//------------------------------------------------------------------------------ +// used for unimplemented methods +//------------------------------------------------------------------------------ +console.useLogger = function (value) { + if (arguments.length) UseLogger = !!value; + + if (UseLogger) { + if (logger.useConsole()) { + throw new Error("console and logger are too intertwingly"); + } + } + + return UseLogger; +}; + +//------------------------------------------------------------------------------ +console.log = function() { + if (logger.useConsole()) return; + logger.log.apply(logger, [].slice.call(arguments)); +}; + +//------------------------------------------------------------------------------ +console.error = function() { + if (logger.useConsole()) return; + logger.error.apply(logger, [].slice.call(arguments)); +}; + +//------------------------------------------------------------------------------ +console.warn = function() { + if (logger.useConsole()) return; + logger.warn.apply(logger, [].slice.call(arguments)); +}; + +//------------------------------------------------------------------------------ +console.info = function() { + if (logger.useConsole()) return; + logger.info.apply(logger, [].slice.call(arguments)); +}; + +//------------------------------------------------------------------------------ +console.debug = function() { + if (logger.useConsole()) return; + logger.debug.apply(logger, [].slice.call(arguments)); +}; + +//------------------------------------------------------------------------------ +console.assert = function(expression) { + if (expression) return; + + var message = utils.vformat(arguments[1], [].slice.call(arguments, 2)); + console.log("ASSERT: " + message); +}; + +//------------------------------------------------------------------------------ +console.clear = function() {}; + +//------------------------------------------------------------------------------ +console.dir = function(object) { + console.log("%o", object); +}; + +//------------------------------------------------------------------------------ +console.dirxml = function(node) { + console.log(node.innerHTML); +}; + +//------------------------------------------------------------------------------ +console.trace = noop; + +//------------------------------------------------------------------------------ +console.group = console.log; + +//------------------------------------------------------------------------------ +console.groupCollapsed = console.log; + +//------------------------------------------------------------------------------ +console.groupEnd = noop; + +//------------------------------------------------------------------------------ +console.time = function(name) { + Timers[name] = new Date().valueOf(); +}; + +//------------------------------------------------------------------------------ +console.timeEnd = function(name) { + var timeStart = Timers[name]; + if (!timeStart) { + console.warn("unknown timer: " + name); + return; + } + + var timeElapsed = new Date().valueOf() - timeStart; + console.log(name + ": " + timeElapsed + "ms"); +}; + +//------------------------------------------------------------------------------ +console.timeStamp = noop; + +//------------------------------------------------------------------------------ +console.profile = noop; + +//------------------------------------------------------------------------------ +console.profileEnd = noop; + +//------------------------------------------------------------------------------ +console.count = noop; + +//------------------------------------------------------------------------------ +console.exception = console.log; + +//------------------------------------------------------------------------------ +console.table = function(data, columns) { + console.log("%o", data); +}; + +//------------------------------------------------------------------------------ +// return a new function that calls both functions passed as args +//------------------------------------------------------------------------------ +function wrapperedOrigCall(orgFunc, newFunc) { + return function() { + var args = [].slice.call(arguments); + try { orgFunc.apply(WinConsole, args); } catch (e) {} + try { newFunc.apply(console, args); } catch (e) {} + }; +} + +//------------------------------------------------------------------------------ +// For every function that exists in the original console object, that +// also exists in the new console object, wrap the new console method +// with one that calls both +//------------------------------------------------------------------------------ +for (var key in console) { + if (typeof WinConsole[key] == "function") { + console[key] = wrapperedOrigCall(WinConsole[key], console[key]); + } +} + +}); + // file: lib/common/plugin/contacts.js define("cordova/plugin/contacts", function(require, exports, module) { var exec = require('cordova/exec'), @@ -4791,6 +4965,233 @@ module.exports = geolocation; }); +// file: lib/common/plugin/logger.js +define("cordova/plugin/logger", function(require, exports, module) { +//------------------------------------------------------------------------------ +// The logger module exports the following properties/functions: +// +// LOG - constant for the level LOG +// ERROR - constant for the level ERROR +// WARN - constant for the level WARN +// INFO - constant for the level INFO +// DEBUG - constant for the level DEBUG +// logLevel() - returns current log level +// logLevel(value) - sets and returns a new log level +// useConsole() - returns whether logger is using console +// useConsole(value) - sets and returns whether logger is using console +// log(message,...) - logs a message at level LOG +// error(message,...) - logs a message at level ERROR +// warn(message,...) - logs a message at level WARN +// info(message,...) - logs a message at level INFO +// debug(message,...) - logs a message at level DEBUG +// logLevel(level,message,...) - logs a message specified level +// +//------------------------------------------------------------------------------ + +var logger = exports; + +var exec = require('cordova/exec'); +var utils = require('cordova/utils'); + +var UseConsole = true; +var Queued = []; +var DeviceReady = false; +var CurrentLevel; + +/** + * Logging levels + */ + +var Levels = [ + "LOG", + "ERROR", + "WARN", + "INFO", + "DEBUG" +]; + +/* + * add the logging levels to the logger object and + * to a separate levelsMap object for testing + */ + +var LevelsMap = {}; +for (var i=0; i CurrentLevel) return; + + // queue the message if not yet at deviceready + if (!DeviceReady && !UseConsole) { + Queued.push([level, message]); + return; + } + + // if not using the console, use the native logger + if (!UseConsole) { + exec(null, null, "Logger", "logLevel", [level, message]); + return; + } + + // make sure console is not using logger + if (console.__usingCordovaLogger) { + throw new Error("console and logger are too intertwingly"); + } + + // log to the console + switch (level) { + case logger.LOG: console.log(message); break; + case logger.ERROR: console.log("ERROR: " + message); break; + case logger.WARN: console.log("WARN: " + message); break; + case logger.INFO: console.log("INFO: " + message); break; + case logger.DEBUG: console.log("DEBUG: " + message); break; + } +}; + +// when deviceready fires, log queued messages +logger.__onDeviceReady = function() { + if (DeviceReady) return; + + DeviceReady = true; + + for (var i=0; i 2) { + setTimeout( function() { + fail(FileError.ENCODING_ERR); + },0); + return; + } // if successful, return either a file or directory entry var success = function(entry) { var result; - if (entry) { if (typeof successCallback === 'function') { // create appropriate Entry object @@ -5019,6 +5426,68 @@ var splashscreen = { module.exports = splashscreen; }); +// file: lib/common/plugin/widget.js +define("cordova/plugin/widget", function(require, exports, module) { +var exec = require('cordova/exec'), + cordova = require('cordova'), + channel = require('cordova/channel'); + +var Widget = function () { + this.author = null; + this.description = null; + this.name = null; + this.shortName = null; + this.version = null; + this.id = null; + this.authorEmail = null; + this.authorHref = null; + this._firstRun = true; + + var me = this; + + channel.onCordovaReady.subscribeOnce(function() { + me.getInfo(function (info) { + me.author = info.author; + me.description = info.description; + me.name = info.name; + me.shortName = info.shortName; + me.version = info.version; + me.id = info.id; + me.authorEmail = info.authorEmail; + me.authorHref = info.authorHref; + + // should only fire this once + if (me._firstRun) { + me._firstRun = false; + channel.onCordovaAppInfoReady.fire(); + } + }, + function (e) { + // If we can't get the network info we should still tell Cordova + // to fire the deviceready event. + if (me._firstRun) { + me._firstRun = false; + channel.onCordovaAppInfoReady.fire(); + } + console.log("Error initializing Widget: " + e); + }); + }); +}; + +/** + * Get connection info + * + * @param {Function} successCallback The function to call when the Connection data is available + * @param {Function} errorCallback The function to call when there is an error getting the Connection data. (OPTIONAL) + */ +Widget.prototype.getInfo = function (successCallback, errorCallback) { + // Get info + exec(successCallback, errorCallback, "Widget", "getApplicationInfo", []); +}; + +module.exports = new Widget(); +}); + // file: lib/common/utils.js define("cordova/utils", function(require, exports, module) { var utils = exports; @@ -5120,6 +5589,16 @@ utils.alert = function(msg) { /** * Formats a string and arguments following it ala sprintf() * + * see utils.vformat() for more information + */ +utils.format = function(formatString /* ,... */) { + var args = [].slice.call(arguments, 1); + return utils.vformat(formatString, args); +}; + +/** + * Formats a string and arguments following it ala vsprintf() + * * format chars: * %j - format arg as JSON * %o - format arg as JSON @@ -5131,14 +5610,13 @@ utils.alert = function(msg) { * for rationale, see FireBug's Console API: * http://getfirebug.com/wiki/index.php/Console_API */ -utils.format = function(formatString /* ,... */) { +utils.vformat = function(formatString, args) { if (formatString === null || formatString === undefined) return ""; if (arguments.length == 1) return formatString.toString(); var pattern = /(.*?)%(.)(.*)/; var rest = formatString.toString(); var result = []; - var args = [].slice.call(arguments,1); while (args.length) { var arg = args.shift(); diff --git a/framework/assets/www/index.html b/framework/assets/www/index.html index 0ca839ab..1f39dc57 100644 --- a/framework/assets/www/index.html +++ b/framework/assets/www/index.html @@ -19,7 +19,7 @@ - + diff --git a/framework/src/org/apache/cordova/Device.java b/framework/src/org/apache/cordova/Device.java index 09a7a47d..a8433561 100644 --- a/framework/src/org/apache/cordova/Device.java +++ b/framework/src/org/apache/cordova/Device.java @@ -38,7 +38,7 @@ import android.telephony.TelephonyManager; 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 From ccd4365922789defc39e6b7e2a32a7a2fc534610 Mon Sep 17 00:00:00 2001 From: Davide Bertola Date: Sat, 26 May 2012 08:46:57 +0200 Subject: [PATCH 3/3] Fix calling cordova.plugin.storage.failQuery function from native code --- framework/src/org/apache/cordova/Storage.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/src/org/apache/cordova/Storage.java b/framework/src/org/apache/cordova/Storage.java index 98ec4225..8cc29b7d 100755 --- a/framework/src/org/apache/cordova/Storage.java +++ b/framework/src/org/apache/cordova/Storage.java @@ -175,7 +175,7 @@ public class Storage extends Plugin { 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 + "');"); } }