From 020e628f22cc7975beab439c6da26af2f9ebc15b Mon Sep 17 00:00:00 2001 From: Jon Miranda Date: Mon, 28 Sep 2020 17:01:42 -0700 Subject: [PATCH] Add shadow radius to windows during app launch / close animations. Bug: 168608912 Change-Id: I2ec50b0b3711c0861659f9c641bbc05fcdeaab45 --- quickstep/res/values/dimens.xml | 2 ++ .../QuickstepAppTransitionManagerImpl.java | 12 ++++++++++-- .../android/quickstep/SwipeUpAnimationLogic.java | 13 +++++++++++-- .../android/quickstep/util/TaskViewSimulator.java | 3 ++- .../android/quickstep/util/TransformParams.java | 14 ++++++++++++++ 5 files changed, 39 insertions(+), 5 deletions(-) diff --git a/quickstep/res/values/dimens.xml b/quickstep/res/values/dimens.xml index c85fe6ca35..c7c0c7ed73 100644 --- a/quickstep/res/values/dimens.xml +++ b/quickstep/res/values/dimens.xml @@ -51,6 +51,8 @@ 16sp 16dp + 5dp + 40dp diff --git a/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java b/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java index dddcc865fa..6e567f792c 100644 --- a/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java +++ b/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java @@ -151,6 +151,7 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans private final float mContentTransY; private final float mWorkspaceTransY; private final float mClosingWindowTransY; + private final float mMaxShadowRadius; private DeviceProfile mDeviceProfile; @@ -184,6 +185,7 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans mContentTransY = res.getDimensionPixelSize(R.dimen.content_trans_y); mWorkspaceTransY = res.getDimensionPixelSize(R.dimen.workspace_trans_y); mClosingWindowTransY = res.getDimensionPixelSize(R.dimen.closing_window_trans_y); + mMaxShadowRadius = res.getDimensionPixelSize(R.dimen.max_shadow_radius); mLauncher.addOnDeviceProfileChangeListener(this); } @@ -536,6 +538,8 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans EXAGGERATED_EASE); FloatProp mWindowRadius = new FloatProp(initialWindowRadius, windowRadius, 0, RADIUS_DURATION, EXAGGERATED_EASE); + FloatProp mShadowRadius = new FloatProp(0, mMaxShadowRadius, 0, + APP_LAUNCH_DURATION, EXAGGERATED_EASE); @Override public void onUpdate(float percent) { @@ -598,7 +602,8 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans builder.withMatrix(matrix) .withWindowCrop(crop) .withAlpha(1f - mIconAlpha.value) - .withCornerRadius(mWindowRadius.value); + .withCornerRadius(mWindowRadius.value) + .withShadowRadius(mShadowRadius.value); } else { tmpPos.set(target.position.x, target.position.y); if (target.localBounds != null) { @@ -748,6 +753,8 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans FloatProp mDy = new FloatProp(0, mClosingWindowTransY, 0, duration, DEACCEL_1_7); FloatProp mScale = new FloatProp(1f, 1f, 0, duration, DEACCEL_1_7); FloatProp mAlpha = new FloatProp(1f, 0f, 25, 125, LINEAR); + FloatProp mShadowRadius = new FloatProp(mMaxShadowRadius, 0, 0, duration, + DEACCEL_1_7); @Override public void onUpdate(float percent) { @@ -769,7 +776,8 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans matrix.postTranslate(tmpPos.x, tmpPos.y); builder.withMatrix(matrix) .withAlpha(mAlpha.value) - .withCornerRadius(windowCornerRadius); + .withCornerRadius(windowCornerRadius) + .withShadowRadius(mShadowRadius.value); } else { matrix.setTranslate(tmpPos.x, tmpPos.y); builder.withMatrix(matrix) diff --git a/quickstep/src/com/android/quickstep/SwipeUpAnimationLogic.java b/quickstep/src/com/android/quickstep/SwipeUpAnimationLogic.java index b6eaa1c7b6..a46de1f601 100644 --- a/quickstep/src/com/android/quickstep/SwipeUpAnimationLogic.java +++ b/quickstep/src/com/android/quickstep/SwipeUpAnimationLogic.java @@ -29,6 +29,7 @@ import androidx.annotation.NonNull; import androidx.annotation.UiThread; import com.android.launcher3.DeviceProfile; +import com.android.launcher3.R; import com.android.launcher3.Utilities; import com.android.launcher3.anim.AnimationSuccessListener; import com.android.launcher3.anim.AnimatorPlaybackController; @@ -66,6 +67,8 @@ public abstract class SwipeUpAnimationLogic { // How much further we can drag past recents, as a factor of mTransitionDragLength. protected float mDragLengthFactor = 1; + protected final float mMaxShadowRadius; + protected AnimatorControllerWithResistance mWindowTransitionController; public SwipeUpAnimationLogic(Context context, RecentsAnimationDeviceState deviceState, @@ -80,6 +83,9 @@ public abstract class SwipeUpAnimationLogic { mDeviceState.getRotationTouchHelper().getCurrentActiveRotation(), mDeviceState.getRotationTouchHelper().getDisplayRotation()); mTaskViewSimulator.setDrawsBelowRecents(true); + + mMaxShadowRadius = context.getResources().getDimensionPixelSize(R.dimen.max_shadow_radius); + mTransformParams.setShadowRadius(mMaxShadowRadius); } protected void initTransitionEndpoints(DeviceProfile dp) { @@ -251,9 +257,11 @@ public abstract class SwipeUpAnimationLogic { mMatrix.setRectToRect(mCropRectF, mWindowCurrentRect, ScaleToFit.FILL); float cornerRadius = Utilities.mapRange(progress, mStartRadius, mEndRadius); + float shadowRadius = Utilities.mapRange(progress, mMaxShadowRadius, 0); mTransformParams .setTargetAlpha(getWindowAlpha(progress)) - .setCornerRadius(cornerRadius); + .setCornerRadius(cornerRadius) + .setShadowRadius(mMaxShadowRadius); mTransformParams.applySurfaceParams(mTransformParams.createSurfaceParams(this)); mAnimationFactory.update(currentRect, progress, mMatrix.mapRadius(cornerRadius)); @@ -264,7 +272,8 @@ public abstract class SwipeUpAnimationLogic { Builder builder, RemoteAnimationTargetCompat app, TransformParams params) { builder.withMatrix(mMatrix) .withWindowCrop(mCropRect) - .withCornerRadius(params.getCornerRadius()); + .withCornerRadius(params.getCornerRadius()) + .withShadowRadius(params.getShadowRadius()); } @Override diff --git a/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java b/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java index 3a54bd61aa..08fe48d5ce 100644 --- a/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java +++ b/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java @@ -322,7 +322,8 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy { Builder builder, RemoteAnimationTargetCompat app, TransformParams params) { builder.withMatrix(mMatrix) .withWindowCrop(mTmpCropRect) - .withCornerRadius(getCurrentCornerRadius()); + .withCornerRadius(getCurrentCornerRadius()) + .withShadowRadius(params.getShadowRadius()); if (ENABLE_QUICKSTEP_LIVE_TILE.get() && params.getRecentsSurface() != null) { // When relativeLayer = 0, it reverts the surfaces back to the original order. diff --git a/quickstep/src/com/android/quickstep/util/TransformParams.java b/quickstep/src/com/android/quickstep/util/TransformParams.java index 45f49bb785..c6a0c6631c 100644 --- a/quickstep/src/com/android/quickstep/util/TransformParams.java +++ b/quickstep/src/com/android/quickstep/util/TransformParams.java @@ -57,6 +57,7 @@ public class TransformParams { private float mProgress; private float mTargetAlpha; private float mCornerRadius; + private float mShadowRadius; private RemoteAnimationTargets mTargetSet; private SurfaceTransactionApplier mSyncTransactionApplier; private SurfaceControl mRecentsSurface; @@ -68,6 +69,7 @@ public class TransformParams { mProgress = 0; mTargetAlpha = 1; mCornerRadius = -1; + mShadowRadius = 0; } /** @@ -90,6 +92,14 @@ public class TransformParams { return this; } + /** + * Sets the shadow radius of the transformed window, in pixels. + */ + public TransformParams setShadowRadius(float shadowRadius) { + mShadowRadius = shadowRadius; + return this; + } + /** * Specifies the alpha of the transformed window. Default is 1. */ @@ -197,6 +207,10 @@ public class TransformParams { return mCornerRadius; } + public float getShadowRadius() { + return mShadowRadius; + } + public SurfaceControl getRecentsSurface() { return mRecentsSurface; }