Fade in shelf icons (replaces y-translation/scale/color-inversion)
Fade based on notification-to-shelf transition amount. Always show notification row icon. Remove "setShelfIconVisible" Bug: 178479515 Test: expand shade and scroll (LTR/RTL) => notification row always shows icon => shelf icons fade in and out with no yTranslation Change-Id: I077f4fcfd25198184e0bdb8f1dcc37710f5e57b1
This commit is contained in:
@@ -527,7 +527,7 @@ public class NotificationShelf extends ActivatableNotificationView implements
|
||||
handleCustomTransformHeight(view, expandingAnimated, iconState);
|
||||
|
||||
float fullTransitionAmount;
|
||||
float transitionAmount;
|
||||
float iconTransitionAmount;
|
||||
float contentTransformationAmount;
|
||||
float shelfStart = getTranslationY();
|
||||
boolean fullyInOrOut = true;
|
||||
@@ -549,18 +549,19 @@ public class NotificationShelf extends ActivatableNotificationView implements
|
||||
fullTransitionAmount = 1.0f - interpolatedAmount;
|
||||
|
||||
if (isLastChild) {
|
||||
// If it's the last child we should use all of the notification to transform
|
||||
// instead of just to the icon, since that can be quite low.
|
||||
transitionAmount = (shelfStart - viewStart) / transformDistance;
|
||||
// Reduce icon transform distance to completely fade in shelf icon
|
||||
// by the time the notification icon fades out, and vice versa
|
||||
iconTransitionAmount = (shelfStart - viewStart)
|
||||
/ (iconTransformStart - viewStart);
|
||||
} else {
|
||||
transitionAmount = (shelfStart - iconTransformStart) / transformDistance;
|
||||
iconTransitionAmount = (shelfStart - iconTransformStart) / transformDistance;
|
||||
}
|
||||
transitionAmount = MathUtils.constrain(transitionAmount, 0.0f, 1.0f);
|
||||
transitionAmount = 1.0f - transitionAmount;
|
||||
iconTransitionAmount = MathUtils.constrain(iconTransitionAmount, 0.0f, 1.0f);
|
||||
iconTransitionAmount = 1.0f - iconTransitionAmount;
|
||||
fullyInOrOut = false;
|
||||
} else {
|
||||
fullTransitionAmount = 1.0f;
|
||||
transitionAmount = 1.0f;
|
||||
iconTransitionAmount = 1.0f;
|
||||
}
|
||||
|
||||
// Transforming the content
|
||||
@@ -569,7 +570,7 @@ public class NotificationShelf extends ActivatableNotificationView implements
|
||||
contentTransformationAmount = 1.0f - contentTransformationAmount;
|
||||
} else {
|
||||
fullTransitionAmount = 0.0f;
|
||||
transitionAmount = 0.0f;
|
||||
iconTransitionAmount = 0.0f;
|
||||
contentTransformationAmount = 0.0f;
|
||||
}
|
||||
if (iconState != null && fullyInOrOut && !expandingAnimated && iconState.isLastExpandIcon) {
|
||||
@@ -585,7 +586,7 @@ public class NotificationShelf extends ActivatableNotificationView implements
|
||||
view.setContentTransformationAmount(contentTransformationAmount, isLastChild);
|
||||
|
||||
// Update the positioning of the icon
|
||||
updateIconPositioning(view, transitionAmount, fullTransitionAmount,
|
||||
updateIconPositioning(view, iconTransitionAmount, fullTransitionAmount,
|
||||
transformDistance, scrolling, scrollingFast, expandingAnimated, isLastChild);
|
||||
|
||||
return fullTransitionAmount;
|
||||
@@ -679,8 +680,7 @@ public class NotificationShelf extends ActivatableNotificationView implements
|
||||
|| iconState.useLinearTransitionAmount) {
|
||||
transitionAmount = iconTransitionAmount;
|
||||
} else {
|
||||
// We take the clamped position instead
|
||||
transitionAmount = clampedAmount;
|
||||
transitionAmount = iconTransitionAmount;
|
||||
iconState.needsCannedAnimation = iconState.clampedAppearAmount != clampedAmount
|
||||
&& !mNoAnimationsInThisFrame;
|
||||
}
|
||||
@@ -689,8 +689,7 @@ public class NotificationShelf extends ActivatableNotificationView implements
|
||||
? fullTransitionAmount
|
||||
: transitionAmount;
|
||||
iconState.clampedAppearAmount = clampedAmount;
|
||||
setIconTransformationAmount(view, transitionAmount, iconTransformDistance,
|
||||
clampedAmount != transitionAmount, isLastChild);
|
||||
setIconTransformationAmount(view, transitionAmount, isLastChild);
|
||||
}
|
||||
|
||||
private boolean isTargetClipped(ExpandableView view) {
|
||||
@@ -708,7 +707,7 @@ public class NotificationShelf extends ActivatableNotificationView implements
|
||||
}
|
||||
|
||||
private void setIconTransformationAmount(ExpandableView view,
|
||||
float transitionAmount, float iconTransformDistance, boolean usingLinearInterpolation,
|
||||
float transitionAmount,
|
||||
boolean isLastChild) {
|
||||
if (!(view instanceof ExpandableNotificationRow)) {
|
||||
return;
|
||||
@@ -720,42 +719,13 @@ public class NotificationShelf extends ActivatableNotificationView implements
|
||||
View rowIcon = row.getShelfTransformationTarget();
|
||||
|
||||
// Let's resolve the relative positions of the icons
|
||||
float notificationIconSize = 0.0f;
|
||||
int iconTopPadding;
|
||||
int iconStartPadding;
|
||||
if (rowIcon != null) {
|
||||
iconTopPadding = row.getRelativeTopPadding(rowIcon);
|
||||
iconStartPadding = row.getRelativeStartPadding(rowIcon);
|
||||
notificationIconSize = rowIcon.getHeight();
|
||||
} else {
|
||||
iconTopPadding = mIconAppearTopPadding;
|
||||
iconStartPadding = 0;
|
||||
}
|
||||
|
||||
float shelfIconSize = mAmbientState.isFullyHidden() ? mHiddenShelfIconSize : mIconSize;
|
||||
shelfIconSize = shelfIconSize * icon.getIconScale();
|
||||
|
||||
// Get the icon correctly positioned in Y
|
||||
float notificationIconPositionY = row.getTranslationY() + row.getContentTranslation();
|
||||
float targetYPosition = 0;
|
||||
boolean stayingInShelf = row.isInShelf() && !row.isTransformingIntoShelf();
|
||||
if (usingLinearInterpolation && !stayingInShelf) {
|
||||
// If we interpolate from the notification position, this might lead to a slightly
|
||||
// odd interpolation, since the notification position changes as well.
|
||||
// Let's instead interpolate directly to the top left of the notification
|
||||
targetYPosition = NotificationUtils.interpolate(
|
||||
Math.min(notificationIconPositionY + mIconAppearTopPadding
|
||||
- getTranslationY(), 0),
|
||||
0,
|
||||
transitionAmount);
|
||||
}
|
||||
notificationIconPositionY += iconTopPadding;
|
||||
float shelfIconPositionY = getTranslationY() + icon.getTop();
|
||||
shelfIconPositionY += (icon.getHeight() - shelfIconSize) / 2.0f;
|
||||
float iconYTranslation = NotificationUtils.interpolate(
|
||||
notificationIconPositionY - shelfIconPositionY,
|
||||
targetYPosition,
|
||||
transitionAmount);
|
||||
|
||||
// Get the icon correctly positioned in X
|
||||
// Even in RTL it's the left, since we're inverting the location in post
|
||||
@@ -767,28 +737,19 @@ public class NotificationShelf extends ActivatableNotificationView implements
|
||||
transitionAmount);
|
||||
|
||||
// Let's handle the case that there's no Icon
|
||||
float alpha = 1.0f;
|
||||
boolean noIcon = !row.isShowingIcon();
|
||||
if (noIcon) {
|
||||
// The view currently doesn't have an icon, lets transform it in!
|
||||
alpha = transitionAmount;
|
||||
notificationIconSize = shelfIconSize / 2.0f;
|
||||
iconXTranslation = mShelfIcons.getActualPaddingStart();
|
||||
}
|
||||
// The notification size is different from the size in the shelf / statusbar
|
||||
float newSize = NotificationUtils.interpolate(notificationIconSize, shelfIconSize,
|
||||
transitionAmount);
|
||||
if (iconState != null) {
|
||||
iconState.scaleX = newSize / shelfIconSize;
|
||||
iconState.scaleY = iconState.scaleX;
|
||||
iconState.hidden = transitionAmount == 0.0f && !iconState.isAnimating(icon);
|
||||
boolean isAppearing = row.isDrawingAppearAnimation() && !row.isInShelf();
|
||||
if (isAppearing) {
|
||||
iconState.hidden = true;
|
||||
iconState.iconAppearAmount = 0.0f;
|
||||
}
|
||||
iconState.alpha = alpha;
|
||||
iconState.yTranslation = iconYTranslation;
|
||||
iconState.alpha = transitionAmount;
|
||||
iconState.xTranslation = iconXTranslation;
|
||||
if (stayingInShelf) {
|
||||
iconState.iconAppearAmount = 1.0f;
|
||||
|
||||
@@ -180,9 +180,6 @@ class ConversationNotificationManager @Inject constructor(
|
||||
}
|
||||
if (changed) {
|
||||
notificationGroupManager.updateIsolation(entry)
|
||||
// ensure that the conversation icon isn't hidden
|
||||
// (ex: if it was showing in the shelf)
|
||||
entry.row?.updateIconVisibilities()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,7 +176,6 @@ public final class NotificationEntry extends ListEntry {
|
||||
private int mBucket = BUCKET_ALERTING;
|
||||
@Nullable private Long mPendingAnimationDuration;
|
||||
private boolean mIsMarkedForUserTriggeredMovement;
|
||||
private boolean mShelfIconVisible;
|
||||
private boolean mIsAlerting;
|
||||
|
||||
public boolean mRemoteEditImeVisible;
|
||||
@@ -417,7 +416,6 @@ public final class NotificationEntry extends ListEntry {
|
||||
//TODO: This will go away when we have a way to bind an entry to a row
|
||||
public void setRow(ExpandableNotificationRow row) {
|
||||
this.row = row;
|
||||
updateShelfIconVisibility();
|
||||
}
|
||||
|
||||
public ExpandableNotificationRowController getRowController() {
|
||||
@@ -938,19 +936,6 @@ public final class NotificationEntry extends ListEntry {
|
||||
return mIsMarkedForUserTriggeredMovement;
|
||||
}
|
||||
|
||||
/** Whether or not the icon for this notification is visible in the shelf. */
|
||||
public void setShelfIconVisible(boolean shelfIconVisible) {
|
||||
if (row == null) return;
|
||||
mShelfIconVisible = shelfIconVisible;
|
||||
updateShelfIconVisibility();
|
||||
}
|
||||
|
||||
private void updateShelfIconVisibility() {
|
||||
if (row != null) {
|
||||
row.setShelfIconVisible(mShelfIconVisible);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark this entry for movement triggered by a user action (ex: changing the priorirty of a
|
||||
* conversation). This can then be used for custom animations.
|
||||
|
||||
@@ -95,11 +95,6 @@ class IconManager @Inject constructor(
|
||||
// Construct the shelf icon view.
|
||||
val shelfIcon = iconBuilder.createIconView(entry)
|
||||
shelfIcon.scaleType = ImageView.ScaleType.CENTER_INSIDE
|
||||
|
||||
// TODO: This doesn't belong here
|
||||
shelfIcon.setOnVisibilityChangedListener { newVisibility: Int ->
|
||||
entry.setShelfIconVisible(newVisibility == View.VISIBLE)
|
||||
}
|
||||
shelfIcon.visibility = View.INVISIBLE
|
||||
|
||||
// Construct the aod icon view.
|
||||
|
||||
@@ -331,7 +331,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
|
||||
private boolean mHeadsupDisappearRunning;
|
||||
private View mChildAfterViewWhenDismissed;
|
||||
private View mGroupParentWhenDismissed;
|
||||
private boolean mShelfIconVisible;
|
||||
private boolean mAboveShelf;
|
||||
private OnUserInteractionCallback mOnUserInteractionCallback;
|
||||
private NotificationGutsManager mNotificationGutsManager;
|
||||
@@ -568,7 +567,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
|
||||
// The public layouts expand button is always visible
|
||||
mPublicLayout.updateExpandButtons(true);
|
||||
updateLimits();
|
||||
updateIconVisibilities();
|
||||
updateShelfIconColor();
|
||||
updateRippleAllowed();
|
||||
if (mUpdateBackgroundOnUpdate) {
|
||||
@@ -883,7 +881,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
|
||||
setDistanceToTopRoundness(NO_ROUNDNESS);
|
||||
mNotificationParent.updateBackgroundForGroupState();
|
||||
}
|
||||
updateIconVisibilities();
|
||||
updateBackgroundClipping();
|
||||
}
|
||||
|
||||
@@ -1481,21 +1478,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
|
||||
return getShelfTransformationTarget() != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the icons to be visible of this notification.
|
||||
*/
|
||||
public void setShelfIconVisible(boolean iconVisible) {
|
||||
if (iconVisible != mShelfIconVisible) {
|
||||
mShelfIconVisible = iconVisible;
|
||||
updateIconVisibilities();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onBelowSpeedBumpChanged() {
|
||||
updateIconVisibilities();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateContentTransformation() {
|
||||
if (mExpandAnimationRunning) {
|
||||
@@ -1522,18 +1504,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
|
||||
}
|
||||
}
|
||||
|
||||
/** Refreshes the visibility of notification icons */
|
||||
public void updateIconVisibilities() {
|
||||
// The shelf icon is never hidden for children in groups
|
||||
boolean visible = !isChildInGroup() && mShelfIconVisible;
|
||||
for (NotificationContentView l : mLayouts) {
|
||||
l.setShelfIconVisible(visible);
|
||||
}
|
||||
if (mChildrenContainer != null) {
|
||||
mChildrenContainer.setShelfIconVisible(visible);
|
||||
}
|
||||
}
|
||||
|
||||
public void setIsLowPriority(boolean isLowPriority) {
|
||||
mIsLowPriority = isLowPriority;
|
||||
mPrivateLayout.setIsLowPriority(isLowPriority);
|
||||
|
||||
@@ -169,7 +169,6 @@ public class NotificationContentView extends FrameLayout {
|
||||
private int mContentHeightAtAnimationStart = UNDEFINED;
|
||||
private boolean mFocusOnVisibilityChange;
|
||||
private boolean mHeadsUpAnimatingAway;
|
||||
private boolean mShelfIconVisible;
|
||||
private int mClipBottomAmount;
|
||||
private boolean mIsLowPriority;
|
||||
private boolean mIsContentExpandable;
|
||||
@@ -1729,23 +1728,6 @@ public class NotificationContentView extends FrameLayout {
|
||||
mFocusOnVisibilityChange = true;
|
||||
}
|
||||
|
||||
public void setShelfIconVisible(boolean iconsVisible) {
|
||||
mShelfIconVisible = iconsVisible;
|
||||
updateIconVisibilities();
|
||||
}
|
||||
|
||||
private void updateIconVisibilities() {
|
||||
if (mContractedWrapper != null) {
|
||||
mContractedWrapper.setShelfIconVisible(mShelfIconVisible);
|
||||
}
|
||||
if (mHeadsUpWrapper != null) {
|
||||
mHeadsUpWrapper.setShelfIconVisible(mShelfIconVisible);
|
||||
}
|
||||
if (mExpandedWrapper != null) {
|
||||
mExpandedWrapper.setShelfIconVisible(mShelfIconVisible);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onVisibilityAggregated(boolean isVisible) {
|
||||
super.onVisibilityAggregated(isVisible);
|
||||
|
||||
@@ -132,20 +132,6 @@ class NotificationConversationTemplateViewWrapper constructor(
|
||||
)
|
||||
}
|
||||
|
||||
override fun setShelfIconVisible(visible: Boolean) {
|
||||
if (conversationLayout.isImportantConversation) {
|
||||
if (conversationIconView.visibility != View.GONE) {
|
||||
conversationIconView.isForceHidden = visible
|
||||
// We don't want the small icon to be hidden by the extended wrapper, as force
|
||||
// hiding the conversationIcon will already do that via its listener.
|
||||
return
|
||||
}
|
||||
} else {
|
||||
conversationIconView.isForceHidden = false
|
||||
}
|
||||
super.setShelfIconVisible(visible)
|
||||
}
|
||||
|
||||
override fun getShelfTransformationTarget(): View? =
|
||||
if (conversationLayout.isImportantConversation)
|
||||
if (conversationIconView.visibility != View.GONE)
|
||||
|
||||
@@ -312,12 +312,6 @@ public class NotificationHeaderViewWrapper extends NotificationViewWrapper {
|
||||
return mIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShelfIconVisible(boolean visible) {
|
||||
super.setShelfIconVisible(visible);
|
||||
mIcon.setForceHidden(visible);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TransformState getCurrentState(int fadingView) {
|
||||
return mTransformationHelper.getCurrentState(fadingView);
|
||||
|
||||
@@ -331,11 +331,6 @@ public abstract class NotificationViewWrapper implements TransformableView {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the shelf icon to be visible and hide our own icons.
|
||||
*/
|
||||
public void setShelfIconVisible(boolean shelfIconVisible) {}
|
||||
|
||||
public int getHeaderTranslation(boolean forceNoHeader) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1225,21 +1225,6 @@ public class NotificationChildrenContainer extends ViewGroup {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setShelfIconVisible(boolean iconVisible) {
|
||||
if (mNotificationHeaderWrapper != null) {
|
||||
CachingIconView icon = mNotificationHeaderWrapper.getIcon();
|
||||
if (icon != null) {
|
||||
icon.setForceHidden(iconVisible);
|
||||
}
|
||||
}
|
||||
if (mNotificationHeaderWrapperLowPriority != null) {
|
||||
CachingIconView icon = mNotificationHeaderWrapperLowPriority.getIcon();
|
||||
if (icon != null) {
|
||||
icon.setForceHidden(iconVisible);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setClipBottomAmount(int clipBottomAmount) {
|
||||
mClipBottomAmount = clipBottomAmount;
|
||||
updateChildrenClipping();
|
||||
|
||||
Reference in New Issue
Block a user