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

Commit 7dee6551 authored by Toby Sargeant's avatar Toby Sargeant Committed by Android (Google) Code Review
Browse files

Merge "[webview] Add a force dark WebSetting"

parents a0567f4d fec405a3
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -53234,6 +53234,7 @@ package android.webkit {
    method public abstract boolean getDomStorageEnabled();
    method public abstract java.lang.String getFantasyFontFamily();
    method public abstract java.lang.String getFixedFontFamily();
    method public abstract int getForceDarkMode();
    method public abstract boolean getJavaScriptCanOpenWindowsAutomatically();
    method public abstract boolean getJavaScriptEnabled();
    method public abstract android.webkit.WebSettings.LayoutAlgorithm getLayoutAlgorithm();
@@ -53280,6 +53281,7 @@ package android.webkit {
    method public abstract deprecated void setEnableSmoothTransition(boolean);
    method public abstract void setFantasyFontFamily(java.lang.String);
    method public abstract void setFixedFontFamily(java.lang.String);
    method public abstract void setForceDarkMode(int);
    method public abstract deprecated void setGeolocationDatabasePath(java.lang.String);
    method public abstract void setGeolocationEnabled(boolean);
    method public abstract void setJavaScriptCanOpenWindowsAutomatically(boolean);
@@ -53310,6 +53312,9 @@ package android.webkit {
    method public abstract void setUserAgentString(java.lang.String);
    method public abstract boolean supportMultipleWindows();
    method public abstract boolean supportZoom();
    field public static final int FORCE_DARK_AUTO = 0; // 0x0
    field public static final int FORCE_DARK_OFF = -1; // 0xffffffff
    field public static final int FORCE_DARK_ON = 1; // 0x1
    field public static final int LOAD_CACHE_ELSE_NETWORK = 1; // 0x1
    field public static final int LOAD_CACHE_ONLY = 3; // 0x3
    field public static final int LOAD_DEFAULT = -1; // 0xffffffff
+53 −0
Original line number Diff line number Diff line
@@ -224,6 +224,42 @@ public abstract class WebSettings {
     */
    public static final int MIXED_CONTENT_COMPATIBILITY_MODE = 2;

    /** @hide */
    @IntDef(prefix = { "FORCE_DARK_" }, value = {
            FORCE_DARK_OFF,
            FORCE_DARK_AUTO,
            FORCE_DARK_ON
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface ForceDarkMode {}

    /**
     * Used with {@link #setForceDarkMode}
     *
     * Disable force dark, irrespective of the force dark mode of the WebView parent. In this mode,
     * WebView content will always be rendered as-is, regardless of whether native views are being
     * automatically darkened.
     */
    public static final int FORCE_DARK_OFF = -1;

    /**
     * Used with {@link #setForceDarkMode}
     *
     * Enable force dark, dependent on the state of the WebView parent. If the WebView parent view
     * is being automatically rendered in dark mode, then WebView content will be rendered so as to
     * emulate a dark theme. WebViews that are not attached to the view hierarchy will not be
     * inverted.
     */
    public static final int FORCE_DARK_AUTO = 0;

    /**
     * Used with {@link #setForceDarkMode}
     *
     * Unconditionally enable force dark. In this mode WebView content will always be rendered so
     * as to emulate a dark theme.
     */
    public static final int FORCE_DARK_ON = +1;

    /**
     * Enables dumping the pages navigation cache to a text file. The default
     * is {@code false}.
@@ -1428,6 +1464,23 @@ public abstract class WebSettings {
    public abstract boolean getSafeBrowsingEnabled();


    /**
     * Set the force dark mode for this WebView.
     */
    public void setForceDarkMode(@ForceDarkMode int forceDarkMode) {
        // Stub implementation to satisfy Roboelectrc shadows that don't override this yet.
    }

    /**
     * Get the force dark mode for this WebView.
     *
     * @return the currently set force dark mode.
     */
    public @ForceDarkMode int getForceDarkMode() {
        // Stub implementation to satisfy Roboelectrc shadows that don't override this yet.
        return FORCE_DARK_AUTO;
    }

    /**
     * @hide
     */