Change commands to plugins.

This commit is contained in:
Bryce Curtis
2010-09-07 13:59:54 -05:00
parent 9e931cc3f6
commit 4f360c2680
16 changed files with 219 additions and 198 deletions
+10 -10
View File
@@ -9,9 +9,9 @@ import org.apache.commons.codec.binary.Base64;
import org.json.JSONArray;
import org.json.JSONException;
import com.phonegap.api.Command;
import com.phonegap.api.CommandManager;
import com.phonegap.api.CommandResult;
import com.phonegap.api.Plugin;
import com.phonegap.api.PluginManager;
import com.phonegap.api.PluginResult;
import android.app.Activity;
import android.content.ContentValues;
@@ -28,7 +28,7 @@ import android.webkit.WebView;
* and returns the captured image. When the camera view is closed, the screen displayed before
* the camera view was shown is redisplayed.
*/
public class CameraLauncher implements Command {
public class CameraLauncher implements Plugin {
WebView webView; // WebView object
DroidGap ctx; // DroidGap object
@@ -70,8 +70,8 @@ public class CameraLauncher implements Command {
* @param args JSONArry of arguments for the command.
* @return A CommandResult object with a status and message.
*/
public CommandResult execute(String action, JSONArray args) {
CommandResult.Status status = CommandResult.Status.OK;
public PluginResult execute(String action, JSONArray args) {
PluginResult.Status status = PluginResult.Status.OK;
String result = "";
try {
@@ -81,10 +81,10 @@ public class CameraLauncher implements Command {
else if (action.equals("takePicture")) {
this.takePicture(args.getInt(0));
}
return new CommandResult(status, result);
return new PluginResult(status, result);
} catch (JSONException e) {
e.printStackTrace();
return new CommandResult(CommandResult.Status.JSON_EXCEPTION);
return new PluginResult(PluginResult.Status.JSON_EXCEPTION);
}
}
@@ -144,7 +144,7 @@ public class CameraLauncher implements Command {
intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo));
this.imageUri = Uri.fromFile(photo);
this.ctx.startActivityForResult((Command) this, intent);
this.ctx.startActivityForResult((Plugin) this, intent);
}
/**
@@ -153,7 +153,7 @@ public class CameraLauncher implements Command {
* @param requestCode The request code originally supplied to startActivityForResult(),
* allowing you to identify who this result came from.
* @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 intent An Intent, which can return result data to the caller (various data can be attached to Intent "extras").
*/
public void onActivityResult(int requestCode, int resultCode, Intent intent) {