Merge "Clock padding and motion adjustments" into pi-dev

This commit is contained in:
TreeHugger Robot
2018-04-20 00:43:53 +00:00
committed by Android (Google) Code Review
10 changed files with 146 additions and 131 deletions

View File

@@ -138,7 +138,7 @@
<!-- Vertical translation of the shelf during animation that happens after the <!-- Vertical translation of the shelf during animation that happens after the
notification panel collapses --> notification panel collapses -->
<dimen name="shelf_appear_translation">9dp</dimen> <dimen name="shelf_appear_translation">42dp</dimen>
<!-- The amount the content shifts upwards when transforming into the icon --> <!-- The amount the content shifts upwards when transforming into the icon -->
<dimen name="notification_icon_transform_content_shift">32dp</dimen> <dimen name="notification_icon_transform_content_shift">32dp</dimen>
@@ -497,9 +497,6 @@
device. --> device. -->
<dimen name="unlock_move_distance">75dp</dimen> <dimen name="unlock_move_distance">75dp</dimen>
<!-- Distance after which the scrim starts fading in when dragging down the quick settings -->
<dimen name="notification_scrim_wait_distance">100dp</dimen>
<!-- Move distance for the unlock hint animation on the lockscreen --> <!-- Move distance for the unlock hint animation on the lockscreen -->
<dimen name="hint_move_distance">75dp</dimen> <dimen name="hint_move_distance">75dp</dimen>

View File

@@ -24,6 +24,8 @@
<item type="id" name="scale_y_animator_tag"/> <item type="id" name="scale_y_animator_tag"/>
<item type="id" name="top_inset_animator_tag"/> <item type="id" name="top_inset_animator_tag"/>
<item type="id" name="height_animator_tag"/> <item type="id" name="height_animator_tag"/>
<item type="id" name="x_animator_tag"/>
<item type="id" name="y_animator_tag"/>
<item type="id" name="shadow_alpha_animator_tag"/> <item type="id" name="shadow_alpha_animator_tag"/>
<item type="id" name="translation_x_animator_end_value_tag"/> <item type="id" name="translation_x_animator_end_value_tag"/>
<item type="id" name="translation_y_animator_end_value_tag"/> <item type="id" name="translation_y_animator_end_value_tag"/>
@@ -34,6 +36,8 @@
<item type="id" name="top_inset_animator_end_value_tag"/> <item type="id" name="top_inset_animator_end_value_tag"/>
<item type="id" name="height_animator_end_value_tag"/> <item type="id" name="height_animator_end_value_tag"/>
<item type="id" name="shadow_alpha_animator_end_value_tag"/> <item type="id" name="shadow_alpha_animator_end_value_tag"/>
<item type="id" name="x_animator_tag_end_value"/>
<item type="id" name="y_animator_tag_end_value"/>
<item type="id" name="translation_x_animator_start_value_tag"/> <item type="id" name="translation_x_animator_start_value_tag"/>
<item type="id" name="translation_y_animator_start_value_tag"/> <item type="id" name="translation_y_animator_start_value_tag"/>
<item type="id" name="translation_z_animator_start_value_tag"/> <item type="id" name="translation_z_animator_start_value_tag"/>
@@ -43,6 +47,8 @@
<item type="id" name="top_inset_animator_start_value_tag"/> <item type="id" name="top_inset_animator_start_value_tag"/>
<item type="id" name="height_animator_start_value_tag"/> <item type="id" name="height_animator_start_value_tag"/>
<item type="id" name="shadow_alpha_animator_start_value_tag"/> <item type="id" name="shadow_alpha_animator_start_value_tag"/>
<item type="id" name="x_animator_tag_start_value"/>
<item type="id" name="y_animator_tag_start_value"/>
<item type="id" name="doze_saved_filter_tag"/> <item type="id" name="doze_saved_filter_tag"/>
<item type="id" name="qs_icon_tag"/> <item type="id" name="qs_icon_tag"/>
<item type="id" name="qs_slash_tag"/> <item type="id" name="qs_slash_tag"/>

View File

@@ -58,7 +58,7 @@ public class NotificationShelf extends ActivatableNotificationView implements
= SystemProperties.getBoolean("debug.icon_scroll_animations", true); = SystemProperties.getBoolean("debug.icon_scroll_animations", true);
private static final int TAG_CONTINUOUS_CLIPPING = R.id.continuous_clipping_tag; private static final int TAG_CONTINUOUS_CLIPPING = R.id.continuous_clipping_tag;
private static final String TAG = "NotificationShelf"; private static final String TAG = "NotificationShelf";
private static final long SHELF_IN_TRANSLATION_DURATION = 220; private static final long SHELF_IN_TRANSLATION_DURATION = 200;
private ViewInvertHelper mViewInvertHelper; private ViewInvertHelper mViewInvertHelper;
private boolean mDark; private boolean mDark;
@@ -157,14 +157,18 @@ public class NotificationShelf extends ActivatableNotificationView implements
public void fadeInTranslating() { public void fadeInTranslating() {
float translation = mShelfIcons.getTranslationY(); float translation = mShelfIcons.getTranslationY();
mShelfIcons.setTranslationY(translation + mShelfAppearTranslation); mShelfIcons.setTranslationY(translation - mShelfAppearTranslation);
mShelfIcons.setAlpha(0); mShelfIcons.setAlpha(0);
mShelfIcons.animate() mShelfIcons.animate()
.alpha(1) .setInterpolator(Interpolators.DECELERATE_QUINT)
.setInterpolator(Interpolators.LINEAR_OUT_SLOW_IN)
.translationY(translation) .translationY(translation)
.setDuration(SHELF_IN_TRANSLATION_DURATION) .setDuration(SHELF_IN_TRANSLATION_DURATION)
.start(); .start();
mShelfIcons.animate()
.alpha(1)
.setInterpolator(Interpolators.LINEAR)
.setDuration(SHELF_IN_TRANSLATION_DURATION)
.start();
} }
@Override @Override

