Merge changes I60669089,Iba4fbaaa into qt-r1-dev

* changes:
  Fixed the maxPanelheight on the lockscreen
  Extended the bypass experience
This commit is contained in:
Selim Cinek
2019-05-28 20:35:13 +00:00
committed by Android (Google) Code Review
10 changed files with 100 additions and 54 deletions

View File

@@ -453,7 +453,7 @@ public class NotificationShelf extends ActivatableNotificationView implements
private void updateContinuousClipping(final ExpandableNotificationRow row) {
StatusBarIconView icon = row.getEntry().expandedIcon;
boolean needsContinuousClipping = ViewState.isAnimatingY(icon) && !mAmbientState.isDark();
boolean needsContinuousClipping = ViewState.isAnimatingY(icon) && !mAmbientState.isDozing();
boolean isContinuousClipping = icon.getTag(TAG_CONTINUOUS_CLIPPING) != null;
if (needsContinuousClipping && !isContinuousClipping) {
final ViewTreeObserver observer = icon.getViewTreeObserver();
@@ -829,7 +829,7 @@ public class NotificationShelf extends ActivatableNotificationView implements
private void setOpenedAmount(float openedAmount) {
mNoAnimationsInThisFrame = openedAmount == 1.0f && mOpenedAmount == 0.0f;
mOpenedAmount = openedAmount;
if (!mAmbientState.isPanelFullWidth() || mAmbientState.isDark()) {
if (!mAmbientState.isPanelFullWidth() || mAmbientState.isDozing()) {
// We don't do a transformation at all, lets just assume we are fully opened
openedAmount = 1.0f;
}

View File

@@ -22,11 +22,12 @@ import android.util.FloatProperty
import com.android.systemui.Interpolators
import com.android.systemui.plugins.statusbar.StatusBarStateController
import com.android.systemui.statusbar.AmbientPulseManager
import com.android.systemui.statusbar.SysuiStatusBarStateController
import com.android.systemui.statusbar.StatusBarState
import com.android.systemui.statusbar.notification.collection.NotificationEntry
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout
import com.android.systemui.statusbar.notification.stack.StackStateAnimator
import com.android.systemui.statusbar.phone.DozeParameters
import com.android.systemui.statusbar.phone.KeyguardBypassController
import javax.inject.Inject
import javax.inject.Singleton
@@ -35,7 +36,8 @@ import javax.inject.Singleton
class NotificationWakeUpCoordinator @Inject constructor(
private val mContext: Context,
private val mAmbientPulseManager: AmbientPulseManager,
private val mStatusBarStateController: StatusBarStateController)
private val mStatusBarStateController: StatusBarStateController,
private val mBypassController: KeyguardBypassController)
: AmbientPulseManager.OnAmbientChangedListener, StatusBarStateController.StateListener {
private val mNotificationVisibility
@@ -137,6 +139,9 @@ class NotificationWakeUpCoordinator @Inject constructor(
}
override fun onDozeAmountChanged(linear: Float, eased: Float) {
if (updateDozeAmountIfBypass()) {
return
}
if (linear != 1.0f && linear != 0.0f
&& (mLinearDozeAmount == 0.0f || mLinearDozeAmount == 1.0f)) {
// Let's notify the scroller that an animation started
@@ -153,6 +158,27 @@ class NotificationWakeUpCoordinator @Inject constructor(
}
}
override fun onStateChanged(newState: Int) {
updateDozeAmountIfBypass();
}
private fun updateDozeAmountIfBypass(): Boolean {
if (mBypassController.bypassEnabled) {
if (mStatusBarStateController.state == StatusBarState.SHADE
|| mStatusBarStateController.state == StatusBarState.SHADE_LOCKED) {
mDozeAmount = 0.0f
mLinearDozeAmount = 0.0f
} else {
mDozeAmount = 1.0f
mLinearDozeAmount = 1.0f
}
updateDarkAmount()
mStackScroller.setDozeAmount(mDozeAmount)
return true
}
return false
}
private fun startVisibilityAnimation(increaseSpeed: Boolean) {
if (mNotificationVisibleAmount == 0f || mNotificationVisibleAmount == 1f) {
mVisibilityInterpolator = if (mNotificationsVisible)

View File

@@ -52,7 +52,7 @@ public class AmbientState {
private float mOverScrollTopAmount;
private float mOverScrollBottomAmount;
private int mSpeedBumpIndex = -1;
private boolean mDark;
private boolean mDozing;
private boolean mHideSensitive;
private AmbientPulseManager mAmbientPulseManager = Dependency.get(AmbientPulseManager.class);
private float mStackTranslation;
@@ -181,8 +181,8 @@ public class AmbientState {
}
/** In dark mode, we draw as little as possible, assuming a black background */
public void setDark(boolean dark) {
mDark = dark;
public void setDozing(boolean dozing) {
mDozing = dozing;
}
/** Dark ratio of the status bar **/
@@ -215,8 +215,8 @@ public class AmbientState {
return mDimmed;
}
public boolean isDark() {
return mDark;
public boolean isDozing() {
return mDozing;
}
public boolean isHideSensitive() {
@@ -459,7 +459,7 @@ public class AmbientState {
* @return whether a row is dozing and not pulsing right now
*/
public boolean isDozingAndNotPulsing(ExpandableNotificationRow row) {
return isDark() && !isPulsing(row.getEntry());
return isDozing() && !isPulsing(row.getEntry());
}
public void setExpandAnimationTopChange(int expandAnimationTopChange) {

View File

@@ -770,7 +770,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
if (mShouldDrawNotificationBackground
&& (mSections[0].getCurrentBounds().top
< mSections[NUM_SECTIONS - 1].getCurrentBounds().bottom
|| mAmbientState.isDark())) {
|| mAmbientState.isDozing())) {
drawBackground(canvas);
} else if (mInHeadsUpPinnedMode || mHeadsUpAnimatingAway) {
drawHeadsUpBackground(canvas);
@@ -804,7 +804,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
canvas.drawLine(0, y, getWidth(), y, mDebugPaint);
}
canvas.drawText(Integer.toString(getMaxNegativeScrollAmount()), getWidth() - 100,
getIntrinsicPadding() + 30, mDebugPaint);
getTopPadding() + 30, mDebugPaint);
canvas.drawText(Integer.toString(getMaxPositiveScrollAmount()), getWidth() - 100,
getHeight() - 30, mDebugPaint);
}
@@ -842,7 +842,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
break;
}
}
if (!mAmbientState.isDark() || anySectionHasVisibleChild) {
if (!mAmbientState.isDozing() || anySectionHasVisibleChild) {
drawBackgroundRects(canvas, left, right, top, backgroundTopAnimationOffset);
}
@@ -1438,7 +1438,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
int notGoneChildCount = getNotGoneChildCount();
if (mEmptyShadeView.getVisibility() == GONE && notGoneChildCount != 0) {
if (isHeadsUpTransition()
|| (mHeadsUpManager.hasPinnedHeadsUp() && !mAmbientState.isDark())) {
|| (mHeadsUpManager.hasPinnedHeadsUp() && !mAmbientState.isDozing())) {
appearPosition = getTopHeadsUpPinnedHeight();
} else {
appearPosition = 0;
@@ -2403,7 +2403,9 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
}
mIntrinsicContentHeight = height;
mContentHeight = height + mTopPadding + mBottomMargin;
// The topPadding can be bigger than the regular padding when qs is expanded, in that
// state the maxPanelHeight and the contentHeight should be bigger
mContentHeight = height + Math.max(mIntrinsicPadding, mTopPadding) + mBottomMargin;
updateScrollability();
clampScrollPosition();
mAmbientState.setLayoutMaxHeight(mContentHeight);
@@ -2783,12 +2785,9 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
*
* @param qsHeight the top padding imposed by the quick settings panel
* @param animate whether to animate the change
* @param ignoreIntrinsicPadding if true, {@link #getIntrinsicPadding()} is ignored and
* {@code qsHeight} is the final top padding
*/
@ShadeViewRefactor(RefactorComponent.COORDINATOR)
public void updateTopPadding(float qsHeight, boolean animate,
boolean ignoreIntrinsicPadding) {
public void updateTopPadding(float qsHeight, boolean animate) {
int topPadding = (int) qsHeight;
int minStackHeight = getLayoutMinHeight();
if (topPadding + minStackHeight > getHeight()) {
@@ -2796,8 +2795,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
} else {
mTopPaddingOverflow = 0;
}
setTopPadding(ignoreIntrinsicPadding ? topPadding : clampPadding(topPadding),
animate);
setTopPadding(topPadding, animate);
setExpandedHeight(mExpandedHeight);
}
@@ -3532,7 +3530,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
private void generateTopPaddingEvent() {
if (mTopPaddingNeedsAnimation) {
AnimationEvent event;
if (mAmbientState.isDark()) {
if (mAmbientState.isDozing()) {
event = new AnimationEvent(null /* view */,
AnimationEvent.ANIMATION_TYPE_TOP_PADDING_CHANGED,
KeyguardSliceView.DEFAULT_ANIM_DURATION);
@@ -4712,21 +4710,19 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
}
/**
* See {@link AmbientState#setDark}.
* See {@link AmbientState#setDozing}.
*/
@ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
public void setDark(boolean dark, boolean animate, @Nullable PointF touchWakeUpScreenLocation) {
if (mAmbientState.isDark() == dark) {
public void setDozing(boolean dozing, boolean animate,
@Nullable PointF touchWakeUpScreenLocation) {
if (mAmbientState.isDozing() == dozing) {
return;
}
mAmbientState.setDark(dark);
mAmbientState.setDozing(dozing);
if (animate && mAnimationsEnabled) {
mDarkNeedsAnimation = true;
mDarkAnimationOriginIndex = findDarkAnimationOriginIndex(touchWakeUpScreenLocation);
mNeedsAnimation = true;
} else {
setDarkAmount(dark ? 1f : 0f);
updateBackground();
}
requestChildrenUpdate();
updateWillNotDraw();
@@ -6348,7 +6344,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
(int) (dragLengthY / mDisplayMetrics.density),
0 /* velocityDp - N/A */);
if (!mAmbientState.isDark() || startingChild != null) {
if (!mAmbientState.isDozing() || startingChild != null) {
// We have notifications, go to locked shade.
mShadeController.goToLockedShade(startingChild);
if (startingChild instanceof ExpandableNotificationRow) {

View File

@@ -255,7 +255,7 @@ public class StackScrollAlgorithm {
state.paddingMap.clear();
int notGoneIndex = 0;
ExpandableView lastView = null;
int firstHiddenIndex = ambientState.isDark()
int firstHiddenIndex = ambientState.isDozing()
? (ambientState.hasPulsingNotifications() ? 1 : 0)
: childCount;

View File

@@ -111,6 +111,12 @@ public class KeyguardClockPositionAlgorithm {
private float mEmptyDragAmount;
/**
* If true the clock should always be positioned like it's dark. Used in the bypass, where
* notifications don't expand on the lock screen and should be kept stable
*/
private boolean mPositionLikeDark;
/**
* Refreshes the dimension values.
*/
@@ -132,7 +138,8 @@ public class KeyguardClockPositionAlgorithm {
public void setup(int minTopMargin, int maxShadeBottom, int notificationStackHeight,
float panelExpansion, int parentHeight, int keyguardStatusHeight, int clockPreferredY,
boolean hasCustomClock, boolean hasVisibleNotifs, float dark, float emptyDragAmount) {
boolean hasCustomClock, boolean hasVisibleNotifs, float dark, float emptyDragAmount,
boolean positionLikeDark) {
mMinTopMargin = minTopMargin + mContainerTopPadding;
mMaxShadeBottom = maxShadeBottom;
mNotificationStackHeight = notificationStackHeight;
@@ -144,13 +151,15 @@ public class KeyguardClockPositionAlgorithm {
mHasVisibleNotifs = hasVisibleNotifs;
mDarkAmount = dark;
mEmptyDragAmount = emptyDragAmount;
mPositionLikeDark = positionLikeDark;
}
public void run(Result result) {
final int y = getClockY();
final int y = getClockY(mPanelExpansion);
result.clockY = y;
result.clockAlpha = getClockAlpha(y);
result.stackScrollerPadding = y + mKeyguardStatusHeight;
result.stackScrollerPaddingExpanded = getClockY(1.0f) + mKeyguardStatusHeight;
result.clockX = (int) interpolate(0, burnInPreventionOffsetX(), mDarkAmount);
}
@@ -195,7 +204,7 @@ public class KeyguardClockPositionAlgorithm {
return (int) y;
}
private int getClockY() {
private int getClockY(float panelExpansion) {
// Dark: Align the bottom edge of the clock at about half of the screen:
float clockYDark = (mHasCustomClock ? getPreferredClockY() : getMaxClockY())
+ burnInPreventionOffsetY();
@@ -205,11 +214,12 @@ public class KeyguardClockPositionAlgorithm {
float clockYBouncer = -mKeyguardStatusHeight;
// Move clock up while collapsing the shade
float shadeExpansion = Interpolators.FAST_OUT_LINEAR_IN.getInterpolation(mPanelExpansion);
float shadeExpansion = Interpolators.FAST_OUT_LINEAR_IN.getInterpolation(panelExpansion);
float clockY = MathUtils.lerp(clockYBouncer, clockYRegular, shadeExpansion);
clockYDark = MathUtils.lerp(clockYBouncer, clockYDark, shadeExpansion);
return (int) (MathUtils.lerp(clockY, clockYDark, mDarkAmount) + mEmptyDragAmount);
float darkAmount = mPositionLikeDark ? 1.0f : mDarkAmount;
return (int) (MathUtils.lerp(clockY, clockYDark, darkAmount) + mEmptyDragAmount);
}
/**
@@ -257,5 +267,10 @@ public class KeyguardClockPositionAlgorithm {
* The top padding of the stack scroller, in pixels.
*/
public int stackScrollerPadding;
/**
* The top padding of the stack scroller, in pixels when fully expanded.
*/
public int stackScrollerPaddingExpanded;
}
}

View File

@@ -150,6 +150,7 @@ public class NotificationPanelView extends PanelView implements
private final AccessibilityManager mAccessibilityManager;
private final NotificationWakeUpCoordinator mWakeUpCoordinator;
private final PulseExpansionHandler mPulseExpansionHandler;
private final KeyguardBypassController mKeyguardBypassController;
@VisibleForTesting
protected KeyguardAffordanceHelper mAffordanceHelper;
@@ -348,7 +349,8 @@ public class NotificationPanelView extends PanelView implements
InjectionInflationController injectionInflationController,
NotificationWakeUpCoordinator coordinator,
PulseExpansionHandler pulseExpansionHandler,
DynamicPrivacyController dynamicPrivacyController) {
DynamicPrivacyController dynamicPrivacyController,
KeyguardBypassController bypassController) {
super(context, attrs);
setWillNotDraw(!DEBUG);
mInjectionInflationController = injectionInflationController;
@@ -363,6 +365,7 @@ public class NotificationPanelView extends PanelView implements
mDisplayId = context.getDisplayId();
mPulseExpansionHandler = pulseExpansionHandler;
mThemeResId = context.getThemeResId();
mKeyguardBypassController = bypassController;
dynamicPrivacyController.addListener(this);
}
@@ -655,14 +658,15 @@ public class NotificationPanelView extends PanelView implements
hasCustomClock(),
mNotificationStackScroller.getVisibleNotificationCount() != 0,
mInterpolatedDarkAmount,
mEmptyDragAmount);
mEmptyDragAmount,
mKeyguardBypassController.getBypassEnabled());
mClockPositionAlgorithm.run(mClockPositionResult);
PropertyAnimator.setProperty(mKeyguardStatusView, AnimatableProperty.X,
mClockPositionResult.clockX, CLOCK_ANIMATION_PROPERTIES, animateClock);
PropertyAnimator.setProperty(mKeyguardStatusView, AnimatableProperty.Y,
mClockPositionResult.clockY, CLOCK_ANIMATION_PROPERTIES, animateClock);
updateClock();
stackScrollerPadding = mClockPositionResult.stackScrollerPadding;
stackScrollerPadding = mClockPositionResult.stackScrollerPaddingExpanded;
}
mNotificationStackScroller.setIntrinsicPadding(stackScrollerPadding);
mNotificationStackScroller.setAntiBurnInOffsetX(mClockPositionResult.clockX);
@@ -1595,7 +1599,7 @@ public class NotificationPanelView extends PanelView implements
} else if (mKeyguardShowing) {
// We can only do the smoother transition on Keyguard when we also are not collapsing
// from a scrolled quick settings.
return MathUtils.lerp((float) mNotificationStackScroller.getIntrinsicPadding(),
return MathUtils.lerp((float) mClockPositionResult.stackScrollerPadding,
(float) (mQsMaxExpansionHeight + mQsNotificationTopPadding),
getQsExpansionFraction());
} else {
@@ -1604,9 +1608,7 @@ public class NotificationPanelView extends PanelView implements
}
protected void requestScrollerTopPaddingUpdate(boolean animate) {
mNotificationStackScroller.updateTopPadding(calculateQsTopPadding(),
animate, mKeyguardShowing
&& (mQsExpandImmediate || mIsExpanding && mQsExpandedWhenExpandingStarted));
mNotificationStackScroller.updateTopPadding(calculateQsTopPadding(), animate);
}
private void trackMovement(MotionEvent event) {
@@ -2863,7 +2865,7 @@ public class NotificationPanelView extends PanelView implements
public void setDozing(boolean dozing, boolean animate, PointF wakeUpTouchLocation) {
if (dozing == mDozing) return;
mDozing = dozing;
mNotificationStackScroller.setDark(mDozing, animate, wakeUpTouchLocation);
mNotificationStackScroller.setDozing(mDozing, animate, wakeUpTouchLocation);
mKeyguardBottomArea.setDozing(mDozing, animate);
if (mBarState == StatusBarState.KEYGUARD
@@ -2871,8 +2873,8 @@ public class NotificationPanelView extends PanelView implements
updateDozingVisibilities(animate);
}
final float darkAmount = dozing ? 1 : 0;
mStatusBarStateController.setDozeAmount(darkAmount, animate);
final float dozeAmount = dozing ? 1 : 0;
mStatusBarStateController.setDozeAmount(dozeAmount, animate);
}
@Override

View File

@@ -194,9 +194,9 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
public void testAntiBurnInOffset() {
final int burnInOffset = 30;
mStackScroller.setAntiBurnInOffsetX(burnInOffset);
mStackScroller.setDark(false /* dark */, false /* animated */, null /* touch */);
mStackScroller.setDarkAmount(0.0f, 0.0f);
Assert.assertEquals(0 /* expected */, mStackScroller.getTranslationX(), 0.01 /* delta */);
mStackScroller.setDark(true /* dark */, false /* animated */, null /* touch */);
mStackScroller.setDarkAmount(1.0f, 1.0f);
Assert.assertEquals(burnInOffset /* expected */, mStackScroller.getTranslationX(),
0.01 /* delta */);
}

View File

@@ -383,7 +383,7 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase {
private void positionClock() {
mClockPositionAlgorithm.setup(EMPTY_MARGIN, SCREEN_HEIGHT, mNotificationStackHeight,
mPanelExpansion, SCREEN_HEIGHT, mKeyguardStatusHeight, mPreferredClockY,
mHasCustomClock, mHasVisibleNotifs, mDark, ZERO_DRAG);
mHasCustomClock, mHasVisibleNotifs, mDark, ZERO_DRAG, false /* positionLikeDark */);
mClockPositionAlgorithm.run(mClockPosition);
}
}

View File

@@ -49,6 +49,7 @@ import com.android.systemui.statusbar.notification.NotificationWakeUpCoordinator
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.ZenModeController;
import com.android.systemui.tuner.TunerService;
import com.android.systemui.util.InjectionInflationController;
import org.junit.Before;
@@ -111,12 +112,16 @@ public class NotificationPanelViewTest extends SysuiTestCase {
mDependency.injectMockDependency(NotificationLockscreenUserManager.class);
mDependency.injectMockDependency(ConfigurationController.class);
mDependency.injectMockDependency(ZenModeController.class);
KeyguardBypassController bypassController = new KeyguardBypassController(mContext,
mock(TunerService.class));
NotificationWakeUpCoordinator coordinator =
new NotificationWakeUpCoordinator(mContext,
new AmbientPulseManager(mContext),
new StatusBarStateControllerImpl());
new StatusBarStateControllerImpl(),
bypassController);
PulseExpansionHandler expansionHandler = new PulseExpansionHandler(mContext, coordinator);
mNotificationPanelView = new TestableNotificationPanelView(coordinator, expansionHandler);
mNotificationPanelView = new TestableNotificationPanelView(coordinator, expansionHandler,
bypassController);
mNotificationPanelView.setHeadsUpManager(mHeadsUpManager);
mNotificationPanelView.setBar(mPanelBar);
@@ -128,7 +133,7 @@ public class NotificationPanelViewTest extends SysuiTestCase {
public void testSetDozing_notifiesNsslAndStateController() {
mNotificationPanelView.setDozing(true /* dozing */, true /* animate */, null /* touch */);
InOrder inOrder = inOrder(mNotificationStackScrollLayout, mStatusBarStateController);
inOrder.verify(mNotificationStackScrollLayout).setDark(eq(true), eq(true), eq(null));
inOrder.verify(mNotificationStackScrollLayout).setDozing(eq(true), eq(true), eq(null));
inOrder.verify(mStatusBarStateController).setDozeAmount(eq(1f), eq(true));
}
@@ -178,11 +183,13 @@ public class NotificationPanelViewTest extends SysuiTestCase {
private class TestableNotificationPanelView extends NotificationPanelView {
TestableNotificationPanelView(NotificationWakeUpCoordinator coordinator,
PulseExpansionHandler expansionHandler) {
PulseExpansionHandler expansionHandler,
KeyguardBypassController bypassController) {
super(NotificationPanelViewTest.this.mContext, null,
new InjectionInflationController(
SystemUIFactory.getInstance().getRootComponent()),
coordinator, expansionHandler, mock(DynamicPrivacyController.class));
coordinator, expansionHandler, mock(DynamicPrivacyController.class),
bypassController);
mNotificationStackScroller = mNotificationStackScrollLayout;
mKeyguardStatusView = NotificationPanelViewTest.this.mKeyguardStatusView;
mKeyguardStatusBar = NotificationPanelViewTest.this.mKeyguardStatusBar;