diff --git a/quickstep/src/com/android/quickstep/LongSwipeHelper.java b/quickstep/src/com/android/quickstep/LongSwipeHelper.java index fbcde8bba2..336be2bd8d 100644 --- a/quickstep/src/com/android/quickstep/LongSwipeHelper.java +++ b/quickstep/src/com/android/quickstep/LongSwipeHelper.java @@ -20,11 +20,8 @@ import static com.android.launcher3.LauncherState.ALL_APPS; import static com.android.launcher3.LauncherState.OVERVIEW; import static com.android.launcher3.anim.Interpolators.DEACCEL; import static com.android.quickstep.WindowTransformSwipeHandler.MAX_SWIPE_DURATION; -import static com.android.systemui.shared.recents.utilities.Utilities.getNextFrameNumber; -import static com.android.systemui.shared.recents.utilities.Utilities.getSurface; import android.animation.ValueAnimator; -import android.view.Surface; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherAnimUtils; @@ -39,7 +36,6 @@ import com.android.launcher3.util.FlingBlockCheck; import com.android.quickstep.util.RemoteAnimationTargetSet; import com.android.quickstep.views.RecentsView; import com.android.systemui.shared.system.RemoteAnimationTargetCompat; -import com.android.systemui.shared.system.TransactionCompat; /** * Utility class to handle long swipe from an app. @@ -65,7 +61,6 @@ public class LongSwipeHelper { } private void init() { - setTargetAlpha(0, true); mFlingBlockCheck.blockFling(); // Init animations @@ -83,8 +78,7 @@ public class LongSwipeHelper { } public void destroy() { - // TODO: We can probably also hide the task view - setTargetAlpha(1, false); + // TODO: We can probably also show the task view mLauncher.getStateManager().goToState(OVERVIEW, false); } @@ -136,31 +130,6 @@ public class LongSwipeHelper { animator.start(); } - private void setTargetAlpha(float alpha, boolean defer) { - final Surface surface = getSurface(mLauncher.getDragLayer()); - final long frameNumber = defer && surface != null ? getNextFrameNumber(surface) : -1; - if (defer) { - if (frameNumber == -1) { - defer = false; - } else { - mLauncher.getDragLayer().invalidate(); - } - } - - TransactionCompat transaction = new TransactionCompat(); - for (RemoteAnimationTargetCompat app : mTargetSet.apps) { - if (!(app.isNotInRecents - || app.activityType == RemoteAnimationTargetCompat.ACTIVITY_TYPE_HOME)) { - transaction.setAlpha(app.leash, alpha); - if (defer) { - transaction.deferTransactionUntil(app.leash, surface, frameNumber); - } - } - } - transaction.setEarlyWakeup(); - transaction.apply(); - } - private void onSwipeAnimationComplete(boolean toAllApps, boolean isFling, Runnable callback) { mLauncher.getStateManager().goToState(toAllApps ? ALL_APPS : OVERVIEW, false); if (!toAllApps) { @@ -176,4 +145,12 @@ public class LongSwipeHelper { callback.run(); } + + public float getTargetAlpha(RemoteAnimationTargetCompat app, Float expectedAlpha) { + if (!(app.isNotInRecents + || app.activityType == RemoteAnimationTargetCompat.ACTIVITY_TYPE_HOME)) { + return 0; + } + return expectedAlpha; + } } diff --git a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java index 584c7f4fa2..765b5ffb31 100644 --- a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java +++ b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java @@ -85,6 +85,7 @@ import com.android.systemui.shared.system.WindowCallbacksCompat; import com.android.systemui.shared.system.WindowManagerWrapper; import java.util.StringJoiner; +import java.util.function.BiFunction; @TargetApi(Build.VERSION_CODES.O) public class WindowTransformSwipeHandler { @@ -927,6 +928,7 @@ public class WindowTransformSwipeHandler { if (mLongSwipeController != null) { mLongSwipeController.destroy(); + setTargetAlphaProvider((t, a1) -> a1); // Rebuild animations buildAnimationController(); @@ -968,6 +970,7 @@ public class WindowTransformSwipeHandler { mLongSwipeController = mActivityControlHelper.getLongSwipeController( mActivity, mRecentsAnimationWrapper.targetSet); onLongSwipeDisplacementUpdated(); + setTargetAlphaProvider(mLongSwipeController::getTargetAlpha); } private void onLongSwipeGestureFinishUi(float velocity, boolean isFling) { @@ -982,4 +985,12 @@ public class WindowTransformSwipeHandler { () -> setStateOnUiThread(STATE_HANDLER_INVALIDATED)); } + + private void setTargetAlphaProvider( + BiFunction provider) { + mClipAnimationHelper.setTaskAlphaCallback(provider); + // TODO: For some reason, when calling updateFinalShift multiple times on the same frame, + // only the first callback is executed. + Utilities.postAsyncCallback(mMainThreadHandler, this::updateFinalShift); + } }