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

Commit 22df87b6 authored by Selim Gurun's avatar Selim Gurun Committed by Android (Google) Code Review
Browse files

Merge "Added the callback signal." into klp-dev

parents aed96e1b fc3f4ee8
Loading
Loading
Loading
Loading
+17 −14
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import android.graphics.drawable.Drawable;
import android.net.http.SslCertificate;
import android.os.Build;
import android.os.Bundle;
import android.os.CancellationSignal;
import android.os.Looper;
import android.os.Message;
import android.os.StrictMode;
@@ -1043,24 +1044,26 @@ public class WebView extends AbsoluteLayout
     * @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.
     *                       A true indicates success, and a false failure. Cannot be null.
     * @param cancellationSignal Signal for cancelling the PDF conversion request. Must not
     *                       be null.
     *
     * The PDF conversion is done asynchronously and the PDF output is written to the provided
     * outputstream. The caller should not close the outputstream until the resultCallback is
     * called, indicating PDF conversion is complete. Webview cannot be drawn during the pdf
     * export so the  application is recommended to take it offscreen, or putting in a layer
     * with an overlaid progress UI / spinner.
     *
     * If the caller cancels the task using the cancellationSignal, the cancellation will be
     * acked using the resultCallback signal.
     *
     * TODO(sgurun) margins, explain the units, make it public.
     * @hide
     */
    public void exportToPdf(OutputStream out, int width, int height,
            ValueCallback<Boolean> resultCallback) {
            ValueCallback<Boolean> resultCallback, CancellationSignal cancellationSignal) {
        checkThread();
        mProvider.exportToPdf(out, width, height, resultCallback);
        mProvider.exportToPdf(out, width, height, resultCallback, cancellationSignal);
    }

    /**
+2 −1
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@ import android.net.http.SslCertificate;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.CancellationSignal;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
@@ -2896,7 +2897,7 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
     */
    @Override
    public void exportToPdf(java.io.OutputStream out, int width, int height,
            ValueCallback<Boolean> resultCallback) {
            ValueCallback<Boolean> resultCallback, CancellationSignal cancellationSignal) {
        // K-only API not implemented in WebViewClassic.
        throw new IllegalStateException("This API not supported on Android 4.3 and earlier");

+2 −1
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.net.http.SslCertificate;
import android.os.Bundle;
import android.os.CancellationSignal;
import android.os.Message;
import android.view.KeyEvent;
import android.view.MotionEvent;
@@ -148,7 +149,7 @@ public interface WebViewProvider {
    public Picture capturePicture();

    public void exportToPdf(OutputStream out, int width, int height,
            ValueCallback<Boolean> resultCallback);
            ValueCallback<Boolean> resultCallback, CancellationSignal cancellationSignal);

    public float getScale();