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

Commit 12dfa249 authored by Michal Brzezinski's avatar Michal Brzezinski
Browse files

Hiding split shade status bar for heads up notifications

Changing split shade status bar alpha so that it's dependent on shade expansion. This has two effects:
- it doesn't show on HUN (alpha = 0), which is the main issue
- it's animated on expansion and transition between launcher status bar and split shade status bar is less jarring - this likely needs to be adjusted in the future but for now should be good enough.

Also splitting getNotificationScrimAlpha into two separate ethods as it's usage got weirder over time and inline comments in method calls got outdated.
Also moving split of getNotificationScrimAlpha to seperate object - it feels a bit weird that this very specific interpolation calculation is in the general Interpolation object.

Bug: 198595419
Test: Receive HUN and NOT see split shade status bar on top of regular status bar
Change-Id: I3bfcd0697da4798fc845d2636303fd3616e131fc
parent 2a482869
Loading
Loading
Loading
Loading
+0 −20
Original line number Diff line number Diff line
@@ -197,26 +197,6 @@ public class Interpolators {
        return MathUtils.max(0.0f, (float) (1.0f - Math.exp(-4 * progress)));
    }

    /**
     * Interpolate alpha for notifications background scrim during shade expansion.
     * @param fraction Shade expansion fraction
     * @param forUiContent If we want the alpha of the scrims, or ui that's on top of them.
     */
    public static float getNotificationScrimAlpha(float fraction, boolean forUiContent) {
        if (forUiContent) {
            fraction = MathUtils.constrainedMap(0f, 1f, 0.3f, 1f, fraction);
        } else {
            fraction = MathUtils.constrainedMap(0f, 1f, 0f, 0.5f, fraction);
        }
        fraction = fraction * 1.2f - 0.2f;
        if (fraction <= 0) {
            return 0;
        } else {
            final float oneMinusFrac = 1f - fraction;
            return (float) (1f - 0.5f * (1f - Math.cos(3.14159f * oneMinusFrac * oneMinusFrac)));
        }
    }

    // Create the default emphasized interpolator
    private static PathInterpolator createEmphasizedInterpolator() {
        Path path = new Path();
+37 −0
Original line number Diff line number Diff line
package com.android.systemui.animation

import android.util.MathUtils

object ShadeInterpolation {

    /**
     * Interpolate alpha for notification background scrim during shade expansion.
     * @param fraction Shade expansion fraction
     */
    @JvmStatic
    fun getNotificationScrimAlpha(fraction: Float): Float {
        val mappedFraction = MathUtils.constrainedMap(0f, 1f, 0f, 0.5f, fraction)
        return interpolateEaseInOut(mappedFraction)
    }

    /**
     * Interpolate alpha for shade content during shade expansion.
     * @param fraction Shade expansion fraction
     */
    @JvmStatic
    fun getContentAlpha(fraction: Float): Float {
        val mappedFraction = MathUtils.constrainedMap(0f, 1f, 0.3f, 1f, fraction)
        return interpolateEaseInOut(mappedFraction)
    }

    private fun interpolateEaseInOut(fraction: Float): Float {
        val mappedFraction = fraction * 1.2f - 0.2f
        return if (mappedFraction <= 0) {
            0f
        } else {
            val oneMinusFrac = 1f - mappedFraction
            (1f - 0.5f * (1f - Math.cos((3.14159f * oneMinusFrac * oneMinusFrac).toDouble())))
                    .toFloat()
        }
    }
}
 No newline at end of file
+2 −1
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ import androidx.annotation.VisibleForTesting;

import com.android.systemui.R;
import com.android.systemui.animation.Interpolators;
import com.android.systemui.animation.ShadeInterpolation;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.media.MediaHost;
import com.android.systemui.plugins.FalsingManager;
@@ -573,7 +574,7 @@ public class QSFragment extends LifecycleFragment implements QS, CommandQueue.Ca
        } else if (progress > 0 && view.getVisibility() != View.VISIBLE) {
            view.setVisibility((View.VISIBLE));
        }
        float alpha = Interpolators.getNotificationScrimAlpha(progress, true /* uiContent */);
        float alpha = ShadeInterpolation.getContentAlpha(progress);
        view.setAlpha(alpha);
    }

+5 −4
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import androidx.dynamicanimation.animation.SpringAnimation
import androidx.dynamicanimation.animation.SpringForce
import com.android.systemui.Dumpable
import com.android.systemui.animation.Interpolators
import com.android.systemui.animation.ShadeInterpolation
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dump.DumpManager
import com.android.systemui.plugins.statusbar.StatusBarStateController
@@ -184,12 +185,12 @@ class NotificationShadeDepthController @Inject constructor(
        val animationRadius = MathUtils.constrain(shadeAnimation.radius,
                blurUtils.minBlurRadius.toFloat(), blurUtils.maxBlurRadius.toFloat())
        val expansionRadius = blurUtils.blurRadiusOfRatio(
                Interpolators.getNotificationScrimAlpha(
                        if (shouldApplyShadeBlur()) shadeExpansion else 0f, false))
                ShadeInterpolation.getNotificationScrimAlpha(
                        if (shouldApplyShadeBlur()) shadeExpansion else 0f))
        var combinedBlur = (expansionRadius * INTERACTION_BLUR_FRACTION +
                animationRadius * ANIMATION_BLUR_FRACTION)
        val qsExpandedRatio = Interpolators.getNotificationScrimAlpha(qsPanelExpansion,
                false /* notification */) * shadeExpansion
        val qsExpandedRatio = ShadeInterpolation.getNotificationScrimAlpha(qsPanelExpansion) *
                shadeExpansion
        combinedBlur = max(combinedBlur, blurUtils.blurRadiusOfRatio(qsExpandedRatio))
        combinedBlur = max(combinedBlur, blurUtils.blurRadiusOfRatio(transitionToFullShadeProgress))
        var shadeRadius = max(combinedBlur, wakeAndUnlockBlurRadius)
+3 −3
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@ import android.view.animation.PathInterpolator;

import com.android.internal.annotations.VisibleForTesting;
import com.android.systemui.R;
import com.android.systemui.animation.Interpolators;
import com.android.systemui.animation.ShadeInterpolation;
import com.android.systemui.plugins.statusbar.StatusBarStateController.StateListener;
import com.android.systemui.statusbar.notification.NotificationUtils;
import com.android.systemui.statusbar.notification.row.ActivatableNotificationView;
@@ -168,8 +168,8 @@ public class NotificationShelf extends ActivatableNotificationView implements
            viewState.clipTopAmount = 0;

            if (ambientState.isExpansionChanging() && !ambientState.isOnKeyguard()) {
                viewState.alpha = Interpolators.getNotificationScrimAlpha(
                        ambientState.getExpansionFraction(), true /* notification */);
                float expansion = ambientState.getExpansionFraction();
                viewState.alpha = ShadeInterpolation.getContentAlpha(expansion);
            } else {
                viewState.alpha = 1f - ambientState.getHideAmount();
            }
Loading