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

Commit 3da27148 authored by Selim Cinek's avatar Selim Cinek Committed by Automerger Merge Worker
Browse files

Merge "Animating the qs / notification bounds now when dismissing media" into sc-dev am: 5b4a42f6

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15105255

Change-Id: I462706014650abd8c8b2124d573eb321496b01a8
parents 02a8eda2 5b4a42f6
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -23,6 +23,8 @@ import com.android.systemui.plugins.annotations.DependsOn;
import com.android.systemui.plugins.annotations.ProvidesInterface;
import com.android.systemui.plugins.qs.QS.HeightListener;

import java.util.function.Consumer;

/**
 * Fragment that contains QS in the notification shade.  Most of the interface is for
 * handling the expand/collapsing of the view interaction.
@@ -33,7 +35,7 @@ public interface QS extends FragmentBase {

    String ACTION = "com.android.systemui.action.PLUGIN_QS";

    int VERSION = 9;
    int VERSION = 10;

    String TAG = "QS";

@@ -101,6 +103,11 @@ public interface QS extends FragmentBase {
        return true;
    }

    /**
     * Add a listener for when the collapsed media visibility changes.
     */
    void setCollapsedMediaVisibilityChangedListener(Consumer<Boolean> listener);

    @ProvidesInterface(version = HeightListener.VERSION)
    interface HeightListener {
        int VERSION = 1;
+1 −61
Original line number Diff line number Diff line
@@ -28,12 +28,8 @@ import android.view.View;
import android.view.WindowInsets;
import android.widget.FrameLayout;

import androidx.dynamicanimation.animation.FloatPropertyCompat;
import androidx.dynamicanimation.animation.SpringForce;

import com.android.systemui.R;
import com.android.systemui.qs.customize.QSCustomizer;
import com.android.wm.shell.animation.PhysicsAnimator;

/**
 * Wrapper view with background which contains {@link QSPanel} and {@link QuickStatusBarHeader}
@@ -41,26 +37,10 @@ import com.android.wm.shell.animation.PhysicsAnimator;
public class QSContainerImpl extends FrameLayout {

    private final Point mSizePoint = new Point();
    private static final FloatPropertyCompat<QSContainerImpl> BACKGROUND_BOTTOM =
            new FloatPropertyCompat<QSContainerImpl>("backgroundBottom") {
                @Override
                public float getValue(QSContainerImpl qsImpl) {
                    return qsImpl.getBackgroundBottom();
                }

                @Override
                public void setValue(QSContainerImpl background, float value) {
                    background.setBackgroundBottom((int) value);
                }
            };
    private static final PhysicsAnimator.SpringConfig BACKGROUND_SPRING
            = new PhysicsAnimator.SpringConfig(SpringForce.STIFFNESS_MEDIUM,
            SpringForce.DAMPING_RATIO_LOW_BOUNCY);
    private int mFancyClippingTop;
    private int mFancyClippingBottom;
    private final float[] mFancyClippingRadii = new float[] {0, 0, 0, 0, 0, 0, 0, 0};
    private  final Path mFancyClippingPath = new Path();
    private int mBackgroundBottom = 0;
    private int mHeightOverride = -1;
    private View mQSDetail;
    private QuickStatusBarHeader mHeader;
@@ -71,7 +51,6 @@ public class QSContainerImpl extends FrameLayout {
    private int mSideMargins;
    private boolean mQsDisabled;
    private int mContentPadding = -1;
    private boolean mAnimateBottomOnNextLayout;
    private int mNavBarInset = 0;
    private boolean mClippingEnabled;

@@ -86,11 +65,6 @@ public class QSContainerImpl extends FrameLayout {
        mQSDetail = findViewById(R.id.qs_detail);
        mHeader = findViewById(R.id.header);
        mQSCustomizer = findViewById(R.id.qs_customize);
        mHeader.getHeaderQsPanel().setMediaVisibilityChangedListener((visible) -> {
            if (mHeader.getHeaderQsPanel().isShown()) {
                mAnimateBottomOnNextLayout = true;
            }
        });
        setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
    }

@@ -99,20 +73,6 @@ public class QSContainerImpl extends FrameLayout {
        return false;
    }

    void onMediaVisibilityChanged(boolean qsVisible) {
        mAnimateBottomOnNextLayout = qsVisible;
    }

    private void setBackgroundBottom(int value) {
        // We're saving the bottom separately since otherwise the bottom would be overridden in
        // the layout and the animation wouldn't properly start at the old position.
        mBackgroundBottom = value;
    }

    private float getBackgroundBottom() {
        return mBackgroundBottom;
    }

    @Override
    protected void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
@@ -186,8 +146,7 @@ public class QSContainerImpl extends FrameLayout {
    @Override
    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
        super.onLayout(changed, left, top, right, bottom);
        updateExpansion(mAnimateBottomOnNextLayout /* animate */);
        mAnimateBottomOnNextLayout = false;
        updateExpansion();
        updateClippingPath();
    }

