Merge "Tuning app close, and turn on flag." into sc-dev

This commit is contained in:
Jonathan Miranda 2021-05-12 23:28:59 +00:00 committed by Android (Google) Code Review
commit 951962cd05
5 changed files with 80 additions and 88 deletions

View File

@ -336,8 +336,8 @@ public class LauncherSwipeHandlerV2 extends
@Override
public void playAtomicAnimation(float velocity) {
new StaggeredWorkspaceAnim(mActivity, velocity,
true /* animateOverviewScrim */).start();
new StaggeredWorkspaceAnim(mActivity, velocity, true /* animateOverviewScrim */,
!PROTOTYPE_APP_CLOSE.get()).start();
}
@Override

View File

@ -69,12 +69,12 @@ public class RectFSpringAnim2 extends RectFSpringAnim {
new FloatPropertyCompat<RectFSpringAnim2>("rectYSpring") {
@Override
public float getValue(RectFSpringAnim2 anim) {
return anim.mCurrentY;
return anim.mCurrentCenterY;
}
@Override
public void setValue(RectFSpringAnim2 anim, float y) {
anim.mCurrentY = y;
anim.mCurrentCenterY = y;
anim.onUpdate();
}
};
@ -100,13 +100,12 @@ public class RectFSpringAnim2 extends RectFSpringAnim {
private final List<Animator.AnimatorListener> mAnimatorListeners = new ArrayList<>();
private float mCurrentCenterX;
private float mCurrentY;
private float mCurrentCenterY;
private float mTargetX;
private float mTargetY;
// If true, tracking the bottom of the rects, else tracking the top.
private final boolean mTrackingBottomY;
private float mProgress;
private SpringAnimation mRectXAnim;
private SpringAnimation mRectYAnim;
@ -139,11 +138,10 @@ public class RectFSpringAnim2 extends RectFSpringAnim {
mStartRect = startRect;
mTargetRect = targetRect;
mTrackingBottomY = startRect.bottom < targetRect.bottom;
mCurrentY = mTrackingBottomY ? mStartRect.bottom : mStartRect.top;
mCurrentCenterY = mStartRect.centerY();
mCurrentCenterX = mStartRect.centerX();
mTargetY = mTrackingBottomY ? mTargetRect.bottom : mTargetRect.top;
mTargetY = mTargetRect.centerY();
mTargetX = mTargetRect.centerX();
ResourceProvider rp = DynamicResource.provider(context);
@ -157,12 +155,6 @@ public class RectFSpringAnim2 extends RectFSpringAnim {
mHomeTransYEnd = dpToPx(rp.getFloat(R.dimen.swipe_up_trans_y_dp));
mScaleStart = rp.getFloat(R.dimen.swipe_up_scale_start);
if (!mTrackingBottomY) {
mYStiffness *= rp.getFloat(R.dimen.swipe_up_rect_2_y_stiffness_low_swipe_multiplier);
mDuration *= rp.getFloat(R.dimen.swipe_up_low_swipe_duration_multiplier);
}
mCloseInterpolator = getAppCloseInterpolator(context);
// End on a "round-enough" radius so that the shape reveal doesn't have to do too much
@ -180,11 +172,8 @@ public class RectFSpringAnim2 extends RectFSpringAnim {
}
if (mRectYAnim != null) {
if (mTrackingBottomY && mTargetY != mTargetRect.bottom) {
mTargetY = mTargetRect.bottom;
mRectYAnim.animateToFinalPosition(mTargetY);
} else if (!mTrackingBottomY && mTargetY != mTargetRect.top) {
mTargetY = mTargetRect.top;
if (mTargetY != mTargetRect.centerY()) {
mTargetY = mTargetRect.centerY();
mRectYAnim.animateToFinalPosition(mTargetY);
}
}
@ -220,9 +209,9 @@ public class RectFSpringAnim2 extends RectFSpringAnim {
}));
mRectYAnim = new SpringAnimation(this, RECT_Y)
.setStartValue(mCurrentY)
.setMinValue(Math.min(0, mCurrentY))
.setMaxValue(Math.max(dp.heightPx, mCurrentY))
.setStartValue(mCurrentCenterY)
.setMinValue(Math.min(0, mCurrentCenterY))
.setMaxValue(Math.max(dp.heightPx, mCurrentCenterY))
.setStartVelocity(velocityPxPerMs.y * 1000)
.setSpring(new SpringForce(mTargetY)
.setStiffness(mYStiffness)
@ -336,13 +325,11 @@ public class RectFSpringAnim2 extends RectFSpringAnim {
mTargetRect.width());
float currentHeight = Utilities.mapRange(rectProgress, mStartRect.height(),
mTargetRect.height());
if (mTrackingBottomY) {
mCurrentRect.set(mCurrentCenterX - currentWidth / 2, mCurrentY - currentHeight,
mCurrentCenterX + currentWidth / 2, mCurrentY);
} else {
mCurrentRect.set(mCurrentCenterX - currentWidth / 2, mCurrentY,
mCurrentCenterX + currentWidth / 2, mCurrentY + currentHeight);
}
mCurrentRect.set(mCurrentCenterX - currentWidth / 2,
mCurrentCenterY - currentHeight / 2,
mCurrentCenterX + currentWidth / 2,
mCurrentCenterY + currentHeight / 2);
float currentPlayTime = mRectScaleAnimEnded ? mRectScaleAnim.getDuration()
: mRectScaleAnim.getCurrentPlayTime();

View File

@ -20,7 +20,6 @@ import static com.android.launcher3.LauncherState.BACKGROUND_APP;
import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.launcher3.anim.PropertySetter.NO_ANIM_PROPERTY_SETTER;
import static com.android.launcher3.config.FeatureFlags.PROTOTYPE_APP_CLOSE;
import static com.android.launcher3.states.StateAnimationConfig.SKIP_DEPTH_CONTROLLER;
import static com.android.launcher3.states.StateAnimationConfig.SKIP_OVERVIEW;
import static com.android.launcher3.states.StateAnimationConfig.SKIP_SCRIM;
@ -71,6 +70,11 @@ public class StaggeredWorkspaceAnim {
private final AnimatorSet mAnimators = new AnimatorSet();
public StaggeredWorkspaceAnim(Launcher launcher, float velocity, boolean animateOverviewScrim) {
this(launcher, velocity, animateOverviewScrim, true);
}
public StaggeredWorkspaceAnim(Launcher launcher, float velocity, boolean animateOverviewScrim,
boolean staggerWorkspace) {
prepareToAnimate(launcher, animateOverviewScrim);
mVelocity = velocity;
@ -81,53 +85,66 @@ public class StaggeredWorkspaceAnim {
mSpringTransY = transFactor * launcher.getResources()
.getDimensionPixelSize(R.dimen.swipe_up_max_workspace_trans_y);
DeviceProfile grid = launcher.getDeviceProfile();
Workspace workspace = launcher.getWorkspace();
Hotseat hotseat = launcher.getHotseat();
if (staggerWorkspace) {
DeviceProfile grid = launcher.getDeviceProfile();
Workspace workspace = launcher.getWorkspace();
Hotseat hotseat = launcher.getHotseat();
// Hotseat and QSB takes up two additional rows.
int totalRows = grid.inv.numRows + (grid.isVerticalBarLayout() ? 0 : 2);
// Hotseat and QSB takes up two additional rows.
int totalRows = grid.inv.numRows + (grid.isVerticalBarLayout() ? 0 : 2);
// Add animation for all the visible workspace pages
workspace.forEachVisiblePage(page -> addAnimationForPage((CellLayout) page, totalRows));
// Add animation for all the visible workspace pages
workspace.forEachVisiblePage(page -> addAnimationForPage((CellLayout) page, totalRows));
boolean workspaceClipChildren = workspace.getClipChildren();
boolean workspaceClipToPadding = workspace.getClipToPadding();
boolean hotseatClipChildren = hotseat.getClipChildren();
boolean hotseatClipToPadding = hotseat.getClipToPadding();
boolean workspaceClipChildren = workspace.getClipChildren();
boolean workspaceClipToPadding = workspace.getClipToPadding();
boolean hotseatClipChildren = hotseat.getClipChildren();
boolean hotseatClipToPadding = hotseat.getClipToPadding();
workspace.setClipChildren(false);
workspace.setClipToPadding(false);
hotseat.setClipChildren(false);
hotseat.setClipToPadding(false);
workspace.setClipChildren(false);
workspace.setClipToPadding(false);
hotseat.setClipChildren(false);
hotseat.setClipToPadding(false);
// Set up springs for the hotseat and qsb.
ViewGroup hotseatIcons = hotseat.getShortcutsAndWidgets();
if (grid.isVerticalBarLayout()) {
for (int i = hotseatIcons.getChildCount() - 1; i >= 0; i--) {
View child = hotseatIcons.getChildAt(i);
CellLayout.LayoutParams lp = ((CellLayout.LayoutParams) child.getLayoutParams());
addStaggeredAnimationForView(child, lp.cellY + 1, totalRows);
}
} else {
final int hotseatRow, qsbRow, taskbarRow;
if (grid.isTaskbarPresent) {
qsbRow = grid.inv.numRows + 1;
hotseatRow = grid.inv.numRows + 2;
// Set up springs for the hotseat and qsb.
ViewGroup hotseatIcons = hotseat.getShortcutsAndWidgets();
if (grid.isVerticalBarLayout()) {
for (int i = hotseatIcons.getChildCount() - 1; i >= 0; i--) {
View child = hotseatIcons.getChildAt(i);
CellLayout.LayoutParams lp =
((CellLayout.LayoutParams) child.getLayoutParams());
addStaggeredAnimationForView(child, lp.cellY + 1, totalRows);
}
} else {
hotseatRow = grid.inv.numRows + 1;
qsbRow = grid.inv.numRows + 2;
}
// Taskbar and hotseat overlap.
taskbarRow = hotseatRow;
final int hotseatRow, qsbRow, taskbarRow;
if (grid.isTaskbarPresent) {
qsbRow = grid.inv.numRows + 1;
hotseatRow = grid.inv.numRows + 2;
} else {
hotseatRow = grid.inv.numRows + 1;
qsbRow = grid.inv.numRows + 2;
}
// Taskbar and hotseat overlap.
taskbarRow = hotseatRow;
for (int i = hotseatIcons.getChildCount() - 1; i >= 0; i--) {
View child = hotseatIcons.getChildAt(i);
addStaggeredAnimationForView(child, hotseatRow, totalRows);
for (int i = hotseatIcons.getChildCount() - 1; i >= 0; i--) {
View child = hotseatIcons.getChildAt(i);
addStaggeredAnimationForView(child, hotseatRow, totalRows);
}
addStaggeredAnimationForView(hotseat.getQsb(), qsbRow, totalRows);
addStaggeredAnimationForView(hotseat.getTaskbarView(), taskbarRow, totalRows);
}
addStaggeredAnimationForView(hotseat.getQsb(), qsbRow, totalRows);
addStaggeredAnimationForView(hotseat.getTaskbarView(), taskbarRow, totalRows);
mAnimators.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
workspace.setClipChildren(workspaceClipChildren);
workspace.setClipToPadding(workspaceClipToPadding);
hotseat.setClipChildren(hotseatClipChildren);
hotseat.setClipToPadding(hotseatClipToPadding);
}
});
}
if (animateOverviewScrim) {
@ -141,15 +158,6 @@ public class StaggeredWorkspaceAnim {
mAnimators.play(launcher.getRootView().getSysUiScrim().createSysuiMultiplierAnim(0f, 1f)
.setDuration(DURATION_MS));
mAnimators.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
workspace.setClipChildren(workspaceClipChildren);
workspace.setClipToPadding(workspaceClipToPadding);
hotseat.setClipChildren(hotseatClipChildren);
hotseat.setClipToPadding(hotseatClipToPadding);
}
});
}
private void addAnimationForPage(CellLayout page, int totalRows) {
@ -220,9 +228,6 @@ public class StaggeredWorkspaceAnim {
* @param totalRows Total number of rows.
*/
private void addStaggeredAnimationForView(View v, int row, int totalRows) {
if (PROTOTYPE_APP_CLOSE.get()) {
return;
}
// Invert the rows, because we stagger starting from the bottom of the screen.
int invertedRow = totalRows - row;
// Add 1 to the inverted row so that the bottom most row has a start delay.

View File

@ -127,12 +127,12 @@
<item name="swipe_up_rect_xy_fling_friction" type="dimen" format="float">1.5</item>
<item name="swipe_up_scale_start" type="dimen" format="float">0.98</item>
<item name="swipe_up_duration" type="dimen" format="float">500</item>
<item name="swipe_up_duration" type="dimen" format="float">400</item>
<item name="swipe_up_trans_y_dp" type="dimen" format="float">3</item>
<item name="swipe_up_trans_y_dp" type="dimen" format="float">4.5</item>
<item name="swipe_up_trans_y_dp_per_s" type="dimen" format="float">3</item>
<item name="swipe_up_trans_y_damping" type="dimen" format="float">0.4</item>
<item name="swipe_up_trans_y_damping" type="dimen" format="float">0.45</item>
<item name="swipe_up_trans_y_stiffness" type="dimen" format="float">200</item>
<item name="swipe_up_rect_xy_damping_ratio" type="dimen" format="float">0.8</item>
@ -140,12 +140,12 @@
<item name="swipe_up_rect_2_x_damping_ratio" type="dimen" format="float">1</item>
<item name="swipe_up_rect_2_x_stiffness" type="dimen" format="float">350</item>
<item name="swipe_up_rect_2_x_stiffness" type="dimen" format="float">250</item>
<item name="swipe_up_rect_2_y_damping_ratio" type="dimen" format="float">1</item>
<item name="swipe_up_rect_2_y_stiffness" type="dimen" format="float">700</item>
<item name="swipe_up_rect_2_y_stiffness" type="dimen" format="float">600</item>
<item name="swipe_up_rect_2_y_stiffness_low_swipe_multiplier" type="dimen" format="float">1</item>
<item name="swipe_up_rect_2_y_stiffness_low_swipe_multiplier" type="dimen" format="float">0.8</item>
<item name="swipe_up_low_swipe_duration_multiplier" type="dimen" format="float">1</item>
<item name="swipe_up_launcher_alpha_max_progress" type="dimen" format="float">0.85</item>

View File

@ -238,7 +238,7 @@ public final class FeatureFlags {
"Sends a notification whenever launcher encounters an uncaught exception.");
public static final BooleanFlag PROTOTYPE_APP_CLOSE = getDebugFlag(
"PROTOTYPE_APP_CLOSE", false, "Enables new app close");
"PROTOTYPE_APP_CLOSE", true, "Enables new app close");
public static final BooleanFlag ENABLE_WALLPAPER_SCRIM = getDebugFlag(
"ENABLE_WALLPAPER_SCRIM", false,