Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ec723947 authored by Lyn Han's avatar Lyn Han
Browse files

Remove padding customization from stack scroller algorithm

Follow up to ag/13004818 - the normal divider height is now 0.5dp =>
4dp, which is not that different when compared to the divider
with increased height at 6dp.

This change simplifies padding math by removing the
- increased padding getter that ExpandableViews override
- padding map from stack scroll algorithm

Bug: 172289783
Test: visual, no regressions
Change-Id: I1183bdbcef81f0bb60bc07d71f9b5bb5f4dce50c
parent 012eb240
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -632,9 +632,6 @@
    <!-- The height of a notification header -->
    <dimen name="notification_header_height">53dp</dimen>

    <!-- The height of the divider between the individual notifications when the notification wants it to be increased. This is currently the case for notification groups -->
    <dimen name="notification_divider_height_increased">6dp</dimen>

    <!-- The height of the gap between adjacent notification sections. -->
    <dimen name="notification_section_divider_height">@dimen/notification_side_paddings</dimen>

+0 −22
Original line number Diff line number Diff line
@@ -331,7 +331,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
    private OnUserInteractionCallback mOnUserInteractionCallback;
    private NotificationGutsManager mNotificationGutsManager;
    private boolean mIsLowPriority;
    private boolean mIsColorized;
    private boolean mUseIncreasedCollapsedHeight;
    private boolean mUseIncreasedHeadsUpHeight;
    private float mTranslationWhenRemoved;
@@ -541,7 +540,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        for (NotificationContentView l : mLayouts) {
            l.onNotificationUpdated(mEntry);
        }
        mIsColorized = mEntry.getSbn().getNotification().isColorized();
        mShowingPublicInitialized = false;
        updateNotificationColor();
        if (mMenuRow != null) {
@@ -1624,8 +1622,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
                R.dimen.notification_max_heads_up_height_increased);

        Resources res = getResources();
        mIncreasedPaddingBetweenElements = res.getDimensionPixelSize(
                R.dimen.notification_divider_height_increased);
        mEnableNonGroupedNotificationExpand =
                res.getBoolean(R.bool.config_enableNonGroupedNotificationExpand);
        mShowGroupBackgroundWhenExpanded =
