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

Commit bebc5620 authored by Tao Bai's avatar Tao Bai Committed by Android (Google) Code Review
Browse files

Merge "Revise createIntent and parseResult API." into lmp-dev

parents 66c0d0cb e8df27ae
Loading
Loading
Loading
Loading
+2 −7
Original line number Diff line number Diff line
@@ -36482,23 +36482,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();
+32 −37
Original line number Diff line number Diff line
@@ -415,38 +415,6 @@ public class WebChromeClient {
        return false;
    }

    /**
     * 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.
     */
@@ -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.
+8 −0
Original line number Diff line number Diff line
@@ -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();