diff --git a/packages/SystemUI/animation/src/com/android/systemui/animation/Interpolators.java b/packages/SystemUI/animation/src/com/android/systemui/animation/Interpolators.java index 58cef31aaf770..0a052df43ead3 100644 --- a/packages/SystemUI/animation/src/com/android/systemui/animation/Interpolators.java +++ b/packages/SystemUI/animation/src/com/android/systemui/animation/Interpolators.java @@ -70,4 +70,17 @@ public class Interpolators { */ public static final Interpolator TOUCH_RESPONSE_REVERSE = new PathInterpolator(0.9f, 0f, 0.7f, 1f); + + /** + * Interpolate alpha for notifications background scrim during shade expansion. + * @param fraction Shade expansion fraction + */ + public static float getNotificationScrimAlpha(float fraction) { + fraction = fraction * 1.2f - 0.2f; + if (fraction <= 0) { + return 0; + } else { + return (float) (1f - 0.5f * (1f - Math.cos(3.14159f * Math.pow(1f - fraction, 2f)))); + } + } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java index 8f462fea04680..e49ca13fa25c8 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java @@ -31,6 +31,7 @@ import android.view.WindowInsets; import android.view.accessibility.AccessibilityNodeInfo; import com.android.internal.annotations.VisibleForTesting; +import com.android.systemui.animation.Interpolators; import com.android.systemui.R; import com.android.systemui.plugins.statusbar.StatusBarStateController.StateListener; import com.android.systemui.statusbar.notification.NotificationUtils; @@ -176,7 +177,13 @@ public class NotificationShelf extends ActivatableNotificationView implements viewState.height = getIntrinsicHeight(); viewState.zTranslation = ambientState.getBaseZHeight(); viewState.clipTopAmount = 0; - viewState.alpha = 1f - ambientState.getHideAmount(); + + if (ambientState.isExpansionChanging() && !ambientState.isOnKeyguard()) { + viewState.alpha = Interpolators.getNotificationScrimAlpha( + ambientState.getExpansionFraction()); + } else { + viewState.alpha = 1f - ambientState.getHideAmount(); + } viewState.belowSpeedBump = mHostLayoutController.getSpeedBumpIndex() == 0; viewState.hideSensitive = false; viewState.xTranslation = getTranslationX(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java index 413048d6ce54e..d94d030f326e2 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java @@ -24,6 +24,7 @@ import android.util.MathUtils; import android.view.View; import android.view.ViewGroup; +import com.android.systemui.animation.Interpolators; import com.android.systemui.R; import com.android.systemui.statusbar.NotificationShelf; import com.android.systemui.statusbar.notification.dagger.SilentHeader; @@ -374,7 +375,13 @@ public class StackScrollAlgorithm { ExpandableView view = algorithmState.visibleChildren.get(i); ExpandableViewState viewState = view.getViewState(); viewState.location = ExpandableViewState.LOCATION_UNKNOWN; - viewState.alpha = 1f - ambientState.getHideAmount(); + + if (ambientState.isExpansionChanging() && !ambientState.isOnKeyguard()) { + viewState.alpha = Interpolators.getNotificationScrimAlpha( + ambientState.getExpansionFraction()); + } else { + viewState.alpha = 1f - ambientState.getHideAmount(); + } if (view.mustStayOnScreen() && viewState.yTranslation >= 0) { // Even if we're not scrolled away we're in view and we're also not in the 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 a952db2a60733..c34fa2f049e1c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java @@ -42,6 +42,7 @@ import com.android.internal.util.function.TriConsumer; import com.android.keyguard.KeyguardUpdateMonitor; import com.android.keyguard.KeyguardUpdateMonitorCallback; import com.android.settingslib.Utils; +import com.android.systemui.animation.Interpolators; import com.android.systemui.DejankUtils; import com.android.systemui.Dumpable; import com.android.systemui.R; @@ -810,15 +811,7 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump } private float getInterpolatedFraction() { - float frac = mPanelExpansion; - // let's start this 20% of the way down the screen - frac = frac * 1.2f - 0.2f; - if (frac <= 0) { - return 0; - } else { - // woo, special effects - return (float) (1f - 0.5f * (1f - Math.cos(3.14159f * Math.pow(1f - frac, 2f)))); - } + return Interpolators.getNotificationScrimAlpha(mPanelExpansion); } private void setScrimAlpha(ScrimView scrim, float alpha) {