Massive Merge Commit of DEATH TO SPACES

This commit is contained in:
Joe Bowser 2012-06-06 14:35:45 -07:00
commit 81195db87d
55 changed files with 882 additions and 951 deletions

View File

@ -18,12 +18,7 @@
*/
package org.apache.cordova;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.apache.cordova.api.CordovaInterface;
import org.apache.cordova.api.Plugin;
import org.apache.cordova.api.PluginResult;
@ -35,8 +30,6 @@ import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.location.Location;
import android.util.Log;
import android.content.Context;
/**
@ -258,7 +251,6 @@ public class AccelListener extends Plugin implements SensorEventListener {
private void setStatus(int status) {
this.status = status;
}
private JSONObject getAccelerationJSON() {
JSONObject r = new JSONObject();
try {

View File

@ -22,7 +22,6 @@ import android.content.Context;
import android.media.AudioManager;
import java.util.ArrayList;
//import org.apache.cordova.api.LOG;
import org.apache.cordova.api.Plugin;
import org.apache.cordova.api.PluginResult;
import org.json.JSONArray;
@ -56,7 +55,6 @@ public class AudioHandler extends Plugin {
/**
* 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.
@ -111,7 +109,6 @@ public class AudioHandler extends Plugin {
/**
* Identifies if action to be executed returns a value and should be run synchronously.
*
* @param action The action to execute
* @return T=returns value
*/
@ -177,7 +174,6 @@ public class AudioHandler extends Plugin {
/**
* Release the audio player instance to save memory.
*
* @param id The id of the audio player
*/
private boolean release(String id) {
@ -192,7 +188,6 @@ public class AudioHandler extends Plugin {
/**
* Start recording and save the specified file.
*
* @param id The id of the audio player
* @param file The name of the file
*/
@ -208,7 +203,6 @@ public class AudioHandler extends Plugin {
/**
* Stop recording and save to the file specified when recording started.
*
* @param id The id of the audio player
*/
public void stopRecordingAudio(String id) {
@ -221,7 +215,6 @@ public class AudioHandler extends Plugin {
/**
* Start or resume playing audio file.
*
* @param id The id of the audio player
* @param file The name of the audio file.
*/
@ -236,8 +229,6 @@ public class AudioHandler extends Plugin {
/**
* Seek to a location.
*
*
* @param id The id of the audio player
* @param miliseconds int: number of milliseconds to skip 1000 = 1 second
*/
@ -250,7 +241,6 @@ public class AudioHandler extends Plugin {
/**
* Pause playing.
*
* @param id The id of the audio player
*/
public void pausePlayingAudio(String id) {
@ -262,7 +252,6 @@ public class AudioHandler extends Plugin {
/**
* Stop playing the audio file.
*
* @param id The id of the audio player
*/
public void stopPlayingAudio(String id) {
@ -276,7 +265,6 @@ public class AudioHandler extends Plugin {
/**
* Get current position of playback.
*
* @param id The id of the audio player
* @return position in msec
*/
@ -290,7 +278,6 @@ public class AudioHandler extends Plugin {
/**
* Get the duration of the audio file.
*
* @param id The id of the audio player
* @param file The name of the audio file.
* @return The duration in msec.

View File

@ -88,7 +88,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
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";
this.tempFile = "/data/data/" + handler.ctx.getActivity().getPackageName() + "/cache/tmprecording.mp3";
}
}
@ -96,7 +96,6 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
* Destroy player and stop audio playing or recording.
*/
public void destroy() {
// Stop any play or record
if (this.mPlayer != null) {
if ((this.state == MEDIA_RUNNING) || (this.state == MEDIA_PAUSED)) {
@ -123,7 +122,6 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
Log.d(LOG_TAG, "AudioPlayer Error: Can't record in play mode.");
this.handler.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", { \"code\":"+MEDIA_ERR_ABORTED+"});");
}
// Make sure we're not already recording
else if (this.recorder == null) {
this.audioFile = file;
@ -162,7 +160,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
f.renameTo(new File(Environment.getExternalStorageDirectory().getAbsolutePath()
+ File.separator + file));
} else {
f.renameTo(new File("/data/data/" + handler.ctx.getPackageName() + "/cache/" + file));
f.renameTo(new File("/data/data/" + handler.ctx.getActivity().getPackageName() + "/cache/" + file));
}
}
@ -178,7 +176,8 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
this.setState(MEDIA_STOPPED);
}
this.moveFile(this.audioFile);
} catch (Exception e) {
}
catch (Exception e) {
e.printStackTrace();
}
}

View File

@ -110,9 +110,8 @@ public class CallbackServer implements Runnable {
*
* @param url The URL of the Cordova app being loaded
*/
@SuppressWarnings("deprecation")
public void init(String url) {
//Log.d(LOG_TAG, "CallbackServer.start("+url+")");
//System.out.println("CallbackServer.start("+url+")");
this.active = false;
this.empty = true;
this.port = 0;
@ -145,7 +144,6 @@ public class CallbackServer implements Runnable {
/**
* Return if polling is being used instead of XHR.
*
* @return
*/
public boolean usePolling() {
@ -154,7 +152,6 @@ public class CallbackServer implements Runnable {
/**
* Get the port that this server is running on.
*
* @return
*/
public int getPort() {
@ -163,7 +160,6 @@ public class CallbackServer implements Runnable {
/**
* Get the security token that this server requires when calling getJavascript().
*
* @return
*/
public String getToken() {

View File

@ -305,7 +305,6 @@ public class CameraLauncher extends Plugin {
} catch (IOException e) {
e.printStackTrace();
}
// If CAMERA
if (srcType == CAMERA) {
// If image available

View File

@ -54,7 +54,7 @@ public class Capture extends Plugin {
// private static final int CAPTURE_APPLICATION_BUSY = 1;
// private static final int CAPTURE_INVALID_ARGUMENT = 2;
private static final int CAPTURE_NO_MEDIA_FILES = 3;
// private static final int CAPTURE_NOT_SUPPORTED = 20;
private static final int CAPTURE_NOT_SUPPORTED = 20;
private String callbackId; // The ID of the callback to be invoked with our result
private long limit; // the number of pics/vids/clips to take

View File

@ -25,10 +25,7 @@ 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;
@ -115,7 +112,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.START_DATE);
dbMap.put("birthday", ContactsContract.CommonDataKinds.Event.CONTENT_ITEM_TYPE);
dbMap.put("note", ContactsContract.CommonDataKinds.Note.NOTE);
dbMap.put("photos.value", ContactsContract.CommonDataKinds.Photo.CONTENT_ITEM_TYPE);
//dbMap.put("categories.value", null);
@ -581,30 +578,26 @@ public class ContactAccessorSdk5 extends ContactAccessor {
whereArgs.add(searchTerm);
whereArgs.add(ContactsContract.CommonDataKinds.Organization.CONTENT_ITEM_TYPE);
}
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("birthday")) {
// where.add("(" + dbMap.get(key) + " LIKE ? AND "
// + ContactsContract.Data.MIMETYPE + " = ? )");
// }
else if (key.startsWith("note")) {
where.add("(" + dbMap.get(key) + " LIKE ? AND "
+ ContactsContract.Data.MIMETYPE + " = ? )");
whereArgs.add(searchTerm);
whereArgs.add(ContactsContract.CommonDataKinds.Note.CONTENT_ITEM_TYPE);
}
else if (key.startsWith("urls")) {
where.add("(" + dbMap.get(key) + " LIKE ? AND "
+ ContactsContract.Data.MIMETYPE + " = ? )");
whereArgs.add(searchTerm);
whereArgs.add(ContactsContract.CommonDataKinds.Website.CONTENT_ITEM_TYPE);
}
}
} catch (JSONException e) {
Log.e(LOG_TAG, e.getMessage(), e);
}
// Creating the where string
StringBuffer selection = new StringBuffer();
@ -1155,35 +1148,6 @@ public class ContactAccessorSdk5 extends ContactAccessor {
.build());
}
// Modify urls
JSONArray websites = null;
try {
websites = contact.getJSONArray("urls");
if (websites != null) {
for (int i=0; i<websites.length(); i++) {
JSONObject website = (JSONObject)websites.get(i);
String websiteId = getJsonString(website, "id");
// This is a new website so do a DB insert
if (websiteId==null) {
ContentValues contentValues = new ContentValues();
contentValues.put(ContactsContract.Data.RAW_CONTACT_ID, rawId);
contentValues.put(ContactsContract.Data.MIMETYPE, ContactsContract.CommonDataKinds.Website.CONTENT_ITEM_TYPE);
contentValues.put(ContactsContract.CommonDataKinds.Website.DATA, getJsonString(website, "value"));
contentValues.put(ContactsContract.CommonDataKinds.Website.TYPE, getContactType(getJsonString(website, "type")));
ops.add(ContentProviderOperation.newInsert(
ContactsContract.Data.CONTENT_URI).withValues(contentValues).build());
}
// This is an existing website so do a DB update
else {
ops.add(ContentProviderOperation.newUpdate(ContactsContract.Data.CONTENT_URI)
.withSelection(ContactsContract.Data.CONTACT_ID + "=? AND " +
ContactsContract.Data.MIMETYPE + "=?",
new String[] { id, ContactsContract.CommonDataKinds.Nickname.CONTENT_ITEM_TYPE })
.withValue(ContactsContract.CommonDataKinds.Nickname.NAME, nickname)
.build());
}
// Modify urls
JSONArray websites = null;
try {
@ -1963,3 +1927,4 @@ public class ContactAccessorSdk5 extends ContactAccessor {
return stringType;
}
}

View File

@ -37,7 +37,6 @@ public class DirectoryManager {
/**
* Determine if a file or directory exists.
*
* @param name The name of the file to check.
* @return T=exists, F=not found
*/

View File

@ -173,6 +173,9 @@ public class DroidGap extends Activity implements CordovaInterface {
protected int splashscreen = 0;
protected int splashscreenTime = 0;
// LoadUrl timeout value in msec (default of 20 sec)
protected int loadUrlTimeoutValue = 20000;
// Keep app running when pause is received. (default = true)
// If true, then the JavaScript and native code continue to run in the background
// when another application (activity) is started.
@ -723,7 +726,6 @@ public class DroidGap extends Activity implements CordovaInterface {
* @param message
*/
public void sendJavascript(String statement) {
//We need to check for the null case on the Kindle Fire because it changes the width and height on load
if (this.appView != null && this.appView.callbackServer != null) {
this.appView.callbackServer.sendJavascript(statement);
}

View File

@ -42,7 +42,6 @@ import android.database.Cursor;
import android.net.Uri;
import android.os.Environment;
import android.provider.MediaStore;
//import android.util.Log;
import android.webkit.MimeTypeMap;
//import android.app.Activity;

View File

@ -58,10 +58,7 @@ public class HttpHandler {
HttpGet httpget = new HttpGet(url);
HttpResponse response = httpclient.execute(httpget);
entity = response.getEntity();
} catch (Exception e) {
e.printStackTrace();
return null;
}
} catch (Exception e) { e.printStackTrace(); return null; }
return entity;
}

View File

@ -18,9 +18,6 @@
*/
package org.apache.cordova;
//import java.lang.reflect.Field;
//import android.app.Activity;
import android.os.Bundle;
public class StandAlone extends DroidGap {

View File

@ -141,7 +141,7 @@ public class Storage extends Plugin {
// If no database path, generate from application package
if (this.path == null) {
this.path = this.ctx.getActivity().getDir("database", Context.MODE_PRIVATE).getPath();
this.path = this.ctx.getActivity().getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath();
}
this.dbName = this.path + File.pathSeparator + db + ".db";

View File

@ -21,13 +21,12 @@ package org.apache.cordova.api;
import org.json.JSONArray;
import org.json.JSONObject;
//import android.util.Log;
public class PluginResult {
private final int status;
private final String message;
private boolean keepCallback = false;
public PluginResult(Status status) {
this.status = status.ordinal();
this.message = "'" + PluginResult.StatusMessages[this.status] + "'";