Compare commits

..

6 Commits

Author SHA1 Message Date
Joe Bowser e2d91c2556 Updating the JS and re-tagging 1.7.0 2012-05-01 14:25:42 -07:00
Joe Bowser 634a9c0f4c Updating the version to 1.7.0 2012-04-30 13:42:38 -07:00
macdonst c846111099 Adding SplashScreen plugin to plugins.xml 2012-04-25 13:17:48 -04:00
macdonst 960e0f3412 Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/incubator-cordova-android 2012-04-25 11:53:39 -04:00
Joe Bowser 39f261c6e2 Incrementing project to 1.7.0rc1 2012-04-25 11:49:55 -04:00
macdonst d7c8bc799d Refactor Android SplashScreen 2012-04-24 15:14:37 -04:00
8 changed files with 222 additions and 151 deletions
+1 -1
View File
@@ -1 +1 @@
1.7.0rc1
1.7.0
@@ -5,7 +5,7 @@
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>PhoneGap</title>
<link rel="stylesheet" href="master.css" type="text/css" media="screen" title="no title">
<script type="text/javascript" charset="utf-8" src="cordova-1.7.0rc1.js"></script>
<script type="text/javascript" charset="utf-8" src="cordova-1.7.0.js"></script>
<script type="text/javascript" charset="utf-8" src="main.js"></script>
</head>
+143 -110
View File
@@ -1,6 +1,6 @@
// commit 017a948047e355ae0c2cdc8c4188ae57b115528a
// commit 1c9ac3578a369dcb35b168c3e2d7ce2e89d45d12
// File generated at :: Mon Apr 23 2012 11:36:23 GMT-0700 (PDT)
// File generated at :: Tue May 01 2012 13:42:28 GMT-0700 (PDT)
/*
Licensed to the Apache Software Foundation (ASF) under one
@@ -101,27 +101,27 @@ document.addEventListener = function(evt, handler, capture) {
if (e == 'deviceready') {
channel.onDeviceReady.subscribeOnce(handler);
} else if (e == 'resume') {
channel.onResume.subscribe(handler);
// if subscribing listener after event has already fired, invoke the handler
if (channel.onResume.fired && handler instanceof Function) {
handler();
}
channel.onResume.subscribe(handler);
// if subscribing listener after event has already fired, invoke the handler
if (channel.onResume.fired && typeof handler == 'function') {
handler();
}
} else if (e == 'pause') {
channel.onPause.subscribe(handler);
channel.onPause.subscribe(handler);
} else if (typeof documentEventHandlers[e] != 'undefined') {
documentEventHandlers[e].subscribe(handler);
documentEventHandlers[e].subscribe(handler);
} else {
m_document_addEventListener.call(document, evt, handler, capture);
m_document_addEventListener.call(document, evt, handler, capture);
}
};
window.addEventListener = function(evt, handler, capture) {
var e = evt.toLowerCase();
if (typeof windowEventHandlers[e] != 'undefined') {
windowEventHandlers[e].subscribe(handler);
} else {
m_window_addEventListener.call(window, evt, handler, capture);
}
var e = evt.toLowerCase();
if (typeof windowEventHandlers[e] != 'undefined') {
windowEventHandlers[e].subscribe(handler);
} else {
m_window_addEventListener.call(window, evt, handler, capture);
}
};
document.removeEventListener = function(evt, handler, capture) {
@@ -140,30 +140,29 @@ document.removeEventListener = function(evt, handler, capture) {
};
window.removeEventListener = function(evt, handler, capture) {
var e = evt.toLowerCase();
// If unsubcribing from an event that is handled by a plugin
if (typeof windowEventHandlers[e] != "undefined") {
windowEventHandlers[e].unsubscribe(handler);
} else {
m_window_removeEventListener.call(window, evt, handler, capture);
}
var e = evt.toLowerCase();
// If unsubcribing from an event that is handled by a plugin
if (typeof windowEventHandlers[e] != "undefined") {
windowEventHandlers[e].unsubscribe(handler);
} else {
m_window_removeEventListener.call(window, evt, handler, capture);
}
};
function createEvent(type, data) {
var event = document.createEvent('Events');
event.initEvent(type, false, false);
if (data) {
for (var i in data) {
if (data.hasOwnProperty(i)) {
event[i] = data[i];
}
var event = document.createEvent('Events');
event.initEvent(type, false, false);
if (data) {
for (var i in data) {
if (data.hasOwnProperty(i)) {
event[i] = data[i];
}
}
}
}
return event;
return event;
}
if(typeof window.console === "undefined")
{
if(typeof window.console === "undefined") {
window.console = {
log:function(){}
};
@@ -176,16 +175,16 @@ var cordova = {
* Methods to add/remove your own addEventListener hijacking on document + window.
*/
addWindowEventHandler:function(event, opts) {
return (windowEventHandlers[event] = channel.create(event, opts));
return (windowEventHandlers[event] = channel.create(event, opts));
},
addDocumentEventHandler:function(event, opts) {
return (documentEventHandlers[event] = channel.create(event, opts));
return (documentEventHandlers[event] = channel.create(event, opts));
},
removeWindowEventHandler:function(event) {
delete windowEventHandlers[event];
delete windowEventHandlers[event];
},
removeDocumentEventHandler:function(event) {
delete documentEventHandlers[event];
delete documentEventHandlers[event];
},
/**
* Retreive original event handlers that were replaced by Cordova
@@ -200,20 +199,20 @@ var cordova = {
* Method to fire event from native code
*/
fireDocumentEvent: function(type, data) {
var evt = createEvent(type, data);
if (typeof documentEventHandlers[type] != 'undefined') {
documentEventHandlers[type].fire(evt);
} else {
document.dispatchEvent(evt);
}
var evt = createEvent(type, data);
if (typeof documentEventHandlers[type] != 'undefined') {
documentEventHandlers[type].fire(evt);
} else {
document.dispatchEvent(evt);
}
},
fireWindowEvent: function(type, data) {
var evt = createEvent(type,data);
if (typeof windowEventHandlers[type] != 'undefined') {
windowEventHandlers[type].fire(evt);
} else {
window.dispatchEvent(evt);
}
var evt = createEvent(type,data);
if (typeof windowEventHandlers[type] != 'undefined') {
windowEventHandlers[type].fire(evt);
} else {
window.dispatchEvent(evt);
}
},
// TODO: this is Android only; think about how to do this better
shuttingDown:false,
@@ -319,6 +318,32 @@ var cordova = {
}
};
// Adds deprecation warnings to functions of an object (but only logs a message once)
function deprecateFunctions(obj, objLabel) {
var newObj = {};
var logHash = {};
for (var i in obj) {
if (obj.hasOwnProperty(i)) {
if (typeof obj[i] == 'function') {
newObj[i] = (function(prop){
var oldFunk = obj[prop];
var funkId = objLabel + '_' + prop;
return function() {
if (!logHash[funkId]) {
console.log('[DEPRECATION NOTICE] The "' + objLabel + '" global will be removed in version 2.0, please use lowercase "cordova".');
logHash[funkId] = true;
}
oldFunk.apply(obj, arguments);
};
})(i);
} else {
newObj[i] = (function(prop) { return obj[prop]; })(i);
}
}
}
return newObj;
}
/**
* Legacy variable for plugin support
* TODO: remove in 2.0.
@@ -326,6 +351,9 @@ var cordova = {
if (!window.PhoneGap) {
window.PhoneGap = cordova;
}
if (!window.Cordova) {
window.Cordova = cordova;
}
/**
* Plugins object
@@ -434,6 +462,8 @@ module.exports = {
// file: lib/common/channel.js
define("cordova/channel", function(require, exports, module) {
var utils = require('cordova/utils');
/**
* Custom pub-sub "channel" that can have functions subscribed to it
* This object is used to define and control firing of events for
@@ -481,21 +511,21 @@ define("cordova/channel", function(require, exports, module) {
* context to the Channel.
*/
var Channel = function(type, opts) {
this.type = type;
this.handlers = {};
this.numHandlers = 0;
this.guid = 0;
this.fired = false;
this.enabled = true;
this.events = {
onSubscribe:null,
onUnsubscribe:null
};
if (opts) {
if (opts.onSubscribe) this.events.onSubscribe = opts.onSubscribe;
if (opts.onUnsubscribe) this.events.onUnsubscribe = opts.onUnsubscribe;
}
},
this.type = type;
this.handlers = {};
this.numHandlers = 0;
this.guid = 0;
this.fired = false;
this.enabled = true;
this.events = {
onSubscribe:null,
onUnsubscribe:null
};
if (opts) {
if (opts.onSubscribe) this.events.onSubscribe = opts.onSubscribe;
if (opts.onUnsubscribe) this.events.onUnsubscribe = opts.onUnsubscribe;
}
},
channel = {
/**
* Calls the provided function only after all of the channels specified
@@ -555,8 +585,11 @@ var Channel = function(type, opts) {
c.fire();
}
}
},
utils = require('cordova/utils');
};
function forceFunction(f) {
if (f === null || f === undefined || typeof f != 'function') throw "Function required as first argument!";
}
/**
* Subscribes the given function to the channel. Any time that
@@ -567,10 +600,10 @@ var Channel = function(type, opts) {
*/
Channel.prototype.subscribe = function(f, c, g) {
// need a function to call
if (f === null || f === undefined) { return; }
forceFunction(f);
var func = f;
if (typeof c == "object" && f instanceof Function) { func = utils.close(c, f); }
if (typeof c == "object") { func = utils.close(c, f); }
g = g || func.observer_guid || f.observer_guid || this.guid++;
func.observer_guid = g;
@@ -587,7 +620,7 @@ Channel.prototype.subscribe = function(f, c, g) {
*/
Channel.prototype.subscribeOnce = function(f, c) {
// need a function to call
if (f === null || f === undefined) { return; }
forceFunction(f);
var g = null;
var _this = this;
@@ -596,7 +629,7 @@ Channel.prototype.subscribeOnce = function(f, c) {
_this.unsubscribe(g);
};
if (this.fired) {
if (typeof c == "object" && f instanceof Function) { f = utils.close(c, f); }
if (typeof c == "object") { f = utils.close(c, f); }
f.apply(this, this.fireArgs);
} else {
g = this.subscribe(m);
@@ -609,9 +642,9 @@ Channel.prototype.subscribeOnce = function(f, c) {
*/
Channel.prototype.unsubscribe = function(g) {
// need a function to unsubscribe
if (g === null || g === undefined) { return; }
if (g === null || g === undefined) { throw "You must pass _something_ into Channel.unsubscribe"; }
if (g instanceof Function) { g = g.observer_guid; }
if (typeof g == 'function') { g = g.observer_guid; }
this.handlers[g] = null;
delete this.handlers[g];
this.numHandlers--;
@@ -627,7 +660,7 @@ Channel.prototype.fire = function(e) {
this.fired = true;
for (var item in this.handlers) {
var handler = this.handlers[item];
if (handler instanceof Function) {
if (typeof handler == 'function') {
var rv = (handler.apply(this, arguments)===false);
fail = fail || rv;
}
@@ -673,6 +706,7 @@ channel.waitForInitialization('onCordovaInfoReady');
channel.waitForInitialization('onCordovaConnectionReady');
module.exports = channel;
});
// file: lib/common/common.js
@@ -1405,14 +1439,14 @@ function convertOut(contact) {
var value = contact.birthday;
if (value !== null) {
// try to make it a Date object if it is not already
if (!value instanceof Date){
if (!utils.isDate(value)){
try {
value = new Date(value);
} catch(exception){
value = null;
}
}
if (value instanceof Date){
if (utils.isDate(value)){
value = value.valueOf(); // convert to milliseconds
}
contact.birthday = value;
@@ -1555,6 +1589,7 @@ Contact.prototype.save = function(successCB, errorCB) {
module.exports = Contact;
});
// file: lib/common/plugin/ContactAddress.js
@@ -1623,8 +1658,8 @@ define("cordova/plugin/ContactField", function(require, exports, module) {
*/
var ContactField = function(type, value, pref) {
this.id = null;
this.type = type || null;
this.value = value || null;
this.type = (type && type.toString()) || null;
this.value = (value && value.toString()) || null;
this.pref = (typeof pref != 'undefined' ? pref : false);
};
@@ -2509,7 +2544,7 @@ FileTransfer.prototype.upload = function(filePath, server, successCallback, erro
fileKey = options.fileKey;
fileName = options.fileName;
mimeType = options.mimeType;
if (options.chunkedMode !== null || typeof options.chunkedMode !== "undefined") {
if (options.chunkedMode !== null || typeof options.chunkedMode != "undefined") {
chunkedMode = options.chunkedMode;
}
if (options.params) {
@@ -3125,7 +3160,7 @@ var utils = require('cordova/utils'),
* size {Number} size of the file in bytes
*/
var MediaFile = function(name, fullPath, type, lastModifiedDate, size){
MediaFile.__super__.constructor.apply(this, arguments);
MediaFile.__super__.constructor.apply(this, arguments);
};
utils.extend(MediaFile, File);
@@ -3140,10 +3175,11 @@ MediaFile.prototype.getFormatData = function(successCallback, errorCallback) {
if (typeof this.fullPath === "undefined" || this.fullPath === null) {
errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT));
} else {
exec(successCallback, errorCallback, "Capture", "getFormatData", [this.fullPath, this.type]);
exec(successCallback, errorCallback, "Capture", "getFormatData", [this.fullPath, this.type]);
}
};
// TODO: can we axe this?
/**
* Casts a PluginResult message property (array of objects) to an array of MediaFile objects
* (used in Objective-C and Android)
@@ -3151,22 +3187,22 @@ MediaFile.prototype.getFormatData = function(successCallback, errorCallback) {
* @param {PluginResult} pluginResult
*/
MediaFile.cast = function(pluginResult) {
var mediaFiles = [];
var i;
for (i=0; i<pluginResult.message.length; i++) {
var mediaFile = new MediaFile();
mediaFile.name = pluginResult.message[i].name;
mediaFile.fullPath = pluginResult.message[i].fullPath;
mediaFile.type = pluginResult.message[i].type;
mediaFile.lastModifiedDate = pluginResult.message[i].lastModifiedDate;
mediaFile.size = pluginResult.message[i].size;
mediaFiles.push(mediaFile);
}
pluginResult.message = mediaFiles;
return pluginResult;
var mediaFiles = [];
for (var i=0; i<pluginResult.message.length; i++) {
var mediaFile = new MediaFile();
mediaFile.name = pluginResult.message[i].name;
mediaFile.fullPath = pluginResult.message[i].fullPath;
mediaFile.type = pluginResult.message[i].type;
mediaFile.lastModifiedDate = pluginResult.message[i].lastModifiedDate;
mediaFile.size = pluginResult.message[i].size;
mediaFiles.push(mediaFile);
}
pluginResult.message = mediaFiles;
return pluginResult;
};
module.exports = MediaFile;
});
// file: lib/common/plugin/MediaFileData.js
@@ -4401,6 +4437,7 @@ module.exports = compass;
define("cordova/plugin/contacts", function(require, exports, module) {
var exec = require('cordova/exec'),
ContactError = require('cordova/plugin/ContactError'),
utils = require('cordova/utils'),
Contact = require('cordova/plugin/Contact');
/**
@@ -4420,7 +4457,7 @@ var contacts = {
if (!successCB) {
throw new TypeError("You must specify a success callback for the find command.");
}
if (!fields || (fields instanceof Array && fields.length === 0)) {
if (!fields || (utils.isArray(fields) && fields.length === 0)) {
if (typeof errorCB === "function") {
errorCB(new ContactError(ContactError.INVALID_ARGUMENT_ERROR));
}
@@ -4456,6 +4493,7 @@ var contacts = {
};
module.exports = contacts;
});
// file: lib/common/plugin/geolocation.js
@@ -4786,17 +4824,23 @@ function UUIDcreatePart(length) {
}
var _self = {
isArray:function(a) {
return Object.prototype.toString.call(a) == '[object Array]';
},
isDate:function(d) {
return Object.prototype.toString.call(d) == '[object Date]';
},
/**
* Does a deep clone of the object.
*/
clone: function(obj) {
if(!obj) {
if(!obj || typeof obj == 'function' || _self.isDate(obj) || typeof obj != 'object') {
return obj;
}
var retVal, i;
if(obj instanceof Array){
if(_self.isArray(obj)){
retVal = [];
for(i = 0; i < obj.length; ++i){
retVal.push(_self.clone(obj[i]));
@@ -4804,18 +4848,6 @@ var _self = {
return retVal;
}
if (obj instanceof Function) {
return obj;
}
if(!(obj instanceof Object)){
return obj;
}
if(obj instanceof Date){
return obj;
}
retVal = {};
for(i in obj){
if(!(i in retVal) || retVal[i] != obj[i]) {
@@ -4826,7 +4858,7 @@ var _self = {
},
close: function(context, func, params) {
if (typeof params === 'undefined') {
if (typeof params == 'undefined') {
return function() {
return func.apply(context, arguments);
};
@@ -4877,6 +4909,7 @@ var _self = {
};
module.exports = _self;
});
+1 -1
View File
@@ -19,7 +19,7 @@
<html>
<head>
<title></title>
<script src="cordova-1.7.0rc1.js"></script>
<script src="cordova-1.7.0.js"></script>
</head>
<body>
+1
View File
@@ -34,4 +34,5 @@
<plugin name="FileTransfer" value="org.apache.cordova.FileTransfer"/>
<plugin name="Capture" value="org.apache.cordova.Capture"/>
<plugin name="Battery" value="org.apache.cordova.BatteryListener"/>
<plugin name="SplashScreen" value="org.apache.cordova.SplashScreen"/>
</plugins>
+1 -1
View File
@@ -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.0rc1"; // Cordova version
public static String cordovaVersion = "1.7.0"; // Cordova version
public static String platform = "Android"; // Device OS
public static String uuid; // Device UUID
+51 -37
View File
@@ -37,18 +37,18 @@ import org.xmlpull.v1.XmlPullParserException;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Configuration;
import android.content.res.XmlResourceParser;
import android.database.Cursor;
import android.graphics.Color;
import android.media.AudioManager;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.os.Handler;
import android.view.Display;
import android.view.KeyEvent;
import android.view.Menu;
@@ -434,9 +434,6 @@ public class DroidGap extends Activity implements CordovaInterface {
// If spashscreen
this.splashscreen = this.getIntegerProperty("splashscreen", 0);
if ((this.urls.size() == 0) && (this.splashscreen != 0)) {
root.setBackgroundResource(this.splashscreen);
}
// If loadUrlTimeoutValue
int timeout = this.getIntegerProperty("loadUrlTimeoutValue", 0);
@@ -609,38 +606,12 @@ public class DroidGap extends Activity implements CordovaInterface {
if (!url.startsWith("javascript:")) {
LOG.d(TAG, "DroidGap.loadUrl(%s, %d)", url, time);
}
final DroidGap me = this;
// Handle activity parameters
this.runOnUiThread(new Runnable() {
public void run() {
if (me.appView == null) {
me.init();
}
me.handleActivityParameters();
}
});
Runnable runnable = new Runnable() {
public void run() {
try {
synchronized(this) {
this.wait(time);
}
} catch (InterruptedException e) {
e.printStackTrace();
}
if (!me.cancelLoadUrl) {
me.loadUrlIntoView(url);
}
else{
me.cancelLoadUrl = false;
LOG.d(TAG, "Aborting loadUrl(%s): Another URL was loaded before timer expired.", url);
}
}
};
Thread thread = new Thread(runnable);
thread.start();
this.handleActivityParameters();
if (this.splashscreen != 0) {
this.showSplashScreen(time);
}
this.loadUrlIntoView(url);
}
/**
@@ -1433,4 +1404,47 @@ public class DroidGap extends Activity implements CordovaInterface {
return this.bound;
}
protected Dialog splashDialog;
/**
* Removes the Dialog that displays the splash screen
*/
public void removeSplashScreen() {
if (splashDialog != null) {
splashDialog.dismiss();
splashDialog = null;
}
}
/**
* Shows the splash screen over the full Activity
*/
protected void showSplashScreen(int time) {
// Get reference to display
Display display = getWindowManager().getDefaultDisplay();
// Create the layout for the dialog
LinearLayout root = new LinearLayout(this);
root.setMinimumHeight(display.getHeight());
root.setMinimumWidth(display.getWidth());
root.setOrientation(LinearLayout.VERTICAL);
root.setBackgroundColor(this.getIntegerProperty("backgroundColor", Color.BLACK));
root.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
ViewGroup.LayoutParams.FILL_PARENT, 0.0F));
root.setBackgroundResource(this.splashscreen);
// Create and show the dialog
splashDialog = new Dialog(this, android.R.style.Theme_Translucent_NoTitleBar);
splashDialog.setContentView(root);
splashDialog.setCancelable(false);
splashDialog.show();
// Set Runnable to remove splash screen just in case
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
public void run() {
removeSplashScreen();
}
}, time);
}
}
@@ -0,0 +1,23 @@
package org.apache.cordova;
import org.apache.cordova.api.Plugin;
import org.apache.cordova.api.PluginResult;
import org.json.JSONArray;
public class SplashScreen extends Plugin {
@Override
public PluginResult execute(String action, JSONArray args, String callbackId) {
PluginResult.Status status = PluginResult.Status.OK;
String result = "";
if (action.equals("hide")) {
((DroidGap)this.ctx).removeSplashScreen();
}
else {
status = PluginResult.Status.INVALID_ACTION;
}
return new PluginResult(status, result);
}
}