summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTao Bai <michaelbai@google.com>2014-09-16 15:30:27 -0700
committerTao Bai <michaelbai@google.com>2014-09-18 11:41:25 -0700
commit481681a1d37ea51a6b1ee53600efeb5013666c58 (patch)
treea1bae239641a2e5a831f954d10bf771abe02df3d /src
parent934dfe5246cd151ffd60eb6277088f58f657b81c (diff)
downloadBrowser-481681a1d37ea51a6b1ee53600efeb5013666c58.tar.gz
Using .jpg as suffix of the temporay file for camera.
Also, change to use the returned file from camcorder. Because the site might rely on the suffix to know the selected file type. BUG:17524075 Change-Id: I7b393d825b5dd11c47337de1feb7d0307fee96d7
Diffstat (limited to 'src')
-rw-r--r--src/com/android/browser/UploadHandler.java43
1 files changed, 21 insertions, 22 deletions
diff --git a/src/com/android/browser/UploadHandler.java b/src/com/android/browser/UploadHandler.java
index c20fbf6f..ab4aff67 100644
--- a/src/com/android/browser/UploadHandler.java
+++ b/src/com/android/browser/UploadHandler.java
@@ -125,18 +125,6 @@ public class UploadHandler {
}
private Intent[] createCaptureIntent() {
- try {
- File mediaPath = new File(mController.getActivity().getFilesDir(), "captured_media");
- if (!mediaPath.exists() && !mediaPath.mkdir()) {
- throw new RuntimeException("Folder cannot be created.");
- }
- File mediaFile = File.createTempFile(
- String.valueOf(System.currentTimeMillis()), null, mediaPath);
- mCapturedMedia = FileProvider.getUriForFile(mController.getActivity(),
- "com.android.browser-classic.file", mediaFile);
- } catch (java.io.IOException e) {
- throw new RuntimeException(e);
- }
String mimeType = "*/*";
String[] acceptTypes = mParams.getAcceptTypes();
if ( acceptTypes != null && acceptTypes.length > 0) {
@@ -145,7 +133,7 @@ public class UploadHandler {
Intent[] intents;
if (mimeType.equals(IMAGE_MIME_TYPE)) {
intents = new Intent[1];
- intents[0] = createCameraIntent();
+ intents[0] = createCameraIntent(createTempFileContentUri(".jpg"));
} else if (mimeType.equals(VIDEO_MIME_TYPE)) {
intents = new Intent[1];
intents[0] = createCamcorderIntent();
@@ -154,15 +142,31 @@ public class UploadHandler {
intents[0] = createSoundRecorderIntent();
} else {
intents = new Intent[3];
- intents[0] = createCameraIntent();
+ intents[0] = createCameraIntent(createTempFileContentUri(".jpg"));
intents[1] = createCamcorderIntent();
intents[2] = createSoundRecorderIntent();
}
return intents;
}
- private Intent createCameraIntent() {
- if (mCapturedMedia == null) throw new IllegalArgumentException();
+ private Uri createTempFileContentUri(String suffix) {
+ try {
+ File mediaPath = new File(mController.getActivity().getFilesDir(), "captured_media");
+ if (!mediaPath.exists() && !mediaPath.mkdir()) {
+ throw new RuntimeException("Folder cannot be created.");
+ }
+ File mediaFile = File.createTempFile(
+ String.valueOf(System.currentTimeMillis()), suffix, mediaPath);
+ return FileProvider.getUriForFile(mController.getActivity(),
+ "com.android.browser-classic.file", mediaFile);
+ } catch (java.io.IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private Intent createCameraIntent(Uri contentUri) {
+ if (contentUri == null) throw new IllegalArgumentException();
+ mCapturedMedia = contentUri;
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION |
Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
@@ -171,12 +175,7 @@ public class UploadHandler {
}
private Intent createCamcorderIntent() {
- if (mCapturedMedia == null) throw new IllegalArgumentException();
- Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
- intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION |
- Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
- intent.putExtra(MediaStore.EXTRA_OUTPUT, mCapturedMedia);
- return intent;
+ return new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
}
private Intent createSoundRecorderIntent() {