Made the notification side paddings consistent
The rounding and paddings are now consistent throughout the shade. Before the notifications were only rounded on the top, but the design didn't work perfectly in all situations. Bug: 69168591 Test: add notifications, observe consistent paddings Change-Id: Idc60cb7d448193c65f77bafebb2d110809ecb725
This commit is contained in:
@@ -152,11 +152,11 @@
|
||||
<dimen name="dialog_padding">16dp</dimen>
|
||||
|
||||
<!-- The margin on the start of the content view -->
|
||||
<dimen name="notification_content_margin_start">24dp</dimen>
|
||||
<dimen name="notification_content_margin_start">16dp</dimen>
|
||||
|
||||
<!-- The margin on the end of the content view
|
||||
Keep in sync with notification_content_plus_picture_margin! -->
|
||||
<dimen name="notification_content_margin_end">24dp</dimen>
|
||||
<dimen name="notification_content_margin_end">16dp</dimen>
|
||||
|
||||
<!-- The margin on the end of the content view with a picture.
|
||||
Keep in sync with notification_content_plus_picture_margin! -->
|
||||
@@ -166,7 +166,7 @@
|
||||
content end margin.
|
||||
Keep equal to (notification_content_picture_margin + notification_content_margin_end)!
|
||||
-->
|
||||
<dimen name="notification_content_plus_picture_margin_end">80dp</dimen>
|
||||
<dimen name="notification_content_plus_picture_margin_end">72dp</dimen>
|
||||
|
||||
<!-- The additional margin on the sides of the ambient view. -->
|
||||
<dimen name="notification_extra_margin_ambient">16dp</dimen>
|
||||
|
||||
@@ -102,10 +102,7 @@
|
||||
<dimen name="notification_max_heads_up_height_increased">188dp</dimen>
|
||||
|
||||
<!-- Side padding on the lockscreen on the side of notifications -->
|
||||
<dimen name="notification_lockscreen_side_paddings">8dp</dimen>
|
||||
|
||||
<!-- Additional side padding for custom content if the app doesn't target P yet -->
|
||||
<dimen name="notification_content_custom_view_side_padding">@dimen/notification_lockscreen_side_paddings</dimen>
|
||||
<dimen name="notification_side_paddings">4dp</dimen>
|
||||
|
||||
<!-- Height of a messaging notifications with actions at least. Not that this is an upper bound
|
||||
and the notification won't use this much, but is measured with wrap_content -->
|
||||
@@ -121,7 +118,7 @@
|
||||
<dimen name="notification_min_interaction_height">40dp</dimen>
|
||||
|
||||
<!-- the padding of the shelf icon container -->
|
||||
<dimen name="shelf_icon_container_padding">21dp</dimen>
|
||||
<dimen name="shelf_icon_container_padding">13dp</dimen>
|
||||
|
||||
<!-- The padding of a notification icon on top to the start of the notification. Used for custom
|
||||
views where the distance can't be measured -->
|
||||
@@ -226,7 +223,7 @@
|
||||
<dimen name="qs_footer_height">48dp</dimen>
|
||||
|
||||
<!-- The padding between the notifications and the quick settings container -->
|
||||
<dimen name="qs_notification_keyguard_padding">8dp</dimen>
|
||||
<dimen name="qs_notification_padding">@dimen/notification_side_paddings</dimen>
|
||||
|
||||
<!-- Height of the status bar header bar when expanded -->
|
||||
<dimen name="status_bar_header_height_expanded">124dp</dimen>
|
||||
|
||||
@@ -86,10 +86,6 @@
|
||||
<item type="id" name="top_roundess_animator_start_tag"/>
|
||||
<item type="id" name="top_roundess_animator_end_tag"/>
|
||||
|
||||
<item type="id" name="side_padding_animator_tag"/>
|
||||
<item type="id" name="side_padding_animator_start_tag"/>
|
||||
<item type="id" name="side_padding_animator_end_tag"/>
|
||||
|
||||
<!-- Accessibility actions for the notification menu -->
|
||||
<item type="id" name="action_snooze_undo"/>
|
||||
<item type="id" name="action_snooze_shorter"/>
|
||||
|
||||
@@ -930,13 +930,6 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
|
||||
return calculateBgColor(true /* withTint */, true /* withOverRide */);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCurrentSidePaddings(float currentSidePaddings) {
|
||||
super.setCurrentSidePaddings(currentSidePaddings);
|
||||
mBackgroundNormal.setCurrentSidePaddings(currentSidePaddings);
|
||||
mBackgroundDimmed.setCurrentSidePaddings(currentSidePaddings);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean childNeedsClipping(View child) {
|
||||
if (child instanceof NotificationBackgroundView && isClippingNeeded()) {
|
||||
|
||||
@@ -2362,16 +2362,15 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
|
||||
NotificationContentView contentView = (NotificationContentView) child;
|
||||
if (isClippingNeeded()) {
|
||||
return true;
|
||||
} else if (!hasNoRoundingAndNoPadding() && contentView.shouldClipToSidePaddings()) {
|
||||
} else if (!hasNoRounding() && contentView.shouldClipToRounding()) {
|
||||
return true;
|
||||
}
|
||||
} else if (child == mChildrenContainer) {
|
||||
if (isClippingNeeded() || ((isGroupExpanded() || isGroupExpansionChanging())
|
||||
&& getClipBottomAmount() != 0.0f && getCurrentBottomRoundness() != 0.0f)) {
|
||||
if (isClippingNeeded() || !hasNoRounding()) {
|
||||
return true;
|
||||
}
|
||||
} else if (child instanceof NotificationGuts) {
|
||||
return !hasNoRoundingAndNoPadding();
|
||||
return !hasNoRounding();
|
||||
}
|
||||
return super.childNeedsClipping(child);
|
||||
}
|
||||
@@ -2401,9 +2400,8 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
|
||||
return super.getCustomClipPath(child);
|
||||
}
|
||||
|
||||
private boolean hasNoRoundingAndNoPadding() {
|
||||
return mCurrentSidePaddings == 0 && getCurrentBottomRoundness() == 0.0f
|
||||
&& getCurrentTopRoundness() == 0.0f;
|
||||
private boolean hasNoRounding() {
|
||||
return getCurrentBottomRoundness() == 0.0f && getCurrentTopRoundness() == 0.0f;
|
||||
}
|
||||
|
||||
public boolean isShowingAmbient() {
|
||||
@@ -2418,20 +2416,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCurrentSidePaddings(float currentSidePaddings) {
|
||||
if (mIsSummaryWithChildren) {
|
||||
List<ExpandableNotificationRow> notificationChildren =
|
||||
mChildrenContainer.getNotificationChildren();
|
||||
int size = notificationChildren.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
ExpandableNotificationRow row = notificationChildren.get(i);
|
||||
row.setCurrentSidePaddings(currentSidePaddings);
|
||||
}
|
||||
}
|
||||
super.setCurrentSidePaddings(currentSidePaddings);
|
||||
}
|
||||
|
||||
public static class NotificationViewState extends ExpandableViewState {
|
||||
|
||||
private final StackScrollState mOverallState;
|
||||
|
||||
@@ -69,7 +69,6 @@ public abstract class ExpandableOutlineView extends ExpandableView {
|
||||
private float mBottomRoundness;
|
||||
private float mTopRoundness;
|
||||
private int mBackgroundTop;
|
||||
protected int mCurrentSidePaddings;
|
||||
|
||||
/**
|
||||
* {@code true} if the children views of the {@link ExpandableOutlineView} are translated when
|
||||
@@ -83,9 +82,9 @@ public abstract class ExpandableOutlineView extends ExpandableView {
|
||||
if (!mCustomOutline && mCurrentTopRoundness == 0.0f
|
||||
&& mCurrentBottomRoundness == 0.0f && !mAlwaysRoundBothCorners) {
|
||||
int translation = mShouldTranslateContents ? (int) getTranslation() : 0;
|
||||
int left = Math.max(translation + mCurrentSidePaddings, mCurrentSidePaddings);
|
||||
int left = Math.max(translation, 0);
|
||||
int top = mClipTopAmount + mBackgroundTop;
|
||||
int right = getWidth() - mCurrentSidePaddings + Math.min(translation, 0);
|
||||
int right = getWidth() + Math.min(translation, 0);
|
||||
int bottom = Math.max(getActualHeight() - mClipBottomAmount, top);
|
||||
outline.setRect(left, top, right, bottom);
|
||||
} else {
|
||||
@@ -115,9 +114,9 @@ public abstract class ExpandableOutlineView extends ExpandableView {
|
||||
if (!mCustomOutline) {
|
||||
int translation = mShouldTranslateContents && !ignoreTranslation
|
||||
? (int) getTranslation() : 0;
|
||||
left = Math.max(translation + mCurrentSidePaddings, mCurrentSidePaddings);
|
||||
left = Math.max(translation, 0);
|
||||
top = mClipTopAmount + mBackgroundTop;
|
||||
right = getWidth() - mCurrentSidePaddings + Math.min(translation, 0);
|
||||
right = getWidth() + Math.min(translation, 0);
|
||||
bottom = Math.max(getActualHeight(), top);
|
||||
int intersectBottom = Math.max(getActualHeight() - mClipBottomAmount, top);
|
||||
if (bottom != intersectBottom) {
|
||||
@@ -135,8 +134,6 @@ public abstract class ExpandableOutlineView extends ExpandableView {
|
||||
top = mOutlineRect.top;
|
||||
right = mOutlineRect.right;
|
||||
bottom = mOutlineRect.bottom;
|
||||
left = Math.max(mCurrentSidePaddings, left);
|
||||
right = Math.min(getWidth() - mCurrentSidePaddings, right);
|
||||
}
|
||||
height = bottom - top;
|
||||
if (height == 0) {
|
||||
@@ -162,13 +159,6 @@ public abstract class ExpandableOutlineView extends ExpandableView {
|
||||
return roundedRectPath;
|
||||
}
|
||||
|
||||
protected Path getRoundedRectPath(int left, int top, int right, int bottom, float topRoundness,
|
||||
float bottomRoundness) {
|
||||
getRoundedRectPath(left, top, right, bottom, topRoundness, bottomRoundness,
|
||||
mTmpPath);
|
||||
return mTmpPath;
|
||||
}
|
||||
|
||||
private void getRoundedRectPath(int left, int top, int right, int bottom, float topRoundness,
|
||||
float bottomRoundness, Path outPath) {
|
||||
outPath.reset();
|
||||
@@ -395,10 +385,4 @@ public abstract class ExpandableOutlineView extends ExpandableView {
|
||||
public Path getCustomClipPath(View child) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setCurrentSidePaddings(float currentSidePaddings) {
|
||||
mCurrentSidePaddings = (int) currentSidePaddings;
|
||||
invalidateOutline();
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,6 @@ public class NotificationBackgroundView extends View {
|
||||
private int mClipBottomAmount;
|
||||
private int mTintColor;
|
||||
private float[] mCornerRadii = new float[8];
|
||||
private int mCurrentSidePaddings;
|
||||
private boolean mBottomIsRounded;
|
||||
private int mBackgroundTop;
|
||||
private boolean mBottomAmountClips = true;
|
||||
@@ -68,8 +67,7 @@ public class NotificationBackgroundView extends View {
|
||||
if (mBottomIsRounded && mBottomAmountClips) {
|
||||
bottom -= mClipBottomAmount;
|
||||
}
|
||||
drawable.setBounds(mCurrentSidePaddings, mBackgroundTop,
|
||||
getWidth() - mCurrentSidePaddings, bottom);
|
||||
drawable.setBounds(0, mBackgroundTop, getWidth(), bottom);
|
||||
drawable.draw(canvas);
|
||||
}
|
||||
}
|
||||
@@ -206,11 +204,6 @@ public class NotificationBackgroundView extends View {
|
||||
}
|
||||
}
|
||||
|
||||
public void setCurrentSidePaddings(float currentSidePaddings) {
|
||||
mCurrentSidePaddings = (int) currentSidePaddings;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public void setBackgroundTop(int backgroundTop) {
|
||||
mBackgroundTop = backgroundTop;
|
||||
invalidate();
|
||||
|
||||
@@ -136,7 +136,6 @@ public class NotificationContentView extends FrameLayout {
|
||||
private int mClipBottomAmount;
|
||||
private boolean mIsLowPriority;
|
||||
private boolean mIsContentExpandable;
|
||||
private int mCustomViewSidePaddings;
|
||||
|
||||
|
||||
public NotificationContentView(Context context, AttributeSet attrs) {
|
||||
@@ -150,8 +149,6 @@ public class NotificationContentView extends FrameLayout {
|
||||
R.dimen.min_notification_layout_height);
|
||||
mNotificationContentMarginEnd = getResources().getDimensionPixelSize(
|
||||
com.android.internal.R.dimen.notification_content_margin_end);
|
||||
mCustomViewSidePaddings = getResources().getDimensionPixelSize(
|
||||
R.dimen.notification_content_custom_view_side_padding);
|
||||
}
|
||||
|
||||
public void setHeights(int smallHeight, int headsUpMaxHeight, int maxHeight,
|
||||
@@ -391,22 +388,6 @@ public class NotificationContentView extends FrameLayout {
|
||||
mContractedWrapper = NotificationViewWrapper.wrap(getContext(), child,
|
||||
mContainingNotification);
|
||||
mContractedWrapper.setDark(mDark, false /* animate */, 0 /* delay */);
|
||||
updateMargins(child);
|
||||
}
|
||||
|
||||
private void updateMargins(View child) {
|
||||
if (child == null) {
|
||||
return;
|
||||
}
|
||||
NotificationViewWrapper wrapper = getWrapperForView(child);
|
||||
boolean isCustomView = wrapper instanceof NotificationCustomViewWrapper;
|
||||
boolean needsMargins = isCustomView &&
|
||||
child.getContext().getApplicationInfo().targetSdkVersion < Build.VERSION_CODES.P;
|
||||
int padding = needsMargins ? mCustomViewSidePaddings : 0;
|
||||
MarginLayoutParams layoutParams = (MarginLayoutParams) child.getLayoutParams();
|
||||
layoutParams.setMarginStart(padding);
|
||||
layoutParams.setMarginEnd(padding);
|
||||
child.setLayoutParams(layoutParams);
|
||||
}
|
||||
|
||||
private NotificationViewWrapper getWrapperForView(View child) {
|
||||
@@ -456,7 +437,6 @@ public class NotificationContentView extends FrameLayout {
|
||||
mExpandedChild = child;
|
||||
mExpandedWrapper = NotificationViewWrapper.wrap(getContext(), child,
|
||||
mContainingNotification);
|
||||
updateMargins(child);
|
||||
}
|
||||
|
||||
public void setHeadsUpChild(View child) {
|
||||
@@ -490,7 +470,6 @@ public class NotificationContentView extends FrameLayout {
|
||||
mHeadsUpChild = child;
|
||||
mHeadsUpWrapper = NotificationViewWrapper.wrap(getContext(), child,
|
||||
mContainingNotification);
|
||||
updateMargins(child);
|
||||
}
|
||||
|
||||
public void setAmbientChild(View child) {
|
||||
@@ -1510,19 +1489,19 @@ public class NotificationContentView extends FrameLayout {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean shouldClipToSidePaddings() {
|
||||
boolean needsPaddings = shouldClipToSidePaddings(getVisibleType());
|
||||
public boolean shouldClipToRounding() {
|
||||
boolean needsPaddings = shouldClipToRounding(getVisibleType());
|
||||
if (mUserExpanding) {
|
||||
needsPaddings |= shouldClipToSidePaddings(mTransformationStartVisibleType);
|
||||
needsPaddings |= shouldClipToRounding(mTransformationStartVisibleType);
|
||||
}
|
||||
return needsPaddings;
|
||||
}
|
||||
|
||||
private boolean shouldClipToSidePaddings(int visibleType) {
|
||||
private boolean shouldClipToRounding(int visibleType) {
|
||||
NotificationViewWrapper visibleWrapper = getVisibleWrapper(visibleType);
|
||||
if (visibleWrapper == null) {
|
||||
return false;
|
||||
}
|
||||
return visibleWrapper.shouldClipToSidePaddings();
|
||||
return visibleWrapper.shouldClipToRounding();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,8 +176,6 @@ public class NotificationMenuRow implements NotificationMenuRowPlugin, View.OnCl
|
||||
final Resources res = mContext.getResources();
|
||||
mHorizSpaceForIcon = res.getDimensionPixelSize(R.dimen.notification_menu_icon_size);
|
||||
mVertSpaceForIcons = res.getDimensionPixelSize(R.dimen.notification_min_height);
|
||||
mSidePadding = res.getDimensionPixelSize(R.dimen.notification_lockscreen_side_paddings);
|
||||
mIconPadding = res.getDimensionPixelSize(R.dimen.notification_menu_icon_padding);
|
||||
mMenuItems.clear();
|
||||
// Construct the menu items based on the notification
|
||||
if (mParent != null && mParent.getStatusBarNotification() != null) {
|
||||
@@ -498,8 +496,8 @@ public class NotificationMenuRow implements NotificationMenuRowPlugin, View.OnCl
|
||||
final int count = mMenuContainer.getChildCount();
|
||||
for (int i = 0; i < count; i++) {
|
||||
final View v = mMenuContainer.getChildAt(i);
|
||||
final float left = mSidePadding + i * mHorizSpaceForIcon;
|
||||
final float right = mParent.getWidth() - (mHorizSpaceForIcon * (i + 1)) - mSidePadding;
|
||||
final float left = i * mHorizSpaceForIcon;
|
||||
final float right = mParent.getWidth() - (mHorizSpaceForIcon * (i + 1));
|
||||
v.setX(showOnLeft ? left : right);
|
||||
}
|
||||
mOnLeft = showOnLeft;
|
||||
|
||||
@@ -38,7 +38,6 @@ public class NotificationCustomViewWrapper extends NotificationViewWrapper {
|
||||
private final Paint mGreyPaint = new Paint();
|
||||
private boolean mIsLegacy;
|
||||
private int mLegacyColor;
|
||||
private boolean mBeforeP;
|
||||
|
||||
protected NotificationCustomViewWrapper(Context ctx, View view, ExpandableNotificationRow row) {
|
||||
super(ctx, view, row);
|
||||
@@ -119,15 +118,7 @@ public class NotificationCustomViewWrapper extends NotificationViewWrapper {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldClipToSidePaddings() {
|
||||
// Before P we ensure that they are now drawing inside out content bounds since we inset
|
||||
// the view. If they target P, then we don't have that guarantee and we need to be safe.
|
||||
return !mBeforeP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContentUpdated(ExpandableNotificationRow row) {
|
||||
super.onContentUpdated(row);
|
||||
mBeforeP = row.getEntry().targetSdk < Build.VERSION_CODES.P;
|
||||
public boolean shouldClipToRounding() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ public class NotificationMediaTemplateViewWrapper extends NotificationTemplateVi
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldClipToSidePaddings() {
|
||||
public boolean shouldClipToRounding() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,11 +265,6 @@ public class NotificationTemplateViewWrapper extends NotificationHeaderViewWrapp
|
||||
updateActionOffset();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldClipToSidePaddings() {
|
||||
return mActionsContainer != null && mActionsContainer.getVisibility() != View.GONE;
|
||||
}
|
||||
|
||||
private void updateActionOffset() {
|
||||
if (mActionsContainer != null) {
|
||||
// We should never push the actions higher than they are in the headsup view.
|
||||
|
||||
@@ -195,7 +195,7 @@ public abstract class NotificationViewWrapper implements TransformableView {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public boolean shouldClipToSidePaddings() {
|
||||
public boolean shouldClipToRounding() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -309,7 +309,7 @@ public class NotificationPanelView extends PanelView implements
|
||||
mIndicationBottomPadding = getResources().getDimensionPixelSize(
|
||||
R.dimen.keyguard_indication_bottom_padding);
|
||||
mQsNotificationTopPadding = getResources().getDimensionPixelSize(
|
||||
R.dimen.qs_notification_keyguard_padding);
|
||||
R.dimen.qs_notification_padding);
|
||||
}
|
||||
|
||||
public void updateResources() {
|
||||
@@ -451,7 +451,8 @@ public class NotificationPanelView extends PanelView implements
|
||||
boolean animate = mNotificationStackScroller.isAddOrRemoveAnimationPending();
|
||||
int stackScrollerPadding;
|
||||
if (mStatusBarState != StatusBarState.KEYGUARD) {
|
||||
stackScrollerPadding = (mQs != null ? mQs.getHeader().getHeight() : 0) + mQsPeekHeight;
|
||||
stackScrollerPadding = (mQs != null ? mQs.getHeader().getHeight() : 0) + mQsPeekHeight
|
||||
+ mQsNotificationTopPadding;
|
||||
mTopPaddingAdjustment = 0;
|
||||
} else {
|
||||
mClockPositionAlgorithm.setup(
|
||||
@@ -1381,7 +1382,7 @@ public class NotificationPanelView extends PanelView implements
|
||||
mNotificationStackScroller.getIntrinsicPadding(),
|
||||
mQsMaxExpansionHeight + mQsNotificationTopPadding);
|
||||
} else {
|
||||
return mQsExpansionHeight;
|
||||
return mQsExpansionHeight + mQsNotificationTopPadding;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,6 @@ import com.android.systemui.statusbar.ActivatableNotificationView;
|
||||
import com.android.systemui.statusbar.DismissView;
|
||||
import com.android.systemui.statusbar.EmptyShadeView;
|
||||
import com.android.systemui.statusbar.ExpandableNotificationRow;
|
||||
import com.android.systemui.statusbar.ExpandableOutlineView;
|
||||
import com.android.systemui.statusbar.ExpandableView;
|
||||
import com.android.systemui.statusbar.NotificationData;
|
||||
import com.android.systemui.statusbar.NotificationGuts;
|
||||
@@ -84,10 +83,8 @@ import com.android.systemui.statusbar.NotificationShelf;
|
||||
import com.android.systemui.statusbar.NotificationSnooze;
|
||||
import com.android.systemui.statusbar.StackScrollerDecorView;
|
||||
import com.android.systemui.statusbar.StatusBarState;
|
||||
import com.android.systemui.statusbar.notification.AnimatableProperty;
|
||||
import com.android.systemui.statusbar.notification.FakeShadowView;
|
||||
import com.android.systemui.statusbar.notification.NotificationUtils;
|
||||
import com.android.systemui.statusbar.notification.PropertyAnimator;
|
||||
import com.android.systemui.statusbar.notification.VisibilityLocationProvider;
|
||||
import com.android.systemui.statusbar.phone.NotificationGroupManager;
|
||||
import com.android.systemui.statusbar.phone.StatusBar;
|
||||
@@ -123,16 +120,7 @@ public class NotificationStackScrollLayout extends ViewGroup
|
||||
/**
|
||||
* Sentinel value for no current active pointer. Used by {@link #mActivePointerId}.
|
||||
*/
|
||||
private static final int INVALID_POINTER = -1;
|
||||
private static final AnimatableProperty SIDE_PADDINGS = AnimatableProperty.from(
|
||||
"sidePaddings",
|
||||
NotificationStackScrollLayout::setCurrentSidePadding,
|
||||
NotificationStackScrollLayout::getCurrentSidePadding,
|
||||
R.id.side_padding_animator_tag,
|
||||
R.id.side_padding_animator_end_tag,
|
||||
R.id.side_padding_animator_start_tag);
|
||||
private static final AnimationProperties SIDE_PADDING_PROPERTIES =
|
||||
new AnimationProperties().setDuration(StackStateAnimator.ANIMATION_DURATION_STANDARD);
|
||||
private static final int INVALID_POINTER = -1;;
|
||||
|
||||
private ExpandHelper mExpandHelper;
|
||||
private NotificationSwipeHelper mSwipeHelper;
|
||||
@@ -140,7 +128,6 @@ public class NotificationStackScrollLayout extends ViewGroup
|
||||
private int mCurrentStackHeight = Integer.MAX_VALUE;
|
||||
private final Paint mBackgroundPaint = new Paint();
|
||||
private final Path mBackgroundPath = new Path();
|
||||
private final float[] mBackgroundRadii = new float[8];
|
||||
private final boolean mShouldDrawNotificationBackground;
|
||||
|
||||
private float mExpandedHeight;
|
||||
@@ -171,7 +158,6 @@ public class NotificationStackScrollLayout extends ViewGroup
|
||||
private int mTopPadding;
|
||||
private int mBottomMargin;
|
||||
private int mBottomInset = 0;
|
||||
private float mCurrentSidePadding;
|
||||
|
||||
/**
|
||||
* The algorithm which calculates the properties for our children
|
||||
@@ -399,7 +385,6 @@ public class NotificationStackScrollLayout extends ViewGroup
|
||||
private boolean mHeadsUpGoingAwayAnimationsAllowed = true;
|
||||
private Runnable mAnimateScroll = this::animateScroll;
|
||||
private int mCornerRadius;
|
||||
private int mLockscreenSidePaddings;
|
||||
private int mSidePaddings;
|
||||
|
||||
public NotificationStackScrollLayout(Context context) {
|
||||
@@ -437,8 +422,7 @@ public class NotificationStackScrollLayout extends ViewGroup
|
||||
res.getBoolean(R.bool.config_fadeNotificationsOnDismiss);
|
||||
|
||||
updateWillNotDraw();
|
||||
mBackgroundPaint.setAntiAlias(true);
|
||||
mBackgroundPaint.setStyle(Paint.Style.FILL);
|
||||
mBackgroundPaint.setAntiAlias(true);;
|
||||
if (DEBUG) {
|
||||
mDebugPaint = new Paint();
|
||||
mDebugPaint.setColor(0xffff0000);
|
||||
@@ -486,7 +470,8 @@ public class NotificationStackScrollLayout extends ViewGroup
|
||||
protected void onDraw(Canvas canvas) {
|
||||
if (mShouldDrawNotificationBackground && !mAmbientState.isDark()
|
||||
&& mCurrentBounds.top < mCurrentBounds.bottom) {
|
||||
canvas.drawPath(mBackgroundPath, mBackgroundPaint);
|
||||
canvas.drawRoundRect(mSidePaddings, mCurrentBounds.top, getWidth() - mSidePaddings,
|
||||
mCurrentBounds.bottom, mCornerRadius, mCornerRadius, mBackgroundPaint);
|
||||
}
|
||||
|
||||
if (DEBUG) {
|
||||
@@ -539,8 +524,7 @@ public class NotificationStackScrollLayout extends ViewGroup
|
||||
R.dimen.min_top_overscroll_to_qs);
|
||||
mStatusBarHeight = res.getDimensionPixelOffset(R.dimen.status_bar_height);
|
||||
mBottomMargin = res.getDimensionPixelSize(R.dimen.notification_panel_margin_bottom);
|
||||
mLockscreenSidePaddings = res.getDimensionPixelSize(
|
||||
R.dimen.notification_lockscreen_side_paddings);
|
||||
mSidePaddings = res.getDimensionPixelSize(R.dimen.notification_side_paddings);
|
||||
mMinInteractionHeight = res.getDimensionPixelSize(
|
||||
R.dimen.notification_min_interaction_height);
|
||||
mCornerRadius = res.getDimensionPixelSize(
|
||||
@@ -571,11 +555,15 @@ public class NotificationStackScrollLayout extends ViewGroup
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
|
||||
int width = MeasureSpec.getSize(widthMeasureSpec);
|
||||
int childWidthSpec = MeasureSpec.makeMeasureSpec(width - mSidePaddings * 2,
|
||||
MeasureSpec.getMode(widthMeasureSpec));
|
||||
// We need to measure all children even the GONE ones, such that the heights are calculated
|
||||
// correctly as they are used to calculate how many we can fit on the screen.
|
||||
final int size = getChildCount();
|
||||
for (int i = 0; i < size; i++) {
|
||||
measureChild(getChildAt(i), widthMeasureSpec, heightMeasureSpec);
|
||||
measureChild(getChildAt(i), childWidthSpec, heightMeasureSpec);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2242,31 +2230,9 @@ public class NotificationStackScrollLayout extends ViewGroup
|
||||
mScrimController.setExcludedBackgroundArea(
|
||||
mFadingOut || mParentNotFullyVisible || mAmbientState.isDark() || mIsClipped ? null
|
||||
: mCurrentBounds);
|
||||
updateBackgroundPath();
|
||||
invalidate();
|
||||
}
|
||||
|
||||
private void updateBackgroundPath() {
|
||||
mBackgroundPath.reset();
|
||||
float topRoundness = 0;
|
||||
if (mFirstVisibleBackgroundChild != null) {
|
||||
topRoundness = mFirstVisibleBackgroundChild.getCurrentBackgroundRadiusTop();
|
||||
}
|
||||
topRoundness = onKeyguard() ? mCornerRadius : topRoundness;
|
||||
float bottomRoundNess = mCornerRadius;
|
||||
mBackgroundRadii[0] = topRoundness;
|
||||
mBackgroundRadii[1] = topRoundness;
|
||||
mBackgroundRadii[2] = topRoundness;
|
||||
mBackgroundRadii[3] = topRoundness;
|
||||
mBackgroundRadii[4] = bottomRoundNess;
|
||||
mBackgroundRadii[5] = bottomRoundNess;
|
||||
mBackgroundRadii[6] = bottomRoundNess;
|
||||
mBackgroundRadii[7] = bottomRoundNess;
|
||||
mBackgroundPath.addRoundRect(mCurrentSidePadding, mCurrentBounds.top,
|
||||
getWidth() - mCurrentSidePadding, mCurrentBounds.bottom, mBackgroundRadii,
|
||||
Path.Direction.CCW);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the background bounds to the new desired bounds
|
||||
*/
|
||||
@@ -2279,8 +2245,8 @@ public class NotificationStackScrollLayout extends ViewGroup
|
||||
mBackgroundBounds.left = mTempInt2[0];
|
||||
mBackgroundBounds.right = mTempInt2[0] + getWidth();
|
||||
}
|
||||
mBackgroundBounds.left += mCurrentSidePadding;
|
||||
mBackgroundBounds.right -= mCurrentSidePadding;
|
||||
mBackgroundBounds.left += mSidePaddings;
|
||||
mBackgroundBounds.right -= mSidePaddings;
|
||||
if (!mIsExpanded) {
|
||||
mBackgroundBounds.top = 0;
|
||||
mBackgroundBounds.bottom = 0;
|
||||
@@ -2892,8 +2858,7 @@ public class NotificationStackScrollLayout extends ViewGroup
|
||||
|
||||
private void applyRoundedNess() {
|
||||
if (mFirstVisibleBackgroundChild != null) {
|
||||
mFirstVisibleBackgroundChild.setTopRoundness(
|
||||
mStatusBarState == StatusBarState.KEYGUARD ? 1.0f : 0.0f,
|
||||
mFirstVisibleBackgroundChild.setTopRoundness(1.0f,
|
||||
mFirstVisibleBackgroundChild.isShown()
|
||||
&& !mChildrenToAddAnimated.contains(mFirstVisibleBackgroundChild));
|
||||
}
|
||||
@@ -2902,7 +2867,6 @@ public class NotificationStackScrollLayout extends ViewGroup
|
||||
mLastVisibleBackgroundChild.isShown()
|
||||
&& !mChildrenToAddAnimated.contains(mLastVisibleBackgroundChild));
|
||||
}
|
||||
updateBackgroundPath();
|
||||
invalidate();
|
||||
}
|
||||
|
||||
@@ -2912,7 +2876,6 @@ public class NotificationStackScrollLayout extends ViewGroup
|
||||
generateAddAnimation(child, false /* fromMoreCard */);
|
||||
updateAnimationState(child);
|
||||
updateChronometerForChild(child);
|
||||
updateCurrentSidePaddings(child);
|
||||
}
|
||||
|
||||
private void updateHideSensitiveForChild(View child) {
|
||||
@@ -4359,43 +4322,6 @@ public class NotificationStackScrollLayout extends ViewGroup
|
||||
public void setStatusBarState(int statusBarState) {
|
||||
mStatusBarState = statusBarState;
|
||||
mAmbientState.setStatusBarState(statusBarState);
|
||||
applyRoundedNess();
|
||||
updateSidePaddings();
|
||||
}
|
||||
|
||||
private void updateSidePaddings() {
|
||||
int sidePaddings = mStatusBarState == StatusBarState.KEYGUARD ? mLockscreenSidePaddings : 0;
|
||||
if (sidePaddings != mSidePaddings) {
|
||||
boolean animate = isShown();
|
||||
mSidePaddings = sidePaddings;
|
||||
PropertyAnimator.setProperty(this, SIDE_PADDINGS, sidePaddings,
|
||||
SIDE_PADDING_PROPERTIES, animate);
|
||||
}
|
||||
}
|
||||
|
||||
protected void setCurrentSidePadding(float sidePadding) {
|
||||
mCurrentSidePadding = sidePadding;
|
||||
updateBackground();
|
||||
applySidePaddingsToChildren();
|
||||
}
|
||||
|
||||
private void applySidePaddingsToChildren() {
|
||||
for (int i = 0; i < getChildCount(); i++) {
|
||||
View view = getChildAt(i);
|
||||
updateCurrentSidePaddings(view);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateCurrentSidePaddings(View view) {
|
||||
if (!(view instanceof ExpandableOutlineView)) {
|
||||
return;
|
||||
}
|
||||
ExpandableOutlineView outlineView = (ExpandableOutlineView) view;
|
||||
outlineView.setCurrentSidePaddings(mCurrentSidePadding);
|
||||
}
|
||||
|
||||
protected float getCurrentSidePadding() {
|
||||
return mCurrentSidePadding;
|
||||
}
|
||||
|
||||
public void setExpandingVelocity(float expandingVelocity) {
|
||||
|
||||
Reference in New Issue
Block a user