View File

@@ -20,25 +20,30 @@ import android.util.FloatProperty;
import android.util.Property; import android.util.Property;
import android.view.View; import android.view.View;
import com.android.systemui.statusbar.stack.AnimationProperties; import com.android.systemui.R;
import java.util.function.BiConsumer; import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function; import java.util.function.Function;
/** /**
* An animatable property of a view. Used with {@link PropertyAnimator} * An animatable property of a view. Used with {@link PropertyAnimator}
*/ */
public interface AnimatableProperty { public abstract class AnimatableProperty {
int getAnimationStartTag();
int getAnimationEndTag(); public static final AnimatableProperty X = AnimatableProperty.from(View.X,
R.id.x_animator_tag, R.id.x_animator_tag_start_value, R.id.x_animator_tag_end_value);
public static final AnimatableProperty Y = AnimatableProperty.from(View.Y,
R.id.y_animator_tag, R.id.y_animator_tag_start_value, R.id.y_animator_tag_end_value);
int getAnimatorTag(); public abstract int getAnimationStartTag();
Property getProperty(); public abstract int getAnimationEndTag();
static <T extends View> AnimatableProperty from(String name, BiConsumer<T, Float> setter, public abstract int getAnimatorTag();
public abstract Property getProperty();
public static <T extends View> AnimatableProperty from(String name, BiConsumer<T, Float> setter,
Function<T, Float> getter, int animatorTag, int startValueTag, int endValueTag) { Function<T, Float> getter, int animatorTag, int startValueTag, int endValueTag) {
Property<T, Float> property = new FloatProperty<T>(name) { Property<T, Float> property = new FloatProperty<T>(name) {
@@ -74,4 +79,29 @@ public interface AnimatableProperty {
} }
}; };
} }
public static <T extends View> AnimatableProperty from(Property<T, Float> property,
int animatorTag, int startValueTag, int endValueTag) {
return new AnimatableProperty() {
@Override
public int getAnimationStartTag() {
return startValueTag;
}
@Override
public int getAnimationEndTag() {
return endValueTag;
}
@Override
public int getAnimatorTag() {
return animatorTag;
}
@Override
public Property getProperty() {
return property;
}
};
}
} }

View File

@@ -24,6 +24,7 @@ import android.util.Property;
import android.view.View; import android.view.View;
import android.view.animation.Interpolator; import android.view.animation.Interpolator;
import com.android.keyguard.KeyguardStatusView;
import com.android.systemui.Interpolators; import com.android.systemui.Interpolators;
import com.android.systemui.statusbar.stack.AnimationFilter; import com.android.systemui.statusbar.stack.AnimationFilter;
import com.android.systemui.statusbar.stack.AnimationProperties; import com.android.systemui.statusbar.stack.AnimationProperties;
@@ -115,4 +116,7 @@ public class PropertyAnimator {
view.setTag(animationEndTag, newEndValue); view.setTag(animationEndTag, newEndValue);
} }
public static <T extends View> boolean isAnimating(T view, AnimatableProperty property) {
return view.getTag(property.getAnimatorTag()) != null;
}
} }

View File

