Modify Taskbar code to accommodate bubble bar gesture to stash/unstash

* Bubble bar typically follows the behavior of taskbar - if taskbar
  is shown, the bubble bar is shown, if taskbar hides, bubble bar
  hides.
* The bubble bar has 3 states: stashed, collapsed (unstashed but
  the bubbles are not expanded), and expanded. When bubbles are
  expanded, this means WMShell is rendering the bubble
  expanded view. In this situation taskbar becomes collapsed.

Bug: 253318833
Test: manual - flag turned on - see go/bubble-bar-tests
Test: manual - flag turned off:
             - launch an app, ensure taskbar is stashed
             - unstash taskbar, drag down on taskbar, ensure it
               becomes stashed
             - be in an app, unstash taskbar, interact with the app,
               ensure taskbar is stashed
             - be in an app, unstash taskbar, select an app from it,
               ensure taskbar is stashed & app is opened
Flag: WM_BUBBLE_BAR
Change-Id: I7b481d768182c8429160ab4a9b213b885a7d78bc
This commit is contained in:
Mady Mellor committed 2023-05-23 14:02:50 -07:00
1 parent 7bae2b82ef
commit 6dea6d1624
10 files changed
+183 -36

No files matched your search

@@ -255,14 +255,15 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
private boolean mEnableBlockingTimeoutDuringTests = false;
// Evaluate whether the handle should be stashed
private final IntPredicate mIsStashedPredicate = flags -> {
boolean inApp = hasAnyFlag(flags, FLAGS_IN_APP);
boolean stashedInApp = hasAnyFlag(flags, FLAGS_STASHED_IN_APP);
boolean stashedLauncherState = hasAnyFlag(flags, FLAG_IN_STASHED_LAUNCHER_STATE);
boolean forceStashed = hasAnyFlag(flags, FLAGS_FORCE_STASHED);
return (inApp && stashedInApp) || (!inApp && stashedLauncherState) || forceStashed;
};
private final StatePropertyHolder mStatePropertyHolder = new StatePropertyHolder(
flags -> {
boolean inApp = hasAnyFlag(flags, FLAGS_IN_APP);
boolean stashedInApp = hasAnyFlag(flags, FLAGS_STASHED_IN_APP);
boolean stashedLauncherState = hasAnyFlag(flags, FLAG_IN_STASHED_LAUNCHER_STATE);
boolean forceStashed = hasAnyFlag(flags, FLAGS_FORCE_STASHED);
return (inApp && stashedInApp) || (!inApp && stashedLauncherState) || forceStashed;
});
mIsStashedPredicate);
private boolean mIsTaskbarSystemActionRegistered = false;
private TaskbarSharedState mTaskbarSharedState;
@@ -501,9 +502,19 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
}
/**
* Stash or unstashes the transient taskbar.
* Stash or unstashes the transient taskbar, using the default TASKBAR_STASH_DURATION.
* If bubble bar exists, it will match taskbars stashing behavior.
*/
public void updateAndAnimateTransientTaskbar(boolean stash) {
updateAndAnimateTransientTaskbar(stash, /* shouldBubblesFollow= */ true);
}
/**
* Stash or unstashes the transient taskbar.
* @param stash whether transient taskbar should be stashed.
* @param shouldBubblesFollow whether bubbles should match taskbars behavior.
*/
public void updateAndAnimateTransientTaskbar(boolean stash, boolean shouldBubblesFollow) {
if (!DisplayController.isTransientTaskbar(mActivity)) {
return;
}
@@ -519,6 +530,34 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
updateStateForFlag(FLAG_STASHED_IN_APP_AUTO, stash);
applyState();
}
mControllers.bubbleControllers.ifPresent(controllers -> {
if (shouldBubblesFollow) {
final boolean willStash = mIsStashedPredicate.test(mState);
if (willStash != controllers.bubbleStashController.isStashed()) {
// Typically bubbles gets stashed / unstashed along with Taskbar, however, if
// taskbar is becoming stashed because bubbles is being expanded, we don't want
// to stash bubbles.
if (willStash) {
controllers.bubbleStashController.stashBubbleBar();
} else {
controllers.bubbleStashController.showBubbleBar(false /* expandBubbles */);
}
}
}
});
}
/**
* Stashes transient taskbar after it has timed out.
*/
private void updateAndAnimateTransientTaskbarForTimeout() {
// If bubbles are expanded we shouldn't stash them when taskbar is hidden
// for the timeout.
boolean bubbleBarExpanded = mControllers.bubbleControllers.isPresent()
&& mControllers.bubbleControllers.get().bubbleBarViewController.isExpanded();
updateAndAnimateTransientTaskbar(/* stash= */ true,
/* shouldBubblesFollow= */ !bubbleBarExpanded);
}
/**
@@ -886,7 +925,7 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
private void onIsStashedChanged(boolean isStashed) {
mControllers.runAfterInit(() -> {
mControllers.stashedHandleViewController.onIsStashedChanged(isStashed);
mControllers.taskbarInsetsController.onTaskbarWindowHeightOrInsetsChanged();
mControllers.taskbarInsetsController.onTaskbarOrBubblebarWindowHeightOrInsetsChanged();
});
}
@@ -1133,7 +1172,7 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
if (mControllers.taskbarAutohideSuspendController.isSuspended()) {
return;
}
updateAndAnimateTransientTaskbar(true);
updateAndAnimateTransientTaskbarForTimeout();
}
@Override