diff options
author | Selim Gurun <sgurun@google.com> | 2013-08-12 18:27:26 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2013-08-12 18:27:38 +0000 |
commit | 1232c51eed998bec13787d75204303502f9e195f (patch) | |
tree | 5b22dad40ff58ba542a4bc171c6891063bf43ad0 /core/java/android/webkit | |
parent | 964f2b3028d0107a9cb6ac25e1e5b3abd8344868 (diff) | |
parent | 2167c0be56cc859e38f69df150747055d67b1ea0 (diff) | |
download | frameworks_base-1232c51eed998bec13787d75204303502f9e195f.zip frameworks_base-1232c51eed998bec13787d75204303502f9e195f.tar.gz frameworks_base-1232c51eed998bec13787d75204303502f9e195f.tar.bz2 |
Merge "Add the API to support webview printing" into klp-dev
Diffstat (limited to 'core/java/android/webkit')
-rw-r--r-- | core/java/android/webkit/WebView.java | 29 | ||||
-rw-r--r-- | core/java/android/webkit/WebViewClassic.java | 11 | ||||
-rw-r--r-- | core/java/android/webkit/WebViewProvider.java | 4 |
3 files changed, 44 insertions, 0 deletions
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index 326d47e..0224fbe 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -48,6 +48,7 @@ import android.widget.AbsoluteLayout; import java.io.BufferedWriter; import java.io.File; +import java.io.OutputStream; import java.util.Map; /** @@ -1034,6 +1035,34 @@ public class WebView extends AbsoluteLayout } /** + * Exports the contents of this Webview as PDF. Only supported for API levels + * {@link android.os.Build.VERSION_CODES#KEY_LIME_PIE} and above. + * + * @param out The stream to export the PDF contents to. Cannot be null. + * @param width The page width. Should be larger than 0. + * @param height The page height. Should be larger than 0. + * @param resultCallback A callback to be invoked when the PDF content is exported. + * A true indicates success, and a false failure. + * + * TODO: explain method parameters, margins, consider making the callback + * return more meaningful information, explain any threading concerns, HW + * draw limitations, and make it public. + * TODO: at the moment we are asking app to provide paper size information (width + * and height). This is likely not ideal (I think need margin info too). + * Another approach would be using PrintAttributes. This is to be clarified later. + * + * TODO: explain this webview will not draw during export (onDraw will clear to + * background color) so recommend taking it offscreen, or putting in a layer with an + * overlaid progress UI / spinner. + * @hide + */ + public void exportToPdf(OutputStream out, int width, int height, + ValueCallback<Boolean> resultCallback) { + checkThread(); + mProvider.exportToPdf(out, width, height, resultCallback); + } + + /** * Gets the current scale of this WebView. * * @return the current scale diff --git a/core/java/android/webkit/WebViewClassic.java b/core/java/android/webkit/WebViewClassic.java index b930276..b9b10f1 100644 --- a/core/java/android/webkit/WebViewClassic.java +++ b/core/java/android/webkit/WebViewClassic.java @@ -2892,6 +2892,17 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc } /** + * See {@link WebView#exportToPdf()} + */ + @Override + public void exportToPdf(java.io.OutputStream out, int width, int height, + ValueCallback<Boolean> resultCallback) { + // K-only API not implemented in WebViewClassic. + throw new IllegalStateException("This API not supported in Classic WebView."); + + } + + /** * See {@link WebView#getScale()} */ @Override diff --git a/core/java/android/webkit/WebViewProvider.java b/core/java/android/webkit/WebViewProvider.java index 8c5c4ce..17b4061 100644 --- a/core/java/android/webkit/WebViewProvider.java +++ b/core/java/android/webkit/WebViewProvider.java @@ -40,6 +40,7 @@ import android.webkit.WebView.PictureListener; import java.io.BufferedWriter; import java.io.File; +import java.io.OutputStream; import java.util.Map; /** @@ -146,6 +147,9 @@ public interface WebViewProvider { public Picture capturePicture(); + public void exportToPdf(OutputStream out, int width, int height, + ValueCallback<Boolean> resultCallback); + public float getScale(); public void setInitialScale(int scaleInPercent); |