Set bubble bar aligned to QSB
Change logic to updated bubble bar alignment with the QSB vertical
center for 3 buttons navigation mode.
Fixes: 378400160
Flag: com.android.wm.shell.enable_bubble_bar
Test: PersistentBubbleStashControllerTest
Test: TransientBubbleStashControllerTest
Test: Manual. Set the buttons navigation mode and observe that the
bubble bar is centered with the QSB when the QSB is not aligned with the
hotseat. Then, switch to gestures navigation mode and observe that the
bubble bar is centered with the hotseat when the QSB is not aligned with
the hotseat.
Change-Id: I57a32ac5bde7a7055b54a89727429424e5c0ca4f
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
index 8149f81..2df520a 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
@@ -301,7 +301,8 @@
BubbleStashController bubbleStashController = isTransientTaskbar
? new TransientBubbleStashController(dimensionsProvider, this)
: new PersistentBubbleStashController(dimensionsProvider);
- bubbleStashController.setHotseatVerticalCenter(launcherDp.getHotseatVerticalCenter());
+ bubbleStashController.setBubbleBarVerticalCenterForHome(
+ launcherDp.getBubbleBarVerticalCenterForHome());
bubbleControllersOptional = Optional.of(new BubbleControllers(
new BubbleBarController(this, bubbleBarView),
new BubbleBarViewController(this, bubbleBarView, bubbleBarContainer),
@@ -369,8 +370,9 @@
applyDeviceProfile(launcherDp);
mControllers.taskbarOverlayController.updateLauncherDeviceProfile(launcherDp);
mControllers.bubbleControllers.ifPresent(bubbleControllers -> {
- int hotseatVertCenter = launcherDp.getHotseatVerticalCenter();
- bubbleControllers.bubbleStashController.setHotseatVerticalCenter(hotseatVertCenter);
+ int bubbleBarVerticalCenter = launcherDp.getBubbleBarVerticalCenterForHome();
+ bubbleControllers.bubbleStashController
+ .setBubbleBarVerticalCenterForHome(bubbleBarVerticalCenter);
});
AbstractFloatingView.closeAllOpenViewsExcept(this, false, TYPE_REBIND_SAFE);
// Reapply fullscreen to take potential new screen size into account.
diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java
index 833be61..aab0c44 100644
--- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java
+++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java
@@ -1307,6 +1307,10 @@
return getBubbleBarCollapsedHeight() + mPointerSize;
}
+ float getArrowHeight() {
+ return mPointerSize;
+ }
+
float getBubbleBarCollapsedHeight() {
// the pointer is invisible when collapsed
return getScaledIconSize() + mBubbleBarPadding * 2;
diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java
index fd08078..3c146b7 100644
--- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java
@@ -447,6 +447,11 @@
return mBarView.getBubbleBarCollapsedHeight();
}
+ /** Returns the bubble bar arrow height.*/
+ public float getBubbleBarArrowHeight() {
+ return mBarView.getArrowHeight();
+ }
+
/**
* @see BubbleBarView#getRelativePivotX()
*/
diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/stashing/BubbleStashController.kt b/quickstep/src/com/android/launcher3/taskbar/bubbles/stashing/BubbleStashController.kt
index d9589bb..b91718e 100644
--- a/quickstep/src/com/android/launcher3/taskbar/bubbles/stashing/BubbleStashController.kt
+++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/stashing/BubbleStashController.kt
@@ -121,8 +121,8 @@
/** Set a bubble bar location */
fun setBubbleBarLocation(bubbleBarLocation: BubbleBarLocation)
- /** Set the hotseat vertical center that bubble bar will align with. */
- fun setHotseatVerticalCenter(hotseatVerticalCenter: Int)
+ /** Set the bubble bar vertical center for launcher home. */
+ fun setBubbleBarVerticalCenterForHome(verticalCenter: Int)
/**
* Stashes the bubble bar (transform to the handle view), or just shrink width of the expanded
diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/stashing/PersistentBubbleStashController.kt b/quickstep/src/com/android/launcher3/taskbar/bubbles/stashing/PersistentBubbleStashController.kt
index 45f5568..31f17c4 100644
--- a/quickstep/src/com/android/launcher3/taskbar/bubbles/stashing/PersistentBubbleStashController.kt
+++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/stashing/PersistentBubbleStashController.kt
@@ -47,7 +47,7 @@
private lateinit var bubbleBarAlphaAnimator: MultiPropertyFactory<View>.MultiProperty
private lateinit var bubbleBarScaleAnimator: AnimatedFloat
private lateinit var controllersAfterInitAction: ControllersAfterInitAction
- private var hotseatVerticalCenter: Int = 0
+ private var verticalCenterForHome: Int = 0
override var launcherState: BubbleLauncherState = BubbleLauncherState.IN_APP
set(state) {
@@ -97,7 +97,7 @@
override val bubbleBarTranslationYForHotseat: Float
get() {
val bubbleBarHeight = bubbleBarViewController.bubbleBarCollapsedHeight
- return -hotseatVerticalCenter + bubbleBarHeight / 2
+ return -verticalCenterForHome + bubbleBarHeight / 2
}
override val bubbleBarTranslationY: Float
@@ -159,8 +159,8 @@
animatorSet.setDuration(BAR_STASH_DURATION).start()
}
- override fun setHotseatVerticalCenter(hotseatVerticalCenter: Int) {
- this.hotseatVerticalCenter = hotseatVerticalCenter
+ override fun setBubbleBarVerticalCenterForHome(verticalCenter: Int) {
+ verticalCenterForHome = verticalCenter
}
override fun showBubbleBarImmediate() = showBubbleBarImmediate(bubbleBarTranslationY)
diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/stashing/TransientBubbleStashController.kt b/quickstep/src/com/android/launcher3/taskbar/bubbles/stashing/TransientBubbleStashController.kt
index 22d504f..cb7fefc 100644
--- a/quickstep/src/com/android/launcher3/taskbar/bubbles/stashing/TransientBubbleStashController.kt
+++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/stashing/TransientBubbleStashController.kt
@@ -78,7 +78,7 @@
context.resources.getDimensionPixelSize(R.dimen.bubblebar_stashed_size) / 2f
private var animator: AnimatorSet? = null
- private var hotseatVerticalCenter: Int = 0
+ private var verticalCenterForHome: Int = 0
override var isStashed: Boolean = false
@VisibleForTesting set
@@ -124,7 +124,7 @@
override val bubbleBarTranslationYForHotseat: Float
get() {
val bubbleBarHeight = bubbleBarViewController.bubbleBarCollapsedHeight
- return -hotseatVerticalCenter + bubbleBarHeight / 2
+ return -verticalCenterForHome + bubbleBarHeight / 2
}
override val bubbleBarTranslationYForTaskbar: Float =
@@ -182,8 +182,8 @@
.start()
}
- override fun setHotseatVerticalCenter(hotseatVerticalCenter: Int) {
- this.hotseatVerticalCenter = hotseatVerticalCenter
+ override fun setBubbleBarVerticalCenterForHome(verticalCenter: Int) {
+ verticalCenterForHome = verticalCenter
}
override fun showBubbleBarImmediate() {
diff --git a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/stashing/PersistentBubbleStashControllerTest.kt b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/stashing/PersistentBubbleStashControllerTest.kt
index f795ab1..4b9c721 100644
--- a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/stashing/PersistentBubbleStashControllerTest.kt
+++ b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/stashing/PersistentBubbleStashControllerTest.kt
@@ -76,7 +76,7 @@
PersistentBubbleStashController(DefaultDimensionsProvider())
setUpBubbleBarView()
setUpBubbleBarController()
- persistentTaskBarStashController.setHotseatVerticalCenter(HOTSEAT_VERTICAL_CENTER)
+ persistentTaskBarStashController.setBubbleBarVerticalCenterForHome(HOTSEAT_VERTICAL_CENTER)
persistentTaskBarStashController.init(
taskbarInsetsController,
bubbleBarViewController,
diff --git a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/stashing/TransientBubbleStashControllerTest.kt b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/stashing/TransientBubbleStashControllerTest.kt
index 1bbd12a..5a64b68 100644
--- a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/stashing/TransientBubbleStashControllerTest.kt
+++ b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/stashing/TransientBubbleStashControllerTest.kt
@@ -109,7 +109,7 @@
setUpStashedHandleView()
setUpBubbleStashedHandleViewController()
PhysicsAnimatorTestUtils.prepareForTest()
- mTransientBubbleStashController.setHotseatVerticalCenter(HOTSEAT_VERTICAL_CENTER)
+ mTransientBubbleStashController.setBubbleBarVerticalCenterForHome(HOTSEAT_VERTICAL_CENTER)
mTransientBubbleStashController.init(
taskbarInsetsController,
bubbleBarViewController,
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index 09225e7..9b6fe4e 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -1861,13 +1861,15 @@
* the bubble bar.
*
* <p>Does not check for visible bubbles persistence, so caller should call
- * {@link #shouldAdjustHotseatForBubbleBar} first.
+ * {@link #shouldAdjustHotseatOrQsbForBubbleBar} first.
*
* <p>If there's no adjustment needed, this method returns {@code 0}.
- * @see #shouldAdjustHotseatForBubbleBar(Context, boolean)
+ * @see #shouldAdjustHotseatOrQsbForBubbleBar(Context, boolean)
*/
public float getHotseatAdjustedBorderSpaceForBubbleBar(Context context) {
- if (!shouldAdjustHotseatForBubbleBar(context)) return 0;
+ if (shouldAlignBubbleBarWithQSB() || !shouldAdjustHotseatOrQsbForBubbleBar(context)) {
+ return 0;
+ }
// The adjustment is shrinking the hotseat's width by 1 icon on either side.
int iconsWidth =
iconSizePx * numShownHotseatIcons + hotseatBorderSpace * (numShownHotseatIcons - 1);
@@ -1880,27 +1882,37 @@
* Returns the hotseat icon translation X for the cellX index.
*
* <p>Does not check for visible bubbles persistence, so caller should call
- * {@link #shouldAdjustHotseatForBubbleBar} first.
+ * {@link #shouldAdjustHotseatOrQsbForBubbleBar} first.
*
* <p>If there's no adjustment needed, this method returns {@code 0}.
- * @see #shouldAdjustHotseatForBubbleBar(Context, boolean)
+ * @see #shouldAdjustHotseatOrQsbForBubbleBar(Context, boolean)
*/
public float getHotseatAdjustedTranslation(Context context, int cellX) {
- if (!shouldAdjustHotseatForBubbleBar(context)) return 0;
float borderSpace = getHotseatAdjustedBorderSpaceForBubbleBar(context);
+ if (borderSpace == 0) return borderSpace;
float borderSpaceDelta = borderSpace - hotseatBorderSpace;
return iconSizePx + cellX * borderSpaceDelta;
}
- /** Returns whether hotseat should be adjusted for the bubble bar. */
- public boolean shouldAdjustHotseatForBubbleBar(Context context, boolean hasBubbles) {
- return hasBubbles && shouldAdjustHotseatForBubbleBar(context);
+ /** Returns whether hotseat or QSB should be adjusted for the bubble bar. */
+ public boolean shouldAdjustHotseatOrQsbForBubbleBar(Context context, boolean hasBubbles) {
+ return hasBubbles && shouldAdjustHotseatOrQsbForBubbleBar(context);
}
- private boolean shouldAdjustHotseatForBubbleBar(Context context) {
- // only need to adjust if bubble bar is enabled, when QSB is on top of the hotseat and
- // there's not enough space for the bubble bar to the right of the hotseat.
- return !isQsbInline && getHotseatLayoutPadding(context).right <= mBubbleBarSpaceThresholdPx;
+ /** Returns whether hotseat should be adjusted for the bubble bar. */
+ public boolean shouldAdjustHotseatForBubbleBar(Context context, boolean hasBubbles) {
+ return shouldAlignBubbleBarWithHotseat()
+ && shouldAdjustHotseatOrQsbForBubbleBar(context, hasBubbles);
+ }
+
+ /** Returns whether hotseat or QSB should be adjusted for the bubble bar. */
+ public boolean shouldAdjustHotseatOrQsbForBubbleBar(Context context) {
+ // only need to adjust if QSB is on top of the hotseat and there's not enough space for the
+ // bubble bar to either side of the hotseat.
+ if (isQsbInline) return false;
+ Rect hotseatPadding = getHotseatLayoutPadding(context);
+ int hotseatMinHorizontalPadding = Math.min(hotseatPadding.left, hotseatPadding.right);
+ return hotseatMinHorizontalPadding <= mBubbleBarSpaceThresholdPx;
}
/**
@@ -2055,15 +2067,29 @@
}
/**
- * Returns the number of pixels the hotseat icons vertical center is translated from the bottom
- * of the screen.
+ * Returns the number of pixels the hotseat icons or QSB vertical center is translated from the
+ * bottom of the screen.
*/
- public int getHotseatVerticalCenter() {
- return hotseatBarSizePx
- - (isQsbInline ? 0 : hotseatQsbVisualHeight)
- - hotseatQsbSpace
- - (hotseatCellHeightPx / 2)
- + ((hotseatCellHeightPx - iconSizePx) / 2);
+ public int getBubbleBarVerticalCenterForHome() {
+ if (shouldAlignBubbleBarWithHotseat()) {
+ return hotseatBarSizePx
+ - (isQsbInline ? 0 : hotseatQsbVisualHeight)
+ - hotseatQsbSpace
+ - (hotseatCellHeightPx / 2)
+ + ((hotseatCellHeightPx - iconSizePx) / 2);
+ } else {
+ return hotseatBarSizePx - (hotseatQsbVisualHeight / 2);
+ }
+ }
+
+ /** Returns whether bubble bar should be aligned with the hotseat. */
+ public boolean shouldAlignBubbleBarWithQSB() {
+ return !shouldAlignBubbleBarWithHotseat();
+ }
+
+ /** Returns whether bubble bar should be aligned with the hotseat. */
+ public boolean shouldAlignBubbleBarWithHotseat() {
+ return isQsbInline || isGestureMode;
}
/**
diff --git a/src/com/android/launcher3/Hotseat.java b/src/com/android/launcher3/Hotseat.java
index b2ccba4..6be8098 100644
--- a/src/com/android/launcher3/Hotseat.java
+++ b/src/com/android/launcher3/Hotseat.java
@@ -186,9 +186,10 @@
*/
public void adjustForBubbleBar(boolean isBubbleBarVisible) {
DeviceProfile dp = mActivity.getDeviceProfile();
- float adjustedBorderSpace = dp.getHotseatAdjustedBorderSpaceForBubbleBar(getContext());
- boolean shouldAdjustHotseat = isBubbleBarVisible
- && Float.compare(adjustedBorderSpace, 0f) != 0;
+ boolean shouldAdjust = isBubbleBarVisible
+ && dp.shouldAdjustHotseatOrQsbForBubbleBar(getContext());
+ boolean shouldAdjustHotseat = shouldAdjust
+ && dp.shouldAlignBubbleBarWithHotseat();
ShortcutAndWidgetContainer icons = getShortcutsAndWidgets();
// update the translation provider for future layout passes of hotseat icons.
if (shouldAdjustHotseat) {
@@ -209,9 +210,12 @@
animatorSet.play(ObjectAnimator.ofFloat(child, VIEW_TRANSLATE_X, tx));
}
}
+ //TODO(b/381109832) refactor & simplify adjustment logic
+ boolean shouldAdjustQsb =
+ shouldAdjustHotseat || (shouldAdjust && dp.shouldAlignBubbleBarWithQSB());
if (mQsb instanceof HorizontalInsettableView horizontalInsettableQsb) {
final float currentInsetFraction = horizontalInsettableQsb.getHorizontalInsets();
- final float targetInsetFraction = shouldAdjustHotseat
+ final float targetInsetFraction = shouldAdjustQsb
? (float) dp.iconSizePx / dp.hotseatQsbWidth : 0;
ValueAnimator qsbAnimator =
ValueAnimator.ofFloat(currentInsetFraction, targetInsetFraction);