[Bouncer] Apply interpolation to udfps

Apply interpolation to udfps view controller when boucer is in transit.
Also rename the function so that it implies that it affects all elements
that need to hide in order to show the bouncer.

Bug: 228282858
Test: Manual
Change-Id: I27d192fb2576c8e02ac193eaee2836da4027c88f
This commit is contained in:
Aaron Liu
2022-04-08 16:34:55 +00:00
parent 0ba48fea68
commit caa6359dbe
11 changed files with 43 additions and 38 deletions

View File

@@ -23,7 +23,7 @@ object BouncerPanelExpansionCalculator {
* Scale the alpha/position of the host view.
*/
@JvmStatic
fun getHostViewScaledExpansion(fraction: Float): Float {
fun showBouncerProgress(fraction: Float): Float {
return when {
fraction >= 0.9f -> 1f
fraction < 0.6 -> 0f
@@ -35,7 +35,7 @@ object BouncerPanelExpansionCalculator {
* Scale the alpha/tint of the back scrim.
*/
@JvmStatic
fun getBackScrimScaledExpansion(fraction: Float): Float {
fun aboutToShowBouncerProgress(fraction: Float): Float {
return MathUtils.constrain((fraction - 0.9f) / 0.1f, 0f, 1f)
}

View File

@@ -327,7 +327,7 @@ public class KeyguardHostViewController extends ViewController<KeyguardHostView>
* @param fraction amount of the screen that should show.
*/
public void setExpansion(float fraction) {
float scaledFraction = BouncerPanelExpansionCalculator.getHostViewScaledExpansion(fraction);
float scaledFraction = BouncerPanelExpansionCalculator.showBouncerProgress(fraction);
mView.setAlpha(MathUtils.constrain(1 - scaledFraction, 0f, 1f));
mView.setTranslationY(scaledFraction * mTranslationY);
}

View File

@@ -25,6 +25,7 @@ import android.util.Log;
import android.util.MathUtils;
import android.view.MotionEvent;
import com.android.keyguard.BouncerPanelExpansionCalculator;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.systemui.R;
import com.android.systemui.animation.ActivityLaunchAnimator;
@@ -71,7 +72,7 @@ public class UdfpsKeyguardViewController extends UdfpsAnimationViewController<Ud
private float mTransitionToFullShadeProgress;
private float mLastDozeAmount;
private long mLastUdfpsBouncerShowTime = -1;
private float mStatusBarExpansion;
private float mPanelExpansionFraction;
private boolean mLaunchTransitionFadingAway;
private boolean mIsLaunchingActivity;
private float mActivityLaunchProgress;
@@ -188,7 +189,7 @@ public class UdfpsKeyguardViewController extends UdfpsAnimationViewController<Ud
pw.println("mQsExpanded=" + mQsExpanded);
pw.println("mIsBouncerVisible=" + mIsBouncerVisible);
pw.println("mInputBouncerHiddenAmount=" + mInputBouncerHiddenAmount);
pw.println("mStatusBarExpansion=" + mStatusBarExpansion);
pw.println("mPanelExpansionFraction=" + mPanelExpansionFraction);
pw.println("unpausedAlpha=" + mView.getUnpausedAlpha());
pw.println("mUdfpsRequested=" + mUdfpsRequested);
pw.println("mView.mUdfpsRequested=" + mView.mUdfpsRequested);
@@ -324,14 +325,16 @@ public class UdfpsKeyguardViewController extends UdfpsAnimationViewController<Ud
*/
@Override
public void updateAlpha() {
// fade icon on transitions to showing the status bar, but if mUdfpsRequested, then
// the keyguard is occluded by some application - so instead use the input bouncer
// hidden amount to determine the fade
float expansion = mUdfpsRequested ? mInputBouncerHiddenAmount : mStatusBarExpansion;
// Fade icon on transitions to showing the status bar or bouncer, but if mUdfpsRequested,
// then the keyguard is occluded by some application - so instead use the input bouncer
// hidden amount to determine the fade.
float expansion = mUdfpsRequested ? mInputBouncerHiddenAmount : mPanelExpansionFraction;
int alpha = mShowingUdfpsBouncer ? 255
: (int) MathUtils.constrain(
MathUtils.map(.5f, .9f, 0f, 255f, expansion),
0f, 255f);
if (!mShowingUdfpsBouncer) {
alpha *= (1.0f - mTransitionToFullShadeProgress);
@@ -471,7 +474,9 @@ public class UdfpsKeyguardViewController extends UdfpsAnimationViewController<Ud
@Override
public void onPanelExpansionChanged(
float fraction, boolean expanded, boolean tracking) {
mStatusBarExpansion = fraction;
mPanelExpansionFraction =
mKeyguardViewManager.bouncerIsInTransit() ? BouncerPanelExpansionCalculator
.aboutToShowBouncerProgress(fraction) : fraction;
updateAlpha();
}
};

View File

@@ -16,7 +16,7 @@
package com.android.systemui.dreams;
import static com.android.keyguard.BouncerPanelExpansionCalculator.getBackScrimScaledExpansion;
import static com.android.keyguard.BouncerPanelExpansionCalculator.aboutToShowBouncerProgress;
import static com.android.keyguard.BouncerPanelExpansionCalculator.getDreamAlphaScaledExpansion;
import static com.android.keyguard.BouncerPanelExpansionCalculator.getDreamYPositionScaledExpansion;
import static com.android.systemui.doze.util.BurnInHelperKt.getBurnInOffset;
@@ -217,19 +217,19 @@ public class DreamOverlayContainerViewController extends ViewController<DreamOve
mBlurUtils.applyBlur(mView.getViewRootImpl(),
(int) mBlurUtils.blurRadiusOfRatio(
1 - getBackScrimScaledExpansion(bouncerHideAmount)), false);
1 - aboutToShowBouncerProgress(bouncerHideAmount)), false);
}
private static float getAlpha(int position, float expansion) {
return Interpolators.LINEAR_OUT_SLOW_IN.getInterpolation(
position == POSITION_TOP ? getDreamAlphaScaledExpansion(expansion)
: getBackScrimScaledExpansion(expansion + 0.03f));
: aboutToShowBouncerProgress(expansion + 0.03f));
}
private float getTranslationY(int position, float expansion) {
final float fraction = Interpolators.LINEAR_OUT_SLOW_IN.getInterpolation(
position == POSITION_TOP ? getDreamYPositionScaledExpansion(expansion)
: getBackScrimScaledExpansion(expansion + 0.03f));
: aboutToShowBouncerProgress(expansion + 0.03f));
return MathUtils.lerp(-mDreamOverlayMaxTranslationY, 0, fraction);
}
}

View File

@@ -610,7 +610,7 @@ public class QSFragment extends LifecycleFragment implements QS, CommandQueue.Ca
view.setVisibility((View.VISIBLE));
}
float alpha = mQSPanelController.bouncerInTransit()
? BouncerPanelExpansionCalculator.getBackScrimScaledExpansion(progress)
? BouncerPanelExpansionCalculator.aboutToShowBouncerProgress(progress)
: ShadeInterpolation.getContentAlpha(progress);
view.setAlpha(alpha);
}

