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
This commit is contained in:
@@ -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.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_UNPINNED
|
||||||
import com.android.launcher3.taskbar.TaskbarDividerPopupView.Companion.createAndPopulate
|
import com.android.launcher3.taskbar.TaskbarDividerPopupView.Companion.createAndPopulate
|
||||||
import java.io.PrintWriter
|
import java.io.PrintWriter
|
||||||
|
import kotlin.jvm.optionals.getOrNull
|
||||||
|
|
||||||
/** Controls taskbar pinning through a popup view. */
|
/** Controls taskbar pinning through a popup view. */
|
||||||
class TaskbarPinningController(private val context: TaskbarActivityContext) :
|
class TaskbarPinningController(private val context: TaskbarActivityContext) :
|
||||||
@@ -119,7 +120,14 @@ class TaskbarPinningController(private val context: TaskbarActivityContext) :
|
|||||||
taskbarViewController.taskbarIconScaleForPinning.animateToValue(animateToValue),
|
taskbarViewController.taskbarIconScaleForPinning.animateToValue(animateToValue),
|
||||||
taskbarViewController.taskbarIconTranslationXForPinning.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
|
animatorSet.interpolator = Interpolators.EMPHASIZED
|
||||||
return animatorSet
|
return animatorSet
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,10 @@ package com.android.launcher3.taskbar.bubbles;
|
|||||||
import static android.view.View.INVISIBLE;
|
import static android.view.View.INVISIBLE;
|
||||||
import static android.view.View.VISIBLE;
|
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.Animator;
|
||||||
import android.animation.AnimatorSet;
|
import android.animation.AnimatorSet;
|
||||||
import android.content.res.Resources;
|
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.TaskbarActivityContext;
|
||||||
import com.android.launcher3.taskbar.TaskbarControllers;
|
import com.android.launcher3.taskbar.TaskbarControllers;
|
||||||
import com.android.launcher3.taskbar.TaskbarInsetsController;
|
import com.android.launcher3.taskbar.TaskbarInsetsController;
|
||||||
|
import com.android.launcher3.taskbar.TaskbarSharedState;
|
||||||
import com.android.launcher3.taskbar.TaskbarStashController;
|
import com.android.launcher3.taskbar.TaskbarStashController;
|
||||||
import com.android.launcher3.taskbar.bubbles.animation.BubbleBarViewAnimator;
|
import com.android.launcher3.taskbar.bubbles.animation.BubbleBarViewAnimator;
|
||||||
import com.android.launcher3.taskbar.bubbles.flyout.BubbleBarFlyoutController;
|
import com.android.launcher3.taskbar.bubbles.flyout.BubbleBarFlyoutController;
|
||||||
import com.android.launcher3.taskbar.bubbles.flyout.BubbleBarFlyoutPositioner;
|
import com.android.launcher3.taskbar.bubbles.flyout.BubbleBarFlyoutPositioner;
|
||||||
import com.android.launcher3.taskbar.bubbles.stashing.BubbleStashController;
|
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.MultiPropertyFactory;
|
||||||
import com.android.launcher3.util.MultiValueAlpha;
|
import com.android.launcher3.util.MultiValueAlpha;
|
||||||
import com.android.quickstep.SystemUiProxy;
|
import com.android.quickstep.SystemUiProxy;
|
||||||
@@ -101,6 +107,9 @@ public class BubbleBarViewController {
|
|||||||
this::updateTranslationY);
|
this::updateTranslationY);
|
||||||
private final AnimatedFloat mBubbleOffsetY = new AnimatedFloat(
|
private final AnimatedFloat mBubbleOffsetY = new AnimatedFloat(
|
||||||
this::updateBubbleOffsetY);
|
this::updateBubbleOffsetY);
|
||||||
|
private final AnimatedFloat mBubbleBarTranslationYForPinning = new AnimatedFloat(
|
||||||
|
this::updateTranslationY);
|
||||||
|
|
||||||
|
|
||||||
// Modified when swipe up is happening on the bubble bar or task bar.
|
// Modified when swipe up is happening on the bubble bar or task bar.
|
||||||
private float mBubbleBarSwipeUpTranslationY;
|
private float mBubbleBarSwipeUpTranslationY;
|
||||||
@@ -120,8 +129,9 @@ public class BubbleBarViewController {
|
|||||||
private BubbleBarViewAnimator mBubbleBarViewAnimator;
|
private BubbleBarViewAnimator mBubbleBarViewAnimator;
|
||||||
private final FrameLayout mBubbleBarContainer;
|
private final FrameLayout mBubbleBarContainer;
|
||||||
private BubbleBarFlyoutController mBubbleBarFlyoutController;
|
private BubbleBarFlyoutController mBubbleBarFlyoutController;
|
||||||
|
private TaskbarSharedState mTaskbarSharedState;
|
||||||
private final TimeSource mTimeSource = System::currentTimeMillis;
|
private final TimeSource mTimeSource = System::currentTimeMillis;
|
||||||
|
private final int mTaskbarTranslationDelta;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private BubbleBarBoundsChangeListener mBoundsChangeListener;
|
private BubbleBarBoundsChangeListener mBoundsChangeListener;
|
||||||
@@ -135,11 +145,13 @@ public class BubbleBarViewController {
|
|||||||
mBubbleBarAlpha = new MultiValueAlpha(mBarView, 1 /* num alpha channels */);
|
mBubbleBarAlpha = new MultiValueAlpha(mBarView, 1 /* num alpha channels */);
|
||||||
mIconSize = activity.getResources().getDimensionPixelSize(
|
mIconSize = activity.getResources().getDimensionPixelSize(
|
||||||
R.dimen.bubblebar_icon_size);
|
R.dimen.bubblebar_icon_size);
|
||||||
|
mTaskbarTranslationDelta = getBubbleBarTranslationDeltaForTaskbar(activity);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Initializes controller. */
|
/** Initializes controller. */
|
||||||
public void init(TaskbarControllers controllers, BubbleControllers bubbleControllers,
|
public void init(TaskbarControllers controllers, BubbleControllers bubbleControllers,
|
||||||
TaskbarViewPropertiesProvider taskbarViewPropertiesProvider) {
|
TaskbarViewPropertiesProvider taskbarViewPropertiesProvider) {
|
||||||
|
mTaskbarSharedState = controllers.getSharedState();
|
||||||
mBubbleStashController = bubbleControllers.bubbleStashController;
|
mBubbleStashController = bubbleControllers.bubbleStashController;
|
||||||
mBubbleBarController = bubbleControllers.bubbleBarController;
|
mBubbleBarController = bubbleControllers.bubbleBarController;
|
||||||
mBubbleDragController = bubbleControllers.bubbleDragController;
|
mBubbleDragController = bubbleControllers.bubbleDragController;
|
||||||
@@ -167,6 +179,10 @@ public class BubbleBarViewController {
|
|||||||
mBoundsChangeListener.onBoundsChanged();
|
mBoundsChangeListener.onBoundsChanged();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
float pinningValue = DisplayController.isTransientTaskbar(mActivity)
|
||||||
|
? PINNING_TRANSIENT
|
||||||
|
: PINNING_PERSISTENT;
|
||||||
|
mBubbleBarTranslationYForPinning.updateValue(pinningValue);
|
||||||
mBarView.setController(new BubbleBarView.Controller() {
|
mBarView.setController(new BubbleBarView.Controller() {
|
||||||
@Override
|
@Override
|
||||||
public float getBubbleBarTranslationY() {
|
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() {
|
private BubbleBarFlyoutPositioner createFlyoutPositioner() {
|
||||||
return new BubbleBarFlyoutPositioner() {
|
return new BubbleBarFlyoutPositioner() {
|
||||||
|
|
||||||
@@ -646,7 +667,35 @@ public class BubbleBarViewController {
|
|||||||
|
|
||||||
private void updateTranslationY() {
|
private void updateTranslationY() {
|
||||||
mBarView.setTranslationY(mBubbleBarTranslationY.value + mBubbleBarSwipeUpTranslationY
|
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) {
|
private void updateScaleX(float scale) {
|
||||||
|
|||||||
Reference in New Issue
Block a user