From bec00acf2812d34fb35cdfc69beed5e9b1f2d984 Mon Sep 17 00:00:00 2001 From: Tracy Zhou Date: Sun, 12 Dec 2021 11:16:29 +0800 Subject: [PATCH] Delay showing task bar until the user releases their finger dragging from all apps to normal Fixes: 208802276 Test: drag from all apps to normal, and the task bar doesn't stash until the user releases their finger Change-Id: I53133cc80749bdc62e77d858b5714ae32facbd1d --- .../taskbar/LauncherTaskbarUIController.java | 5 +++++ .../taskbar/TaskbarLauncherStateController.java | 15 ++++++++++++++- ...NoButtonNavbarToOverviewTouchController.java | 17 +++++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java b/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java index 5e8db69f2b..d2ac7c117f 100644 --- a/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java +++ b/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java @@ -113,6 +113,11 @@ public class LauncherTaskbarUIController extends TaskbarUIController { return !mTaskbarLauncherStateController.isAnimatingToLauncher(); } + public void setShouldDelayLauncherStateAnim(boolean shouldDelayLauncherStateAnim) { + mTaskbarLauncherStateController.setShouldDelayLauncherStateAnim( + shouldDelayLauncherStateAnim); + } + /** * Should be called from onResume() and onPause(), and animates the Taskbar accordingly. */ diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java index e2ba459068..49843d5d77 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java @@ -73,6 +73,8 @@ import java.util.function.Supplier; private boolean mIsAnimatingToLauncherViaGesture; private boolean mIsAnimatingToLauncherViaResume; + private boolean mShouldDelayLauncherStateAnim; + private final StateManager.StateListener mStateListener = new StateManager.StateListener() { @@ -85,7 +87,9 @@ import java.util.function.Supplier; mLauncherState = toState; } updateStateForFlag(FLAG_TRANSITION_STATE_RUNNING, true); - applyState(); + if (!mShouldDelayLauncherStateAnim) { + applyState(); + } } @Override @@ -153,6 +157,15 @@ import java.util.function.Supplier; return mIsAnimatingToLauncherViaResume || mIsAnimatingToLauncherViaGesture; } + public void setShouldDelayLauncherStateAnim(boolean shouldDelayLauncherStateAnim) { + if (!shouldDelayLauncherStateAnim && mShouldDelayLauncherStateAnim) { + // Animate the animation we have delayed immediately. This is usually triggered when + // the user has released their finger. + applyState(); + } + mShouldDelayLauncherStateAnim = shouldDelayLauncherStateAnim; + } + /** * Updates the proper flag to change the state of the task bar. * diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java index ef6f53e8f5..7ec12439cb 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java @@ -18,6 +18,7 @@ package com.android.launcher3.uioverrides.touchcontrollers; import static com.android.launcher3.LauncherAnimUtils.VIEW_BACKGROUND_COLOR; import static com.android.launcher3.LauncherAnimUtils.newCancelListener; +import static com.android.launcher3.LauncherState.ALL_APPS; import static com.android.launcher3.LauncherState.HINT_STATE; import static com.android.launcher3.LauncherState.NORMAL; import static com.android.launcher3.LauncherState.OVERVIEW; @@ -33,11 +34,13 @@ import android.graphics.PointF; import android.view.MotionEvent; import android.view.ViewConfiguration; +import com.android.launcher3.BaseQuickstepLauncher; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherState; import com.android.launcher3.Utilities; import com.android.launcher3.anim.AnimatorPlaybackController; import com.android.launcher3.states.StateAnimationConfig; +import com.android.launcher3.taskbar.LauncherTaskbarUIController; import com.android.quickstep.SystemUiProxy; import com.android.quickstep.util.AnimatorControllerWithResistance; import com.android.quickstep.util.MotionPauseDetector; @@ -109,6 +112,14 @@ public class NoButtonNavbarToOverviewTouchController extends PortraitStatesTouch @Override public void onDragStart(boolean start, float startDisplacement) { + if (mLauncher.isInState(ALL_APPS)) { + LauncherTaskbarUIController controller = + ((BaseQuickstepLauncher) mLauncher).getTaskbarUIController(); + if (controller != null) { + controller.setShouldDelayLauncherStateAnim(true); + } + } + super.onDragStart(start, startDisplacement); mMotionPauseDetector.clear(); @@ -139,6 +150,12 @@ public class NoButtonNavbarToOverviewTouchController extends PortraitStatesTouch @Override public void onDragEnd(float velocity) { + LauncherTaskbarUIController controller = + ((BaseQuickstepLauncher) mLauncher).getTaskbarUIController(); + if (controller != null) { + controller.setShouldDelayLauncherStateAnim(false); + } + if (mStartedOverview) { goToOverviewOrHomeOnDragEnd(velocity); } else {