diff options
author | Ben Murdoch <benm@google.com> | 2012-01-11 10:56:43 +0000 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2012-04-13 14:03:56 +0100 |
commit | 8cad413fe902010140cf20aad47c2f4e7a51f8d2 (patch) | |
tree | 105ee0228d351fa1d27c681846e2a229017e7452 /src/com/android/browser/UploadHandler.java | |
parent | 981bd08923014c7208f7b59fbe6a00db90c24e22 (diff) | |
download | packages_apps_Browser-8cad413fe902010140cf20aad47c2f4e7a51f8d2.zip packages_apps_Browser-8cad413fe902010140cf20aad47c2f4e7a51f8d2.tar.gz packages_apps_Browser-8cad413fe902010140cf20aad47c2f4e7a51f8d2.tar.bz2 |
Add support for HTML Media Capture "capture" attribute.
Receive the value for the new "capture" attribute on HTML
file pickers, and do the right thing with it.
Requires changes in WebKit
(I0a921be31fda79a43c05da4fe22d9c808d92709c)
and the framework (I494adc1274ca21ce8fe52a6c7b6b758217927e66).
Bug: 5771207
Change-Id: I38dfe2df043fdba1388384dbd3b5370737eb38e5
Diffstat (limited to 'src/com/android/browser/UploadHandler.java')
-rw-r--r-- | src/com/android/browser/UploadHandler.java | 58 |
1 files changed, 28 insertions, 30 deletions
diff --git a/src/com/android/browser/UploadHandler.java b/src/com/android/browser/UploadHandler.java index 5947e4a..a9560bb 100644 --- a/src/com/android/browser/UploadHandler.java +++ b/src/com/android/browser/UploadHandler.java @@ -90,7 +90,7 @@ public class UploadHandler { mCaughtActivityNotFoundException = false; } - void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType) { + void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture) { final String imageMimeType = "image/*"; final String videoMimeType = "video/*"; @@ -102,8 +102,8 @@ public class UploadHandler { final String mediaSourceValueMicrophone = "microphone"; // According to the spec, media source can be 'filesystem' or 'camera' or 'camcorder' - // or 'microphone'. - String mediaSource = ""; + // or 'microphone' and the default value should be 'filesystem'. + String mediaSource = mediaSourceValueFileSystem; if (mUploadMessage != null) { // Already a file picker operation in progress. @@ -116,12 +116,22 @@ public class UploadHandler { String params[] = acceptType.split(";"); String mimeType = params[0]; - for (String p : params) { - String[] keyValue = p.split("="); - if (keyValue.length == 2) { - // Process key=value parameters. - if (mediaSourceKey.equals(keyValue[0])) { - mediaSource = keyValue[1]; + if (capture.length() > 0) { + mediaSource = capture; + } + + if (capture.equals(mediaSourceValueFileSystem)) { + // To maintain backwards compatibility with the previous implementation + // of the media capture API, if the value of the 'capture' attribute is + // "filesystem", we should examine the accept-type for a MIME type that + // may specify a different capture value. + for (String p : params) { + String[] keyValue = p.split("="); + if (keyValue.length == 2) { + // Process key=value parameters. + if (mediaSourceKey.equals(keyValue[0])) { + mediaSource = keyValue[1]; + } } } } @@ -135,14 +145,10 @@ public class UploadHandler { // camera directly. startActivity(createCameraIntent()); return; - } else if (mediaSource.equals(mediaSourceValueFileSystem)) { - // Specified 'image/*' and requested the filesystem, so go ahead and launch an - // OPENABLE intent. - startActivity(createOpenableIntent(imageMimeType)); - return; } else { - // Specified just 'image/*', so launch an intent for both the Camera and image/* - // OPENABLE. + // Specified just 'image/*', capture=filesystem, or an invalid capture parameter. + // In all these cases we show a traditional picker filetered on accept type + // so launch an intent for both the Camera and image/* OPENABLE. Intent chooser = createChooserIntent(createCameraIntent()); chooser.putExtra(Intent.EXTRA_INTENT, createOpenableIntent(imageMimeType)); startActivity(chooser); @@ -154,14 +160,10 @@ public class UploadHandler { // camcorder directly. startActivity(createCamcorderIntent()); return; - } else if (mediaSource.equals(mediaSourceValueFileSystem)) { - // Specified 'video/*' and requested the filesystem, so go ahead and launch an - // an OPENABLE intent. - startActivity(createOpenableIntent(videoMimeType)); - return; - } else { - // Specified just 'video/*', so go ahead and launch an intent for both camcorder and - // video/* OPENABLE. + } else { + // Specified just 'video/*', capture=filesystem or an invalid capture parameter. + // In all these cases we show an intent for the traditional file picker, filtered + // on accept type so launch an intent for both camcorder and video/* OPENABLE. Intent chooser = createChooserIntent(createCamcorderIntent()); chooser.putExtra(Intent.EXTRA_INTENT, createOpenableIntent(videoMimeType)); startActivity(chooser); @@ -173,13 +175,9 @@ public class UploadHandler { // recorder. startActivity(createSoundRecorderIntent()); return; - } else if (mediaSource.equals(mediaSourceValueFileSystem)) { - // Specified 'audio/*' and requested filesystem, so go ahead and launch an - // OPENABLE intent. - startActivity(createOpenableIntent(audioMimeType)); - return; } else { - // Specified just 'audio/*', so go ahead and launch an intent for both the sound + // Specified just 'audio/*', capture=filesystem of an invalid capture parameter. + // In all these cases so go ahead and launch an intent for both the sound // recorder and audio/* OPENABLE. Intent chooser = createChooserIntent(createSoundRecorderIntent()); chooser.putExtra(Intent.EXTRA_INTENT, createOpenableIntent(audioMimeType)); |