Update setting taskbar window height
Updated the logic to set the taskbar window height to accommodate the bubble bar with its maximum flyout height before the bubble bar animation begins. The height is reverted to the default value once the animation is completed. Fixes: 378400160 Flag: com.android.wm.shell.enable_bubble_bar Test: Manual. Set 3-button navigation mode and have the QSB placed above the hotseat. Send a notification that will display a bubble, and observe the bubble bar animation and final placement aligned with the QSB. Next, set gesture navigation mode and repeat the flow above. Observe that the bubble bar is aligned with the hotseat icons. Felix video: http://recall/-/gx8ASgewUeUS3QYohfrd1J/gYMVt0sH4si0KOpaBxIPem Tangor video: http://recall/-/gx8ASgewUeUS3QYohfrd1J/fz95MbjcjW3awStnuOl8BJ Change-Id: I239f935743c3936fed44822c3c62652073ffefe2
This commit is contained in:
1 parent
28907bcbd6
commit
3111daf2f1
14 files changed
+173
-137
No files matched your search
@@ -1138,6 +1138,10 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
|
||||
return getSetupWindowSize();
|
||||
}
|
||||
|
||||
int bubbleBarTop = mControllers.bubbleControllers.map(bubbleControllers ->
|
||||
bubbleControllers.bubbleBarViewController.getBubbleBarWithFlyoutMaximumHeight()
|
||||
).orElse(0);
|
||||
int taskbarWindowSize;
|
||||
boolean shouldTreatAsTransient = DisplayController.isTransientTaskbar(this)
|
||||
|| (enableTaskbarPinning() && !isThreeButtonNav());
|
||||
|
||||
@@ -1154,16 +1158,18 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
|
||||
DeviceProfile transientTaskbarDp = mDeviceProfile.toBuilder(this)
|
||||
.setIsTransientTaskbar(true).build();
|
||||
|
||||
return transientTaskbarDp.taskbarHeight
|
||||
taskbarWindowSize = transientTaskbarDp.taskbarHeight
|
||||
+ (2 * transientTaskbarDp.taskbarBottomMargin)
|
||||
+ Math.max(extraHeightForTaskbarTooltips, resources.getDimensionPixelSize(
|
||||
R.dimen.transient_taskbar_shadow_blur));
|
||||
return Math.max(taskbarWindowSize, bubbleBarTop);
|
||||
}
|
||||
|
||||
|
||||
return mDeviceProfile.taskbarHeight
|
||||
taskbarWindowSize = mDeviceProfile.taskbarHeight
|
||||
+ getCornerRadius()
|
||||
+ extraHeightForTaskbarTooltips;
|
||||
return Math.max(taskbarWindowSize, bubbleBarTop);
|
||||
}
|
||||
|
||||
public int getSetupWindowSize() {
|
||||
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (C) 2024 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.launcher3.taskbar.bubbles
|
||||
|
||||
/** Controls the parent view height. */
|
||||
interface BubbleBarParentViewHeightUpdateNotifier {
|
||||
|
||||
/** Notify parent that top boundary should be updated. */
|
||||
fun updateTopBoundary()
|
||||
}
|
||||
@@ -171,7 +171,7 @@ public class BubbleBarViewController {
|
||||
mBubbleBarContainer, createFlyoutPositioner(), createFlyoutCallbacks());
|
||||
mBubbleBarViewAnimator = new BubbleBarViewAnimator(
|
||||
mBarView, mBubbleStashController, mBubbleBarFlyoutController,
|
||||
mBubbleBarController::showExpandedView);
|
||||
createBubbleBarParentViewController(), mBubbleBarController::showExpandedView);
|
||||
mTaskbarViewPropertiesProvider = taskbarViewPropertiesProvider;
|
||||
onBubbleBarConfigurationChanged(/* animate= */ false);
|
||||
mActivity.addOnDeviceProfileChangeListener(
|
||||
@@ -318,17 +318,6 @@ public class BubbleBarViewController {
|
||||
|
||||
private FlyoutCallbacks createFlyoutCallbacks() {
|
||||
return new FlyoutCallbacks() {
|
||||
@Override
|
||||
public void extendTopBoundary(int space) {
|
||||
int defaultSize = mActivity.getDefaultTaskbarWindowSize();
|
||||
mActivity.setTaskbarWindowSize(defaultSize + space);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetTopBoundary() {
|
||||
mActivity.setTaskbarWindowSize(mActivity.getDefaultTaskbarWindowSize());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flyoutClicked() {
|
||||
interruptAnimationForTouch();
|
||||
@@ -337,6 +326,15 @@ public class BubbleBarViewController {
|
||||
};
|
||||
}
|
||||
|
||||
private BubbleBarParentViewHeightUpdateNotifier createBubbleBarParentViewController() {
|
||||
return new BubbleBarParentViewHeightUpdateNotifier() {
|
||||
@Override
|
||||
public void updateTopBoundary() {
|
||||
mActivity.setTaskbarWindowSize(mActivity.getDefaultTaskbarWindowSize());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void onBubbleClicked(BubbleView bubbleView) {
|
||||
if (mBubbleBarPinning.isAnimating()) return;
|
||||
bubbleView.markSeen();
|
||||
@@ -585,6 +583,19 @@ public class BubbleBarViewController {
|
||||
return mHiddenForNoBubbles;
|
||||
}
|
||||
|
||||
/** Returns maximum height of the bubble bar with the flyout view. */
|
||||
public int getBubbleBarWithFlyoutMaximumHeight() {
|
||||
if (!isBubbleBarVisible()) return 0;
|
||||
int bubbleBarTopOnHome = (int) (mBubbleStashController.getBubbleBarVerticalCenterForHome()
|
||||
+ mBarView.getBubbleBarCollapsedHeight() / 2);
|
||||
int result = (int) (bubbleBarTopOnHome + mBarView.getArrowHeight());
|
||||
if (isAnimatingNewBubble()) {
|
||||
// when animating new bubble add the maximum height of the flyout view
|
||||
result += mBubbleBarFlyoutController.getMaximumFlyoutHeight();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the bubble bar should be hidden because there are no bubbles.
|
||||
*/
|
||||
|
||||
+16
-6
@@ -25,6 +25,7 @@ import androidx.dynamicanimation.animation.DynamicAnimation
|
||||
import androidx.dynamicanimation.animation.SpringForce
|
||||
import com.android.launcher3.R
|
||||
import com.android.launcher3.taskbar.bubbles.BubbleBarBubble
|
||||
import com.android.launcher3.taskbar.bubbles.BubbleBarParentViewHeightUpdateNotifier
|
||||
import com.android.launcher3.taskbar.bubbles.BubbleBarView
|
||||
import com.android.launcher3.taskbar.bubbles.BubbleView
|
||||
import com.android.launcher3.taskbar.bubbles.flyout.BubbleBarFlyoutController
|
||||
@@ -39,6 +40,7 @@ constructor(
|
||||
private val bubbleBarView: BubbleBarView,
|
||||
private val bubbleStashController: BubbleStashController,
|
||||
private val bubbleBarFlyoutController: BubbleBarFlyoutController,
|
||||
private val bubbleBarParentViewHeightUpdateNotifier: BubbleBarParentViewHeightUpdateNotifier,
|
||||
private val onExpanded: Runnable,
|
||||
private val scheduler: Scheduler = HandlerScheduler(bubbleBarView),
|
||||
) {
|
||||
@@ -342,7 +344,7 @@ constructor(
|
||||
scheduler.post(buildHandleToBubbleBarAnimation(initialVelocity = finalVelocity))
|
||||
return@addEndListener
|
||||
}
|
||||
animatingBubble = null
|
||||
clearAnimatingBubble()
|
||||
if (!canceled) bubbleStashController.stashBubbleBarImmediate()
|
||||
bubbleBarView.relativePivotY = 1f
|
||||
bubbleBarView.scaleY = 1f
|
||||
@@ -378,7 +380,7 @@ constructor(
|
||||
moveToState(AnimatingBubble.State.ANIMATING_OUT)
|
||||
bubbleBarFlyoutController.collapseFlyout {
|
||||
onFlyoutRemoved()
|
||||
animatingBubble = null
|
||||
clearAnimatingBubble()
|
||||
}
|
||||
bubbleStashController.showBubbleBarImmediate()
|
||||
bubbleStashController.updateTaskbarTouchRegion()
|
||||
@@ -437,7 +439,7 @@ constructor(
|
||||
moveToState(AnimatingBubble.State.ANIMATING_OUT)
|
||||
bubbleBarFlyoutController.collapseFlyout {
|
||||
onFlyoutRemoved()
|
||||
animatingBubble = null
|
||||
clearAnimatingBubble()
|
||||
}
|
||||
bubbleStashController.showBubbleBarImmediate()
|
||||
bubbleStashController.updateTaskbarTouchRegion()
|
||||
@@ -515,7 +517,7 @@ constructor(
|
||||
val hideAnimation = animatingBubble?.hideAnimation ?: return
|
||||
scheduler.cancel(hideAnimation)
|
||||
bubbleBarView.relativePivotY = 1f
|
||||
animatingBubble = null
|
||||
clearAnimatingBubble()
|
||||
}
|
||||
|
||||
/** Notifies the animator that the taskbar area was touched during an animation. */
|
||||
@@ -523,7 +525,7 @@ constructor(
|
||||
cancelFlyout()
|
||||
val hideAnimation = animatingBubble?.hideAnimation ?: return
|
||||
scheduler.cancel(hideAnimation)
|
||||
animatingBubble = null
|
||||
clearAnimatingBubble()
|
||||
bubbleStashController.getStashedHandlePhysicsAnimator().cancelIfRunning()
|
||||
bubbleBarView.relativePivotY = 1f
|
||||
bubbleStashController.onNewBubbleAnimationInterrupted(
|
||||
@@ -672,7 +674,7 @@ constructor(
|
||||
private fun cancelHideAnimation() {
|
||||
val hideAnimation = animatingBubble?.hideAnimation ?: return
|
||||
scheduler.cancel(hideAnimation)
|
||||
animatingBubble = null
|
||||
clearAnimatingBubble()
|
||||
bubbleBarView.relativePivotY = 1f
|
||||
bubbleStashController.showBubbleBarImmediate()
|
||||
}
|
||||
@@ -700,6 +702,14 @@ constructor(
|
||||
private fun moveToState(state: AnimatingBubble.State) {
|
||||
val animatingBubble = this.animatingBubble ?: return
|
||||
this.animatingBubble = animatingBubble.copy(state = state)
|
||||
if (state == AnimatingBubble.State.ANIMATING_IN) {
|
||||
bubbleBarParentViewHeightUpdateNotifier.updateTopBoundary()
|
||||
}
|
||||
}
|
||||
|
||||
private fun clearAnimatingBubble() {
|
||||
animatingBubble = null
|
||||
bubbleBarParentViewHeightUpdateNotifier.updateTopBoundary()
|
||||
}
|
||||
|
||||
private fun expandBubbleBar() {
|
||||
|
||||
+6
-13
@@ -35,6 +35,8 @@ constructor(
|
||||
private val flyoutScheduler: FlyoutScheduler = HandlerScheduler(container),
|
||||
) {
|
||||
|
||||
val maximumFlyoutHeight: Int = BubbleBarFlyoutView.getMaximumViewHeight(container.context)
|
||||
|
||||
private companion object {
|
||||
const val EXPAND_ANIMATION_DURATION_MS = 400L
|
||||
const val COLLAPSE_ANIMATION_DURATION_MS = 350L
|
||||
@@ -61,6 +63,8 @@ constructor(
|
||||
return rect
|
||||
}
|
||||
|
||||
fun getFlyoutMaxHeight(): Int = BubbleBarFlyoutView.getMaximumViewHeight(container.context)
|
||||
|
||||
fun setUpAndShowFlyout(message: BubbleBarFlyoutMessage, onInit: () -> Unit, onEnd: () -> Unit) {
|
||||
flyout?.let(container::removeView)
|
||||
val flyout = BubbleBarFlyoutView(container.context, positioner, flyoutScheduler)
|
||||
@@ -102,11 +106,10 @@ constructor(
|
||||
}
|
||||
}
|
||||
animator.addListener(
|
||||
onStart = { extendTopBoundary() },
|
||||
onEnd = {
|
||||
endAction()
|
||||
flyout.setOnClickListener { callbacks.flyoutClicked() }
|
||||
},
|
||||
}
|
||||
)
|
||||
animator.start()
|
||||
}
|
||||
@@ -114,14 +117,13 @@ constructor(
|
||||
fun updateFlyoutFullyExpanded(message: BubbleBarFlyoutMessage, onEnd: () -> Unit) {
|
||||
val flyout = flyout ?: return
|
||||
hideFlyout(AnimationType.FADE) {
|
||||
callbacks.resetTopBoundary()
|
||||
flyout.updateData(message) { showFlyout(AnimationType.FADE, onEnd) }
|
||||
}
|
||||
}
|
||||
|
||||
fun updateFlyoutWhileExpanding(message: BubbleBarFlyoutMessage) {
|
||||
val flyout = flyout ?: return
|
||||
flyout.updateData(message) { extendTopBoundary() }
|
||||
flyout.updateData(message) {}
|
||||
}
|
||||
|
||||
fun updateFlyoutWhileCollapsing(message: BubbleBarFlyoutMessage, onEnd: () -> Unit) {
|
||||
@@ -131,14 +133,6 @@ constructor(
|
||||
flyout.updateData(message) { showFlyout(AnimationType.MORPH, onEnd) }
|
||||
}
|
||||
|
||||
private fun extendTopBoundary() {
|
||||
val flyout = flyout ?: return
|
||||
val flyoutTop = flyout.top + flyout.translationY
|
||||
// If the top position of the flyout is negative, then it's bleeding over the
|
||||
// top boundary of its parent view
|
||||
if (flyoutTop < 0) callbacks.extendTopBoundary(space = -flyoutTop.toInt())
|
||||
}
|
||||
|
||||
fun cancelFlyout(endAction: () -> Unit) {
|
||||
hideFlyout(AnimationType.FADE) {
|
||||
cleanupFlyoutView()
|
||||
@@ -184,7 +178,6 @@ constructor(
|
||||
private fun cleanupFlyoutView() {
|
||||
container.removeView(flyout)
|
||||
this@BubbleBarFlyoutController.flyout = null
|
||||
callbacks.resetTopBoundary()
|
||||
}
|
||||
|
||||
fun hasFlyout() = flyout != null
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.android.launcher3.taskbar.bubbles.flyout
|
||||
|
||||
import android.content.Context
|
||||
import android.content.res.Configuration
|
||||
import android.content.res.Resources
|
||||
import android.graphics.Canvas
|
||||
import android.graphics.Color
|
||||
import android.graphics.Outline
|
||||
@@ -44,11 +45,27 @@ class BubbleBarFlyoutView(
|
||||
scheduler: FlyoutScheduler? = null,
|
||||
) : ConstraintLayout(context) {
|
||||
|
||||
private companion object {
|
||||
// the minimum progress of the expansion animation before the content starts fading in.
|
||||
const val MIN_EXPANSION_PROGRESS_FOR_CONTENT_ALPHA = 0.75f
|
||||
companion object {
|
||||
// the rate multiple for the background color animation relative to the morph animation.
|
||||
const val BACKGROUND_COLOR_CHANGE_RATE = 5
|
||||
// the minimum progress of the expansion animation before the content starts fading in.
|
||||
private const val MIN_EXPANSION_PROGRESS_FOR_CONTENT_ALPHA = 0.75f
|
||||
|
||||
private const val TEXT_ROW_HEIGHT_SP = 20
|
||||
private const val MAX_ROWS_COUNT = 3
|
||||
|
||||
/** Returns the maximum possible height of the flyout view. */
|
||||
fun getMaximumViewHeight(context: Context): Int {
|
||||
val verticalPaddings = getFlyoutPadding(context) * 2
|
||||
val textSizeSp = TEXT_ROW_HEIGHT_SP * MAX_ROWS_COUNT
|
||||
val textSizePx = textSizeSp * Resources.getSystem().displayMetrics.scaledDensity
|
||||
val triangleHeight =
|
||||
context.resources.getDimensionPixelSize(R.dimen.bubblebar_flyout_triangle_height)
|
||||
return verticalPaddings + textSizePx.toInt() + triangleHeight
|
||||
}
|
||||
|
||||
private fun getFlyoutPadding(context: Context) =
|
||||
context.resources.getDimensionPixelSize(R.dimen.bubblebar_flyout_padding)
|
||||
}
|
||||
|
||||
private val scheduler: FlyoutScheduler = scheduler ?: HandlerScheduler(this)
|
||||
@@ -61,10 +78,7 @@ class BubbleBarFlyoutView(
|
||||
private val message: TextView by
|
||||
lazy(LazyThreadSafetyMode.NONE) { findViewById(R.id.bubble_flyout_text) }
|
||||
|
||||
private val flyoutPadding by
|
||||
lazy(LazyThreadSafetyMode.NONE) {
|
||||
context.resources.getDimensionPixelSize(R.dimen.bubblebar_flyout_padding)
|
||||
}
|
||||
private val flyoutPadding by lazy(LazyThreadSafetyMode.NONE) { getFlyoutPadding(context) }
|
||||
|
||||
private val triangleHeight by
|
||||
lazy(LazyThreadSafetyMode.NONE) {
|
||||
|
||||
@@ -18,11 +18,6 @@ package com.android.launcher3.taskbar.bubbles.flyout
|
||||
|
||||
/** Callbacks that the flyout uses to notify of events. */
|
||||
interface FlyoutCallbacks {
|
||||
/** Requests to extend the top boundary of the parent to fully include the flyout. */
|
||||
fun extendTopBoundary(space: Int)
|
||||
|
||||
/** Resets the top boundary of the parent. */
|
||||
fun resetTopBoundary()
|
||||
|
||||
/** The flyout was clicked. */
|
||||
fun flyoutClicked()
|
||||
|
||||
+3
-3
@@ -74,6 +74,9 @@ interface BubbleStashController {
|
||||
val isBubblesShowingOnOverview: Boolean
|
||||
get() = launcherState == BubbleLauncherState.OVERVIEW
|
||||
|
||||
/** Bubble bar vertical center for launcher home. */
|
||||
var bubbleBarVerticalCenterForHome: Int
|
||||
|
||||
/** Updated when sysui locked state changes, when locked, bubble bar is not shown. */
|
||||
var isSysuiLocked: Boolean
|
||||
|
||||
@@ -121,9 +124,6 @@ interface BubbleStashController {
|
||||
/** Set a bubble bar location */
|
||||
fun setBubbleBarLocation(bubbleBarLocation: BubbleBarLocation)
|
||||
|
||||
/** 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
|
||||
* bubble bar based on the controller implementation.
|
||||
|
||||
+2
-6
@@ -47,7 +47,7 @@ class PersistentBubbleStashController(
|
||||
private lateinit var bubbleBarAlphaAnimator: MultiPropertyFactory<View>.MultiProperty
|
||||
private lateinit var bubbleBarScaleAnimator: AnimatedFloat
|
||||
private lateinit var controllersAfterInitAction: ControllersAfterInitAction
|
||||
private var verticalCenterForHome: Int = 0
|
||||
override var bubbleBarVerticalCenterForHome: Int = 0
|
||||
|
||||
override var launcherState: BubbleLauncherState = BubbleLauncherState.IN_APP
|
||||
set(state) {
|
||||
@@ -97,7 +97,7 @@ class PersistentBubbleStashController(
|
||||
override val bubbleBarTranslationYForHotseat: Float
|
||||
get() {
|
||||
val bubbleBarHeight = bubbleBarViewController.bubbleBarCollapsedHeight
|
||||
return -verticalCenterForHome + bubbleBarHeight / 2
|
||||
return -bubbleBarVerticalCenterForHome + bubbleBarHeight / 2
|
||||
}
|
||||
|
||||
override val bubbleBarTranslationY: Float
|
||||
@@ -159,10 +159,6 @@ class PersistentBubbleStashController(
|
||||
animatorSet.setDuration(BAR_STASH_DURATION).start()
|
||||
}
|
||||
|
||||
override fun setBubbleBarVerticalCenterForHome(verticalCenter: Int) {
|
||||
verticalCenterForHome = verticalCenter
|
||||
}
|
||||
|
||||
override fun showBubbleBarImmediate() = showBubbleBarImmediate(bubbleBarTranslationY)
|
||||
|
||||
override fun showBubbleBarImmediate(bubbleBarTranslationY: Float) {
|
||||
|
||||
+2
-6
@@ -78,7 +78,7 @@ class TransientBubbleStashController(
|
||||
context.resources.getDimensionPixelSize(R.dimen.bubblebar_stashed_size) / 2f
|
||||
|
||||
private var animator: AnimatorSet? = null
|
||||
private var verticalCenterForHome: Int = 0
|
||||
override var bubbleBarVerticalCenterForHome: Int = 0
|
||||
|
||||
override var isStashed: Boolean = false
|
||||
@VisibleForTesting set
|
||||
@@ -124,7 +124,7 @@ class TransientBubbleStashController(
|
||||
override val bubbleBarTranslationYForHotseat: Float
|
||||
get() {
|
||||
val bubbleBarHeight = bubbleBarViewController.bubbleBarCollapsedHeight
|
||||
return -verticalCenterForHome + bubbleBarHeight / 2
|
||||
return -bubbleBarVerticalCenterForHome + bubbleBarHeight / 2
|
||||
}
|
||||
|
||||
override val bubbleBarTranslationYForTaskbar: Float =
|
||||
@@ -182,10 +182,6 @@ class TransientBubbleStashController(
|
||||
.start()
|
||||
}
|
||||
|
||||
override fun setBubbleBarVerticalCenterForHome(verticalCenter: Int) {
|
||||
verticalCenterForHome = verticalCenter
|
||||
}
|
||||
|
||||
override fun showBubbleBarImmediate() {
|
||||
showBubbleBarImmediate(bubbleBarTranslationY)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user