mirror of
https://github.com/apache/cordova-android.git
synced 2026-05-30 00:00:04 +08:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1511183dfd | |||
| a640804897 | |||
| f95fdb5873 |
@@ -5,7 +5,7 @@
|
|||||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
||||||
<title>PhoneGap</title>
|
<title>PhoneGap</title>
|
||||||
<link rel="stylesheet" href="master.css" type="text/css" media="screen" title="no title" charset="utf-8">
|
<link rel="stylesheet" href="master.css" type="text/css" media="screen" title="no title" charset="utf-8">
|
||||||
<script type="text/javascript" charset="utf-8" src="phonegap-1.3.0rc1.js"></script>
|
<script type="text/javascript" charset="utf-8" src="phonegap-1.3.0.js"></script>
|
||||||
<script type="text/javascript" charset="utf-8" src="main.js"></script>
|
<script type="text/javascript" charset="utf-8" src="main.js"></script>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title></title>
|
<title></title>
|
||||||
<script src="phonegap-1.3.0rc1.js"></script>
|
<script src="phonegap-1.3.0.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
|
|||||||
@@ -49,6 +49,13 @@ public class Capture extends Plugin {
|
|||||||
private static final int CAPTURE_IMAGE = 1; // Constant for capture image
|
private static final int CAPTURE_IMAGE = 1; // Constant for capture image
|
||||||
private static final int CAPTURE_VIDEO = 2; // Constant for capture video
|
private static final int CAPTURE_VIDEO = 2; // Constant for capture video
|
||||||
private static final String LOG_TAG = "Capture";
|
private static final String LOG_TAG = "Capture";
|
||||||
|
|
||||||
|
private static final int CAPTURE_INTERNAL_ERR = 0;
|
||||||
|
private static final int CAPTURE_APPLICATION_BUSY = 1;
|
||||||
|
private static final int CAPTURE_INVALID_ARGUMENT = 2;
|
||||||
|
private static final int CAPTURE_NO_MEDIA_FILES = 3;
|
||||||
|
private static final int CAPTURE_NOT_SUPPORTED = 20;
|
||||||
|
|
||||||
private 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
|
||||||
@@ -260,7 +267,7 @@ public class Capture extends Plugin {
|
|||||||
uri = this.ctx.getContentResolver().insert(android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI, values);
|
uri = this.ctx.getContentResolver().insert(android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI, values);
|
||||||
} catch (UnsupportedOperationException ex) {
|
} catch (UnsupportedOperationException ex) {
|
||||||
LOG.d(LOG_TAG, "Can't write to internal media storage.");
|
LOG.d(LOG_TAG, "Can't write to internal media storage.");
|
||||||
this.fail("Error capturing image - no media storage found.");
|
this.fail(createErrorObject(CAPTURE_INTERNAL_ERR, "Error capturing image - no media storage found."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -290,7 +297,7 @@ public class Capture extends Plugin {
|
|||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
this.fail("Error capturing image.");
|
this.fail(createErrorObject(CAPTURE_INTERNAL_ERR, "Error capturing image."));
|
||||||
}
|
}
|
||||||
} else if (requestCode == CAPTURE_VIDEO) {
|
} else if (requestCode == CAPTURE_VIDEO) {
|
||||||
// Get the uri of the video clip
|
// Get the uri of the video clip
|
||||||
@@ -315,7 +322,7 @@ public class Capture extends Plugin {
|
|||||||
}
|
}
|
||||||
// user canceled the action
|
// user canceled the action
|
||||||
else {
|
else {
|
||||||
this.fail("Canceled.");
|
this.fail(createErrorObject(CAPTURE_NO_MEDIA_FILES, "Canceled."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If something else
|
// If something else
|
||||||
@@ -326,7 +333,7 @@ public class Capture extends Plugin {
|
|||||||
}
|
}
|
||||||
// something bad happened
|
// something bad happened
|
||||||
else {
|
else {
|
||||||
this.fail("Did not complete!");
|
this.fail(createErrorObject(CAPTURE_NO_MEDIA_FILES, "Did not complete!"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -369,13 +376,24 @@ public class Capture extends Plugin {
|
|||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private JSONObject createErrorObject(int code, String message) {
|
||||||
|
JSONObject obj = new JSONObject();
|
||||||
|
try {
|
||||||
|
obj.put("code", code);
|
||||||
|
obj.put("message", message);
|
||||||
|
} catch (JSONException e) {
|
||||||
|
// This will never happen
|
||||||
|
}
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send error message to JavaScript.
|
* Send error message to JavaScript.
|
||||||
*
|
*
|
||||||
* @param err
|
* @param err
|
||||||
*/
|
*/
|
||||||
public void fail(String err) {
|
public void fail(JSONObject err) {
|
||||||
this.error(new PluginResult(PluginResult.Status.ERROR, err), this.callbackId);
|
this.error(new PluginResult(PluginResult.Status.ERROR, err), this.callbackId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ import android.telephony.TelephonyManager;
|
|||||||
public class Device extends Plugin {
|
public class Device extends Plugin {
|
||||||
public static final String TAG = "Device";
|
public static final String TAG = "Device";
|
||||||
|
|
||||||
public static String phonegapVersion = "1.3.0rc1"; // PhoneGap version
|
public static String phonegapVersion = "1.3.0"; // PhoneGap version
|
||||||
public static String platform = "Android"; // Device OS
|
public static String platform = "Android"; // Device OS
|
||||||
public static String uuid; // Device UUID
|
public static String uuid; // Device UUID
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user