summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Matt Pietal <mpietal@google.com> 2022-05-13 18:21:34 +0000
committer Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> 2022-05-13 18:21:34 +0000
commit995561f15c6475c936812357fdf032e602eb1531 (patch)
tree6f00dd05f8f753d3fa59f398786a8219e79dd8c3
parent00f1fb94113050c8a7a0a974f1e188ec9f1a4bd6 (diff)
parentdc65d350fd76926c71906f5601fa84493d64e3e6 (diff)
Merge "Don't blend front scrim on AOD" into tm-dev am: dc65d350fd
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18366805 Change-Id: Iece29cf380843c5ab108709e1576d7cced612b45 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--packages/SystemUI/src/com/android/systemui/scrim/ScrimView.java21
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java2
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimState.java14
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java7
4 files changed, 41 insertions, 3 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/scrim/ScrimView.java b/packages/SystemUI/src/com/android/systemui/scrim/ScrimView.java
index 7530681c82b2..f68e0429ef7c 100644
--- a/packages/SystemUI/src/com/android/systemui/scrim/ScrimView.java
+++ b/packages/SystemUI/src/com/android/systemui/scrim/ScrimView.java
@@ -58,6 +58,7 @@ public class ScrimView extends View {
private Drawable mDrawable;
private PorterDuffColorFilter mColorFilter;
private int mTintColor;
+ private boolean mBlendWithMainColor = true;
private Runnable mChangeRunnable;
private Executor mChangeRunnableExecutor;
private Executor mExecutor;
@@ -192,6 +193,19 @@ public class ScrimView extends View {
}
/**
+ * 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.
* @param color The color.
* @param animated If we should animate.
@@ -211,8 +225,11 @@ public class ScrimView extends View {
// Optimization to blend colors and avoid a color filter
ScrimDrawable drawable = (ScrimDrawable) mDrawable;
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);
} else {
boolean hasAlpha = Color.alpha(mTintColor) != 0;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java
index f9e17da9773f..0e77866bef1d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java
@@ -402,6 +402,8 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump
mScrimBehind.setFocusable(!state.isLowPowerState());
mNotificationsScrim.setFocusable(!state.isLowPowerState());
+ mScrimInFront.setBlendWithMainColor(state.shouldBlendWithMainColor());
+
// Cancel blanking transitions that were pending before we requested a new state
if (mPendingFrameCallback != null) {
mScrimBehind.removeCallbacks(mPendingFrameCallback);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimState.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimState.java
index 47b705845fce..4a5f712d587c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimState.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimState.java
@@ -203,6 +203,11 @@ public enum ScrimState {
public boolean isLowPowerState() {
return true;
}
+
+ @Override
+ public boolean shouldBlendWithMainColor() {
+ return false;
+ }
},
/**
@@ -325,6 +330,13 @@ public enum ScrimState {
public void prepare(ScrimState previousState) {
}
+ /**
+ * Whether a particular state should enable blending with extracted theme colors.
+ */
+ public boolean shouldBlendWithMainColor() {
+ return true;
+ }
+
public float getFrontAlpha() {
return mFrontAlpha;
}
@@ -422,4 +434,4 @@ public enum ScrimState {
public void setClipQsScrim(boolean clipsQsScrim) {
mClipQsScrim = clipsQsScrim;
}
-} \ No newline at end of file
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java
index dce520c0973d..5f8dda359563 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java
@@ -1490,6 +1490,13 @@ public class ScrimControllerTest extends SysuiTestCase {
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) {
mScrimController.setRawPanelExpansionFraction(expansion);
finishAnimationsImmediately();