From 58ddac1d09a05b3fc8359545285d363407883f37 Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Tue, 12 Mar 2019 16:22:57 -0700 Subject: [PATCH] Removing fade animation on swipe up Fade animation is no longer required as the transform is also handled on the main thread. So we will get the RecentsAnimaiton always after Launcher has drawn Change-Id: Ieb05406c9a5b9132b0518155bdbda16c1f73a6ec --- .../FallbackActivityControllerHelper.java | 6 -- .../LauncherActivityControllerHelper.java | 7 -- .../FallbackActivityControllerHelper.java | 5 -- .../LauncherActivityControllerHelper.java | 5 -- .../android/quickstep/MultiStateCallback.java | 5 ++ .../WindowTransformSwipeHandler.java | 71 ++++++------------- .../quickstep/ActivityControlHelper.java | 3 - .../launcher3/dragndrop/DragLayer.java | 3 +- 8 files changed, 26 insertions(+), 79 deletions(-) diff --git a/go/quickstep/src/com/android/quickstep/FallbackActivityControllerHelper.java b/go/quickstep/src/com/android/quickstep/FallbackActivityControllerHelper.java index abb9242247..bba08a40af 100644 --- a/go/quickstep/src/com/android/quickstep/FallbackActivityControllerHelper.java +++ b/go/quickstep/src/com/android/quickstep/FallbackActivityControllerHelper.java @@ -26,7 +26,6 @@ import androidx.annotation.Nullable; import com.android.launcher3.anim.AnimatorPlaybackController; import com.android.launcher3.userevent.nano.LauncherLogProto; -import com.android.launcher3.util.MultiValueAlpha.AlphaProperty; import com.android.quickstep.util.RemoteAnimationTargetSet; import com.android.quickstep.views.IconRecentsView; @@ -109,11 +108,6 @@ public final class FallbackActivityControllerHelper extends return false; } - @Override - public AlphaProperty getAlphaProperty(RecentsActivity activity) { - return activity.getDragLayer().getAlphaProperty(0); - } - @Override public int getContainerType() { return LauncherLogProto.ContainerType.SIDELOADED_LAUNCHER; diff --git a/go/quickstep/src/com/android/quickstep/LauncherActivityControllerHelper.java b/go/quickstep/src/com/android/quickstep/LauncherActivityControllerHelper.java index 76685f3410..d55d2e5fd9 100644 --- a/go/quickstep/src/com/android/quickstep/LauncherActivityControllerHelper.java +++ b/go/quickstep/src/com/android/quickstep/LauncherActivityControllerHelper.java @@ -22,9 +22,7 @@ import com.android.launcher3.Launcher; import com.android.launcher3.LauncherAppState; import com.android.launcher3.LauncherInitListener; import com.android.launcher3.anim.AnimatorPlaybackController; -import com.android.launcher3.dragndrop.DragLayer; import com.android.launcher3.userevent.nano.LauncherLogProto; -import com.android.launcher3.util.MultiValueAlpha.AlphaProperty; import com.android.quickstep.views.IconRecentsView; import java.util.function.BiPredicate; @@ -93,11 +91,6 @@ public final class LauncherActivityControllerHelper extends GoActivityControlHel return true; } - @Override - public AlphaProperty getAlphaProperty(Launcher activity) { - return activity.getDragLayer().getAlphaProperty(DragLayer.ALPHA_INDEX_SWIPE_UP); - } - @Override public int getContainerType() { final Launcher launcher = getVisibleLauncher(); diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/FallbackActivityControllerHelper.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/FallbackActivityControllerHelper.java index 1ed1353c6c..d61ed724dd 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/FallbackActivityControllerHelper.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/FallbackActivityControllerHelper.java @@ -181,11 +181,6 @@ public final class FallbackActivityControllerHelper implements return false; } - @Override - public AlphaProperty getAlphaProperty(RecentsActivity activity) { - return activity.getDragLayer().getAlphaProperty(0); - } - @Override public int getContainerType() { return LauncherLogProto.ContainerType.SIDELOADED_LAUNCHER; diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java index eee03441db..e95e2a0de5 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java @@ -393,11 +393,6 @@ public final class LauncherActivityControllerHelper implements ActivityControlHe return true; } - @Override - public AlphaProperty getAlphaProperty(Launcher activity) { - return activity.getDragLayer().getAlphaProperty(DragLayer.ALPHA_INDEX_SWIPE_UP); - } - @Override public int getContainerType() { final Launcher launcher = getVisibleLauncher(); diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/MultiStateCallback.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/MultiStateCallback.java index 9fceab4ac7..357c9fc35e 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/MultiStateCallback.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/MultiStateCallback.java @@ -18,6 +18,8 @@ package com.android.quickstep; import android.util.Log; import android.util.SparseArray; +import com.android.launcher3.config.FeatureFlags; + import java.util.StringJoiner; import java.util.function.Consumer; @@ -101,6 +103,9 @@ public class MultiStateCallback { * The callback is only run once. */ public void addCallback(int stateMask, Runnable callback) { + if (FeatureFlags.IS_DOGFOOD_BUILD && mCallbacks.get(stateMask) != null) { + throw new IllegalStateException("Multiple callbacks on same state"); + } mCallbacks.put(stateMask, callback); } diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/WindowTransformSwipeHandler.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/WindowTransformSwipeHandler.java index 7bea5935c4..00dbdff1bf 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/WindowTransformSwipeHandler.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/WindowTransformSwipeHandler.java @@ -40,7 +40,6 @@ import static com.android.quickstep.WindowTransformSwipeHandler.GestureEndTarget import static com.android.quickstep.views.RecentsView.UPDATE_SYSUI_FLAGS_THRESHOLD; import android.animation.Animator; -import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorSet; import android.animation.ObjectAnimator; import android.animation.TimeInterpolator; @@ -78,8 +77,6 @@ import com.android.launcher3.logging.UserEventDispatcher; import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction; import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch; import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType; -import com.android.launcher3.util.MultiValueAlpha; -import com.android.launcher3.util.MultiValueAlpha.AlphaProperty; import com.android.launcher3.util.RaceConditionTracker; import com.android.launcher3.util.TraceHelper; import com.android.launcher3.views.FloatingIconView; @@ -113,7 +110,7 @@ public class WindowTransformSwipeHandler implements SwipeAnimationListener, OnApplyWindowInsetsListener { private static final String TAG = WindowTransformSwipeHandler.class.getSimpleName(); - private static final String[] STATE_NAMES = DEBUG_STATES ? new String[19] : null; + private static final String[] STATE_NAMES = DEBUG_STATES ? new String[16] : null; private static int getFlagForIndex(int index, String name) { if (DEBUG_STATES) { @@ -126,47 +123,44 @@ public class WindowTransformSwipeHandler private static final int STATE_LAUNCHER_PRESENT = getFlagForIndex(0, "STATE_LAUNCHER_PRESENT"); private static final int STATE_LAUNCHER_STARTED = getFlagForIndex(1, "STATE_LAUNCHER_STARTED"); private static final int STATE_LAUNCHER_DRAWN = getFlagForIndex(2, "STATE_LAUNCHER_DRAWN"); - private static final int STATE_ACTIVITY_MULTIPLIER_COMPLETE = - getFlagForIndex(3, "STATE_ACTIVITY_MULTIPLIER_COMPLETE"); // Internal initialization states private static final int STATE_APP_CONTROLLER_RECEIVED = - getFlagForIndex(4, "STATE_APP_CONTROLLER_RECEIVED"); + getFlagForIndex(3, "STATE_APP_CONTROLLER_RECEIVED"); // Interaction finish states private static final int STATE_SCALED_CONTROLLER_HOME = - getFlagForIndex(5, "STATE_SCALED_CONTROLLER_HOME"); + getFlagForIndex(4, "STATE_SCALED_CONTROLLER_HOME"); private static final int STATE_SCALED_CONTROLLER_RECENTS = - getFlagForIndex(6, "STATE_SCALED_CONTROLLER_RECENTS"); + getFlagForIndex(5, "STATE_SCALED_CONTROLLER_RECENTS"); private static final int STATE_SCALED_CONTROLLER_LAST_TASK = - getFlagForIndex(7, "STATE_SCALED_CONTROLLER_LAST_TASK"); + getFlagForIndex(6, "STATE_SCALED_CONTROLLER_LAST_TASK"); private static final int STATE_HANDLER_INVALIDATED = - getFlagForIndex(8, "STATE_HANDLER_INVALIDATED"); + getFlagForIndex(7, "STATE_HANDLER_INVALIDATED"); private static final int STATE_GESTURE_STARTED = - getFlagForIndex(9, "STATE_GESTURE_STARTED"); + getFlagForIndex(8, "STATE_GESTURE_STARTED"); private static final int STATE_GESTURE_CANCELLED = - getFlagForIndex(10, "STATE_GESTURE_CANCELLED"); + getFlagForIndex(9, "STATE_GESTURE_CANCELLED"); private static final int STATE_GESTURE_COMPLETED = - getFlagForIndex(11, "STATE_GESTURE_COMPLETED"); + getFlagForIndex(10, "STATE_GESTURE_COMPLETED"); private static final int STATE_CAPTURE_SCREENSHOT = - getFlagForIndex(12, "STATE_CAPTURE_SCREENSHOT"); + getFlagForIndex(11, "STATE_CAPTURE_SCREENSHOT"); private static final int STATE_SCREENSHOT_CAPTURED = - getFlagForIndex(13, "STATE_SCREENSHOT_CAPTURED"); + getFlagForIndex(12, "STATE_SCREENSHOT_CAPTURED"); private static final int STATE_SCREENSHOT_VIEW_SHOWN = - getFlagForIndex(14, "STATE_SCREENSHOT_VIEW_SHOWN"); + getFlagForIndex(13, "STATE_SCREENSHOT_VIEW_SHOWN"); private static final int STATE_RESUME_LAST_TASK = - getFlagForIndex(15, "STATE_RESUME_LAST_TASK"); + getFlagForIndex(14, "STATE_RESUME_LAST_TASK"); private static final int STATE_START_NEW_TASK = - getFlagForIndex(16, "STATE_START_NEW_TASK"); + getFlagForIndex(15, "STATE_START_NEW_TASK"); private static final int STATE_CURRENT_TASK_FINISHED = - getFlagForIndex(17, "STATE_CURRENT_TASK_FINISHED"); + getFlagForIndex(16, "STATE_CURRENT_TASK_FINISHED"); private static final int LAUNCHER_UI_STATES = - STATE_LAUNCHER_PRESENT | STATE_LAUNCHER_DRAWN | STATE_ACTIVITY_MULTIPLIER_COMPLETE - | STATE_LAUNCHER_STARTED; + STATE_LAUNCHER_PRESENT | STATE_LAUNCHER_DRAWN | STATE_LAUNCHER_STARTED; // For debugging, keep in sync with above states @@ -226,7 +220,6 @@ public class WindowTransformSwipeHandler // 1 => preview snapShot is completely aligned with the recents view and hotseat is completely // visible. private final AnimatedFloat mCurrentShift = new AnimatedFloat(this::updateFinalShift); - private boolean mDispatchedDownEvent; private boolean mContinuingLastGesture; // To avoid UI jump when gesture is started, we offset the animation by the threshold. private float mShiftAtGestureStart = 0; @@ -238,7 +231,6 @@ public class WindowTransformSwipeHandler private final ActivityInitListener mActivityInitListener; private final int mRunningTaskId; - private final RunningTaskInfo mRunningTaskInfo; private ThumbnailData mTaskSnapshot; private MultiStateCallback mStateCallback; @@ -265,7 +257,6 @@ public class WindowTransformSwipeHandler long touchTimeMs, ActivityControlHelper controller, boolean continuingLastGesture, InputConsumerController inputConsumer) { mContext = context; - mRunningTaskInfo = runningTaskInfo; mRunningTaskId = runningTaskInfo.id; mTouchTimeMs = touchTimeMs; mActivityControlHelper = controller; @@ -312,8 +303,7 @@ public class WindowTransformSwipeHandler this::startNewTask); mStateCallback.addCallback(STATE_LAUNCHER_PRESENT | STATE_APP_CONTROLLER_RECEIVED - | STATE_ACTIVITY_MULTIPLIER_COMPLETE - | STATE_CAPTURE_SCREENSHOT, + | STATE_LAUNCHER_DRAWN | STATE_CAPTURE_SCREENSHOT, this::switchToScreenshot); mStateCallback.addCallback(STATE_SCREENSHOT_CAPTURED | STATE_GESTURE_COMPLETED @@ -322,13 +312,13 @@ public class WindowTransformSwipeHandler mStateCallback.addCallback(STATE_LAUNCHER_PRESENT | STATE_GESTURE_COMPLETED | STATE_SCALED_CONTROLLER_HOME | STATE_APP_CONTROLLER_RECEIVED - | STATE_ACTIVITY_MULTIPLIER_COMPLETE, + | STATE_LAUNCHER_DRAWN, this::finishCurrentTransitionToHome); mStateCallback.addCallback(STATE_SCALED_CONTROLLER_HOME | STATE_CURRENT_TASK_FINISHED, this::reset); mStateCallback.addCallback(STATE_LAUNCHER_PRESENT | STATE_APP_CONTROLLER_RECEIVED - | STATE_ACTIVITY_MULTIPLIER_COMPLETE | STATE_SCALED_CONTROLLER_RECENTS + | STATE_LAUNCHER_DRAWN | STATE_SCALED_CONTROLLER_RECENTS | STATE_CURRENT_TASK_FINISHED | STATE_GESTURE_COMPLETED | STATE_GESTURE_STARTED, this::setupLauncherUiAfterSwipeUpAnimation); @@ -440,11 +430,10 @@ public class WindowTransformSwipeHandler AbstractFloatingView.closeAllOpenViews(activity, mWasLauncherAlreadyVisible); if (mWasLauncherAlreadyVisible) { - mStateCallback.setState(STATE_ACTIVITY_MULTIPLIER_COMPLETE | STATE_LAUNCHER_DRAWN); + mStateCallback.setState(STATE_LAUNCHER_DRAWN); } else { TraceHelper.beginSection("WTS-init"); View dragLayer = activity.getDragLayer(); - mActivityControlHelper.getAlphaProperty(activity).setValue(0); dragLayer.getViewTreeObserver().addOnDrawListener(new OnDrawListener() { @Override @@ -477,25 +466,6 @@ public class WindowTransformSwipeHandler } private void launcherFrameDrawn() { - AlphaProperty property = mActivityControlHelper.getAlphaProperty(mActivity); - if (property.getValue() < 1) { - if (mGestureStarted) { - final MultiStateCallback callback = mStateCallback; - ObjectAnimator animator = ObjectAnimator.ofFloat( - property, MultiValueAlpha.VALUE, 1); - animator.setDuration(getFadeInDuration()).addListener( - new AnimatorListenerAdapter() { - @Override - public void onAnimationEnd(Animator animation) { - callback.setState(STATE_ACTIVITY_MULTIPLIER_COMPLETE); - } - }); - animator.start(); - } else { - property.setValue(1); - mStateCallback.setState(STATE_ACTIVITY_MULTIPLIER_COMPLETE); - } - } mLauncherFrameDrawnTime = SystemClock.uptimeMillis(); } @@ -1074,7 +1044,6 @@ public class WindowTransformSwipeHandler private void invalidateHandlerWithLauncher() { mLauncherTransitionController = null; - mActivityControlHelper.getAlphaProperty(mActivity).setValue(1); mRecentsView.setEnableFreeScroll(true); mRecentsView.setRunningTaskIconScaledDown(false); diff --git a/quickstep/src/com/android/quickstep/ActivityControlHelper.java b/quickstep/src/com/android/quickstep/ActivityControlHelper.java index eccef04286..75be2e48e1 100644 --- a/quickstep/src/com/android/quickstep/ActivityControlHelper.java +++ b/quickstep/src/com/android/quickstep/ActivityControlHelper.java @@ -31,7 +31,6 @@ import android.view.animation.Interpolator; import com.android.launcher3.BaseDraggingActivity; import com.android.launcher3.DeviceProfile; import com.android.launcher3.anim.AnimatorPlaybackController; -import com.android.launcher3.util.MultiValueAlpha.AlphaProperty; import com.android.quickstep.util.RemoteAnimationProvider; import com.android.quickstep.util.RemoteAnimationTargetSet; import com.android.systemui.shared.system.RemoteAnimationTargetCompat; @@ -85,8 +84,6 @@ public interface ActivityControlHelper { return true; } - AlphaProperty getAlphaProperty(T activity); - /** * Used for containerType in {@link com.android.launcher3.logging.UserEventDispatcher} */ diff --git a/src/com/android/launcher3/dragndrop/DragLayer.java b/src/com/android/launcher3/dragndrop/DragLayer.java index f005ce7bf7..6950a1fad6 100644 --- a/src/com/android/launcher3/dragndrop/DragLayer.java +++ b/src/com/android/launcher3/dragndrop/DragLayer.java @@ -63,8 +63,7 @@ public class DragLayer extends BaseDragLayer { public static final int ALPHA_INDEX_OVERLAY = 0; public static final int ALPHA_INDEX_LAUNCHER_LOAD = 1; public static final int ALPHA_INDEX_TRANSITIONS = 2; - public static final int ALPHA_INDEX_SWIPE_UP = 3; - private static final int ALPHA_CHANNEL_COUNT = 4; + private static final int ALPHA_CHANNEL_COUNT = 3; public static final int ANIMATION_END_DISAPPEAR = 0; public static final int ANIMATION_END_REMAIN_VISIBLE = 2;