Support overriding All Apps EDU animation on drag am: ec4a56a311 am: a9b1814d42
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/15349065 Change-Id: I80b23a3e3afd982ddba7bb666d63023e3f63f03d
This commit is contained in:
commit
cfeb463f33
2 files changed
+63
-33
No files matched your search
@@ -17,13 +17,10 @@ package com.android.quickstep.views;
|
|||||||
|
|
||||||
import static com.android.launcher3.LauncherState.ALL_APPS;
|
import static com.android.launcher3.LauncherState.ALL_APPS;
|
||||||
import static com.android.launcher3.LauncherState.NORMAL;
|
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.FAST_OUT_SLOW_IN;
|
||||||
import static com.android.launcher3.anim.Interpolators.LINEAR;
|
import static com.android.launcher3.anim.Interpolators.LINEAR;
|
||||||
import static com.android.launcher3.anim.Interpolators.OVERSHOOT_1_7;
|
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.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.Animator;
|
||||||
import android.animation.AnimatorListenerAdapter;
|
import android.animation.AnimatorListenerAdapter;
|
||||||
@@ -35,7 +32,7 @@ import android.graphics.Rect;
|
|||||||
import android.graphics.drawable.GradientDrawable;
|
import android.graphics.drawable.GradientDrawable;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.ViewGroup;
|
import android.view.View;
|
||||||
|
|
||||||
import androidx.core.graphics.ColorUtils;
|
import androidx.core.graphics.ColorUtils;
|
||||||
|
|
||||||
@@ -44,25 +41,21 @@ import com.android.launcher3.DeviceProfile;
|
|||||||
import com.android.launcher3.Launcher;
|
import com.android.launcher3.Launcher;
|
||||||
import com.android.launcher3.R;
|
import com.android.launcher3.R;
|
||||||
import com.android.launcher3.Utilities;
|
import com.android.launcher3.Utilities;
|
||||||
import com.android.launcher3.allapps.AllAppsTransitionController;
|
|
||||||
import com.android.launcher3.anim.AnimatorPlaybackController;
|
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.dragndrop.DragLayer;
|
||||||
import com.android.launcher3.states.StateAnimationConfig;
|
import com.android.launcher3.uioverrides.touchcontrollers.PortraitStatesTouchController;
|
||||||
import com.android.launcher3.util.Themes;
|
import com.android.launcher3.util.Themes;
|
||||||
import com.android.quickstep.util.MultiValueUpdateListener;
|
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.
|
* 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 {
|
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 Launcher mLauncher;
|
||||||
|
private AllAppsEduTouchController mTouchController;
|
||||||
|
|
||||||
private AnimatorSet mAnimation;
|
private AnimatorSet mAnimation;
|
||||||
|
|
||||||
@@ -123,8 +116,35 @@ public class AllAppsEduView extends AbstractFloatingView {
|
|||||||
return true;
|
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
|
@Override
|
||||||
public boolean onControllerInterceptTouchEvent(MotionEvent ev) {
|
public boolean onControllerInterceptTouchEvent(MotionEvent ev) {
|
||||||
|
mTouchController.onControllerInterceptTouchEvent(ev);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,23 +165,9 @@ public class AllAppsEduView extends AbstractFloatingView {
|
|||||||
int secondPart = 1200;
|
int secondPart = 1200;
|
||||||
int introDuration = firstPart + secondPart;
|
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 =
|
AnimatorPlaybackController stateAnimationController =
|
||||||
mLauncher.getStateManager().createAnimationToNewWorkspace(ALL_APPS, config);
|
mTouchController.initAllAppsAnimation();
|
||||||
float maxAllAppsProgress = mLauncher.getDeviceProfile().isLandscape ? 0.35f : 0.15f;
|
float maxAllAppsProgress = 0.75f;
|
||||||
|
|
||||||
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());
|
|
||||||
|
|
||||||
ValueAnimator intro = ValueAnimator.ofFloat(0, 1f);
|
ValueAnimator intro = ValueAnimator.ofFloat(0, 1f);
|
||||||
intro.setInterpolator(LINEAR);
|
intro.setInterpolator(LINEAR);
|
||||||
@@ -198,6 +204,7 @@ public class AllAppsEduView extends AbstractFloatingView {
|
|||||||
mGradient.setAlpha(0);
|
mGradient.setAlpha(0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
mLauncher.getAppsView().setVisibility(View.VISIBLE);
|
||||||
mAnimation.play(intro);
|
mAnimation.play(intro);
|
||||||
|
|
||||||
ValueAnimator closeAllApps = ValueAnimator.ofFloat(maxAllAppsProgress, 0f);
|
ValueAnimator closeAllApps = ValueAnimator.ofFloat(maxAllAppsProgress, 0f);
|
||||||
@@ -223,6 +230,7 @@ public class AllAppsEduView extends AbstractFloatingView {
|
|||||||
|
|
||||||
private void init(Launcher launcher) {
|
private void init(Launcher launcher) {
|
||||||
mLauncher = launcher;
|
mLauncher = launcher;
|
||||||
|
mTouchController = new AllAppsEduTouchController(mLauncher);
|
||||||
|
|
||||||
int accentColor = Themes.getColorAccent(launcher);
|
int accentColor = Themes.getColorAccent(launcher);
|
||||||
mGradient = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM,
|
mGradient = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM,
|
||||||
@@ -250,9 +258,8 @@ public class AllAppsEduView extends AbstractFloatingView {
|
|||||||
*/
|
*/
|
||||||
public static void show(Launcher launcher) {
|
public static void show(Launcher launcher) {
|
||||||
final DragLayer dragLayer = launcher.getDragLayer();
|
final DragLayer dragLayer = launcher.getDragLayer();
|
||||||
ViewGroup parent = (ViewGroup) dragLayer.getParent();
|
AllAppsEduView view = (AllAppsEduView) launcher.getLayoutInflater().inflate(
|
||||||
AllAppsEduView view = launcher.getViewCache().getView(R.layout.all_apps_edu_view,
|
R.layout.all_apps_edu_view, dragLayer, false);
|
||||||
launcher, parent);
|
|
||||||
view.init(launcher);
|
view.init(launcher);
|
||||||
launcher.getDragLayer().addView(view);
|
launcher.getDragLayer().addView(view);
|
||||||
launcher.getStatsLogManager().logger().log(LAUNCHER_ALL_APPS_EDU_SHOWN);
|
launcher.getStatsLogManager().logger().log(LAUNCHER_ALL_APPS_EDU_SHOWN);
|
||||||
@@ -260,4 +267,27 @@ public class AllAppsEduView extends AbstractFloatingView {
|
|||||||
view.requestLayout();
|
view.requestLayout();
|
||||||
view.playAnimation();
|
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 LauncherState mToState;
|
||||||
protected AnimatorPlaybackController mCurrentAnimation;
|
protected AnimatorPlaybackController mCurrentAnimation;
|
||||||
protected boolean mGoingBetweenStates = true;
|
protected boolean mGoingBetweenStates = true;
|
||||||
|
// Ratio of transition process [0, 1] to drag displacement (px)
|
||||||
|
protected float mProgressMultiplier;
|
||||||
|
|
||||||
private boolean mNoIntercept;
|
private boolean mNoIntercept;
|
||||||
private boolean mIsLogContainerSet;
|
private boolean mIsLogContainerSet;
|
||||||
private float mStartProgress;
|
private float mStartProgress;
|
||||||
// Ratio of transition process [0, 1] to drag displacement (px)
|
|
||||||
private float mProgressMultiplier;
|
|
||||||
private float mDisplacementShift;
|
private float mDisplacementShift;
|
||||||
private boolean mCanBlockFling;
|
private boolean mCanBlockFling;
|
||||||
private boolean mAllAppsOvershootStarted;
|
private boolean mAllAppsOvershootStarted;
|
||||||
|
|||||||
Reference in new issue
Block a user