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

@ -1,33 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<projectDescription> <projectDescription>
<name>Cordova</name> <name>Cordova</name>
<comment></comment> <comment></comment>
<projects> <projects>
</projects> </projects>
<buildSpec> <buildSpec>
<buildCommand> <buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name> <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments> <arguments>
</arguments> </arguments>
</buildCommand> </buildCommand>
<buildCommand> <buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name> <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments> <arguments>
</arguments> </arguments>
</buildCommand> </buildCommand>
<buildCommand> <buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name> <name>org.eclipse.jdt.core.javabuilder</name>
<arguments> <arguments>
</arguments> </arguments>
</buildCommand> </buildCommand>
<buildCommand> <buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name> <name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments> <arguments>
</arguments> </arguments>
</buildCommand> </buildCommand>
</buildSpec> </buildSpec>
<natures> <natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature> <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature> <nature>org.eclipse.jdt.core.javanature</nature>
</natures> </natures>
</projectDescription> </projectDescription>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- <!--
Licensed to the Apache Software Foundation (ASF) under one Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file or more contributor license agreements. See the NOTICE file
distributed with this work for additional information distributed with this work for additional information
@ -39,12 +39,12 @@
<uses-permission android:name="android.permission.RECORD_VIDEO"/> <uses-permission android:name="android.permission.RECORD_VIDEO"/>
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.READ_CONTACTS" /> <uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" /> <uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" /> <uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.BROADCAST_STICKY" /> <uses-permission android:name="android.permission.BROADCAST_STICKY" />
<uses-feature android:name="android.hardware.camera" /> <uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" /> <uses-feature android:name="android.hardware.camera.autofocus" />
@ -57,7 +57,7 @@
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity> </activity>
<activity android:name="org.apache.cordova.DroidGap" android:label="@string/app_name" <activity android:name="org.apache.cordova.DroidGap" android:label="@string/app_name"
android:configChanges="orientation|keyboardHidden"> android:configChanges="orientation|keyboardHidden">
<intent-filter> <intent-filter>
</intent-filter> </intent-filter>
@ -65,4 +65,4 @@
</application> </application>
<uses-sdk android:minSdkVersion="2" /> <uses-sdk android:minSdkVersion="2" />
</manifest> </manifest>

View File

@ -1,4 +1,4 @@
<!-- <!--
Licensed to the Apache Software Foundation (ASF) under one Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file or more contributor license agreements. See the NOTICE file
distributed with this work for additional information distributed with this work for additional information

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- <!--
Licensed to the Apache Software Foundation (ASF) under one Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file or more contributor license agreements. See the NOTICE file
distributed with this work for additional information distributed with this work for additional information
@ -51,7 +51,7 @@
--> -->
<property file="ant.properties" /> <property file="ant.properties" />
<!-- We need to setup the double quote. --> <!-- We need to setup the double quote. -->
<property name="dblQuote">"</property> <property name="dblQuote">"</property>
@ -110,10 +110,10 @@
<!-- Combine JavaScript files into one cordova-uncompressed.js file. --> <!-- Combine JavaScript files into one cordova-uncompressed.js file. -->
<target name="build-javascript" depends="clean"> <target name="build-javascript" depends="clean">
<!-- Clean up existing files --> <!-- Clean up existing files -->
<!--<delete file="assets/www/cordova_${version}.js"/>--> <!--<delete file="assets/www/cordova_${version}.js"/>-->
<!-- Create uncompressed JS file --> <!-- Create uncompressed JS file -->
<concat destfile="assets/www/cordova-${version}.js"> <concat destfile="assets/www/cordova-${version}.js">
<filelist dir="assets/js" files="cordova.android.js"/> <filelist dir="assets/js" files="cordova.android.js"/>
@ -121,8 +121,8 @@
<!-- update project files to reference cordova-x.x.x.min.js --> <!-- update project files to reference cordova-x.x.x.min.js -->
<replaceregexp match="cordova(.*)\.js" replace="cordova-${version}.js" byline="true"> <replaceregexp match="cordova(.*)\.js" replace="cordova-${version}.js" byline="true">
<fileset file="assets/www/index.html" /> <fileset file="assets/www/index.html" />
<fileset file="../bin/templates/project/cordova/templates/project/assets/www/index.html" /> <fileset file="../bin/templates/project/cordova/templates/project/assets/www/index.html" />
</replaceregexp> </replaceregexp>
<!-- This is sketchy, but it works, ${dblQuote} does not --> <!-- This is sketchy, but it works, ${dblQuote} does not -->

View File

@ -1,8 +1,8 @@
# This file is automatically generated by Android Tools. # This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED! # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
# #
# This file must be checked in Version Control Systems. # This file must be checked in Version Control Systems.
# #
# To customize properties used by the Ant build system use, # To customize properties used by the Ant build system use,
# "build.properties", and override values to adapt the script to your # "build.properties", and override values to adapt the script to your
# project structure. # project structure.

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- <!--
Licensed to the Apache Software Foundation (ASF) under one Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file or more contributor license agreements. See the NOTICE file
distributed with this work for additional information distributed with this work for additional information
@ -21,9 +21,9 @@
android:orientation="vertical" android:orientation="vertical"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"
> >
<WebView android:id="@+id/appView" <WebView android:id="@+id/appView"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:layout_width="fill_parent" android:layout_width="fill_parent"
/> />
</LinearLayout> </LinearLayout>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- <!--
Licensed to the Apache Software Foundation (ASF) under one Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file or more contributor license agreements. See the NOTICE file
distributed with this work for additional information distributed with this work for additional information

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- <!--
Licensed to the Apache Software Foundation (ASF) under one Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file or more contributor license agreements. See the NOTICE file
distributed with this work for additional information distributed with this work for additional information
@ -18,16 +18,16 @@
under the License. under the License.
--> -->
<cordova> <cordova>
<!-- <!--
access elements control the Android whitelist. access elements control the Android whitelist.
Domains are assumed blocked unless set otherwise Domains are assumed blocked unless set otherwise
--> -->
<access origin="http://127.0.0.1*"/> <!-- allow local pages --> <access origin="http://127.0.0.1*"/> <!-- allow local pages -->
<!-- <access origin="https://example.com" /> allow any secure requests to example.com --> <!-- <access origin="https://example.com" /> allow any secure requests to example.com -->
<!-- <access origin="https://example.com" subdomains="true" /> such as above, but including subdomains, such as www --> <!-- <access origin="https://example.com" subdomains="true" /> such as above, but including subdomains, such as www -->
<!-- <access origin=".*"/> Allow all domains, suggested development use only --> <!-- <access origin=".*"/> Allow all domains, suggested development use only -->
<log level="DEBUG"/> <log level="DEBUG"/>
<preference name="useBrowserHistory" value="false" /> <preference name="useBrowserHistory" value="false" />

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- <!--
Licensed to the Apache Software Foundation (ASF) under one Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file or more contributor license agreements. See the NOTICE file
distributed with this work for additional information distributed with this work for additional information

View File

@ -20,7 +20,7 @@ package com.phonegap.api;
/** /**
* Log to Android logging system. * Log to Android logging system.
* *
* Log message can be a string or a printf formatted string with arguments. * Log message can be a string or a printf formatted string with arguments.
* See http://developer.android.com/reference/java/util/Formatter.html * See http://developer.android.com/reference/java/util/Formatter.html
*/ */

View File

@ -25,7 +25,7 @@ import android.webkit.WebView;
/** /**
* PluginManager is exposed to JavaScript in the Cordova WebView. * PluginManager is exposed to JavaScript in the Cordova WebView.
* *
* Calling native plugin code can be done by calling PluginManager.exec(...) * Calling native plugin code can be done by calling PluginManager.exec(...)
* from JavaScript. * from JavaScript.
*/ */

View File

@ -22,32 +22,32 @@ import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
public class PluginResult extends org.apache.cordova.api.PluginResult { public class PluginResult extends org.apache.cordova.api.PluginResult {
public PluginResult(Status status) {
super(status);
}
public PluginResult(Status status, String message) {
super(status, message);
}
public PluginResult(Status status, JSONArray message) { public PluginResult(Status status) {
super(status);
}
public PluginResult(Status status, String message) {
super(status, message); super(status, message);
} }
public PluginResult(Status status, JSONObject message) { public PluginResult(Status status, JSONArray message) {
super(status, message); super(status, message);
} }
public PluginResult(Status status, int i) { public PluginResult(Status status, JSONObject message) {
super(status, message);
}
public PluginResult(Status status, int i) {
super(status, i); super(status, i);
} }
public PluginResult(Status status, float f) { public PluginResult(Status status, float f) {
super(status, f); super(status, f);
} }
public PluginResult(Status status, boolean b) { public PluginResult(Status status, boolean b) {
super(status, b); super(status, b);
} }
} }

View File

