mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-01 02:12:58 +08:00
Merge branch 'master' of git://github.com/phonegap/phonegap-android
This commit is contained in:
commit
9bf3a82964
@ -95,7 +95,13 @@ public class Capture extends Plugin {
|
|||||||
obj.put("duration", 0);
|
obj.put("duration", 0);
|
||||||
obj.put("codecs", "");
|
obj.put("codecs", "");
|
||||||
|
|
||||||
if (mimeType.equals("image/jpeg")) {
|
// If the mimeType isn't set the rest will fail
|
||||||
|
// so let's see if we can determine it.
|
||||||
|
if (mimeType == null || mimeType.equals("")) {
|
||||||
|
mimeType = FileUtils.getMimeType(filePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mimeType.equals("image/jpeg") || filePath.endsWith(".jpg")) {
|
||||||
obj = getImageData(filePath, obj);
|
obj = getImageData(filePath, obj);
|
||||||
}
|
}
|
||||||
else if (filePath.endsWith("audio/3gpp")) {
|
else if (filePath.endsWith("audio/3gpp")) {
|
||||||
|
@ -18,8 +18,10 @@ import org.json.JSONArray;
|
|||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
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.util.Log;
|
import android.util.Log;
|
||||||
import android.webkit.MimeTypeMap;
|
import android.webkit.MimeTypeMap;
|
||||||
|
|
||||||
@ -228,22 +230,34 @@ public class FileUtils extends Plugin {
|
|||||||
*/
|
*/
|
||||||
private JSONObject resolveLocalFileSystemURI(String url) throws IOException, JSONException {
|
private JSONObject resolveLocalFileSystemURI(String url) throws IOException, JSONException {
|
||||||
String decoded = URLDecoder.decode(url, "UTF-8");
|
String decoded = URLDecoder.decode(url, "UTF-8");
|
||||||
// Test to see if this is a valid URL first
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
URL testUrl = new URL(decoded);
|
|
||||||
|
|
||||||
File fp = null;
|
File fp = null;
|
||||||
if (decoded.startsWith("file://")) {
|
|
||||||
fp = new File(decoded.substring(7, decoded.length()));
|
// Handle the special case where you get an Android content:// uri.
|
||||||
} else {
|
if (decoded.startsWith("content:")) {
|
||||||
fp = new File(decoded);
|
Cursor cursor = this.ctx.managedQuery(Uri.parse(decoded), new String[] { MediaStore.Images.Media.DATA }, null, null, null);
|
||||||
}
|
// Note: MediaStore.Images/Audio/Video.Media.DATA is always "_data"
|
||||||
if (!fp.exists()) {
|
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
|
||||||
throw new FileNotFoundException();
|
cursor.moveToFirst();
|
||||||
}
|
fp = new File(cursor.getString(column_index));
|
||||||
if (!fp.canRead()) {
|
} else {
|
||||||
throw new IOException();
|
// Test to see if this is a valid URL first
|
||||||
}
|
@SuppressWarnings("unused")
|
||||||
|
URL testUrl = new URL(decoded);
|
||||||
|
|
||||||
|
if (decoded.startsWith("file://")) {
|
||||||
|
fp = new File(decoded.substring(7, decoded.length()));
|
||||||
|
} else {
|
||||||
|
fp = new File(decoded);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!fp.exists()) {
|
||||||
|
throw new FileNotFoundException();
|
||||||
|
}
|
||||||
|
if (!fp.canRead()) {
|
||||||
|
throw new IOException();
|
||||||
|
}
|
||||||
return getEntry(fp);
|
return getEntry(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user