From eedc7ab8fdb94de05201fa87537991558accbe8a Mon Sep 17 00:00:00 2001 From: mpodolian Date: Fri, 18 Oct 2024 13:29:12 -0700 Subject: [PATCH 1/2] Animate the bubble bar Y for task bar pinned/unpinned switches. Animate the horizontal position of the bubble bar on taskbar pinned / unpinned switches. Bug: 345698412 Test: TaskbarPinningControllerTest Flag: com.android.wm.shell.enable_bubble_bar Change-Id: If330dc9e5f7b16a588973ad6043a5dc6709e13ab --- .../taskbar/TaskbarPinningController.kt | 10 +++- .../bubbles/BubbleBarViewController.java | 53 ++++++++++++++++++- 2 files changed, 60 insertions(+), 3 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarPinningController.kt b/quickstep/src/com/android/launcher3/taskbar/TaskbarPinningController.kt index 7848b7e238..caf8dd8dc5 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarPinningController.kt +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarPinningController.kt @@ -30,6 +30,7 @@ import com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASK import com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_UNPINNED import com.android.launcher3.taskbar.TaskbarDividerPopupView.Companion.createAndPopulate import java.io.PrintWriter +import kotlin.jvm.optionals.getOrNull /** Controls taskbar pinning through a popup view. */ class TaskbarPinningController(private val context: TaskbarActivityContext) : @@ -119,7 +120,14 @@ class TaskbarPinningController(private val context: TaskbarActivityContext) : taskbarViewController.taskbarIconScaleForPinning.animateToValue(animateToValue), taskbarViewController.taskbarIconTranslationXForPinning.animateToValue(animateToValue), ) - + controllers.bubbleControllers.getOrNull()?.bubbleBarViewController?.let { + // if bubble bar is not visible no need to add it`s animations + if (!it.isBubbleBarVisible) return@let + // TODO(b/345698412): add scale animation + animatorSet.playTogether( + it.bubbleBarTranslationYForPinning.animateToValue(animateToValue) + ) + } animatorSet.interpolator = Interpolators.EMPHASIZED return animatorSet } diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java index 76d36061f1..7e572386ad 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java @@ -18,6 +18,10 @@ package com.android.launcher3.taskbar.bubbles; import static android.view.View.INVISIBLE; import static android.view.View.VISIBLE; +import static com.android.launcher3.Utilities.mapRange; +import static com.android.launcher3.taskbar.TaskbarPinningController.PINNING_PERSISTENT; +import static com.android.launcher3.taskbar.TaskbarPinningController.PINNING_TRANSIENT; + import android.animation.Animator; import android.animation.AnimatorSet; import android.content.res.Resources; @@ -41,11 +45,13 @@ import com.android.launcher3.anim.RoundedRectRevealOutlineProvider; import com.android.launcher3.taskbar.TaskbarActivityContext; import com.android.launcher3.taskbar.TaskbarControllers; import com.android.launcher3.taskbar.TaskbarInsetsController; +import com.android.launcher3.taskbar.TaskbarSharedState; import com.android.launcher3.taskbar.TaskbarStashController; import com.android.launcher3.taskbar.bubbles.animation.BubbleBarViewAnimator; import com.android.launcher3.taskbar.bubbles.flyout.BubbleBarFlyoutController; import com.android.launcher3.taskbar.bubbles.flyout.BubbleBarFlyoutPositioner; import com.android.launcher3.taskbar.bubbles.stashing.BubbleStashController; +import com.android.launcher3.util.DisplayController; import com.android.launcher3.util.MultiPropertyFactory; import com.android.launcher3.util.MultiValueAlpha; import com.android.quickstep.SystemUiProxy; @@ -101,6 +107,9 @@ public class BubbleBarViewController { this::updateTranslationY); private final AnimatedFloat mBubbleOffsetY = new AnimatedFloat( this::updateBubbleOffsetY); + private final AnimatedFloat mBubbleBarTranslationYForPinning = new AnimatedFloat( + this::updateTranslationY); + // Modified when swipe up is happening on the bubble bar or task bar. private float mBubbleBarSwipeUpTranslationY; @@ -120,8 +129,9 @@ public class BubbleBarViewController { private BubbleBarViewAnimator mBubbleBarViewAnimator; private final FrameLayout mBubbleBarContainer; private BubbleBarFlyoutController mBubbleBarFlyoutController; - + private TaskbarSharedState mTaskbarSharedState; private final TimeSource mTimeSource = System::currentTimeMillis; + private final int mTaskbarTranslationDelta; @Nullable private BubbleBarBoundsChangeListener mBoundsChangeListener; @@ -135,11 +145,13 @@ public class BubbleBarViewController { mBubbleBarAlpha = new MultiValueAlpha(mBarView, 1 /* num alpha channels */); mIconSize = activity.getResources().getDimensionPixelSize( R.dimen.bubblebar_icon_size); + mTaskbarTranslationDelta = getBubbleBarTranslationDeltaForTaskbar(activity); } /** Initializes controller. */ public void init(TaskbarControllers controllers, BubbleControllers bubbleControllers, TaskbarViewPropertiesProvider taskbarViewPropertiesProvider) { + mTaskbarSharedState = controllers.getSharedState(); mBubbleStashController = bubbleControllers.bubbleStashController; mBubbleBarController = bubbleControllers.bubbleBarController; mBubbleDragController = bubbleControllers.bubbleDragController; @@ -167,6 +179,10 @@ public class BubbleBarViewController { mBoundsChangeListener.onBoundsChanged(); } }); + float pinningValue = DisplayController.isTransientTaskbar(mActivity) + ? PINNING_TRANSIENT + : PINNING_PERSISTENT; + mBubbleBarTranslationYForPinning.updateValue(pinningValue); mBarView.setController(new BubbleBarView.Controller() { @Override public float getBubbleBarTranslationY() { @@ -220,6 +236,11 @@ public class BubbleBarViewController { }; } + /** Returns animated float property for controlling pining Y position. */ + public AnimatedFloat getBubbleBarTranslationYForPinning() { + return mBubbleBarTranslationYForPinning; + } + private BubbleBarFlyoutPositioner createFlyoutPositioner() { return new BubbleBarFlyoutPositioner() { @@ -646,7 +667,35 @@ public class BubbleBarViewController { private void updateTranslationY() { mBarView.setTranslationY(mBubbleBarTranslationY.value + mBubbleBarSwipeUpTranslationY - + mBubbleBarStashTranslationY); + + mBubbleBarStashTranslationY + getBubbleBarTranslationYForTaskbarPinning()); + } + + /** Computes translation y for taskbar pinning. */ + private float getBubbleBarTranslationYForTaskbarPinning() { + if (mTaskbarSharedState == null) return 0f; + float animationProgress = mBubbleBarTranslationYForPinning.value; + if (mTaskbarSharedState.startTaskbarVariantIsTransient) { + return mapRange(animationProgress, /* min = */ 0f, mTaskbarTranslationDelta); + } else { + return mapRange(animationProgress, -mTaskbarTranslationDelta, /* max = */ 0f); + } + } + + /** + * Calculates the vertical difference in the bubble bar positions for pinned and transient + * taskbar modes. + */ + private int getBubbleBarTranslationDeltaForTaskbar(TaskbarActivityContext activity) { + Resources res = activity.getResources(); + int persistentBubbleSize = res + .getDimensionPixelSize(R.dimen.bubblebar_icon_size_persistent_taskbar); + int persistentSpacingSize = res + .getDimensionPixelSize(R.dimen.bubblebar_icon_spacing_persistent_taskbar); + int persistentBubbleBarSize = persistentBubbleSize + persistentSpacingSize * 2; + int persistentTaskbarHeight = activity.getPersistentTaskbarDeviceProfile().taskbarHeight; + int persistentBubbleBarY = (persistentTaskbarHeight - persistentBubbleBarSize) / 2; + int transientBubbleBarY = activity.getTransientTaskbarDeviceProfile().taskbarBottomMargin; + return transientBubbleBarY - persistentBubbleBarY; } private void updateScaleX(float scale) { From 92d25cd21d80461c7c2954edaf425f2c627edf5c Mon Sep 17 00:00:00 2001 From: mpodolian Date: Tue, 22 Oct 2024 12:39:09 -0700 Subject: [PATCH 2/2] Added scale animation for taskbar pinning transition. Animate the bubble bar icons size and padding for taskbar change mode animation. Bug: 345698412 Test: TaskbarPinningControllerTest Flag: com.android.wm.shell.enable_bubble_bar Change-Id: Ibdecabd1310203dc956f69673dc446a0e7e556a6 --- .../taskbar/TaskbarPinningController.kt | 5 +- .../taskbar/bubbles/BubbleBarView.java | 11 ++++ .../bubbles/BubbleBarViewController.java | 50 ++++++++++++++----- 3 files changed, 49 insertions(+), 17 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarPinningController.kt b/quickstep/src/com/android/launcher3/taskbar/TaskbarPinningController.kt index caf8dd8dc5..bcfc7181da 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarPinningController.kt +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarPinningController.kt @@ -123,10 +123,7 @@ class TaskbarPinningController(private val context: TaskbarActivityContext) : controllers.bubbleControllers.getOrNull()?.bubbleBarViewController?.let { // if bubble bar is not visible no need to add it`s animations if (!it.isBubbleBarVisible) return@let - // TODO(b/345698412): add scale animation - animatorSet.playTogether( - it.bubbleBarTranslationYForPinning.animateToValue(animateToValue) - ) + animatorSet.playTogether(it.bubbleBarPinning.animateToValue(animateToValue)) } animatorSet.interpolator = Interpolators.EMPHASIZED return animatorSet diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java index c5d649ecfb..996d6459bd 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java @@ -331,6 +331,17 @@ public class BubbleBarView extends FrameLayout { } } + /** + * Set the bubble icons size and spacing between the bubbles and the borders of the bubble + * bar. + */ + public void setIconSizeAndPaddingForPinning(float newIconSize, float newBubbleBarPadding) { + mBubbleBarPadding = newBubbleBarPadding; + mIconScale = newIconSize / mIconSize; + updateBubblesLayoutProperties(mBubbleBarLocation); + invalidate(); + } + /** * Sets new icon sizes and newBubbleBarPadding between icons and bubble bar borders. * diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java index 7e572386ad..74546d877e 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java @@ -107,9 +107,10 @@ public class BubbleBarViewController { this::updateTranslationY); private final AnimatedFloat mBubbleOffsetY = new AnimatedFloat( this::updateBubbleOffsetY); - private final AnimatedFloat mBubbleBarTranslationYForPinning = new AnimatedFloat( - this::updateTranslationY); - + private final AnimatedFloat mBubbleBarPinning = new AnimatedFloat(pinningProgress -> { + updateTranslationY(); + setBubbleBarScaleAndPadding(pinningProgress); + }); // Modified when swipe up is happening on the bubble bar or task bar. private float mBubbleBarSwipeUpTranslationY; @@ -182,7 +183,7 @@ public class BubbleBarViewController { float pinningValue = DisplayController.isTransientTaskbar(mActivity) ? PINNING_TRANSIENT : PINNING_PERSISTENT; - mBubbleBarTranslationYForPinning.updateValue(pinningValue); + mBubbleBarPinning.updateValue(pinningValue); mBarView.setController(new BubbleBarView.Controller() { @Override public float getBubbleBarTranslationY() { @@ -236,9 +237,9 @@ public class BubbleBarViewController { }; } - /** Returns animated float property for controlling pining Y position. */ - public AnimatedFloat getBubbleBarTranslationYForPinning() { - return mBubbleBarTranslationYForPinning; + /** Returns animated float property responsible for pinning transition animation. */ + public AnimatedFloat getBubbleBarPinning() { + return mBubbleBarPinning; } private BubbleBarFlyoutPositioner createFlyoutPositioner() { @@ -609,9 +610,11 @@ public class BubbleBarViewController { updateBubbleBarIconSizeAndPadding(newIconSize, newPadding, animate); } - private int getBubbleBarIconSizeFromDeviceProfile(Resources res) { - DeviceProfile deviceProfile = mActivity.getDeviceProfile(); + return getBubbleBarIconSizeFromDeviceProfile(res, mActivity.getDeviceProfile()); + } + + private int getBubbleBarIconSizeFromDeviceProfile(Resources res, DeviceProfile deviceProfile) { DisplayMetrics dm = res.getDisplayMetrics(); float smallIconSize = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, APP_ICON_SMALL_DP, dm); @@ -626,7 +629,10 @@ public class BubbleBarViewController { } private int getBubbleBarPaddingFromDeviceProfile(Resources res) { - DeviceProfile deviceProfile = mActivity.getDeviceProfile(); + return getBubbleBarPaddingFromDeviceProfile(res, mActivity.getDeviceProfile()); + } + + private int getBubbleBarPaddingFromDeviceProfile(Resources res, DeviceProfile deviceProfile) { DisplayMetrics dm = res.getDisplayMetrics(); float mediumIconSize = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, APP_ICON_MEDIUM_DP, dm); @@ -673,14 +679,32 @@ public class BubbleBarViewController { /** Computes translation y for taskbar pinning. */ private float getBubbleBarTranslationYForTaskbarPinning() { if (mTaskbarSharedState == null) return 0f; - float animationProgress = mBubbleBarTranslationYForPinning.value; + float pinningProgress = mBubbleBarPinning.value; if (mTaskbarSharedState.startTaskbarVariantIsTransient) { - return mapRange(animationProgress, /* min = */ 0f, mTaskbarTranslationDelta); + return mapRange(pinningProgress, /* min = */ 0f, mTaskbarTranslationDelta); } else { - return mapRange(animationProgress, -mTaskbarTranslationDelta, /* max = */ 0f); + return mapRange(pinningProgress, -mTaskbarTranslationDelta, /* max = */ 0f); } } + private void setBubbleBarScaleAndPadding(float pinningProgress) { + Resources res = mActivity.getResources(); + // determine icon scale for pinning + int persistentIconSize = res.getDimensionPixelSize( + R.dimen.bubblebar_icon_size_persistent_taskbar); + int transientIconSize = getBubbleBarIconSizeFromDeviceProfile(res, + mActivity.getTransientTaskbarDeviceProfile()); + float pinningIconSize = mapRange(pinningProgress, transientIconSize, persistentIconSize); + + // determine bubble bar padding for pinning + int persistentPadding = res.getDimensionPixelSize( + R.dimen.bubblebar_icon_spacing_persistent_taskbar); + int transientPadding = getBubbleBarPaddingFromDeviceProfile(res, + mActivity.getTransientTaskbarDeviceProfile()); + float pinningPadding = mapRange(pinningProgress, transientPadding, persistentPadding); + mBarView.setIconSizeAndPaddingForPinning(pinningIconSize, pinningPadding); + } + /** * Calculates the vertical difference in the bubble bar positions for pinned and transient * taskbar modes.