[automerge] Make AllApps bottom sheet follow finger and snap after 30% progress 2p: c83ea5f8fb

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/17523008

Bug: 220336617
Change-Id: I0e9fa83437dafb91ba22e929b31f55cbf88c3189
This commit is contained in:
Alex Chau
2022-04-06 12:31:08 +00:00
committed by Presubmit Automerger Backend
6 changed files with 14 additions and 28 deletions
@@ -25,11 +25,8 @@ import static com.android.launcher3.anim.Interpolators.ACCEL;
import static com.android.launcher3.anim.Interpolators.DEACCEL;
import static com.android.launcher3.anim.Interpolators.FINAL_FRAME;
import static com.android.launcher3.anim.Interpolators.INSTANT;
import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.launcher3.anim.Interpolators.LINEAR_TELEPORT;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_ALL_APPS_FADE;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_SCRIM_FADE;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_VERTICAL_PROGRESS;
import android.view.MotionEvent;
@@ -140,7 +137,6 @@ public class PortraitStatesTouchController extends AbstractStateChangeTouchContr
builder.setInterpolator(ANIM_SCRIM_FADE, Interpolators.clampToProgress(ACCEL,
ALL_APPS_SCRIM_VISIBLE_THRESHOLD,
ALL_APPS_SCRIM_OPAQUE_THRESHOLD));
builder.setInterpolator(ANIM_VERTICAL_PROGRESS, isTablet ? LINEAR_TELEPORT : LINEAR);
return builder;
}
@@ -155,7 +151,6 @@ public class PortraitStatesTouchController extends AbstractStateChangeTouchContr
builder.setInterpolator(ANIM_SCRIM_FADE, Interpolators.clampToProgress(DEACCEL,
1 - ALL_APPS_SCRIM_OPAQUE_THRESHOLD,
1 - ALL_APPS_SCRIM_VISIBLE_THRESHOLD));
builder.setInterpolator(ANIM_VERTICAL_PROGRESS, isTablet ? LINEAR_TELEPORT : LINEAR);
return builder;
}
@@ -38,6 +38,7 @@ public class LauncherAnimUtils {
// Progress after which the transition is assumed to be a success
public static final float SUCCESS_TRANSITION_PROGRESS = 0.5f;
public static final float TABLET_BOTTOM_SHEET_SUCCESS_TRANSITION_PROGRESS = 0.3f;
public static final IntProperty<Drawable> DRAWABLE_ALPHA =
new IntProperty<Drawable>("drawableAlpha") {
@@ -130,23 +130,6 @@ public class Interpolators {
}
};
public static final Interpolator LINEAR_TELEPORT = t -> {
float startTeleport = 0.2f;
float endTeleport = 0.4f;
float teleportProgress = 0.5f;
float v;
if (t < startTeleport) {
v = LINEAR.getInterpolation(t);
} else if (t < endTeleport) {
v = Utilities.mapToRange(t, startTeleport, endTeleport, startTeleport,
endTeleport + teleportProgress, ACCEL_DEACCEL);
} else {
v = LINEAR.getInterpolation(t) + teleportProgress;
}
v = Utilities.boundToRange(v, 0f, 1f);
return v;
};
private static final float FAST_FLING_PX_MS = 10;
public static Interpolator scrollInterpolatorForVelocity(float velocity) {
@@ -16,6 +16,7 @@
package com.android.launcher3.touch;
import static com.android.launcher3.LauncherAnimUtils.SUCCESS_TRANSITION_PROGRESS;
import static com.android.launcher3.LauncherAnimUtils.TABLET_BOTTOM_SHEET_SUCCESS_TRANSITION_PROGRESS;
import static com.android.launcher3.LauncherAnimUtils.newCancelListener;
import static com.android.launcher3.LauncherState.ALL_APPS;
import static com.android.launcher3.LauncherState.NORMAL;
@@ -285,8 +286,13 @@ public abstract class AbstractStateChangeTouchController
? mToState : mFromState;
// snap to top or bottom using the release velocity
} else {
float successTransitionProgress =
mLauncher.getDeviceProfile().isTablet
&& (mToState == ALL_APPS || mFromState == ALL_APPS)
? TABLET_BOTTOM_SHEET_SUCCESS_TRANSITION_PROGRESS
: SUCCESS_TRANSITION_PROGRESS;
targetState =
(interpolatedProgress > SUCCESS_TRANSITION_PROGRESS) ? mToState : mFromState;
(interpolatedProgress > successTransitionProgress) ? mToState : mFromState;
}
final float endProgress;
@@ -20,10 +20,8 @@ import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.anim.Interpolators.FINAL_FRAME;
import static com.android.launcher3.anim.Interpolators.INSTANT;
import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.launcher3.anim.Interpolators.LINEAR_TELEPORT;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_ALL_APPS_FADE;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_SCRIM_FADE;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_VERTICAL_PROGRESS;
import android.view.MotionEvent;
import android.view.animation.Interpolator;
@@ -113,7 +111,6 @@ public class AllAppsSwipeController extends AbstractStateChangeTouchController {
config.setInterpolator(ANIM_SCRIM_FADE, ALLAPPS_STAGGERED_FADE_LATE_RESPONDER);
config.setInterpolator(ANIM_ALL_APPS_FADE, isTablet
? FINAL_FRAME : ALLAPPS_STAGGERED_FADE_EARLY_RESPONDER);
config.setInterpolator(ANIM_VERTICAL_PROGRESS, isTablet ? LINEAR_TELEPORT : LINEAR);
}
/**
@@ -125,7 +122,6 @@ public class AllAppsSwipeController extends AbstractStateChangeTouchController {
config.setInterpolator(ANIM_SCRIM_FADE, ALLAPPS_STAGGERED_FADE_EARLY_RESPONDER);
config.setInterpolator(ANIM_ALL_APPS_FADE, isTablet
? INSTANT : ALLAPPS_STAGGERED_FADE_LATE_RESPONDER);
config.setInterpolator(ANIM_VERTICAL_PROGRESS, isTablet ? LINEAR_TELEPORT : LINEAR);
}
@@ -17,6 +17,8 @@ package com.android.launcher3.views;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static com.android.launcher3.LauncherAnimUtils.SUCCESS_TRANSITION_PROGRESS;
import static com.android.launcher3.LauncherAnimUtils.TABLET_BOTTOM_SHEET_SUCCESS_TRANSITION_PROGRESS;
import static com.android.launcher3.anim.Interpolators.scrollInterpolatorForVelocity;
import android.animation.Animator;
@@ -184,7 +186,10 @@ public abstract class AbstractSlideInView<T extends Context & ActivityContext>
@Override
public void onDragEnd(float velocity) {
if ((mSwipeDetector.isFling(velocity) && velocity > 0) || mTranslationShift > 0.5f) {
float successfulShiftThreshold = mActivityContext.getDeviceProfile().isTablet
? TABLET_BOTTOM_SHEET_SUCCESS_TRANSITION_PROGRESS : SUCCESS_TRANSITION_PROGRESS;
if ((mSwipeDetector.isFling(velocity) && velocity > 0)
|| mTranslationShift > successfulShiftThreshold) {
mScrollInterpolator = scrollInterpolatorForVelocity(velocity);
mOpenCloseAnimator.setDuration(BaseSwipeDetector.calculateDuration(
velocity, TRANSLATION_SHIFT_CLOSED - mTranslationShift));