Update placement of the nav bar in persistent taskbar for 3 button nav

Implemented nav bar placement update to be located opposite to the
bubble bar.
When bubble bar is moved to the other side of the bar, 3 button nav will
swap sides (without animation).
If taskbar has to be repositioned it does that with the animation.

Test: TaskbarViewControllerTest
Bug: 346381754
Flag: com.android.wm.shell.enable_bubble_bar
Change-Id: Id031706183c60cbd9c67537b01530acb43bae614
This commit is contained in:
mpodolian
2024-08-30 17:34:23 -07:00
parent 9074e19dad
commit 04088ebef7
11 changed files with 288 additions and 34 deletions
@@ -91,6 +91,7 @@ import com.android.launcher3.Utilities;
import com.android.launcher3.anim.AlphaUpdateListener;
import com.android.launcher3.anim.AnimatedFloat;
import com.android.launcher3.taskbar.TaskbarNavButtonController.TaskbarButton;
import com.android.launcher3.taskbar.bubbles.BubbleBarController;
import com.android.launcher3.taskbar.navbutton.NavButtonLayoutFactory;
import com.android.launcher3.taskbar.navbutton.NavButtonLayoutFactory.NavButtonLayoutter;
import com.android.launcher3.taskbar.navbutton.NearestTouchFrame;
@@ -106,6 +107,7 @@ import com.android.systemui.shared.rotation.RotationButton;
import com.android.systemui.shared.statusbar.phone.BarTransitions;
import com.android.systemui.shared.system.QuickStepContract;
import com.android.systemui.shared.system.QuickStepContract.SystemUiStateFlags;
import com.android.wm.shell.shared.bubbles.BubbleBarLocation;
import java.io.PrintWriter;
import java.util.ArrayList;
@@ -115,7 +117,8 @@ import java.util.function.IntPredicate;
/**
* Controller for managing nav bar buttons in taskbar
*/
public class NavbarButtonsViewController implements TaskbarControllers.LoggableTaskbarController {
public class NavbarButtonsViewController implements TaskbarControllers.LoggableTaskbarController,
BubbleBarController.BubbleBarLocationListener {
private final Rect mTempRect = new Rect();
@@ -397,6 +400,12 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
}
};
mSeparateWindowParent.recreateControllers();
if (com.android.wm.shell.Flags.enableBubbleBarInPersistentTaskBar()
&& mControllers.bubbleControllers.isPresent()) {
BubbleBarLocation bubblesLocation = mControllers.bubbleControllers.get()
.bubbleBarViewController.getBubbleBarLocation();
onBubbleBarLocationUpdated(bubblesLocation);
}
}
private void initButtons(ViewGroup navContainer, ViewGroup endContainer,
@@ -1168,6 +1177,52 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
mHitboxExtender.onAnimationProgressToOverview(alignment);
}
/** Adjusts navigation buttons layout accordingly to the bubble bar position. */
@Override
public void onBubbleBarLocationUpdated(BubbleBarLocation location) {
mNavButtonContainer.setTranslationX(getNavBarTranslationX(location));
}
/** Animates navigation buttons accordingly to the bubble bar position. */
@Override
public void onBubbleBarLocationAnimated(BubbleBarLocation location) {
// TODO(b/346381754) add the teleport animation similarly to the bubble bar
mNavButtonContainer.setTranslationX(getNavBarTranslationX(location));
}
private int getNavBarTranslationX(BubbleBarLocation location) {
boolean isNavbarOnRight = location.isOnLeft(mNavButtonsView.isLayoutRtl());
DeviceProfile dp = mContext.getDeviceProfile();
float navBarTargetStartX;
if (mContext.shouldStartAlignTaskbar()) {
int navBarSpacing = dp.inlineNavButtonsEndSpacingPx;
// If the taskbar is start aligned the navigation bar is aligned to the start or end of
// the container, depending on the bubble bar location
if (isNavbarOnRight) {
navBarTargetStartX = dp.widthPx - navBarSpacing - mNavButtonContainer.getWidth();
} else {
navBarTargetStartX = navBarSpacing;
}
} else {
// If the task bar is not start aligned, the navigation bar is located in the center
// between the taskbar and screen edges, depending on the bubble bar location.
float navbarWidth = mNavButtonContainer.getWidth();
Rect taskbarBounds = mControllers.taskbarViewController.getIconLayoutBounds();
if (isNavbarOnRight) {
if (mNavButtonsView.isLayoutRtl()) {
float taskBarEnd = taskbarBounds.right;
navBarTargetStartX = (dp.widthPx + taskBarEnd - navbarWidth) / 2;
} else {
navBarTargetStartX = mNavButtonContainer.getLeft();
}
} else {
float taskBarStart = taskbarBounds.left;
navBarTargetStartX = (taskBarStart - navbarWidth) / 2;
}
}
return (int) navBarTargetStartX - mNavButtonContainer.getLeft();
}
private class RotationButtonListener implements RotationButton.RotationButtonUpdatesCallback {
@Override
public void onVisibilityChanged(boolean isVisible) {