Merge remote-tracking branch 'upstream/master' into volumebtns

This commit is contained in:
Julien Bouquillon 2012-06-02 22:52:34 +02:00
commit 55ee289ed6
6 changed files with 130 additions and 111 deletions

View File

@ -38,10 +38,13 @@ fi
# update the cordova-android framework for the desired target # update the cordova-android framework for the desired target
android update project --target $TARGET --path ./framework android update project --target $TARGET --path ./framework
# Use curl to get the jar (TODO: Support Apache Mirrors) if [ ! -e ./framework/libs/commons-codec-1.6.jar ]; then
curl -OL http://mirror.symnds.com/software/Apache//commons/codec/binaries/commons-codec-1.6-bin.zip # Use curl to get the jar (TODO: Support Apache Mirrors)
unzip commons-codec-1.6-bin.zip curl -OL http://mirror.symnds.com/software/Apache//commons/codec/binaries/commons-codec-1.6-bin.zip
cp commons-codec-1.6/commons-codec-1.6.jar ./framework/libs 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 # compile cordova.js and cordova.jar
cd ./framework && ant jar && cd ../ cd ./framework && ant jar && cd ../

View File

@ -223,7 +223,7 @@ public class AccelListener extends Plugin implements SensorEventListener {
if (this.accuracy >= SensorManager.SENSOR_STATUS_ACCURACY_MEDIUM) { if (this.accuracy >= SensorManager.SENSOR_STATUS_ACCURACY_MEDIUM) {
// Save time that event was received // Save time that event was received
this.timestamp = System.currentTimeMillis(); this.timestamp = System.nanoTime();
this.x = event.values[0]; this.x = event.values[0];
this.y = event.values[1]; this.y = event.values[1];
this.z = event.values[2]; this.z = event.values[2];

View File

@ -353,7 +353,7 @@ public class Capture extends Plugin {
try { try {
// File properties // File properties
obj.put("name", fp.getName()); 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 // 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 // are reported as video/3gpp. I'm doing this hacky check of the URI to see if it

View File

@ -18,7 +18,6 @@ package org.apache.cordova;
import java.util.HashMap; import java.util.HashMap;
import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.util.Log; import android.util.Log;
import android.webkit.WebView; import android.webkit.WebView;
@ -48,21 +47,21 @@ public abstract class ContactAccessor {
* @return true if the key data is required * @return true if the key data is required
*/ */
protected boolean isRequired(String key, HashMap<String,Boolean> map) { protected boolean isRequired(String key, HashMap<String,Boolean> map) {
Boolean retVal = map.get(key); Boolean retVal = map.get(key);
return (retVal == null) ? false : retVal.booleanValue(); return (retVal == null) ? false : retVal.booleanValue();
} }
/** /**
* Create a hash map of what data needs to be populated in the Contact object * Create a hash map of what data needs to be populated in the Contact object
* @param fields the list of fields to populate * @param fields the list of fields to populate
* @return the hash map of required data * @return the hash map of required data
*/ */
protected HashMap<String,Boolean> buildPopulationSet(JSONArray fields) { protected HashMap<String,Boolean> buildPopulationSet(JSONArray fields) {
HashMap<String,Boolean> map = new HashMap<String,Boolean>(); HashMap<String,Boolean> map = new HashMap<String,Boolean>();
String key; String key;
try { try {
if (fields.length() == 1 && fields.getString(0).equals("*")) { if (fields.length() == 1 && fields.getString(0).equals("*")) {
map.put("displayName", true); map.put("displayName", true);
map.put("name", true); map.put("name", true);
map.put("nickname", true); map.put("nickname", true);
@ -76,90 +75,90 @@ public abstract class ContactAccessor {
map.put("urls", true); map.put("urls", true);
map.put("photos", true); map.put("photos", true);
map.put("categories", 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")) { else if (key.startsWith("photos")) {
map.put("photos", true); map.put("photos", true);
} }
else if (key.startsWith("categories")) { else if (key.startsWith("categories")) {
map.put("categories", true); 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 * Convenience method to get a string from a JSON object. Saves a
* lot of try/catch writing. * lot of try/catch writing.
* If the property is not found in the object null will be returned. * If the property is not found in the object null will be returned.
* *
* @param obj contact object to search * @param obj contact object to search
* @param property to be looked up * @param property to be looked up
* @return The value of the property * @return The value of the property
*/ */
protected String getJsonString(JSONObject obj, String property) { protected String getJsonString(JSONObject obj, String property) {
String value = null; String value = null;
try { try {
if (obj != null) { if (obj != null) {
value = obj.getString(property); value = obj.getString(property);
if (value.equals("null")) { if (value.equals("null")) {
Log.d(LOG_TAG, property + " is string called 'null'"); Log.d(LOG_TAG, property + " is string called 'null'");
value = 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. * Handles adding a JSON Contact object into the database.
* @return TODO * @return TODO
*/ */
public abstract String save(JSONObject contact); public abstract String save(JSONObject contact);
/** /**
* Handles searching through SDK-specific contacts API. * Handles searching through SDK-specific contacts API.
@ -175,25 +174,25 @@ public abstract class ContactAccessor {
/** /**
* Handles removing a contact from the database. * 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 * A class that represents the where clause to be used in the database query
*/ */
class WhereOptions { class WhereOptions {
private String where; private String where;
private String[] whereArgs; private String[] whereArgs;
public void setWhere(String where) { public void setWhere(String where) {
this.where = 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;
}
}
} }

View File

@ -25,7 +25,10 @@ import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.net.URL; import java.net.URL;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
@ -111,7 +114,7 @@ public class ContactAccessorSdk5 extends ContactAccessor {
dbMap.put("organizations.name", ContactsContract.CommonDataKinds.Organization.COMPANY); dbMap.put("organizations.name", ContactsContract.CommonDataKinds.Organization.COMPANY);
dbMap.put("organizations.department", ContactsContract.CommonDataKinds.Organization.DEPARTMENT); dbMap.put("organizations.department", ContactsContract.CommonDataKinds.Organization.DEPARTMENT);
dbMap.put("organizations.title", ContactsContract.CommonDataKinds.Organization.TITLE); 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("note", ContactsContract.CommonDataKinds.Note.NOTE);
dbMap.put("photos.value", ContactsContract.CommonDataKinds.Photo.CONTENT_ITEM_TYPE); dbMap.put("photos.value", ContactsContract.CommonDataKinds.Photo.CONTENT_ITEM_TYPE);
//dbMap.put("categories.value", null); //dbMap.put("categories.value", null);
@ -437,14 +440,14 @@ public class ContactAccessorSdk5 extends ContactAccessor {
contact.put("ims", ims); contact.put("ims", ims);
} }
if (websites.length() > 0) { if (websites.length() > 0) {
contact.put("websites", websites); contact.put("urls", websites);
} }
if (photos.length() > 0) { if (photos.length() > 0) {
contact.put("photos", photos); contact.put("photos", photos);
} }
} }
catch (JSONException e) { catch (JSONException e) {
Log.e(LOG_TAG,e.getMessage(),e); Log.e(LOG_TAG,e.getMessage(),e);
} }
return contact; return contact;
} }
@ -579,10 +582,24 @@ public class ContactAccessorSdk5 extends ContactAccessor {
whereArgs.add(searchTerm); whereArgs.add(searchTerm);
whereArgs.add(ContactsContract.CommonDataKinds.Organization.CONTENT_ITEM_TYPE); whereArgs.add(ContactsContract.CommonDataKinds.Organization.CONTENT_ITEM_TYPE);
} }
// else if (key.startsWith("birthday")) { else if (key.startsWith("birthday")) {
// where.add("(" + dbMap.get(key) + " LIKE ? AND " try {
// + ContactsContract.Data.MIMETYPE + " = ? )"); 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")) { else if (key.startsWith("note")) {
where.add("(" + dbMap.get(key) + " LIKE ? AND " where.add("(" + dbMap.get(key) + " LIKE ? AND "
+ ContactsContract.Data.MIMETYPE + " = ? )"); + ContactsContract.Data.MIMETYPE + " = ? )");
@ -1149,7 +1166,7 @@ public class ContactAccessorSdk5 extends ContactAccessor {
// Modify urls // Modify urls
JSONArray websites = null; JSONArray websites = null;
try { try {
websites = contact.getJSONArray("websites"); websites = contact.getJSONArray("urls");
if (websites != null) { if (websites != null) {
for (int i=0; i<websites.length(); i++) { for (int i=0; i<websites.length(); i++) {
JSONObject website = (JSONObject)websites.get(i); JSONObject website = (JSONObject)websites.get(i);

View File

@ -175,7 +175,7 @@ public class Storage extends Plugin {
System.out.println("Storage.executeSql(): Error=" + ex.getMessage()); System.out.println("Storage.executeSql(): Error=" + ex.getMessage());
// Send error message back to JavaScript // 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 + "');");
} }
} }