Merge "Shelf alignment and animation fixes" into pi-dev

This commit is contained in:
TreeHugger Robot
2018-04-11 02:01:27 +00:00
committed by Android (Google) Code Review
6 changed files with 63 additions and 33 deletions

View File

@@ -136,6 +136,10 @@
views where the distance can't be measured --> views where the distance can't be measured -->
<dimen name="notification_icon_appear_padding">15dp</dimen> <dimen name="notification_icon_appear_padding">15dp</dimen>
<!-- Vertical translation of the shelf during animation that happens after the
notification panel collapses -->
<dimen name="shelf_appear_translation">9dp</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>

View File

@@ -17,7 +17,6 @@
package com.android.systemui.statusbar; package com.android.systemui.statusbar;
import static com.android.systemui.statusbar.phone.NotificationIconContainer.IconState.NO_VALUE; import static com.android.systemui.statusbar.phone.NotificationIconContainer.IconState.NO_VALUE;
import static com.android.systemui.statusbar.phone.NotificationIconContainer.OVERFLOW_EARLY_AMOUNT;
import android.content.Context; import android.content.Context;
import android.content.res.Configuration; import android.content.res.Configuration;
@@ -26,6 +25,7 @@ import android.graphics.Rect;
import android.os.SystemProperties; import android.os.SystemProperties;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.util.Log; import android.util.Log;
import android.util.MathUtils;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.ViewTreeObserver; import android.view.ViewTreeObserver;
@@ -58,6 +58,8 @@ 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 ViewInvertHelper mViewInvertHelper; private ViewInvertHelper mViewInvertHelper;
private boolean mDark; private boolean mDark;
private NotificationIconContainer mShelfIcons; private NotificationIconContainer mShelfIcons;
@@ -65,6 +67,7 @@ public class NotificationShelf extends ActivatableNotificationView implements
private int[] mTmp = new int[2]; private int[] mTmp = new int[2];
private boolean mHideBackground; private boolean mHideBackground;
private int mIconAppearTopPadding; private int mIconAppearTopPadding;
private int mShelfAppearTranslation;
private int mStatusBarHeight; private int mStatusBarHeight;
private int mStatusBarPaddingStart; private int mStatusBarPaddingStart;
private AmbientState mAmbientState; private AmbientState mAmbientState;
@@ -120,6 +123,7 @@ public class NotificationShelf extends ActivatableNotificationView implements
mStatusBarHeight = res.getDimensionPixelOffset(R.dimen.status_bar_height); mStatusBarHeight = res.getDimensionPixelOffset(R.dimen.status_bar_height);
mStatusBarPaddingStart = res.getDimensionPixelOffset(R.dimen.status_bar_padding_start); mStatusBarPaddingStart = res.getDimensionPixelOffset(R.dimen.status_bar_padding_start);
mPaddingBetweenElements = res.getDimensionPixelSize(R.dimen.notification_divider_height); mPaddingBetweenElements = res.getDimensionPixelSize(R.dimen.notification_divider_height);
mShelfAppearTranslation = res.getDimensionPixelSize(R.dimen.shelf_appear_translation);
ViewGroup.LayoutParams layoutParams = getLayoutParams(); ViewGroup.LayoutParams layoutParams = getLayoutParams();
layoutParams.height = res.getDimensionPixelOffset(R.dimen.notification_shelf_height); layoutParams.height = res.getDimensionPixelOffset(R.dimen.notification_shelf_height);
@@ -151,6 +155,18 @@ public class NotificationShelf extends ActivatableNotificationView implements
updateInteractiveness(); updateInteractiveness();
} }
public void fadeInTranslating() {
float translation = mShelfIcons.getTranslationY();
mShelfIcons.setTranslationY(translation + mShelfAppearTranslation);
mShelfIcons.setAlpha(0);
mShelfIcons.animate()
.alpha(1)
.setInterpolator(Interpolators.LINEAR_OUT_SLOW_IN)
.translationY(translation)
.setDuration(SHELF_IN_TRANSLATION_DURATION)
.start();
}
@Override @Override
protected View getContentView() { protected View getContentView() {
return mShelfIcons; return mShelfIcons;
@@ -175,12 +191,14 @@ public class NotificationShelf extends ActivatableNotificationView implements
float viewEnd = lastViewState.yTranslation + lastViewState.height; float viewEnd = lastViewState.yTranslation + lastViewState.height;
mShelfState.copyFrom(lastViewState); mShelfState.copyFrom(lastViewState);
mShelfState.height = getIntrinsicHeight(); mShelfState.height = getIntrinsicHeight();
mShelfState.yTranslation = Math.max(Math.min(viewEnd, maxShelfEnd) - mShelfState.height,
float awakenTranslation = Math.max(Math.min(viewEnd, maxShelfEnd) - mShelfState.height,
getFullyClosedTranslation()); getFullyClosedTranslation());
float darkTranslation = mAmbientState.getDarkTopPadding();
float yRatio = mAmbientState.hasPulsingNotifications() ?
0 : mAmbientState.getDarkAmount();
mShelfState.yTranslation = MathUtils.lerp(awakenTranslation, darkTranslation, yRatio);
mShelfState.zTranslation = ambientState.getBaseZHeight(); mShelfState.zTranslation = ambientState.getBaseZHeight();
if (mAmbientState.isDark() && !mAmbientState.hasPulsingNotifications()) {
mShelfState.yTranslation = mAmbientState.getDarkTopPadding();
}
float openedAmount = (mShelfState.yTranslation - getFullyClosedTranslation()) float openedAmount = (mShelfState.yTranslation - getFullyClosedTranslation())
/ (getIntrinsicHeight() * 2); / (getIntrinsicHeight() * 2);
openedAmount = Math.min(1.0f, openedAmount); openedAmount = Math.min(1.0f, openedAmount);
@@ -555,7 +573,9 @@ public class NotificationShelf extends ActivatableNotificationView implements
iconState.translateContent = false; iconState.translateContent = false;
} }
float transitionAmount; float transitionAmount;
if (isLastChild || !USE_ANIMATIONS_WHEN_OPENING || iconState.useFullTransitionAmount if (mAmbientState.getDarkAmount() > 0 && !row.isInShelf()) {
transitionAmount = mAmbientState.isFullyDark() ? 1 : 0;
} else if (isLastChild || !USE_ANIMATIONS_WHEN_OPENING || iconState.useFullTransitionAmount
|| iconState.useLinearTransitionAmount) { || iconState.useLinearTransitionAmount) {
transitionAmount = iconTransitionAmount; transitionAmount = iconTransitionAmount;
} else { } else {

View File

@@ -70,8 +70,8 @@ public class AmbientState {
private int mIntrinsicPadding; private int mIntrinsicPadding;
private int mExpandAnimationTopChange; private int mExpandAnimationTopChange;
private ExpandableNotificationRow mExpandingNotification; private ExpandableNotificationRow mExpandingNotification;
private boolean mFullyDark;
private int mDarkTopPadding; private int mDarkTopPadding;
private float mDarkAmount;
public AmbientState(Context context) { public AmbientState(Context context) {
reload(context); reload(context);
@@ -149,6 +149,16 @@ public class AmbientState {
mDark = dark; mDark = dark;
} }
/** Dark ratio of the status bar **/
public void setDarkAmount(float darkAmount) {
mDarkAmount = darkAmount;
}
/** Returns the dark ratio of the status bar */
public float getDarkAmount() {
return mDarkAmount;
}
public void setHideSensitive(boolean hideSensitive) { public void setHideSensitive(boolean hideSensitive) {
mHideSensitive = hideSensitive; mHideSensitive = hideSensitive;
} }
@@ -412,18 +422,11 @@ public class AmbientState {
return mExpandAnimationTopChange; return mExpandAnimationTopChange;
} }
/**
* {@see isFullyDark}
*/
public void setFullyDark(boolean fullyDark) {
mFullyDark = fullyDark;
}
/** /**
* @return {@code true } when shade is completely dark: in AOD or ambient display. * @return {@code true } when shade is completely dark: in AOD or ambient display.
*/ */
public boolean isFullyDark() { public boolean isFullyDark() {
return mFullyDark; return mDarkAmount == 1;
} }
public void setDarkTopPadding(int darkTopPadding) { public void setDarkTopPadding(int darkTopPadding) {

View File

@@ -96,6 +96,7 @@ import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.notification.FakeShadowView; import com.android.systemui.statusbar.notification.FakeShadowView;
import com.android.systemui.statusbar.notification.NotificationUtils; import com.android.systemui.statusbar.notification.NotificationUtils;
import com.android.systemui.statusbar.notification.VisibilityLocationProvider; import com.android.systemui.statusbar.notification.VisibilityLocationProvider;
import com.android.systemui.statusbar.phone.DozeParameters;
import com.android.systemui.statusbar.phone.HeadsUpManagerPhone; import com.android.systemui.statusbar.phone.HeadsUpManagerPhone;
import com.android.systemui.statusbar.phone.NotificationGroupManager; import com.android.systemui.statusbar.phone.NotificationGroupManager;
import com.android.systemui.statusbar.phone.ScrimController; import com.android.systemui.statusbar.phone.ScrimController;
@@ -269,8 +270,6 @@ public class NotificationStackScrollLayout extends ViewGroup
*/ */
private boolean mOnlyScrollingInThisMotion; private boolean mOnlyScrollingInThisMotion;
private boolean mDisallowDismissInThisMotion; private boolean mDisallowDismissInThisMotion;
private boolean mInterceptDelegateEnabled;
private boolean mDelegateToScrollView;
private boolean mDisallowScrollingInThisMotion; private boolean mDisallowScrollingInThisMotion;
private long mGoToFullShadeDelay; private long mGoToFullShadeDelay;
private ViewTreeObserver.OnPreDrawListener mChildrenUpdater private ViewTreeObserver.OnPreDrawListener mChildrenUpdater
@@ -562,17 +561,17 @@ public class NotificationStackScrollLayout extends ViewGroup
return; return;
} }
final int color; float alpha =
if (mAmbientState.isDark()) { BACKGROUND_ALPHA_DIMMED + (1 - BACKGROUND_ALPHA_DIMMED) * (1.0f - mDimAmount);
color = Color.WHITE; alpha *= 1f - mDarkAmount;
} else { // We need to manually blend in the background color.
float alpha = int scrimColor = mScrimController.getBackgroundColor();
BACKGROUND_ALPHA_DIMMED + (1 - BACKGROUND_ALPHA_DIMMED) * (1.0f - mDimAmount); int awakeColor = ColorUtils.blendARGB(scrimColor, mBgColor, alpha);
alpha *= 1f - mDarkAmount;
// We need to manually blend in the background color // Interpolate between semi-transparent notification panel background color
int scrimColor = mScrimController.getBackgroundColor(); // and white AOD separator.
color = ColorUtils.blendARGB(scrimColor, mBgColor, alpha); float colorInterpolation = Interpolators.DECELERATE_QUINT.getInterpolation(mDarkAmount);
} int color = ColorUtils.blendARGB(awakeColor, Color.WHITE, colorInterpolation);
if (mCachedBackgroundColor != color) { if (mCachedBackgroundColor != color) {
mCachedBackgroundColor = color; mCachedBackgroundColor = color;
@@ -3961,13 +3960,18 @@ public class NotificationStackScrollLayout extends ViewGroup
private void setDarkAmount(float darkAmount) { private void setDarkAmount(float darkAmount) {
mDarkAmount = darkAmount; mDarkAmount = darkAmount;
final boolean fullyDark = darkAmount == 1; boolean wasFullyDark = mAmbientState.isFullyDark();
if (mAmbientState.isFullyDark() != fullyDark) { mAmbientState.setDarkAmount(darkAmount);
mAmbientState.setFullyDark(fullyDark); if (mAmbientState.isFullyDark() != wasFullyDark) {
updateContentHeight(); updateContentHeight();
DozeParameters dozeParameters = DozeParameters.getInstance(mContext);
if (mAmbientState.isFullyDark() && dozeParameters.shouldControlScreenOff()) {
mShelf.fadeInTranslating();
}
} }
updateBackgroundDimming(); updateBackgroundDimming();
updateAntiBurnInTranslation(); updateAntiBurnInTranslation();
requestChildrenUpdate();
} }
public float getDarkAmount() { public float getDarkAmount() {

View File

@@ -276,8 +276,6 @@ public class StackScrollAlgorithm {
if (i >= firstHiddenIndex) { if (i >= firstHiddenIndex) {
// we need normal padding now, to be in sync with what the stack calculates // we need normal padding now, to be in sync with what the stack calculates
lastView = null; lastView = null;
ExpandableViewState viewState = resultState.getViewStateForView(v);
viewState.hidden = true;
} }
notGoneIndex = updateNotGoneIndex(resultState, state, notGoneIndex, v); notGoneIndex = updateNotGoneIndex(resultState, state, notGoneIndex, v);
float increasedPadding = v.getIncreasedPaddingAmount(); float increasedPadding = v.getIncreasedPaddingAmount();

View File

@@ -97,6 +97,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
doNothing().when(mGroupManager).collapseAllGroups(); doNothing().when(mGroupManager).collapseAllGroups();
doNothing().when(mExpandHelper).cancelImmediately(); doNothing().when(mExpandHelper).cancelImmediately();
doNothing().when(notificationShelf).setAnimationsEnabled(anyBoolean()); doNothing().when(notificationShelf).setAnimationsEnabled(anyBoolean());
doNothing().when(notificationShelf).fadeInTranslating();
} }
@Test @Test