summaryrefslogtreecommitdiffstats
path: root/core/java/android/webkit
diff options
context:
space:
mode:
authorTao Bai <michaelbai@google.com>2014-09-10 21:55:15 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-09-10 21:55:15 +0000
commit96bca16a43c45d266ee56db36d46604fdcbfd6ef (patch)
treedb9fbace11b9275d3abab5c39f3544ccfb321bd6 /core/java/android/webkit
parent62d0664fed1bb251fbab605a78408b01993ef050 (diff)
parent2ca2501f5f412100d5318307d9e03129884907c2 (diff)
downloadframeworks_base-96bca16a43c45d266ee56db36d46604fdcbfd6ef.zip
frameworks_base-96bca16a43c45d266ee56db36d46604fdcbfd6ef.tar.gz
frameworks_base-96bca16a43c45d266ee56db36d46604fdcbfd6ef.tar.bz2
am cdad4651: am 3350edac: Merge "Revise createIntent and parseResult API." into lmp-dev
* commit 'cdad4651a1e93b0cfe2b199e39e5583ce9a19454': Revise createIntent and parseResult API.
Diffstat (limited to 'core/java/android/webkit')
-rw-r--r--core/java/android/webkit/WebChromeClient.java69
-rw-r--r--core/java/android/webkit/WebViewFactoryProvider.java8
2 files changed, 40 insertions, 37 deletions
diff --git a/core/java/android/webkit/WebChromeClient.java b/core/java/android/webkit/WebChromeClient.java
index 547acfa..46a7fd0 100644
--- a/core/java/android/webkit/WebChromeClient.java
+++ b/core/java/android/webkit/WebChromeClient.java
@@ -416,38 +416,6 @@ public class WebChromeClient {
}
/**
- * UploadHelper simplifies file upload operations by providing helper methods that
- * would handle most common file picker/media capture requests. The application
- * can use the helper to build an intent to start a file picker, and then parse
- * the result returned by the activity.
- *
- * How to use:
- * 1. Create a helper using {@link FileChooserParams#getUploadHelper}
- * 2. Build an intent using {@link UploadHelper#buildIntent}
- * 3. Fire the intent using {@link android.app.Activity#startActivityForResult}.
- * 4. Check for ActivityNotFoundException and take a user friendly action if thrown.
- * 5. Listen the result using {@link android.app.Activity#onActivityResult}
- * 6. Parse the result using {@link UploadHelper#parseResult}
- * 7. Send the result using filePathCallback of {@link WebChromeClient#onShowFileChooser}
- */
- public static abstract class UploadHelper {
- /**
- * Returns an intent that would start a file picker for file selection/media capture.
- */
- public abstract Intent buildIntent();
-
- /**
- * Parses the result returned by the file picker activity.
- *
- * @param resultCode the integer result code returned by the file picker activity.
- * @param data the intent returned by the file picker activity.
- * @return the Uris of selected file(s) or null if the resultCode indicates
- * activity canceled or any other error.
- */
- public abstract Uri[] parseResult(int resultCode, Intent data);
- }
-
- /**
* Parameters used in the {@link #onShowFileChooser} method.
*/
public static abstract class FileChooserParams {
@@ -464,11 +432,17 @@ public class WebChromeClient {
public static final int MODE_SAVE = 3;
/**
- * Returns a helper to simplify choosing and uploading files. The helper builds a default
- * intent that the application can send using startActivityForResult and processes the
- * results.
+ * Parse the result returned by the file picker activity. This method should be used with
+ * {@link #createIntent}. Refer to {@link #createIntent} for how to use it.
+ *
+ * @param resultCode the integer result code returned by the file picker activity.
+ * @param data the intent returned by the file picker activity.
+ * @return the Uris of selected file(s) or null if the resultCode indicates
+ * activity canceled or any other error.
*/
- public abstract UploadHelper getUploadHelper();
+ public static Uri[] parseResult(int resultCode, Intent data) {
+ return WebViewFactory.getProvider().getStatics().parseFileChooserResult(resultCode, data);
+ }
/**
* Returns file chooser mode.
@@ -500,7 +474,28 @@ public class WebChromeClient {
* The file name of a default selection if specified, or null.
*/
public abstract String getFilenameHint();
- };
+
+ /**
+ * Creates an intent that would start a file picker for file selection.
+ * The Intent supports choosing files from simple file sources available
+ * on the device. Some advanced sources (for example, live media capture)
+ * may not be supported and applications wishing to support these sources
+ * or more advanced file operations should build their own Intent.
+ *
+ * <pre>
+ * How to use:
+ * 1. Build an intent using {@link #createIntent}
+ * 2. Fire the intent using {@link android.app.Activity#startActivityForResult}.
+ * 3. Check for ActivityNotFoundException and take a user friendly action if thrown.
+ * 4. Listen the result using {@link android.app.Activity#onActivityResult}
+ * 5. Parse the result using {@link #parseResult} only if media capture was not requested.
+ * 6. Send the result using filePathCallback of {@link WebChromeClient#onShowFileChooser}
+ * </pre>
+ *
+ * @return an Intent that supports basic file chooser sources.
+ */
+ public abstract Intent createIntent();
+ }
/**
* Tell the client to open a file chooser.
diff --git a/core/java/android/webkit/WebViewFactoryProvider.java b/core/java/android/webkit/WebViewFactoryProvider.java
index 20bb932..d37d217 100644
--- a/core/java/android/webkit/WebViewFactoryProvider.java
+++ b/core/java/android/webkit/WebViewFactoryProvider.java
@@ -17,6 +17,8 @@
package android.webkit;
import android.content.Context;
+import android.content.Intent;
+import android.net.Uri;
/**
* This is the main entry-point into the WebView back end implementations, which the WebView
@@ -64,6 +66,12 @@ public interface WebViewFactoryProvider {
* {@link android.webkit.WebView#setSlowWholeDocumentDrawEnabled(boolean) }
*/
void enableSlowWholeDocumentDraw();
+
+ /**
+ * Implement the API method
+ * {@link android.webkit.WebChromeClient.FileChooserParams#parseResult(int, Intent)}
+ */
+ Uri[] parseFileChooserResult(int resultCode, Intent intent);
}
Statics getStatics();