@@ -20,8 +20,8 @@ import static com.android.systemui.statusbar.notification.NotificationUtils.inte
import android.content.res.Resources; import android.content.res.Resources;
import android.util.MathUtils; import android.util.MathUtils;
import com.android.keyguard.KeyguardStatusView;
import com.android.keyguard.KeyguardStatusView;
import com.android.systemui.Interpolators; import com.android.systemui.Interpolators;
import com.android.systemui.R; import com.android.systemui.R;
@@ -46,12 +46,6 @@ public class KeyguardClockPositionAlgorithm {
*/ */
private int mClockNotificationsMargin; private int mClockNotificationsMargin;
/**
* Current height of {@link NotificationPanelView}, considering how much the
* user collapsed it.
*/
private float mExpandedHeight;
/** /**
* Height of the parent view - display size in px. * Height of the parent view - display size in px.
*/ */
@@ -84,9 +78,9 @@ public class KeyguardClockPositionAlgorithm {
private int mContainerTopPadding; private int mContainerTopPadding;
/** /**
* @see NotificationPanelView#getMaxPanelHeight() * @see NotificationPanelView#getExpandedFraction()
*/ */
private float mMaxPanelHeight; private float mPanelExpansion;
/** /**
* Burn-in prevention x translation. * Burn-in prevention x translation.
@@ -140,13 +134,13 @@ public class KeyguardClockPositionAlgorithm {
} }
public void setup(int minTopMargin, int maxShadeBottom, int notificationStackHeight, public void setup(int minTopMargin, int maxShadeBottom, int notificationStackHeight,
float expandedHeight, float maxPanelHeight, int parentHeight, int keyguardStatusHeight, float panelExpansion, int parentHeight,
float dark, boolean secure, boolean pulsing, int bouncerTop) { int keyguardStatusHeight, float dark, boolean secure, boolean pulsing,
int bouncerTop) {
mMinTopMargin = minTopMargin + mContainerTopPadding; mMinTopMargin = minTopMargin + mContainerTopPadding;
mMaxShadeBottom = maxShadeBottom; mMaxShadeBottom = maxShadeBottom;
mNotificationStackHeight = notificationStackHeight; mNotificationStackHeight = notificationStackHeight;
mExpandedHeight = expandedHeight; mPanelExpansion = panelExpansion;
mMaxPanelHeight = maxPanelHeight;
mHeight = parentHeight; mHeight = parentHeight;
mKeyguardStatusHeight = keyguardStatusHeight; mKeyguardStatusHeight = keyguardStatusHeight;
mDarkAmount = dark; mDarkAmount = dark;
@@ -171,16 +165,12 @@ public class KeyguardClockPositionAlgorithm {
return mHeight / 2 - mKeyguardStatusHeight - mClockNotificationsMargin; return mHeight / 2 - mKeyguardStatusHeight - mClockNotificationsMargin;
} }
public int getExpandedClockBottom() {
return getExpandedClockPosition() + mKeyguardStatusHeight;
}
/** /**
* Vertically align the clock and the shade in the available space considering only * Vertically align the clock and the shade in the available space considering only
* a percentage of the clock height defined by {@code CLOCK_HEIGHT_WEIGHT}. * a percentage of the clock height defined by {@code CLOCK_HEIGHT_WEIGHT}.
* @return Clock Y in pixels. * @return Clock Y in pixels.
*/ */
private int getExpandedClockPosition() { public int getExpandedClockPosition() {
final int availableHeight = mMaxShadeBottom - mMinTopMargin; final int availableHeight = mMaxShadeBottom - mMinTopMargin;
final int containerCenter = mMinTopMargin + availableHeight / 2; final int containerCenter = mMinTopMargin + availableHeight / 2;
@@ -212,8 +202,7 @@ public class KeyguardClockPositionAlgorithm {
mMinTopMargin : -mKeyguardStatusHeight; mMinTopMargin : -mKeyguardStatusHeight;
// Move clock up while collapsing the shade // Move clock up while collapsing the shade
float shadeExpansion = mExpandedHeight / mMaxPanelHeight; float shadeExpansion = Interpolators.FAST_OUT_LINEAR_IN.getInterpolation(mPanelExpansion);
shadeExpansion = Interpolators.FAST_OUT_LINEAR_IN.getInterpolation(shadeExpansion);
final float clockY = MathUtils.lerp(clockYTarget, clockYRegular, shadeExpansion); final float clockY = MathUtils.lerp(clockYTarget, clockYRegular, shadeExpansion);
return (int) MathUtils.lerp(clockY, clockYDark, mDarkAmount); return (int) MathUtils.lerp(clockY, clockYDark, mDarkAmount);

View File

@@ -20,7 +20,6 @@ import static com.android.systemui.statusbar.notification.ActivityLaunchAnimator
import android.animation.Animator; import android.animation.Animator;
import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator; import android.animation.ObjectAnimator;
import android.animation.ValueAnimator; import android.animation.ValueAnimator;
import android.app.ActivityManager; import android.app.ActivityManager;
@@ -44,7 +43,6 @@ import android.view.MotionEvent;
import android.view.VelocityTracker; import android.view.VelocityTracker;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.WindowInsets; import android.view.WindowInsets;
import android.view.accessibility.AccessibilityManager; import android.view.accessibility.AccessibilityManager;
import android.widget.FrameLayout; import android.widget.FrameLayout;
@@ -69,8 +67,11 @@ import com.android.systemui.statusbar.NotificationData;
import com.android.systemui.statusbar.NotificationShelf; import com.android.systemui.statusbar.NotificationShelf;
import com.android.systemui.statusbar.StatusBarState; import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.notification.ActivityLaunchAnimator; import com.android.systemui.statusbar.notification.ActivityLaunchAnimator;
import com.android.systemui.statusbar.notification.AnimatableProperty;
import com.android.systemui.statusbar.notification.PropertyAnimator;
import com.android.systemui.statusbar.policy.KeyguardUserSwitcher; import com.android.systemui.statusbar.policy.KeyguardUserSwitcher;
import com.android.systemui.statusbar.policy.OnHeadsUpChangedListener; import com.android.systemui.statusbar.policy.OnHeadsUpChangedListener;
import com.android.systemui.statusbar.stack.AnimationProperties;
import com.android.systemui.statusbar.stack.NotificationStackScrollLayout; import com.android.systemui.statusbar.stack.NotificationStackScrollLayout;
import com.android.systemui.statusbar.stack.StackStateAnimator; import com.android.systemui.statusbar.stack.StackStateAnimator;
@@ -101,6 +102,8 @@ public class NotificationPanelView extends PanelView implements
public static final long DOZE_ANIMATION_DURATION = 700; public static final long DOZE_ANIMATION_DURATION = 700;
private static final AnimationProperties CLOCK_ANIMATION_PROPERTIES = new AnimationProperties()
.setDuration(StackStateAnimator.ANIMATION_DURATION_STANDARD);
private static final FloatProperty<NotificationPanelView> SET_DARK_AMOUNT_PROPERTY = private static final FloatProperty<NotificationPanelView> SET_DARK_AMOUNT_PROPERTY =
new FloatProperty<NotificationPanelView>("mDarkAmount") { new FloatProperty<NotificationPanelView>("mDarkAmount") {
@Override @Override
@@ -122,11 +125,10 @@ public class NotificationPanelView extends PanelView implements
private QS mQs; private QS mQs;
private FrameLayout mQsFrame; private FrameLayout mQsFrame;
private KeyguardStatusView mKeyguardStatusView; private KeyguardStatusView mKeyguardStatusView;
private View mReserveNotificationSpace;
private View mQsNavbarScrim; private View mQsNavbarScrim;
protected NotificationsQuickSettingsContainer mNotificationContainerParent; protected NotificationsQuickSettingsContainer mNotificationContainerParent;
protected NotificationStackScrollLayout mNotificationStackScroller; protected NotificationStackScrollLayout mNotificationStackScroller;
private boolean mAnimateNextTopPaddingChange; private boolean mAnimateNextPositionUpdate;
private int mTrackingPointer; private int mTrackingPointer;
private VelocityTracker mQsVelocityTracker; private VelocityTracker mQsVelocityTracker;
@@ -173,9 +175,6 @@ public class NotificationPanelView extends PanelView implements
private int mUnlockMoveDistance; private int mUnlockMoveDistance;
private float mEmptyDragAmount; private float mEmptyDragAmount;
private Animator mClockAnimator;
private int mClockAnimationTargetX = Integer.MIN_VALUE;
private int mClockAnimationTargetY = Integer.MIN_VALUE;
private KeyguardClockPositionAlgorithm mClockPositionAlgorithm = private KeyguardClockPositionAlgorithm mClockPositionAlgorithm =
new KeyguardClockPositionAlgorithm(); new KeyguardClockPositionAlgorithm();
private KeyguardClockPositionAlgorithm.Result mClockPositionResult = private KeyguardClockPositionAlgorithm.Result mClockPositionResult =
@@ -183,7 +182,6 @@ public class NotificationPanelView extends PanelView implements
private boolean mIsExpanding; private boolean mIsExpanding;
private boolean mBlockTouches; private boolean mBlockTouches;
private int mNotificationScrimWaitDistance;
// Used for two finger gesture as well as accessibility shortcut to QS. // Used for two finger gesture as well as accessibility shortcut to QS.
private boolean mQsExpandImmediate; private boolean mQsExpandImmediate;
private boolean mTwoFingerQsExpandPossible; private boolean mTwoFingerQsExpandPossible;
@@ -310,8 +308,6 @@ public class NotificationPanelView extends PanelView implements
getResources().getDimensionPixelSize(R.dimen.header_notifications_collide_distance); getResources().getDimensionPixelSize(R.dimen.header_notifications_collide_distance);
mUnlockMoveDistance = getResources().getDimensionPixelOffset(R.dimen.unlock_move_distance); mUnlockMoveDistance = getResources().getDimensionPixelOffset(R.dimen.unlock_move_distance);
mClockPositionAlgorithm.loadDimens(getResources()); mClockPositionAlgorithm.loadDimens(getResources());
mNotificationScrimWaitDistance =
getResources().getDimensionPixelSize(R.dimen.notification_scrim_wait_distance);
mQsFalsingThreshold = getResources().getDimensionPixelSize( mQsFalsingThreshold = getResources().getDimensionPixelSize(
R.dimen.qs_falsing_threshold); R.dimen.qs_falsing_threshold);
mPositionMinSideMargin = getResources().getDimensionPixelSize( mPositionMinSideMargin = getResources().getDimensionPixelSize(
@@ -461,19 +457,19 @@ public class NotificationPanelView extends PanelView implements
*/ */
private void positionClockAndNotifications() { private void positionClockAndNotifications() {
boolean animate = mNotificationStackScroller.isAddOrRemoveAnimationPending(); boolean animate = mNotificationStackScroller.isAddOrRemoveAnimationPending();
boolean animateClock = animate || mAnimateNextPositionUpdate;
int stackScrollerPadding; int stackScrollerPadding;
if (mStatusBarState != StatusBarState.KEYGUARD) { if (mStatusBarState != StatusBarState.KEYGUARD) {
stackScrollerPadding = (mQs != null ? mQs.getHeader().getHeight() : 0) + mQsPeekHeight stackScrollerPadding = (mQs != null ? mQs.getHeader().getHeight() : 0) + mQsPeekHeight
+ mQsNotificationTopPadding; + mQsNotificationTopPadding;
} else { } else {
final int totalHeight = getHeight(); int totalHeight = getHeight();
final int bottomPadding = Math.max(mIndicationBottomPadding, mAmbientIndicationBottomPadding); int bottomPadding = Math.max(mIndicationBottomPadding, mAmbientIndicationBottomPadding);
mClockPositionAlgorithm.setup( mClockPositionAlgorithm.setup(
mStatusBarMinHeight, mStatusBarMinHeight,
totalHeight - bottomPadding, totalHeight - bottomPadding,
calculatePanelHeightShade() - mNotificationStackScroller.getTopPadding(), mNotificationStackScroller.getIntrinsicContentHeight(),
getExpandedHeight(), getExpandedFraction(),
getMaxPanelHeight(),
totalHeight, totalHeight,
mKeyguardStatusView.getHeight(), mKeyguardStatusView.getHeight(),
mDarkAmount, mDarkAmount,
@@ -481,12 +477,10 @@ public class NotificationPanelView extends PanelView implements
mPulsing, mPulsing,
mBouncerTop); mBouncerTop);
mClockPositionAlgorithm.run(mClockPositionResult); mClockPositionAlgorithm.run(mClockPositionResult);
if (animate || mClockAnimator != null) { PropertyAnimator.setProperty(mKeyguardStatusView, AnimatableProperty.X,
startClockAnimation(mClockPositionResult.clockX, mClockPositionResult.clockY); mClockPositionResult.clockX, CLOCK_ANIMATION_PROPERTIES, animateClock);
} else { PropertyAnimator.setProperty(mKeyguardStatusView, AnimatableProperty.Y,
mKeyguardStatusView.setX(mClockPositionResult.clockX); mClockPositionResult.clockY, CLOCK_ANIMATION_PROPERTIES, animateClock);
mKeyguardStatusView.setY(mClockPositionResult.clockY);
}
updateClock(); updateClock();
stackScrollerPadding = mClockPositionResult.stackScrollerPadding; stackScrollerPadding = mClockPositionResult.stackScrollerPadding;
} }
@@ -497,6 +491,7 @@ public class NotificationPanelView extends PanelView implements
mStackScrollerMeasuringPass++; mStackScrollerMeasuringPass++;
requestScrollerTopPaddingUpdate(animate); requestScrollerTopPaddingUpdate(animate);
mStackScrollerMeasuringPass = 0; mStackScrollerMeasuringPass = 0;
mAnimateNextPositionUpdate = false;
} }
/** /**
@@ -558,42 +553,6 @@ public class NotificationPanelView extends PanelView implements
positionClockAndNotifications(); positionClockAndNotifications();
} }
private void startClockAnimation(int x, int y) {
if (mClockAnimationTargetX == x && mClockAnimationTargetY == y) {
return;
}
mClockAnimationTargetX = x;
mClockAnimationTargetY = y;
getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
getViewTreeObserver().removeOnPreDrawListener(this);
if (mClockAnimator != null) {
mClockAnimator.removeAllListeners();
mClockAnimator.cancel();
}
AnimatorSet set = new AnimatorSet();
set.play(ObjectAnimator.ofFloat(
mKeyguardStatusView, View.Y, mClockAnimationTargetY))
.with(ObjectAnimator.ofFloat(
mKeyguardStatusView, View.X, mClockAnimationTargetX));
mClockAnimator = set;
mClockAnimator.setInterpolator(Interpolators.FAST_OUT_SLOW_IN);
mClockAnimator.setDuration(StackStateAnimator.ANIMATION_DURATION_STANDARD);
mClockAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
mClockAnimator = null;
mClockAnimationTargetX = Integer.MIN_VALUE;
mClockAnimationTargetY = Integer.MIN_VALUE;
}
});
mClockAnimator.start();
return true;
}
});
}
private void updateClock() { private void updateClock() {
if (!mKeyguardStatusViewAnimating) { if (!mKeyguardStatusViewAnimating) {
mKeyguardStatusView.setAlpha(mClockPositionResult.clockAlpha); mKeyguardStatusView.setAlpha(mClockPositionResult.clockAlpha);
@@ -601,9 +560,9 @@ public class NotificationPanelView extends PanelView implements
} }
public void animateToFullShade(long delay) { public void animateToFullShade(long delay) {
mAnimateNextTopPaddingChange = true;
mNotificationStackScroller.goToFullShade(delay); mNotificationStackScroller.goToFullShade(delay);
requestLayout(); requestLayout();
mAnimateNextPositionUpdate = true;
} }
public void setQsExpansionEnabled(boolean qsExpansionEnabled) { public void setQsExpansionEnabled(boolean qsExpansionEnabled) {
@@ -1411,10 +1370,8 @@ public class NotificationPanelView extends PanelView implements
protected void requestScrollerTopPaddingUpdate(boolean animate) { protected void requestScrollerTopPaddingUpdate(boolean animate) {
mNotificationStackScroller.updateTopPadding(calculateQsTopPadding(), mNotificationStackScroller.updateTopPadding(calculateQsTopPadding(),
mAnimateNextTopPaddingChange || animate, animate, mKeyguardShowing
mKeyguardShowing
&& (mQsExpandImmediate || mIsExpanding && mQsExpandedWhenExpandingStarted)); && (mQsExpandImmediate || mIsExpanding && mQsExpandedWhenExpandingStarted));
mAnimateNextTopPaddingChange = false;
} }
private void trackMovement(MotionEvent event) { private void trackMovement(MotionEvent event) {
@@ -1535,7 +1492,7 @@ public class NotificationPanelView extends PanelView implements
if (mQsExpandImmediate || mQsExpanded || mIsExpanding && mQsExpandedWhenExpandingStarted) { if (mQsExpandImmediate || mQsExpanded || mIsExpanding && mQsExpandedWhenExpandingStarted) {
maxHeight = calculatePanelHeightQsExpanded(); maxHeight = calculatePanelHeightQsExpanded();
} else { } else {
maxHeight = Math.max(calculatePanelHeightShade(), calculatePanelHeightShadeExpanded()); maxHeight = calculatePanelHeightShade();
} }
maxHeight = Math.max(maxHeight, min); maxHeight = Math.max(maxHeight, min);
return maxHeight; return maxHeight;
@@ -1606,14 +1563,15 @@ public class NotificationPanelView extends PanelView implements
int emptyBottomMargin = mNotificationStackScroller.getEmptyBottomMargin(); int emptyBottomMargin = mNotificationStackScroller.getEmptyBottomMargin();
int maxHeight = mNotificationStackScroller.getHeight() - emptyBottomMargin; int maxHeight = mNotificationStackScroller.getHeight() - emptyBottomMargin;
maxHeight += mNotificationStackScroller.getTopPaddingOverflow(); maxHeight += mNotificationStackScroller.getTopPaddingOverflow();
return maxHeight;
}
private int calculatePanelHeightShadeExpanded() { if (mStatusBarState == StatusBarState.KEYGUARD) {
return mNotificationStackScroller.getHeight() int minKeyguardPanelBottom = mClockPositionAlgorithm.getExpandedClockPosition()
- mNotificationStackScroller.getEmptyBottomMargin() + mKeyguardStatusView.getHeight()
- mNotificationStackScroller.getTopPadding() + mNotificationStackScroller.getIntrinsicContentHeight();
+ mClockPositionAlgorithm.getExpandedClockBottom(); return Math.max(maxHeight, minKeyguardPanelBottom);
} else {
return maxHeight;
}
} }
private int calculatePanelHeightQsExpanded() { private int calculatePanelHeightQsExpanded() {
@@ -1652,7 +1610,8 @@ public class NotificationPanelView extends PanelView implements
private void updateNotificationTranslucency() { private void updateNotificationTranslucency() {
float alpha = 1f; float alpha = 1f;
if (mClosingWithAlphaFadeOut && !mExpandingFromHeadsUp && !mHeadsUpManager.hasPinnedHeadsUp()) { if (mClosingWithAlphaFadeOut && !mExpandingFromHeadsUp &&
!mHeadsUpManager.hasPinnedHeadsUp()) {
alpha = getFadeoutAlpha(); alpha = getFadeoutAlpha();
} }
mNotificationStackScroller.setAlpha(alpha); mNotificationStackScroller.setAlpha(alpha);
@@ -1907,13 +1866,16 @@ public class NotificationPanelView extends PanelView implements
if (view == null && mQsExpanded) { if (view == null && mQsExpanded) {
return; return;
} }
if (needsAnimation) {
mAnimateNextPositionUpdate = true;
}
ExpandableView firstChildNotGone = mNotificationStackScroller.getFirstChildNotGone(); ExpandableView firstChildNotGone = mNotificationStackScroller.getFirstChildNotGone();
ExpandableNotificationRow firstRow = firstChildNotGone instanceof ExpandableNotificationRow ExpandableNotificationRow firstRow = firstChildNotGone instanceof ExpandableNotificationRow
? (ExpandableNotificationRow) firstChildNotGone ? (ExpandableNotificationRow) firstChildNotGone
: null; : null;
if (firstRow != null if (firstRow != null
&& (view == firstRow || (firstRow.getNotificationParent() == firstRow))) { && (view == firstRow || (firstRow.getNotificationParent() == firstRow))) {
requestScrollerTopPaddingUpdate(false); requestScrollerTopPaddingUpdate(false /* animate */);
} }
requestPanelHeightUpdate(); requestPanelHeightUpdate();
} }
@@ -2337,15 +2299,15 @@ public class NotificationPanelView extends PanelView implements
p.setColor(Color.YELLOW); p.setColor(Color.YELLOW);
canvas.drawLine(0, calculatePanelHeightShade(), getWidth(), canvas.drawLine(0, calculatePanelHeightShade(), getWidth(),
calculatePanelHeightShade(), p); calculatePanelHeightShade(), p);
p.setColor(Color.GRAY);
canvas.drawLine(0, calculatePanelHeightShadeExpanded(), getWidth(),
calculatePanelHeightShadeExpanded(), p);
p.setColor(Color.MAGENTA); p.setColor(Color.MAGENTA);
canvas.drawLine(0, calculateQsTopPadding(), getWidth(), canvas.drawLine(0, calculateQsTopPadding(), getWidth(),
calculateQsTopPadding(), p); calculateQsTopPadding(), p);
p.setColor(Color.CYAN); p.setColor(Color.CYAN);
canvas.drawLine(0, mNotificationStackScroller.getTopPadding(), getWidth(), canvas.drawLine(0, mClockPositionResult.stackScrollerPadding, getWidth(),
mNotificationStackScroller.getTopPadding(), p); mNotificationStackScroller.getTopPadding(), p);
p.setColor(Color.GRAY);
canvas.drawLine(0, mClockPositionResult.clockY, getWidth(),
mClockPositionResult.clockY, p);
} }
} }

