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

This commit is contained in:
Mike Schneider
2022-09-09 05:03:40 +00:00
committed by Android (Google) Code Review

View File

@@ -16,6 +16,7 @@ package com.android.systemui.qs;
import android.animation.TimeInterpolator; import android.animation.TimeInterpolator;
import android.animation.ValueAnimator; import android.animation.ValueAnimator;
import android.annotation.NonNull;
import android.util.Log; import android.util.Log;
import android.util.Pair; import android.util.Pair;
import android.util.SparseArray; 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.QS;
import com.android.systemui.plugins.qs.QSTile; import com.android.systemui.plugins.qs.QSTile;
import com.android.systemui.plugins.qs.QSTileView; 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.QSPanel.QSTileLayout;
import com.android.systemui.qs.TouchAnimator.Builder; 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.dagger.QSScope;
import com.android.systemui.qs.tileimpl.HeightOverrideable; import com.android.systemui.qs.tileimpl.HeightOverrideable;
import com.android.systemui.tuner.TunerService; import com.android.systemui.tuner.TunerService;
import com.android.systemui.tuner.TunerService.Tunable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
@@ -47,16 +44,26 @@ import java.util.concurrent.Executor;
import javax.inject.Inject; 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 @QSScope
public class QSAnimator implements Callback, PageListener, Listener, OnLayoutChangeListener, public class QSAnimator implements QSHost.Callback, PagedTileLayout.PageListener,
OnAttachStateChangeListener, Tunable { TouchAnimator.Listener, OnLayoutChangeListener,
OnAttachStateChangeListener {
private static final String TAG = "QSAnimator"; 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; private static final float EXPANDED_TILE_DELAY = .86f;
//Non first page delays //Non first page delays
private static final float QS_TILE_LABEL_FADE_OUT_START = 0.15f; 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; public static final float SHORT_PARALLAX_AMOUNT = 0.1f;
/** /**
* List of all views that will be reset when clearing animation state * List of all views that will be reset when clearing animation state
* see {@link #clearAnimationState()} } * see {@link #clearAnimationState()} }
@@ -125,14 +131,11 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha
private boolean mNeedsAnimatorUpdate = false; private boolean mNeedsAnimatorUpdate = false;
private boolean mOnKeyguard; private boolean mOnKeyguard;
private boolean mAllowFancy;
private boolean mFullRows;
private int mNumQuickTiles; private int mNumQuickTiles;
private int mLastQQSTileHeight; private int mLastQQSTileHeight;
private float mLastPosition; private float mLastPosition;
private final QSTileHost mHost; private final QSTileHost mHost;
private final Executor mExecutor; private final Executor mExecutor;
private final TunerService mTunerService;
private boolean mShowCollapsedOnKeyguard; private boolean mShowCollapsedOnKeyguard;
private boolean mTranslateWhileExpanding; private boolean mTranslateWhileExpanding;
private int mQQSTop; private int mQQSTop;
@@ -153,7 +156,6 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha
mQuickStatusBarHeader = quickStatusBarHeader; mQuickStatusBarHeader = quickStatusBarHeader;
mHost = qsTileHost; mHost = qsTileHost;
mExecutor = executor; mExecutor = executor;
mTunerService = tunerService;
mQSExpansionPathInterpolator = qsExpansionPathInterpolator; mQSExpansionPathInterpolator = qsExpansionPathInterpolator;
mHost.addCallback(this); mHost.addCallback(this);
mQsPanelController.addOnAttachStateChangeListener(this); mQsPanelController.addOnAttachStateChangeListener(this);
@@ -199,7 +201,6 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha
setCurrentPosition(); setCurrentPosition();
} }
private void setCurrentPosition() { private void setCurrentPosition() {
setPosition(mLastPosition); setPosition(mLastPosition);
} }
@@ -210,30 +211,15 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha
} }
@Override @Override
public void onViewAttachedToWindow(@Nullable View v) { public void onViewAttachedToWindow(@NonNull View view) {
mTunerService.addTunable(this, ALLOW_FANCY_ANIMATION,
MOVE_FULL_ROWS);
}
@Override
public void onViewDetachedFromWindow(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(); updateAnimators();
} }
@Override
public void onViewDetachedFromWindow(@NonNull View v) {
mHost.removeCallback(this);
}
private void addNonFirstPageAnimators(int page) { private void addNonFirstPageAnimators(int page) {
Pair<HeightExpansionAnimator, TouchAnimator> pair = createSecondaryPageAnimators(page); Pair<HeightExpansionAnimator, TouchAnimator> pair = createSecondaryPageAnimators(page);
if (pair != null) { if (pair != null) {
@@ -339,8 +325,7 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha
View view = mQs.getView(); View view = mQs.getView();
// This case: less tiles to animate in small displays. // This case: less tiles to animate in small displays.
if (count < mQuickQSPanelController.getTileLayout().getNumVisibleTiles() if (count < mQuickQSPanelController.getTileLayout().getNumVisibleTiles()) {
&& mAllowFancy) {
// Quick tiles. // Quick tiles.
QSTileView quickTileView = mQuickQSPanelController.getTileView(tile); QSTileView quickTileView = mQuickQSPanelController.getTileView(tile);
if (quickTileView == null) continue; if (quickTileView == null) continue;
@@ -422,7 +407,7 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha
mAnimatedQsViews.add(tileView); mAnimatedQsViews.add(tileView);
mAllViews.add(quickTileView); mAllViews.add(quickTileView);
mAllViews.add(quickTileView.getSecondaryLabel()); mAllViews.add(quickTileView.getSecondaryLabel());
} else if (mFullRows && isIconInAnimatedRow(count)) { } else if (isIconInAnimatedRow(count)) {
firstPageBuilder.addFloat(tileView, "translationY", -heightDiff, 0); firstPageBuilder.addFloat(tileView, "translationY", -heightDiff, 0);
@@ -457,7 +442,6 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha
} }
} }
if (mAllowFancy) {
animateBrightnessSlider(firstPageBuilder); animateBrightnessSlider(firstPageBuilder);
mFirstPageAnimator = firstPageBuilder mFirstPageAnimator = firstPageBuilder
@@ -495,7 +479,6 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha
mOtherFirstPageTilesHeightAnimator.setInterpolator( mOtherFirstPageTilesHeightAnimator.setInterpolator(
mQSExpansionPathInterpolator.getYInterpolator()); mQSExpansionPathInterpolator.getYInterpolator());
} }
}
mNonfirstPageAlphaAnimator = nonFirstPageAlphaBuilder mNonfirstPageAlphaAnimator = nonFirstPageAlphaBuilder
.addFloat(mQuickQsPanel, "alpha", 1, 0) .addFloat(mQuickQsPanel, "alpha", 1, 0)
.addFloat(tileLayout, "alpha", 0, 1) .addFloat(tileLayout, "alpha", 0, 1)
@@ -639,7 +622,7 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha
} }
private void getRelativePositionInt(int[] loc1, View view, View parent) { private void getRelativePositionInt(int[] loc1, View view, View parent) {
if(view == parent || view == null) return; if (view == parent || view == null) return;
// Ignore tile pages as they can have some offset we don't want to take into account in // Ignore tile pages as they can have some offset we don't want to take into account in
// RTL. // RTL.
if (!isAPage(view)) { if (!isAPage(view)) {
@@ -672,7 +655,6 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha
} }
} }
mLastPosition = position; mLastPosition = position;
if (!mAllowFancy) return;
if (mOnFirstPage) { if (mOnFirstPage) {
mQuickQsPanel.setAlpha(1); mQuickQsPanel.setAlpha(1);
mFirstPageAnimator.setPosition(position); mFirstPageAnimator.setPosition(position);
@@ -807,6 +789,7 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha
private final ValueAnimator.AnimatorUpdateListener mUpdateListener = private final ValueAnimator.AnimatorUpdateListener mUpdateListener =
new ValueAnimator.AnimatorUpdateListener() { new ValueAnimator.AnimatorUpdateListener() {
float mLastT = -1; float mLastT = -1;
@Override @Override
public void onAnimationUpdate(ValueAnimator valueAnimator) { public void onAnimationUpdate(ValueAnimator valueAnimator) {
float t = valueAnimator.getAnimatedFraction(); float t = valueAnimator.getAnimatedFraction();