Merge "Fix the wrong tint state of Nav buttons" into pi-dev
diff --git a/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java b/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java
index 0ba26e9..c01cafa 100644
--- a/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java
+++ b/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java
@@ -25,6 +25,7 @@
import com.android.internal.logging.MetricsLogger;
import com.android.internal.widget.LockPatternUtils;
+import com.android.internal.colorextraction.ColorExtractor.GradientColors;
import com.android.keyguard.ViewMediatorCallback;
import com.android.systemui.Dependency.DependencyProvider;
import com.android.systemui.classifier.FalsingManager;
@@ -101,12 +102,13 @@
dismissCallbackRegistry, FalsingManager.getInstance(context));
}
- public ScrimController createScrimController(LightBarController lightBarController,
- ScrimView scrimBehind, ScrimView scrimInFront, LockscreenWallpaper lockscreenWallpaper,
+ public ScrimController createScrimController(ScrimView scrimBehind, ScrimView scrimInFront,
+ LockscreenWallpaper lockscreenWallpaper, Consumer<Float> scrimBehindAlphaListener,
+ Consumer<GradientColors> scrimInFrontColorListener,
Consumer<Integer> scrimVisibleListener, DozeParameters dozeParameters,
AlarmManager alarmManager) {
- return new ScrimController(lightBarController, scrimBehind, scrimInFront,
- scrimVisibleListener, dozeParameters, alarmManager);
+ return new ScrimController(scrimBehind, scrimInFront, scrimBehindAlphaListener,
+ scrimInFrontColorListener, scrimVisibleListener, dozeParameters, alarmManager);
}
public NotificationIconAreaController createNotificationIconAreaController(Context context,
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 2c335a3..cc143bb 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java
@@ -111,7 +111,6 @@
private final Context mContext;
protected final ScrimView mScrimBehind;
protected final ScrimView mScrimInFront;
- private final LightBarController mLightBarController;
private final UnlockMethodCache mUnlockMethodCache;
private final KeyguardUpdateMonitor mKeyguardUpdateMonitor;
private final DozeParameters mDozeParameters;
@@ -145,6 +144,8 @@
private int mCurrentBehindTint;
private boolean mWallpaperVisibilityTimedOut;
private int mScrimsVisibility;
+ private final Consumer<GradientColors> mScrimInFrontColorListener;
+ private final Consumer<Float> mScrimBehindAlphaListener;
private final Consumer<Integer> mScrimVisibleListener;
private boolean mBlankScreen;
private boolean mScreenBlankingCallbackCalled;
@@ -161,17 +162,20 @@
private boolean mWakeLockHeld;
private boolean mKeyguardOccluded;
- public ScrimController(LightBarController lightBarController, ScrimView scrimBehind,
- ScrimView scrimInFront, Consumer<Integer> scrimVisibleListener,
- DozeParameters dozeParameters, AlarmManager alarmManager) {
+ public ScrimController(ScrimView scrimBehind, ScrimView scrimInFront,
+ Consumer<Float> scrimBehindAlphaListener,
+ Consumer<GradientColors> scrimInFrontColorListener,
+ Consumer<Integer> scrimVisibleListener, DozeParameters dozeParameters,
+ AlarmManager alarmManager) {
mScrimBehind = scrimBehind;
mScrimInFront = scrimInFront;
+ mScrimBehindAlphaListener = scrimBehindAlphaListener;
+ mScrimInFrontColorListener = scrimInFrontColorListener;
mScrimVisibleListener = scrimVisibleListener;
mContext = scrimBehind.getContext();
mUnlockMethodCache = UnlockMethodCache.getInstance(mContext);
mDarkenWhileDragging = !mUnlockMethodCache.canSkipBouncer();
mKeyguardUpdateMonitor = KeyguardUpdateMonitor.getInstance(mContext);
- mLightBarController = lightBarController;
mScrimBehindAlphaResValue = mContext.getResources().getFloat(R.dimen.scrim_behind_alpha);
mTimeTicker = new AlarmTimeout(alarmManager, this::onHideWallpaperTimeout,
"hide_aod_wallpaper", new Handler());
@@ -370,6 +374,8 @@
setOrAdaptCurrentAnimation(mScrimBehind);
setOrAdaptCurrentAnimation(mScrimInFront);
+
+ mScrimBehindAlphaListener.accept(mScrimBehind.getViewAlpha());
}
}
@@ -478,7 +484,7 @@
float minOpacity = ColorUtils.calculateMinimumBackgroundAlpha(textColor, mainColor,
4.5f /* minimumContrast */) / 255f;
mScrimBehindAlpha = Math.max(mScrimBehindAlphaResValue, minOpacity);
- mLightBarController.setScrimColor(mScrimInFront.getColors());
+ mScrimInFrontColorListener.accept(mScrimInFront.getColors());
}
// We want to override the back scrim opacity for the AOD state
@@ -705,9 +711,8 @@
}
}
- // TODO factor mLightBarController out of this class
if (scrim == mScrimBehind) {
- mLightBarController.setScrimAlpha(alpha);
+ mScrimBehindAlphaListener.accept(alpha);
}
final boolean wantsAlphaUpdate = alpha != currentAlpha;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
index 46b6c4c..0072dc0 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
@@ -916,8 +916,14 @@
ScrimView scrimBehind = mStatusBarWindow.findViewById(R.id.scrim_behind);
ScrimView scrimInFront = mStatusBarWindow.findViewById(R.id.scrim_in_front);
- mScrimController = SystemUIFactory.getInstance().createScrimController(mLightBarController,
+ mScrimController = SystemUIFactory.getInstance().createScrimController(
scrimBehind, scrimInFront, mLockscreenWallpaper,
+ scrimBehindAlpha -> {
+ mLightBarController.setScrimAlpha(scrimBehindAlpha);
+ },
+ scrimInFrontColor -> {
+ mLightBarController.setScrimColor(scrimInFrontColor);
+ },
scrimsVisible -> {
if (mStatusBarWindowManager != null) {
mStatusBarWindowManager.setScrimsVisibility(scrimsVisible);
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 82129a1..0416232 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
@@ -42,6 +42,7 @@
import android.testing.TestableLooper;
import android.view.View;
+import com.android.internal.colorextraction.ColorExtractor.GradientColors;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.statusbar.ScrimView;
@@ -65,9 +66,12 @@
private SynchronousScrimController mScrimController;
private ScrimView mScrimBehind;
private ScrimView mScrimInFront;
+ private Consumer<Float> mScrimBehindAlphaCallback;
+ private Consumer<GradientColors> mScrimInFrontColorCallback;
private Consumer<Integer> mScrimVisibilityCallback;
+ private float mScrimBehindAlpha;
+ private GradientColors mScrimInFrontColor;
private int mScrimVisibility;
- private LightBarController mLightBarController;
private DozeParameters mDozeParamenters;
private WakeLock mWakeLock;
private boolean mAlwaysOnEnabled;
@@ -75,19 +79,20 @@
@Before
public void setup() {
- mLightBarController = mock(LightBarController.class);
mScrimBehind = spy(new ScrimView(getContext()));
mScrimInFront = new ScrimView(getContext());
mWakeLock = mock(WakeLock.class);
mAlarmManager = mock(AlarmManager.class);
mAlwaysOnEnabled = true;
+ mScrimBehindAlphaCallback = (Float alpha) -> mScrimBehindAlpha = alpha;
+ mScrimInFrontColorCallback = (GradientColors color) -> mScrimInFrontColor = color;
mScrimVisibilityCallback = (Integer visible) -> mScrimVisibility = visible;
mDozeParamenters = mock(DozeParameters.class);
when(mDozeParamenters.getAlwaysOn()).thenAnswer(invocation -> mAlwaysOnEnabled);
when(mDozeParamenters.getDisplayNeedsBlanking()).thenReturn(true);
- mScrimController = new SynchronousScrimController(mLightBarController, mScrimBehind,
- mScrimInFront, mScrimVisibilityCallback, mDozeParamenters,
- mAlarmManager);
+ mScrimController = new SynchronousScrimController(mScrimBehind, mScrimInFront,
+ mScrimBehindAlphaCallback, mScrimInFrontColorCallback, mScrimVisibilityCallback,
+ mDozeParamenters, mAlarmManager);
}
@Test
@@ -206,6 +211,28 @@
}
@Test
+ public void panelExpansion() {
+ mScrimController.setPanelExpansion(0f);
+ mScrimController.setPanelExpansion(0.5f);
+ mScrimController.transitionTo(ScrimState.UNLOCKED);
+ mScrimController.finishAnimationsImmediately();
+
+ reset(mScrimBehind);
+ mScrimController.setPanelExpansion(0f);
+ mScrimController.setPanelExpansion(1.0f);
+ mScrimController.onPreDraw();
+
+ Assert.assertEquals("Scrim alpha should change after setPanelExpansion",
+ mScrimBehindAlpha, mScrimBehind.getViewAlpha(), 0.01f);
+
+ mScrimController.setPanelExpansion(0f);
+ mScrimController.onPreDraw();
+
+ Assert.assertEquals("Scrim alpha should change after setPanelExpansion",
+ mScrimBehindAlpha, mScrimBehind.getViewAlpha(), 0.01f);
+ }
+
+ @Test
public void panelExpansionAffectsAlpha() {
mScrimController.setPanelExpansion(0f);
mScrimController.setPanelExpansion(0.5f);
@@ -531,11 +558,12 @@
private boolean mAnimationCancelled;
boolean mOnPreDrawCalled;
- SynchronousScrimController(LightBarController lightBarController,
- ScrimView scrimBehind, ScrimView scrimInFront,
+ SynchronousScrimController(ScrimView scrimBehind, ScrimView scrimInFront,
+ Consumer<Float> scrimBehindAlphaListener,
+ Consumer<GradientColors> scrimInFrontColorListener,
Consumer<Integer> scrimVisibleListener, DozeParameters dozeParameters,
AlarmManager alarmManager) {
- super(lightBarController, scrimBehind, scrimInFront,
+ super(scrimBehind, scrimInFront, scrimBehindAlphaListener, scrimInFrontColorListener,
scrimVisibleListener, dozeParameters, alarmManager);
mHandler = new FakeHandler(Looper.myLooper());
}