Correctly clip QS during heads-up pull down
Test: pull down heads-up Test: swipe-up heads-up Test: receive hun, wait for timeout Test: atest NotificationShadeDepthControllerTest Test: atest NotificationPanelViewControllerTest Fixes: 197641911 Fixes: 199527220 Change-Id: I47914698091aedfe7e4b1004039467de197194c7
This commit is contained in:
@@ -78,7 +78,8 @@ class NotificationShadeDepthController @Inject constructor(
|
|||||||
private var keyguardAnimator: Animator? = null
|
private var keyguardAnimator: Animator? = null
|
||||||
private var notificationAnimator: Animator? = null
|
private var notificationAnimator: Animator? = null
|
||||||
private var updateScheduled: Boolean = false
|
private var updateScheduled: Boolean = false
|
||||||
private var shadeExpansion = 0f
|
@VisibleForTesting
|
||||||
|
var shadeExpansion = 0f
|
||||||
private var isClosed: Boolean = true
|
private var isClosed: Boolean = true
|
||||||
private var isOpen: Boolean = false
|
private var isOpen: Boolean = false
|
||||||
private var isBlurred: Boolean = false
|
private var isBlurred: Boolean = false
|
||||||
@@ -92,6 +93,9 @@ class NotificationShadeDepthController @Inject constructor(
|
|||||||
// Only for dumpsys
|
// Only for dumpsys
|
||||||
private var lastAppliedBlur = 0
|
private var lastAppliedBlur = 0
|
||||||
|
|
||||||
|
// Shade expansion offset that happens when pulling down on a HUN.
|
||||||
|
var panelPullDownMinFraction = 0f
|
||||||
|
|
||||||
var shadeAnimation = DepthAnimation()
|
var shadeAnimation = DepthAnimation()
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
@@ -312,8 +316,10 @@ class NotificationShadeDepthController @Inject constructor(
|
|||||||
/**
|
/**
|
||||||
* Update blurs when pulling down the shade
|
* Update blurs when pulling down the shade
|
||||||
*/
|
*/
|
||||||
override fun onPanelExpansionChanged(expansion: Float, tracking: Boolean) {
|
override fun onPanelExpansionChanged(rawExpansion: Float, tracking: Boolean) {
|
||||||
val timestamp = SystemClock.elapsedRealtimeNanos()
|
val timestamp = SystemClock.elapsedRealtimeNanos()
|
||||||
|
val expansion = MathUtils.saturate(
|
||||||
|
(rawExpansion - panelPullDownMinFraction) / (1f - panelPullDownMinFraction))
|
||||||
|
|
||||||
if (shadeExpansion == expansion && prevTracking == tracking) {
|
if (shadeExpansion == expansion && prevTracking == tracking) {
|
||||||
prevTimestamp = timestamp
|
prevTimestamp = timestamp
|
||||||
|
|||||||
@@ -582,6 +582,7 @@ public class NotificationPanelViewController extends PanelViewController {
|
|||||||
private int mQsClipBottom;
|
private int mQsClipBottom;
|
||||||
private boolean mQsVisible;
|
private boolean mQsVisible;
|
||||||
private final ContentResolver mContentResolver;
|
private final ContentResolver mContentResolver;
|
||||||
|
private float mMinFraction;
|
||||||
|
|
||||||
private final Executor mUiExecutor;
|
private final Executor mUiExecutor;
|
||||||
private final SecureSettings mSecureSettings;
|
private final SecureSettings mSecureSettings;
|
||||||
@@ -1777,6 +1778,15 @@ public class NotificationPanelViewController extends PanelViewController {
|
|||||||
return !mQsTouchAboveFalsingThreshold;
|
return !mQsTouchAboveFalsingThreshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Percentage of panel expansion offset, caused by pulling down on a heads-up.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setMinFraction(float minFraction) {
|
||||||
|
mMinFraction = minFraction;
|
||||||
|
mDepthController.setPanelPullDownMinFraction(mMinFraction);
|
||||||
|
}
|
||||||
|
|
||||||
private float computeQsExpansionFraction() {
|
private float computeQsExpansionFraction() {
|
||||||
if (mQSAnimatingHiddenFromCollapsed) {
|
if (mQSAnimatingHiddenFromCollapsed) {
|
||||||
// When hiding QS from collapsed state, the expansion can sometimes temporarily
|
// When hiding QS from collapsed state, the expansion can sometimes temporarily
|
||||||
@@ -2246,6 +2256,12 @@ public class NotificationPanelViewController extends PanelViewController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
top += mOverStretchAmount;
|
top += mOverStretchAmount;
|
||||||
|
// Correction for instant expansion caused by HUN pull down/
|
||||||
|
if (mMinFraction > 0f && mMinFraction < 1f) {
|
||||||
|
float realFraction =
|
||||||
|
(getExpandedFraction() - mMinFraction) / (1f - mMinFraction);
|
||||||
|
top *= MathUtils.saturate(realFraction / mMinFraction);
|
||||||
|
}
|
||||||
bottom = getView().getBottom();
|
bottom = getView().getBottom();
|
||||||
// notification bounds should take full screen width regardless of insets
|
// notification bounds should take full screen width regardless of insets
|
||||||
left = 0;
|
left = 0;
|
||||||
@@ -3313,7 +3329,7 @@ public class NotificationPanelViewController extends PanelViewController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setPanelScrimMinFraction(float minFraction) {
|
public void setPanelScrimMinFraction(float minFraction) {
|
||||||
mBar.panelScrimMinFractionChanged(minFraction);
|
mBar.onPanelMinFractionChanged(minFraction);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearNotificationEffects() {
|
public void clearNotificationEffects() {
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ package com.android.systemui.statusbar.phone;
|
|||||||
|
|
||||||
import static java.lang.Float.isNaN;
|
import static java.lang.Float.isNaN;
|
||||||
|
|
||||||
|
import android.annotation.CallSuper;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
@@ -162,7 +163,13 @@ public abstract class PanelBar extends FrameLayout {
|
|||||||
return mPanel == null || mPanel.getView().dispatchTouchEvent(event);
|
return mPanel == null || mPanel.getView().dispatchTouchEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void panelScrimMinFractionChanged(float minFraction);
|
/**
|
||||||
|
* Percentage of panel expansion offset, caused by pulling down on a heads-up.
|
||||||
|
*/
|
||||||
|
@CallSuper
|
||||||
|
public void onPanelMinFractionChanged(float minFraction) {
|
||||||
|
mPanel.setMinFraction(minFraction);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param frac the fraction from the expansion in [0, 1]
|
* @param frac the fraction from the expansion in [0, 1]
|
||||||
|
|||||||
@@ -339,6 +339,13 @@ public abstract class PanelViewController {
|
|||||||
|
|
||||||
protected abstract float getOpeningHeight();
|
protected abstract float getOpeningHeight();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Minimum fraction from where expansion should start. This is set when pulling down on a
|
||||||
|
* heads-up notification.
|
||||||
|
* @param minFraction Fraction from 0 to 1.
|
||||||
|
*/
|
||||||
|
public abstract void setMinFraction(float minFraction);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return whether the swiping direction is upwards and above a 45 degree angle compared to the
|
* @return whether the swiping direction is upwards and above a 45 degree angle compared to the
|
||||||
* horizontal direction
|
* horizontal direction
|
||||||
|
|||||||
@@ -273,10 +273,11 @@ public class PhoneStatusBarView extends PanelBar {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void panelScrimMinFractionChanged(float minFraction) {
|
public void onPanelMinFractionChanged(float minFraction) {
|
||||||
if (isNaN(minFraction)) {
|
if (isNaN(minFraction)) {
|
||||||
throw new IllegalArgumentException("minFraction cannot be NaN");
|
throw new IllegalArgumentException("minFraction cannot be NaN");
|
||||||
}
|
}
|
||||||
|
super.onPanelMinFractionChanged(minFraction);
|
||||||
if (mMinFraction != minFraction) {
|
if (mMinFraction != minFraction) {
|
||||||
mMinFraction = minFraction;
|
mMinFraction = minFraction;
|
||||||
updateScrimFraction();
|
updateScrimFraction();
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import com.android.systemui.statusbar.phone.DozeParameters
|
|||||||
import com.android.systemui.statusbar.phone.ScrimController
|
import com.android.systemui.statusbar.phone.ScrimController
|
||||||
import com.android.systemui.statusbar.policy.KeyguardStateController
|
import com.android.systemui.statusbar.policy.KeyguardStateController
|
||||||
import com.android.systemui.util.mockito.eq
|
import com.android.systemui.util.mockito.eq
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
@@ -167,6 +168,22 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
|
|||||||
verify(shadeAnimation).animateTo(eq(maxBlur), any())
|
verify(shadeAnimation).animateTo(eq(maxBlur), any())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun onPanelExpansionChanged_respectsMinPanelPullDownFraction() {
|
||||||
|
notificationShadeDepthController.panelPullDownMinFraction = 0.5f
|
||||||
|
notificationShadeDepthController.onPanelExpansionChanged(0.5f /* expansion */,
|
||||||
|
true /* tracking */)
|
||||||
|
assertThat(notificationShadeDepthController.shadeExpansion).isEqualTo(0f)
|
||||||
|
|
||||||
|
notificationShadeDepthController.onPanelExpansionChanged(0.75f /* expansion */,
|
||||||
|
true /* tracking */)
|
||||||
|
assertThat(notificationShadeDepthController.shadeExpansion).isEqualTo(0.5f)
|
||||||
|
|
||||||
|
notificationShadeDepthController.onPanelExpansionChanged(1f /* expansion */,
|
||||||
|
true /* tracking */)
|
||||||
|
assertThat(notificationShadeDepthController.shadeExpansion).isEqualTo(1f)
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun onStateChanged_reevalutesBlurs_ifSameRadiusAndNewState() {
|
fun onStateChanged_reevalutesBlurs_ifSameRadiusAndNewState() {
|
||||||
onPanelExpansionChanged_apliesBlur_ifShade()
|
onPanelExpansionChanged_apliesBlur_ifShade()
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ import java.util.List;
|
|||||||
@SmallTest
|
@SmallTest
|
||||||
@RunWith(AndroidTestingRunner.class)
|
@RunWith(AndroidTestingRunner.class)
|
||||||
@TestableLooper.RunWithLooper
|
@TestableLooper.RunWithLooper
|
||||||
public class NotificationPanelViewTest extends SysuiTestCase {
|
public class NotificationPanelViewControllerTest extends SysuiTestCase {
|
||||||
|
|
||||||
private static final int NOTIFICATION_SCRIM_TOP_PADDING_IN_SPLIT_SHADE = 50;
|
private static final int NOTIFICATION_SCRIM_TOP_PADDING_IN_SPLIT_SHADE = 50;
|
||||||
|
|
||||||
@@ -471,6 +471,12 @@ public class NotificationPanelViewTest extends SysuiTestCase {
|
|||||||
.setHeadsUpAppearanceController(mock(HeadsUpAppearanceController.class));
|
.setHeadsUpAppearanceController(mock(HeadsUpAppearanceController.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSetMinFraction() {
|
||||||
|
mNotificationPanelViewController.setMinFraction(0.5f);
|
||||||
|
verify(mNotificationShadeDepthController).setPanelPullDownMinFraction(eq(0.5f));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSetDozing_notifiesNsslAndStateController() {
|
public void testSetDozing_notifiesNsslAndStateController() {
|
||||||
mNotificationPanelViewController.setDozing(true /* dozing */, false /* animate */,
|
mNotificationPanelViewController.setDozing(true /* dozing */, false /* animate */,
|
||||||
Reference in New Issue
Block a user