Merge "Don't special case swipe up animation if launcher was visible" into ub-launcher3-qt-dev

This commit is contained in:
Tony Wickham
2019-04-16 21:19:17 +00:00
committed by Android (Google) Code Review
2 changed files with 37 additions and 36 deletions
@@ -38,6 +38,10 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.animation.Interpolator;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.UiThread;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAppState;
@@ -59,10 +63,6 @@ import com.android.systemui.shared.system.RemoteAnimationTargetCompat;
import java.util.function.BiPredicate;
import java.util.function.Consumer;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.UiThread;
/**
* {@link ActivityControlHelper} for the in-launcher recents.
*/
@@ -163,21 +163,16 @@ public final class LauncherActivityControllerHelper implements ActivityControlHe
}
activity.getStateManager().setRestState(resetState);
final LauncherState fromState;
if (!activityVisible) {
// Since the launcher is not visible, we can safely reset the scroll position.
// This ensures then the next swipe up to all-apps starts from scroll 0.
activity.getAppsView().reset(false /* animate */);
fromState = animateActivity ? BACKGROUND_APP : OVERVIEW;
activity.getStateManager().goToState(fromState, false);
final LauncherState fromState = animateActivity ? BACKGROUND_APP : OVERVIEW;
activity.getStateManager().goToState(fromState, false);
// Since all apps is not visible, we can safely reset the scroll position.
// This ensures then the next swipe up to all-apps starts from scroll 0.
activity.getAppsView().reset(false /* animate */);
// Optimization, hide the all apps view to prevent layout while initializing
activity.getAppsView().getContentView().setVisibility(View.GONE);
// Optimization, hide the all apps view to prevent layout while initializing
activity.getAppsView().getContentView().setVisibility(View.GONE);
AccessibilityManagerCompat.sendStateEventToTest(activity, fromState.ordinal);
} else {
fromState = startState;
}
AccessibilityManagerCompat.sendStateEventToTest(activity, fromState.ordinal);
return new AnimationFactory() {
private Animator mShelfAnim;
@@ -185,8 +180,7 @@ public final class LauncherActivityControllerHelper implements ActivityControlHe
@Override
public void createActivityController(long transitionLength) {
createActivityControllerInternal(activity, activityVisible, fromState,
transitionLength, callback);
createActivityControllerInternal(activity, fromState, transitionLength, callback);
}
@Override
@@ -230,18 +224,9 @@ public final class LauncherActivityControllerHelper implements ActivityControlHe
};
}
private void createActivityControllerInternal(Launcher activity, boolean wasVisible,
LauncherState fromState, long transitionLength,
Consumer<AnimatorPlaybackController> callback) {
private void createActivityControllerInternal(Launcher activity, LauncherState fromState,
long transitionLength, Consumer<AnimatorPlaybackController> callback) {
LauncherState endState = OVERVIEW;
if (wasVisible && fromState != BACKGROUND_APP) {
// If a translucent app was launched fom launcher, animate launcher states.
DeviceProfile dp = activity.getDeviceProfile();
long accuracy = 2 * Math.max(dp.widthPx, dp.heightPx);
callback.accept(activity.getStateManager()
.createAnimationToNewWorkspace(fromState, endState, accuracy));
return;
}
if (fromState == endState) {
return;
}
@@ -64,6 +64,9 @@ import android.view.WindowInsets;
import android.view.WindowManager;
import android.view.animation.Interpolator;
import androidx.annotation.NonNull;
import androidx.annotation.UiThread;
import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.DeviceProfile;
@@ -103,9 +106,6 @@ import com.android.systemui.shared.system.WindowCallbacksCompat;
import java.util.function.BiFunction;
import java.util.function.Consumer;
import androidx.annotation.NonNull;
import androidx.annotation.UiThread;
@TargetApi(Build.VERSION_CODES.O)
public class WindowTransformSwipeHandler<T extends BaseDraggingActivity>
implements SwipeAnimationListener, OnApplyWindowInsetsListener {
@@ -429,8 +429,19 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity>
// If we've already ended the gesture and are going home, don't prepare recents UI,
// as that will set the state as BACKGROUND_APP, overriding the animation to NORMAL.
if (mGestureEndTarget != HOME) {
mAnimationFactory = mActivityControlHelper.prepareRecentsUI(mActivity,
mWasLauncherAlreadyVisible, true, this::onAnimatorPlaybackControllerCreated);
Runnable initAnimFactory = () -> {
mAnimationFactory = mActivityControlHelper.prepareRecentsUI(mActivity,
mWasLauncherAlreadyVisible, true,
this::onAnimatorPlaybackControllerCreated);
};
if (mWasLauncherAlreadyVisible) {
// Launcher is visible, but might be about to stop. Thus, if we prepare recents
// now, it might get overridden by moveToRestState() in onStop(). To avoid this,
// wait until the next gesture (and possibly launcher) starts.
mStateCallback.addCallback(STATE_GESTURE_STARTED, initAnimFactory);
} else {
initAnimFactory.run();
}
}
AbstractFloatingView.closeAllOpenViews(activity, mWasLauncherAlreadyVisible);
@@ -1044,7 +1055,12 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity>
}
private void invalidateHandlerWithLauncher() {
mLauncherTransitionController = null;
if (mLauncherTransitionController != null) {
if (mLauncherTransitionController.getAnimationPlayer().isStarted()) {
mLauncherTransitionController.getAnimationPlayer().cancel();
}
mLauncherTransitionController = null;
}
mRecentsView.setEnableFreeScroll(true);
mRecentsView.setRunningTaskIconScaledDown(false);