Stash the bar after settling in Overview
Test: https://recall.googleplex.com/projects/81822932-8526-4ee7-b5f7-4ef6d6603f1d/sessions/f0f7a3db-76b6-4f60-87e8-8918bd6cf180
Bug: 193938970
Change-Id: Ic08d3156f5c78a34f353783b760d5cf098e442e8
diff --git a/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java b/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java
index 359f436..68dfac7 100644
--- a/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java
@@ -19,10 +19,12 @@
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_LONGPRESS_HIDE;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_LONGPRESS_SHOW;
import static com.android.launcher3.taskbar.TaskbarStashController.FLAG_IN_APP;
+import static com.android.launcher3.taskbar.TaskbarStashController.FLAG_IN_STASHED_LAUNCHER_STATE;
import static com.android.launcher3.taskbar.TaskbarViewController.ALPHA_INDEX_HOME;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
+import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.graphics.Rect;
import android.view.MotionEvent;
@@ -42,6 +44,7 @@
import com.android.launcher3.logging.InstanceIdSequence;
import com.android.launcher3.model.data.ItemInfoWithIcon;
import com.android.launcher3.model.data.WorkspaceItemInfo;
+import com.android.launcher3.statemanager.StateManager;
import com.android.launcher3.util.MultiValueAlpha;
import com.android.launcher3.util.MultiValueAlpha.AlphaProperty;
import com.android.launcher3.util.OnboardingPrefs;
@@ -76,6 +79,16 @@
private final DeviceProfile.OnDeviceProfileChangeListener mOnDeviceProfileChangeListener =
this::onStashedInAppChanged;
+ private final StateManager.StateListener<LauncherState> mStateListener =
+ new StateManager.StateListener<LauncherState>() {
+ @Override
+ public void onStateTransitionComplete(LauncherState finalState) {
+ TaskbarStashController controller = mControllers.taskbarStashController;
+ controller.updateStateForFlag(FLAG_IN_STASHED_LAUNCHER_STATE,
+ finalState.isTaskbarStashed());
+ }
+ };
+
// Initialized in init.
private TaskbarControllers mControllers;
private AnimatedFloat mTaskbarBackgroundAlpha;
@@ -118,6 +131,7 @@
onStashedInAppChanged(mLauncher.getDeviceProfile());
mLauncher.addOnDeviceProfileChangeListener(mOnDeviceProfileChangeListener);
+ mLauncher.getStateManager().addStateListener(mStateListener);
}
@Override
@@ -127,6 +141,7 @@
mIconAlignmentForGestureState.finishAnimation();
mLauncher.removeOnDeviceProfileChangeListener(mOnDeviceProfileChangeListener);
+ mLauncher.getStateManager().removeStateListener(mStateListener);
mLauncher.getHotseat().setIconsAlpha(1f);
mLauncher.setTaskbarUIController(null);
}
@@ -184,24 +199,28 @@
*/
public Animator createAnimToLauncher(@NonNull LauncherState toState,
@NonNull RecentsAnimationCallbacks callbacks, long duration) {
+ AnimatorSet animatorSet = new AnimatorSet();
TaskbarStashController stashController = mControllers.taskbarStashController;
- ObjectAnimator animator = mIconAlignmentForGestureState
- .animateToValue(1)
- .setDuration(duration);
- animator.addListener(new AnimatorListenerAdapter() {
+ stashController.updateStateForFlag(FLAG_IN_STASHED_LAUNCHER_STATE,
+ toState.isTaskbarStashed());
+ if (toState.isTaskbarStashed()) {
+ animatorSet.play(stashController.applyStateWithoutStart(duration));
+ } else {
+ animatorSet.play(mIconAlignmentForGestureState
+ .animateToValue(1)
+ .setDuration(duration));
+ }
+ animatorSet.addListener(new AnimatorListenerAdapter() {
@Override
- public void onAnimationEnd(Animator animation) {
+ public void onAnimationEnd(Animator animator) {
mTargetStateOverride = null;
animator.removeListener(this);
}
@Override
- public void onAnimationStart(Animator animation) {
+ public void onAnimationStart(Animator animator) {
mTargetStateOverride = toState;
mIsAnimatingToLauncherViaGesture = true;
- // TODO: FLAG_IN_APP might be sufficient for now, but in the future we do want to
- // add another flag for LauncherState as well. We will need to decide whether to
- // show hotseat or the task bar.
stashController.updateStateForFlag(FLAG_IN_APP, false);
stashController.applyState(duration);
}
@@ -215,7 +234,7 @@
callbacks.removeListener(listener);
});
- return animator;
+ return animatorSet;
}
private float getCurrentIconAlignmentRatio() {
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java
index fc277cc..a9ff03b 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java
@@ -41,6 +41,7 @@
public static final int FLAG_IN_APP = 1 << 0;
public static final int FLAG_STASHED_IN_APP = 1 << 1;
+ public static final int FLAG_IN_STASHED_LAUNCHER_STATE = 1 << 2;
/**
* How long to stash/unstash when manually invoked via long press.
@@ -83,9 +84,6 @@
private final int mStashedHeight;
private final int mUnstashedHeight;
- private final StatePropertyHolder mStatePropertyHolder = new StatePropertyHolder(
- flags -> (((flags & FLAG_IN_APP) != 0) && (flags & FLAG_STASHED_IN_APP) != 0));
-
// Initialized in init.
private TaskbarControllers mControllers;
// Taskbar background properties.
@@ -106,6 +104,18 @@
private @Nullable AnimatorSet mAnimator;
+ // Evaluate whether the handle should be stashed
+ private final StatePropertyHolder mStatePropertyHolder = new StatePropertyHolder(
+ flags -> {
+ if (!supportsStashing()) {
+ return false;
+ }
+ boolean inApp = (flags & FLAG_IN_APP) != 0;
+ boolean stashedInApp = (flags & FLAG_STASHED_IN_APP) != 0;
+ boolean stashedLauncherState = (flags & FLAG_IN_STASHED_LAUNCHER_STATE) != 0;
+ return (inApp && stashedInApp) || (!inApp && stashedLauncherState);
+ });
+
public TaskbarStashController(TaskbarActivityContext activity) {
mActivity = activity;
mPrefs = Utilities.getPrefs(mActivity);
@@ -331,7 +341,15 @@
}
public void applyState(long duration) {
- mStatePropertyHolder.setState(mState, duration);
+ mStatePropertyHolder.setState(mState, duration, true);
+ }
+
+ public Animator applyStateWithoutStart() {
+ return applyStateWithoutStart(TASKBAR_STASH_DURATION);
+ }
+
+ public Animator applyStateWithoutStart(long duration) {
+ return mStatePropertyHolder.setState(mState, duration, false);
}
/**
@@ -360,12 +378,16 @@
mStashCondition = stashCondition;
}
- public void setState(int flags, long duration) {
+ public Animator setState(int flags, long duration, boolean start) {
boolean isStashed = mStashCondition.test(flags);
if (mIsStashed != isStashed) {
mIsStashed = isStashed;
- createAnimToIsStashed(mIsStashed, duration).start();
+ Animator animator = createAnimToIsStashed(mIsStashed, duration);
+ if (start) {
+ animator.start();
+ }
}
+ return mAnimator;
}
}
}
diff --git a/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java b/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java
index 1302ac0..d396018 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java
@@ -97,6 +97,11 @@
}
@Override
+ public boolean isTaskbarStashed() {
+ return true;
+ }
+
+ @Override
public int getWorkspaceScrimColor(Launcher launcher) {
return Themes.getAttrColor(launcher, R.attr.overviewScrimColor);
}
diff --git a/src/com/android/launcher3/LauncherState.java b/src/com/android/launcher3/LauncherState.java
index 7985ab5..15378e0 100644
--- a/src/com/android/launcher3/LauncherState.java
+++ b/src/com/android/launcher3/LauncherState.java
@@ -197,6 +197,10 @@
return (getVisibleElements(launcher) & elements) == elements;
}
+ public boolean isTaskbarStashed() {
+ return false;
+ }
+
/**
* Fraction shift in the vertical translation UI and related properties
*