diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java index 56c34a0b3665b..8f1e0a1a6b162 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java @@ -23,6 +23,7 @@ import android.content.res.Configuration; import android.content.res.Resources; import android.graphics.Rect; import android.util.AttributeSet; +import android.util.IndentingPrintWriter; import android.util.MathUtils; import android.view.View; import android.view.ViewGroup; @@ -52,6 +53,9 @@ import com.android.systemui.statusbar.notification.stack.NotificationStackScroll import com.android.systemui.statusbar.notification.stack.StackScrollAlgorithm; import com.android.systemui.statusbar.notification.stack.ViewState; import com.android.systemui.statusbar.phone.NotificationIconContainer; +import com.android.systemui.util.DumpUtilsKt; + +import java.io.PrintWriter; /** * A notification shelf view that is placed inside the notification scroller. It manages the @@ -86,7 +90,6 @@ public class NotificationShelf extends ActivatableNotificationView implements private boolean mInteractive; private boolean mAnimationsEnabled = true; private boolean mShowNotificationShelf; - private float mFirstElementRoundness; private Rect mClipRect = new Rect(); private int mIndexOfFirstViewInShelf = -1; private float mCornerAnimationDistance; @@ -263,8 +266,7 @@ public class NotificationShelf extends ActivatableNotificationView implements final float actualWidth = mAmbientState.isOnKeyguard() ? MathUtils.lerp(shortestWidth, getWidth(), fractionToShade) : getWidth(); - ActivatableNotificationView anv = (ActivatableNotificationView) this; - anv.setBackgroundWidth((int) actualWidth); + setBackgroundWidth((int) actualWidth); if (mShelfIcons != null) { mShelfIcons.setActualLayoutWidth((int) actualWidth); } @@ -365,9 +367,7 @@ public class NotificationShelf extends ActivatableNotificationView implements boolean expandingAnimated = mAmbientState.isExpansionChanging() && !mAmbientState.isPanelTracking(); int baseZHeight = mAmbientState.getBaseZHeight(); - int backgroundTop = 0; int clipTopAmount = 0; - float firstElementRoundness = 0.0f; for (int i = 0; i < mHostLayoutController.getChildCount(); i++) { ExpandableView child = mHostLayoutController.getChildAt(i); @@ -420,18 +420,6 @@ public class NotificationShelf extends ActivatableNotificationView implements if (notGoneIndex != 0 || !aboveShelf) { expandableRow.setAboveShelf(false); } - if (notGoneIndex == 0) { - StatusBarIconView icon = expandableRow.getEntry().getIcons().getShelfIcon(); - NotificationIconContainer.IconState iconState = getIconState(icon); - // The icon state might be null in rare cases where the notification is actually - // added to the layout, but not to the shelf. An example are replied messages, - // since they don't show up on AOD - if (iconState != null && iconState.clampedAppearAmount == 1.0f) { - // only if the first icon is fully in the shelf we want to clip to it! - backgroundTop = (int) (child.getTranslationY() - getTranslationY()); - firstElementRoundness = expandableRow.getTopRoundness(); - } - } previousColor = ownColorUntinted; notGoneIndex++; @@ -467,8 +455,6 @@ public class NotificationShelf extends ActivatableNotificationView implements // TODO(b/172289889) transition last icon in shelf to notification icon and vice versa. setVisibility(isHidden ? View.INVISIBLE : View.VISIBLE); - setBackgroundTop(backgroundTop); - setFirstElementRoundness(firstElementRoundness); mShelfIcons.setSpeedBumpIndex(mHostLayoutController.getSpeedBumpIndex()); mShelfIcons.calculateIconXTranslations(); mShelfIcons.applyIconStates(); @@ -570,12 +556,6 @@ public class NotificationShelf extends ActivatableNotificationView implements } } - private void setFirstElementRoundness(float firstElementRoundness) { - if (mFirstElementRoundness != firstElementRoundness) { - mFirstElementRoundness = firstElementRoundness; - } - } - private void updateIconClipAmount(ExpandableNotificationRow row) { float maxTop = row.getTranslationY(); if (getClipTopAmount() != 0) { @@ -1011,6 +991,18 @@ public class NotificationShelf extends ActivatableNotificationView implements expandableView.requestRoundnessReset(LegacySourceType.OnScroll); } + @Override + public void dump(PrintWriter pwOriginal, String[] args) { + IndentingPrintWriter pw = DumpUtilsKt.asIndenting(pwOriginal); + super.dump(pw, args); + if (DUMP_VERBOSE) { + DumpUtilsKt.withIncreasedIndent(pw, () -> { + pw.println("mActualWidth: " + mActualWidth); + pw.println("mStatusBarHeight: " + mStatusBarHeight); + }); + } + } + public class ShelfState extends ExpandableViewState { private boolean hasItemsInStableShelf; private ExpandableView firstViewInShelf; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ActivatableNotificationView.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ActivatableNotificationView.java index 7addc8fe7a154..68ad49befc54d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ActivatableNotificationView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ActivatableNotificationView.java @@ -23,6 +23,7 @@ import android.content.Context; import android.graphics.Canvas; import android.graphics.Point; import android.util.AttributeSet; +import android.util.IndentingPrintWriter; import android.util.MathUtils; import android.view.Choreographer; import android.view.MotionEvent; @@ -43,7 +44,9 @@ import com.android.systemui.statusbar.notification.NotificationUtils; import com.android.systemui.statusbar.notification.SourceType; import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout; import com.android.systemui.statusbar.notification.stack.StackStateAnimator; +import com.android.systemui.util.DumpUtilsKt; +import java.io.PrintWriter; import java.util.HashSet; import java.util.Set; @@ -651,11 +654,6 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView mBackgroundNormal.setRadius(topRadius, bottomRadius); } - @Override - protected void setBackgroundTop(int backgroundTop) { - mBackgroundNormal.setBackgroundTop(backgroundTop); - } - protected abstract View getContentView(); public int calculateBgColor() { @@ -819,6 +817,22 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView mOnDetachResetRoundness.add(sourceType); } + @Override + public void dump(PrintWriter pwOriginal, String[] args) { + IndentingPrintWriter pw = DumpUtilsKt.asIndenting(pwOriginal); + super.dump(pw, args); + if (DUMP_VERBOSE) { + DumpUtilsKt.withIncreasedIndent(pw, () -> { + pw.println("mBackgroundNormal: " + mBackgroundNormal); + if (mBackgroundNormal != null) { + DumpUtilsKt.withIncreasedIndent(pw, () -> { + mBackgroundNormal.dump(pw, args); + }); + } + }); + } + } + public interface OnActivatedListener { void onActivated(ActivatableNotificationView view); void onActivationReset(ActivatableNotificationView view); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableOutlineView.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableOutlineView.java index 20412452b7f99..197caa2d56452 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableOutlineView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableOutlineView.java @@ -24,12 +24,16 @@ import android.graphics.Path; import android.graphics.Rect; import android.graphics.RectF; import android.util.AttributeSet; +import android.util.IndentingPrintWriter; import android.view.View; import android.view.ViewOutlineProvider; import com.android.systemui.R; import com.android.systemui.statusbar.notification.RoundableState; import com.android.systemui.statusbar.notification.stack.NotificationChildrenContainer; +import com.android.systemui.util.DumpUtilsKt; + +import java.io.PrintWriter; /** * Like {@link ExpandableView}, but setting an outline for the height and clipping. @@ -43,7 +47,6 @@ public abstract class ExpandableOutlineView extends ExpandableView { private float mOutlineAlpha = -1f; private boolean mAlwaysRoundBothCorners; private Path mTmpPath = new Path(); - private int mBackgroundTop; /** * {@code false} if the children views of the {@link ExpandableOutlineView} are translated when @@ -59,7 +62,7 @@ public abstract class ExpandableOutlineView extends ExpandableView { // Only when translating just the contents, does the outline need to be shifted. int translation = !mDismissUsingRowTranslationX ? (int) getTranslation() : 0; int left = Math.max(translation, 0); - int top = mClipTopAmount + mBackgroundTop; + int top = mClipTopAmount; int right = getWidth() + Math.min(translation, 0); int bottom = Math.max(getActualHeight() - mClipBottomAmount, top); outline.setRect(left, top, right, bottom); @@ -92,7 +95,7 @@ public abstract class ExpandableOutlineView extends ExpandableView { ? (int) getTranslation() : 0; int halfExtraWidth = (int) (mExtraWidthForClipping / 2.0f); left = Math.max(translation, 0) - halfExtraWidth; - top = mClipTopAmount + mBackgroundTop; + top = mClipTopAmount; right = getWidth() + halfExtraWidth + Math.min(translation, 0); // If the top is rounded we want the bottom to be at most at the top roundness, in order // to avoid the shadow changing when scrolling up. @@ -228,13 +231,6 @@ public abstract class ExpandableOutlineView extends ExpandableView { super.applyRoundnessAndInvalidate(); } - protected void setBackgroundTop(int backgroundTop) { - if (mBackgroundTop != backgroundTop) { - mBackgroundTop = backgroundTop; - invalidateOutline(); - } - } - public void onDensityOrFontScaleChanged() { initDimens(); applyRoundnessAndInvalidate(); @@ -350,4 +346,18 @@ public abstract class ExpandableOutlineView extends ExpandableView { public Path getCustomClipPath(View child) { return null; } + + @Override + public void dump(PrintWriter pwOriginal, String[] args) { + IndentingPrintWriter pw = DumpUtilsKt.asIndenting(pwOriginal); + super.dump(pw, args); + DumpUtilsKt.withIncreasedIndent(pw, () -> { + pw.println("Roundness: " + getRoundableState().debugString()); + if (DUMP_VERBOSE) { + pw.println("mCustomOutline: " + mCustomOutline + " mOutlineRect: " + mOutlineRect); + pw.println("mOutlineAlpha: " + mOutlineAlpha); + pw.println("mAlwaysRoundBothCorners: " + mAlwaysRoundBothCorners); + } + }); + } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableView.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableView.java index 955d7c18f8709..25c7264af047f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableView.java @@ -51,6 +51,8 @@ import java.util.List; */ public abstract class ExpandableView extends FrameLayout implements Dumpable, Roundable { private static final String TAG = "ExpandableView"; + /** whether the dump() for this class should include verbose details */ + protected static final boolean DUMP_VERBOSE = false; private RoundableState mRoundableState = null; protected OnHeightChangedListener mOnHeightChangedListener; @@ -825,6 +827,14 @@ public abstract class ExpandableView extends FrameLayout implements Dumpable, Ro viewState.dump(pw, args); pw.println(); } + if (DUMP_VERBOSE) { + pw.println("mClipTopAmount: " + mClipTopAmount); + pw.println("mClipBottomAmount " + mClipBottomAmount); + pw.println("mClipToActualHeight: " + mClipToActualHeight); + pw.println("mExtraWidthForClipping: " + mExtraWidthForClipping); + pw.println("mMinimumHeightForClipping: " + mMinimumHeightForClipping); + pw.println("getClipBounds(): " + getClipBounds()); + } }); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationBackgroundView.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationBackgroundView.java index 51715696efb03..da8d2d524456a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationBackgroundView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationBackgroundView.java @@ -28,12 +28,16 @@ import android.util.AttributeSet; import android.view.View; import com.android.internal.util.ArrayUtils; +import com.android.systemui.Dumpable; import com.android.systemui.R; +import java.io.PrintWriter; +import java.util.Arrays; + /** * A view that can be used for both the dimmed and normal background of an notification. */ -public class NotificationBackgroundView extends View { +public class NotificationBackgroundView extends View implements Dumpable { private final boolean mDontModifyCorners; private Drawable mBackground; @@ -42,7 +46,6 @@ public class NotificationBackgroundView extends View { private int mTintColor; private final float[] mCornerRadii = new float[8]; private boolean mBottomIsRounded; - private int mBackgroundTop; private boolean mBottomAmountClips = true; private int mActualHeight = -1; private int mActualWidth = -1; @@ -60,8 +63,7 @@ public class NotificationBackgroundView extends View { @Override protected void onDraw(Canvas canvas) { - if (mClipTopAmount + mClipBottomAmount < getActualHeight() - mBackgroundTop - || mExpandAnimationRunning) { + if (mClipTopAmount + mClipBottomAmount < getActualHeight() || mExpandAnimationRunning) { canvas.save(); if (!mExpandAnimationRunning) { canvas.clipRect(0, mClipTopAmount, getWidth(), @@ -74,7 +76,7 @@ public class NotificationBackgroundView extends View { private void draw(Canvas canvas, Drawable drawable) { if (drawable != null) { - int top = mBackgroundTop; + int top = 0; int bottom = getActualHeight(); if (mBottomIsRounded && mBottomAmountClips @@ -261,11 +263,6 @@ public class NotificationBackgroundView extends View { } } - public void setBackgroundTop(int backgroundTop) { - mBackgroundTop = backgroundTop; - invalidate(); - } - /** Set the current expand animation size. */ public void setExpandAnimationSize(int width, int height) { mExpandAnimationHeight = height; @@ -291,4 +288,16 @@ public class NotificationBackgroundView extends View { public void setPressedAllowed(boolean allowed) { mIsPressedAllowed = allowed; } + + @Override + public void dump(PrintWriter pw, String[] args) { + pw.println("mDontModifyCorners: " + mDontModifyCorners); + pw.println("mClipTopAmount: " + mClipTopAmount); + pw.println("mClipBottomAmount: " + mClipBottomAmount); + pw.println("mCornerRadii: " + Arrays.toString(mCornerRadii)); + pw.println("mBottomIsRounded: " + mBottomIsRounded); + pw.println("mBottomAmountClips: " + mBottomAmountClips); + pw.println("mActualWidth: " + mActualWidth); + pw.println("mActualHeight: " + mActualHeight); + } }