summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorTiger Huang <tigerhuang@google.com>2021-05-25 17:12:16 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2021-05-25 17:12:16 +0000
commitea428b55e7b6f58b4e09654c854ec490cd342e7b (patch)
treed56457f32cdd3a7a4761450fb6800a047da1bd0a /core/java
parentf294d0ba5fd8ed38b6ac4ae6b2de48f1ec067669 (diff)
parent1ce223481a24c2bc4ee7b49d0435f2f775e1a14b (diff)
Merge "Flush the animation if it is canceled" into sc-dev
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/view/InsetsAnimationControlImpl.java15
-rw-r--r--core/java/android/view/InsetsAnimationThreadControlRunner.java14
-rw-r--r--core/java/android/view/InsetsController.java5
3 files changed, 23 insertions, 11 deletions
diff --git a/core/java/android/view/InsetsAnimationControlImpl.java b/core/java/android/view/InsetsAnimationControlImpl.java
index 3255dd65b193..b3caac07aa61 100644
--- a/core/java/android/view/InsetsAnimationControlImpl.java
+++ b/core/java/android/view/InsetsAnimationControlImpl.java
@@ -28,6 +28,8 @@ import static android.view.InsetsAnimationControlImplProto.TMP_MATRIX;
import static android.view.InsetsController.ANIMATION_TYPE_SHOW;
import static android.view.InsetsController.AnimationType;
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_FLOATING;
import static android.view.InsetsState.ISIDE_LEFT;
@@ -85,6 +87,7 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll
private final Matrix mTmpMatrix = new Matrix();
private final InsetsState mInitialInsetsState;
private final @AnimationType int mAnimationType;
+ private final @LayoutInsetsDuringAnimation int mLayoutInsetsDuringAnimation;
private final @InsetsType int mTypes;
private @InsetsType int mControllingTypes;
private final InsetsAnimationControlCallbacks mController;
@@ -107,9 +110,10 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll
@VisibleForTesting
public InsetsAnimationControlImpl(SparseArray<InsetsSourceControl> controls,
@Nullable Rect frame, InsetsState state, WindowInsetsAnimationControlListener listener,
- @InsetsType int types,
- InsetsAnimationControlCallbacks controller, long durationMs, Interpolator interpolator,
- @AnimationType int animationType, CompatibilityInfo.Translator translator) {
+ @InsetsType int types, InsetsAnimationControlCallbacks controller, long durationMs,
+ Interpolator interpolator, @AnimationType int animationType,
+ @LayoutInsetsDuringAnimation int layoutInsetsDuringAnimation,
+ CompatibilityInfo.Translator translator) {
mControls = controls;
mListener = listener;
mTypes = types;
@@ -145,6 +149,7 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll
durationMs);
mAnimation.setAlpha(getCurrentAlpha());
mAnimationType = animationType;
+ mLayoutInsetsDuringAnimation = layoutInsetsDuringAnimation;
mTranslator = translator;
mController.startAnimation(this, listener, types, mAnimation,
new Bounds(mHiddenInsets, mShownInsets));
@@ -299,6 +304,10 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll
if (mFinished) {
return;
}
+ mPendingInsets = mLayoutInsetsDuringAnimation == LAYOUT_INSETS_DURING_ANIMATION_SHOWN
+ ? mShownInsets : mHiddenInsets;
+ mPendingAlpha = 1f;
+ applyChangeInsets(null);
mCancelled = true;
mListener.onCancelled(mReadyDispatched ? this : null);
if (DEBUG) Log.d(TAG, "notify Control request cancelled for types: " + mTypes);
diff --git a/core/java/android/view/InsetsAnimationThreadControlRunner.java b/core/java/android/view/InsetsAnimationThreadControlRunner.java
index 436a17c0de0b..c6ebc9e52e84 100644
--- a/core/java/android/view/InsetsAnimationThreadControlRunner.java
+++ b/core/java/android/view/InsetsAnimationThreadControlRunner.java
@@ -29,6 +29,7 @@ import android.util.Log;
import android.util.SparseArray;
import android.util.proto.ProtoOutputStream;
import android.view.InsetsController.AnimationType;
+import android.view.InsetsController.LayoutInsetsDuringAnimation;
import android.view.SyncRtSurfaceTransactionApplier.SurfaceParams;
import android.view.WindowInsets.Type.InsetsType;
import android.view.WindowInsetsAnimation.Bounds;
@@ -103,14 +104,15 @@ public class InsetsAnimationThreadControlRunner implements InsetsAnimationContro
@UiThread
public InsetsAnimationThreadControlRunner(SparseArray<InsetsSourceControl> controls,
@Nullable Rect frame, InsetsState state, WindowInsetsAnimationControlListener listener,
- @InsetsType int types,
- InsetsAnimationControlCallbacks controller, long durationMs, Interpolator interpolator,
- @AnimationType int animationType, CompatibilityInfo.Translator translator,
- Handler mainThreadHandler) {
+ @InsetsType int types, InsetsAnimationControlCallbacks controller, long durationMs,
+ Interpolator interpolator, @AnimationType int animationType,
+ @LayoutInsetsDuringAnimation int layoutInsetsDuringAnimation,
+ CompatibilityInfo.Translator translator, Handler mainThreadHandler) {
mMainThreadHandler = mainThreadHandler;
mOuterCallbacks = controller;
- mControl = new InsetsAnimationControlImpl(controls, frame, state, listener,
- types, mCallbacks, durationMs, interpolator, animationType, translator);
+ mControl = new InsetsAnimationControlImpl(controls, frame, state, listener, types,
+ mCallbacks, durationMs, interpolator, animationType, layoutInsetsDuringAnimation,
+ translator);
InsetsAnimationThread.getHandler().post(() -> {
if (mControl.isCancelled()) {
return;
diff --git a/core/java/android/view/InsetsController.java b/core/java/android/view/InsetsController.java
index d17b42edb815..d339c0471125 100644
--- a/core/java/android/view/InsetsController.java
+++ b/core/java/android/view/InsetsController.java
@@ -1053,10 +1053,11 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
final InsetsAnimationControlRunner runner = useInsetsAnimationThread
? new InsetsAnimationThreadControlRunner(controls,
frame, mState, listener, typesReady, this, durationMs, interpolator,
- animationType, mHost.getTranslator(), mHost.getHandler())
+ animationType, layoutInsetsDuringAnimation, mHost.getTranslator(),
+ mHost.getHandler())
: new InsetsAnimationControlImpl(controls,
frame, mState, listener, typesReady, this, durationMs, interpolator,
- animationType, mHost.getTranslator());
+ animationType, layoutInsetsDuringAnimation, mHost.getTranslator());
if ((typesReady & WindowInsets.Type.ime()) != 0) {
ImeTracing.getInstance().triggerClientDump("InsetsAnimationControlImpl",
mHost.getInputMethodManager(), null /* icProto */);