View File

@@ -797,7 +797,7 @@ public abstract class PanelViewController {
mExpandedFraction = Math.min(1f,
maxPanelHeight == 0 ? 0 : mExpandedHeight / maxPanelHeight);
mAmbientState.setExpansionFraction(mStatusBarKeyguardViewManager.bouncerIsInTransit()
? BouncerPanelExpansionCalculator.getBackScrimScaledExpansion(mExpandedFraction)
? BouncerPanelExpansionCalculator.aboutToShowBouncerProgress(mExpandedFraction)
: mExpandedFraction);
onHeightUpdated(mExpandedHeight);
updatePanelExpansionAndVisibility();

View File

@@ -790,7 +790,7 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump
if (mBouncerHiddenFraction != KeyguardBouncer.EXPANSION_HIDDEN) {
final float interpolatedFraction =
BouncerPanelExpansionCalculator.getBackScrimScaledExpansion(
BouncerPanelExpansionCalculator.aboutToShowBouncerProgress(
mBouncerHiddenFraction);
mBehindAlpha = MathUtils.lerp(mDefaultScrimAlpha, mBehindAlpha,
interpolatedFraction);
@@ -1076,7 +1076,7 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump
private float getInterpolatedFraction() {
if (mStatusBarKeyguardViewManager.bouncerIsInTransit()) {
return BouncerPanelExpansionCalculator
.getBackScrimScaledExpansion(mPanelExpansionFraction);
.aboutToShowBouncerProgress(mPanelExpansionFraction);
}
return ShadeInterpolation.getNotificationScrimAlpha(mPanelExpansionFraction);
}

View File

@@ -29,29 +29,29 @@ import org.junit.runner.RunWith
class BouncerPanelExpansionCalculatorTest : SysuiTestCase() {
@Test
fun testGetHostViewScaledExpansion() {
assertThat(BouncerPanelExpansionCalculator.getHostViewScaledExpansion(1f))
assertThat(BouncerPanelExpansionCalculator.showBouncerProgress(1f))
.isEqualTo(1f)
assertThat(BouncerPanelExpansionCalculator.getHostViewScaledExpansion(0.9f))
assertThat(BouncerPanelExpansionCalculator.showBouncerProgress(0.9f))
.isEqualTo(1f)
assertThat(BouncerPanelExpansionCalculator.getHostViewScaledExpansion(0.59f))
assertThat(BouncerPanelExpansionCalculator.showBouncerProgress(0.59f))
.isEqualTo(0f)
assertThat(BouncerPanelExpansionCalculator.getHostViewScaledExpansion(0f))
assertThat(BouncerPanelExpansionCalculator.showBouncerProgress(0f))
.isEqualTo(0f)
assertEquals(BouncerPanelExpansionCalculator
.getHostViewScaledExpansion(0.8f), 2f / 3f, 0.01f)
.showBouncerProgress(0.8f), 2f / 3f, 0.01f)
}
@Test
fun testGetBackScrimScaledExpansion() {
assertThat(BouncerPanelExpansionCalculator.getBackScrimScaledExpansion(1f))
assertThat(BouncerPanelExpansionCalculator.aboutToShowBouncerProgress(1f))
.isEqualTo(1f)
assertEquals(BouncerPanelExpansionCalculator
.getBackScrimScaledExpansion(0.95f), 1f / 2f, 0.01f)
assertThat(BouncerPanelExpansionCalculator.getBackScrimScaledExpansion(0.9f))
.aboutToShowBouncerProgress(0.95f), 1f / 2f, 0.01f)
assertThat(BouncerPanelExpansionCalculator.aboutToShowBouncerProgress(0.9f))
.isEqualTo(0f)
assertThat(BouncerPanelExpansionCalculator.getBackScrimScaledExpansion(0.5f))
assertThat(BouncerPanelExpansionCalculator.aboutToShowBouncerProgress(0.5f))
.isEqualTo(0f)
assertThat(BouncerPanelExpansionCalculator.getBackScrimScaledExpansion(0f))
assertThat(BouncerPanelExpansionCalculator.aboutToShowBouncerProgress(0f))
.isEqualTo(0f)
}
@@ -63,9 +63,9 @@ class BouncerPanelExpansionCalculatorTest : SysuiTestCase() {
.getKeyguardClockScaledExpansion(0.8f), 1f / 3f, 0.01f)
assertThat(BouncerPanelExpansionCalculator.getKeyguardClockScaledExpansion(0.7f))
.isEqualTo(0f)
assertThat(BouncerPanelExpansionCalculator.getBackScrimScaledExpansion(0.5f))
assertThat(BouncerPanelExpansionCalculator.aboutToShowBouncerProgress(0.5f))
.isEqualTo(0f)
assertThat(BouncerPanelExpansionCalculator.getBackScrimScaledExpansion(0f))
assertThat(BouncerPanelExpansionCalculator.aboutToShowBouncerProgress(0f))
.isEqualTo(0f)
}
}

