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

Commit ce07a81c authored by Fabian Kozynski's avatar Fabian Kozynski
Browse files

Fix QS expanding animation when there's scrolling

The bottom of QSContainerImpl has to be set to the bottom of the actual
view height. However, the bottom of the views that overlay the
background (and should pretend to be scrollable) should be corrected by
the interpolated scrolling range.

QS will draw behind the nav bar. This is only relevant when QS is long
(with media) and we are not using gesture nav. In that case, the bottom
padding/margin is enough that any buttons are still above the navbar.

Test: force scrolling and test manually
Change-Id: Ib0ffd1fe6824808fcf7a0774aa3523366cd869f9
parent 2f5313a7
Loading
Loading
Loading
Loading
+14 −11
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package com.android.systemui.qs;

import static android.app.StatusBarManager.DISABLE2_QUICK_SETTINGS;
import static android.content.res.Configuration.ORIENTATION_LANDSCAPE;

import android.content.Context;
import android.content.res.Configuration;
@@ -62,7 +61,7 @@ public class QSContainerImpl extends FrameLayout {
    private float mQsExpansion;
    private QSCustomizer mQSCustomizer;
    private View mDragHandle;
    private View mQSPanelContainer;
    private NonInterceptingScrollView mQSPanelContainer;

    private View mBackground;

@@ -127,18 +126,12 @@ public class QSContainerImpl extends FrameLayout {
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        // QSPanel will show as many rows as it can (up to TileLayout.MAX_ROWS) such that the
        // bottom and footer are inside the screen.
        Configuration config = getResources().getConfiguration();
        boolean navBelow = config.smallestScreenWidthDp >= 600
                || config.orientation != Configuration.ORIENTATION_LANDSCAPE;
        MarginLayoutParams layoutParams = (MarginLayoutParams) mQSPanelContainer.getLayoutParams();

        // The footer is pinned to the bottom of QSPanel (same bottoms), therefore we don't need to
        // subtract its height. We do not care if the collapsed notifications fit in the screen.
        int maxQs = getDisplayHeight() - layoutParams.topMargin - layoutParams.bottomMargin
                - getPaddingBottom();
        if (navBelow) {
            maxQs -= getResources().getDimensionPixelSize(R.dimen.navigation_bar_height);
        }

        int padding = mPaddingLeft + mPaddingRight + layoutParams.leftMargin
                + layoutParams.rightMargin;
@@ -217,12 +210,13 @@ public class QSContainerImpl extends FrameLayout {

    public void updateExpansion(boolean animate) {
        int height = calculateContainerHeight();
        int scrollBottom = calculateContainerBottom();
        setBottom(getTop() + height);
        mQSDetail.setBottom(getTop() + height);
        mQSDetail.setBottom(getTop() + scrollBottom);
        // Pin the drag handle to the bottom of the panel.
        mDragHandle.setTranslationY(height - mDragHandle.getHeight());
        mDragHandle.setTranslationY(scrollBottom - mDragHandle.getHeight());
        mBackground.setTop(mQSPanelContainer.getTop());
        updateBackgroundBottom(height, animate);
        updateBackgroundBottom(scrollBottom, animate);
    }

    private void updateBackgroundBottom(int height, boolean animated) {
@@ -246,6 +240,15 @@ public class QSContainerImpl extends FrameLayout {
                + mHeader.getHeight();
    }

    int calculateContainerBottom() {
        int heightOverride = mHeightOverride != -1 ? mHeightOverride : getMeasuredHeight();
        return mQSCustomizer.isCustomizing() ? mQSCustomizer.getHeight()
                : Math.round(mQsExpansion
                        * (heightOverride + mQSPanelContainer.getScrollRange()
                                - mQSPanelContainer.getScrollY() - mHeader.getHeight()))
                        + mHeader.getHeight();
    }

    public void setExpansion(float expansion) {
        mQsExpansion = expansion;
        mDragHandle.setAlpha(1.0f - expansion);