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
This commit is contained in:
Michal Brzezinski
2021-10-14 19:11:08 +01:00
parent 2a482869f7
commit 12dfa2498e
10 changed files with 65 additions and 38 deletions

View File

@@ -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();

View File

@@ -0,0 +1,37 @@
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()
}
}
}

View File

@@ -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);
}

View File

@@ -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)

View File

@@ -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();
}

View File

@@ -25,7 +25,7 @@ import android.view.View;
import android.view.ViewGroup;
import com.android.systemui.R;
import com.android.systemui.animation.Interpolators;
import com.android.systemui.animation.ShadeInterpolation;
import com.android.systemui.statusbar.NotificationShelf;
import com.android.systemui.statusbar.notification.row.ActivatableNotificationView;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
@@ -407,8 +407,8 @@ public class StackScrollAlgorithm {
viewState.alpha = 1f - ambientState.getHideAmount();
} else if (ambientState.isExpansionChanging()) {
// Adjust alpha for shade open & close.
viewState.alpha = Interpolators.getNotificationScrimAlpha(
ambientState.getExpansionFraction(), true /* notification */);
float expansion = ambientState.getExpansionFraction();
viewState.alpha = ShadeInterpolation.getContentAlpha(expansion);
}
if (ambientState.isShadeExpanded() && view.mustStayOnScreen()

View File

@@ -1247,6 +1247,7 @@ public class NotificationPanelViewController extends PanelViewController {
stackScrollerPadding = mClockPositionResult.stackScrollerPaddingExpanded;
}
mSplitShadeHeaderController.setShadeExpandedFraction(getExpandedFraction());
mNotificationStackScrollLayoutController.setIntrinsicPadding(stackScrollerPadding);
mKeyguardBottomArea.setAntiBurnInOffsetX(mClockPositionResult.clockX);

View File

@@ -47,7 +47,7 @@ import com.android.settingslib.Utils;
import com.android.systemui.DejankUtils;
import com.android.systemui.Dumpable;
import com.android.systemui.R;
import com.android.systemui.animation.Interpolators;
import com.android.systemui.animation.ShadeInterpolation;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.dock.DockManager;
@@ -579,8 +579,7 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump
if (isNaN(expansionFraction)) {
return;
}
expansionFraction = Interpolators
.getNotificationScrimAlpha(expansionFraction, false /* notification */);
expansionFraction = ShadeInterpolation.getNotificationScrimAlpha(expansionFraction);
boolean qsBottomVisible = qsPanelBottomY > 0;
if (mQsExpansion != expansionFraction || mQsBottomVisible != qsBottomVisible) {
mQsExpansion = expansionFraction;
@@ -915,8 +914,7 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump
}
private float getInterpolatedFraction() {
return Interpolators.getNotificationScrimAlpha(
mPanelExpansionFraction, false /* notification */);
return ShadeInterpolation.getNotificationScrimAlpha(mPanelExpansionFraction);
}
private void setScrimAlpha(ScrimView scrim, float alpha) {

View File

@@ -18,6 +18,7 @@ package com.android.systemui.statusbar.phone
import android.view.View
import com.android.systemui.R
import com.android.systemui.animation.ShadeInterpolation
import com.android.systemui.battery.BatteryMeterView
import com.android.systemui.battery.BatteryMeterViewController
import com.android.systemui.flags.FeatureFlags
@@ -53,6 +54,14 @@ class SplitShadeHeaderController @Inject constructor(
updateVisibility()
}
var shadeExpandedFraction = -1f
set(value) {
if (visible && field != value) {
statusBar.alpha = ShadeInterpolation.getContentAlpha(value)
field = value
}
}
init {
batteryMeterViewController.init()
val batteryIcon: BatteryMeterView = statusBar.findViewById(R.id.batteryRemainingIcon)

View File

@@ -24,7 +24,7 @@ import android.view.View
import android.view.ViewRootImpl
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.animation.Interpolators
import com.android.systemui.animation.ShadeInterpolation
import com.android.systemui.dump.DumpManager
import com.android.systemui.plugins.statusbar.StatusBarStateController
import com.android.systemui.statusbar.phone.BiometricUnlockController
@@ -208,7 +208,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
notificationShadeDepthController.onPanelExpansionChanged(1f, tracking = false)
notificationShadeDepthController.updateBlurCallback.doFrame(0)
verify(wallpaperController).setNotificationShadeZoom(
eq(Interpolators.getNotificationScrimAlpha(0.25f, false /* notifications */)))
eq(ShadeInterpolation.getNotificationScrimAlpha(0.25f)))
}
@Test