View File

@@ -828,7 +828,7 @@ public abstract class PanelView extends FrameLayout {
} }
@Override @Override
protected void onLayout (boolean changed, int left, int top, int right, int bottom) { protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom); super.onLayout(changed, left, top, right, bottom);
mStatusBar.onPanelLaidOut(); mStatusBar.onPanelLaidOut();
requestPanelHeightUpdate(); requestPanelHeightUpdate();
@@ -1088,13 +1088,10 @@ public abstract class PanelView extends FrameLayout {
} }
cancelPeek(); cancelPeek();
notifyExpandingStarted(); notifyExpandingStarted();
startUnlockHintAnimationPhase1(new Runnable() { startUnlockHintAnimationPhase1(() -> {
@Override notifyExpandingFinished();
public void run() { onUnlockHintFinished();
notifyExpandingFinished(); mHintAnimationRunning = false;
onUnlockHintFinished();
mHintAnimationRunning = false;
}
}); });
onUnlockHintStarted(); onUnlockHintStarted();
mHintAnimationRunning = true; mHintAnimationRunning = true;

View File

@@ -164,6 +164,7 @@ public class NotificationStackScrollLayout extends ViewGroup
private Paint mDebugPaint; private Paint mDebugPaint;
private int mContentHeight; private int mContentHeight;
private int mIntrinsicContentHeight;
private int mCollapsedSize; private int mCollapsedSize;
private int mPaddingBetweenElements; private int mPaddingBetweenElements;
private int mIncreasedPaddingBetweenElements; private int mIncreasedPaddingBetweenElements;
@@ -538,15 +539,16 @@ public class NotificationStackScrollLayout extends ViewGroup
canvas.drawRect(darkLeft, darkTop, darkRight, darkBottom, mBackgroundPaint); canvas.drawRect(darkLeft, darkTop, darkRight, darkBottom, mBackgroundPaint);
} }
} else { } else {
float animProgress = Interpolators.FAST_OUT_SLOW_IN float inverseDark = 1 - mDarkAmount;
.getInterpolation(1f - mDarkAmount); float yProgress = Interpolators.FAST_OUT_SLOW_IN.getInterpolation(inverseDark);
float sidePaddingsProgress = Interpolators.FAST_OUT_SLOW_IN float xProgress = Interpolators.FAST_OUT_SLOW_IN
.getInterpolation((1f - mDarkAmount) * 2); .getInterpolation(inverseDark * 2f);
mBackgroundAnimationRect.set( mBackgroundAnimationRect.set(
(int) MathUtils.lerp(darkLeft, lockScreenLeft, sidePaddingsProgress), (int) MathUtils.lerp(darkLeft, lockScreenLeft, xProgress),
(int) MathUtils.lerp(darkTop, lockScreenTop, animProgress), (int) MathUtils.lerp(darkTop, lockScreenTop, yProgress),
(int) MathUtils.lerp(darkRight, lockScreenRight, sidePaddingsProgress), (int) MathUtils.lerp(darkRight, lockScreenRight, xProgress),
(int) MathUtils.lerp(darkBottom, lockScreenBottom, animProgress)); (int) MathUtils.lerp(darkBottom, lockScreenBottom, yProgress));
if (!mAmbientState.isDark() || mFirstVisibleBackgroundChild != null) { if (!mAmbientState.isDark() || mFirstVisibleBackgroundChild != null) {
canvas.drawRoundRect(mBackgroundAnimationRect.left, mBackgroundAnimationRect.top, canvas.drawRoundRect(mBackgroundAnimationRect.left, mBackgroundAnimationRect.top,
mBackgroundAnimationRect.right, mBackgroundAnimationRect.bottom, mBackgroundAnimationRect.right, mBackgroundAnimationRect.bottom,
@@ -628,8 +630,12 @@ public class NotificationStackScrollLayout extends ViewGroup
} }
private void notifyHeightChangeListener(ExpandableView view) { private void notifyHeightChangeListener(ExpandableView view) {
notifyHeightChangeListener(view, false /* needsAnimation */);
}
private void notifyHeightChangeListener(ExpandableView view, boolean needsAnimation) {
if (mOnHeightChangedListener != null) { if (mOnHeightChangedListener != null) {
mOnHeightChangedListener.onHeightChanged(view, false /* needsAnimation */); mOnHeightChangedListener.onHeightChanged(view, needsAnimation);
} }
} }
@@ -850,7 +856,7 @@ public class NotificationStackScrollLayout extends ViewGroup
mNeedsAnimation = true; mNeedsAnimation = true;
} }
requestChildrenUpdate(); requestChildrenUpdate();
notifyHeightChangeListener(null); notifyHeightChangeListener(null, animate);
} }
} }
@@ -915,6 +921,13 @@ public class NotificationStackScrollLayout extends ViewGroup
updateClipping(); updateClipping();
} }
/**
* Return the height of the content ignoring the footer.
*/
public int getIntrinsicContentHeight() {
return mIntrinsicContentHeight;
}
public void updateClipping() { public void updateClipping() {
boolean animatingClipping = mDarkAmount > 0 && mDarkAmount < 1; boolean animatingClipping = mDarkAmount > 0 && mDarkAmount < 1;
boolean clipped = mRequestedClipBounds != null && !mInHeadsUpPinnedMode boolean clipped = mRequestedClipBounds != null && !mInHeadsUpPinnedMode
@@ -2130,8 +2143,9 @@ public class NotificationStackScrollLayout extends ViewGroup
for (int i = 0; i < getChildCount(); i++) { for (int i = 0; i < getChildCount(); i++) {
ExpandableView expandableView = (ExpandableView) getChildAt(i); ExpandableView expandableView = (ExpandableView) getChildAt(i);
boolean footerViewOnLockScreen = expandableView == mFooterView && onKeyguard();
if (expandableView.getVisibility() != View.GONE if (expandableView.getVisibility() != View.GONE
&& !expandableView.hasNoContentHeight()) { && !expandableView.hasNoContentHeight() && !footerViewOnLockScreen) {
boolean limitReached = maxDisplayedNotifications != -1 boolean limitReached = maxDisplayedNotifications != -1
&& numShownItems >= maxDisplayedNotifications; && numShownItems >= maxDisplayedNotifications;
boolean notificationOnAmbientThatIsNotPulsing = mAmbientState.isFullyDark() boolean notificationOnAmbientThatIsNotPulsing = mAmbientState.isFullyDark()
@@ -2179,6 +2193,7 @@ public class NotificationStackScrollLayout extends ViewGroup
} }
} }
} }
mIntrinsicContentHeight = height;
mContentHeight = height + mTopPadding + mBottomMargin; mContentHeight = height + mTopPadding + mBottomMargin;
updateScrollability(); updateScrollability();
clampScrollPosition(); clampScrollPosition();
@@ -3656,7 +3671,7 @@ public class NotificationStackScrollLayout extends ViewGroup
updateContentHeight(); updateContentHeight();
updateScrollPositionOnExpandInBottom(view); updateScrollPositionOnExpandInBottom(view);
clampScrollPosition(); clampScrollPosition();
notifyHeightChangeListener(view); notifyHeightChangeListener(view, needsAnimation);
ExpandableNotificationRow row = view instanceof ExpandableNotificationRow ExpandableNotificationRow row = view instanceof ExpandableNotificationRow
? (ExpandableNotificationRow) view ? (ExpandableNotificationRow) view
: null; : null;
@@ -3970,6 +3985,7 @@ public class NotificationStackScrollLayout extends ViewGroup
mShelf.fadeInTranslating(); mShelf.fadeInTranslating();
} }
} }
updateAlgorithmHeightAndPadding();
updateBackgroundDimming(); updateBackgroundDimming();
updateAntiBurnInTranslation(); updateAntiBurnInTranslation();
requestChildrenUpdate(); requestChildrenUpdate();

View File

@@ -39,6 +39,7 @@ import com.android.systemui.statusbar.stack.AnimationFilter;
import com.android.systemui.statusbar.stack.AnimationProperties; import com.android.systemui.statusbar.stack.AnimationProperties;
import com.android.systemui.statusbar.stack.ViewState; import com.android.systemui.statusbar.stack.ViewState;
import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@@ -227,4 +228,13 @@ public class PropertyAnimatorTest extends SysuiTestCase {
assertNotNull(animator); assertNotNull(animator);
assertTrue(animator.getListeners().contains(mFinishListener)); assertTrue(animator.getListeners().contains(mFinishListener));
} }
@Test
public void testIsAnimating() {
mAnimationFilter.reset();
mAnimationFilter.animate(mProperty.getProperty());
assertFalse(PropertyAnimator.isAnimating(mView, mProperty));
PropertyAnimator.startAnimation(mView, mProperty, 200f, mAnimationProperties);
assertTrue(PropertyAnimator.isAnimating(mView, mProperty));
}
} }