Adapted the icon transformation into the shelf
The transformation is now more refined. Test: Add notifications, scroll Bug: 32437839 Change-Id: I2d553b2305fae508d2eb94ca4cee18faa41815a1
This commit is contained in:
@@ -28,6 +28,8 @@ import android.view.accessibility.AccessibilityNodeInfo;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RemoteViews;
|
||||
|
||||
import com.android.internal.widget.CachingIconView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
@@ -45,7 +47,7 @@ public class NotificationHeaderView extends ViewGroup {
|
||||
private OnClickListener mExpandClickListener;
|
||||
private HeaderTouchListener mTouchListener = new HeaderTouchListener();
|
||||
private ImageView mExpandButton;
|
||||
private View mIcon;
|
||||
private CachingIconView mIcon;
|
||||
private View mProfileBadge;
|
||||
private View mInfo;
|
||||
private int mIconColor;
|
||||
@@ -123,7 +125,7 @@ public class NotificationHeaderView extends ViewGroup {
|
||||
if (mExpandButton != null) {
|
||||
mExpandButton.setAccessibilityDelegate(mExpandDelegate);
|
||||
}
|
||||
mIcon = findViewById(com.android.internal.R.id.icon);
|
||||
mIcon = (CachingIconView) findViewById(com.android.internal.R.id.icon);
|
||||
mProfileBadge = findViewById(com.android.internal.R.id.profile_badge);
|
||||
}
|
||||
|
||||
@@ -311,7 +313,7 @@ public class NotificationHeaderView extends ViewGroup {
|
||||
return mProfileBadge;
|
||||
}
|
||||
|
||||
public View getIcon() {
|
||||
public CachingIconView getIcon() {
|
||||
return mIcon;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,8 @@ public class CachingIconView extends ImageView {
|
||||
private String mLastPackage;
|
||||
private int mLastResId;
|
||||
private boolean mInternalSetDrawable;
|
||||
private boolean mForceHidden;
|
||||
private int mDesiredVisibility;
|
||||
|
||||
public CachingIconView(Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
@@ -175,4 +177,24 @@ public class CachingIconView extends ImageView {
|
||||
mLastResId = 0;
|
||||
mLastPackage = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the icon to be forcibly hidden, even when it's visibility is changed to visible.
|
||||
*/
|
||||
public void setForceHidden(boolean forceHidden) {
|
||||
mForceHidden = forceHidden;
|
||||
updateVisibility();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVisibility(int visibility) {
|
||||
mDesiredVisibility = visibility;
|
||||
updateVisibility();
|
||||
}
|
||||
|
||||
private void updateVisibility() {
|
||||
int visibility = mDesiredVisibility == VISIBLE && mForceHidden ? INVISIBLE
|
||||
: mDesiredVisibility;
|
||||
super.setVisibility(visibility);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,6 +88,9 @@
|
||||
views where the distance can't be measured -->
|
||||
<dimen name="notification_icon_appear_padding">15dp</dimen>
|
||||
|
||||
<!-- The amount the content shifts upwards when transforming into the icon -->
|
||||
<dimen name="notification_icon_transform_content_shift">16dp</dimen>
|
||||
|
||||
<!-- Minimum layouted height of a notification in the statusbar-->
|
||||
<dimen name="min_notification_layout_height">48dp</dimen>
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ import android.widget.ImageView;
|
||||
import com.android.internal.logging.MetricsLogger;
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.internal.util.NotificationColorUtil;
|
||||
import com.android.systemui.Interpolators;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.classifier.FalsingManager;
|
||||
import com.android.systemui.statusbar.notification.HybridNotificationView;
|
||||
@@ -63,6 +64,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
|
||||
|
||||
private static final int DEFAULT_DIVIDER_ALPHA = 0x29;
|
||||
private static final int COLORED_DIVIDER_ALPHA = 0x7B;
|
||||
private int mIconTransformContentShift;
|
||||
private int mNotificationMinHeightLegacy;
|
||||
private int mMaxHeadsUpHeightLegacy;
|
||||
private int mMaxHeadsUpHeight;
|
||||
@@ -188,6 +190,8 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
|
||||
private View mChildAfterViewWhenDismissed;
|
||||
private View mGroupParentWhenDismissed;
|
||||
private boolean mRefocusOnDismiss;
|
||||
private float mIconTransformationAmount;
|
||||
private boolean mIconsVisible = true;
|
||||
|
||||
public boolean isGroupExpansionChanging() {
|
||||
if (isChildInGroup()) {
|
||||
@@ -293,6 +297,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
|
||||
// The public layouts expand button is always visible
|
||||
mPublicLayout.updateExpandButtons(true);
|
||||
updateLimits();
|
||||
updateIconVisibilities();
|
||||
}
|
||||
|
||||
private void updateLimits() {
|
||||
@@ -809,6 +814,52 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
|
||||
return notificationHeader != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set how much this notification is transformed into an icon.
|
||||
*
|
||||
* @param iconTransformationAmount A value from 0 to 1 indicating how much we are transformed
|
||||
* to an icon
|
||||
*/
|
||||
public void setIconTransformationAmount(float iconTransformationAmount) {
|
||||
if (mIconTransformationAmount != iconTransformationAmount) {
|
||||
mIconTransformationAmount = iconTransformationAmount;
|
||||
updateContentFadeOut();
|
||||
boolean iconsVisible = mIconTransformationAmount == 0.0f;
|
||||
if (iconsVisible != mIconsVisible) {
|
||||
mIconsVisible = iconsVisible;
|
||||
updateIconVisibilities();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateContentFadeOut() {
|
||||
if (!isChildInGroup()) {
|
||||
float contentAlpha = 1.0f - mIconTransformationAmount;
|
||||
contentAlpha = Math.max((contentAlpha - 0.5f) / 0.5f, 0.0f);
|
||||
contentAlpha = Interpolators.ALPHA_OUT.getInterpolation(contentAlpha);
|
||||
mPublicLayout.setAlpha(contentAlpha);
|
||||
float translationY = - mIconTransformationAmount * mIconTransformContentShift;
|
||||
mPublicLayout.setTranslationY(translationY);
|
||||
mPrivateLayout.setAlpha(contentAlpha);
|
||||
mPrivateLayout.setTranslationY(translationY);
|
||||
if (mChildrenContainer != null) {
|
||||
mChildrenContainer.setAlpha(contentAlpha);
|
||||
mChildrenContainer.setTranslationY(translationY);
|
||||
// TODO: handle children fade out better
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateIconVisibilities() {
|
||||
if (!isChildInGroup()) {
|
||||
mPublicLayout.setIconsVisible(mIconsVisible);
|
||||
mPrivateLayout.setIconsVisible(mIconsVisible);
|
||||
if (mChildrenContainer != null) {
|
||||
mChildrenContainer.setIconsVisible(mIconsVisible);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface ExpansionLogger {
|
||||
public void logNotificationExpansion(String key, boolean userAction, boolean expanded);
|
||||
}
|
||||
@@ -828,6 +879,8 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
|
||||
mMaxHeadsUpHeight = getFontScaledHeight(R.dimen.notification_max_heads_up_height);
|
||||
mIncreasedPaddingBetweenElements = getResources()
|
||||
.getDimensionPixelSize(R.dimen.notification_divider_height_increased);
|
||||
mIconTransformContentShift = getResources().getDimensionPixelSize(
|
||||
R.dimen.notification_icon_transform_content_shift);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1712,6 +1765,8 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
|
||||
public static class NotificationViewState extends ExpandableViewState {
|
||||
|
||||
private final StackScrollState mOverallState;
|
||||
public float iconTransformationAmount;
|
||||
|
||||
|
||||
private NotificationViewState(StackScrollState stackScrollState) {
|
||||
mOverallState = stackScrollState;
|
||||
@@ -1726,6 +1781,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
|
||||
row.setClipToActualHeight(true);
|
||||
}
|
||||
row.applyChildrenState(mOverallState);
|
||||
row.setIconTransformationAmount(iconTransformationAmount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,6 +122,7 @@ public class NotificationContentView extends FrameLayout {
|
||||
private int mContentHeightAtAnimationStart = UNDEFINED;
|
||||
private boolean mFocusOnVisibilityChange;
|
||||
private boolean mHeadsupDisappearRunning;
|
||||
private boolean mIconsVisible;
|
||||
|
||||
|
||||
public NotificationContentView(Context context, AttributeSet attrs) {
|
||||
@@ -1191,4 +1192,30 @@ public class NotificationContentView extends FrameLayout {
|
||||
public void setFocusOnVisibilityChange() {
|
||||
mFocusOnVisibilityChange = true;
|
||||
}
|
||||
|
||||
public void setIconsVisible(boolean iconsVisible) {
|
||||
mIconsVisible = iconsVisible;
|
||||
updateIconVisibilities();
|
||||
}
|
||||
|
||||
private void updateIconVisibilities() {
|
||||
if (mContractedWrapper != null) {
|
||||
NotificationHeaderView header = mContractedWrapper.getNotificationHeader();
|
||||
if (header != null) {
|
||||
header.getIcon().setForceHidden(!mIconsVisible);
|
||||
}
|
||||
}
|
||||
if (mHeadsUpWrapper != null) {
|
||||
NotificationHeaderView header = mHeadsUpWrapper.getNotificationHeader();
|
||||
if (header != null) {
|
||||
header.getIcon().setForceHidden(!mIconsVisible);
|
||||
}
|
||||
}
|
||||
if (mExpandedWrapper != null) {
|
||||
NotificationHeaderView header = mExpandedWrapper.getNotificationHeader();
|
||||
if (header != null) {
|
||||
header.getIcon().setForceHidden(!mIconsVisible);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,7 +157,9 @@ public class NotificationShelf extends ActivatableNotificationView {
|
||||
}
|
||||
if (row != null){
|
||||
// Not in the shelf yet, Icon needs to be placed on top of the notification icon
|
||||
updateIconAppearance(row.getEntry(), lastViewState, mShelfState);
|
||||
updateIconAppearance(row.getEntry(),
|
||||
(ExpandableNotificationRow.NotificationViewState) lastViewState,
|
||||
mShelfState);
|
||||
}
|
||||
}
|
||||
mShelfState.iconStates = mNotificationIconContainer.calculateIconStates(
|
||||
@@ -171,7 +173,8 @@ public class NotificationShelf extends ActivatableNotificationView {
|
||||
}
|
||||
}
|
||||
|
||||
private void updateIconAppearance(NotificationData.Entry entry, ExpandableViewState rowState,
|
||||
private void updateIconAppearance(NotificationData.Entry entry,
|
||||
ExpandableNotificationRow.NotificationViewState rowState,
|
||||
ShelfState shelfState) {
|
||||
StatusBarIconView icon = entry.expandedIcon;
|
||||
ViewState iconState = shelfState.iconStates.get(icon);
|
||||
@@ -207,6 +210,7 @@ public class NotificationShelf extends ActivatableNotificationView {
|
||||
iconState.scaleX = newSize / icon.getHeight();
|
||||
iconState.scaleY = iconState.scaleX;
|
||||
iconState.hidden = transitionAmount == 0.0f;
|
||||
rowState.iconTransformationAmount = transitionAmount;
|
||||
if (!entry.row.isShowingIcon()) {
|
||||
iconState.alpha = transitionAmount;
|
||||
}
|
||||
|
||||
@@ -1999,9 +1999,9 @@ public class NotificationPanelView extends PanelView implements
|
||||
@Override
|
||||
protected float getCannedFlingDurationFactor() {
|
||||
if (mQsExpanded) {
|
||||
return 0.7f;
|
||||
return 0.9f;
|
||||
} else {
|
||||
return 0.6f;
|
||||
return 0.8f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -184,6 +184,11 @@ public class NotificationChildrenContainer extends ViewGroup {
|
||||
setMeasuredDimension(width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasOverlappingRendering() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pointInView(float localX, float localY, float slop) {
|
||||
return localX >= -slop && localY >= -slop && localX < ((mRight - mLeft) + slop) &&
|
||||
@@ -207,6 +212,7 @@ public class NotificationChildrenContainer extends ViewGroup {
|
||||
mDividers.add(newIndex, divider);
|
||||
|
||||
updateGroupOverflow();
|
||||
row.setIconTransformationAmount(0);
|
||||
}
|
||||
|
||||
public void removeNotification(ExpandableNotificationRow row) {
|
||||
@@ -876,4 +882,13 @@ public class NotificationChildrenContainer extends ViewGroup {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setIconsVisible(boolean iconsVisible) {
|
||||
if (mNotificationHeaderWrapper != null) {
|
||||
NotificationHeaderView header = mNotificationHeaderWrapper.getNotificationHeader();
|
||||
if (header != null) {
|
||||
header.getIcon().setForceHidden(!iconsVisible);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user