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

Commit c41f8fdf authored by Lucas Dupin's avatar Lucas Dupin
Browse files

Animate scrim colors when unlocking

Test: Set different wallpapers on home and lock screen, unlock the phone
Change-Id: Ifba44be747f0ad7b6ed4aec75197746edbbecfd2
parent 13e82946
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -167,6 +167,10 @@ public class ScrimView extends View implements ConfigurationController.Configura
    }

    public void setColors(@NonNull ColorExtractor.GradientColors colors) {
        setColors(colors, false);
    }

    public void setColors(@NonNull ColorExtractor.GradientColors colors, boolean animated) {
        if (colors == null) {
            throw new IllegalArgumentException("Colors cannot be null");
        }
@@ -174,7 +178,7 @@ public class ScrimView extends View implements ConfigurationController.Configura
            return;
        }
        mColors.set(colors);
        updateColorWithTint();
        updateColorWithTint(animated);
    }

    @VisibleForTesting
@@ -183,14 +187,18 @@ public class ScrimView extends View implements ConfigurationController.Configura
    }

    public void setTint(int color) {
        setTint(color, false);
    }

    public void setTint(int color, boolean animated) {
        if (mTintColor == color) {
            return;
        }
        mTintColor = color;
        updateColorWithTint();
        updateColorWithTint(animated);
    }

    private void updateColorWithTint() {
    private void updateColorWithTint(boolean animated) {
        if (mDrawable instanceof GradientDrawable) {
            // Optimization to blend colors and avoid a color filter
            GradientDrawable drawable = (GradientDrawable) mDrawable;
@@ -199,7 +207,7 @@ public class ScrimView extends View implements ConfigurationController.Configura
                    tintAmount);
            int secondaryTinted = ColorUtils.blendARGB(mColors.getSecondaryColor(), mTintColor,
                    tintAmount);
            drawable.setColors(mainTinted, secondaryTinted, false);
            drawable.setColors(mainTinted, secondaryTinted, animated);
        } else {
            if (mColorFilter == null) {
                mColorFilter = new PorterDuffColorFilter(mTintColor, PorterDuff.Mode.SRC_OVER);
+2 −2
Original line number Diff line number Diff line
@@ -277,8 +277,8 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener,
                mScrimInFront.setColors(mLockColors);
                mScrimBehind.setColors(mLockColors);
            } else {
                mScrimInFront.setColors(mSystemColors);
                mScrimBehind.setColors(mSystemColors);
                mScrimInFront.setColors(mSystemColors, true);
                mScrimBehind.setColors(mSystemColors, true);
            }
        }