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

Commit 70f93ee6 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add API to set tonal shadow color"

parents b0c854ef d8be4a0a
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -969,7 +969,9 @@ package android {
    field public static final int orderingFromXml = 16843239; // 0x10101e7
    field public static final int orientation = 16842948; // 0x10100c4
    field public static final int outAnimation = 16843128; // 0x1010178
    field public static final int outlineAmbientShadowColor = 16844162; // 0x1010582
    field public static final int outlineProvider = 16843960; // 0x10104b8
    field public static final int outlineSpotShadowColor = 16844161; // 0x1010581
    field public static final int overScrollFooter = 16843459; // 0x10102c3
    field public static final int overScrollHeader = 16843458; // 0x10102c2
    field public static final int overScrollMode = 16843457; // 0x10102c1
@@ -47235,7 +47237,9 @@ package android.view {
    method public int getNextFocusRightId();
    method public int getNextFocusUpId();
    method public android.view.View.OnFocusChangeListener getOnFocusChangeListener();
    method public int getOutlineAmbientShadowColor();
    method public android.view.ViewOutlineProvider getOutlineProvider();
    method public int getOutlineSpotShadowColor();
    method public int getOverScrollMode();
    method public android.view.ViewOverlay getOverlay();
    method public int getPaddingBottom();
@@ -47557,7 +47561,9 @@ package android.view {
    method public void setOnScrollChangeListener(android.view.View.OnScrollChangeListener);
    method public void setOnSystemUiVisibilityChangeListener(android.view.View.OnSystemUiVisibilityChangeListener);
    method public void setOnTouchListener(android.view.View.OnTouchListener);
    method public void setOutlineAmbientShadowColor(int);
    method public void setOutlineProvider(android.view.ViewOutlineProvider);
    method public void setOutlineSpotShadowColor(int);
    method public void setOverScrollMode(int);
    method public void setPadding(int, int, int, int);
    method public void setPaddingRelative(int, int, int, int);
+25 −4
Original line number Diff line number Diff line
@@ -353,9 +353,24 @@ public class RenderNode {
        return nHasShadow(mNativeRenderNode);
    }

    /** setShadowColor */
    public boolean setShadowColor(int color) {
        return nSetShadowColor(mNativeRenderNode, color);
    /** setSpotShadowColor */
    public boolean setSpotShadowColor(int color) {
        return nSetSpotShadowColor(mNativeRenderNode, color);
    }

    /** setAmbientShadowColor */
    public boolean setAmbientShadowColor(int color) {
        return nSetAmbientShadowColor(mNativeRenderNode, color);
    }

    /** getSpotShadowColor */
    public int getSpotShadowColor() {
        return nGetSpotShadowColor(mNativeRenderNode);
    }

    /** getAmbientShadowColor */
    public int getAmbientShadowColor() {
        return nGetAmbientShadowColor(mNativeRenderNode);
    }

    /**
@@ -915,7 +930,13 @@ public class RenderNode {
    @CriticalNative
    private static native boolean nHasShadow(long renderNode);
    @CriticalNative
    private static native boolean nSetShadowColor(long renderNode, int color);
    private static native boolean nSetSpotShadowColor(long renderNode, int color);
    @CriticalNative
    private static native boolean nSetAmbientShadowColor(long renderNode, int color);
    @CriticalNative
    private static native int nGetSpotShadowColor(long renderNode);
    @CriticalNative
    private static native int nGetAmbientShadowColor(long renderNode);
    @CriticalNative
    private static native boolean nSetClipToOutline(long renderNode, boolean clipToOutline);
    @CriticalNative
+60 −3
Original line number Diff line number Diff line
@@ -725,6 +725,8 @@ import java.util.function.Predicate;
 * @attr ref android.R.styleable#View_nextFocusRight
 * @attr ref android.R.styleable#View_nextFocusUp
 * @attr ref android.R.styleable#View_onClick
 * @attr ref android.R.styleable#View_outlineSpotShadowColor
 * @attr ref android.R.styleable#View_outlineAmbientShadowColor
 * @attr ref android.R.styleable#View_padding
 * @attr ref android.R.styleable#View_paddingHorizontal
 * @attr ref android.R.styleable#View_paddingVertical
@@ -5446,6 +5448,12 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
                        setAccessibilityPaneTitle(a.getString(attr));
                    }
                    break;
                case R.styleable.View_outlineSpotShadowColor:
                    setOutlineSpotShadowColor(a.getColor(attr, Color.BLACK));
                    break;
                case R.styleable.View_outlineAmbientShadowColor:
                    setOutlineAmbientShadowColor(a.getColor(attr, Color.BLACK));
                    break;
            }
        }
@@ -15481,14 +15489,61 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
    }
    /**
     * @hide
     * Sets the color of the spot shadow that is drawn when the view has a positive Z or
     * elevation value.
     * <p>
     * By default the shadow color is black. Generally, this color will be opaque so the intensity
     * of the shadow is consistent between different views with different colors.
     * <p>
     * The opacity of the final spot shadow is a function of the shadow caster height, the
     * alpha channel of the outlineSpotShadowColor (typically opaque), and the
     * {@link android.R.attr#spotShadowAlpha} theme attribute.
     *
     * @attr ref android.R.styleable#View_outlineSpotShadowColor
     * @param color The color this View will cast for its elevation spot shadow.
     */
    public void setShadowColor(@ColorInt int color) {
        if (mRenderNode.setShadowColor(color)) {
    public void setOutlineSpotShadowColor(@ColorInt int color) {
        if (mRenderNode.setSpotShadowColor(color)) {
            invalidateViewProperty(true, true);
        }
    }
    /**
     * @return The shadow color set by {@link #setOutlineSpotShadowColor(int)}, or black if nothing
     * was set
     */
    public @ColorInt int getOutlineSpotShadowColor() {
        return mRenderNode.getSpotShadowColor();
    }
    /**
     * Sets the color of the ambient shadow that is drawn when the view has a positive Z or
     * elevation value.
     * <p>
     * By default the shadow color is black. Generally, this color will be opaque so the intensity
     * of the shadow is consistent between different views with different colors.
     * <p>
     * The opacity of the final ambient shadow is a function of the shadow caster height, the
     * alpha channel of the outlineAmbientShadowColor (typically opaque), and the
     * {@link android.R.attr#ambientShadowAlpha} theme attribute.
     *
     * @attr ref android.R.styleable#View_outlineAmbientShadowColor
     * @param color The color this View will cast for its elevation shadow.
     */
    public void setOutlineAmbientShadowColor(@ColorInt int color) {
        if (mRenderNode.setAmbientShadowColor(color)) {
            invalidateViewProperty(true, true);
        }
    }
    /**
     * @return The shadow color set by {@link #setOutlineAmbientShadowColor(int)}, or black if
     * nothing was set
     */
    public @ColorInt int getOutlineAmbientShadowColor() {
        return mRenderNode.getAmbientShadowColor();
    }
    /** @hide */
    public void setRevealClip(boolean shouldClip, float x, float y, float radius) {
@@ -26992,6 +27047,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        stream.addProperty("drawing:willNotCacheDrawing", willNotCacheDrawing());
        stream.addProperty("drawing:drawingCacheEnabled", isDrawingCacheEnabled());
        stream.addProperty("drawing:overlappingRendering", hasOverlappingRendering());
        stream.addProperty("drawing:outlineAmbientShadowColor", getOutlineAmbientShadowColor());
        stream.addProperty("drawing:outlineSpotShadowColor", getOutlineSpotShadowColor());
        // focus
        stream.addProperty("focus:hasFocus", hasFocus());
+23 −3
Original line number Diff line number Diff line
@@ -174,8 +174,25 @@ static jboolean android_view_RenderNode_hasShadow(jlong renderNodePtr) {
    return renderNode->stagingProperties().hasShadow();
}

static jboolean android_view_RenderNode_setShadowColor(jlong renderNodePtr, jint shadowColor) {
    return SET_AND_DIRTY(setShadowColor, static_cast<SkColor>(shadowColor), RenderNode::GENERIC);
static jboolean android_view_RenderNode_setSpotShadowColor(jlong renderNodePtr, jint shadowColor) {
    return SET_AND_DIRTY(setSpotShadowColor,
            static_cast<SkColor>(shadowColor), RenderNode::GENERIC);
}

static jint android_view_RenderNode_getSpotShadowColor(jlong renderNodePtr) {
    RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr);
    return renderNode->stagingProperties().getSpotShadowColor();
}

static jboolean android_view_RenderNode_setAmbientShadowColor(jlong renderNodePtr,
        jint shadowColor) {
    return SET_AND_DIRTY(setAmbientShadowColor,
            static_cast<SkColor>(shadowColor), RenderNode::GENERIC);
}

static jint android_view_RenderNode_getAmbientShadowColor(jlong renderNodePtr) {
    RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr);
    return renderNode->stagingProperties().getAmbientShadowColor();
}

static jboolean android_view_RenderNode_setClipToOutline(jlong renderNodePtr,
@@ -575,7 +592,10 @@ static const JNINativeMethod gMethods[] = {
    { "nSetOutlineEmpty",      "(J)Z",   (void*) android_view_RenderNode_setOutlineEmpty },
    { "nSetOutlineNone",       "(J)Z",   (void*) android_view_RenderNode_setOutlineNone },
    { "nHasShadow",            "(J)Z",   (void*) android_view_RenderNode_hasShadow },
    { "nSetShadowColor",       "(JI)Z",  (void*) android_view_RenderNode_setShadowColor },
    { "nSetSpotShadowColor",   "(JI)Z",  (void*) android_view_RenderNode_setSpotShadowColor },
    { "nGetSpotShadowColor",   "(J)I",   (void*) android_view_RenderNode_getSpotShadowColor },
    { "nSetAmbientShadowColor","(JI)Z",  (void*) android_view_RenderNode_setAmbientShadowColor },
    { "nGetAmbientShadowColor","(J)I",   (void*) android_view_RenderNode_getAmbientShadowColor },
    { "nSetClipToOutline",     "(JZ)Z",  (void*) android_view_RenderNode_setClipToOutline },
    { "nSetRevealClip",        "(JZFFF)Z", (void*) android_view_RenderNode_setRevealClip },

+22 −0
Original line number Diff line number Diff line
@@ -3036,6 +3036,28 @@
        <!-- The title this view should present to accessibility as a pane title.
             See {@link android.view.View#setAccessibilityPaneTitle(CharSequence)} -->
        <attr name="accessibilityPaneTitle" format="string" />

        <!-- Sets the color of the spot shadow that is drawn when the view has a positive Z or
             elevation value.
             <p>
             By default the shadow color is black. Generally, this color will be opaque so the
             intensity of the shadow is consistent between different views with different colors.
             <p>
             The opacity of the final spot shadow is a function of the shadow caster height, the
             alpha channel of the outlineSpotShadowColor (typically opaque), and the
             {@link android.R.attr#spotShadowAlpha} theme attribute. -->
        <attr name="outlineSpotShadowColor" format="color" />

        <!-- Sets the color of the ambient shadow that is drawn when the view has a positive Z
             or elevation value.
             <p>
             By default the shadow color is black. Generally, this color will be opaque so the
             intensity of the shadow is consistent between different views with different colors.
             <p>
             The opacity of the final ambient shadow is a function of the shadow caster height,
             the alpha channel of the outlineAmbientShadowColor (typically opaque), and the
             {@link android.R.attr#ambientShadowAlpha} theme attribute. -->
        <attr name="outlineAmbientShadowColor" format="color" />
    </declare-styleable>

    <!-- Attributes that can be assigned to a tag for a particular View. -->
Loading