Merge "WebView: Revise setAlgorithmicDarkeningAllowed Javadoc" into tm-dev

This commit is contained in:
TreeHugger Robot
2022-03-03 00:59:06 +00:00
committed by Android (Google) Code Review

View File

@@ -1554,7 +1554,7 @@ public abstract class WebSettings {
* @see #getForceDark * @see #getForceDark
* @deprecated The "force dark" model previously implemented by WebView was complex * @deprecated The "force dark" model previously implemented by WebView was complex
* and didn't interoperate well with current Web standards for * and didn't interoperate well with current Web standards for
* prefers-color-scheme and color-scheme. In apps with * {@code prefers-color-scheme} and {@code color-scheme}. In apps with
* {@code targetSdkVersion} ≥ {@link android.os.Build.VERSION_CODES#TIRAMISU} * {@code targetSdkVersion} ≥ {@link android.os.Build.VERSION_CODES#TIRAMISU}
* this API is a no-op and WebView will always use the dark style defined by web content * this API is a no-op and WebView will always use the dark style defined by web content
* authors if the app's theme is dark. To customize the behavior, refer to * authors if the app's theme is dark. To customize the behavior, refer to
@@ -1602,6 +1602,61 @@ public abstract class WebSettings {
* If Android is applying Force Dark to WebView then WebView will ignore the value of * If Android is applying Force Dark to WebView then WebView will ignore the value of
* this setting and behave as if it were set to true. * this setting and behave as if it were set to true.
* *
* <p>
* The deprecated {@link #setForceDark} and related API are no-ops in apps with
* {@code targetSdkVersion} &ge; {@link android.os.Build.VERSION_CODES#TIRAMISU},
* but they still apply to apps with
* {@code targetSdkVersion} &lt; {@link android.os.Build.VERSION_CODES#TIRAMISU}.
*
* <p>
* The below table summarizes how APIs work with different apps.
*
* <table border="2" width="85%" align="center" cellpadding="5">
* <thead>
* <tr>
* <th>App</th>
* <th>Web content which uses {@code prefers-color-scheme}</th>
* <th>Web content which does not use {@code prefers-color-scheme}</th>
* </tr>
* </thead>
* <tbody>
* <tr>
* <td>App with {@code isLightTheme} True or not set</td>
* <td>Renders with the light theme defined by the content author.</td>
* <td>Renders with the default styling defined by the content author.</td>
* </tr>
* <tr>
* <td>App with Android forceDark in effect</td>
* <td>Renders with the dark theme defined by the content author.</td>
* <td>Renders with the styling modified to dark colors by an algorithm
* if allowed by the content author.</td>
* </tr>
* <tr>
* <td>App with {@code isLightTheme} False,
* {@code targetSdkVersion} &lt; {@link android.os.Build.VERSION_CODES#TIRAMISU},
* and has {@code FORCE_DARK_AUTO}</td>
* <td>Renders with the dark theme defined by the content author.</td>
* <td>Renders with the default styling defined by the content author.</td>
* </tr>
* <tr>
* <td>App with {@code isLightTheme} False,
* {@code targetSdkVersion} &ge; {@link android.os.Build.VERSION_CODES#TIRAMISU},
* and {@code setAlgorithmicDarkening(false)}</td>
* <td>Renders with the dark theme defined by the content author.</td>
* <td>Renders with the default styling defined by the content author.</td>
* </tr>
* <tr>
* <td>App with {@code isLightTheme} False,
* {@code targetSdkVersion} &ge; {@link android.os.Build.VERSION_CODES#TIRAMISU},
* and {@code setAlgorithmicDarkening(true)}</td>
* <td>Renders with the dark theme defined by the content author.</td>
* <td>Renders with the styling modified to dark colors by an algorithm if allowed
* by the content author.</td>
* </tr>
* </tbody>
* </table>
* </p>
*
* @param allow allow algorithmic darkening or not. * @param allow allow algorithmic darkening or not.
*/ */
public void setAlgorithmicDarkeningAllowed(boolean allow) { public void setAlgorithmicDarkeningAllowed(boolean allow) {