@ -18,12 +18,7 @@
*/ */
package org.apache.cordova; package org.apache.cordova;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map;
import org.apache.cordova.api.CordovaInterface; import org.apache.cordova.api.CordovaInterface;
import org.apache.cordova.api.Plugin; import org.apache.cordova.api.Plugin;
import org.apache.cordova.api.PluginResult; import org.apache.cordova.api.PluginResult;
@ -35,12 +30,10 @@ import android.hardware.Sensor;
import android.hardware.SensorEvent; import android.hardware.SensorEvent;
import android.hardware.SensorEventListener; import android.hardware.SensorEventListener;
import android.hardware.SensorManager; import android.hardware.SensorManager;
import android.location.Location;
import android.util.Log;
import android.content.Context; import android.content.Context;
/** /**
* This class listens to the accelerometer sensor and stores the latest * This class listens to the accelerometer sensor and stores the latest
* acceleration values x,y,z. * acceleration values x,y,z.
*/ */
public class AccelListener extends Plugin implements SensorEventListener { public class AccelListener extends Plugin implements SensorEventListener {
@ -49,7 +42,7 @@ public class AccelListener extends Plugin implements SensorEventListener {
public static int STARTING = 1; public static int STARTING = 1;
public static int RUNNING = 2; public static int RUNNING = 2;
public static int ERROR_FAILED_TO_START = 3; public static int ERROR_FAILED_TO_START = 3;
private float x,y,z; // most recent acceleration values private float x,y,z; // most recent acceleration values
private long timestamp; // time of most recent value private long timestamp; // time of most recent value
private int status; // status of listener private int status; // status of listener
@ -70,11 +63,11 @@ public class AccelListener extends Plugin implements SensorEventListener {
this.timestamp = 0; this.timestamp = 0;
this.setStatus(AccelListener.STOPPED); this.setStatus(AccelListener.STOPPED);
} }
/** /**
* Sets the context of the Command. This can then be used to do things like * Sets the context of the Command. This can then be used to do things like
* get file paths associated with the Activity. * get file paths associated with the Activity.
* *
* @param ctx The context of the main Activity. * @param ctx The context of the main Activity.
*/ */
@ -95,7 +88,7 @@ public class AccelListener extends Plugin implements SensorEventListener {
PluginResult.Status status = PluginResult.Status.NO_RESULT; PluginResult.Status status = PluginResult.Status.NO_RESULT;
String message = ""; String message = "";
PluginResult result = new PluginResult(status, message); PluginResult result = new PluginResult(status, message);
result.setKeepCallback(true); result.setKeepCallback(true);
if (action.equals("start")) { if (action.equals("start")) {
this.callbackId = callbackId; this.callbackId = callbackId;
@ -115,7 +108,7 @@ public class AccelListener extends Plugin implements SensorEventListener {
} }
return result; return result;
} }
/** /**
* Called by AccelBroker when listener is to be shut down. * Called by AccelBroker when listener is to be shut down.
* Stop listener. * Stop listener.
@ -132,15 +125,15 @@ public class AccelListener extends Plugin implements SensorEventListener {
* Start listening for acceleration sensor. * Start listening for acceleration sensor.
* *
* @return status of listener * @return status of listener
*/ */
private int start() { private int start() {
// If already starting or running, then just return // If already starting or running, then just return
if ((this.status == AccelListener.RUNNING) || (this.status == AccelListener.STARTING)) { if ((this.status == AccelListener.RUNNING) || (this.status == AccelListener.STARTING)) {
return this.status; return this.status;
} }
this.setStatus(AccelListener.STARTING); this.setStatus(AccelListener.STARTING);
// Get accelerometer from sensor manager // Get accelerometer from sensor manager
List<Sensor> list = this.sensorManager.getSensorList(Sensor.TYPE_ACCELEROMETER); List<Sensor> list = this.sensorManager.getSensorList(Sensor.TYPE_ACCELEROMETER);
@ -185,7 +178,7 @@ public class AccelListener extends Plugin implements SensorEventListener {
/** /**
* Called when the accuracy of the sensor has changed. * Called when the accuracy of the sensor has changed.
* *
* @param sensor * @param sensor
* @param accuracy * @param accuracy
*/ */
@ -194,7 +187,7 @@ public class AccelListener extends Plugin implements SensorEventListener {
if (sensor.getType() != Sensor.TYPE_ACCELEROMETER) { if (sensor.getType() != Sensor.TYPE_ACCELEROMETER) {
return; return;
} }
// If not running, then just return // If not running, then just return
if (this.status == AccelListener.STOPPED) { if (this.status == AccelListener.STOPPED) {
return; return;
@ -204,7 +197,7 @@ public class AccelListener extends Plugin implements SensorEventListener {
/** /**
* Sensor listener event. * Sensor listener event.
* *
* @param SensorEvent event * @param SensorEvent event
*/ */
public void onSensorChanged(SensorEvent event) { public void onSensorChanged(SensorEvent event) {
@ -218,7 +211,7 @@ public class AccelListener extends Plugin implements SensorEventListener {
return; return;
} }
this.setStatus(AccelListener.RUNNING); this.setStatus(AccelListener.RUNNING);
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
@ -246,7 +239,7 @@ public class AccelListener extends Plugin implements SensorEventListener {
this.error(err, this.callbackId); this.error(err, this.callbackId);
} }
private void win() { private void win() {
// Success return object // Success return object
PluginResult result = new PluginResult(PluginResult.Status.OK, this.getAccelerationJSON()); PluginResult result = new PluginResult(PluginResult.Status.OK, this.getAccelerationJSON());
@ -258,7 +251,6 @@ public class AccelListener extends Plugin implements SensorEventListener {
private void setStatus(int status) { private void setStatus(int status) {
this.status = status; this.status = status;
} }
private JSONObject getAccelerationJSON() { private JSONObject getAccelerationJSON() {
JSONObject r = new JSONObject(); JSONObject r = new JSONObject();
try { try {

View File

@ -96,13 +96,13 @@ public class App extends Plugin {
/** /**
* Load the url into the webview. * Load the url into the webview.
* *
* @param url * @param url
* @param props Properties that can be passed in to the DroidGap activity (i.e. loadingDialog, wait, ...) * @param props Properties that can be passed in to the DroidGap activity (i.e. loadingDialog, wait, ...)
* @throws JSONException * @throws JSONException
*/ */
public void loadUrl(String url, JSONObject props) throws JSONException { public void loadUrl(String url, JSONObject props) throws JSONException {
LOG.d("App", "App.loadUrl(" + url + "," + props + ")"); LOG.d("App", "App.loadUrl("+url+","+props+")");
int wait = 0; int wait = 0;
boolean openExternal = false; boolean openExternal = false;
boolean clearHistory = false; boolean clearHistory = false;
@ -128,13 +128,13 @@ public class App extends Plugin {
} }
else if (value.getClass().equals(String.class)) { else if (value.getClass().equals(String.class)) {
params.put(key, (String) value); params.put(key, (String)value);
} }
else if (value.getClass().equals(Boolean.class)) { else if (value.getClass().equals(Boolean.class)) {
params.put(key, (Boolean) value); params.put(key, (Boolean)value);
} }
else if (value.getClass().equals(Integer.class)) { else if (value.getClass().equals(Integer.class)) {
params.put(key, (Integer) value); params.put(key, (Integer)value);
} }
} }
} }
@ -144,7 +144,7 @@ public class App extends Plugin {
if (wait > 0) { if (wait > 0) {
try { try {
synchronized (this) { synchronized(this) {
this.wait(wait); this.wait(wait);
} }
} catch (InterruptedException e) { } catch (InterruptedException e) {
@ -180,7 +180,7 @@ public class App extends Plugin {
/** /**
* Override the default behavior of the Android back button. * Override the default behavior of the Android back button.
* If overridden, when the back button is pressed, the "backKeyDown" JavaScript event will be fired. * If overridden, when the back button is pressed, the "backKeyDown" JavaScript event will be fired.
* *
* @param override T=override, F=cancel override * @param override T=override, F=cancel override
*/ */
public void overrideBackbutton(boolean override) { public void overrideBackbutton(boolean override) {
@ -190,7 +190,7 @@ public class App extends Plugin {
/** /**
* Return whether the Android back button is overridden by the user. * Return whether the Android back button is overridden by the user.
* *
* @return boolean * @return boolean
*/ */
public boolean isBackbuttonOverridden() { public boolean isBackbuttonOverridden() {

View File

@ -22,7 +22,6 @@ import android.content.Context;
import android.media.AudioManager; import android.media.AudioManager;
import java.util.ArrayList; import java.util.ArrayList;
//import org.apache.cordova.api.LOG;
import org.apache.cordova.api.Plugin; import org.apache.cordova.api.Plugin;
import org.apache.cordova.api.PluginResult; import org.apache.cordova.api.PluginResult;
import org.json.JSONArray; import org.json.JSONArray;
@ -30,12 +29,12 @@ import org.json.JSONException;
import java.util.HashMap; import java.util.HashMap;
/** /**
* This class called by CordovaActivity to play and record audio. * This class called by CordovaActivity to play and record audio.
* The file can be local or over a network using http. * The file can be local or over a network using http.
* *
* Audio formats supported (tested): * Audio formats supported (tested):
* .mp3, .wav * .mp3, .wav
* *
* Local audio files must reside in one of two places: * Local audio files must reside in one of two places:
* android_asset: file name must start with /android_asset/sound.mp3 * android_asset: file name must start with /android_asset/sound.mp3
* sdcard: file name is just sound.mp3 * sdcard: file name is just sound.mp3
@ -56,7 +55,6 @@ public class AudioHandler extends Plugin {
/** /**
* Executes the request and returns PluginResult. * Executes the request and returns PluginResult.
*
* @param action The action to execute. * @param action The action to execute.
* @param args JSONArry of arguments for the plugin. * @param args JSONArry of arguments for the plugin.
* @param callbackId The callback id used when calling back into JavaScript. * @param callbackId The callback id used when calling back into JavaScript.
@ -85,11 +83,11 @@ public class AudioHandler extends Plugin {
else if (action.equals("stopPlayingAudio")) { else if (action.equals("stopPlayingAudio")) {
this.stopPlayingAudio(args.getString(0)); this.stopPlayingAudio(args.getString(0));
} else if (action.equals("setVolume")) { } else if (action.equals("setVolume")) {
try { try {
this.setVolume(args.getString(0), Float.parseFloat(args.getString(1))); this.setVolume(args.getString(0), Float.parseFloat(args.getString(1)));
} catch (NumberFormatException nfe) { } catch (NumberFormatException nfe) {
//no-op //no-op
} }
} else if (action.equals("getCurrentPositionAudio")) { } else if (action.equals("getCurrentPositionAudio")) {
float f = this.getCurrentPositionAudio(args.getString(0)); float f = this.getCurrentPositionAudio(args.getString(0));
return new PluginResult(status, f); return new PluginResult(status, f);
@ -111,7 +109,6 @@ public class AudioHandler extends Plugin {
/** /**
* Identifies if action to be executed returns a value and should be run synchronously. * Identifies if action to be executed returns a value and should be run synchronously.
*
* @param action The action to execute * @param action The action to execute
* @return T=returns value * @return T=returns value
*/ */
@ -136,8 +133,8 @@ public class AudioHandler extends Plugin {
} }
/** /**
* Called when a message is sent to plugin. * Called when a message is sent to plugin.
* *
* @param id The message id * @param id The message id
* @param data The message data * @param data The message data
* @return Object to stop propagation or null * @return Object to stop propagation or null
@ -177,7 +174,6 @@ public class AudioHandler extends Plugin {
/** /**
* Release the audio player instance to save memory. * Release the audio player instance to save memory.
*
* @param id The id of the audio player * @param id The id of the audio player
*/ */
private boolean release(String id) { private boolean release(String id) {
@ -192,7 +188,6 @@ public class AudioHandler extends Plugin {
/** /**
* Start recording and save the specified file. * Start recording and save the specified file.
*
* @param id The id of the audio player * @param id The id of the audio player
* @param file The name of the file * @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. * Stop recording and save to the file specified when recording started.
*
* @param id The id of the audio player * @param id The id of the audio player
*/ */
public void stopRecordingAudio(String id) { public void stopRecordingAudio(String id) {
@ -221,7 +215,6 @@ public class AudioHandler extends Plugin {
/** /**
* Start or resume playing audio file. * Start or resume playing audio file.
*
* @param id The id of the audio player * @param id The id of the audio player
* @param file The name of the audio file. * @param file The name of the audio file.
*/ */
@ -236,8 +229,6 @@ public class AudioHandler extends Plugin {
/** /**
* Seek to a location. * Seek to a location.
*
*
* @param id The id of the audio player * @param id The id of the audio player
* @param miliseconds int: number of milliseconds to skip 1000 = 1 second * @param miliseconds int: number of milliseconds to skip 1000 = 1 second
*/ */
@ -250,7 +241,6 @@ public class AudioHandler extends Plugin {
/** /**
* Pause playing. * Pause playing.
*
* @param id The id of the audio player * @param id The id of the audio player
*/ */
public void pausePlayingAudio(String id) { public void pausePlayingAudio(String id) {
@ -262,7 +252,6 @@ public class AudioHandler extends Plugin {
/** /**
* Stop playing the audio file. * Stop playing the audio file.
*
* @param id The id of the audio player * @param id The id of the audio player
*/ */
public void stopPlayingAudio(String id) { public void stopPlayingAudio(String id) {
@ -276,7 +265,6 @@ public class AudioHandler extends Plugin {
/** /**
* Get current position of playback. * Get current position of playback.
*
* @param id The id of the audio player * @param id The id of the audio player
* @return position in msec * @return position in msec
*/ */
@ -290,7 +278,6 @@ public class AudioHandler extends Plugin {
/** /**
* Get the duration of the audio file. * Get the duration of the audio file.
*
* @param id The id of the audio player * @param id The id of the audio player
* @param file The name of the audio file. * @param file The name of the audio file.
* @return The duration in msec. * @return The duration in msec.
@ -313,7 +300,7 @@ public class AudioHandler extends Plugin {
/** /**
* Set the audio device to be used for playback. * Set the audio device to be used for playback.
* *
* @param output 1=earpiece, 2=speaker * @param output 1=earpiece, 2=speaker
*/ */
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@ -332,7 +319,7 @@ public class AudioHandler extends Plugin {
/** /**
* Get the audio device to be used for playback. * Get the audio device to be used for playback.
* *
* @return 1=earpiece, 2=speaker * @return 1=earpiece, 2=speaker
*/ */
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")

View File

@ -35,7 +35,7 @@ import java.io.IOException;
* This class implements the audio playback and recording capabilities used by Cordova. * This class implements the audio playback and recording capabilities used by Cordova.
* It is called by the AudioHandler Cordova class. * It is called by the AudioHandler Cordova class.
* Only one file can be played or recorded per class instance. * Only one file can be played or recorded per class instance.
* *
* Local audio files must reside in one of two places: * Local audio files must reside in one of two places:
* android_asset: file name must start with /android_asset/sound.mp3 * android_asset: file name must start with /android_asset/sound.mp3
* sdcard: file name is just sound.mp3 * sdcard: file name is just sound.mp3
@ -56,7 +56,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
private static int MEDIA_DURATION = 2; private static int MEDIA_DURATION = 2;
private static int MEDIA_POSITION = 3; private static int MEDIA_POSITION = 3;
private static int MEDIA_ERROR = 9; private static int MEDIA_ERROR = 9;
// Media error codes // Media error codes
private static int MEDIA_ERR_NONE_ACTIVE = 0; private static int MEDIA_ERR_NONE_ACTIVE = 0;
private static int MEDIA_ERR_ABORTED = 1; private static int MEDIA_ERR_ABORTED = 1;
@ -74,7 +74,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
private String tempFile = null; // Temporary recording file name private String tempFile = null; // Temporary recording file name
private MediaPlayer mPlayer = null; // Audio player object private MediaPlayer mPlayer = null; // Audio player object
private boolean prepareOnly = false; private boolean prepareOnly = false;
/** /**
* Constructor. * Constructor.
@ -88,15 +88,14 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
this.tempFile = Environment.getExternalStorageDirectory().getAbsolutePath() + "/tmprecording.mp3"; this.tempFile = Environment.getExternalStorageDirectory().getAbsolutePath() + "/tmprecording.mp3";
} else { } else {
this.tempFile = "/data/data/" + handler.ctx.getPackageName() + "/cache/tmprecording.mp3"; this.tempFile = "/data/data/" + handler.ctx.getActivity().getPackageName() + "/cache/tmprecording.mp3";
} }
} }
/** /**
* Destroy player and stop audio playing or recording. * Destroy player and stop audio playing or recording.
*/ */
public void destroy() { public void destroy() {
// Stop any play or record // Stop any play or record
if (this.mPlayer != null) { if (this.mPlayer != null) {
if ((this.state == MEDIA_RUNNING) || (this.state == MEDIA_PAUSED)) { 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."); 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+"});"); this.handler.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", { \"code\":"+MEDIA_ERR_ABORTED+"});");
} }
// Make sure we're not already recording // Make sure we're not already recording
else if (this.recorder == null) { else if (this.recorder == null) {
this.audioFile = file; this.audioFile = file;
@ -142,43 +140,44 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
this.handler.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", { \"code\":"+MEDIA_ERR_ABORTED+"});"); this.handler.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", { \"code\":"+MEDIA_ERR_ABORTED+"});");
} }
else { else {
Log.d(LOG_TAG, "AudioPlayer Error: Already recording."); Log.d(LOG_TAG, "AudioPlayer Error: Already recording.");
this.handler.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", { \"code\":"+MEDIA_ERR_ABORTED+"});"); this.handler.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", { \"code\":"+MEDIA_ERR_ABORTED+"});");
} }
} }
/** /**
* Save temporary recorded file to specified name * Save temporary recorded file to specified name
* *
* @param file * @param file
*/ */
public void moveFile(String file) { public void moveFile(String file) {
/* this is a hack to save the file as the specified name */ /* this is a hack to save the file as the specified name */
File f = new File(this.tempFile); File f = new File(this.tempFile);
if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
f.renameTo(new File(Environment.getExternalStorageDirectory().getAbsolutePath() f.renameTo(new File(Environment.getExternalStorageDirectory().getAbsolutePath()
+ File.separator + file)); + File.separator + file));
} else { } else {
f.renameTo(new File("/data/data/" + handler.ctx.getPackageName() + "/cache/" + file)); f.renameTo(new File("/data/data/" + handler.ctx.getActivity().getPackageName() + "/cache/" + file));
} }
} }
/** /**
* Stop recording and save to the file specified when recording started. * Stop recording and save to the file specified when recording started.
*/ */
public void stopRecording() { public void stopRecording() {
if (this.recorder != null) { if (this.recorder != null) {
try { try{
if (this.state == MEDIA_RUNNING) { if (this.state == MEDIA_RUNNING) {
this.recorder.stop(); this.recorder.stop();
this.setState(MEDIA_STOPPED); this.setState(MEDIA_STOPPED);
} }
this.moveFile(this.audioFile); this.moveFile(this.audioFile);
} catch (Exception e) { }
catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }

View File

@ -24,46 +24,46 @@ package org.apache.cordova;
public class AuthenticationToken { public class AuthenticationToken {
private String userName; private String userName;
private String password; private String password;
/** /**
* Gets the user name. * Gets the user name.
* *
* @return the user name * @return the user name
*/ */
public String getUserName() { public String getUserName() {
return userName; return userName;
} }
/** /**
* Sets the user name. * Sets the user name.
* *
* @param userName * @param userName
* the new user name * the new user name
*/ */
public void setUserName(String userName) { public void setUserName(String userName) {
this.userName = userName; this.userName = userName;
} }
/** /**
* Gets the password. * Gets the password.
* *
* @return the password * @return the password
*/ */
public String getPassword() { public String getPassword() {
return password; return password;
} }
/** /**
* Sets the password. * Sets the password.
* *
* @param password * @param password
* the new password * the new password
*/ */
public void setPassword(String password) { public void setPassword(String password) {
this.password = password; this.password = password;
} }
} }

View File

@ -47,7 +47,7 @@ public class BatteryListener extends Plugin {
/** /**
* Executes the request and returns PluginResult. * Executes the request and returns PluginResult.
* *
* @param action The action to execute. * @param action The action to execute.
* @param args JSONArry of arguments for the plugin. * @param args JSONArry of arguments for the plugin.
* @param callbackId The callback id used when calling back into JavaScript. * @param callbackId The callback id used when calling back into JavaScript.
@ -76,7 +76,7 @@ public class BatteryListener extends Plugin {
ctx.getActivity().registerReceiver(this.receiver, intentFilter); ctx.getActivity().registerReceiver(this.receiver, intentFilter);
} }
// Don't return any result now, since status results will be sent when events come in from broadcast receiver // Don't return any result now, since status results will be sent when events come in from broadcast receiver
PluginResult pluginResult = new PluginResult(PluginResult.Status.NO_RESULT); PluginResult pluginResult = new PluginResult(PluginResult.Status.NO_RESULT);
pluginResult.setKeepCallback(true); pluginResult.setKeepCallback(true);
return pluginResult; return pluginResult;
@ -115,7 +115,7 @@ public class BatteryListener extends Plugin {
/** /**
* Creates a JSONObject with the current battery information * Creates a JSONObject with the current battery information
* *
* @param batteryIntent the current battery information * @param batteryIntent the current battery information
* @return a JSONObject containing the battery status information * @return a JSONObject containing the battery status information
*/ */
@ -132,7 +132,7 @@ public class BatteryListener extends Plugin {
/** /**
* Updates the JavaScript side whenever the battery changes * Updates the JavaScript side whenever the battery changes
* *
* @param batteryIntent the current battery information * @param batteryIntent the current battery information
* @return * @return
*/ */
@ -142,7 +142,7 @@ public class BatteryListener extends Plugin {
/** /**
* Create a new plugin result and send it back to JavaScript * Create a new plugin result and send it back to JavaScript
* *
* @param connection the network info to set as navigator.connection * @param connection the network info to set as navigator.connection
*/ */
private void sendUpdate(JSONObject info, boolean keepCallback) { private void sendUpdate(JSONObject info, boolean keepCallback) {

View File

@ -31,25 +31,25 @@ import java.util.LinkedList;
* This class provides a way for Java to run JavaScript in the web page that has loaded Cordova. * This class provides a way for Java to run JavaScript in the web page that has loaded Cordova.
* The CallbackServer class implements an XHR server and a polling server with a list of JavaScript * The CallbackServer class implements an XHR server and a polling server with a list of JavaScript
* statements that are to be executed on the web page. * statements that are to be executed on the web page.
* *
* The process flow for XHR is: * The process flow for XHR is:
* 1. JavaScript makes an async XHR call. * 1. JavaScript makes an async XHR call.
* 2. The server holds the connection open until data is available. * 2. The server holds the connection open until data is available.
* 3. The server writes the data to the client and closes the connection. * 3. The server writes the data to the client and closes the connection.
* 4. The server immediately starts listening for the next XHR call. * 4. The server immediately starts listening for the next XHR call.
* 5. The client receives this XHR response, processes it. * 5. The client receives this XHR response, processes it.
* 6. The client sends a new async XHR request. * 6. The client sends a new async XHR request.
* *
* The CallbackServer class requires the following permission in Android manifest file * The CallbackServer class requires the following permission in Android manifest file
* <uses-permission android:name="android.permission.INTERNET" /> * <uses-permission android:name="android.permission.INTERNET" />
* *
* If the device has a proxy set, then XHR cannot be used, so polling must be used instead. * If the device has a proxy set, then XHR cannot be used, so polling must be used instead.
* This can be determined by the client by calling CallbackServer.usePolling(). * This can be determined by the client by calling CallbackServer.usePolling().
* *
* The process flow for polling is: * The process flow for polling is:
* 1. The client calls CallbackServer.getJavascript() to retrieve next statement. * 1. The client calls CallbackServer.getJavascript() to retrieve next statement.
* 2. If statement available, then client processes it. * 2. If statement available, then client processes it.
* 3. The client repeats #1 in loop. * 3. The client repeats #1 in loop.
*/ */
public class CallbackServer implements Runnable { public class CallbackServer implements Runnable {
@ -104,15 +104,14 @@ public class CallbackServer implements Runnable {
/** /**
* Init callback server and start XHR if running local app. * Init callback server and start XHR if running local app.
* *
* If Cordova app is loaded from file://, then we can use XHR * If Cordova app is loaded from file://, then we can use XHR
* otherwise we have to use polling due to cross-domain security restrictions. * otherwise we have to use polling due to cross-domain security restrictions.
* *
* @param url The URL of the Cordova app being loaded * @param url The URL of the Cordova app being loaded
*/ */
@SuppressWarnings("deprecation")
public void init(String url) { public void init(String url) {
//Log.d(LOG_TAG, "CallbackServer.start("+url+")"); //System.out.println("CallbackServer.start("+url+")");
this.active = false; this.active = false;
this.empty = true; this.empty = true;
this.port = 0; this.port = 0;
@ -135,7 +134,7 @@ public class CallbackServer implements Runnable {
/** /**
* Re-init when loading a new HTML page into webview. * Re-init when loading a new HTML page into webview.
* *
* @param url The URL of the Cordova app being loaded * @param url The URL of the Cordova app being loaded
*/ */
public void reinit(String url) { public void reinit(String url) {
@ -145,7 +144,6 @@ public class CallbackServer implements Runnable {
/** /**
* Return if polling is being used instead of XHR. * Return if polling is being used instead of XHR.
*
* @return * @return
*/ */
public boolean usePolling() { public boolean usePolling() {
@ -154,7 +152,6 @@ public class CallbackServer implements Runnable {
/** /**
* Get the port that this server is running on. * Get the port that this server is running on.
*
* @return * @return
*/ */
public int getPort() { public int getPort() {
@ -163,7 +160,6 @@ public class CallbackServer implements Runnable {
/** /**
* Get the security token that this server requires when calling getJavascript(). * Get the security token that this server requires when calling getJavascript().
*
* @return * @return
*/ */
public String getToken() { public String getToken() {
@ -373,10 +369,10 @@ public class CallbackServer implements Runnable {
static final String digits = "0123456789ABCDEF"; static final String digits = "0123456789ABCDEF";
/** /**
* This will encode the return value to JavaScript. We revert the encoding for * This will encode the return value to JavaScript. We revert the encoding for
* common characters that don't require encoding to reduce the size of the string * common characters that don't require encoding to reduce the size of the string
* being passed to JavaScript. * being passed to JavaScript.
* *
* @param s to be encoded * @param s to be encoded
* @param enc encoding type * @param enc encoding type
* @return encoded string * @return encoded string

View File

@ -46,7 +46,7 @@ import android.provider.MediaStore;
/** /**
* This class launches the camera view, allows the user to take a picture, closes the camera view, * This class launches the camera view, allows the user to take a picture, closes the camera view,
* and returns the captured image. When the camera view is closed, the screen displayed before * and returns the captured image. When the camera view is closed, the screen displayed before
* the camera view was shown is redisplayed. * the camera view was shown is redisplayed.
*/ */
public class CameraLauncher extends Plugin { public class CameraLauncher extends Plugin {
@ -73,7 +73,7 @@ public class CameraLauncher extends Plugin {
private int mQuality; // Compression quality hint (0-100: 0=low quality & high compression, 100=compress of max quality) private int mQuality; // Compression quality hint (0-100: 0=low quality & high compression, 100=compress of max quality)
private int targetWidth; // desired width of the image private int targetWidth; // desired width of the image
private int targetHeight; // desired height of the image private int targetHeight; // desired height of the image
private Uri imageUri; // Uri of captured image private Uri imageUri; // Uri of captured image
private int encodingType; // Type of encoding to use private int encodingType; // Type of encoding to use
private int mediaType; // What type of media to retrieve private int mediaType; // What type of media to retrieve
@ -99,7 +99,7 @@ public class CameraLauncher extends Plugin {
/** /**
* Executes the request and returns PluginResult. * Executes the request and returns PluginResult.
* *
* @param action The action to execute. * @param action The action to execute.
* @param args JSONArry of arguments for the plugin. * @param args JSONArry of arguments for the plugin.
* @param callbackId The callback id used when calling back into JavaScript. * @param callbackId The callback id used when calling back into JavaScript.
@ -153,15 +153,15 @@ public class CameraLauncher extends Plugin {
* Take a picture with the camera. * Take a picture with the camera.
* When an image is captured or the camera view is cancelled, the result is returned * When an image is captured or the camera view is cancelled, the result is returned
* in CordovaActivity.onActivityResult, which forwards the result to this.onActivityResult. * in CordovaActivity.onActivityResult, which forwards the result to this.onActivityResult.
* *
* The image can either be returned as a base64 string or a URI that points to the file. * The image can either be returned as a base64 string or a URI that points to the file.
* To display base64 string in an img tag, set the source to: * To display base64 string in an img tag, set the source to:
* img.src="data:image/jpeg;base64,"+result; * img.src="data:image/jpeg;base64,"+result;
* or to display URI in an img tag * or to display URI in an img tag
* img.src=result; * img.src=result;
* *
* @param quality Compression quality hint (0-100: 0=low quality & high compression, 100=compress of max quality) * @param quality Compression quality hint (0-100: 0=low quality & high compression, 100=compress of max quality)
* @param returnType Set the type of image to return. * @param returnType Set the type of image to return.
*/ */
public void takePicture(int returnType, int encodingType) { public void takePicture(int returnType, int encodingType) {
// Save the number of images currently on disk for later // Save the number of images currently on disk for later
@ -185,7 +185,7 @@ public class CameraLauncher extends Plugin {
/** /**
* Create a file in the applications temporary directory based upon the supplied encoding. * Create a file in the applications temporary directory based upon the supplied encoding.
* *
* @param encodingType of the image to be taken * @param encodingType of the image to be taken
* @return a File object pointing to the temporary picture * @return a File object pointing to the temporary picture
*/ */
@ -203,10 +203,10 @@ public class CameraLauncher extends Plugin {
/** /**
* Get image from photo library. * Get image from photo library.
* *
* @param quality Compression quality hint (0-100: 0=low quality & high compression, 100=compress of max quality) * @param quality Compression quality hint (0-100: 0=low quality & high compression, 100=compress of max quality)
* @param srcType The album to get image from. * @param srcType The album to get image from.
* @param returnType Set the type of image to return. * @param returnType Set the type of image to return.
*/ */
// TODO: Images selected from SDCARD don't display correctly, but from CAMERA ALBUM do! // TODO: Images selected from SDCARD don't display correctly, but from CAMERA ALBUM do!
public void getImage(int srcType, int returnType) { public void getImage(int srcType, int returnType) {
@ -220,7 +220,7 @@ public class CameraLauncher extends Plugin {
title = GET_VIDEO; title = GET_VIDEO;
} }
else if (this.mediaType == ALLMEDIA) { else if (this.mediaType == ALLMEDIA) {
// I wanted to make the type 'image/*, video/*' but this does not work on all versions // I wanted to make the type 'image/*, video/*' but this does not work on all versions
// of android so I had to go with the wildcard search. // of android so I had to go with the wildcard search.
intent.setType("*/*"); intent.setType("*/*");
title = GET_All; title = GET_All;
@ -236,9 +236,9 @@ public class CameraLauncher extends Plugin {
/** /**
* Scales the bitmap according to the requested size. * Scales the bitmap according to the requested size.
* *
* @param bitmap The bitmap to scale. * @param bitmap The bitmap to scale.
* @return Bitmap A new Bitmap object of the same bitmap after scaling. * @return Bitmap A new Bitmap object of the same bitmap after scaling.
*/ */
public Bitmap scaleBitmap(Bitmap bitmap) { public Bitmap scaleBitmap(Bitmap bitmap) {
int newWidth = this.targetWidth; int newWidth = this.targetWidth;
@ -274,16 +274,16 @@ public class CameraLauncher extends Plugin {
newWidth = (newHeight * origWidth) / origHeight; newWidth = (newHeight * origWidth) / origHeight;
} }
} }
Bitmap retval = Bitmap.createScaledBitmap(bitmap, newWidth, newHeight, true); Bitmap retval = Bitmap.createScaledBitmap(bitmap, newWidth, newHeight, true);
bitmap.recycle(); bitmap.recycle();
return retval; return retval;
} }
/** /**
* Called when the camera view exits. * Called when the camera view exits.
* *
* @param requestCode The request code originally supplied to startActivityForResult(), * @param requestCode The request code originally supplied to startActivityForResult(),
* allowing you to identify who this result came from. * allowing you to identify who this result came from.
* @param resultCode The integer result code returned by the child activity through its setResult(). * @param resultCode The integer result code returned by the child activity through its setResult().
* @param intent An Intent, which can return result data to the caller (various data can be attached to Intent "extras"). * @param intent An Intent, which can return result data to the caller (various data can be attached to Intent "extras").
@ -305,7 +305,6 @@ public class CameraLauncher extends Plugin {
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
// If CAMERA // If CAMERA
if (srcType == CAMERA) { if (srcType == CAMERA) {
// If image available // If image available
@ -415,7 +414,7 @@ public class CameraLauncher extends Plugin {
matrix.setRotate(rotate); matrix.setRotate(rotate);
bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true); bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
} }
bitmap = scaleBitmap(bitmap); bitmap = scaleBitmap(bitmap);
this.processPicture(bitmap); this.processPicture(bitmap);
bitmap.recycle(); bitmap.recycle();
bitmap = null; bitmap = null;
@ -474,7 +473,7 @@ public class CameraLauncher extends Plugin {
/** /**
* Creates a cursor that can be used to determine how many images we have. * Creates a cursor that can be used to determine how many images we have.
* *
* @return a cursor * @return a cursor
*/ */
private Cursor queryImgDB() { private Cursor queryImgDB() {
@ -488,9 +487,9 @@ public class CameraLauncher extends Plugin {
/** /**
* Used to find out if we are in a situation where the Camera Intent adds to images * Used to find out if we are in a situation where the Camera Intent adds to images
* to the content store. If we are using a FILE_URI and the number of images in the DB * to the content store. If we are using a FILE_URI and the number of images in the DB
* increases by 2 we have a duplicate, when using a DATA_URL the number is 1. * increases by 2 we have a duplicate, when using a DATA_URL the number is 1.
* *
* @param type FILE_URI or DATA_URL * @param type FILE_URI or DATA_URL
*/ */
private void checkForDuplicateImage(int type) { private void checkForDuplicateImage(int type) {
@ -536,7 +535,7 @@ public class CameraLauncher extends Plugin {
/** /**
* Send error message to JavaScript. * Send error message to JavaScript.
* *
* @param err * @param err
*/ */
public void failPicture(String err) { public void failPicture(String err) {

View File

@ -54,13 +54,13 @@ public class Capture extends Plugin {
// private static final int CAPTURE_APPLICATION_BUSY = 1; // private static final int CAPTURE_APPLICATION_BUSY = 1;
// private static final int CAPTURE_INVALID_ARGUMENT = 2; // private static final int CAPTURE_INVALID_ARGUMENT = 2;
private static final int CAPTURE_NO_MEDIA_FILES = 3; 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 String callbackId; // The ID of the callback to be invoked with our result
private long limit; // the number of pics/vids/clips to take private long limit; // the number of pics/vids/clips to take
private double duration; // optional duration parameter for video recording private double duration; // optional duration parameter for video recording
private JSONArray results; // The array of results to be returned to the user private JSONArray results; // The array of results to be returned to the user
private Uri imageUri; // Uri of captured image private Uri imageUri; // Uri of captured image
//private CordovaInterface cordova; //private CordovaInterface cordova;
@ -110,7 +110,7 @@ public class Capture extends Plugin {
/** /**
* Provides the media data file data depending on it's mime type * Provides the media data file data depending on it's mime type
* *
* @param filePath path to the file * @param filePath path to the file
* @param mimeType of the file * @param mimeType of the file
* @return a MediaFileData object * @return a MediaFileData object
@ -149,7 +149,7 @@ public class Capture extends Plugin {
/** /**
* Get the Image specific attributes * Get the Image specific attributes
* *
* @param filePath path to the file * @param filePath path to the file
* @param obj represents the Media File Data * @param obj represents the Media File Data
* @return a JSONObject that represents the Media File Data * @return a JSONObject that represents the Media File Data
@ -165,7 +165,7 @@ public class Capture extends Plugin {
/** /**
* Get the Image specific attributes * Get the Image specific attributes
* *
* @param filePath path to the file * @param filePath path to the file
* @param obj represents the Media File Data * @param obj represents the Media File Data
* @param video if true get video attributes as well * @param video if true get video attributes as well
@ -223,13 +223,13 @@ public class Capture extends Plugin {
} }
/** /**
* Called when the video view exits. * Called when the video view exits.
* *
* @param requestCode The request code originally supplied to startActivityForResult(), * @param requestCode The request code originally supplied to startActivityForResult(),
* allowing you to identify who this result came from. * allowing you to identify who this result came from.
* @param resultCode The integer result code returned by the child activity through its setResult(). * @param resultCode The integer result code returned by the child activity through its setResult().
* @param intent An Intent, which can return result data to the caller (various data can be attached to Intent "extras"). * @param intent An Intent, which can return result data to the caller (various data can be attached to Intent "extras").
* @throws JSONException * @throws JSONException
*/ */
public void onActivityResult(int requestCode, int resultCode, Intent intent) { public void onActivityResult(int requestCode, int resultCode, Intent intent) {
@ -349,10 +349,10 @@ public class Capture extends Plugin {
/** /**
* Creates a JSONObject that represents a File from the Uri * Creates a JSONObject that represents a File from the Uri
* *
* @param data the Uri of the audio/image/video * @param data the Uri of the audio/image/video
* @return a JSONObject that represents a File * @return a JSONObject that represents a File
* @throws IOException * @throws IOException
*/ */
private JSONObject createMediaFile(Uri data) { private JSONObject createMediaFile(Uri data) {
File fp = new File(FileUtils.getRealPathFromURI(data, this.ctx)); File fp = new File(FileUtils.getRealPathFromURI(data, this.ctx));
@ -398,7 +398,7 @@ public class Capture extends Plugin {
/** /**
* Send error message to JavaScript. * Send error message to JavaScript.
* *
* @param err * @param err
*/ */
public void fail(JSONObject err) { public void fail(JSONObject err) {

View File

@ -66,7 +66,7 @@ public class CompassListener extends Plugin implements SensorEventListener {
/** /**
* Sets the context of the Command. This can then be used to do things like * Sets the context of the Command. This can then be used to do things like
* get file paths associated with the Activity. * get file paths associated with the Activity.
* *
* @param ctx The context of the main Activity. * @param ctx The context of the main Activity.
*/ */
public void setContext(CordovaInterface ctx) { public void setContext(CordovaInterface ctx) {
@ -76,7 +76,7 @@ public class CompassListener extends Plugin implements SensorEventListener {
/** /**
* Executes the request and returns PluginResult. * Executes the request and returns PluginResult.
* *
* @param action The action to execute. * @param action The action to execute.
* @param args JSONArry of arguments for the plugin. * @param args JSONArry of arguments for the plugin.
* @param callbackId The callback id used when calling back into JavaScript. * @param callbackId The callback id used when calling back into JavaScript.
@ -139,7 +139,7 @@ public class CompassListener extends Plugin implements SensorEventListener {
/** /**
* Identifies if action to be executed returns a value and should be run synchronously. * Identifies if action to be executed returns a value and should be run synchronously.
* *
* @param action The action to execute * @param action The action to execute
* @return T=returns value * @return T=returns value
*/ */
@ -172,7 +172,7 @@ public class CompassListener extends Plugin implements SensorEventListener {
/** /**
* Start listening for compass sensor. * Start listening for compass sensor.
* *
* @return status of listener * @return status of listener
*/ */
public int start() { public int start() {
@ -213,12 +213,12 @@ public class CompassListener extends Plugin implements SensorEventListener {
} }
public void onAccuracyChanged(Sensor sensor, int accuracy) { public void onAccuracyChanged(Sensor sensor, int accuracy) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
/** /**
* Sensor listener event. * Sensor listener event.
* *
* @param SensorEvent event * @param SensorEvent event
*/ */
public void onSensorChanged(SensorEvent event) { public void onSensorChanged(SensorEvent event) {
@ -239,7 +239,7 @@ public class CompassListener extends Plugin implements SensorEventListener {
/** /**
* Get status of compass sensor. * Get status of compass sensor.
* *
* @return status * @return status
*/ */
public int getStatus() { public int getStatus() {
@ -248,7 +248,7 @@ public class CompassListener extends Plugin implements SensorEventListener {
/** /**
* Get the most recent compass heading. * Get the most recent compass heading.
* *
* @return heading * @return heading
*/ */
public float getHeading() { public float getHeading() {
@ -258,7 +258,7 @@ public class CompassListener extends Plugin implements SensorEventListener {
/** /**
* Set the timeout to turn off compass sensor if getHeading() hasn't been called. * Set the timeout to turn off compass sensor if getHeading() hasn't been called.
* *
* @param timeout Timeout in msec. * @param timeout Timeout in msec.
*/ */
public void setTimeout(long timeout) { public void setTimeout(long timeout) {
@ -267,7 +267,7 @@ public class CompassListener extends Plugin implements SensorEventListener {
/** /**
* Get the timeout to turn off compass sensor if getHeading() hasn't been called. * Get the timeout to turn off compass sensor if getHeading() hasn't been called.
* *
* @return timeout in msec * @return timeout in msec
*/ */
public long getTimeout() { public long getTimeout() {
@ -284,7 +284,7 @@ public class CompassListener extends Plugin implements SensorEventListener {
/** /**
* Create the CompassHeading JSON object to be returned to JavaScript * Create the CompassHeading JSON object to be returned to JavaScript
* *
* @return a compass heading * @return a compass heading
*/ */
private JSONObject getCompassHeading() { private JSONObject getCompassHeading() {
@ -293,7 +293,7 @@ public class CompassListener extends Plugin implements SensorEventListener {
try { try {
obj.put("magneticHeading", this.getHeading()); obj.put("magneticHeading", this.getHeading());
obj.put("trueHeading", this.getHeading()); obj.put("trueHeading", this.getHeading());
// Since the magnetic and true heading are always the same our and accuracy // Since the magnetic and true heading are always the same our and accuracy
// is defined as the difference between true and magnetic always return zero // is defined as the difference between true and magnetic always return zero
obj.put("headingAccuracy", 0); obj.put("headingAccuracy", 0);
obj.put("timestamp", this.timeStamp); obj.put("timestamp", this.timeStamp);

View File

@ -41,9 +41,9 @@ public abstract class ContactAccessor {
protected WebView mView; protected WebView mView;
/** /**
* Check to see if the data associated with the key is required to * Check to see if the data associated with the key is required to
* be populated in the Contact object. * be populated in the Contact object.
* @param key * @param key
* @param map created by running buildPopulationSet. * @param map created by running buildPopulationSet.
* @return true if the key data is required * @return true if the key data is required
*/ */
@ -51,7 +51,7 @@ public abstract class ContactAccessor {
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
@ -59,7 +59,7 @@ public abstract class ContactAccessor {
*/ */
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("*")) {
@ -128,12 +128,12 @@ public abstract class ContactAccessor {
} }
return map; 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
@ -151,7 +151,7 @@ public abstract class ContactAccessor {
} }
catch (JSONException e) { catch (JSONException e) {
Log.d(LOG_TAG, "Could not get = " + e.getMessage()); Log.d(LOG_TAG, "Could not get = " + e.getMessage());
} }
return value; return value;
} }
@ -168,7 +168,7 @@ public abstract class ContactAccessor {
/** /**
* Handles searching through SDK-specific contacts API. * Handles searching through SDK-specific contacts API.
* @throws JSONException * @throws JSONException
*/ */
public abstract JSONObject getContactById(String id) throws JSONException; public abstract JSONObject getContactById(String id) throws JSONException;

View File

@ -25,10 +25,7 @@ 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;
@ -88,39 +85,39 @@ public class ContactAccessorSdk5 extends ContactAccessor {
*/ */
private static final Map<String, String> dbMap = new HashMap<String, String>(); private static final Map<String, String> dbMap = new HashMap<String, String>();
static { static {
dbMap.put("id", ContactsContract.Data.CONTACT_ID); dbMap.put("id", ContactsContract.Data.CONTACT_ID);
dbMap.put("displayName", ContactsContract.Contacts.DISPLAY_NAME); dbMap.put("displayName", ContactsContract.Contacts.DISPLAY_NAME);
dbMap.put("name", ContactsContract.CommonDataKinds.StructuredName.DISPLAY_NAME); dbMap.put("name", ContactsContract.CommonDataKinds.StructuredName.DISPLAY_NAME);
dbMap.put("name.formatted", ContactsContract.CommonDataKinds.StructuredName.DISPLAY_NAME); dbMap.put("name.formatted", ContactsContract.CommonDataKinds.StructuredName.DISPLAY_NAME);
dbMap.put("name.familyName", ContactsContract.CommonDataKinds.StructuredName.FAMILY_NAME); dbMap.put("name.familyName", ContactsContract.CommonDataKinds.StructuredName.FAMILY_NAME);
dbMap.put("name.givenName", ContactsContract.CommonDataKinds.StructuredName.GIVEN_NAME); dbMap.put("name.givenName", ContactsContract.CommonDataKinds.StructuredName.GIVEN_NAME);
dbMap.put("name.middleName", ContactsContract.CommonDataKinds.StructuredName.MIDDLE_NAME); dbMap.put("name.middleName", ContactsContract.CommonDataKinds.StructuredName.MIDDLE_NAME);
dbMap.put("name.honorificPrefix", ContactsContract.CommonDataKinds.StructuredName.PREFIX); dbMap.put("name.honorificPrefix", ContactsContract.CommonDataKinds.StructuredName.PREFIX);
dbMap.put("name.honorificSuffix", ContactsContract.CommonDataKinds.StructuredName.SUFFIX); dbMap.put("name.honorificSuffix", ContactsContract.CommonDataKinds.StructuredName.SUFFIX);
dbMap.put("nickname", ContactsContract.CommonDataKinds.Nickname.NAME); dbMap.put("nickname", ContactsContract.CommonDataKinds.Nickname.NAME);
dbMap.put("phoneNumbers", ContactsContract.CommonDataKinds.Phone.NUMBER); dbMap.put("phoneNumbers", ContactsContract.CommonDataKinds.Phone.NUMBER);
dbMap.put("phoneNumbers.value", ContactsContract.CommonDataKinds.Phone.NUMBER); dbMap.put("phoneNumbers.value", ContactsContract.CommonDataKinds.Phone.NUMBER);
dbMap.put("emails", ContactsContract.CommonDataKinds.Email.DATA); dbMap.put("emails", ContactsContract.CommonDataKinds.Email.DATA);
dbMap.put("emails.value", ContactsContract.CommonDataKinds.Email.DATA); dbMap.put("emails.value", ContactsContract.CommonDataKinds.Email.DATA);
dbMap.put("addresses", ContactsContract.CommonDataKinds.StructuredPostal.FORMATTED_ADDRESS); dbMap.put("addresses", ContactsContract.CommonDataKinds.StructuredPostal.FORMATTED_ADDRESS);
dbMap.put("addresses.formatted", ContactsContract.CommonDataKinds.StructuredPostal.FORMATTED_ADDRESS); dbMap.put("addresses.formatted", ContactsContract.CommonDataKinds.StructuredPostal.FORMATTED_ADDRESS);
dbMap.put("addresses.streetAddress", ContactsContract.CommonDataKinds.StructuredPostal.STREET); dbMap.put("addresses.streetAddress", ContactsContract.CommonDataKinds.StructuredPostal.STREET);
dbMap.put("addresses.locality", ContactsContract.CommonDataKinds.StructuredPostal.CITY); dbMap.put("addresses.locality", ContactsContract.CommonDataKinds.StructuredPostal.CITY);
dbMap.put("addresses.region", ContactsContract.CommonDataKinds.StructuredPostal.REGION); dbMap.put("addresses.region", ContactsContract.CommonDataKinds.StructuredPostal.REGION);
dbMap.put("addresses.postalCode", ContactsContract.CommonDataKinds.StructuredPostal.POSTCODE); dbMap.put("addresses.postalCode", ContactsContract.CommonDataKinds.StructuredPostal.POSTCODE);
dbMap.put("addresses.country", ContactsContract.CommonDataKinds.StructuredPostal.COUNTRY); dbMap.put("addresses.country", ContactsContract.CommonDataKinds.StructuredPostal.COUNTRY);
dbMap.put("ims", ContactsContract.CommonDataKinds.Im.DATA); dbMap.put("ims", ContactsContract.CommonDataKinds.Im.DATA);
dbMap.put("ims.value", ContactsContract.CommonDataKinds.Im.DATA); dbMap.put("ims.value", ContactsContract.CommonDataKinds.Im.DATA);
dbMap.put("organizations", ContactsContract.CommonDataKinds.Organization.COMPANY); dbMap.put("organizations", ContactsContract.CommonDataKinds.Organization.COMPANY);
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.START_DATE); dbMap.put("birthday", ContactsContract.CommonDataKinds.Event.CONTENT_ITEM_TYPE);
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);
dbMap.put("urls", ContactsContract.CommonDataKinds.Website.URL); dbMap.put("urls", ContactsContract.CommonDataKinds.Website.URL);
dbMap.put("urls.value", ContactsContract.CommonDataKinds.Website.URL); dbMap.put("urls.value", ContactsContract.CommonDataKinds.Website.URL);
} }
/** /**
@ -539,71 +536,67 @@ public class ContactAccessorSdk5 extends ContactAccessor {
where.add("(" + dbMap.get(key) + " LIKE ? )"); where.add("(" + dbMap.get(key) + " LIKE ? )");
whereArgs.add(searchTerm); whereArgs.add(searchTerm);
} }
else if (key.startsWith("name")) { else if (key.startsWith("name")) {
where.add("(" + dbMap.get(key) + " LIKE ? AND " where.add("(" + dbMap.get(key) + " LIKE ? AND "
+ ContactsContract.Data.MIMETYPE + " = ? )"); + ContactsContract.Data.MIMETYPE + " = ? )");
whereArgs.add(searchTerm); whereArgs.add(searchTerm);
whereArgs.add(ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE); whereArgs.add(ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE);
} }
else if (key.startsWith("nickname")) { else if (key.startsWith("nickname")) {
where.add("(" + dbMap.get(key) + " LIKE ? AND " where.add("(" + dbMap.get(key) + " LIKE ? AND "
+ ContactsContract.Data.MIMETYPE + " = ? )"); + ContactsContract.Data.MIMETYPE + " = ? )");
whereArgs.add(searchTerm); whereArgs.add(searchTerm);
whereArgs.add(ContactsContract.CommonDataKinds.Nickname.CONTENT_ITEM_TYPE); whereArgs.add(ContactsContract.CommonDataKinds.Nickname.CONTENT_ITEM_TYPE);
} }
else if (key.startsWith("phoneNumbers")) { else if (key.startsWith("phoneNumbers")) {
where.add("(" + dbMap.get(key) + " LIKE ? AND " where.add("(" + dbMap.get(key) + " LIKE ? AND "
+ ContactsContract.Data.MIMETYPE + " = ? )"); + ContactsContract.Data.MIMETYPE + " = ? )");
whereArgs.add(searchTerm); whereArgs.add(searchTerm);
whereArgs.add(ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE); whereArgs.add(ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE);
} }
else if (key.startsWith("emails")) { else if (key.startsWith("emails")) {
where.add("(" + dbMap.get(key) + " LIKE ? AND " where.add("(" + dbMap.get(key) + " LIKE ? AND "
+ ContactsContract.Data.MIMETYPE + " = ? )"); + ContactsContract.Data.MIMETYPE + " = ? )");
whereArgs.add(searchTerm); whereArgs.add(searchTerm);
whereArgs.add(ContactsContract.CommonDataKinds.Email.CONTENT_ITEM_TYPE); whereArgs.add(ContactsContract.CommonDataKinds.Email.CONTENT_ITEM_TYPE);
} }
else if (key.startsWith("addresses")) { else if (key.startsWith("addresses")) {
where.add("(" + dbMap.get(key) + " LIKE ? AND " where.add("(" + dbMap.get(key) + " LIKE ? AND "
+ ContactsContract.Data.MIMETYPE + " = ? )"); + ContactsContract.Data.MIMETYPE + " = ? )");
whereArgs.add(searchTerm); whereArgs.add(searchTerm);
whereArgs.add(ContactsContract.CommonDataKinds.StructuredPostal.CONTENT_ITEM_TYPE); whereArgs.add(ContactsContract.CommonDataKinds.StructuredPostal.CONTENT_ITEM_TYPE);
} }
else if (key.startsWith("ims")) { else if (key.startsWith("ims")) {
where.add("(" + dbMap.get(key) + " LIKE ? AND " where.add("(" + dbMap.get(key) + " LIKE ? AND "
+ ContactsContract.Data.MIMETYPE + " = ? )"); + ContactsContract.Data.MIMETYPE + " = ? )");
whereArgs.add(searchTerm); whereArgs.add(searchTerm);
whereArgs.add(ContactsContract.CommonDataKinds.Im.CONTENT_ITEM_TYPE); whereArgs.add(ContactsContract.CommonDataKinds.Im.CONTENT_ITEM_TYPE);
} }
else if (key.startsWith("organizations")) { else if (key.startsWith("organizations")) {
where.add("(" + dbMap.get(key) + " LIKE ? AND " where.add("(" + dbMap.get(key) + " LIKE ? AND "
+ ContactsContract.Data.MIMETYPE + " = ? )"); + ContactsContract.Data.MIMETYPE + " = ? )");
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")) {
try { // where.add("(" + dbMap.get(key) + " LIKE ? AND "
SimpleDateFormat format = new SimpleDateFormat("EEEE, MMMM dd, yyyy"); // + ContactsContract.Data.MIMETYPE + " = ? )");
Date searchDate = format.parse(searchTerm.substring(1, searchTerm.length()-1)); // }
// Have to subtract one from the month as JavaScript's January is 01 else if (key.startsWith("note")) {
// while Java's January is 00. where.add("(" + dbMap.get(key) + " LIKE ? AND "
searchDate.setMonth(searchDate.getMonth()-1); + ContactsContract.Data.MIMETYPE + " = ? )");
SimpleDateFormat newFormat = new SimpleDateFormat("yyyy-MM-dd"); whereArgs.add(searchTerm);
whereArgs.add(ContactsContract.CommonDataKinds.Note.CONTENT_ITEM_TYPE);
where.add("(" + dbMap.get(key) + " = ? AND " }
+ ContactsContract.Data.MIMETYPE + " = ? )"); else if (key.startsWith("urls")) {
whereArgs.add(newFormat.format(searchDate)); where.add("(" + dbMap.get(key) + " LIKE ? AND "
whereArgs.add(ContactsContract.CommonDataKinds.Event.CONTENT_ITEM_TYPE); + ContactsContract.Data.MIMETYPE + " = ? )");
whereArgs.add(searchTerm);
whereArgs.add(ContactsContract.CommonDataKinds.Website.CONTENT_ITEM_TYPE);
}
} }
catch (ParseException e) { } catch (JSONException e) {
Log.d(LOG_TAG, "Bad romance format"); Log.e(LOG_TAG, e.getMessage(), e);
}
}
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);
} }
// Creating the where string // Creating the where string
@ -1135,47 +1128,18 @@ public class ContactAccessorSdk5 extends ContactAccessor {
Log.d(LOG_TAG, "Could not get emails"); Log.d(LOG_TAG, "Could not get emails");
} }
// Modify note // Modify note
String note = getJsonString(contact, "note"); String note = getJsonString(contact, "note");
ops.add(ContentProviderOperation.newUpdate(ContactsContract.Data.CONTENT_URI) ops.add(ContentProviderOperation.newUpdate(ContactsContract.Data.CONTENT_URI)
.withSelection(ContactsContract.Data.CONTACT_ID + "=? AND " + .withSelection(ContactsContract.Data.CONTACT_ID + "=? AND " +
ContactsContract.Data.MIMETYPE + "=?", ContactsContract.Data.MIMETYPE + "=?",
new String[]{id,ContactsContract.CommonDataKinds.Note.CONTENT_ITEM_TYPE}) new String[] { id, ContactsContract.CommonDataKinds.Note.CONTENT_ITEM_TYPE })
.withValue(ContactsContract.CommonDataKinds.Note.NOTE, note) .withValue(ContactsContract.CommonDataKinds.Note.NOTE, note)
.build()); .build());
// Modify nickname // Modify nickname
String nickname = getJsonString(contact, "nickname"); String nickname = getJsonString(contact, "nickname");
if (nickname != null) { if (nickname != null) {
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 {
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) ops.add(ContentProviderOperation.newUpdate(ContactsContract.Data.CONTENT_URI)
.withSelection(ContactsContract.Data.CONTACT_ID + "=? AND " + .withSelection(ContactsContract.Data.CONTACT_ID + "=? AND " +
ContactsContract.Data.MIMETYPE + "=?", ContactsContract.Data.MIMETYPE + "=?",
@ -1963,3 +1927,4 @@ public class ContactAccessorSdk5 extends ContactAccessor {
return stringType; return stringType;
} }
} }

View File

@ -46,7 +46,7 @@ public class ContactManager extends Plugin {
/** /**
* Executes the request and returns PluginResult. * Executes the request and returns PluginResult.
* *
* @param action The action to execute. * @param action The action to execute.
* @param args JSONArry of arguments for the plugin. * @param args JSONArry of arguments for the plugin.
* @param callbackId The callback id used when calling back into JavaScript. * @param callbackId The callback id used when calling back into JavaScript.
@ -57,7 +57,7 @@ public class ContactManager extends Plugin {
String result = ""; String result = "";
/** /**
* Check to see if we are on an Android 1.X device. If we are return an error as we * Check to see if we are on an Android 1.X device. If we are return an error as we
* do not support this as of Cordova 1.0. * do not support this as of Cordova 1.0.
*/ */
if (android.os.Build.VERSION.RELEASE.startsWith("1.")) { if (android.os.Build.VERSION.RELEASE.startsWith("1.")) {

View File

@ -50,7 +50,7 @@ public class CordovaChromeClient extends WebChromeClient {
/** /**
* Constructor. * Constructor.
* *
* @param ctx * @param ctx
*/ */
public CordovaChromeClient(CordovaInterface ctx) { public CordovaChromeClient(CordovaInterface ctx) {
@ -79,7 +79,7 @@ public class CordovaChromeClient extends WebChromeClient {
/** /**
* Tell the client to display a javascript alert dialog. * Tell the client to display a javascript alert dialog.
* *
* @param view * @param view
* @param url * @param url
* @param message * @param message
@ -123,7 +123,7 @@ public class CordovaChromeClient extends WebChromeClient {
/** /**
* Tell the client to display a confirm dialog to the user. * Tell the client to display a confirm dialog to the user.
* *
* @param view * @param view
* @param url * @param url
* @param message * @param message
@ -171,13 +171,13 @@ public class CordovaChromeClient extends WebChromeClient {
} }
/** /**
* Tell the client to display a prompt dialog to the user. * Tell the client to display a prompt dialog to the user.
* If the client returns true, WebView will assume that the client will * If the client returns true, WebView will assume that the client will
* handle the prompt dialog and call the appropriate JsPromptResult method. * handle the prompt dialog and call the appropriate JsPromptResult method.
* *
* Since we are hacking prompts for our own purposes, we should not be using them for * Since we are hacking prompts for our own purposes, we should not be using them for
* this purpose, perhaps we should hack console.log to do this instead! * this purpose, perhaps we should hack console.log to do this instead!
* *
* @param view * @param view
* @param url * @param url
* @param message * @param message
@ -320,8 +320,8 @@ public class CordovaChromeClient extends WebChromeClient {
@Override @Override
/** /**
* Instructs the client to show a prompt to ask the user to set the Geolocation permission state for the specified origin. * Instructs the client to show a prompt to ask the user to set the Geolocation permission state for the specified origin.
* *
* @param origin * @param origin
* @param callback * @param callback
*/ */

View File

@ -38,161 +38,161 @@ public class CordovaLocationListener implements LocationListener {
protected LocationManager locationManager; protected LocationManager locationManager;
private GeoBroker owner; private GeoBroker owner;
protected boolean running = false; protected boolean running = false;
public HashMap<String, String> watches = new HashMap<String, String>(); public HashMap<String, String> watches = new HashMap<String, String>();
private List<String> callbacks = new ArrayList<String>(); private List<String> callbacks = new ArrayList<String>();
private String TAG = "[Cordova Location Listener]"; private String TAG = "[Cordova Location Listener]";
public CordovaLocationListener(LocationManager manager, GeoBroker broker, String tag) { public CordovaLocationListener(LocationManager manager, GeoBroker broker, String tag) {
this.locationManager = manager; this.locationManager = manager;
this.owner = broker; this.owner = broker;
this.TAG = tag; this.TAG = tag;
} }
protected void fail(int code, String message) { protected void fail(int code, String message) {
for (String callbackId: this.callbacks) for (String callbackId: this.callbacks)
{ {
this.owner.fail(code, message, callbackId); this.owner.fail(code, message, callbackId);
} }
this.callbacks.clear(); this.callbacks.clear();
Iterator it = this.watches.entrySet().iterator(); Iterator it = this.watches.entrySet().iterator();
while (it.hasNext()) { while (it.hasNext()) {
Map.Entry pairs = (Map.Entry)it.next(); Map.Entry pairs = (Map.Entry)it.next();
this.owner.fail(code, message, (String)pairs.getValue()); this.owner.fail(code, message, (String)pairs.getValue());
} }
} }
private void win(Location loc) { private void win(Location loc) {
for (String callbackId: this.callbacks) for (String callbackId: this.callbacks)
{ {
this.owner.win(loc, callbackId); this.owner.win(loc, callbackId);
} }
this.callbacks.clear(); this.callbacks.clear();
Iterator it = this.watches.entrySet().iterator(); Iterator it = this.watches.entrySet().iterator();
while (it.hasNext()) { while (it.hasNext()) {
Map.Entry pairs = (Map.Entry)it.next(); Map.Entry pairs = (Map.Entry)it.next();
this.owner.win(loc, (String)pairs.getValue()); this.owner.win(loc, (String)pairs.getValue());
} }
} }
/** /**
* Location Listener Methods * Location Listener Methods
*/ */
/**
* Called when the provider is disabled by the user.
*
* @param provider
*/
public void onProviderDisabled(String provider) {
Log.d(TAG, "Location provider '" + provider + "' disabled.");
this.fail(POSITION_UNAVAILABLE, "GPS provider disabled.");
}
/** /**
* Called when the provider is enabled by the user. * Called when the provider is disabled by the user.
* *
* @param provider * @param provider
*/ */
public void onProviderEnabled(String provider) { public void onProviderDisabled(String provider) {
Log.d(TAG, "Location provider "+ provider + " has been enabled"); Log.d(TAG, "Location provider '" + provider + "' disabled.");
} this.fail(POSITION_UNAVAILABLE, "GPS provider disabled.");
}
/** /**
* Called when the provider status changes. This method is called when a * Called when the provider is enabled by the user.
* provider is unable to fetch a location or if the provider has recently *
* become available after a period of unavailability. * @param provider
* */
* @param provider public void onProviderEnabled(String provider) {
* @param status Log.d(TAG, "Location provider "+ provider + " has been enabled");
* @param extras }
*/
public void onStatusChanged(String provider, int status, Bundle extras) { /**
Log.d(TAG, "The status of the provider " + provider + " has changed"); * Called when the provider status changes. This method is called when a
if (status == 0) { * provider is unable to fetch a location or if the provider has recently
Log.d(TAG, provider + " is OUT OF SERVICE"); * become available after a period of unavailability.
this.fail(CordovaLocationListener.POSITION_UNAVAILABLE, "Provider " + provider + " is out of service."); *
} * @param provider
else if (status == 1) { * @param status
Log.d(TAG, provider + " is TEMPORARILY_UNAVAILABLE"); * @param extras
} */
else { public void onStatusChanged(String provider, int status, Bundle extras) {
Log.d(TAG, provider + " is AVAILABLE"); Log.d(TAG, "The status of the provider " + provider + " has changed");
} if (status == 0) {
} Log.d(TAG, provider + " is OUT OF SERVICE");
this.fail(CordovaLocationListener.POSITION_UNAVAILABLE, "Provider " + provider + " is out of service.");
}
else if (status == 1) {
Log.d(TAG, provider + " is TEMPORARILY_UNAVAILABLE");
}
else {
Log.d(TAG, provider + " is AVAILABLE");
}
}
/**
* Called when the location has changed.
*
* @param location
*/
public void onLocationChanged(Location location) {
Log.d(TAG, "The location has been updated!");
this.win(location);
}
// PUBLIC
public int size() {
return this.watches.size() + this.callbacks.size();
}
public void addWatch(String timerId, String callbackId) {
this.watches.put(timerId, callbackId);
if (this.size() == 1) {
this.start();
}
}
public void addCallback(String callbackId) {
this.callbacks.add(callbackId);
if (this.size() == 1) {
this.start();
}
}
public void clearWatch(String timerId) {
if (this.watches.containsKey(timerId)) {
this.watches.remove(timerId);
}
if (this.size() == 0) {
this.stop();
}
}
/**
* Called when the location has changed.
*
* @param location
*/
public void onLocationChanged(Location location) {
Log.d(TAG, "The location has been updated!");
this.win(location);
}
// PUBLIC
public int size() {
return this.watches.size() + this.callbacks.size();
}
public void addWatch(String timerId, String callbackId) {
this.watches.put(timerId, callbackId);
if (this.size() == 1) {
this.start();
}
}
public void addCallback(String callbackId) {
this.callbacks.add(callbackId);
if (this.size() == 1) {
this.start();
}
}
public void clearWatch(String timerId) {
if (this.watches.containsKey(timerId)) {
this.watches.remove(timerId);
}
if (this.size() == 0) {
this.stop();
}
}
/** /**
* Destroy listener. * Destroy listener.
*/ */
public void destroy() { public void destroy() {
this.stop(); this.stop();
} }
// LOCAL
/**
* Start requesting location updates.
*
* @param interval
*/
protected void start() {
if (!this.running) {
if (this.locationManager.getProvider(LocationManager.NETWORK_PROVIDER) != null) {
this.running = true;
this.locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 60000, 10, this);
} else {
this.fail(CordovaLocationListener.POSITION_UNAVAILABLE, "Network provider is not available.");
}
}
}
/** // LOCAL
* Stop receiving location updates.
*/ /**
private void stop() { * Start requesting location updates.
if (this.running) { *
this.locationManager.removeUpdates(this); * @param interval
this.running = false; */
} protected void start() {
} if (!this.running) {
if (this.locationManager.getProvider(LocationManager.NETWORK_PROVIDER) != null) {
this.running = true;
this.locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 60000, 10, this);
} else {
this.fail(CordovaLocationListener.POSITION_UNAVAILABLE, "Network provider is not available.");
}
}
}
/**
* Stop receiving location updates.
*/
private void stop() {
if (this.running) {
this.locationManager.removeUpdates(this);
this.running = false;
}
}
} }

View File

@ -53,7 +53,7 @@ public class CordovaWebViewClient extends WebViewClient {
/** /**
* Constructor. * Constructor.
* *
* @param ctx * @param ctx
*/ */
public CordovaWebViewClient(CordovaInterface ctx) { public CordovaWebViewClient(CordovaInterface ctx) {
@ -81,9 +81,9 @@ public class CordovaWebViewClient extends WebViewClient {
} }
/** /**
* Give the host application a chance to take over the control when a new url * Give the host application a chance to take over the control when a new url
* is about to be loaded in the current WebView. * is about to be loaded in the current WebView.
* *
* @param view The WebView that is initiating the callback. * @param view The WebView that is initiating the callback.
* @param url The url to be loaded. * @param url The url to be loaded.
* @return true to override, false for default behavior * @return true to override, false for default behavior
@ -189,8 +189,8 @@ public class CordovaWebViewClient extends WebViewClient {
/** /**
* On received http auth request. * On received http auth request.
* The method reacts on all registered authentication tokens. There is one and only one authentication token for any host + realm combination * The method reacts on all registered authentication tokens. There is one and only one authentication token for any host + realm combination
* *
* @param view * @param view
* @param handler * @param handler
* @param host * @param host
@ -217,7 +217,7 @@ public class CordovaWebViewClient extends WebViewClient {
*/ */
@Override @Override
public void onPageStarted(WebView view, String url, Bitmap favicon) { public void onPageStarted(WebView view, String url, Bitmap favicon) {
// Clear history so history.back() doesn't do anything. // Clear history so history.back() doesn't do anything.
// So we can reinit() native side CallbackServer & PluginManager. // So we can reinit() native side CallbackServer & PluginManager.
if (!this.appView.useBrowserHistory) { if (!this.appView.useBrowserHistory) {
view.clearHistory(); view.clearHistory();
@ -250,8 +250,8 @@ public class CordovaWebViewClient extends WebViewClient {
LOG.d(TAG, "onPageFinished(" + url + ")"); LOG.d(TAG, "onPageFinished(" + url + ")");
/** /**
* Because of a timing issue we need to clear this history in onPageFinished as well as * Because of a timing issue we need to clear this history in onPageFinished as well as
* onPageStarted. However we only want to do this if the doClearHistory boolean is set to * onPageStarted. However we only want to do this if the doClearHistory boolean is set to
* true. You see when you load a url with a # in it which is common in jQuery applications * true. You see when you load a url with a # in it which is common in jQuery applications
* onPageStared is not called. Clearing the history at that point would break jQuery apps. * onPageStared is not called. Clearing the history at that point would break jQuery apps.
*/ */
@ -302,13 +302,13 @@ public class CordovaWebViewClient extends WebViewClient {
} }
/** /**
* Report an error to the host application. These errors are unrecoverable (i.e. the main resource is unavailable). * Report an error to the host application. These errors are unrecoverable (i.e. the main resource is unavailable).
* The errorCode parameter corresponds to one of the ERROR_* constants. * The errorCode parameter corresponds to one of the ERROR_* constants.
* *
* @param view The WebView that is initiating the callback. * @param view The WebView that is initiating the callback.
* @param errorCode The error code corresponding to an ERROR_* value. * @param errorCode The error code corresponding to an ERROR_* value.
* @param description A String describing the error. * @param description A String describing the error.
* @param failingUrl The url that failed to load. * @param failingUrl The url that failed to load.
*/ */
@Override @Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
@ -370,7 +370,7 @@ public class CordovaWebViewClient extends WebViewClient {
*/ */
@Override @Override
public void doUpdateVisitedHistory(WebView view, String url, boolean isReload) { public void doUpdateVisitedHistory(WebView view, String url, boolean isReload) {
/* /*
* If you do a document.location.href the url does not get pushed on the stack * If you do a document.location.href the url does not get pushed on the stack
* so we do a check here to see if the url should be pushed. * so we do a check here to see if the url should be pushed.
*/ */

View File

@ -53,7 +53,7 @@ public class Device extends Plugin {
/** /**
* Sets the context of the Command. This can then be used to do things like * Sets the context of the Command. This can then be used to do things like
* get file paths associated with the Activity. * get file paths associated with the Activity.
* *
* @param ctx The context of the main Activity. * @param ctx The context of the main Activity.
*/ */
public void setContext(CordovaInterface ctx) { public void setContext(CordovaInterface ctx) {
@ -64,7 +64,7 @@ public class Device extends Plugin {
/** /**
* Executes the request and returns PluginResult. * Executes the request and returns PluginResult.
* *
* @param action The action to execute. * @param action The action to execute.
* @param args JSONArry of arguments for the plugin. * @param args JSONArry of arguments for the plugin.
* @param callbackId The callback id used when calling back into JavaScript. * @param callbackId The callback id used when calling back into JavaScript.
@ -95,7 +95,7 @@ public class Device extends Plugin {
/** /**
* Identifies if action to be executed returns a value and should be run synchronously. * Identifies if action to be executed returns a value and should be run synchronously.
* *
* @param action The action to execute * @param action The action to execute
* @return T=returns value * @return T=returns value
*/ */
@ -158,7 +158,7 @@ public class Device extends Plugin {
/** /**
* Get the OS name. * Get the OS name.
* *
* @return * @return
*/ */
public String getPlatform() { public String getPlatform() {
@ -167,7 +167,7 @@ public class Device extends Plugin {
/** /**
* Get the device's Universally Unique Identifier (UUID). * Get the device's Universally Unique Identifier (UUID).
* *
* @return * @return
*/ */
public String getUuid() { public String getUuid() {
@ -177,7 +177,7 @@ public class Device extends Plugin {
/** /**
* Get the Cordova version. * Get the Cordova version.
* *
* @return * @return
*/ */
public String getCordovaVersion() { public String getCordovaVersion() {
@ -196,7 +196,7 @@ public class Device extends Plugin {
/** /**
* Get the OS version. * Get the OS version.
* *
* @return * @return
*/ */
public String getOSVersion() { public String getOSVersion() {

View File

@ -25,9 +25,9 @@ import android.os.Environment;
import android.os.StatFs; import android.os.StatFs;
/** /**
* This class provides file directory utilities. * This class provides file directory utilities.
* All file operations are performed on the SD card. * All file operations are performed on the SD card.
* *
* It is used by the FileUtils class. * It is used by the FileUtils class.
*/ */
public class DirectoryManager { public class DirectoryManager {
@ -37,7 +37,6 @@ public class DirectoryManager {
/** /**
* Determine if a file or directory exists. * Determine if a file or directory exists.
*
* @param name The name of the file to check. * @param name The name of the file to check.
* @return T=exists, F=not found * @return T=exists, F=not found
*/ */
@ -117,12 +116,12 @@ public class DirectoryManager {
/** /**
* Create a new file object from two file paths. * Create a new file object from two file paths.
* *
* @param file1 Base file path * @param file1 Base file path
* @param file2 Remaining file path * @param file2 Remaining file path
* @return File object * @return File object
*/ */
private static File constructFilePaths(String file1, String file2) { private static File constructFilePaths (String file1, String file2) {
File newPath; File newPath;
if (file2.startsWith(file1)) { if (file2.startsWith(file1)) {
newPath = new File(file2); newPath = new File(file2);
@ -134,9 +133,9 @@ public class DirectoryManager {
} }
/** /**
* Determine if we can use the SD Card to store the temporary file. If not then use * Determine if we can use the SD Card to store the temporary file. If not then use
* the internal cache directory. * the internal cache directory.
* *
* @return the absolute path of where to store the file * @return the absolute path of where to store the file
*/ */
protected static String getTempDirectoryPath(Context ctx) { protected static String getTempDirectoryPath(Context ctx) {

View File

@ -53,29 +53,29 @@ import android.widget.LinearLayout;
* This class is the main Android activity that represents the Cordova * This class is the main Android activity that represents the Cordova
* application. It should be extended by the user to load the specific * application. It should be extended by the user to load the specific
* html file that contains the application. * html file that contains the application.
* *
* As an example: * As an example:
* *
* package org.apache.cordova.examples; * package org.apache.cordova.examples;
* import android.app.Activity; * import android.app.Activity;
* import android.os.Bundle; * import android.os.Bundle;
* import org.apache.cordova.*; * import org.apache.cordova.*;
* *
* public class Examples extends DroidGap { * public class Examples extends DroidGap {
* @Override * @Override
* public void onCreate(Bundle savedInstanceState) { * public void onCreate(Bundle savedInstanceState) {
* super.onCreate(savedInstanceState); * super.onCreate(savedInstanceState);
* *
* // Set properties for activity * // Set properties for activity
* super.setStringProperty("loadingDialog", "Title,Message"); // show loading dialog * super.setStringProperty("loadingDialog", "Title,Message"); // show loading dialog
* super.setStringProperty("errorUrl", "file:///android_asset/www/error.html"); // if error loading file in super.loadUrl(). * super.setStringProperty("errorUrl", "file:///android_asset/www/error.html"); // if error loading file in super.loadUrl().
* *
* // Initialize activity * // Initialize activity
* super.init(); * super.init();
* *
* // Clear cache if you want * // Clear cache if you want
* super.appView.clearCache(true); * super.appView.clearCache(true);
* *
* // Load your application * // Load your application
* super.setIntegerProperty("splashscreen", R.drawable.splash); // load splash.jpg image from the resource drawable directory * super.setIntegerProperty("splashscreen", R.drawable.splash); // load splash.jpg image from the resource drawable directory
* super.loadUrl("file:///android_asset/www/index.html", 3000); // show splash screen 3 sec before loading app * super.loadUrl("file:///android_asset/www/index.html", 3000); // show splash screen 3 sec before loading app
@ -83,15 +83,15 @@ import android.widget.LinearLayout;
* } * }
* *
* Properties: The application can be configured using the following properties: * Properties: The application can be configured using the following properties:
* *
* // Display a native loading dialog when loading app. Format for value = "Title,Message". * // Display a native loading dialog when loading app. Format for value = "Title,Message".
* // (String - default=null) * // (String - default=null)
* super.setStringProperty("loadingDialog", "Wait,Loading Demo..."); * super.setStringProperty("loadingDialog", "Wait,Loading Demo...");
* *
* // Display a native loading dialog when loading sub-pages. Format for value = "Title,Message". * // Display a native loading dialog when loading sub-pages. Format for value = "Title,Message".
* // (String - default=null) * // (String - default=null)
* super.setStringProperty("loadingPageDialog", "Loading page..."); * super.setStringProperty("loadingPageDialog", "Loading page...");
* *
* // Load a splash screen image from the resource drawable directory. * // Load a splash screen image from the resource drawable directory.
* // (Integer - default=0) * // (Integer - default=0)
* super.setIntegerProperty("splashscreen", R.drawable.splash); * super.setIntegerProperty("splashscreen", R.drawable.splash);
@ -99,21 +99,21 @@ import android.widget.LinearLayout;
* // Set the background color. * // Set the background color.
* // (Integer - default=0 or BLACK) * // (Integer - default=0 or BLACK)
* super.setIntegerProperty("backgroundColor", Color.WHITE); * super.setIntegerProperty("backgroundColor", Color.WHITE);
* *
* // Time in msec to wait before triggering a timeout error when loading * // Time in msec to wait before triggering a timeout error when loading
* // with super.loadUrl(). (Integer - default=20000) * // with super.loadUrl(). (Integer - default=20000)
* super.setIntegerProperty("loadUrlTimeoutValue", 60000); * super.setIntegerProperty("loadUrlTimeoutValue", 60000);
* *
* // URL to load if there's an error loading specified URL with loadUrl(). * // URL to load if there's an error loading specified URL with loadUrl().
* // Should be a local URL starting with file://. (String - default=null) * // Should be a local URL starting with file://. (String - default=null)
* super.setStringProperty("errorUrl", "file:///android_asset/www/error.html"); * super.setStringProperty("errorUrl", "file:///android_asset/www/error.html");
* *
* // Enable app to keep running in background. (Boolean - default=true) * // Enable app to keep running in background. (Boolean - default=true)
* super.setBooleanProperty("keepRunning", false); * super.setBooleanProperty("keepRunning", false);
* *
* Cordova.xml configuration: * Cordova.xml configuration:
* Cordova uses a configuration file at res/xml/cordova.xml to specify the following settings. * Cordova uses a configuration file at res/xml/cordova.xml to specify the following settings.
* *
* Approved list of URLs that can be loaded into DroidGap * Approved list of URLs that can be loaded into DroidGap
* <access origin="http://server regexp" subdomains="true" /> * <access origin="http://server regexp" subdomains="true" />
* Log level: ERROR, WARN, INFO, DEBUG, VERBOSE (default=ERROR) * Log level: ERROR, WARN, INFO, DEBUG, VERBOSE (default=ERROR)
@ -124,7 +124,7 @@ import android.widget.LinearLayout;
* Before using a new plugin, a new element must be added to the file. * Before using a new plugin, a new element must be added to the file.
* name attribute is the service name passed to Cordova.exec() in JavaScript * name attribute is the service name passed to Cordova.exec() in JavaScript
* value attribute is the Java class name to call. * value attribute is the Java class name to call.
* *
* <plugins> * <plugins>
* <plugin name="App" value="org.apache.cordova.App"/> * <plugin name="App" value="org.apache.cordova.App"/>
* ... * ...
@ -173,6 +173,9 @@ public class DroidGap extends Activity implements CordovaInterface {
protected int splashscreen = 0; protected int splashscreen = 0;
protected int splashscreenTime = 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) // Keep app running when pause is received. (default = true)
// If true, then the JavaScript and native code continue to run in the background // If true, then the JavaScript and native code continue to run in the background
// when another application (activity) is started. // when another application (activity) is started.
@ -193,7 +196,7 @@ public class DroidGap extends Activity implements CordovaInterface {
/** /**
* Removes the authentication token. * Removes the authentication token.
* *
* @param host * @param host
* @param realm * @param realm
* *
@ -208,13 +211,13 @@ public class DroidGap extends Activity implements CordovaInterface {
/** /**
* Gets the authentication token. * Gets the authentication token.
* *
* In order it tries: * In order it tries:
* 1- host + realm * 1- host + realm
* 2- host * 2- host
* 3- realm * 3- realm
* 4- no host, no realm * 4- no host, no realm
* *
* @param host * @param host
* @param realm * @param realm
* *
@ -287,7 +290,7 @@ public class DroidGap extends Activity implements CordovaInterface {
/** /**
* Initialize web container with web view objects. * Initialize web container with web view objects.
* *
* @param webView * @param webView
* @param webViewClient * @param webViewClient
* @param webChromeClient * @param webChromeClient
@ -379,7 +382,7 @@ public class DroidGap extends Activity implements CordovaInterface {
/** /**
* Load the url into the webview after waiting for period of time. * Load the url into the webview after waiting for period of time.
* This is used to display the splashscreen for certain amount of time. * This is used to display the splashscreen for certain amount of time.
* *
* @param url * @param url
* @param time The number of ms to wait before loading webview * @param time The number of ms to wait before loading webview
*/ */
@ -422,7 +425,7 @@ public class DroidGap extends Activity implements CordovaInterface {
/** /**
* Go to previous page in history. (We manage our own history) * Go to previous page in history. (We manage our own history)
* *
* @return true if we went back, false if we are already at top * @return true if we went back, false if we are already at top
*/ */
public boolean backHistory() { public boolean backHistory() {
@ -434,8 +437,8 @@ public class DroidGap extends Activity implements CordovaInterface {
@Override @Override
/** /**
* Called by the system when the device configuration changes while your activity is running. * Called by the system when the device configuration changes while your activity is running.
* *
* @param Configuration newConfig * @param Configuration newConfig
*/ */
public void onConfigurationChanged(Configuration newConfig) { public void onConfigurationChanged(Configuration newConfig) {
@ -445,7 +448,7 @@ public class DroidGap extends Activity implements CordovaInterface {
/** /**
* Get boolean property for activity. * Get boolean property for activity.
* *
* @param name * @param name
* @param defaultValue * @param defaultValue
* @return * @return
@ -475,7 +478,7 @@ public class DroidGap extends Activity implements CordovaInterface {
/** /**
* Get int property for activity. * Get int property for activity.
* *
* @param name * @param name
* @param defaultValue * @param defaultValue
* @return * @return
@ -499,7 +502,7 @@ public class DroidGap extends Activity implements CordovaInterface {
/** /**
* Get string property for activity. * Get string property for activity.
* *
* @param name * @param name
* @param defaultValue * @param defaultValue
* @return * @return
@ -518,7 +521,7 @@ public class DroidGap extends Activity implements CordovaInterface {
/** /**
* Get double property for activity. * Get double property for activity.
* *
* @param name * @param name
* @param defaultValue * @param defaultValue
* @return * @return
@ -542,7 +545,7 @@ public class DroidGap extends Activity implements CordovaInterface {
/** /**
* Set boolean property on activity. * Set boolean property on activity.
* *
* @param name * @param name
* @param value * @param value
*/ */
@ -552,7 +555,7 @@ public class DroidGap extends Activity implements CordovaInterface {
/** /**
* Set int property on activity. * Set int property on activity.
* *
* @param name * @param name
* @param value * @param value
*/ */
@ -562,7 +565,7 @@ public class DroidGap extends Activity implements CordovaInterface {
/** /**
* Set string property on activity. * Set string property on activity.
* *
* @param name * @param name
* @param value * @param value
*/ */
@ -572,7 +575,7 @@ public class DroidGap extends Activity implements CordovaInterface {
/** /**
* Set double property on activity. * Set double property on activity.
* *
* @param name * @param name
* @param value * @param value
*/ */
@ -582,7 +585,7 @@ public class DroidGap extends Activity implements CordovaInterface {
@Override @Override
/** /**
* Called when the system is about to start resuming a previous activity. * Called when the system is about to start resuming a previous activity.
*/ */
protected void onPause() { protected void onPause() {
super.onPause(); super.onPause();
@ -627,7 +630,7 @@ public class DroidGap extends Activity implements CordovaInterface {
@Override @Override
/** /**
* Called when the activity will start interacting with the user. * Called when the activity will start interacting with the user.
*/ */
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
@ -665,7 +668,7 @@ public class DroidGap extends Activity implements CordovaInterface {
@Override @Override
/** /**
* The final call you receive before your activity is destroyed. * The final call you receive before your activity is destroyed.
*/ */
public void onDestroy() { public void onDestroy() {
LOG.d(TAG, "onDestroy()"); LOG.d(TAG, "onDestroy()");
@ -690,8 +693,8 @@ public class DroidGap extends Activity implements CordovaInterface {
} }
/** /**
* Send a message to all plugins. * Send a message to all plugins.
* *
* @param id The message id * @param id The message id
* @param data The message data * @param data The message data
*/ */
@ -704,9 +707,9 @@ public class DroidGap extends Activity implements CordovaInterface {
/** /**
* @deprecated * @deprecated
* Add services to res/xml/plugins.xml instead. * Add services to res/xml/plugins.xml instead.
* *
* Add a class that implements a service. * Add a class that implements a service.
* *
* @param serviceType * @param serviceType
* @param className * @param className
*/ */
@ -719,11 +722,10 @@ public class DroidGap extends Activity implements CordovaInterface {
/** /**
* Send JavaScript statement back to JavaScript. * Send JavaScript statement back to JavaScript.
* (This is a convenience method) * (This is a convenience method)
* *
* @param message * @param message
*/ */
public void sendJavascript(String statement) { 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) { if (this.appView != null && this.appView.callbackServer != null) {
this.appView.callbackServer.sendJavascript(statement); this.appView.callbackServer.sendJavascript(statement);
} }
@ -731,7 +733,7 @@ public class DroidGap extends Activity implements CordovaInterface {
/** /**
* Show the spinner. Must be called from the UI thread. * Show the spinner. Must be called from the UI thread.
* *
* @param title Title of the dialog * @param title Title of the dialog
* @param message The message of the dialog * @param message The message of the dialog
*/ */
@ -817,7 +819,7 @@ public class DroidGap extends Activity implements CordovaInterface {
/** /**
* Launch an activity for which you would like a result when it finished. When this activity exits, * Launch an activity for which you would like a result when it finished. When this activity exits,
* your onActivityResult() method will be called. * your onActivityResult() method will be called.
* *
* @param command The command object * @param command The command object
* @param intent The intent to start * @param intent The intent to start
* @param requestCode The request code that is passed to callback to identify the activity * @param requestCode The request code that is passed to callback to identify the activity
@ -838,9 +840,9 @@ public class DroidGap extends Activity implements CordovaInterface {
@Override @Override
/** /**
* Called when an activity you launched exits, giving you the requestCode you started it with, * Called when an activity you launched exits, giving you the requestCode you started it with,
* the resultCode it returned, and any additional data from it. * the resultCode it returned, and any additional data from it.
* *
* @param requestCode The request code originally supplied to startActivityForResult(), * @param requestCode The request code originally supplied to startActivityForResult(),
* allowing you to identify who this result came from. * allowing you to identify who this result came from.
* @param resultCode The integer result code returned by the child activity through its setResult(). * @param resultCode The integer result code returned by the child activity through its setResult().
* @param data An Intent, which can return result data to the caller (various data can be attached to Intent "extras"). * @param data An Intent, which can return result data to the caller (various data can be attached to Intent "extras").
@ -934,7 +936,7 @@ public class DroidGap extends Activity implements CordovaInterface {
/** /**
* Determine if URL is in approved list of URLs to load. * Determine if URL is in approved list of URLs to load.
* *
* @param url * @param url
* @return * @return
*/ */
@ -948,7 +950,7 @@ public class DroidGap extends Activity implements CordovaInterface {
/* /*
* Hook in DroidGap for menu plugins * Hook in DroidGap for menu plugins
* *
*/ */
@Override @Override
public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(Menu menu) {

View File

@ -41,31 +41,31 @@ public class ExifHelper {
private String make = null; private String make = null;
private String model = null; private String model = null;
private String orientation = null; private String orientation = null;
private String whiteBalance = null; private String whiteBalance = null;
private ExifInterface inFile = null; private ExifInterface inFile = null;
private ExifInterface outFile = null; private ExifInterface outFile = null;
/** /**
* The file before it is compressed * The file before it is compressed
* *
* @param filePath * @param filePath
* @throws IOException * @throws IOException
*/ */
public void createInFile(String filePath) throws IOException { public void createInFile(String filePath) throws IOException {
this.inFile = new ExifInterface(filePath); this.inFile = new ExifInterface(filePath);
} }
/** /**
* The file after it has been compressed * The file after it has been compressed
* *
* @param filePath * @param filePath
* @throws IOException * @throws IOException
*/ */
public void createOutFile(String filePath) throws IOException { public void createOutFile(String filePath) throws IOException {
this.outFile = new ExifInterface(filePath); this.outFile = new ExifInterface(filePath);
} }
/** /**
* Reads all the EXIF data from the input file. * Reads all the EXIF data from the input file.
*/ */
@ -88,12 +88,12 @@ public class ExifHelper {
this.make = inFile.getAttribute(ExifInterface.TAG_MAKE); this.make = inFile.getAttribute(ExifInterface.TAG_MAKE);
this.model = inFile.getAttribute(ExifInterface.TAG_MODEL); this.model = inFile.getAttribute(ExifInterface.TAG_MODEL);
this.orientation = inFile.getAttribute(ExifInterface.TAG_ORIENTATION); this.orientation = inFile.getAttribute(ExifInterface.TAG_ORIENTATION);
this.whiteBalance = inFile.getAttribute(ExifInterface.TAG_WHITE_BALANCE); this.whiteBalance = inFile.getAttribute(ExifInterface.TAG_WHITE_BALANCE);
} }
/** /**
* Writes the previously stored EXIF data to the output file. * Writes the previously stored EXIF data to the output file.
* *
* @throws IOException * @throws IOException
*/ */
public void writeExifData() throws IOException { public void writeExifData() throws IOException {
@ -101,7 +101,7 @@ public class ExifHelper {
if (this.outFile == null) { if (this.outFile == null) {
return; return;
} }
if (this.aperature != null) { if (this.aperature != null) {
this.outFile.setAttribute(ExifInterface.TAG_APERTURE, this.aperature); this.outFile.setAttribute(ExifInterface.TAG_APERTURE, this.aperature);
} }
@ -159,7 +159,7 @@ public class ExifHelper {
if (this.whiteBalance != null) { if (this.whiteBalance != null) {
this.outFile.setAttribute(ExifInterface.TAG_WHITE_BALANCE, this.whiteBalance); this.outFile.setAttribute(ExifInterface.TAG_WHITE_BALANCE, this.whiteBalance);
} }
this.outFile.saveAttributes(); this.outFile.saveAttributes();
} }
} }

View File

@ -449,14 +449,14 @@ public class FileTransfer extends Plugin {
URL url = new URL(source); URL url = new URL(source);
connection = (HttpURLConnection) url.openConnection(); connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET"); connection.setRequestMethod("GET");
//Add cookie support //Add cookie support
String cookie = CookieManager.getInstance().getCookie(source); String cookie = CookieManager.getInstance().getCookie(source);
if(cookie != null) if(cookie != null)
{ {
connection.setRequestProperty("cookie", cookie); connection.setRequestProperty("cookie", cookie);
} }
connection.connect(); connection.connect();
Log.d(LOG_TAG, "Download file: " + url); Log.d(LOG_TAG, "Download file: " + url);
@ -539,7 +539,7 @@ public class FileTransfer extends Plugin {
/** /**
* Get a File object from the passed in path * Get a File object from the passed in path
* *
* @param path file path * @param path file path
* @return file object * @return file object
*/ */

View File

@ -25,39 +25,39 @@ import org.json.JSONObject;
* Encapsulates the result and/or status of uploading a file to a remote server. * Encapsulates the result and/or status of uploading a file to a remote server.
*/ */
public class FileUploadResult { public class FileUploadResult {
private long bytesSent = 0; // bytes sent private long bytesSent = 0; // bytes sent
private int responseCode = -1; // HTTP response code private int responseCode = -1; // HTTP response code
private String response = null; // HTTP response private String response = null; // HTTP response
public long getBytesSent() { public long getBytesSent() {
return bytesSent; return bytesSent;
} }
public void setBytesSent(long bytes) { public void setBytesSent(long bytes) {
this.bytesSent = bytes; this.bytesSent = bytes;
} }
public int getResponseCode() { public int getResponseCode() {
return responseCode; return responseCode;
} }
public void setResponseCode(int responseCode) { public void setResponseCode(int responseCode) {
this.responseCode = responseCode; this.responseCode = responseCode;
} }
public String getResponse() { public String getResponse() {
return response; return response;
} }
public void setResponse(String response) { public void setResponse(String response) {
this.response = response; this.response = response;
} }
public JSONObject toJSONObject() throws JSONException { public JSONObject toJSONObject() throws JSONException {
return new JSONObject( return new JSONObject(
"{bytesSent:" + bytesSent + "{bytesSent:" + bytesSent +
",responseCode:" + responseCode + ",responseCode:" + responseCode +
",response:" + JSONObject.quote(response) + "}"); ",response:" + JSONObject.quote(response) + "}");
} }
} }

View File

@ -42,7 +42,6 @@ import android.database.Cursor;
import android.net.Uri; import android.net.Uri;
import android.os.Environment; import android.os.Environment;
import android.provider.MediaStore; import android.provider.MediaStore;
//import android.util.Log;
import android.webkit.MimeTypeMap; import android.webkit.MimeTypeMap;
//import android.app.Activity; //import android.app.Activity;
@ -739,7 +738,7 @@ public class FileUtils extends Plugin {
/** /**
* This method removes the "file://" from the passed in filePath * This method removes the "file://" from the passed in filePath
* *
* @param filePath to be checked. * @param filePath to be checked.
* @return * @return
*/ */
@ -752,7 +751,7 @@ public class FileUtils extends Plugin {
/** /**
* Create a File object from the passed in path * Create a File object from the passed in path
* *
* @param filePath * @param filePath
* @return * @return
*/ */

View File

@ -26,25 +26,25 @@ import android.location.LocationManager;
* *
*/ */
public class GPSListener extends CordovaLocationListener { public class GPSListener extends CordovaLocationListener {
public GPSListener(LocationManager locationManager, GeoBroker m) { public GPSListener(LocationManager locationManager, GeoBroker m) {
super(locationManager, m, "[Cordova GPSListener]"); super(locationManager, m, "[Cordova GPSListener]");
} }
/** /**
* Start requesting location updates. * Start requesting location updates.
* *
* @param interval * @param interval
*/ */
@Override @Override
protected void start() { protected void start() {
if (!this.running) { if (!this.running) {
if (this.locationManager.getProvider(LocationManager.GPS_PROVIDER) != null) { if (this.locationManager.getProvider(LocationManager.GPS_PROVIDER) != null) {
this.running = true; this.running = true;
this.locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 60000, 0, this); this.locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 60000, 0, this);
} else { } else {
this.fail(CordovaLocationListener.POSITION_UNAVAILABLE, "GPS provider is not available."); this.fail(CordovaLocationListener.POSITION_UNAVAILABLE, "GPS provider is not available.");
} }
} }
} }
} }

View File

@ -30,7 +30,7 @@ import android.location.LocationManager;
/* /*
* This class is the interface to the Geolocation. It's bound to the geo object. * This class is the interface to the Geolocation. It's bound to the geo object.
* *
* This class only starts and stops various GeoListeners, which consist of a GPS and a Network Listener * This class only starts and stops various GeoListeners, which consist of a GPS and a Network Listener
*/ */
@ -47,7 +47,7 @@ public class GeoBroker extends Plugin {
/** /**
* Executes the request and returns PluginResult. * Executes the request and returns PluginResult.
* *
* @param action The action to execute. * @param action The action to execute.
* @param args JSONArry of arguments for the plugin. * @param args JSONArry of arguments for the plugin.
* @param callbackId The callback id used when calling back into JavaScript. * @param callbackId The callback id used when calling back into JavaScript.
@ -114,7 +114,7 @@ public class GeoBroker extends Plugin {
/** /**
* Identifies if action to be executed returns a value and should be run synchronously. * Identifies if action to be executed returns a value and should be run synchronously.
* *
* @param action The action to execute * @param action The action to execute
* @return T=returns value * @return T=returns value
*/ */

View File

@ -58,10 +58,7 @@ public class HttpHandler {
HttpGet httpget = new HttpGet(url); HttpGet httpget = new HttpGet(url);
HttpResponse response = httpclient.execute(httpget); HttpResponse response = httpclient.execute(httpget);
entity = response.getEntity(); entity = response.getEntity();
} catch (Exception e) { } catch (Exception e) { e.printStackTrace(); return null; }
e.printStackTrace();
return null;
}
return entity; return entity;
} }
@ -76,7 +73,7 @@ public class HttpHandler {
byte buff[] = new byte[1024]; byte buff[] = new byte[1024];
FileOutputStream out = FileOutputStream out =
new FileOutputStream(FilePath); new FileOutputStream(FilePath);
do { do {
int numread = in.read(buff); int numread = in.read(buff);
if (numread <= 0) if (numread <= 0)
break; break;

View File

@ -32,7 +32,7 @@ public class LinearLayoutSoftKeyboardDetect extends LinearLayout {
private static final String TAG = "SoftKeyboardDetect"; private static final String TAG = "SoftKeyboardDetect";
private int oldHeight = 0; // Need to save the old height as not to send redundant events private int oldHeight = 0; // Need to save the old height as not to send redundant events
private int oldWidth = 0; // Need to save old width for orientation change private int oldWidth = 0; // Need to save old width for orientation change
private int screenWidth = 0; private int screenWidth = 0;
private int screenHeight = 0; private int screenHeight = 0;
private DroidGap app = null; private DroidGap app = null;
@ -46,12 +46,12 @@ public class LinearLayoutSoftKeyboardDetect extends LinearLayout {
@Override @Override
/** /**
* Start listening to new measurement events. Fire events when the height * Start listening to new measurement events. Fire events when the height
* gets smaller fire a show keyboard event and when height gets bigger fire * gets smaller fire a show keyboard event and when height gets bigger fire
* a hide keyboard event. * a hide keyboard event.
* *
* Note: We are using app.postMessage so that this is more compatible with the API * Note: We are using app.postMessage so that this is more compatible with the API
* *
* @param widthMeasureSpec * @param widthMeasureSpec
* @param heightMeasureSpec * @param heightMeasureSpec
*/ */
@ -84,7 +84,7 @@ public class LinearLayoutSoftKeyboardDetect extends LinearLayout {
screenWidth = tmp_var; screenWidth = tmp_var;
LOG.v(TAG, "Orientation Change"); LOG.v(TAG, "Orientation Change");
} }
// If the height as gotten bigger then we will assume the soft keyboard has // If the height as gotten bigger then we will assume the soft keyboard has
// gone away. // gone away.
else if (height > oldHeight) { else if (height > oldHeight) {
if (app != null) if (app != null)

View File

@ -26,7 +26,7 @@ import android.location.LocationManager;
* *
*/ */
public class NetworkListener extends CordovaLocationListener { public class NetworkListener extends CordovaLocationListener {
public NetworkListener(LocationManager locationManager, GeoBroker m) { public NetworkListener(LocationManager locationManager, GeoBroker m) {
super(locationManager, m, "[Cordova NetworkListener]"); super(locationManager, m, "[Cordova NetworkListener]");
} }
} }

View File

@ -83,7 +83,7 @@ public class NetworkManager extends Plugin {
/** /**
* Sets the context of the Command. This can then be used to do things like * Sets the context of the Command. This can then be used to do things like
* get file paths associated with the Activity. * get file paths associated with the Activity.
* *
* @param ctx The context of the main Activity. * @param ctx The context of the main Activity.
*/ */
public void setContext(CordovaInterface ctx) { public void setContext(CordovaInterface ctx) {
@ -109,7 +109,7 @@ public class NetworkManager extends Plugin {
/** /**
* Executes the request and returns PluginResult. * Executes the request and returns PluginResult.
* *
* @param action The action to execute. * @param action The action to execute.
* @param args JSONArry of arguments for the plugin. * @param args JSONArry of arguments for the plugin.
* @param callbackId The callback id used when calling back into JavaScript. * @param callbackId The callback id used when calling back into JavaScript.
@ -132,7 +132,7 @@ public class NetworkManager extends Plugin {
/** /**
* Identifies if action to be executed returns a value and should be run synchronously. * Identifies if action to be executed returns a value and should be run synchronously.
* *
* @param action The action to execute * @param action The action to execute
* @return T=returns value * @return T=returns value
*/ */
@ -159,7 +159,7 @@ public class NetworkManager extends Plugin {
/** /**
* Updates the JavaScript side whenever the connection changes * Updates the JavaScript side whenever the connection changes
* *
* @param info the current active network info * @param info the current active network info
* @return * @return
*/ */
@ -168,9 +168,9 @@ public class NetworkManager extends Plugin {
sendUpdate(this.getConnectionInfo(info)); sendUpdate(this.getConnectionInfo(info));
} }
/** /**
* Get the latest network connection information * Get the latest network connection information
* *
* @param info the current active network info * @param info the current active network info
* @return a JSONObject that represents the network info * @return a JSONObject that represents the network info
*/ */
@ -190,7 +190,7 @@ public class NetworkManager extends Plugin {
/** /**
* Create a new plugin result and send it back to JavaScript * Create a new plugin result and send it back to JavaScript
* *
* @param connection the network info to set as navigator.connection * @param connection the network info to set as navigator.connection
*/ */
private void sendUpdate(String type) { private void sendUpdate(String type) {
@ -204,7 +204,7 @@ public class NetworkManager extends Plugin {
/** /**
* Determine the type of connection * Determine the type of connection
* *
* @param info the network info so we can determine connection type. * @param info the network info so we can determine connection type.
* @return the type of mobile network we are on * @return the type of mobile network we are on
*/ */

View File

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

View File

@ -31,209 +31,209 @@ import android.database.Cursor;
import android.database.sqlite.*; import android.database.sqlite.*;
/** /**
* This class implements the HTML5 database support to work around a bug for * This class implements the HTML5 database support to work around a bug for
* Android 3.0 devices. It is not used for other versions of Android, since * Android 3.0 devices. It is not used for other versions of Android, since
* HTML5 database is built in to the browser. * HTML5 database is built in to the browser.
*/ */
public class Storage extends Plugin { public class Storage extends Plugin {
// Data Definition Language // Data Definition Language
private static final String ALTER = "alter"; private static final String ALTER = "alter";
private static final String CREATE = "create"; private static final String CREATE = "create";
private static final String DROP = "drop"; private static final String DROP = "drop";
private static final String TRUNCATE = "truncate"; private static final String TRUNCATE = "truncate";
SQLiteDatabase myDb = null; // Database object
String path = null; // Database path
String dbName = null; // Database name
/** SQLiteDatabase myDb = null; // Database object
* Constructor. String path = null; // Database path
*/ String dbName = null; // Database name
public Storage() {
}
/** /**
* Executes the request and returns PluginResult. * Constructor.
* */
* @param action public Storage() {
* The action to execute. }
* @param args
* JSONArry of arguments for the plugin.
* @param callbackId
* The callback id used when calling back into JavaScript.
* @return A PluginResult object with a status and message.
*/
public PluginResult execute(String action, JSONArray args, String callbackId) {
PluginResult.Status status = PluginResult.Status.OK;
String result = "";
try { /**
if (action.equals("openDatabase")) { * Executes the request and returns PluginResult.
this.openDatabase(args.getString(0), args.getString(1), *
args.getString(2), args.getLong(3)); * @param action
} else if (action.equals("executeSql")) { * The action to execute.
String[] s = null; * @param args
if (args.isNull(1)) { * JSONArry of arguments for the plugin.
s = new String[0]; * @param callbackId
} else { * The callback id used when calling back into JavaScript.
JSONArray a = args.getJSONArray(1); * @return A PluginResult object with a status and message.
int len = a.length(); */
s = new String[len]; public PluginResult execute(String action, JSONArray args, String callbackId) {
for (int i = 0; i < len; i++) { PluginResult.Status status = PluginResult.Status.OK;
s[i] = a.getString(i); String result = "";
}
}
this.executeSql(args.getString(0), s, args.getString(2));
}
return new PluginResult(status, result);
} catch (JSONException e) {
return new PluginResult(PluginResult.Status.JSON_EXCEPTION);
}
}
/** try {
* Identifies if action to be executed returns a value and should be run if (action.equals("openDatabase")) {
* synchronously. this.openDatabase(args.getString(0), args.getString(1),
* args.getString(2), args.getLong(3));
* @param action } else if (action.equals("executeSql")) {
* The action to execute String[] s = null;
* @return T=returns value if (args.isNull(1)) {
*/ s = new String[0];
public boolean isSynch(String action) { } else {
return true; JSONArray a = args.getJSONArray(1);
} int len = a.length();
s = new String[len];
for (int i = 0; i < len; i++) {
s[i] = a.getString(i);
}
}
this.executeSql(args.getString(0), s, args.getString(2));
}
return new PluginResult(status, result);
} catch (JSONException e) {
return new PluginResult(PluginResult.Status.JSON_EXCEPTION);
}
}
/** /**
* Clean up and close database. * Identifies if action to be executed returns a value and should be run
*/ * synchronously.
@Override *
public void onDestroy() { * @param action
if (this.myDb != null) { * The action to execute
this.myDb.close(); * @return T=returns value
this.myDb = null; */
} public boolean isSynch(String action) {
} return true;
}
// -------------------------------------------------------------------------- /**
// LOCAL METHODS * Clean up and close database.
// -------------------------------------------------------------------------- */
@Override
public void onDestroy() {
if (this.myDb != null) {
this.myDb.close();
this.myDb = null;
}
}
/** // --------------------------------------------------------------------------
* Open database. // LOCAL METHODS
* // --------------------------------------------------------------------------
* @param db
* The name of the database
* @param version
* The version
* @param display_name
* The display name
* @param size
* The size in bytes
*/
public void openDatabase(String db, String version, String display_name,
long size) {
// If database is open, then close it /**
if (this.myDb != null) { * Open database.
this.myDb.close(); *
} * @param db
* The name of the database
* @param version
* The version
* @param display_name
* The display name
* @param size
* The size in bytes
*/
public void openDatabase(String db, String version, String display_name,
long size) {
// If no database path, generate from application package // If database is open, then close it
if (this.path == null) { if (this.myDb != null) {
this.path = this.ctx.getActivity().getDir("database", Context.MODE_PRIVATE).getPath(); this.myDb.close();
} }
this.dbName = this.path + File.pathSeparator + db + ".db"; // If no database path, generate from application package
this.myDb = SQLiteDatabase.openOrCreateDatabase(this.dbName, null); if (this.path == null) {
} this.path = this.ctx.getActivity().getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath();
}
/** this.dbName = this.path + File.pathSeparator + db + ".db";
* Execute SQL statement. this.myDb = SQLiteDatabase.openOrCreateDatabase(this.dbName, null);
* }
* @param query
* The SQL query
* @param params
* Parameters for the query
* @param tx_id
* Transaction id
*/
public void executeSql(String query, String[] params, String tx_id) {
try {
if (isDDL(query)) {
this.myDb.execSQL(query);
this.sendJavascript("cordova.require('cordova/plugin/android/storage').completeQuery('" + tx_id + "', '');");
}
else {
Cursor myCursor = this.myDb.rawQuery(query, params);
this.processResults(myCursor, tx_id);
myCursor.close();
}
}
catch (SQLiteException ex) {
ex.printStackTrace();
System.out.println("Storage.executeSql(): Error=" + ex.getMessage());
// Send error message back to JavaScript
this.sendJavascript("cordova.require('cordova/plugin/android/storage').failQuery('" + ex.getMessage() + "','" + tx_id + "');");
}
}
/** /**
* Checks to see the the query is a Data Definintion command * Execute SQL statement.
* *
* @param query to be executed * @param query
* @return true if it is a DDL command, false otherwise * The SQL query
*/ * @param params
private boolean isDDL(String query) { * Parameters for the query
String cmd = query.toLowerCase(); * @param tx_id
if (cmd.startsWith(DROP) || cmd.startsWith(CREATE) || cmd.startsWith(ALTER) || cmd.startsWith(TRUNCATE)) { * Transaction id
return true; */
} public void executeSql(String query, String[] params, String tx_id) {
return false; try {
} if (isDDL(query)) {
this.myDb.execSQL(query);
this.sendJavascript("cordova.require('cordova/plugin/android/storage').completeQuery('" + tx_id + "', '');");
}
else {
Cursor myCursor = this.myDb.rawQuery(query, params);
this.processResults(myCursor, tx_id);
myCursor.close();
}
}
catch (SQLiteException ex) {
ex.printStackTrace();
System.out.println("Storage.executeSql(): Error=" + ex.getMessage());
/** // Send error message back to JavaScript
* Process query results. this.sendJavascript("cordova.require('cordova/plugin/android/storage').failQuery('" + ex.getMessage() + "','" + tx_id + "');");
* }
* @param cur }
* Cursor into query results
* @param tx_id
* Transaction id
*/
public void processResults(Cursor cur, String tx_id) {
String result = "[]"; /**
// If query result has rows * Checks to see the the query is a Data Definintion command
*
* @param query to be executed
* @return true if it is a DDL command, false otherwise
*/
private boolean isDDL(String query) {
String cmd = query.toLowerCase();
if (cmd.startsWith(DROP) || cmd.startsWith(CREATE) || cmd.startsWith(ALTER) || cmd.startsWith(TRUNCATE)) {
return true;
}
return false;
}
if (cur.moveToFirst()) { /**
JSONArray fullresult = new JSONArray(); * Process query results.
String key = ""; *
String value = ""; * @param cur
int colCount = cur.getColumnCount(); * Cursor into query results
* @param tx_id
* Transaction id
*/
public void processResults(Cursor cur, String tx_id) {
// Build up JSON result object for each row String result = "[]";
do { // If query result has rows
JSONObject row = new JSONObject();
try {
for (int i = 0; i < colCount; ++i) {
key = cur.getColumnName(i);
value = cur.getString(i);
row.put(key, value);
}
fullresult.put(row);
} catch (JSONException e) { if (cur.moveToFirst()) {
e.printStackTrace(); JSONArray fullresult = new JSONArray();
} String key = "";
String value = "";
int colCount = cur.getColumnCount();
} while (cur.moveToNext()); // Build up JSON result object for each row
do {
JSONObject row = new JSONObject();
try {
for (int i = 0; i < colCount; ++i) {
key = cur.getColumnName(i);
value = cur.getString(i);
row.put(key, value);
}
fullresult.put(row);
result = fullresult.toString(); } catch (JSONException e) {
} e.printStackTrace();
}
// Let JavaScript know that there are no more rows } while (cur.moveToNext());
this.sendJavascript("cordova.require('cordova/plugin/android/storage').completeQuery('" + tx_id + "', " + result + ");");
} result = fullresult.toString();
}
// Let JavaScript know that there are no more rows
this.sendJavascript("cordova.require('cordova/plugin/android/storage').completeQuery('" + tx_id + "', " + result + ");");
}
} }

View File

@ -45,7 +45,7 @@ public class TempListener extends Plugin implements SensorEventListener {
/** /**
* Sets the context of the Command. This can then be used to do things like * Sets the context of the Command. This can then be used to do things like
* get file paths associated with the Activity. * get file paths associated with the Activity.
* *
* @param ctx The context of the main Activity. * @param ctx The context of the main Activity.
*/ */
public void setContext(CordovaInterface ctx) { public void setContext(CordovaInterface ctx) {

View File

@ -33,7 +33,7 @@ public interface IPlugin {
/** /**
* Executes the request and returns PluginResult. * Executes the request and returns PluginResult.
* *
* @param action The action to execute. * @param action The action to execute.
* @param args JSONArry of arguments for the plugin. * @param args JSONArry of arguments for the plugin.
* @param callbackId The callback id used when calling back into JavaScript. * @param callbackId The callback id used when calling back into JavaScript.
@ -43,7 +43,7 @@ public interface IPlugin {
/** /**
* Identifies if action to be executed returns a value and should be run synchronously. * Identifies if action to be executed returns a value and should be run synchronously.
* *
* @param action The action to execute * @param action The action to execute
* @return T=returns value * @return T=returns value
*/ */
@ -66,32 +66,32 @@ public interface IPlugin {
void setView(CordovaWebView webView); void setView(CordovaWebView webView);
/** /**
* Called when the system is about to start resuming a previous activity. * Called when the system is about to start resuming a previous activity.
* *
* @param multitasking Flag indicating if multitasking is turned on for app * @param multitasking Flag indicating if multitasking is turned on for app
*/ */
void onPause(boolean multitasking); void onPause(boolean multitasking);
/** /**
* Called when the activity will start interacting with the user. * Called when the activity will start interacting with the user.
* *
* @param multitasking Flag indicating if multitasking is turned on for app * @param multitasking Flag indicating if multitasking is turned on for app
*/ */
void onResume(boolean multitasking); void onResume(boolean multitasking);
/** /**
* Called when the activity receives a new intent. * Called when the activity receives a new intent.
*/ */
void onNewIntent(Intent intent); void onNewIntent(Intent intent);
/** /**
* The final call you receive before your activity is destroyed. * The final call you receive before your activity is destroyed.
*/ */
void onDestroy(); void onDestroy();
/** /**
* Called when a message is sent to plugin. * Called when a message is sent to plugin.
* *
* @param id The message id * @param id The message id
* @param data The message data * @param data The message data
* @return Object to stop propagation or null * @return Object to stop propagation or null
@ -100,9 +100,9 @@ public interface IPlugin {
/** /**
* Called when an activity you launched exits, giving you the requestCode you started it with, * Called when an activity you launched exits, giving you the requestCode you started it with,
* the resultCode it returned, and any additional data from it. * the resultCode it returned, and any additional data from it.
* *
* @param requestCode The request code originally supplied to startActivityForResult(), * @param requestCode The request code originally supplied to startActivityForResult(),
* allowing you to identify who this result came from. * allowing you to identify who this result came from.
* @param resultCode The integer result code returned by the child activity through its setResult(). * @param resultCode The integer result code returned by the child activity through its setResult().
* @param data An Intent, which can return result data to the caller (various data can be attached to Intent "extras"). * @param data An Intent, which can return result data to the caller (various data can be attached to Intent "extras").
@ -111,7 +111,7 @@ public interface IPlugin {
/** /**
* By specifying a <url-filter> in plugins.xml you can map a URL (using startsWith atm) to this method. * By specifying a <url-filter> in plugins.xml you can map a URL (using startsWith atm) to this method.
* *
* @param url The URL that is trying to be loaded in the Cordova webview. * @param url The URL that is trying to be loaded in the Cordova webview.
* @return Return true to prevent the URL from loading. Default is false. * @return Return true to prevent the URL from loading. Default is false.
*/ */

View File

@ -22,12 +22,12 @@ import android.util.Log;
/** /**
* Log to Android logging system. * Log to Android logging system.
* *
* Log message can be a string or a printf formatted string with arguments. * Log message can be a string or a printf formatted string with arguments.
* See http://developer.android.com/reference/java/util/Formatter.html * See http://developer.android.com/reference/java/util/Formatter.html
*/ */
public class LOG { public class LOG {
public static final int VERBOSE = Log.VERBOSE; public static final int VERBOSE = Log.VERBOSE;
public static final int DEBUG = Log.DEBUG; public static final int DEBUG = Log.DEBUG;
public static final int INFO = Log.INFO; public static final int INFO = Log.INFO;
@ -36,20 +36,20 @@ public class LOG {
// Current log level // Current log level
public static int LOGLEVEL = Log.ERROR; public static int LOGLEVEL = Log.ERROR;
/** /**
* Set the current log level. * Set the current log level.
* *
* @param logLevel * @param logLevel
*/ */
public static void setLogLevel(int logLevel) { public static void setLogLevel(int logLevel) {
LOGLEVEL = logLevel; LOGLEVEL = logLevel;
Log.i("CordovaLog", "Changing log level to " + logLevel); Log.i("CordovaLog", "Changing log level to " + logLevel);
} }
/** /**
* Set the current log level. * Set the current log level.
* *
* @param logLevel * @param logLevel
*/ */
public static void setLogLevel(String logLevel) { public static void setLogLevel(String logLevel) {
@ -63,7 +63,7 @@ public class LOG {
/** /**
* Determine if log level will be logged * Determine if log level will be logged
* *
* @param logLevel * @param logLevel
* @return * @return
*/ */
@ -73,7 +73,7 @@ public class LOG {
/** /**
* Verbose log message. * Verbose log message.
* *
* @param tag * @param tag
* @param s * @param s
*/ */
@ -83,17 +83,17 @@ public class LOG {
/** /**
* Debug log message. * Debug log message.
* *
* @param tag * @param tag
* @param s * @param s
*/ */
public static void d(String tag, String s) { public static void d(String tag, String s) {
if (LOG.DEBUG >= LOGLEVEL) Log.d(tag, s); if (LOG.DEBUG >= LOGLEVEL) Log.d(tag, s);
} }
/** /**
* Info log message. * Info log message.
* *
* @param tag * @param tag
* @param s * @param s
*/ */
@ -103,7 +103,7 @@ public class LOG {
/** /**
* Warning log message. * Warning log message.
* *
* @param tag * @param tag
* @param s * @param s
*/ */
@ -113,7 +113,7 @@ public class LOG {
/** /**
* Error log message. * Error log message.
* *
* @param tag * @param tag
* @param s * @param s
*/ */
@ -123,7 +123,7 @@ public class LOG {
/** /**
* Verbose log message. * Verbose log message.
* *
* @param tag * @param tag
* @param s * @param s
* @param e * @param e
@ -134,7 +134,7 @@ public class LOG {
/** /**
* Debug log message. * Debug log message.
* *
* @param tag * @param tag
* @param s * @param s
* @param e * @param e
@ -142,10 +142,10 @@ public class LOG {
public static void d(String tag, String s, Throwable e) { public static void d(String tag, String s, Throwable e) {
if (LOG.DEBUG >= LOGLEVEL) Log.d(tag, s, e); if (LOG.DEBUG >= LOGLEVEL) Log.d(tag, s, e);
} }
/** /**
* Info log message. * Info log message.
* *
* @param tag * @param tag
* @param s * @param s
* @param e * @param e
@ -156,7 +156,7 @@ public class LOG {
/** /**
* Warning log message. * Warning log message.
* *
* @param tag * @param tag
* @param s * @param s
* @param e * @param e
@ -167,7 +167,7 @@ public class LOG {
/** /**
* Error log message. * Error log message.
* *
* @param tag * @param tag
* @param s * @param s
* @param e * @param e
@ -178,7 +178,7 @@ public class LOG {
/** /**
* Verbose log message with printf formatting. * Verbose log message with printf formatting.
* *
* @param tag * @param tag
* @param s * @param s
* @param args * @param args
@ -189,7 +189,7 @@ public class LOG {
/** /**
* Debug log message with printf formatting. * Debug log message with printf formatting.
* *
* @param tag * @param tag
* @param s * @param s
* @param args * @param args
@ -200,7 +200,7 @@ public class LOG {
/** /**
* Info log message with printf formatting. * Info log message with printf formatting.
* *
* @param tag * @param tag
* @param s * @param s
* @param args * @param args
@ -208,10 +208,10 @@ public class LOG {
public static void i(String tag, String s, Object... args) { public static void i(String tag, String s, Object... args) {
if (LOG.INFO >= LOGLEVEL) Log.i(tag, String.format(s, args)); if (LOG.INFO >= LOGLEVEL) Log.i(tag, String.format(s, args));
} }
/** /**
* Warning log message with printf formatting. * Warning log message with printf formatting.
* *
* @param tag * @param tag
* @param s * @param s
* @param args * @param args
@ -219,10 +219,10 @@ public class LOG {
public static void w(String tag, String s, Object... args) { public static void w(String tag, String s, Object... args) {
if (LOG.WARN >= LOGLEVEL) Log.w(tag, String.format(s, args)); if (LOG.WARN >= LOGLEVEL) Log.w(tag, String.format(s, args));
} }
/** /**
* Error log message with printf formatting. * Error log message with printf formatting.
* *
* @param tag * @param tag
* @param s * @param s
* @param args * @param args

View File

@ -46,7 +46,7 @@ public abstract class Plugin implements IPlugin {
/** /**
* Identifies if action to be executed returns a value and should be run synchronously. * Identifies if action to be executed returns a value and should be run synchronously.
* *
* @param action The action to execute * @param action The action to execute
* @return T=returns value * @return T=returns value
*/ */
@ -57,7 +57,7 @@ public abstract class Plugin implements IPlugin {
/** /**
* Sets the context of the Plugin. This can then be used to do things like * Sets the context of the Plugin. This can then be used to do things like
* get file paths associated with the Activity. * get file paths associated with the Activity.
* *
* @param ctx The context of the main Activity. * @param ctx The context of the main Activity.
*/ */
public void setContext(CordovaInterface ctx) { public void setContext(CordovaInterface ctx) {
@ -83,28 +83,28 @@ public abstract class Plugin implements IPlugin {
} }
/** /**
* Called when the activity will start interacting with the user. * Called when the activity will start interacting with the user.
* *
* @param multitasking Flag indicating if multitasking is turned on for app * @param multitasking Flag indicating if multitasking is turned on for app
*/ */
public void onResume(boolean multitasking) { public void onResume(boolean multitasking) {
} }
/** /**
* Called when the activity receives a new intent. * Called when the activity receives a new intent.
*/ */
public void onNewIntent(Intent intent) { public void onNewIntent(Intent intent) {
} }
/** /**
* The final call you receive before your activity is destroyed. * The final call you receive before your activity is destroyed.
*/ */
public void onDestroy() { public void onDestroy() {
} }
/** /**
* Called when a message is sent to plugin. * Called when a message is sent to plugin.
* *
* @param id The message id * @param id The message id
* @param data The message data * @param data The message data
* @return Object to stop propagation or null * @return Object to stop propagation or null
@ -115,9 +115,9 @@ public abstract class Plugin implements IPlugin {
/** /**
* Called when an activity you launched exits, giving you the requestCode you started it with, * Called when an activity you launched exits, giving you the requestCode you started it with,
* the resultCode it returned, and any additional data from it. * the resultCode it returned, and any additional data from it.
* *
* @param requestCode The request code originally supplied to startActivityForResult(), * @param requestCode The request code originally supplied to startActivityForResult(),
* allowing you to identify who this result came from. * allowing you to identify who this result came from.
* @param resultCode The integer result code returned by the child activity through its setResult(). * @param resultCode The integer result code returned by the child activity through its setResult().
* @param data An Intent, which can return result data to the caller (various data can be attached to Intent "extras"). * @param data An Intent, which can return result data to the caller (various data can be attached to Intent "extras").
@ -127,7 +127,7 @@ public abstract class Plugin implements IPlugin {
/** /**
* By specifying a <url-filter> in plugins.xml you can map a URL (using startsWith atm) to this method. * By specifying a <url-filter> in plugins.xml you can map a URL (using startsWith atm) to this method.
* *
* @param url The URL that is trying to be loaded in the Cordova webview. * @param url The URL that is trying to be loaded in the Cordova webview.
* @return Return true to prevent the URL from loading. Default is false. * @return Return true to prevent the URL from loading. Default is false.
*/ */
@ -138,7 +138,7 @@ public abstract class Plugin implements IPlugin {
/** /**
* Send generic JavaScript statement back to JavaScript. * Send generic JavaScript statement back to JavaScript.
* success(...) and error(...) should be used instead where possible. * success(...) and error(...) should be used instead where possible.
* *
* @param statement * @param statement
*/ */
public void sendJavascript(String statement) { public void sendJavascript(String statement) {
@ -147,11 +147,11 @@ public abstract class Plugin implements IPlugin {
/** /**
* Call the JavaScript success callback for this plugin. * Call the JavaScript success callback for this plugin.
* *
* This can be used if the execute code for the plugin is asynchronous meaning * This can be used if the execute code for the plugin is asynchronous meaning
* that execute should return null and the callback from the async operation can * that execute should return null and the callback from the async operation can
* call success(...) or error(...) * call success(...) or error(...)
* *
* @param pluginResult The result to return. * @param pluginResult The result to return.
* @param callbackId The callback id used when calling back into JavaScript. * @param callbackId The callback id used when calling back into JavaScript.
*/ */
@ -161,7 +161,7 @@ public abstract class Plugin implements IPlugin {
/** /**
* Helper for success callbacks that just returns the Status.OK by default * Helper for success callbacks that just returns the Status.OK by default
* *
* @param message The message to add to the success result. * @param message The message to add to the success result.
* @param callbackId The callback id used when calling back into JavaScript. * @param callbackId The callback id used when calling back into JavaScript.
*/ */
@ -171,7 +171,7 @@ public abstract class Plugin implements IPlugin {
/** /**
* Helper for success callbacks that just returns the Status.OK by default * Helper for success callbacks that just returns the Status.OK by default
* *
* @param message The message to add to the success result. * @param message The message to add to the success result.
* @param callbackId The callback id used when calling back into JavaScript. * @param callbackId The callback id used when calling back into JavaScript.
*/ */
@ -181,7 +181,7 @@ public abstract class Plugin implements IPlugin {
/** /**
* Call the JavaScript error callback for this plugin. * Call the JavaScript error callback for this plugin.
* *
* @param pluginResult The result to return. * @param pluginResult The result to return.
* @param callbackId The callback id used when calling back into JavaScript. * @param callbackId The callback id used when calling back into JavaScript.
*/ */
@ -191,7 +191,7 @@ public abstract class Plugin implements IPlugin {
/** /**
* Helper for error callbacks that just returns the Status.ERROR by default * Helper for error callbacks that just returns the Status.ERROR by default
* *
* @param message The message to add to the error result. * @param message The message to add to the error result.
* @param callbackId The callback id used when calling back into JavaScript. * @param callbackId The callback id used when calling back into JavaScript.
*/ */
@ -201,7 +201,7 @@ public abstract class Plugin implements IPlugin {
/** /**
* Helper for error callbacks that just returns the Status.ERROR by default * Helper for error callbacks that just returns the Status.ERROR by default
* *
* @param message The message to add to the error result. * @param message The message to add to the error result.
* @param callbackId The callback id used when calling back into JavaScript. * @param callbackId The callback id used when calling back into JavaScript.
*/ */

View File

@ -46,13 +46,13 @@ public class PluginEntry {
public IPlugin plugin = null; public IPlugin plugin = null;
/** /**
* Flag that indicates the plugin object should be created when PluginManager is initialized. * Flag that indicates the plugin object should be created when PluginManager is initialized.
*/ */
public boolean onload = false; public boolean onload = false;
/** /**
* Constructor * Constructor
* *
* @param service The name of the service * @param service The name of the service
* @param pluginClass The plugin class name * @param pluginClass The plugin class name
* @param onload Create plugin object when HTML page is loaded * @param onload Create plugin object when HTML page is loaded
@ -66,7 +66,7 @@ public class PluginEntry {
/** /**
* Create plugin object. * Create plugin object.
* If plugin is already created, then just return it. * If plugin is already created, then just return it.
* *
* @return The plugin object * @return The plugin object
*/ */
public IPlugin createPlugin(CordovaWebView webView, CordovaInterface ctx) { public IPlugin createPlugin(CordovaWebView webView, CordovaInterface ctx) {
@ -91,7 +91,7 @@ public class PluginEntry {
/** /**
* Get the class. * Get the class.
* *
* @param clazz * @param clazz
* @return * @return
* @throws ClassNotFoundException * @throws ClassNotFoundException
@ -108,7 +108,7 @@ public class PluginEntry {
/** /**
* Get the interfaces that a class implements and see if it implements the * Get the interfaces that a class implements and see if it implements the
* org.apache.cordova.api.Plugin interface. * org.apache.cordova.api.Plugin interface.
* *
* @param c The class to check the interfaces of. * @param c The class to check the interfaces of.
* @return Boolean indicating if the class implements org.apache.cordova.api.Plugin * @return Boolean indicating if the class implements org.apache.cordova.api.Plugin
*/ */

View File

@ -33,7 +33,7 @@ import android.content.res.XmlResourceParser;
/** /**
* PluginManager is exposed to JavaScript in the Cordova WebView. * PluginManager is exposed to JavaScript in the Cordova WebView.
* *
* Calling native plugin code can be done by calling PluginManager.exec(...) * Calling native plugin code can be done by calling PluginManager.exec(...)
* from JavaScript. * from JavaScript.
*/ */
@ -55,7 +55,7 @@ public class PluginManager {
/** /**
* Constructor. * Constructor.
* *
* @param app * @param app
* @param ctx * @param ctx
*/ */
@ -148,23 +148,23 @@ public class PluginManager {
/** /**
* Receives a request for execution and fulfills it by finding the appropriate * Receives a request for execution and fulfills it by finding the appropriate
* Java class and calling it's execute method. * Java class and calling it's execute method.
* *
* PluginManager.exec can be used either synchronously or async. In either case, a JSON encoded * PluginManager.exec can be used either synchronously or async. In either case, a JSON encoded
* string is returned that will indicate if any errors have occurred when trying to find * string is returned that will indicate if any errors have occurred when trying to find
* or execute the class denoted by the clazz argument. * or execute the class denoted by the clazz argument.
* *
* @param service String containing the service to run * @param service String containing the service to run
* @param action String containt the action that the class is supposed to perform. This is * @param action String containt the action that the class is supposed to perform. This is
* passed to the plugin execute method and it is up to the plugin developer * passed to the plugin execute method and it is up to the plugin developer
* how to deal with it. * how to deal with it.
* @param callbackId String containing the id of the callback that is execute in JavaScript if * @param callbackId String containing the id of the callback that is execute in JavaScript if
* this is an async plugin call. * this is an async plugin call.
* @param args An Array literal string containing any arguments needed in the * @param args An Array literal string containing any arguments needed in the
* plugin execute method. * plugin execute method.
* @param async Boolean indicating whether the calling JavaScript code is expecting an * @param async Boolean indicating whether the calling JavaScript code is expecting an
* immediate return value. If true, either Cordova.callbackSuccess(...) or * immediate return value. If true, either Cordova.callbackSuccess(...) or
* Cordova.callbackError(...) is called once the plugin code has executed. * Cordova.callbackError(...) is called once the plugin code has executed.
* *
* @return JSON encoded string with a response message and status. * @return JSON encoded string with a response message and status.
*/ */
public String exec(final String service, final String action, final String callbackId, final String jsonArgs, final boolean async) { public String exec(final String service, final String action, final String callbackId, final String jsonArgs, final boolean async) {
@ -231,10 +231,10 @@ public class PluginManager {
} }
/** /**
* Get the plugin object that implements the service. * Get the plugin object that implements the service.
* If the plugin object does not already exist, then create it. * If the plugin object does not already exist, then create it.
* If the service doesn't exist, then return null. * If the service doesn't exist, then return null.
* *
* @param service The name of the service. * @param service The name of the service.
* @return IPlugin or null * @return IPlugin or null
*/ */
@ -251,9 +251,9 @@ public class PluginManager {
} }
/** /**
* Add a plugin class that implements a service to the service entry table. * Add a plugin class that implements a service to the service entry table.
* This does not create the plugin object instance. * This does not create the plugin object instance.
* *
* @param service The service name * @param service The service name
* @param className The plugin class name * @param className The plugin class name
*/ */
@ -263,9 +263,9 @@ public class PluginManager {
} }
/** /**
* Add a plugin class that implements a service to the service entry table. * Add a plugin class that implements a service to the service entry table.
* This does not create the plugin object instance. * This does not create the plugin object instance.
* *
* @param entry The plugin entry * @param entry The plugin entry
*/ */
public void addService(PluginEntry entry) { public void addService(PluginEntry entry) {
@ -274,7 +274,7 @@ public class PluginManager {
/** /**
* Called when the system is about to start resuming a previous activity. * Called when the system is about to start resuming a previous activity.
* *
* @param multitasking Flag indicating if multitasking is turned on for app * @param multitasking Flag indicating if multitasking is turned on for app
*/ */
public void onPause(boolean multitasking) { public void onPause(boolean multitasking) {
@ -287,7 +287,7 @@ public class PluginManager {
/** /**
* Called when the activity will start interacting with the user. * Called when the activity will start interacting with the user.
* *
* @param multitasking Flag indicating if multitasking is turned on for app * @param multitasking Flag indicating if multitasking is turned on for app
*/ */
public void onResume(boolean multitasking) { public void onResume(boolean multitasking) {
@ -311,7 +311,7 @@ public class PluginManager {
/** /**
* Send a message to all plugins. * Send a message to all plugins.
* *
* @param id The message id * @param id The message id
* @param data The message data * @param data The message data
* @return * @return
@ -345,7 +345,7 @@ public class PluginManager {
/** /**
* Called when the URL of the webview changes. * Called when the URL of the webview changes.
* *
* @param url The URL that is being changed to. * @param url The URL that is being changed to.
* @return Return false to allow the URL to load, return true to prevent the URL from loading. * @return Return false to allow the URL to load, return true to prevent the URL from loading.
*/ */

View File

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

View File

@ -21,8 +21,8 @@ package org.apache.cordova.file;
public class EncodingException extends Exception { public class EncodingException extends Exception {
public EncodingException(String message) { public EncodingException(String message) {
super(message); super(message);
} }
} }

View File

@ -21,8 +21,8 @@ package org.apache.cordova.file;
public class FileExistsException extends Exception { public class FileExistsException extends Exception {
public FileExistsException(String msg) { public FileExistsException(String msg) {
super(msg); super(msg);
} }
} }

View File

@ -22,8 +22,8 @@ package org.apache.cordova.file;
public class InvalidModificationException extends Exception { public class InvalidModificationException extends Exception {
public InvalidModificationException(String message) { public InvalidModificationException(String message) {
super(message); super(message);
} }
} }

View File

@ -21,8 +21,8 @@ package org.apache.cordova.file;
public class NoModificationAllowedException extends Exception { public class NoModificationAllowedException extends Exception {
public NoModificationAllowedException(String message) { public NoModificationAllowedException(String message) {
super(message); super(message);
} }
} }

View File

@ -22,8 +22,8 @@ package org.apache.cordova.file;
public class TypeMismatchException extends Exception { public class TypeMismatchException extends Exception {
public TypeMismatchException(String message) { public TypeMismatchException(String message) {
super(message); super(message);
} }
} }