Merge "Flush the animation if it is canceled" into sc-dev am: ea428b55e7
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14640272 Change-Id: I06940f0be00a298776f05fe22be17e4cbf8bc201
This commit is contained in:
@@ -28,6 +28,8 @@ import static android.view.InsetsAnimationControlImplProto.TMP_MATRIX;
|
|||||||
import static android.view.InsetsController.ANIMATION_TYPE_SHOW;
|
import static android.view.InsetsController.ANIMATION_TYPE_SHOW;
|
||||||
import static android.view.InsetsController.AnimationType;
|
import static android.view.InsetsController.AnimationType;
|
||||||
import static android.view.InsetsController.DEBUG;
|
import static android.view.InsetsController.DEBUG;
|
||||||
|
import static android.view.InsetsController.LAYOUT_INSETS_DURING_ANIMATION_SHOWN;
|
||||||
|
import static android.view.InsetsController.LayoutInsetsDuringAnimation;
|
||||||
import static android.view.InsetsState.ISIDE_BOTTOM;
|
import static android.view.InsetsState.ISIDE_BOTTOM;
|
||||||
import static android.view.InsetsState.ISIDE_FLOATING;
|
import static android.view.InsetsState.ISIDE_FLOATING;
|
||||||
import static android.view.InsetsState.ISIDE_LEFT;
|
import static android.view.InsetsState.ISIDE_LEFT;
|
||||||
@@ -85,6 +87,7 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll
|
|||||||
private final Matrix mTmpMatrix = new Matrix();
|
private final Matrix mTmpMatrix = new Matrix();
|
||||||
private final InsetsState mInitialInsetsState;
|
private final InsetsState mInitialInsetsState;
|
||||||
private final @AnimationType int mAnimationType;
|
private final @AnimationType int mAnimationType;
|
||||||
|
private final @LayoutInsetsDuringAnimation int mLayoutInsetsDuringAnimation;
|
||||||
private final @InsetsType int mTypes;
|
private final @InsetsType int mTypes;
|
||||||
private @InsetsType int mControllingTypes;
|
private @InsetsType int mControllingTypes;
|
||||||
private final InsetsAnimationControlCallbacks mController;
|
private final InsetsAnimationControlCallbacks mController;
|
||||||
@@ -107,9 +110,10 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll
|
|||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public InsetsAnimationControlImpl(SparseArray<InsetsSourceControl> controls,
|
public InsetsAnimationControlImpl(SparseArray<InsetsSourceControl> controls,
|
||||||
@Nullable Rect frame, InsetsState state, WindowInsetsAnimationControlListener listener,
|
@Nullable Rect frame, InsetsState state, WindowInsetsAnimationControlListener listener,
|
||||||
@InsetsType int types,
|
@InsetsType int types, InsetsAnimationControlCallbacks controller, long durationMs,
|
||||||
InsetsAnimationControlCallbacks controller, long durationMs, Interpolator interpolator,
|
Interpolator interpolator, @AnimationType int animationType,
|
||||||
@AnimationType int animationType, CompatibilityInfo.Translator translator) {
|
@LayoutInsetsDuringAnimation int layoutInsetsDuringAnimation,
|
||||||
|
CompatibilityInfo.Translator translator) {
|
||||||
mControls = controls;
|
mControls = controls;
|
||||||
mListener = listener;
|
mListener = listener;
|
||||||
mTypes = types;
|
mTypes = types;
|
||||||
@@ -145,6 +149,7 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll
|
|||||||
durationMs);
|
durationMs);
|
||||||
mAnimation.setAlpha(getCurrentAlpha());
|
mAnimation.setAlpha(getCurrentAlpha());
|
||||||
mAnimationType = animationType;
|
mAnimationType = animationType;
|
||||||
|
mLayoutInsetsDuringAnimation = layoutInsetsDuringAnimation;
|
||||||
mTranslator = translator;
|
mTranslator = translator;
|
||||||
mController.startAnimation(this, listener, types, mAnimation,
|
mController.startAnimation(this, listener, types, mAnimation,
|
||||||
new Bounds(mHiddenInsets, mShownInsets));
|
new Bounds(mHiddenInsets, mShownInsets));
|
||||||
@@ -299,6 +304,10 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll
|
|||||||
if (mFinished) {
|
if (mFinished) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
mPendingInsets = mLayoutInsetsDuringAnimation == LAYOUT_INSETS_DURING_ANIMATION_SHOWN
|
||||||
|
? mShownInsets : mHiddenInsets;
|
||||||
|
mPendingAlpha = 1f;
|
||||||
|
applyChangeInsets(null);
|
||||||
mCancelled = true;
|
mCancelled = true;
|
||||||
mListener.onCancelled(mReadyDispatched ? this : null);
|
mListener.onCancelled(mReadyDispatched ? this : null);
|
||||||
if (DEBUG) Log.d(TAG, "notify Control request cancelled for types: " + mTypes);
|
if (DEBUG) Log.d(TAG, "notify Control request cancelled for types: " + mTypes);
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import android.util.Log;
|
|||||||
import android.util.SparseArray;
|
import android.util.SparseArray;
|
||||||
import android.util.proto.ProtoOutputStream;
|
import android.util.proto.ProtoOutputStream;
|
||||||
import android.view.InsetsController.AnimationType;
|
import android.view.InsetsController.AnimationType;
|
||||||
|
import android.view.InsetsController.LayoutInsetsDuringAnimation;
|
||||||
import android.view.SyncRtSurfaceTransactionApplier.SurfaceParams;
|
import android.view.SyncRtSurfaceTransactionApplier.SurfaceParams;
|
||||||
import android.view.WindowInsets.Type.InsetsType;
|
import android.view.WindowInsets.Type.InsetsType;
|
||||||
import android.view.WindowInsetsAnimation.Bounds;
|
import android.view.WindowInsetsAnimation.Bounds;
|
||||||
@@ -103,14 +104,15 @@ public class InsetsAnimationThreadControlRunner implements InsetsAnimationContro
|
|||||||
@UiThread
|
@UiThread
|
||||||
public InsetsAnimationThreadControlRunner(SparseArray<InsetsSourceControl> controls,
|
public InsetsAnimationThreadControlRunner(SparseArray<InsetsSourceControl> controls,
|
||||||
@Nullable Rect frame, InsetsState state, WindowInsetsAnimationControlListener listener,
|
@Nullable Rect frame, InsetsState state, WindowInsetsAnimationControlListener listener,
|
||||||
@InsetsType int types,
|
@InsetsType int types, InsetsAnimationControlCallbacks controller, long durationMs,
|
||||||
InsetsAnimationControlCallbacks controller, long durationMs, Interpolator interpolator,
|
Interpolator interpolator, @AnimationType int animationType,
|
||||||
@AnimationType int animationType, CompatibilityInfo.Translator translator,
|
@LayoutInsetsDuringAnimation int layoutInsetsDuringAnimation,
|
||||||
Handler mainThreadHandler) {
|
CompatibilityInfo.Translator translator, Handler mainThreadHandler) {
|
||||||
mMainThreadHandler = mainThreadHandler;
|
mMainThreadHandler = mainThreadHandler;
|
||||||
mOuterCallbacks = controller;
|
mOuterCallbacks = controller;
|
||||||
mControl = new InsetsAnimationControlImpl(controls, frame, state, listener,
|
mControl = new InsetsAnimationControlImpl(controls, frame, state, listener, types,
|
||||||
types, mCallbacks, durationMs, interpolator, animationType, translator);
|
mCallbacks, durationMs, interpolator, animationType, layoutInsetsDuringAnimation,
|
||||||
|
translator);
|
||||||
InsetsAnimationThread.getHandler().post(() -> {
|
InsetsAnimationThread.getHandler().post(() -> {
|
||||||
if (mControl.isCancelled()) {
|
if (mControl.isCancelled()) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1053,10 +1053,11 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
|
|||||||
final InsetsAnimationControlRunner runner = useInsetsAnimationThread
|
final InsetsAnimationControlRunner runner = useInsetsAnimationThread
|
||||||
? new InsetsAnimationThreadControlRunner(controls,
|
? new InsetsAnimationThreadControlRunner(controls,
|
||||||
frame, mState, listener, typesReady, this, durationMs, interpolator,
|
frame, mState, listener, typesReady, this, durationMs, interpolator,
|
||||||
animationType, mHost.getTranslator(), mHost.getHandler())
|
animationType, layoutInsetsDuringAnimation, mHost.getTranslator(),
|
||||||
|
mHost.getHandler())
|
||||||
: new InsetsAnimationControlImpl(controls,
|
: new InsetsAnimationControlImpl(controls,
|
||||||
frame, mState, listener, typesReady, this, durationMs, interpolator,
|
frame, mState, listener, typesReady, this, durationMs, interpolator,
|
||||||
animationType, mHost.getTranslator());
|
animationType, layoutInsetsDuringAnimation, mHost.getTranslator());
|
||||||
if ((typesReady & WindowInsets.Type.ime()) != 0) {
|
if ((typesReady & WindowInsets.Type.ime()) != 0) {
|
||||||
ImeTracing.getInstance().triggerClientDump("InsetsAnimationControlImpl",
|
ImeTracing.getInstance().triggerClientDump("InsetsAnimationControlImpl",
|
||||||
mHost.getInputMethodManager(), null /* icProto */);
|
mHost.getInputMethodManager(), null /* icProto */);
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ public class InsetsAnimationControlImplTest {
|
|||||||
mController = new InsetsAnimationControlImpl(controls,
|
mController = new InsetsAnimationControlImpl(controls,
|
||||||
new Rect(0, 0, 500, 500), mInsetsState, mMockListener, systemBars(),
|
new Rect(0, 0, 500, 500), mInsetsState, mMockListener, systemBars(),
|
||||||
mMockController, 10 /* durationMs */, new LinearInterpolator(),
|
mMockController, 10 /* durationMs */, new LinearInterpolator(),
|
||||||
0 /* animationType */, null /* translator */);
|
0 /* animationType */, 0 /* layoutInsetsDuringAnimation */, null /* translator */);
|
||||||
mController.mReadyDispatched = true;
|
mController.mReadyDispatched = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
|
|||||||
import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY;
|
import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY;
|
||||||
import static android.view.InsetsController.ANIMATION_TYPE_HIDE;
|
import static android.view.InsetsController.ANIMATION_TYPE_HIDE;
|
||||||
import static android.view.InsetsController.ANIMATION_TYPE_SHOW;
|
import static android.view.InsetsController.ANIMATION_TYPE_SHOW;
|
||||||
|
import static android.view.InsetsController.LAYOUT_INSETS_DURING_ANIMATION_HIDDEN;
|
||||||
|
import static android.view.InsetsController.LAYOUT_INSETS_DURING_ANIMATION_SHOWN;
|
||||||
import static android.view.InsetsState.ITYPE_IME;
|
import static android.view.InsetsState.ITYPE_IME;
|
||||||
import static android.view.InsetsState.ITYPE_NAVIGATION_BAR;
|
import static android.view.InsetsState.ITYPE_NAVIGATION_BAR;
|
||||||
import static android.view.InsetsState.ITYPE_STATUS_BAR;
|
import static android.view.InsetsState.ITYPE_STATUS_BAR;
|
||||||
@@ -522,7 +524,10 @@ class InsetsPolicy {
|
|||||||
mAnimationControl = new InsetsAnimationControlImpl(controls,
|
mAnimationControl = new InsetsAnimationControlImpl(controls,
|
||||||
null /* frame */, state, mListener, typesReady, this,
|
null /* frame */, state, mListener, typesReady, this,
|
||||||
mListener.getDurationMs(), getInsetsInterpolator(),
|
mListener.getDurationMs(), getInsetsInterpolator(),
|
||||||
show ? ANIMATION_TYPE_SHOW : ANIMATION_TYPE_HIDE, null /* translator */);
|
show ? ANIMATION_TYPE_SHOW : ANIMATION_TYPE_HIDE, show
|
||||||
|
? LAYOUT_INSETS_DURING_ANIMATION_SHOWN
|
||||||
|
: LAYOUT_INSETS_DURING_ANIMATION_HIDDEN,
|
||||||
|
null /* translator */);
|
||||||
SurfaceAnimationThread.getHandler().post(
|
SurfaceAnimationThread.getHandler().post(
|
||||||
() -> mListener.onReady(mAnimationControl, typesReady));
|
() -> mListener.onReady(mAnimationControl, typesReady));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user