Support overriding All Apps EDU animation on drag
Test: Dragging during All Apps EDU animation overrides the animation. Bug: 160218103 Change-Id: I1c0a2d047bcb43ea7ce30cf87182b392dac313e4
This commit is contained in:
parent
3a7df28e8d
commit
ec4a56a311
|
@ -17,13 +17,10 @@ package com.android.quickstep.views;
|
|||
|
||||
import static com.android.launcher3.LauncherState.ALL_APPS;
|
||||
import static com.android.launcher3.LauncherState.NORMAL;
|
||||
import static com.android.launcher3.anim.Interpolators.ACCEL;
|
||||
import static com.android.launcher3.anim.Interpolators.FAST_OUT_SLOW_IN;
|
||||
import static com.android.launcher3.anim.Interpolators.LINEAR;
|
||||
import static com.android.launcher3.anim.Interpolators.OVERSHOOT_1_7;
|
||||
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALL_APPS_EDU_SHOWN;
|
||||
import static com.android.launcher3.states.StateAnimationConfig.ANIM_ALL_APPS_FADE;
|
||||
import static com.android.launcher3.states.StateAnimationConfig.ANIM_SCRIM_FADE;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
|
@ -35,7 +32,7 @@ import android.graphics.Rect;
|
|||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.core.graphics.ColorUtils;
|
||||
|
||||
|
@ -44,25 +41,21 @@ import com.android.launcher3.DeviceProfile;
|
|||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.allapps.AllAppsTransitionController;
|
||||
import com.android.launcher3.anim.AnimatorPlaybackController;
|
||||
import com.android.launcher3.anim.Interpolators;
|
||||
import com.android.launcher3.anim.PendingAnimation;
|
||||
import com.android.launcher3.dragndrop.DragLayer;
|
||||
import com.android.launcher3.states.StateAnimationConfig;
|
||||
import com.android.launcher3.uioverrides.touchcontrollers.PortraitStatesTouchController;
|
||||
import com.android.launcher3.util.Themes;
|
||||
import com.android.quickstep.util.MultiValueUpdateListener;
|
||||
|
||||
/**
|
||||
* View used to educate the user on how to access All Apps when in No Nav Button navigation mode.
|
||||
* Consumes all touches until after the animation is completed and the view is removed.
|
||||
* If the user drags on the view, the animation is overridden so the user can swipe to All Apps or
|
||||
* Home.
|
||||
*/
|
||||
public class AllAppsEduView extends AbstractFloatingView {
|
||||
|
||||
private static final float HINT_PROG_SCRIM_THRESHOLD = 0.06f;
|
||||
private static final float HINT_PROG_CONTENT_THRESHOLD = 0.08f;
|
||||
|
||||
private Launcher mLauncher;
|
||||
private AllAppsEduTouchController mTouchController;
|
||||
|
||||
private AnimatorSet mAnimation;
|
||||
|
||||
|
@ -123,8 +116,35 @@ public class AllAppsEduView extends AbstractFloatingView {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onControllerTouchEvent(MotionEvent ev) {
|
||||
mTouchController.onControllerTouchEvent(ev);
|
||||
if (mAnimation != null) {
|
||||
updateAnimationOnTouchEvent(ev);
|
||||
}
|
||||
return super.onControllerTouchEvent(ev);
|
||||
}
|
||||
|
||||
private void updateAnimationOnTouchEvent(MotionEvent ev) {
|
||||
switch (ev.getActionMasked()) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
mAnimation.pause();
|
||||
return;
|
||||
case MotionEvent.ACTION_UP:
|
||||
case MotionEvent.ACTION_CANCEL:
|
||||
mAnimation.resume();
|
||||
return;
|
||||
}
|
||||
|
||||
if (mTouchController.isDraggingOrSettling()) {
|
||||
mAnimation = null;
|
||||
handleClose(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onControllerInterceptTouchEvent(MotionEvent ev) {
|
||||
mTouchController.onControllerInterceptTouchEvent(ev);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -145,23 +165,9 @@ public class AllAppsEduView extends AbstractFloatingView {
|
|||
int secondPart = 1200;
|
||||
int introDuration = firstPart + secondPart;
|
||||
|
||||
StateAnimationConfig config = new StateAnimationConfig();
|
||||
config.setInterpolator(ANIM_ALL_APPS_FADE, Interpolators.clampToProgress(ACCEL,
|
||||
HINT_PROG_SCRIM_THRESHOLD, HINT_PROG_CONTENT_THRESHOLD));
|
||||
config.setInterpolator(ANIM_SCRIM_FADE,
|
||||
Interpolators.clampToProgress(ACCEL, 0, HINT_PROG_CONTENT_THRESHOLD));
|
||||
config.duration = secondPart;
|
||||
config.userControlled = false;
|
||||
AnimatorPlaybackController stateAnimationController =
|
||||
mLauncher.getStateManager().createAnimationToNewWorkspace(ALL_APPS, config);
|
||||
float maxAllAppsProgress = mLauncher.getDeviceProfile().isLandscape ? 0.35f : 0.15f;
|
||||
|
||||
AllAppsTransitionController allAppsController = mLauncher.getAllAppsController();
|
||||
PendingAnimation allAppsAlpha = new PendingAnimation(config.duration);
|
||||
allAppsController.setAlphas(ALL_APPS, config, allAppsAlpha);
|
||||
mLauncher.getWorkspace().getStateTransitionAnimation().setScrim(allAppsAlpha, ALL_APPS,
|
||||
config);
|
||||
mAnimation.play(allAppsAlpha.buildAnim());
|
||||
mTouchController.initAllAppsAnimation();
|
||||
float maxAllAppsProgress = 0.75f;
|
||||
|
||||
ValueAnimator intro = ValueAnimator.ofFloat(0, 1f);
|
||||
intro.setInterpolator(LINEAR);
|
||||
|
@ -198,6 +204,7 @@ public class AllAppsEduView extends AbstractFloatingView {
|
|||
mGradient.setAlpha(0);
|
||||
}
|
||||
});
|
||||
mLauncher.getAppsView().setVisibility(View.VISIBLE);
|
||||
mAnimation.play(intro);
|
||||
|
||||
ValueAnimator closeAllApps = ValueAnimator.ofFloat(maxAllAppsProgress, 0f);
|
||||
|
@ -223,6 +230,7 @@ public class AllAppsEduView extends AbstractFloatingView {
|
|||
|
||||
private void init(Launcher launcher) {
|
||||
mLauncher = launcher;
|
||||
mTouchController = new AllAppsEduTouchController(mLauncher);
|
||||
|
||||
int accentColor = Themes.getColorAccent(launcher);
|
||||
mGradient = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM,
|
||||
|
@ -250,9 +258,8 @@ public class AllAppsEduView extends AbstractFloatingView {
|
|||
*/
|
||||
public static void show(Launcher launcher) {
|
||||
final DragLayer dragLayer = launcher.getDragLayer();
|
||||
ViewGroup parent = (ViewGroup) dragLayer.getParent();
|
||||
AllAppsEduView view = launcher.getViewCache().getView(R.layout.all_apps_edu_view,
|
||||
launcher, parent);
|
||||
AllAppsEduView view = (AllAppsEduView) launcher.getLayoutInflater().inflate(
|
||||
R.layout.all_apps_edu_view, dragLayer, false);
|
||||
view.init(launcher);
|
||||
launcher.getDragLayer().addView(view);
|
||||
launcher.getStatsLogManager().logger().log(LAUNCHER_ALL_APPS_EDU_SHOWN);
|
||||
|
@ -260,4 +267,27 @@ public class AllAppsEduView extends AbstractFloatingView {
|
|||
view.requestLayout();
|
||||
view.playAnimation();
|
||||
}
|
||||
|
||||
private static class AllAppsEduTouchController extends PortraitStatesTouchController {
|
||||
|
||||
private AllAppsEduTouchController(Launcher l) {
|
||||
super(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canInterceptTouch(MotionEvent ev) {
|
||||
return true;
|
||||
}
|
||||
|
||||
private AnimatorPlaybackController initAllAppsAnimation() {
|
||||
mFromState = NORMAL;
|
||||
mToState = ALL_APPS;
|
||||
mProgressMultiplier = initCurrentAnimation();
|
||||
return mCurrentAnimation;
|
||||
}
|
||||
|
||||
private boolean isDraggingOrSettling() {
|
||||
return mDetector.isDraggingOrSettling();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,12 +65,12 @@ public abstract class AbstractStateChangeTouchController
|
|||
protected LauncherState mToState;
|
||||
protected AnimatorPlaybackController mCurrentAnimation;
|
||||
protected boolean mGoingBetweenStates = true;
|
||||
// Ratio of transition process [0, 1] to drag displacement (px)
|
||||
protected float mProgressMultiplier;
|
||||
|
||||
private boolean mNoIntercept;
|
||||
private boolean mIsLogContainerSet;
|
||||
private float mStartProgress;
|
||||
// Ratio of transition process [0, 1] to drag displacement (px)
|
||||
private float mProgressMultiplier;
|
||||
private float mDisplacementShift;
|
||||
private boolean mCanBlockFling;
|
||||
private boolean mAllAppsOvershootStarted;
|
||||
|
|
Loading…
Reference in New Issue