@@ -230,31 +189,12 @@ public class QSContainerImpl extends FrameLayout {
    }

    public void updateExpansion() {
        updateExpansion(false /* animate */);
    }

    public void updateExpansion(boolean animate) {
        int height = calculateContainerHeight();
        int scrollBottom = calculateContainerBottom();
        setBottom(getTop() + height);
        mQSDetail.setBottom(getTop() + scrollBottom);
        int qsDetailBottomMargin = ((MarginLayoutParams) mQSDetail.getLayoutParams()).bottomMargin;
        mQSDetail.setBottom(getTop() + scrollBottom - qsDetailBottomMargin);
        updateBackgroundBottom(scrollBottom, animate);
    }

    private void updateBackgroundBottom(int height, boolean animated) {
        PhysicsAnimator<QSContainerImpl> physicsAnimator = PhysicsAnimator.getInstance(this);
        if (physicsAnimator.isPropertyAnimating(BACKGROUND_BOTTOM) || animated) {
            // An animation is running or we want to animate
            // Let's make sure to set the currentValue again, since the call below might only
            // start in the next frame and otherwise we'd flicker
            BACKGROUND_BOTTOM.setValue(this, BACKGROUND_BOTTOM.getValue(this));
            physicsAnimator.spring(BACKGROUND_BOTTOM, height, BACKGROUND_SPRING).start();
        } else {
            BACKGROUND_BOTTOM.setValue(this, height);
        }

    }

    protected int calculateContainerHeight() {
+0 −6
Original line number Diff line number Diff line
@@ -61,12 +61,6 @@ public class QSContainerImplController extends ViewController<QSContainerImpl> {
    @Override
    protected void onViewAttached() {
        mView.updateResources(mQsPanelController, mQuickStatusBarHeaderController);
        mQsPanelController.setMediaVisibilityChangedListener((visible) -> {
            if (mQsPanelController.isShown()) {
                mView.onMediaVisibilityChanged(true);
            }
        });

        mConfigurationController.addCallback(mConfigurationListener);
    }

+7 −0
Original line number Diff line number Diff line
@@ -53,6 +53,8 @@ import com.android.systemui.util.InjectionInflationController;
import com.android.systemui.util.LifecycleFragment;
import com.android.systemui.util.Utils;

import java.util.function.Consumer;

import javax.inject.Inject;
import javax.inject.Named;

@@ -281,6 +283,11 @@ public class QSFragment extends LifecycleFragment implements QS, CommandQueue.Ca
        return mLastQSExpansion == 0.0f || mLastQSExpansion == -1;
    }

    @Override
    public void setCollapsedMediaVisibilityChangedListener(Consumer<Boolean> listener) {
        mQuickQSPanelController.setMediaVisibilityChangedListener(listener);
    }

    private void setEditLocation(View view) {
        View edit = view.findViewById(android.R.id.edit);
        int[] loc = edit.getLocationOnScreen();
+0 −12
Original line number Diff line number Diff line
@@ -46,7 +46,6 @@ import com.android.systemui.util.animation.UniqueObjectHostView;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;

/** View that represents the quick settings tile panel (when expanded/pulled down). **/
public class QSPanel extends LinearLayout implements Tunable {
@@ -105,7 +104,6 @@ public class QSPanel extends LinearLayout implements Tunable {
    protected QSTileLayout mTileLayout;
    private int mLastOrientation = -1;
    private int mMediaTotalBottomMargin;
    private Consumer<Boolean> mMediaVisibilityChangedListener;

    public QSPanel(Context context, AttributeSet attrs) {
        super(context, attrs);
@@ -148,12 +146,6 @@ public class QSPanel extends LinearLayout implements Tunable {
        }
    }

    protected void onMediaVisibilityChanged(Boolean visible) {
        if (mMediaVisibilityChangedListener != null) {
            mMediaVisibilityChangedListener.accept(visible);
        }
    }

    /**
     * Add brightness view above the tile layout.
     *
@@ -667,10 +659,6 @@ public class QSPanel extends LinearLayout implements Tunable {
        mHeaderContainer = headerContainer;
    }

    public void setMediaVisibilityChangedListener(Consumer<Boolean> visibilityChangedListener) {
        mMediaVisibilityChangedListener = visibilityChangedListener;
    }

    public boolean isListening() {
        return mListening;
    }
Loading