Adjust the hotseat when the bubble bar becomes visible
When the bubble bar becomes visible the space between icons in the
hotseat is now adjusted. This change only does it when the QSB is
above the icons, but this will be changed in the future to be based
on the amount of space between the hotseat and the edge of the screen.
When the hotseat is adjusted, the new width is smaller by the size of
2 icons. The icons are then translated to be evenly spaced within the
boundaries of the new width.
Since the adjustment is only applied when the QSB is above the icons,
it is resized accordingly to the new width.
All visual updates currently snap to the new position, but will be animated
in a follow up.
Demo: https://recall.googleplex.com/projects/3391fc5c-599d-4827-b6f8-d2deb160aa99/sessions/fad1a5c5-e9cf-4586-92e4-1e92df3b002e
Bug: 280494203
Test: Manual (on tangor)
- Set device to landscape
- Make the bubble bar visible by adding a bubble
- Rotate to portrait mode
- Observe that the hotseat is adjusted
- Rotate to landscape
- Observe that the hotseat adjustment is removed
- Rotate back to portrait
- Observe that the hotseat is adjusted again
- Dismiss the bubble to hide he bubble bar
- Observe the hotseat adjustment is removed
Change-Id: I5b02a60b6cb301ffa2507a6d825c748a782cca18
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index baa170b..9124317 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -220,6 +220,9 @@
private final int mMinHotseatQsbWidthPx;
private final int mMaxHotseatIconSpacePx;
public final int inlineNavButtonsEndSpacingPx;
+ // Space required for the bubble bar between the hotseat and the edge of the screen. If there's
+ // not enough space, the hotseat will adjust itself for the bubble bar.
+ private final int mBubbleBarSpaceThresholdPx;
// Bottom sheets
public int bottomSheetTopPadding;
@@ -574,6 +577,9 @@
hotseatBarEndOffset = 0;
}
+ mBubbleBarSpaceThresholdPx =
+ res.getDimensionPixelSize(R.dimen.bubblebar_hotseat_adjustment_threshold);
+
// Needs to be calculated after hotseatBarSizePx is correct,
// for the available height to be correct
if (mIsResponsiveGrid) {
@@ -1562,6 +1568,32 @@
paddings.bottom -= insets.bottom;
}
+
+ /**
+ * Returns the new border space that should be used between hotseat icons after adjusting it to
+ * the bubble bar.
+ *
+ * <p>If there's no adjustment needed, this method returns {@code 0}.
+ */
+ public float getHotseatAdjustedBorderSpaceForBubbleBar(Context context) {
+ // only need to adjust when QSB is on top of the hotseat.
+ if (isQsbInline) {
+ return 0;
+ }
+
+ // no need to adjust if there's enough space for the bubble bar to the right of the hotseat.
+ if (getHotseatLayoutPadding(context).right > mBubbleBarSpaceThresholdPx) {
+ return 0;
+ }
+
+ // The adjustment is shrinking the hotseat's width by 1 icon on either side.
+ int iconsWidth =
+ iconSizePx * numShownHotseatIcons + hotseatBorderSpace * (numShownHotseatIcons - 1);
+ int newWidth = iconsWidth - 2 * iconSizePx;
+ // Evenly space the icons within the boundaries of the new width.
+ return (float) (newWidth - iconSizePx * numShownHotseatIcons) / (numShownHotseatIcons - 1);
+ }
+
/**
* Returns the padding for hotseat view
*/
@@ -2169,5 +2201,4 @@
mIsGestureMode, mViewScaleProvider, mOverrideProvider);
}
}
-
}