Merge "Let animations of insets controller can be disabled" into rvc-dev am: 299734b637 am: 3f6f662d51 am: 115e3a75a9
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11570106 Change-Id: I082ad1e4aaf53ff0dbfd439798f5afdea69e0123
This commit is contained in:
@@ -260,6 +260,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
|
||||
private final boolean mHasAnimationCallbacks;
|
||||
private final @InsetsType int mRequestedTypes;
|
||||
private final long mDurationMs;
|
||||
private final boolean mDisable;
|
||||
|
||||
private ThreadLocal<AnimationHandler> mSfAnimationHandlerThreadLocal =
|
||||
new ThreadLocal<AnimationHandler>() {
|
||||
@@ -272,11 +273,12 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
|
||||
};
|
||||
|
||||
public InternalAnimationControlListener(boolean show, boolean hasAnimationCallbacks,
|
||||
int requestedTypes) {
|
||||
int requestedTypes, boolean disable) {
|
||||
mShow = show;
|
||||
mHasAnimationCallbacks = hasAnimationCallbacks;
|
||||
mRequestedTypes = requestedTypes;
|
||||
mDurationMs = calculateDurationMs();
|
||||
mDisable = disable;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -284,6 +286,10 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
|
||||
mController = controller;
|
||||
if (DEBUG) Log.d(TAG, "default animation onReady types: " + types);
|
||||
|
||||
if (mDisable) {
|
||||
onAnimationFinish();
|
||||
return;
|
||||
}
|
||||
mAnimator = ValueAnimator.ofFloat(0f, 1f);
|
||||
mAnimator.setDuration(mDurationMs);
|
||||
mAnimator.setInterpolator(new LinearInterpolator());
|
||||
@@ -477,6 +483,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
|
||||
private DisplayCutout mLastDisplayCutout;
|
||||
private boolean mStartingAnimation;
|
||||
private int mCaptionInsetsHeight = 0;
|
||||
private boolean mAnimationsDisabled;
|
||||
|
||||
private Runnable mPendingControlTimeout = this::abortPendingImeControlRequest;
|
||||
private final ArrayList<OnControllableInsetsChangedListener> mControllableInsetsChangedListeners
|
||||
@@ -1213,8 +1220,8 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
|
||||
}
|
||||
|
||||
boolean hasAnimationCallbacks = mHost.hasAnimationCallbacks();
|
||||
final InternalAnimationControlListener listener =
|
||||
new InternalAnimationControlListener(show, hasAnimationCallbacks, types);
|
||||
final InternalAnimationControlListener listener = new InternalAnimationControlListener(
|
||||
show, hasAnimationCallbacks, types, mAnimationsDisabled);
|
||||
|
||||
// Show/hide animations always need to be relative to the display frame, in order that shown
|
||||
// and hidden state insets are correct.
|
||||
@@ -1329,6 +1336,11 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
|
||||
return mHost.getSystemBarsBehavior();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAnimationsDisabled(boolean disable) {
|
||||
mAnimationsDisabled = disable;
|
||||
}
|
||||
|
||||
private @InsetsType int calculateControllableTypes() {
|
||||
@InsetsType int result = 0;
|
||||
for (int i = mSourceConsumers.size() - 1; i >= 0; i--) {
|
||||
|
||||
@@ -38,6 +38,7 @@ public class PendingInsetsController implements WindowInsetsController {
|
||||
private @Appearance int mAppearance;
|
||||
private @Appearance int mAppearanceMask;
|
||||
private @Behavior int mBehavior = KEEP_BEHAVIOR;
|
||||
private boolean mAnimationsDisabled;
|
||||
private final InsetsState mDummyState = new InsetsState();
|
||||
private InsetsController mReplayedInsetsController;
|
||||
private ArrayList<OnControllableInsetsChangedListener> mControllableInsetsChangedListeners
|
||||
@@ -102,6 +103,15 @@ public class PendingInsetsController implements WindowInsetsController {
|
||||
return mBehavior;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAnimationsDisabled(boolean disable) {
|
||||
if (mReplayedInsetsController != null) {
|
||||
mReplayedInsetsController.setAnimationsDisabled(disable);
|
||||
} else {
|
||||
mAnimationsDisabled = disable;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public InsetsState getState() {
|
||||
return mDummyState;
|
||||
@@ -151,6 +161,9 @@ public class PendingInsetsController implements WindowInsetsController {
|
||||
if (mCaptionInsetsHeight != 0) {
|
||||
controller.setCaptionInsetsHeight(mCaptionInsetsHeight);
|
||||
}
|
||||
if (mAnimationsDisabled) {
|
||||
controller.setAnimationsDisabled(true);
|
||||
}
|
||||
int size = mRequests.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
mRequests.get(i).replay(controller);
|
||||
@@ -167,6 +180,7 @@ public class PendingInsetsController implements WindowInsetsController {
|
||||
mBehavior = KEEP_BEHAVIOR;
|
||||
mAppearance = 0;
|
||||
mAppearanceMask = 0;
|
||||
mAnimationsDisabled = false;
|
||||
|
||||
// After replaying, we forward everything directly to the replayed instance.
|
||||
mReplayedInsetsController = controller;
|
||||
|
||||
@@ -221,6 +221,13 @@ public interface WindowInsetsController {
|
||||
*/
|
||||
@Behavior int getSystemBarsBehavior();
|
||||
|
||||
/**
|
||||
* Disables or enables the animations.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
void setAnimationsDisabled(boolean disable);
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
|
||||
@@ -459,6 +459,18 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartedWakingUp() {
|
||||
mStatusBar.getNotificationShadeWindowView().getWindowInsetsController()
|
||||
.setAnimationsDisabled(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartedGoingToSleep() {
|
||||
mStatusBar.getNotificationShadeWindowView().getWindowInsetsController()
|
||||
.setAnimationsDisabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinishedGoingToSleep() {
|
||||
mBouncer.onScreenTurnedOff();
|
||||
|
||||
@@ -384,7 +384,7 @@ class InsetsPolicy {
|
||||
InsetsPolicyAnimationControlCallbacks mControlCallbacks;
|
||||
|
||||
InsetsPolicyAnimationControlListener(boolean show, Runnable finishCallback, int types) {
|
||||
super(show, false /* hasCallbacks */, types);
|
||||
super(show, false /* hasCallbacks */, types, false /* disable */);
|
||||
mFinishCallback = finishCallback;
|
||||
mControlCallbacks = new InsetsPolicyAnimationControlCallbacks(this);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user