diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index 935e662784..68bd12ac38 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -315,6 +315,7 @@ public abstract class AbsSwipeUpHandler, private final float mQuickSwitchScaleScrollThreshold; private final int mTaskbarAppWindowThreshold; + private final int mTaskbarHomeOverviewThreshold; private final int mTaskbarCatchUpThreshold; private boolean mTaskbarAlreadyOpen; private final boolean mIsTransientTaskbar; @@ -343,21 +344,29 @@ public abstract class AbsSwipeUpHandler, mContinuingLastGesture = continuingLastGesture; Resources res = context.getResources(); - mTaskbarAppWindowThreshold = res - .getDimensionPixelSize(ENABLE_TASKBAR_REVISED_THRESHOLDS.get() - ? R.dimen.taskbar_app_window_threshold_v2 - : R.dimen.taskbar_app_window_threshold); - mTaskbarCatchUpThreshold = res.getDimensionPixelSize(R.dimen.taskbar_catch_up_threshold); - mIsTransientTaskbar = DisplayController.isTransientTaskbar(mActivity); - mQuickSwitchScaleScrollThreshold = res .getDimension(R.dimen.quick_switch_scaling_scroll_threshold); mSplashMainWindowShiftLength = -res .getDimensionPixelSize(R.dimen.starting_surface_exit_animation_window_shift_length); - initAfterSubclassConstructor(); + initTransitionEndpoints(mRemoteTargetHandles[0].getTaskViewSimulator() + .getOrientationState().getLauncherDeviceProfile()); initStateCallbacks(); + + mIsTransientTaskbar = mDp.isTaskbarPresent + && DisplayController.isTransientTaskbar(mActivity); + TaskbarUIController controller = mActivityInterface.getTaskbarController(); + mTaskbarAlreadyOpen = controller != null && !controller.isTaskbarStashed(); + mTaskbarAppWindowThreshold = res + .getDimensionPixelSize(ENABLE_TASKBAR_REVISED_THRESHOLDS.get() + ? R.dimen.taskbar_app_window_threshold_v2 + : R.dimen.taskbar_app_window_threshold); + mTaskbarHomeOverviewThreshold = res.getDimensionPixelSize( + ENABLE_TASKBAR_REVISED_THRESHOLDS.get() + ? R.dimen.taskbar_home_overview_threshold_v2 + : R.dimen.taskbar_home_overview_threshold); + mTaskbarCatchUpThreshold = res.getDimensionPixelSize(R.dimen.taskbar_catch_up_threshold); } @Nullable @@ -736,18 +745,12 @@ public abstract class AbsSwipeUpHandler, } /** - * Sets whether or not we should clamp the scroll offset. - * This is used to avoid x-axis movement when swiping up transient taskbar. - * @param clampScrollOffset When true, we clamp the scroll to 0 before the clamp threshold is - * met. + * Returns threshold that needs to be met in order for motion pause to be allowed. */ - public void setClampScrollOffset(boolean clampScrollOffset) { - if (mRecentsView == null) { - mStateCallback.runOnceAtState(STATE_LAUNCHER_PRESENT, - () -> mRecentsView.setClampScrollOffset(clampScrollOffset)); - return; - } - mRecentsView.setClampScrollOffset(clampScrollOffset); + public float getThresholdToAllowMotionPause() { + return mIsTransientTaskbar + ? mTaskbarHomeOverviewThreshold + : 0; } public void setIsLikelyToStartNewTask(boolean isLikelyToStartNewTask) { @@ -946,10 +949,33 @@ public abstract class AbsSwipeUpHandler, } notifyGestureStartedAsync(); setIsLikelyToStartNewTask(isLikelyToStartNewTask, false /* animate */); + + if (mIsTransientTaskbar && !mTaskbarAlreadyOpen && !isLikelyToStartNewTask) { + setClampScrollOffset(true); + } mStateCallback.setStateOnUiThread(STATE_GESTURE_STARTED); mGestureStarted = true; } + /** + * Sets whether or not we should clamp the scroll offset. + * This is used to avoid x-axis movement when swiping up transient taskbar. + * @param clampScrollOffset When true, we clamp the scroll to 0 before the clamp threshold is + * met. + */ + private void setClampScrollOffset(boolean clampScrollOffset) { + if (!mIsTransientTaskbar) { + return; + } + if (mRecentsView == null) { + mStateCallback.runOnceAtState(STATE_LAUNCHER_PRESENT, + () -> mRecentsView.setClampScrollOffset(clampScrollOffset)); + return; + } + mRecentsView.setClampScrollOffset(clampScrollOffset); + } + + /** * Notifies the launcher that the swipe gesture has started. This can be called multiple times. */ @@ -1174,6 +1200,8 @@ public abstract class AbsSwipeUpHandler, float currentShift = mCurrentShift.value; final GestureEndTarget endTarget = calculateEndTarget(velocity, endVelocity, isFling, isCancel); + + setClampScrollOffset(false); // Set the state, but don't notify until the animation completes mGestureState.setEndTarget(endTarget, false /* isAtomic */); mAnimationFactory.setEndTarget(endTarget); @@ -1966,15 +1994,6 @@ public abstract class AbsSwipeUpHandler, || app.windowConfiguration.getActivityType() == ACTIVITY_TYPE_HOME; } - /** - * To be called at the end of constructor of subclasses. This calls various methods which can - * depend on proper class initialization. - */ - protected void initAfterSubclassConstructor() { - initTransitionEndpoints(mRemoteTargetHandles[0].getTaskViewSimulator() - .getOrientationState().getLauncherDeviceProfile()); - } - protected void performHapticFeedback() { VibratorWrapper.INSTANCE.get(mContext).vibrate(OVERVIEW_HAPTIC); } @@ -2228,13 +2247,6 @@ public abstract class AbsSwipeUpHandler, return scaleProgress; } - /** - * Updates the current status of taskbar during this swipe. - */ - public void setTaskbarAlreadyOpen(boolean taskbarAlreadyOpen) { - mTaskbarAlreadyOpen = taskbarAlreadyOpen; - } - /** * Overrides the gesture displacement to keep the app window at the bottom of the screen while * the transient taskbar is being swiped in. diff --git a/quickstep/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java index c12bd20ce9..d8c1da0a8a 100644 --- a/quickstep/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java +++ b/quickstep/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java @@ -29,7 +29,6 @@ import static com.android.launcher3.Utilities.EDGE_NAV_BAR; import static com.android.launcher3.Utilities.getXVelocity; import static com.android.launcher3.Utilities.getYVelocity; import static com.android.launcher3.Utilities.squaredHypot; -import static com.android.launcher3.config.FeatureFlags.ENABLE_TASKBAR_REVISED_THRESHOLDS; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import static com.android.launcher3.util.TraceHelper.FLAG_CHECK_FOR_RACE_CONDITIONS; import static com.android.launcher3.util.VelocityUtils.PX_PER_MS; @@ -50,11 +49,9 @@ import androidx.annotation.UiThread; import com.android.launcher3.R; import com.android.launcher3.Utilities; -import com.android.launcher3.taskbar.TaskbarUIController; import com.android.launcher3.testing.TestLogging; import com.android.launcher3.testing.shared.TestProtocol; import com.android.launcher3.tracing.InputConsumerProto; -import com.android.launcher3.util.DisplayController; import com.android.launcher3.util.Preconditions; import com.android.launcher3.util.TraceHelper; import com.android.quickstep.AbsSwipeUpHandler; @@ -135,10 +132,6 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC // Might be displacement in X or Y, depending on the direction we are swiping from the nav bar. private float mStartDisplacement; - private final boolean mIsTransientTaskbar; - private final boolean mTaskbarAlreadyOpen; - private final int mTaskbarHomeOverviewThreshold; - public OtherActivityInputConsumer(Context base, RecentsAnimationDeviceState deviceState, TaskAnimationManager taskAnimationManager, GestureState gestureState, boolean isDeferredDownTarget, Consumer onCompleteCallback, @@ -163,14 +156,6 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC mInputEventReceiver = inputEventReceiver; mMotionEventsHandler = new MotionEventsHandler(base); - TaskbarUIController controller = mActivityInterface.getTaskbarController(); - mTaskbarAlreadyOpen = controller != null && !controller.isTaskbarStashed(); - mIsTransientTaskbar = DisplayController.isTransientTaskbar(base); - mTaskbarHomeOverviewThreshold = base.getResources() - .getDimensionPixelSize(ENABLE_TASKBAR_REVISED_THRESHOLDS.get() - ? R.dimen.taskbar_home_overview_threshold_v2 - : R.dimen.taskbar_home_overview_threshold); - boolean continuingPreviousGesture = mTaskAnimationManager.isRecentsAnimationRunning(); mIsDeferredDownTarget = !continuingPreviousGesture && isDeferredDownTarget; @@ -333,10 +318,8 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC } if (mDeviceState.isFullyGesturalNavMode()) { - boolean minSwipeMet = upDist >= mMotionPauseMinDisplacement; - if (mIsTransientTaskbar) { - minSwipeMet = upDist >= mTaskbarHomeOverviewThreshold; - } + boolean minSwipeMet = upDist >= Math.max(mMotionPauseMinDisplacement, + mInteractionHandler.getThresholdToAllowMotionPause()); mInteractionHandler.setCanSlowSwipeGoHome(minSwipeMet); mMotionPauseDetector.setDisallowPause(!minSwipeMet || isLikelyToStartNewTask); @@ -372,11 +355,6 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC // Notify the handler that the gesture has actually started mInteractionHandler.onGestureStarted(isLikelyToStartNewTask); - - mInteractionHandler.setTaskbarAlreadyOpen(mTaskbarAlreadyOpen); - if (mIsTransientTaskbar && !mTaskbarAlreadyOpen && !isLikelyToStartNewTask) { - mInteractionHandler.setClampScrollOffset(true); - } } private void startTouchTrackingForWindowAnimation(long touchTimeMs) { @@ -474,9 +452,6 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC @UiThread private void onInteractionGestureFinished() { Preconditions.assertUIThread(); - if (mInteractionHandler != null) { - mInteractionHandler.setClampScrollOffset(false); - } removeListener(); mInteractionHandler = null; cleanupAfterGesture(); diff --git a/quickstep/src/com/android/quickstep/views/TaskView.java b/quickstep/src/com/android/quickstep/views/TaskView.java index 4de69cd372..bda30a576b 100644 --- a/quickstep/src/com/android/quickstep/views/TaskView.java +++ b/quickstep/src/com/android/quickstep/views/TaskView.java @@ -1632,7 +1632,7 @@ public class TaskView extends FrameLayout implements Reusable { */ private static RectF getInsetsToDrawInFullscreen(PreviewPositionHelper pph, DeviceProfile dp, boolean isTaskbarTransient) { - if (isTaskbarTransient) { + if (dp.isTaskbarPresent && isTaskbarTransient) { return pph.getClippedInsets(); } return dp.isTaskbarPresent && !dp.isTaskbarPresentInApps