Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 23a1af6f authored by Selim Gurun's avatar Selim Gurun
Browse files

Provide an API to set print document name.

Bug: 13250097

The current print api for Webview does not allow setting the
print document name, so all documents show up using a hardcoded
name (which is visible to the user). Deprecate the current API
and provide a new one that allows setting the document name.

Change-Id: I7043b78e98f25bbc0e0ef33e1d6d3b0d34401e48
parent 8959ad36
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -31773,7 +31773,8 @@ package android.webkit {
    method public void clearSslPreferences();
    method public deprecated void clearView();
    method public android.webkit.WebBackForwardList copyBackForwardList();
    method public android.print.PrintDocumentAdapter createPrintDocumentAdapter();
    method public deprecated android.print.PrintDocumentAdapter createPrintDocumentAdapter();
    method public android.print.PrintDocumentAdapter createPrintDocumentAdapter(java.lang.String);
    method public void destroy();
    method public void documentHasImages(android.os.Message);
    method public void evaluateJavascript(java.lang.String, android.webkit.ValueCallback<java.lang.String>);
+16 −4
Original line number Diff line number Diff line
@@ -1134,10 +1134,19 @@ public class WebView extends AbsoluteLayout
        return mProvider.capturePicture();
    }

    /**
     * @deprecated Use {@link #createPrintDocumentAdapter(String)} which requires user
     *             to provide a print document name.
     */
    @Deprecated
    public PrintDocumentAdapter createPrintDocumentAdapter() {
        checkThread();
        if (DebugFlags.TRACE_API) Log.d(LOGTAG, "createPrintDocumentAdapter");
        return mProvider.createPrintDocumentAdapter("default");
    }

    /**
     * Creates a PrintDocumentAdapter that provides the content of this Webview for printing.
     * Only supported for API levels
     * {@link android.os.Build.VERSION_CODES#KITKAT} and above.
     *
     * The adapter works by converting the Webview contents to a PDF stream. The Webview cannot
     * be drawn during the conversion process - any such draws are undefined. It is recommended
@@ -1145,11 +1154,14 @@ public class WebView extends AbsoluteLayout
     * temporarily hide a visible WebView by using a custom PrintDocumentAdapter instance
     * wrapped around the object returned and observing the onStart and onFinish methods. See
     * {@link android.print.PrintDocumentAdapter} for more information.
     *
     * @param documentName  The user-facing name of the printed document. See
     *                      {@link android.print.PrintDocumentInfo}
     */
    public PrintDocumentAdapter createPrintDocumentAdapter() {
    public PrintDocumentAdapter createPrintDocumentAdapter(String documentName) {
        checkThread();
        if (DebugFlags.TRACE_API) Log.d(LOGTAG, "createPrintDocumentAdapter");
        return mProvider.createPrintDocumentAdapter();
        return mProvider.createPrintDocumentAdapter(documentName);
    }

    /**
+1 −1
Original line number Diff line number Diff line
@@ -147,7 +147,7 @@ public interface WebViewProvider {

    public Picture capturePicture();

    public PrintDocumentAdapter createPrintDocumentAdapter();
    public PrintDocumentAdapter createPrintDocumentAdapter(String documentName);

    public float getScale();