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

Commit 3d57bffa authored by Mike Schneider's avatar Mike Schneider Committed by Automerger Merge Worker
Browse files

Merge "Remove Tunables for QSAnimator, and add some documentation on what the...

Merge "Remove Tunables for QSAnimator, and add some documentation on what the class does." into tm-qpr-dev am: ec715df5

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



Change-Id: I755d6b3235a77ca47264149f3ab2b68f94611b0d
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 68cee5d9 ec715df5
Loading
Loading
Loading
Loading
+82 −99
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@ package com.android.systemui.qs;

import android.animation.TimeInterpolator;
import android.animation.ValueAnimator;
import android.annotation.NonNull;
import android.util.Log;
import android.util.Pair;
import android.util.SparseArray;
@@ -30,15 +31,11 @@ import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.plugins.qs.QS;
import com.android.systemui.plugins.qs.QSTile;
import com.android.systemui.plugins.qs.QSTileView;
import com.android.systemui.qs.PagedTileLayout.PageListener;
import com.android.systemui.qs.QSHost.Callback;
import com.android.systemui.qs.QSPanel.QSTileLayout;
import com.android.systemui.qs.TouchAnimator.Builder;
import com.android.systemui.qs.TouchAnimator.Listener;
import com.android.systemui.qs.dagger.QSScope;
import com.android.systemui.qs.tileimpl.HeightOverrideable;
import com.android.systemui.tuner.TunerService;
import com.android.systemui.tuner.TunerService.Tunable;

import java.util.ArrayList;
import java.util.Collection;
@@ -47,16 +44,26 @@ import java.util.concurrent.Executor;

import javax.inject.Inject;

/** */
/**
 * Performs the animated transition between the QQS and QS views.
 *
 * <p>The transition is driven externally via {@link #setPosition(float)}, where 0 is a fully
 * collapsed QQS and one a fully expanded QS.
 *
 * <p>This implementation maintains a set of {@code TouchAnimator} to transition the properties of
 * views both in QQS and QS. These {@code TouchAnimator} are re-created lazily if contents of either
 * view change, see {@link #requestAnimatorUpdate()}.
 *
 * <p>During the transition, both QS and QQS are visible. For overlapping tiles (Whenever the QS
 * shows the first page), the corresponding QS tiles are hidden until QS is fully expanded.
 */
@QSScope
public class QSAnimator implements Callback, PageListener, Listener, OnLayoutChangeListener,
        OnAttachStateChangeListener, Tunable {
public class QSAnimator implements QSHost.Callback, PagedTileLayout.PageListener,
        TouchAnimator.Listener, OnLayoutChangeListener,
        OnAttachStateChangeListener {

    private static final String TAG = "QSAnimator";

    private static final String ALLOW_FANCY_ANIMATION = "sysui_qs_fancy_anim";
    private static final String MOVE_FULL_ROWS = "sysui_qs_move_whole_rows";

    private static final float EXPANDED_TILE_DELAY = .86f;
    //Non first page delays
    private static final float QS_TILE_LABEL_FADE_OUT_START = 0.15f;
@@ -65,7 +72,6 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha

    public static final float SHORT_PARALLAX_AMOUNT = 0.1f;


    /**
     * List of all views that will be reset when clearing animation state
     * see {@link #clearAnimationState()} }
@@ -125,14 +131,11 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha
    private boolean mNeedsAnimatorUpdate = false;
    private boolean mOnKeyguard;

    private boolean mAllowFancy;
    private boolean mFullRows;
    private int mNumQuickTiles;
    private int mLastQQSTileHeight;
    private float mLastPosition;
    private final QSTileHost mHost;
    private final Executor mExecutor;
    private final TunerService mTunerService;
    private boolean mShowCollapsedOnKeyguard;
    private boolean mTranslateWhileExpanding;
    private int mQQSTop;
@@ -153,7 +156,6 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha
        mQuickStatusBarHeader = quickStatusBarHeader;
        mHost = qsTileHost;
        mExecutor = executor;
        mTunerService = tunerService;
        mQSExpansionPathInterpolator = qsExpansionPathInterpolator;
        mHost.addCallback(this);
        mQsPanelController.addOnAttachStateChangeListener(this);
@@ -199,7 +201,6 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha
        setCurrentPosition();
    }


    private void setCurrentPosition() {
        setPosition(mLastPosition);
    }
@@ -210,28 +211,13 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha
    }

    @Override
    public void onViewAttachedToWindow(@Nullable View v) {
        mTunerService.addTunable(this, ALLOW_FANCY_ANIMATION,
                MOVE_FULL_ROWS);
    public void onViewAttachedToWindow(@NonNull View view) {
        updateAnimators();
    }

    @Override
    public void onViewDetachedFromWindow(View v) {
    public void onViewDetachedFromWindow(@NonNull View v) {
        mHost.removeCallback(this);
        mTunerService.removeTunable(this);
    }

    @Override
    public void onTuningChanged(String key, String newValue) {
        if (ALLOW_FANCY_ANIMATION.equals(key)) {
            mAllowFancy = TunerService.parseIntegerSwitch(newValue, true);
            if (!mAllowFancy) {
                clearAnimationState();
            }
        } else if (MOVE_FULL_ROWS.equals(key)) {
            mFullRows = TunerService.parseIntegerSwitch(newValue, true);
        }
        updateAnimators();
    }

    private void addNonFirstPageAnimators(int page) {
@@ -339,8 +325,7 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha
                View view = mQs.getView();

                // This case: less tiles to animate in small displays.
                if (count < mQuickQSPanelController.getTileLayout().getNumVisibleTiles()
                        && mAllowFancy) {
                if (count < mQuickQSPanelController.getTileLayout().getNumVisibleTiles()) {
                    // Quick tiles.
                    QSTileView quickTileView = mQuickQSPanelController.getTileView(tile);
                    if (quickTileView == null) continue;
@@ -422,7 +407,7 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha
                    mAnimatedQsViews.add(tileView);
                    mAllViews.add(quickTileView);
                    mAllViews.add(quickTileView.getSecondaryLabel());
                } else if (mFullRows && isIconInAnimatedRow(count)) {
                } else if (isIconInAnimatedRow(count)) {

                    firstPageBuilder.addFloat(tileView, "translationY", -heightDiff, 0);

@@ -457,7 +442,6 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha
            }
        }

        if (mAllowFancy) {
        animateBrightnessSlider(firstPageBuilder);

        mFirstPageAnimator = firstPageBuilder
@@ -495,7 +479,6 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha
            mOtherFirstPageTilesHeightAnimator.setInterpolator(
                    mQSExpansionPathInterpolator.getYInterpolator());
        }
        }
        mNonfirstPageAlphaAnimator = nonFirstPageAlphaBuilder
                .addFloat(mQuickQsPanel, "alpha", 1, 0)
                .addFloat(tileLayout, "alpha", 0, 1)
@@ -672,7 +655,6 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha
            }
        }
        mLastPosition = position;
        if (!mAllowFancy) return;
        if (mOnFirstPage) {
            mQuickQsPanel.setAlpha(1);
            mFirstPageAnimator.setPosition(position);
@@ -807,6 +789,7 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha
        private final ValueAnimator.AnimatorUpdateListener mUpdateListener =
                new ValueAnimator.AnimatorUpdateListener() {
                    float mLastT = -1;

                    @Override
                    public void onAnimationUpdate(ValueAnimator valueAnimator) {
                        float t = valueAnimator.getAnimatedFraction();