Merge "Add shadow radius to windows during app launch / close animations." into ub-launcher3-master

This commit is contained in:
Jonathan Miranda
2020-10-05 22:20:27 +00:00
committed by Android (Google) Code Review
5 changed files with 39 additions and 5 deletions
@@ -153,6 +153,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;
@@ -186,6 +187,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);
}
@@ -538,6 +540,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) {
@@ -600,7 +604,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) {
@@ -750,6 +755,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) {
@@ -771,7 +778,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)
@@ -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
@@ -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.
@@ -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;
}