mirror of
https://github.com/apache/cordova-android.git
synced 2026-05-11 00:00:05 +08:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a489ae0fb6 | |||
| adfdb16dc5 | |||
| 24e5c24dd4 | |||
| 22e5ccfed4 | |||
| 508cafad1d | |||
| c21e8c9c87 | |||
| 5f93a26eea | |||
| d79403e352 | |||
| ed94d0dd30 | |||
| ca1a322c76 | |||
| 7d0cc5837d | |||
| b77f1cbff8 | |||
| ccd4365922 |
+7
-4
@@ -38,10 +38,13 @@ fi
|
||||
# update the cordova-android framework for the desired target
|
||||
android update project --target $TARGET --path ./framework
|
||||
|
||||
# Use curl to get the jar (TODO: Support Apache Mirrors)
|
||||
curl -OL http://mirror.symnds.com/software/Apache//commons/codec/binaries/commons-codec-1.6-bin.zip
|
||||
unzip commons-codec-1.6-bin.zip
|
||||
cp commons-codec-1.6/commons-codec-1.6.jar ./framework/libs
|
||||
if [ ! -e ./framework/libs/commons-codec-1.6.jar ]; then
|
||||
# Use curl to get the jar (TODO: Support Apache Mirrors)
|
||||
curl -OL http://mirror.symnds.com/software/Apache//commons/codec/binaries/commons-codec-1.6-bin.zip
|
||||
unzip commons-codec-1.6-bin.zip
|
||||
mkdir -p ./framework/libs
|
||||
cp commons-codec-1.6/commons-codec-1.6.jar ./framework/libs/
|
||||
fi
|
||||
|
||||
# compile cordova.js and cordova.jar
|
||||
cd ./framework && ant jar && cd ../
|
||||
|
||||
@@ -23,7 +23,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.8.0rc1.js"></script>
|
||||
<script type="text/javascript" charset="utf-8" src="cordova-1.8.0.js"></script>
|
||||
<script type="text/javascript" charset="utf-8" src="main.js"></script>
|
||||
|
||||
</head>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// commit 95f199e1c207dc89b84e79a9a7b27d6a3cc8fe14
|
||||
// commit ac0a3990438f4a89faa993316fb5614f61cf3be6
|
||||
|
||||
// File generated at :: Thu May 24 2012 21:36:17 GMT-0400 (EDT)
|
||||
// File generated at :: Tue Jun 05 2012 14:14:16 GMT-0700 (PDT)
|
||||
|
||||
/*
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
@@ -77,7 +77,7 @@ var channel = require('cordova/channel');
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
channel.onDOMContentLoaded.fire();
|
||||
}, false);
|
||||
if (document.readyState == 'complete') {
|
||||
if (document.readyState == 'complete' || document.readyState == 'interactive') {
|
||||
channel.onDOMContentLoaded.fire();
|
||||
}
|
||||
|
||||
@@ -99,7 +99,11 @@ var documentEventHandlers = {},
|
||||
document.addEventListener = function(evt, handler, capture) {
|
||||
var e = evt.toLowerCase();
|
||||
if (typeof documentEventHandlers[e] != 'undefined') {
|
||||
documentEventHandlers[e].subscribe(handler);
|
||||
if (evt === 'deviceready') {
|
||||
documentEventHandlers[e].subscribeOnce(handler);
|
||||
} else {
|
||||
documentEventHandlers[e].subscribe(handler);
|
||||
}
|
||||
} else {
|
||||
m_document_addEventListener.call(document, evt, handler, capture);
|
||||
}
|
||||
@@ -504,7 +508,7 @@ var Channel = function(type, opts) {
|
||||
this.type = type;
|
||||
this.handlers = {};
|
||||
this.numHandlers = 0;
|
||||
this.guid = 0;
|
||||
this.guid = 1;
|
||||
this.fired = false;
|
||||
this.enabled = true;
|
||||
this.events = {
|
||||
@@ -595,12 +599,21 @@ Channel.prototype.subscribe = function(f, c, g) {
|
||||
var func = f;
|
||||
if (typeof c == "object") { func = utils.close(c, f); }
|
||||
|
||||
g = g || func.observer_guid || f.observer_guid || this.guid++;
|
||||
g = g || func.observer_guid || f.observer_guid;
|
||||
if (!g) {
|
||||
// first time we've seen this subscriber
|
||||
g = this.guid++;
|
||||
}
|
||||
else {
|
||||
// subscriber already handled; dont set it twice
|
||||
return g;
|
||||
}
|
||||
func.observer_guid = g;
|
||||
f.observer_guid = g;
|
||||
this.handlers[g] = func;
|
||||
this.numHandlers++;
|
||||
if (this.events.onSubscribe) this.events.onSubscribe.call(this);
|
||||
if (this.fired) func.call(this);
|
||||
return g;
|
||||
};
|
||||
|
||||
@@ -637,6 +650,7 @@ Channel.prototype.unsubscribe = function(g) {
|
||||
if (typeof g == 'function') { g = g.observer_guid; }
|
||||
var handler = this.handlers[g];
|
||||
if (handler) {
|
||||
if (handler.observer_guid) handler.observer_guid=null;
|
||||
this.handlers[g] = null;
|
||||
delete this.handlers[g];
|
||||
this.numHandlers--;
|
||||
@@ -779,6 +793,9 @@ module.exports = {
|
||||
Camera:{
|
||||
path: 'cordova/plugin/CameraConstants'
|
||||
},
|
||||
CameraPopoverOptions: {
|
||||
path: 'cordova/plugin/CameraPopoverOptions'
|
||||
},
|
||||
CaptureError: {
|
||||
path: 'cordova/plugin/CaptureError'
|
||||
},
|
||||
@@ -1088,7 +1105,7 @@ module.exports = {
|
||||
|
||||
// Patch localStorage if necessary
|
||||
if (typeof window.localStorage == 'undefined' || window.localStorage === null) {
|
||||
window.localStorage = new storage.CupCakeLocalStorage();
|
||||
window.localStorage = new storage.CupcakeLocalStorage();
|
||||
}
|
||||
|
||||
// Let native code know we are all done on the JS side.
|
||||
@@ -1259,8 +1276,12 @@ cameraExport.getPicture = function(successCallback, errorCallback, options) {
|
||||
} else if (typeof options.saveToPhotoAlbum == "number") {
|
||||
saveToPhotoAlbum = options.saveToPhotoAlbum <=0 ? false : true;
|
||||
}
|
||||
var popoverOptions = null;
|
||||
if (typeof options.popoverOptions == "object") {
|
||||
popoverOptions = options.popoverOptions;
|
||||
}
|
||||
|
||||
exec(successCallback, errorCallback, "Camera", "takePicture", [quality, destinationType, sourceType, targetWidth, targetHeight, encodingType, mediaType, allowEdit, correctOrientation, saveToPhotoAlbum]);
|
||||
exec(successCallback, errorCallback, "Camera", "takePicture", [quality, destinationType, sourceType, targetWidth, targetHeight, encodingType, mediaType, allowEdit, correctOrientation, saveToPhotoAlbum, popoverOptions]);
|
||||
};
|
||||
|
||||
module.exports = cameraExport;
|
||||
@@ -1286,10 +1307,37 @@ module.exports = {
|
||||
PHOTOLIBRARY : 0, // Choose image from picture library (same as SAVEDPHOTOALBUM for Android)
|
||||
CAMERA : 1, // Take picture from camera
|
||||
SAVEDPHOTOALBUM : 2 // Choose image from picture library (same as PHOTOLIBRARY for Android)
|
||||
},
|
||||
PopoverArrowDirection:{
|
||||
ARROW_UP : 1, // matches iOS UIPopoverArrowDirection constants to specify arrow location on popover
|
||||
ARROW_DOWN : 2,
|
||||
ARROW_LEFT : 4,
|
||||
ARROW_RIGHT : 8,
|
||||
ARROW_ANY : 15
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
// file: lib/common/plugin/CameraPopoverOptions.js
|
||||
define("cordova/plugin/CameraPopoverOptions", function(require, exports, module) {
|
||||
var Camera = require('cordova/plugin/CameraConstants');
|
||||
|
||||
/**
|
||||
* Encapsulates options for iOS Popover image picker
|
||||
*/
|
||||
var CameraPopoverOptions = function(x,y,width,height,arrowDir){
|
||||
// information of rectangle that popover should be anchored to
|
||||
this.x = x || 0;
|
||||
this.y = y || 32;
|
||||
this.width = width || 320;
|
||||
this.height = height || 480;
|
||||
// The direction of the popover arrow
|
||||
this.arrowDir = arrowDir || Camera.PopoverArrowDirection.ARROW_ANY;
|
||||
};
|
||||
|
||||
module.exports = CameraPopoverOptions;
|
||||
});
|
||||
|
||||
// file: lib/common/plugin/CaptureAudioOptions.js
|
||||
define("cordova/plugin/CaptureAudioOptions", function(require, exports, module) {
|
||||
/**
|
||||
@@ -3288,7 +3336,7 @@ var Position = function(coords, timestamp) {
|
||||
} else {
|
||||
this.coords = new Coordinates();
|
||||
}
|
||||
this.timestamp = (timestamp !== undefined) ? timestamp : new Date().getTime();
|
||||
this.timestamp = (timestamp !== undefined) ? timestamp : new Date();
|
||||
};
|
||||
|
||||
module.exports = Position;
|
||||
@@ -4853,7 +4901,7 @@ var geolocation = {
|
||||
velocity:p.velocity,
|
||||
altitudeAccuracy:p.altitudeAccuracy
|
||||
},
|
||||
p.timestamp || new Date()
|
||||
(p.timestamp === undefined ? new Date() : ((p.timestamp instanceof Date) ? p.timestamp : new Date(p.timestamp)))
|
||||
);
|
||||
geolocation.lastPosition = pos;
|
||||
successCallback(pos);
|
||||
@@ -4937,7 +4985,7 @@ var geolocation = {
|
||||
velocity:p.velocity,
|
||||
altitudeAccuracy:p.altitudeAccuracy
|
||||
},
|
||||
p.timestamp || new Date()
|
||||
(p.timestamp === undefined ? new Date() : ((p.timestamp instanceof Date) ? p.timestamp : new Date(p.timestamp)))
|
||||
);
|
||||
geolocation.lastPosition = pos;
|
||||
successCallback(pos);
|
||||
@@ -5426,68 +5474,6 @@ 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;
|
||||
@@ -5613,9 +5599,10 @@ utils.format = function(formatString /* ,... */) {
|
||||
utils.vformat = function(formatString, args) {
|
||||
if (formatString === null || formatString === undefined) return "";
|
||||
if (arguments.length == 1) return formatString.toString();
|
||||
if (typeof formatString != "string") return formatString.toString();
|
||||
|
||||
var pattern = /(.*?)%(.)(.*)/;
|
||||
var rest = formatString.toString();
|
||||
var rest = formatString;
|
||||
var result = [];
|
||||
|
||||
while (args.length) {
|
||||
@@ -5658,13 +5645,20 @@ function UUIDcreatePart(length) {
|
||||
//------------------------------------------------------------------------------
|
||||
function formatted(object, formatChar) {
|
||||
|
||||
switch(formatChar) {
|
||||
case 'j':
|
||||
case 'o': return JSON.stringify(object);
|
||||
case 'c': return '';
|
||||
try {
|
||||
switch(formatChar) {
|
||||
case 'j':
|
||||
case 'o': return JSON.stringify(object);
|
||||
case 'c': return '';
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
return "error JSON.stringify()ing argument: " + e;
|
||||
}
|
||||
|
||||
if (null === object) return Object.prototype.toString.call(object);
|
||||
if ((object === null) || (object === undefined)) {
|
||||
return Object.prototype.toString.call(object);
|
||||
}
|
||||
|
||||
return object.toString();
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<title></title>
|
||||
<script src="cordova-1.8.0rc1.js"></script>
|
||||
<script src="cordova-1.8.0.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
@@ -223,7 +223,7 @@ public class AccelListener extends Plugin implements SensorEventListener {
|
||||
if (this.accuracy >= SensorManager.SENSOR_STATUS_ACCURACY_MEDIUM) {
|
||||
|
||||
// Save time that event was received
|
||||
this.timestamp = System.currentTimeMillis();
|
||||
this.timestamp = System.nanoTime();
|
||||
this.x = event.values[0];
|
||||
this.y = event.values[1];
|
||||
this.z = event.values[2];
|
||||
|
||||
@@ -85,7 +85,11 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
|
||||
public AudioPlayer(AudioHandler handler, String id) {
|
||||
this.handler = handler;
|
||||
this.id = id;
|
||||
this.tempFile = Environment.getExternalStorageDirectory().getAbsolutePath() + "/tmprecording.mp3";
|
||||
if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
|
||||
this.tempFile = Environment.getExternalStorageDirectory().getAbsolutePath() + "/tmprecording.mp3";
|
||||
} else {
|
||||
this.tempFile = "/data/data/" + handler.ctx.getPackageName() + "/cache/tmprecording.mp3";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -151,11 +155,16 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
|
||||
*
|
||||
* @param file
|
||||
*/
|
||||
public void moveFile(String file) {
|
||||
|
||||
public void moveFile(String file) {
|
||||
/* this is a hack to save the file as the specified name */
|
||||
File f = new File(this.tempFile);
|
||||
f.renameTo(new File("/sdcard/" + file));
|
||||
if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
|
||||
f.renameTo(new File(Environment.getExternalStorageDirectory().getAbsolutePath()
|
||||
+ File.separator + file));
|
||||
} else {
|
||||
f.renameTo(new File("/data/data/" + handler.ctx.getPackageName() + "/cache/" + file));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -148,9 +148,10 @@ public class Capture extends Plugin {
|
||||
* @throws JSONException
|
||||
*/
|
||||
private JSONObject getImageData(String filePath, JSONObject obj) throws JSONException {
|
||||
Bitmap bitmap = BitmapFactory.decodeFile(filePath);
|
||||
Bitmap bitmap = BitmapFactory.decodeFile(FileUtils.stripFileProtocol(filePath));
|
||||
obj.put("height", bitmap.getHeight());
|
||||
obj.put("width", bitmap.getWidth());
|
||||
bitmap.recycle();
|
||||
return obj;
|
||||
}
|
||||
|
||||
@@ -353,7 +354,7 @@ public class Capture extends Plugin {
|
||||
try {
|
||||
// File properties
|
||||
obj.put("name", fp.getName());
|
||||
obj.put("fullPath", fp.getAbsolutePath());
|
||||
obj.put("fullPath", "file://" + fp.getAbsolutePath());
|
||||
|
||||
// Because of an issue with MimeTypeMap.getMimeTypeFromExtension() all .3gpp files
|
||||
// are reported as video/3gpp. I'm doing this hacky check of the URI to see if it
|
||||
|
||||
@@ -18,7 +18,6 @@ package org.apache.cordova;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.webkit.WebView;
|
||||
@@ -48,21 +47,21 @@ public abstract class ContactAccessor {
|
||||
* @return true if the key data is required
|
||||
*/
|
||||
protected boolean isRequired(String key, HashMap<String,Boolean> map) {
|
||||
Boolean retVal = map.get(key);
|
||||
return (retVal == null) ? false : retVal.booleanValue();
|
||||
}
|
||||
Boolean retVal = map.get(key);
|
||||
return (retVal == null) ? false : retVal.booleanValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a hash map of what data needs to be populated in the Contact object
|
||||
* @param fields the list of fields to populate
|
||||
* @return the hash map of required data
|
||||
*/
|
||||
protected HashMap<String,Boolean> buildPopulationSet(JSONArray fields) {
|
||||
HashMap<String,Boolean> map = new HashMap<String,Boolean>();
|
||||
protected HashMap<String,Boolean> buildPopulationSet(JSONArray fields) {
|
||||
HashMap<String,Boolean> map = new HashMap<String,Boolean>();
|
||||
|
||||
String key;
|
||||
try {
|
||||
if (fields.length() == 1 && fields.getString(0).equals("*")) {
|
||||
String key;
|
||||
try {
|
||||
if (fields.length() == 1 && fields.getString(0).equals("*")) {
|
||||
map.put("displayName", true);
|
||||
map.put("name", true);
|
||||
map.put("nickname", true);
|
||||
@@ -76,90 +75,90 @@ public abstract class ContactAccessor {
|
||||
map.put("urls", true);
|
||||
map.put("photos", true);
|
||||
map.put("categories", true);
|
||||
}
|
||||
else {
|
||||
for (int i=0; i<fields.length(); i++) {
|
||||
key = fields.getString(i);
|
||||
if (key.startsWith("displayName")) {
|
||||
map.put("displayName", true);
|
||||
}
|
||||
else if (key.startsWith("name")) {
|
||||
map.put("displayName", true);
|
||||
map.put("name", true);
|
||||
}
|
||||
else if (key.startsWith("nickname")) {
|
||||
map.put("nickname", true);
|
||||
}
|
||||
else if (key.startsWith("phoneNumbers")) {
|
||||
map.put("phoneNumbers", true);
|
||||
}
|
||||
else if (key.startsWith("emails")) {
|
||||
map.put("emails", true);
|
||||
}
|
||||
else if (key.startsWith("addresses")) {
|
||||
map.put("addresses", true);
|
||||
}
|
||||
else if (key.startsWith("ims")) {
|
||||
map.put("ims", true);
|
||||
}
|
||||
else if (key.startsWith("organizations")) {
|
||||
map.put("organizations", true);
|
||||
}
|
||||
else if (key.startsWith("birthday")) {
|
||||
map.put("birthday", true);
|
||||
}
|
||||
else if (key.startsWith("note")) {
|
||||
map.put("note", true);
|
||||
}
|
||||
else if (key.startsWith("urls")) {
|
||||
map.put("urls", true);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (int i=0; i<fields.length(); i++) {
|
||||
key = fields.getString(i);
|
||||
if (key.startsWith("displayName")) {
|
||||
map.put("displayName", true);
|
||||
}
|
||||
else if (key.startsWith("name")) {
|
||||
map.put("displayName", true);
|
||||
map.put("name", true);
|
||||
}
|
||||
else if (key.startsWith("nickname")) {
|
||||
map.put("nickname", true);
|
||||
}
|
||||
else if (key.startsWith("phoneNumbers")) {
|
||||
map.put("phoneNumbers", true);
|
||||
}
|
||||
else if (key.startsWith("emails")) {
|
||||
map.put("emails", true);
|
||||
}
|
||||
else if (key.startsWith("addresses")) {
|
||||
map.put("addresses", true);
|
||||
}
|
||||
else if (key.startsWith("ims")) {
|
||||
map.put("ims", true);
|
||||
}
|
||||
else if (key.startsWith("organizations")) {
|
||||
map.put("organizations", true);
|
||||
}
|
||||
else if (key.startsWith("birthday")) {
|
||||
map.put("birthday", true);
|
||||
}
|
||||
else if (key.startsWith("note")) {
|
||||
map.put("note", true);
|
||||
}
|
||||
else if (key.startsWith("urls")) {
|
||||
map.put("urls", true);
|
||||
}
|
||||
else if (key.startsWith("photos")) {
|
||||
map.put("photos", true);
|
||||
}
|
||||
else if (key.startsWith("categories")) {
|
||||
map.put("categories", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (JSONException e) {
|
||||
Log.e(LOG_TAG, e.getMessage(), e);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
catch (JSONException e) {
|
||||
Log.e(LOG_TAG, e.getMessage(), e);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method to get a string from a JSON object. Saves a
|
||||
* lot of try/catch writing.
|
||||
* If the property is not found in the object null will be returned.
|
||||
*
|
||||
* @param obj contact object to search
|
||||
* @param property to be looked up
|
||||
* @return The value of the property
|
||||
*/
|
||||
protected String getJsonString(JSONObject obj, String property) {
|
||||
String value = null;
|
||||
try {
|
||||
if (obj != null) {
|
||||
value = obj.getString(property);
|
||||
if (value.equals("null")) {
|
||||
Log.d(LOG_TAG, property + " is string called 'null'");
|
||||
value = null;
|
||||
}
|
||||
/**
|
||||
* Convenience method to get a string from a JSON object. Saves a
|
||||
* lot of try/catch writing.
|
||||
* If the property is not found in the object null will be returned.
|
||||
*
|
||||
* @param obj contact object to search
|
||||
* @param property to be looked up
|
||||
* @return The value of the property
|
||||
*/
|
||||
protected String getJsonString(JSONObject obj, String property) {
|
||||
String value = null;
|
||||
try {
|
||||
if (obj != null) {
|
||||
value = obj.getString(property);
|
||||
if (value.equals("null")) {
|
||||
Log.d(LOG_TAG, property + " is string called 'null'");
|
||||
value = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (JSONException e) {
|
||||
Log.d(LOG_TAG, "Could not get = " + e.getMessage());
|
||||
}
|
||||
return value;
|
||||
}
|
||||
catch (JSONException e) {
|
||||
Log.d(LOG_TAG, "Could not get = " + e.getMessage());
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles adding a JSON Contact object into the database.
|
||||
* @return TODO
|
||||
*/
|
||||
public abstract String save(JSONObject contact);
|
||||
public abstract String save(JSONObject contact);
|
||||
|
||||
/**
|
||||
* Handles searching through SDK-specific contacts API.
|
||||
@@ -175,25 +174,25 @@ public abstract class ContactAccessor {
|
||||
/**
|
||||
* Handles removing a contact from the database.
|
||||
*/
|
||||
public abstract boolean remove(String id);
|
||||
public abstract boolean remove(String id);
|
||||
|
||||
/**
|
||||
* A class that represents the where clause to be used in the database query
|
||||
*/
|
||||
class WhereOptions {
|
||||
private String where;
|
||||
private String[] whereArgs;
|
||||
public void setWhere(String where) {
|
||||
this.where = where;
|
||||
/**
|
||||
* A class that represents the where clause to be used in the database query
|
||||
*/
|
||||
class WhereOptions {
|
||||
private String where;
|
||||
private String[] whereArgs;
|
||||
public void setWhere(String where) {
|
||||
this.where = where;
|
||||
}
|
||||
public String getWhere() {
|
||||
return where;
|
||||
}
|
||||
public void setWhereArgs(String[] whereArgs) {
|
||||
this.whereArgs = whereArgs;
|
||||
}
|
||||
public String[] getWhereArgs() {
|
||||
return whereArgs;
|
||||
}
|
||||
}
|
||||
public String getWhere() {
|
||||
return where;
|
||||
}
|
||||
public void setWhereArgs(String[] whereArgs) {
|
||||
this.whereArgs = whereArgs;
|
||||
}
|
||||
public String[] getWhereArgs() {
|
||||
return whereArgs;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,10 @@ import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
@@ -111,7 +114,7 @@ public class ContactAccessorSdk5 extends ContactAccessor {
|
||||
dbMap.put("organizations.name", ContactsContract.CommonDataKinds.Organization.COMPANY);
|
||||
dbMap.put("organizations.department", ContactsContract.CommonDataKinds.Organization.DEPARTMENT);
|
||||
dbMap.put("organizations.title", ContactsContract.CommonDataKinds.Organization.TITLE);
|
||||
dbMap.put("birthday", ContactsContract.CommonDataKinds.Event.CONTENT_ITEM_TYPE);
|
||||
dbMap.put("birthday", ContactsContract.CommonDataKinds.Event.START_DATE);
|
||||
dbMap.put("note", ContactsContract.CommonDataKinds.Note.NOTE);
|
||||
dbMap.put("photos.value", ContactsContract.CommonDataKinds.Photo.CONTENT_ITEM_TYPE);
|
||||
//dbMap.put("categories.value", null);
|
||||
@@ -437,14 +440,14 @@ public class ContactAccessorSdk5 extends ContactAccessor {
|
||||
contact.put("ims", ims);
|
||||
}
|
||||
if (websites.length() > 0) {
|
||||
contact.put("websites", websites);
|
||||
contact.put("urls", websites);
|
||||
}
|
||||
if (photos.length() > 0) {
|
||||
contact.put("photos", photos);
|
||||
}
|
||||
}
|
||||
catch (JSONException e) {
|
||||
Log.e(LOG_TAG,e.getMessage(),e);
|
||||
Log.e(LOG_TAG,e.getMessage(),e);
|
||||
}
|
||||
return contact;
|
||||
}
|
||||
@@ -579,10 +582,24 @@ public class ContactAccessorSdk5 extends ContactAccessor {
|
||||
whereArgs.add(searchTerm);
|
||||
whereArgs.add(ContactsContract.CommonDataKinds.Organization.CONTENT_ITEM_TYPE);
|
||||
}
|
||||
// else if (key.startsWith("birthday")) {
|
||||
// where.add("(" + dbMap.get(key) + " LIKE ? AND "
|
||||
// + ContactsContract.Data.MIMETYPE + " = ? )");
|
||||
// }
|
||||
else if (key.startsWith("birthday")) {
|
||||
try {
|
||||
SimpleDateFormat format = new SimpleDateFormat("EEEE, MMMM dd, yyyy");
|
||||
Date searchDate = format.parse(searchTerm.substring(1, searchTerm.length()-1));
|
||||
// Have to subtract one from the month as JavaScript's January is 01
|
||||
// while Java's January is 00.
|
||||
searchDate.setMonth(searchDate.getMonth()-1);
|
||||
SimpleDateFormat newFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
|
||||
where.add("(" + dbMap.get(key) + " = ? AND "
|
||||
+ ContactsContract.Data.MIMETYPE + " = ? )");
|
||||
whereArgs.add(newFormat.format(searchDate));
|
||||
whereArgs.add(ContactsContract.CommonDataKinds.Event.CONTENT_ITEM_TYPE);
|
||||
}
|
||||
catch (ParseException e) {
|
||||
Log.d(LOG_TAG, "Bad romance format");
|
||||
}
|
||||
}
|
||||
else if (key.startsWith("note")) {
|
||||
where.add("(" + dbMap.get(key) + " LIKE ? AND "
|
||||
+ ContactsContract.Data.MIMETYPE + " = ? )");
|
||||
@@ -1149,7 +1166,7 @@ public class ContactAccessorSdk5 extends ContactAccessor {
|
||||
// Modify urls
|
||||
JSONArray websites = null;
|
||||
try {
|
||||
websites = contact.getJSONArray("websites");
|
||||
websites = contact.getJSONArray("urls");
|
||||
if (websites != null) {
|
||||
for (int i=0; i<websites.length(); i++) {
|
||||
JSONObject website = (JSONObject)websites.get(i);
|
||||
|
||||
@@ -38,7 +38,7 @@ import android.telephony.TelephonyManager;
|
||||
public class Device extends Plugin {
|
||||
public static final String TAG = "Device";
|
||||
|
||||
public static String cordovaVersion = "1.8.0rc1"; // Cordova version
|
||||
public static String cordovaVersion = "1.8.0"; // Cordova version
|
||||
public static String platform = "Android"; // Device OS
|
||||
public static String uuid; // Device UUID
|
||||
|
||||
|
||||
@@ -740,7 +740,7 @@ public class FileUtils extends Plugin {
|
||||
* @param filePath to be checked.
|
||||
* @return
|
||||
*/
|
||||
private String stripFileProtocol(String filePath) {
|
||||
public static String stripFileProtocol(String filePath) {
|
||||
if (filePath.startsWith("file://")) {
|
||||
filePath = filePath.substring(7);
|
||||
}
|
||||
|
||||
@@ -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 + "');");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ public class PluginResult {
|
||||
}
|
||||
|
||||
public String getJSONString() {
|
||||
return "{status:" + this.status + ",message:" + this.message + ",keepCallback:" + this.keepCallback + "}";
|
||||
return "{\"status\":" + this.status + ",\"message\":" + this.message + ",\"keepCallback\":" + this.keepCallback + "}";
|
||||
}
|
||||
|
||||
public String toSuccessCallbackString(String callbackId) {
|
||||
|
||||
Reference in New Issue
Block a user