summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTao Bai <michaelbai@google.com>2014-09-02 14:09:49 -0700
committerTao Bai <michaelbai@google.com>2014-09-09 11:21:22 -0700
commite8df27aec8367f8718c03059af679049fc522d9c (patch)
tree3540a8f7b9252f659cf35c639c073406e9ef87c5
parent9580f6c6cb24086c250f1d1c09139c060fd8b50a (diff)
downloadframeworks_base-e8df27aec8367f8718c03059af679049fc522d9c.zip
frameworks_base-e8df27aec8367f8718c03059af679049fc522d9c.tar.gz
frameworks_base-e8df27aec8367f8718c03059af679049fc522d9c.tar.bz2
Revise createIntent and parseResult API.
- Both are move to FileChooserParams, remove UploadHelper class. - createIntent only handls non-capture intents - parseResult is the static member of FileChooseParams and should be used with createIntent. BUG:17253647,16624450 Change-Id: I81cac7c1b739880db4e4c1f2b4612ed2ee87cb1b
-rw-r--r--api/current.txt9
-rw-r--r--core/java/android/webkit/WebChromeClient.java69
-rw-r--r--core/java/android/webkit/WebViewFactoryProvider.java8
3 files changed, 42 insertions, 44 deletions
diff --git a/api/current.txt b/api/current.txt
index 9b53c05..5c18ade 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -36498,23 +36498,18 @@ package android.webkit {
public static abstract class WebChromeClient.FileChooserParams {
ctor public WebChromeClient.FileChooserParams();
+ method public abstract android.content.Intent createIntent();
method public abstract java.lang.String[] getAcceptTypes();
method public abstract java.lang.String getFilenameHint();
method public abstract int getMode();
method public abstract java.lang.CharSequence getTitle();
- method public abstract android.webkit.WebChromeClient.UploadHelper getUploadHelper();
method public abstract boolean isCaptureEnabled();
+ method public static android.net.Uri[] parseResult(int, android.content.Intent);
field public static final int MODE_OPEN = 0; // 0x0
field public static final int MODE_OPEN_MULTIPLE = 1; // 0x1
field public static final int MODE_SAVE = 3; // 0x3
}
- public static abstract class WebChromeClient.UploadHelper {
- ctor public WebChromeClient.UploadHelper();
- method public abstract android.content.Intent buildIntent();
- method public abstract android.net.Uri[] parseResult(int, android.content.Intent);
- }
-
public class WebHistoryItem implements java.lang.Cloneable {
method public android.graphics.Bitmap getFavicon();
method public java.lang.String getOriginalUrl();
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();