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

Commit 0b8068ea authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "sysui: refactored for extension."

parents 9a7fa83b 8779802f
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ import com.android.systemui.statusbar.policy.SecurityController;
import com.android.systemui.statusbar.policy.UserInfoController;
import com.android.systemui.statusbar.policy.UserSwitcherController;
import com.android.systemui.statusbar.policy.ZenModeController;
import com.android.systemui.statusbar.stack.StackScrollAlgorithm;

/**
 * Class factory to provide customizable SystemUI components.
@@ -115,4 +116,8 @@ public class SystemUIFactory {
    public <T> T createInstance(Class<T> classType) {
        return null;
    }

    public StackScrollAlgorithm createStackScrollAlgorithm(Context context) {
        return new StackScrollAlgorithm(context);
    }
}
+3 −5
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ import com.android.systemui.ExpandHelper;
import com.android.systemui.Interpolators;
import com.android.systemui.R;
import com.android.systemui.SwipeHelper;
import com.android.systemui.SystemUIFactory;
import com.android.systemui.classifier.FalsingManager;
import com.android.systemui.statusbar.ActivatableNotificationView;
import com.android.systemui.statusbar.DismissView;
@@ -141,7 +142,7 @@ public class NotificationStackScrollLayout extends ViewGroup
    /**
     * The algorithm which calculates the properties for our children
     */
    private final StackScrollAlgorithm mStackScrollAlgorithm;
    protected final StackScrollAlgorithm mStackScrollAlgorithm;

    /**
     * The current State this Layout is in
@@ -352,7 +353,7 @@ public class NotificationStackScrollLayout extends ViewGroup
        mExpandHelper.setScrollAdapter(this);
        mSwipeHelper = new NotificationSwipeHelper(SwipeHelper.X, this, getContext());
        mSwipeHelper.setLongPressListener(mLongPressListener);
        mStackScrollAlgorithm = new StackScrollAlgorithm(context);
        mStackScrollAlgorithm = SystemUIFactory.getInstance().createStackScrollAlgorithm(context);
        initView(context);
        setWillNotDraw(false);
        if (DEBUG) {
@@ -1053,7 +1054,6 @@ public class NotificationStackScrollLayout extends ViewGroup
                }
                boolean isBeingDragged = !mScroller.isFinished();
                setIsBeingDragged(isBeingDragged);

                /*
                 * If being flinged and user touches, stop the fling. isFinished
                 * will be false if being flinged.
@@ -1138,7 +1138,6 @@ public class NotificationStackScrollLayout extends ViewGroup
                            }
                        }
                    }

                    mActivePointerId = INVALID_POINTER;
                    endDrag();
                }
@@ -1320,7 +1319,6 @@ public class NotificationStackScrollLayout extends ViewGroup
            boolean isTouchEvent) {

        int newScrollY = scrollY + deltaY;

        final int top = -maxOverScrollY;
        final int bottom = maxOverScrollY + scrollRangeY;

+102 −89
Original line number Diff line number Diff line
@@ -359,14 +359,20 @@ public class StackScrollAlgorithm {

        // The y coordinate of the current child.
        float currentYPosition = -algorithmState.scrollY;

        int childCount = algorithmState.visibleChildren.size();
        int paddingAfterChild;
        for (int i = 0; i < childCount; i++) {
            currentYPosition = updateChild(i, resultState, algorithmState, ambientState,
                    currentYPosition, bottomStackStart);
        }
    }

    protected float updateChild(int i, StackScrollState resultState,
            StackScrollAlgorithmState algorithmState, AmbientState ambientState,
            float currentYPosition, float bottomStackStart) {
        ExpandableView child = algorithmState.visibleChildren.get(i);
        StackViewState childViewState = resultState.getViewStateForView(child);
        childViewState.location = StackViewState.LOCATION_UNKNOWN;
            paddingAfterChild = getPaddingAfterChild(algorithmState, child);
        int paddingAfterChild = getPaddingAfterChild(algorithmState, child);
        int childHeight = getMaxAllowedChildHeight(child);
        int collapsedHeight = child.getCollapsedHeight();
        childViewState.yTranslation = currentYPosition;
@@ -416,10 +422,10 @@ public class StackScrollAlgorithm {

        childViewState.yTranslation += ambientState.getTopPadding()
                + ambientState.getStackTranslation();
        }
        return currentYPosition;
    }

    private int getPaddingAfterChild(StackScrollAlgorithmState algorithmState,
    protected int getPaddingAfterChild(StackScrollAlgorithmState algorithmState,
            ExpandableView child) {
        Float paddingValue = algorithmState.increasedPaddingMap.get(child);
        return paddingValue == null
@@ -513,7 +519,7 @@ public class StackScrollAlgorithm {
        }
    }

    private int getMaxAllowedChildHeight(View child) {
    protected int getMaxAllowedChildHeight(View child) {
        if (child instanceof ExpandableView) {
            ExpandableView expandableView = (ExpandableView) child;
            return expandableView.getIntrinsicHeight();
@@ -581,7 +587,7 @@ public class StackScrollAlgorithm {
     * @param childHeight the height of the child
     * @param ambientState The ambient state of the algorithm
     */
    private void updateFirstChildHeight(ExpandableView child, StackViewState childViewState,
    protected void updateFirstChildHeight(ExpandableView child, StackViewState childViewState,
                                          int childHeight, AmbientState ambientState) {

            // The starting position of the bottom stack peek
@@ -604,6 +610,14 @@ public class StackScrollAlgorithm {
        int childCount = algorithmState.visibleChildren.size();
        float childrenOnTop = 0.0f;
        for (int i = childCount - 1; i >= 0; i--) {
            updateChildZValue(i, childCount, childrenOnTop,
                    resultState, algorithmState, ambientState);
        }
    }

    protected void updateChildZValue(int i, int childCount, float childrenOnTop,
            StackScrollState resultState, StackScrollAlgorithmState algorithmState,
            AmbientState ambientState) {
        ExpandableView child = algorithmState.visibleChildren.get(i);
        StackViewState childViewState = resultState.getViewStateForView(child);
        if (i > (childCount - 1 - algorithmState.itemsInBottomStack)) {
@@ -642,7 +656,6 @@ public class StackScrollAlgorithm {
            childViewState.zTranslation = mZBasicHeight;
        }
    }
    }

    private boolean isMaxSizeInitialized(ExpandableView child) {
        if (child instanceof ExpandableNotificationRow) {
@@ -667,7 +680,7 @@ public class StackScrollAlgorithm {
        this.mIsExpanded = isExpanded;
    }

    class StackScrollAlgorithmState {
    protected class StackScrollAlgorithmState {

        /**
         * The scroll position of the algorithm