diff options
| author | 2023-09-07 16:30:04 +0000 | |
|---|---|---|
| committer | 2023-09-07 16:30:04 +0000 | |
| commit | 850a751508d54421b82e27eb146a26ec241eb1be (patch) | |
| tree | 75312c23f685729415061c99425242e6bfb06da0 | |
| parent | 14c35bff804f925995b4d7483775e9ae1fbcafbb (diff) | |
| parent | 52b2f003192d4548d5a72153cba6a54c3e393cd8 (diff) | |
Merge "Don't set negative alpha values for the KeyguardBottomArea" into main
2 files changed, 33 insertions, 4 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java index c1999043743c..246ea0ed1e13 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java @@ -2317,7 +2317,8 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump return mKeyguardInteractor.getWakefulnessModel().getValue(); } - private void maybeAnimateBottomAreaAlpha() { + @VisibleForTesting + void maybeAnimateBottomAreaAlpha() { mBottomAreaShadeAlphaAnimator.cancel(); if (mBarState == StatusBarState.SHADE_LOCKED) { mBottomAreaShadeAlphaAnimator.setFloatValues(mBottomAreaShadeAlpha, 0.0f); @@ -2679,10 +2680,10 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump // • User tapping on lock screen: bouncer won't be visible but panel expansion will // change due to "unlock hint animation." In this case, fading out the bottom area // would also hide the message that says "swipe to unlock," we don't want to do that. - float expansionAlpha = MathUtils.map( - isUnlockHintRunning() ? 0 : KeyguardBouncerConstants.ALPHA_EXPANSION_THRESHOLD, 1f, - 0f, 1f, + float expansionAlpha = MathUtils.constrainedMap(0f, 1f, + isUnlockHintRunning() ? 0f : KeyguardBouncerConstants.ALPHA_EXPANSION_THRESHOLD, 1f, getExpandedFraction()); + float alpha = Math.min(expansionAlpha, 1 - mQsController.computeExpansionFraction()); alpha *= mBottomAreaShadeAlpha; if (mFeatureFlags.isEnabled(Flags.MIGRATE_SPLIT_KEYGUARD_BOTTOM_AREA)) { diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerWithCoroutinesTest.kt b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerWithCoroutinesTest.kt index c68095ca65a7..b0125f8289ec 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerWithCoroutinesTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerWithCoroutinesTest.kt @@ -26,6 +26,7 @@ import androidx.test.filters.SmallTest import com.android.internal.util.CollectionUtils import com.android.keyguard.KeyguardClockSwitch.LARGE import com.android.systemui.R +import com.android.systemui.coroutines.collectLastValue import com.android.systemui.flags.Flags.ONE_WAY_HAPTICS_API_MIGRATION import com.android.systemui.statusbar.StatusBarState.KEYGUARD import com.android.systemui.statusbar.StatusBarState.SHADE @@ -261,4 +262,31 @@ class NotificationPanelViewControllerWithCoroutinesTest : } advanceUntilIdle() } + + @Test + fun onLayoutChange_shadeCollapsed_bottomAreaAlphaIsZero() = runTest { + // GIVEN bottomAreaShadeAlpha was updated before + mNotificationPanelViewController.maybeAnimateBottomAreaAlpha() + + // WHEN a layout change is triggered with the shade being closed + triggerLayoutChange() + + // THEN the bottomAreaAlpha is zero + val bottomAreaAlpha by collectLastValue(mFakeKeyguardRepository.bottomAreaAlpha) + assertThat(bottomAreaAlpha).isEqualTo(0f) + } + + @Test + fun onShadeExpanded_bottomAreaAlphaIsFullyOpaque() = runTest { + // GIVEN bottomAreaShadeAlpha was updated before + mNotificationPanelViewController.maybeAnimateBottomAreaAlpha() + + // WHEN the shade expanded + val transitionDistance = mNotificationPanelViewController.maxPanelTransitionDistance + mNotificationPanelViewController.expandedHeight = transitionDistance.toFloat() + + // THEN the bottomAreaAlpha is fully opaque + val bottomAreaAlpha by collectLastValue(mFakeKeyguardRepository.bottomAreaAlpha) + assertThat(bottomAreaAlpha).isEqualTo(1f) + } } |