Updated bubble bar position to be center aligned with the hotseat

Added a method to the device profile to calculate the vertical center of
the hotseat icons. Simplified the logic for positioning the bubble bar.

Test: TransientBubbleStashControllerTest
Test: PersistentBubbleStashControllerTest
Test: Visual. Go to home page, check that bubble bar is vertically
center aligned with the hotseat
Bug: 345491493
Flag: com.android.wm.shell.enable_bubble_bar

Change-Id: I52f1b94de79f6c912f43a88fcc5c884e20e56310
This commit is contained in:
mpodolian
2024-10-15 17:14:06 -07:00
parent bea43b0c03
commit f230eee2ff
9 changed files with 46 additions and 35 deletions

View File

@@ -297,6 +297,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
BubbleStashController bubbleStashController = isTransientTaskbar
? new TransientBubbleStashController(dimensionsProvider, this)
: new PersistentBubbleStashController(dimensionsProvider);
bubbleStashController.setHotseatVerticalCenter(launcherDp.getHotseatVerticalCenter());
bubbleControllersOptional = Optional.of(new BubbleControllers(
new BubbleBarController(this, bubbleBarView),
new BubbleBarViewController(this, bubbleBarView, bubbleBarContainer),
@@ -362,8 +363,11 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
/** Updates {@link DeviceProfile} instances for any Taskbar windows. */
public void updateDeviceProfile(DeviceProfile launcherDp) {
applyDeviceProfile(launcherDp);
mControllers.taskbarOverlayController.updateLauncherDeviceProfile(launcherDp);
mControllers.bubbleControllers.ifPresent(bubbleControllers -> {
int hotseatVertCenter = launcherDp.getHotseatVerticalCenter();
bubbleControllers.bubbleStashController.setHotseatVerticalCenter(hotseatVertCenter);
});
AbstractFloatingView.closeAllOpenViewsExcept(this, false, TYPE_REBIND_SAFE);
// Reapply fullscreen to take potential new screen size into account.
setTaskbarWindowFullscreen(mIsFullscreen);

View File

@@ -42,12 +42,6 @@ interface BubbleStashController {
/** Provides taskbar height in pixels. */
fun getTaskbarHeight(): Int
/** Provides hotseat bottom space in pixels. */
fun getHotseatBottomSpace(): Int
/** Provides hotseat height in pixels. */
fun getHotseatHeight(): Int
}
/** Execute passed action only after controllers are initiated. */
@@ -94,7 +88,7 @@ interface BubbleStashController {
taskbarInsetsController: TaskbarInsetsController,
bubbleBarViewController: BubbleBarViewController,
bubbleStashedHandleViewController: BubbleStashedHandleViewController?,
controllersAfterInitAction: ControllersAfterInitAction
controllersAfterInitAction: ControllersAfterInitAction,
)
/** Shows the bubble bar at [bubbleBarTranslationY] position immediately without animation. */
@@ -127,6 +121,9 @@ interface BubbleStashController {
/** Set a bubble bar location */
fun setBubbleBarLocation(bubbleBarLocation: BubbleBarLocation)
/** Set the hotseat vertical center that bubble bar will align with. */
fun setHotseatVerticalCenter(hotseatVerticalCenter: Int)
/**
* Stashes the bubble bar (transform to the handle view), or just shrink width of the expanded
* bubble bar based on the controller implementation.

View File

@@ -27,13 +27,9 @@ import com.android.launcher3.taskbar.bubbles.stashing.BubbleStashController.Task
class DeviceProfileDimensionsProviderAdapter(
private val taskbarActivityContext: TaskbarActivityContext
) : TaskbarHotseatDimensionsProvider {
override fun getTaskbarBottomSpace(): Int = deviceProfile().taskbarBottomMargin
override fun getTaskbarBottomSpace(): Int = taskbarDp().taskbarBottomMargin
override fun getTaskbarHeight(): Int = deviceProfile().taskbarHeight
override fun getTaskbarHeight(): Int = taskbarDp().taskbarHeight
override fun getHotseatBottomSpace(): Int = deviceProfile().hotseatBarBottomSpacePx
override fun getHotseatHeight(): Int = deviceProfile().hotseatCellHeightPx
private fun deviceProfile(): DeviceProfile = taskbarActivityContext.deviceProfile
private fun taskbarDp(): DeviceProfile = taskbarActivityContext.deviceProfile
}

View File

@@ -36,7 +36,7 @@ import com.android.wm.shell.shared.animation.PhysicsAnimator
import com.android.wm.shell.shared.bubbles.BubbleBarLocation
class PersistentBubbleStashController(
private val taskbarHotseatDimensionsProvider: TaskbarHotseatDimensionsProvider,
private val taskbarHotseatDimensionsProvider: TaskbarHotseatDimensionsProvider
) : BubbleStashController {
private lateinit var taskbarInsetsController: TaskbarInsetsController
@@ -45,6 +45,7 @@ class PersistentBubbleStashController(
private lateinit var bubbleBarAlphaAnimator: MultiPropertyFactory<View>.MultiProperty
private lateinit var bubbleBarScaleAnimator: AnimatedFloat
private lateinit var controllersAfterInitAction: ControllersAfterInitAction
private var hotseatVerticalCenter: Int = 0
override var launcherState: BubbleLauncherState = BubbleLauncherState.IN_APP
set(state) {
@@ -92,17 +93,15 @@ class PersistentBubbleStashController(
override val bubbleBarTranslationYForHotseat: Float
get() {
val hotseatBottomSpace = taskbarHotseatDimensionsProvider.getHotseatBottomSpace()
val hotseatCellHeight = taskbarHotseatDimensionsProvider.getHotseatHeight()
val bubbleBarHeight: Float = bubbleBarViewController.bubbleBarCollapsedHeight
return -hotseatBottomSpace - (hotseatCellHeight - bubbleBarHeight) / 2
val bubbleBarHeight = bubbleBarViewController.bubbleBarCollapsedHeight
return -hotseatVerticalCenter + bubbleBarHeight / 2
}
override fun init(
taskbarInsetsController: TaskbarInsetsController,
bubbleBarViewController: BubbleBarViewController,
bubbleStashedHandleViewController: BubbleStashedHandleViewController?,
controllersAfterInitAction: ControllersAfterInitAction
controllersAfterInitAction: ControllersAfterInitAction,
) {
this.taskbarInsetsController = taskbarInsetsController
this.bubbleBarViewController = bubbleBarViewController
@@ -119,13 +118,17 @@ class PersistentBubbleStashController(
animatorSet.playTogether(
bubbleBarScaleAnimator.animateToValue(1f),
bubbleBarTranslationYAnimator.animateToValue(bubbleBarTranslationY),
bubbleBarAlphaAnimator.animateToValue(1f)
bubbleBarAlphaAnimator.animateToValue(1f),
)
}
updateTouchRegionOnAnimationEnd(animatorSet)
animatorSet.setDuration(BAR_STASH_DURATION).start()
}
override fun setHotseatVerticalCenter(hotseatVerticalCenter: Int) {
this.hotseatVerticalCenter = hotseatVerticalCenter
}
override fun showBubbleBarImmediate() = showBubbleBarImmediate(bubbleBarTranslationY)
override fun showBubbleBarImmediate(bubbleBarTranslationY: Float) {

View File

@@ -78,6 +78,7 @@ class TransientBubbleStashController(
context.resources.getDimensionPixelSize(R.dimen.bubblebar_stashed_size) / 2f
private var animator: AnimatorSet? = null
private var hotseatVerticalCenter: Int = 0
override var isStashed: Boolean = false
@VisibleForTesting set
@@ -118,10 +119,8 @@ class TransientBubbleStashController(
override val bubbleBarTranslationYForHotseat: Float
get() {
val hotseatBottomSpace = taskbarHotseatDimensionsProvider.getHotseatBottomSpace()
val hotseatCellHeight = taskbarHotseatDimensionsProvider.getHotseatHeight()
val bubbleBarHeight: Float = bubbleBarViewController.bubbleBarCollapsedHeight
return -hotseatBottomSpace - (hotseatCellHeight - bubbleBarHeight) / 2
val bubbleBarHeight = bubbleBarViewController.bubbleBarCollapsedHeight
return -hotseatVerticalCenter + bubbleBarHeight / 2
}
override val bubbleBarTranslationYForTaskbar: Float =
@@ -176,6 +175,10 @@ class TransientBubbleStashController(
.start()
}
override fun setHotseatVerticalCenter(hotseatVerticalCenter: Int) {
this.hotseatVerticalCenter = hotseatVerticalCenter
}
override fun showBubbleBarImmediate() {
showBubbleBarImmediate(bubbleBarTranslationY)
}

View File

@@ -48,6 +48,7 @@ class PersistentBubbleStashControllerTest {
companion object {
const val BUBBLE_BAR_HEIGHT = 100f
const val HOTSEAT_VERTICAL_CENTER = 95
const val HOTSEAT_TRANSLATION_Y = -45f
const val TASK_BAR_TRANSLATION_Y = -5f
}
@@ -74,11 +75,12 @@ class PersistentBubbleStashControllerTest {
PersistentBubbleStashController(DefaultDimensionsProvider())
setUpBubbleBarView()
setUpBubbleBarController()
persistentTaskBarStashController.setHotseatVerticalCenter(HOTSEAT_VERTICAL_CENTER)
persistentTaskBarStashController.init(
taskbarInsetsController,
bubbleBarViewController,
null,
ImmediateAction()
ImmediateAction(),
)
}

View File

@@ -23,21 +23,13 @@ class ImmediateAction : BubbleStashController.ControllersAfterInitAction {
class DefaultDimensionsProvider(
private val taskBarBottomSpace: Int = TASKBAR_BOTTOM_SPACE,
private val taskBarHeight: Int = TASKBAR_HEIGHT,
private val hotseatBottomSpace: Int = HOTSEAT_BOTTOM_SPACE,
private val hotseatHeight: Int = HOTSEAT_HEIGHT
) : BubbleStashController.TaskbarHotseatDimensionsProvider {
override fun getTaskbarBottomSpace(): Int = taskBarBottomSpace
override fun getTaskbarHeight(): Int = taskBarHeight
override fun getHotseatBottomSpace(): Int = hotseatBottomSpace
override fun getHotseatHeight(): Int = hotseatHeight
companion object {
const val TASKBAR_BOTTOM_SPACE = 0
const val TASKBAR_HEIGHT = 110
const val HOTSEAT_BOTTOM_SPACE = 20
const val HOTSEAT_HEIGHT = 150
}
}

View File

@@ -60,6 +60,7 @@ class TransientBubbleStashControllerTest {
companion object {
const val TASKBAR_BOTTOM_SPACE = 5
const val HOTSEAT_VERTICAL_CENTER = 95
const val BUBBLE_BAR_WIDTH = 200
const val BUBBLE_BAR_HEIGHT = 100
const val HOTSEAT_TRANSLATION_Y = -45f
@@ -108,6 +109,7 @@ class TransientBubbleStashControllerTest {
setUpStashedHandleView()
setUpBubbleStashedHandleViewController()
PhysicsAnimatorTestUtils.prepareForTest()
mTransientBubbleStashController.setHotseatVerticalCenter(HOTSEAT_VERTICAL_CENTER)
mTransientBubbleStashController.init(
taskbarInsetsController,
bubbleBarViewController,

View File

@@ -2018,6 +2018,18 @@ public class DeviceProfile {
}
}
/**
* Returns the number of pixels the hotseat icons vertical center is translated from the bottom
* of the screen.
*/
public int getHotseatVerticalCenter() {
return hotseatBarSizePx
- (isQsbInline ? 0 : hotseatQsbVisualHeight)
- hotseatQsbSpace
- (hotseatCellHeightPx / 2)
+ ((hotseatCellHeightPx - iconSizePx) / 2);
}
/**
* Returns the number of pixels the taskbar is translated from the bottom of the screen.
*/