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

Commit b82c6271 authored by Lyn Han's avatar Lyn Han Committed by Automerger Merge Worker
Browse files

Merge "Fade notifications with background scrim for shade expansion" into...

Merge "Fade notifications with background scrim for shade expansion" into sc-dev am: e7db82a8 am: 93417535

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14426002

Change-Id: Ibb335a37de0adc3c79b0dcde7f7b6ccd2875b2de
parents efa5e70b 93417535
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -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))));
        }
    }
}
+8 −1
Original line number Diff line number Diff line
@@ -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;

            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();
+8 −1
Original line number Diff line number Diff line
@@ -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;

        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
+2 −9
Original line number Diff line number Diff line
@@ -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) {