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

Commit a36306d4 authored by Matt Pietal's avatar Matt Pietal Committed by Automerger Merge Worker
Browse files

Merge "Don't blend front scrim on AOD" into tm-dev am: dc65d350 am: 995561f1 am: eccac0a9

parents 5d323ab8 eccac0a9
Loading
Loading
Loading
Loading
+19 −2
Original line number Original line Diff line number Diff line
@@ -58,6 +58,7 @@ public class ScrimView extends View {
    private Drawable mDrawable;
    private Drawable mDrawable;
    private PorterDuffColorFilter mColorFilter;
    private PorterDuffColorFilter mColorFilter;
    private int mTintColor;
    private int mTintColor;
    private boolean mBlendWithMainColor = true;
    private Runnable mChangeRunnable;
    private Runnable mChangeRunnable;
    private Executor mChangeRunnableExecutor;
    private Executor mChangeRunnableExecutor;
    private Executor mExecutor;
    private Executor mExecutor;
@@ -191,6 +192,19 @@ public class ScrimView extends View {
        setTint(color, false);
        setTint(color, false);
    }
    }


    /**
     * The call to {@link #setTint} will blend with the main color, with the amount
     * determined by the alpha of the tint. Set to false to avoid this blend.
     */
    public void setBlendWithMainColor(boolean blend) {
        mBlendWithMainColor = blend;
    }

    /** @return true if blending tint color with main color */
    public boolean shouldBlendWithMainColor() {
        return mBlendWithMainColor;
    }

    /**
    /**
     * Tints this view, optionally animating it.
     * Tints this view, optionally animating it.
     * @param color The color.
     * @param color The color.
@@ -211,8 +225,11 @@ public class ScrimView extends View {
            // Optimization to blend colors and avoid a color filter
            // Optimization to blend colors and avoid a color filter
            ScrimDrawable drawable = (ScrimDrawable) mDrawable;
            ScrimDrawable drawable = (ScrimDrawable) mDrawable;
            float tintAmount = Color.alpha(mTintColor) / 255f;
            float tintAmount = Color.alpha(mTintColor) / 255f;
            int mainTinted = ColorUtils.blendARGB(mColors.getMainColor(), mTintColor,

                    tintAmount);
            int mainTinted = mTintColor;
            if (mBlendWithMainColor) {
                mainTinted = ColorUtils.blendARGB(mColors.getMainColor(), mTintColor, tintAmount);
            }
            drawable.setColor(mainTinted, animated);
            drawable.setColor(mainTinted, animated);
        } else {
        } else {
            boolean hasAlpha = Color.alpha(mTintColor) != 0;
            boolean hasAlpha = Color.alpha(mTintColor) != 0;
+2 −0
Original line number Original line Diff line number Diff line
@@ -402,6 +402,8 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump
        mScrimBehind.setFocusable(!state.isLowPowerState());
        mScrimBehind.setFocusable(!state.isLowPowerState());
        mNotificationsScrim.setFocusable(!state.isLowPowerState());
        mNotificationsScrim.setFocusable(!state.isLowPowerState());


        mScrimInFront.setBlendWithMainColor(state.shouldBlendWithMainColor());

        // Cancel blanking transitions that were pending before we requested a new state
        // Cancel blanking transitions that were pending before we requested a new state
        if (mPendingFrameCallback != null) {
        if (mPendingFrameCallback != null) {
            mScrimBehind.removeCallbacks(mPendingFrameCallback);
            mScrimBehind.removeCallbacks(mPendingFrameCallback);
+13 −1
Original line number Original line Diff line number Diff line
@@ -203,6 +203,11 @@ public enum ScrimState {
        public boolean isLowPowerState() {
        public boolean isLowPowerState() {
            return true;
            return true;
        }
        }

        @Override
        public boolean shouldBlendWithMainColor() {
            return false;
        }
    },
    },


    /**
    /**
@@ -325,6 +330,13 @@ public enum ScrimState {
    public void prepare(ScrimState previousState) {
    public void prepare(ScrimState previousState) {
    }
    }


    /**
     * Whether a particular state should enable blending with extracted theme colors.
     */
    public boolean shouldBlendWithMainColor() {
        return true;
    }

    public float getFrontAlpha() {
    public float getFrontAlpha() {
        return mFrontAlpha;
        return mFrontAlpha;
    }
    }
+7 −0
Original line number Original line Diff line number Diff line
@@ -1490,6 +1490,13 @@ public class ScrimControllerTest extends SysuiTestCase {
        assertAlphaAfterExpansion(mNotificationsScrim, 0f, expansion);
        assertAlphaAfterExpansion(mNotificationsScrim, 0f, expansion);
    }
    }


    @Test
    public void aodStateSetsFrontScrimToNotBlend() {
        mScrimController.transitionTo(ScrimState.AOD);
        Assert.assertFalse("Front scrim should not blend with main color",
                mScrimInFront.shouldBlendWithMainColor());
    }

    private void assertAlphaAfterExpansion(ScrimView scrim, float expectedAlpha, float expansion) {
    private void assertAlphaAfterExpansion(ScrimView scrim, float expectedAlpha, float expansion) {
        mScrimController.setRawPanelExpansionFraction(expansion);
        mScrimController.setRawPanelExpansionFraction(expansion);
        finishAnimationsImmediately();
        finishAnimationsImmediately();