From ef44cf8f4580e389a000879c5532bbaaaa288612 Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Mon, 11 May 2020 13:27:54 -0700 Subject: [PATCH] Fixing pullback factor not initialized after launcher process death Instead of storing it on first swipe-up, computing it when required Change-Id: I4b37002a016328e3b2d1c8535198ec8a6b56faf3 --- .../android/quickstep/BaseSwipeUpHandler.java | 24 ++++++++++--------- .../quickstep/LauncherActivityInterface.java | 15 ------------ .../quickstep/BaseActivityInterface.java | 10 -------- 3 files changed, 13 insertions(+), 36 deletions(-) diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java index f76b18b920..40afebdcf1 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java @@ -36,7 +36,6 @@ import android.graphics.PointF; import android.graphics.Rect; import android.graphics.RectF; import android.os.Build; -import android.util.Pair; import android.view.MotionEvent; import android.view.View; import android.view.animation.Interpolator; @@ -347,21 +346,24 @@ public abstract class BaseSwipeUpHandler dragFactorStartAndMaxProgress = - mActivityInterface.getSwipeUpPullbackStartAndMaxProgress(); - mDragLengthFactorStartPullback = dragFactorStartAndMaxProgress.first; - mDragLengthFactorMaxPullback = dragFactorStartAndMaxProgress.second; - } - mTaskViewSimulator.setDp(dp); mTaskViewSimulator.setLayoutRotation( mDeviceState.getCurrentActiveRotation(), mDeviceState.getDisplayRotation()); + if (mDeviceState.isFullyGesturalNavMode()) { + // We can drag all the way to the top of the screen. + mDragLengthFactor = (float) dp.heightPx / mTransitionDragLength; + + float startScale = mTaskViewSimulator.getFullScreenScale(); + // Start pulling back when RecentsView scale is 0.75f, and let it go down to 0.5f. + mDragLengthFactorStartPullback = (0.75f - startScale) / (1 - startScale); + mDragLengthFactorMaxPullback = (0.5f - startScale) / (1 - startScale); + } else { + mDragLengthFactor = 1; + mDragLengthFactorStartPullback = mDragLengthFactorMaxPullback = 1; + } + AnimatorSet anim = new AnimatorSet(); anim.setDuration(mTransitionDragLength * 2); anim.setInterpolator(t -> t * mDragLengthFactor); diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityInterface.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityInterface.java index dc35bf6dc0..9495338d4f 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityInterface.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityInterface.java @@ -34,7 +34,6 @@ import android.animation.ObjectAnimator; import android.content.Context; import android.graphics.Rect; import android.util.Log; -import android.util.Pair; import android.view.MotionEvent; import android.view.animation.Interpolator; @@ -72,9 +71,6 @@ import java.util.function.Predicate; */ public final class LauncherActivityInterface implements BaseActivityInterface { - private Pair mSwipeUpPullbackStartAndMaxProgress = - BaseActivityInterface.super.getSwipeUpPullbackStartAndMaxProgress(); - @Override public int getSwipeUpDestinationAndLength(DeviceProfile dp, Context context, Rect outRect) { LAUNCHER_ACTIVITY_SIZE_STRATEGY.calculateTaskSize(context, dp, outRect); @@ -87,11 +83,6 @@ public final class LauncherActivityInterface implements BaseActivityInterface getSwipeUpPullbackStartAndMaxProgress() { - return mSwipeUpPullbackStartAndMaxProgress; - } - @Override public void onTransitionCancelled(boolean activityVisible) { Launcher launcher = getCreatedActivity(); @@ -282,12 +273,6 @@ public final class LauncherActivityInterface implements BaseActivityInterface( - pullbackStartProgress, pullbackMaxProgress); } @Override diff --git a/quickstep/src/com/android/quickstep/BaseActivityInterface.java b/quickstep/src/com/android/quickstep/BaseActivityInterface.java index bdddb3f8aa..9bf06cc89a 100644 --- a/quickstep/src/com/android/quickstep/BaseActivityInterface.java +++ b/quickstep/src/com/android/quickstep/BaseActivityInterface.java @@ -19,7 +19,6 @@ import android.annotation.TargetApi; import android.content.Context; import android.graphics.Rect; import android.os.Build; -import android.util.Pair; import android.view.MotionEvent; import android.view.View; import android.view.animation.Interpolator; @@ -49,15 +48,6 @@ public interface BaseActivityInterface { int getSwipeUpDestinationAndLength(DeviceProfile dp, Context context, Rect outRect); - /** - * @return The progress of the swipe where we start resisting the user, where 0 is fullscreen - * and 1 is recents. These values should probably be greater than 1 to let the user swipe past - * recents before we start resisting them. - */ - default Pair getSwipeUpPullbackStartAndMaxProgress() { - return new Pair<>(1.4f, 1.8f); - } - void onSwipeUpToRecentsComplete(); default void onSwipeUpToHomeComplete() { }