@@ -2843,24 +2839,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        MetricsLogger.action(mContext, event, userExpanded);
    }

    @Override
    public float getIncreasedPaddingAmount() {
        if (mIsSummaryWithChildren) {
            if (isGroupExpanded()) {
                return 1.0f;
            } else if (isUserLocked()) {
                return mChildrenContainer.getIncreasedPaddingAmount();
            }
        } else if (isColorized() && (!mIsLowPriority || isExpanded())) {
            return -1.0f;
        }
        return 0.0f;
    }

    private boolean isColorized() {
        return mIsColorized && mBgTint != NO_COLOR;
    }

    @Override
    protected boolean disallowSingleClick(MotionEvent event) {
        if (areGutsExposed()) {
+0 −9
Original line number Diff line number Diff line
@@ -499,15 +499,6 @@ public abstract class ExpandableView extends FrameLayout implements Dumpable {
        return super.hasOverlappingRendering() && getActualHeight() <= getHeight();
    }

    /**
     * @return an amount between -1 and 1 of increased padding that this child needs. 1 means it
     * needs a full increased padding while -1 means it needs no padding at all. For 0.0f the normal
     * padding is applied.
     */
    public float getIncreasedPaddingAmount() {
        return 0.0f;
    }

    public boolean mustStayOnScreen() {
        return false;
    }
+0 −7
Original line number Diff line number Diff line
@@ -1271,13 +1271,6 @@ public class NotificationChildrenContainer extends ViewGroup {
        }
    }

    public float getIncreasedPaddingAmount() {
        if (showingAsLowPriority()) {
            return 0.0f;
        }
        return getGroupExpandFraction();
    }

    @VisibleForTesting
    public boolean isUserLocked() {
        return mUserLocked;
+7 −83
Original line number Diff line number Diff line
@@ -198,7 +198,6 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
    private int mIntrinsicContentHeight;
    private int mCollapsedSize;
    private int mPaddingBetweenElements;
    private int mIncreasedPaddingBetweenElements;
    private int mMaxTopPadding;
    private int mTopPadding;
    private int mBottomMargin;
@@ -883,8 +882,6 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
        mAmbientState.reload(context);
        mPaddingBetweenElements = Math.max(1,
                res.getDimensionPixelSize(R.dimen.notification_divider_height));
        mIncreasedPaddingBetweenElements =
                res.getDimensionPixelSize(R.dimen.notification_divider_height_increased);
        mMinTopOverScrollToEscape = res.getDimensionPixelSize(
                R.dimen.min_top_overscroll_to_qs);
        mStatusBarHeight = res.getDimensionPixelSize(R.dimen.status_bar_height);
@@ -1101,11 +1098,8 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
            for (int i = 0; i < getChildCount(); i++) {
                ExpandableView child = (ExpandableView) getChildAt(i);
                if (mChildrenToAddAnimated.contains(child)) {
                    int startingPosition = getPositionInLinearLayout(child);
                    float increasedPaddingAmount = child.getIncreasedPaddingAmount();
                    int padding = increasedPaddingAmount == 1.0f ? mIncreasedPaddingBetweenElements
                            : increasedPaddingAmount == -1.0f ? 0 : mPaddingBetweenElements;
                    int childHeight = getIntrinsicHeight(child) + padding;
                    final int startingPosition = getPositionInLinearLayout(child);
                    final int childHeight = getIntrinsicHeight(child) + mPaddingBetweenElements;
                    if (startingPosition < mOwnScrollY) {
                        // This child starts off screen, so let's keep it offscreen to keep the
                        // others visible
@@ -2299,7 +2293,6 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
    private void updateContentHeight() {
        int height = 0;
        float previousPaddingRequest = mPaddingBetweenElements;
        float previousPaddingAmount = 0.0f;
        int numShownItems = 0;
        boolean finish = false;
        int maxDisplayedNotifications = mMaxDisplayedNotifications;
@@ -2318,37 +2311,10 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
                } else {
                    viewHeight = expandableView.getIntrinsicHeight();
                }
                float increasedPaddingAmount = expandableView.getIncreasedPaddingAmount();
                float padding;
                if (increasedPaddingAmount >= 0.0f) {
                    padding = (int) NotificationUtils.interpolate(
                            previousPaddingRequest,
                            mIncreasedPaddingBetweenElements,
                            increasedPaddingAmount);
                    previousPaddingRequest = (int) NotificationUtils.interpolate(
                            mPaddingBetweenElements,
                            mIncreasedPaddingBetweenElements,
                            increasedPaddingAmount);
                } else {
                    int ownPadding = (int) NotificationUtils.interpolate(
                            0,
                            mPaddingBetweenElements,
                            1.0f + increasedPaddingAmount);
                    if (previousPaddingAmount > 0.0f) {
                        padding = (int) NotificationUtils.interpolate(
                                ownPadding,
                                mIncreasedPaddingBetweenElements,
                                previousPaddingAmount);
                    } else {
                        padding = ownPadding;
                    }
                    previousPaddingRequest = ownPadding;
                }
                if (height != 0) {
                    height += padding;
                    height += mPaddingBetweenElements;
                }
                height += calculateGapHeight(previousView, expandableView, numShownItems);
                previousPaddingAmount = increasedPaddingAmount;
                height += viewHeight;
                numShownItems++;
                previousView = expandableView;
@@ -3056,22 +3022,9 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
            }
            updateOnScrollChange();
        } else {
            int startingPosition = getPositionInLinearLayout(removedChild);
            float increasedPaddingAmount = removedChild.getIncreasedPaddingAmount();
            int padding;
            if (increasedPaddingAmount >= 0) {
                padding = (int) NotificationUtils.interpolate(
                        mPaddingBetweenElements,
                        mIncreasedPaddingBetweenElements,
                        increasedPaddingAmount);
            } else {
                padding = (int) NotificationUtils.interpolate(
                        0,
                        mPaddingBetweenElements,
                        1.0f + increasedPaddingAmount);
            }
            int childHeight = getIntrinsicHeight(removedChild) + padding;
            int endPosition = startingPosition + childHeight;
            final int startingPosition = getPositionInLinearLayout(removedChild);
            final int childHeight = getIntrinsicHeight(removedChild) + mPaddingBetweenElements;
            final int endPosition = startingPosition + childHeight;
            if (endPosition <= mOwnScrollY) {
                // This child is fully scrolled of the top, so we have to deduct its height from the
                // scrollPosition
@@ -3104,42 +3057,13 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
            requestedView = requestedRow = childInGroup.getNotificationParent();
        }
        int position = 0;
        float previousPaddingRequest = mPaddingBetweenElements;
        float previousPaddingAmount = 0.0f;
        for (int i = 0; i < getChildCount(); i++) {
            ExpandableView child = (ExpandableView) getChildAt(i);
            boolean notGone = child.getVisibility() != View.GONE;
            if (notGone && !child.hasNoContentHeight()) {
                float increasedPaddingAmount = child.getIncreasedPaddingAmount();
                float padding;
                if (increasedPaddingAmount >= 0.0f) {
                    padding = (int) NotificationUtils.interpolate(
                            previousPaddingRequest,
                            mIncreasedPaddingBetweenElements,
                            increasedPaddingAmount);
                    previousPaddingRequest = (int) NotificationUtils.interpolate(
                            mPaddingBetweenElements,
                            mIncreasedPaddingBetweenElements,
                            increasedPaddingAmount);
                } else {
                    int ownPadding = (int) NotificationUtils.interpolate(
                            0,
                            mPaddingBetweenElements,
                            1.0f + increasedPaddingAmount);
                    if (previousPaddingAmount > 0.0f) {
                        padding = (int) NotificationUtils.interpolate(
                                ownPadding,
                                mIncreasedPaddingBetweenElements,
                                previousPaddingAmount);
                    } else {
                        padding = ownPadding;
                    }
                    previousPaddingRequest = ownPadding;
                }
                if (position != 0) {
                    position += padding;
                    position += mPaddingBetweenElements;
                }
                previousPaddingAmount = increasedPaddingAmount;
            }
            if (child == requestedView) {
                if (requestedRow != null) {
Loading