Merge "AllAppsTransitionController always use LauncherStateTransitionAnimation b/30375760" into ub-launcher3-calgary

This commit is contained in:
Hyunyoung Song 2016-07-27 18:03:52 +00:00 committed by Android (Google) Code Review
commit 0dc7e91d5c
4 changed files with 22 additions and 36 deletions

View File

@ -3296,7 +3296,7 @@ public class Launcher extends Activity
public boolean showWorkspace(boolean animated, Runnable onCompleteRunnable) { public boolean showWorkspace(boolean animated, Runnable onCompleteRunnable) {
boolean changed = mState != State.WORKSPACE || boolean changed = mState != State.WORKSPACE ||
mWorkspace.getState() != Workspace.State.NORMAL; mWorkspace.getState() != Workspace.State.NORMAL;
if (changed) { if (changed || mAllAppsController.isTransitioning()) {
mWorkspace.setVisibility(View.VISIBLE); mWorkspace.setVisibility(View.VISIBLE);
mStateTransitionAnimation.startAnimationToWorkspace(mState, mWorkspace.getState(), mStateTransitionAnimation.startAnimationToWorkspace(mState, mWorkspace.getState(),
Workspace.State.NORMAL, animated, onCompleteRunnable); Workspace.State.NORMAL, animated, onCompleteRunnable);
@ -3393,8 +3393,10 @@ public class Launcher extends Activity
// TODO: calling method should use the return value so that when {@code false} is returned // TODO: calling method should use the return value so that when {@code false} is returned
// the workspace transition doesn't fall into invalid state. // the workspace transition doesn't fall into invalid state.
private boolean showAppsOrWidgets(State toState, boolean animated, boolean focusSearchBar) { private boolean showAppsOrWidgets(State toState, boolean animated, boolean focusSearchBar) {
if (mState != State.WORKSPACE && mState != State.APPS_SPRING_LOADED && if (!(mState == State.WORKSPACE ||
mState != State.WIDGETS_SPRING_LOADED) { mState == State.APPS_SPRING_LOADED ||
mState == State.WIDGETS_SPRING_LOADED ||
(mState == State.APPS && mAllAppsController.isTransitioning()))) {
return false; return false;
} }
if (toState != State.APPS && toState != State.WIDGETS) { if (toState != State.APPS && toState != State.WIDGETS) {

View File

@ -207,7 +207,8 @@ public class LauncherStateTransitionAnimation {
Log.e(TAG, "Unexpected call to startAnimationToWorkspace"); Log.e(TAG, "Unexpected call to startAnimationToWorkspace");
} }
if (fromState == Launcher.State.APPS || fromState == Launcher.State.APPS_SPRING_LOADED) { if (fromState == Launcher.State.APPS || fromState == Launcher.State.APPS_SPRING_LOADED
|| mAllAppsController.isTransitioning()) {
int animType = CIRCULAR_REVEAL; int animType = CIRCULAR_REVEAL;
if (FeatureFlags.LAUNCHER3_ALL_APPS_PULL_UP) { if (FeatureFlags.LAUNCHER3_ALL_APPS_PULL_UP) {
animType = PULLUP; animType = PULLUP;
@ -434,7 +435,7 @@ public class LauncherStateTransitionAnimation {
pCb.onTransitionComplete(); pCb.onTransitionComplete();
} }
}); });
mAllAppsController.animateToAllApps(animation, revealDuration, false); mAllAppsController.animateToAllApps(animation, revealDuration);
dispatchOnLauncherTransitionPrepare(fromView, animated, false); dispatchOnLauncherTransitionPrepare(fromView, animated, false);
dispatchOnLauncherTransitionPrepare(toView, animated, false); dispatchOnLauncherTransitionPrepare(toView, animated, false);
@ -898,9 +899,8 @@ public class LauncherStateTransitionAnimation {
@Override @Override
public void onAnimationEnd(Animator animation) { public void onAnimationEnd(Animator animation) {
if (canceled) return; if (canceled) return;
dispatchOnLauncherTransitionEnd(fromView, animated, false); dispatchOnLauncherTransitionEnd(fromView, animated, true);
dispatchOnLauncherTransitionEnd(toView, animated, false); dispatchOnLauncherTransitionEnd(toView, animated, true);
// Run any queued runnables // Run any queued runnables
if (onCompleteRunnable != null) { if (onCompleteRunnable != null) {
onCompleteRunnable.run(); onCompleteRunnable.run();
@ -918,7 +918,7 @@ public class LauncherStateTransitionAnimation {
} }
}); });
mAllAppsController.animateToWorkspace(animation, revealDuration, false); mAllAppsController.animateToWorkspace(animation, revealDuration);
// Dispatch the prepare transition signal // Dispatch the prepare transition signal
dispatchOnLauncherTransitionPrepare(fromView, animated, multiplePagesVisible); dispatchOnLauncherTransitionPrepare(fromView, animated, multiplePagesVisible);

View File

@ -153,7 +153,7 @@ public class AllAppsTransitionController implements TouchController, VerticalPul
if (mDetector.isSettlingState() && (isInDisallowRecatchBottomZone() || isInDisallowRecatchTopZone())) { if (mDetector.isSettlingState() && (isInDisallowRecatchBottomZone() || isInDisallowRecatchTopZone())) {
return false; return false;
} }
return mDetector.shouldIntercept(); return mDetector.isDraggingOrSettling();
} }
private boolean shouldPossiblyIntercept(MotionEvent ev) { private boolean shouldPossiblyIntercept(MotionEvent ev) {
@ -222,27 +222,17 @@ public class AllAppsTransitionController implements TouchController, VerticalPul
LauncherLogProto.Action.FLING, LauncherLogProto.Action.FLING,
LauncherLogProto.Action.UP, LauncherLogProto.Action.UP,
LauncherLogProto.HOTSEAT); LauncherLogProto.HOTSEAT);
mLauncher.showAppsView(true, true, false, false);
} else {
animateToAllApps(mCurrentAnimation, mAnimationDuration, true);
} }
mLauncher.showAppsView(true, true, false, false);
} else { } else {
calculateDuration(velocity, Math.abs(mShiftRange - mAppsView.getTranslationY())); calculateDuration(velocity, Math.abs(mShiftRange - mAppsView.getTranslationY()));
if (mLauncher.isAllAppsVisible()) { mLauncher.showWorkspace(true);
mLauncher.showWorkspace(true);
} else {
animateToWorkspace(mCurrentAnimation, mAnimationDuration, true);
}
} }
// snap to top or bottom using the release velocity // snap to top or bottom using the release velocity
} else { } else {
if (mAppsView.getTranslationY() > mShiftRange / 2) { if (mAppsView.getTranslationY() > mShiftRange / 2) {
calculateDuration(velocity, Math.abs(mShiftRange - mAppsView.getTranslationY())); calculateDuration(velocity, Math.abs(mShiftRange - mAppsView.getTranslationY()));
if (mLauncher.isAllAppsVisible()) { mLauncher.showWorkspace(true);
mLauncher.showWorkspace(true);
} else {
animateToWorkspace(mCurrentAnimation, mAnimationDuration, true);
}
} else { } else {
calculateDuration(velocity, Math.abs(mAppsView.getTranslationY())); calculateDuration(velocity, Math.abs(mAppsView.getTranslationY()));
if (!mLauncher.isAllAppsVisible()) { if (!mLauncher.isAllAppsVisible()) {
@ -250,15 +240,15 @@ public class AllAppsTransitionController implements TouchController, VerticalPul
LauncherLogProto.Action.SWIPE, LauncherLogProto.Action.SWIPE,
LauncherLogProto.Action.UP, LauncherLogProto.Action.UP,
LauncherLogProto.HOTSEAT); LauncherLogProto.HOTSEAT);
mLauncher.showAppsView(true, true, false, false);
} else {
animateToAllApps(mCurrentAnimation, mAnimationDuration, true);
} }
mLauncher.showAppsView(true, true, false, false);
} }
} }
} }
public boolean isTransitioning() {
return mDetector.isDraggingOrSettling();
}
/** /**
* @param start {@code true} if start of new drag. * @param start {@code true} if start of new drag.
*/ */
@ -354,7 +344,7 @@ public class AllAppsTransitionController implements TouchController, VerticalPul
} }
} }
public void animateToAllApps(AnimatorSet animationOut, long duration, boolean start) { public void animateToAllApps(AnimatorSet animationOut, long duration) {
if (animationOut == null) { if (animationOut == null) {
return; return;
} }
@ -390,9 +380,6 @@ public class AllAppsTransitionController implements TouchController, VerticalPul
} }
}); });
mCurrentAnimation = animationOut; mCurrentAnimation = animationOut;
if (start) {
mCurrentAnimation.start();
}
} }
public void showDiscoveryBounce() { public void showDiscoveryBounce() {
@ -425,7 +412,7 @@ public class AllAppsTransitionController implements TouchController, VerticalPul
}); });
} }
public void animateToWorkspace(AnimatorSet animationOut, long duration, boolean start) { public void animateToWorkspace(AnimatorSet animationOut, long duration) {
if (animationOut == null) { if (animationOut == null) {
return; return;
} }
@ -462,9 +449,6 @@ public class AllAppsTransitionController implements TouchController, VerticalPul
} }
}); });
mCurrentAnimation = animationOut; mCurrentAnimation = animationOut;
if (start) {
mCurrentAnimation.start();
}
} }
public void finishPullUp() { public void finishPullUp() {

View File

@ -72,7 +72,7 @@ public class VerticalPullDetector {
mState = newState; mState = newState;
} }
public boolean shouldIntercept() { public boolean isDraggingOrSettling() {
return mState == ScrollState.DRAGGING || mState == ScrollState.SETTLING; return mState == ScrollState.DRAGGING || mState == ScrollState.SETTLING;
} }