Hide hotseat when bubble bar is expanded.

Added logic to stash the hotseat when on launcher home screen.

Bug: 280494203
Test: Manual:
http://recall/-/gx8ASgewUeUS3QYohfrd1J/fjfjUw296LRXUm9uYqXU4K
all tests in com.android.launcher3.taskbar
Flag: com.android.wm.shell.enable_bubble_bar

Change-Id: I67b298831eaed9c549a2fae7dc5a0d9fae51f7c4
This commit is contained in:
Liran Binyamin authored and mpodolian committed 2024-09-16 15:50:28 -07:00
1 parent 9c749aaf2d
commit 69f4974e24
10 files changed
+179 -40

No files matched your search

@@ -17,9 +17,12 @@ package com.android.launcher3.taskbar;
import static com.android.app.animation.Interpolators.EMPHASIZED;
import static com.android.launcher3.LauncherState.HOTSEAT_ICONS;
import static com.android.launcher3.Hotseat.ALPHA_CHANNEL_TASKBAR_ALIGNMENT;
import static com.android.launcher3.Hotseat.ALPHA_CHANNEL_TASKBAR_STASH;
import static com.android.launcher3.taskbar.TaskbarStashController.FLAG_IN_APP;
import static com.android.launcher3.taskbar.TaskbarStashController.FLAG_IN_OVERVIEW;
import static com.android.launcher3.taskbar.TaskbarStashController.FLAG_IN_STASHED_LAUNCHER_STATE;
import static com.android.launcher3.taskbar.TaskbarStashController.FLAG_STASHED_FOR_BUBBLES;
import static com.android.launcher3.taskbar.TaskbarViewController.ALPHA_INDEX_HOME;
import static com.android.launcher3.util.FlagDebugUtils.appendFlag;
import static com.android.launcher3.util.FlagDebugUtils.formatFlagChange;
@@ -41,6 +44,7 @@ import androidx.annotation.Nullable;
import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Hotseat.HotseatQsbAlphaId;
import com.android.launcher3.LauncherState;
import com.android.launcher3.QuickstepTransitionManager;
import com.android.launcher3.Utilities;
@@ -145,7 +149,7 @@ public class TaskbarLauncherStateController {
private AnimatedFloat mTaskbarBackgroundAlpha;
private AnimatedFloat mTaskbarAlpha;
private AnimatedFloat mTaskbarCornerRoundness;
private MultiProperty mIconAlphaForHome;
private MultiProperty mTaskbarAlphaForHome;
private QuickstepLauncher mLauncher;
private boolean mIsDestroyed = false;
@@ -175,11 +179,11 @@ public class TaskbarLauncherStateController {
if (mIsQsbInline && !dp.isQsbInline) {
// We only modify QSB alpha if isQsbInline = true. If we switch to a DP
// where isQsbInline = false, then we need to reset the alpha.
mLauncher.getHotseat().setQsbAlpha(1f);
mLauncher.getHotseat().setQsbAlpha(1f, ALPHA_CHANNEL_TASKBAR_ALIGNMENT);
}
mIsQsbInline = dp.isQsbInline;
TaskbarLauncherStateController.this.updateIconAlphaForHome(
mIconAlphaForHome.getValue());
mTaskbarAlphaForHome.getValue(), ALPHA_CHANNEL_TASKBAR_ALIGNMENT);
}
};
@@ -242,7 +246,7 @@ public class TaskbarLauncherStateController {
.getTaskbarBackgroundAlpha();
mTaskbarAlpha = mControllers.taskbarDragLayerController.getTaskbarAlpha();
mTaskbarCornerRoundness = mControllers.getTaskbarCornerRoundness();
mIconAlphaForHome = mControllers.taskbarViewController
mTaskbarAlphaForHome = mControllers.taskbarViewController
.getTaskbarIconAlpha().get(ALPHA_INDEX_HOME);
resetIconAlignment();
@@ -266,7 +270,7 @@ public class TaskbarLauncherStateController {
mIconAlignment.finishAnimation();
mLauncher.getHotseat().setIconsAlpha(1f);
mLauncher.getHotseat().setIconsAlpha(1f, ALPHA_CHANNEL_TASKBAR_ALIGNMENT);
mLauncher.getStateManager().removeStateListener(mStateListener);
mCanSyncViews = !mControllers.taskbarActivityContext.isPhoneMode();
@@ -701,14 +705,17 @@ public class TaskbarLauncherStateController {
public void onAnimationEnd(Animator animation) {
if (isInStashedState && committed) {
// Reset hotseat alpha to default
mLauncher.getHotseat().setIconsAlpha(1);
mLauncher.getHotseat().setIconsAlpha(1, ALPHA_CHANNEL_TASKBAR_ALIGNMENT);
}
}
@Override
public void onAnimationStart(Animator animation) {
if (mLauncher.getHotseat().getIconsAlpha() > 0) {
updateIconAlphaForHome(mLauncher.getHotseat().getIconsAlpha());
float hotseatIconsAlpha = mLauncher.getHotseat()
.getIconsAlpha(ALPHA_CHANNEL_TASKBAR_ALIGNMENT)
.getValue();
if (hotseatIconsAlpha > 0) {
updateIconAlphaForHome(hotseatIconsAlpha, ALPHA_CHANNEL_TASKBAR_ALIGNMENT);
}
}
});
@@ -737,6 +744,25 @@ public class TaskbarLauncherStateController {
}
}
protected void stashHotseat(boolean stash) {
TaskbarStashController stashController = mControllers.taskbarStashController;
stashController.updateStateForFlag(FLAG_STASHED_FOR_BUBBLES, stash);
Runnable swapHotseatWithTaskbar = new Runnable() {
@Override
public void run() {
updateIconAlphaForHome(stash ? 1 : 0, ALPHA_CHANNEL_TASKBAR_STASH);
}
};
if (stash) {
stashController.applyState();
// if we stashing the hotseat we need to immediately swap it with the animating taskbar
swapHotseatWithTaskbar.run();
} else {
// if we revert stashing make swap after taskbar animation is complete
stashController.applyState(/* postApplyAction = */ swapHotseatWithTaskbar);
}
}
/**
* Resets and updates the icon alignment.
*/
@@ -746,7 +772,7 @@ public class TaskbarLauncherStateController {
}
private void onIconAlignmentRatioChanged() {
float currentValue = mIconAlphaForHome.getValue();
float currentValue = mTaskbarAlphaForHome.getValue();
boolean taskbarWillBeVisible = mIconAlignment.value < 1;
boolean firstFrameVisChanged = (taskbarWillBeVisible && Float.compare(currentValue, 1) != 0)
|| (!taskbarWillBeVisible && Float.compare(currentValue, 0) != 0);
@@ -754,8 +780,10 @@ public class TaskbarLauncherStateController {
mControllers.taskbarViewController.setLauncherIconAlignment(
mIconAlignment.value, mLauncher.getDeviceProfile());
mControllers.navbarButtonsViewController.updateTaskbarAlignment(mIconAlignment.value);
// Switch taskbar and hotseat in last frame
updateIconAlphaForHome(taskbarWillBeVisible ? 1 : 0);
// Switch taskbar and hotseat in last frame and if taskbar is not hidden for bubbles
boolean isHiddenForBubbles = mControllers.taskbarStashController.isHiddenForBubbles();
updateIconAlphaForHome(taskbarWillBeVisible ? 1 : 0, ALPHA_CHANNEL_TASKBAR_ALIGNMENT,
/* updateTaskbarAlpha = */ !isHiddenForBubbles);
// Sync the first frame where we swap taskbar and hotseat.
if (firstFrameVisChanged && mCanSyncViews && !Utilities.isRunningInTestHarness()) {
@@ -765,12 +793,20 @@ public class TaskbarLauncherStateController {
}
}
private void updateIconAlphaForHome(float alpha) {
private void updateIconAlphaForHome(float taskbarAlpha, @HotseatQsbAlphaId int alphaChannel) {
updateIconAlphaForHome(taskbarAlpha, alphaChannel, /* updateTaskbarAlpha = */ true);
}
private void updateIconAlphaForHome(float taskbarAlpha,
@HotseatQsbAlphaId int alphaChannel,
boolean updateTaskbarAlpha) {
if (mIsDestroyed) {
return;
}
mIconAlphaForHome.setValue(alpha);
boolean hotseatVisible = alpha == 0
if (updateTaskbarAlpha) {
mTaskbarAlphaForHome.setValue(taskbarAlpha);
}
boolean hotseatVisible = taskbarAlpha == 0
|| mControllers.taskbarActivityContext.isPhoneMode()
|| (!mControllers.uiController.isHotseatIconOnTopWhenAligned()
&& mIconAlignment.value > 0);
@@ -778,9 +814,10 @@ public class TaskbarLauncherStateController {
* Hide Launcher Hotseat icons when Taskbar icons have opacity. Both icon sets
* should not be visible at the same time.
*/
mLauncher.getHotseat().setIconsAlpha(hotseatVisible ? 1 : 0);
float targetAlpha = hotseatVisible ? 1 : 0;
mLauncher.getHotseat().setIconsAlpha(targetAlpha, alphaChannel);
if (mIsQsbInline) {
mLauncher.getHotseat().setQsbAlpha(hotseatVisible ? 1 : 0);
mLauncher.getHotseat().setQsbAlpha(targetAlpha, alphaChannel);
}
}
@@ -868,7 +905,7 @@ public class TaskbarLauncherStateController {
pw.println(String.format(
"%s\tmTaskbarBackgroundAlpha=%.2f", prefix, mTaskbarBackgroundAlpha.value));
pw.println(String.format(
"%s\tmIconAlphaForHome=%.2f", prefix, mIconAlphaForHome.getValue()));
"%s\tmTaskbarAlphaForHome=%.2f", prefix, mTaskbarAlphaForHome.getValue()));
pw.println(String.format("%s\tmPrevState=%s", prefix,
mPrevState == null ? null : getStateString(mPrevState)));
pw.println(String.format("%s\tmState=%s", prefix, getStateString(mState)));