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

Commit 31581eb4 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Scrim opacity varies based on notification count"

parents 5d2afb94 a0bf851a
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -250,8 +250,7 @@ public class ScrimView extends View implements ConfigurationController.Configura
        }
    }

    @VisibleForTesting
    float getViewAlpha() {
    public float getViewAlpha() {
        return mViewAlpha;
    }

+20 −4
Original line number Diff line number Diff line
@@ -25,9 +25,8 @@ import android.content.Context;
import android.graphics.Color;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.support.v4.graphics.ColorUtils;
import android.util.Log;
import android.util.TypedValue;
import android.util.MathUtils;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
@@ -57,8 +56,12 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener,
            = new PathInterpolator(0f, 0, 0.7f, 1f);
    public static final Interpolator KEYGUARD_FADE_OUT_INTERPOLATOR_LOCKED
            = new PathInterpolator(0.3f, 0f, 0.8f, 1f);
    public static final float GRADIENT_SCRIM_ALPHA = 0.75f;
    protected static final float SCRIM_BEHIND_ALPHA_KEYGUARD = 0.45f;
    // Default alpha value for most scrims, if unsure use this constant
    public static final float GRADIENT_SCRIM_ALPHA = 0.60f;
    // A scrim varies its opacity based on a busyness factor, for example
    // how many notifications are currently visible.
    public static final float GRADIENT_SCRIM_ALPHA_BUSY = 0.90f;
    protected static final float SCRIM_BEHIND_ALPHA_KEYGUARD = GRADIENT_SCRIM_ALPHA;
    protected static final float SCRIM_BEHIND_ALPHA_UNLOCKING = 0.2f;
    private static final float SCRIM_IN_FRONT_ALPHA = GRADIENT_SCRIM_ALPHA;
    private static final float SCRIM_IN_FRONT_ALPHA_LOCKED = GRADIENT_SCRIM_ALPHA;
@@ -256,6 +259,19 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener,
        return mDozeInFrontAlpha;
    }

    public void setNotificationCount(int notificationCount) {
        final float maxNotificationDensity = 3;
        float notificationDensity = Math.min(notificationCount / maxNotificationDensity, 1f);
        float newAlpha = MathUtils.map(0, 1,
                GRADIENT_SCRIM_ALPHA, GRADIENT_SCRIM_ALPHA_BUSY,
                notificationDensity);
        if (mScrimBehindAlphaKeyguard != newAlpha) {
            mScrimBehindAlphaKeyguard = newAlpha;
            mAnimateChange = true;
            scheduleUpdate();
        }
    }

    private float getScrimInFrontAlpha() {
        return mKeyguardUpdateMonitor.needsSlowUnlockTransition()
                ? SCRIM_IN_FRONT_ALPHA_LOCKED
+3 −0
Original line number Diff line number Diff line
@@ -6779,6 +6779,9 @@ public class StatusBar extends SystemUI implements DemoMode,
        // another "changeViewPosition" call is ever added.
        mStackScroller.changeViewPosition(mNotificationShelf,
                mStackScroller.getChildCount() - offsetFromEnd);

        // Scrim opacity varies based on notification count
        mScrimController.setNotificationCount(mStackScroller.getNotGoneChildCount());
    }

    public boolean shouldShowOnKeyguard(StatusBarNotification sbn) {