View File

@@ -177,7 +177,7 @@ public class DreamOverlayContainerViewControllerTest extends SysuiTestCase {
final float bouncerHideAmount = 0.05f;
final float scaledFraction =
BouncerPanelExpansionCalculator.getBackScrimScaledExpansion(bouncerHideAmount);
BouncerPanelExpansionCalculator.aboutToShowBouncerProgress(bouncerHideAmount);
bouncerExpansionCaptor.getValue().onExpansionChanged(bouncerHideAmount);
verify(mBlurUtils).blurRadiusOfRatio(1 - scaledFraction);

View File

@@ -214,7 +214,7 @@ public class QSFragmentTest extends SysuiBaseFragmentTest {
assertThat(mQsFragmentView.getAlpha())
.isEqualTo(
BouncerPanelExpansionCalculator.getBackScrimScaledExpansion(
BouncerPanelExpansionCalculator.aboutToShowBouncerProgress(
transitionProgress));
}

View File

@@ -1244,11 +1244,11 @@ public class ScrimControllerTest extends SysuiTestCase {
float expansion = 0.8f;
float expectedAlpha =
BouncerPanelExpansionCalculator.getBackScrimScaledExpansion(expansion);
BouncerPanelExpansionCalculator.aboutToShowBouncerProgress(expansion);
assertAlphaAfterExpansion(mNotificationsScrim, expectedAlpha, expansion);
expansion = 0.2f;
expectedAlpha = BouncerPanelExpansionCalculator.getBackScrimScaledExpansion(expansion);
expectedAlpha = BouncerPanelExpansionCalculator.aboutToShowBouncerProgress(expansion);
assertAlphaAfterExpansion(mNotificationsScrim, expectedAlpha, expansion);
}
@@ -1284,7 +1284,7 @@ public class ScrimControllerTest extends SysuiTestCase {
// Verify normal behavior after
mScrimController.setUnocclusionAnimationRunning(false);
float expansion = 0.4f;
float alpha = 1 - BouncerPanelExpansionCalculator.getBackScrimScaledExpansion(expansion);
float alpha = 1 - BouncerPanelExpansionCalculator.aboutToShowBouncerProgress(expansion);
assertAlphaAfterExpansion(mNotificationsScrim, alpha, expansion);
}
@@ -1316,15 +1316,15 @@ public class ScrimControllerTest extends SysuiTestCase {
mScrimController.transitionTo(ScrimState.KEYGUARD);
float expansion = 0.8f;
float alpha = 1 - BouncerPanelExpansionCalculator.getBackScrimScaledExpansion(expansion);
float alpha = 1 - BouncerPanelExpansionCalculator.aboutToShowBouncerProgress(expansion);
assertAlphaAfterExpansion(mNotificationsScrim, alpha, expansion);
expansion = 0.4f;
alpha = 1 - BouncerPanelExpansionCalculator.getBackScrimScaledExpansion(expansion);
alpha = 1 - BouncerPanelExpansionCalculator.aboutToShowBouncerProgress(expansion);
assertAlphaAfterExpansion(mNotificationsScrim, alpha, expansion);
expansion = 0.2f;
alpha = 1 - BouncerPanelExpansionCalculator.getBackScrimScaledExpansion(expansion);
alpha = 1 - BouncerPanelExpansionCalculator.aboutToShowBouncerProgress(expansion);
assertAlphaAfterExpansion(mNotificationsScrim, alpha, expansion);
}