Transient Taskbar's Background animation

Added fold/unfold animation to the background of transient taskbar.
Note: The animation has only been added to transient taskbar

Test: manual
Fixes: 273929852
Change-Id: I2f35b6a1157341744d9c7b8306d7dbd8490702dc
This commit is contained in:
dshivangi
2023-03-22 18:26:12 +00:00
committed by Shivangi Dubey
parent b828ba1386
commit 4c38fada4f
4 changed files with 36 additions and 0 deletions

View File

@@ -50,6 +50,7 @@ class TaskbarBackgroundRenderer(context: TaskbarActivityContext) {
private val fullRightCornerRadius = context.rightCornerRadius.toFloat()
private var leftCornerRadius = fullLeftCornerRadius
private var rightCornerRadius = fullRightCornerRadius
private var widthInsetPercentage = 0f
private val square: Path = Path()
private val circle: Path = Path()
private val invertedLeftCornerPath: Path = Path()
@@ -157,12 +158,22 @@ class TaskbarBackgroundRenderer(context: TaskbarActivityContext) {
transientBackgroundBounds.right - halfWidthDelta,
bottom
)
val horizontalInset = fullWidth * widthInsetPercentage
lastDrawnTransientRect.inset(horizontalInset, 0f)
canvas.drawRoundRect(lastDrawnTransientRect, radius, radius, paint)
}
canvas.restore()
}
/**
* Sets the width percentage to inset the transient taskbar's background from the left and from
* the right.
*/
fun setBackgroundHorizontalInsets(insetPercentage: Float) {
widthInsetPercentage = insetPercentage
}
companion object {
const val DEFAULT_ROUNDNESS = 1f
}

View File

@@ -200,4 +200,13 @@ public class TaskbarDragLayer extends BaseDragLayer<TaskbarActivityContext> {
}
return super.dispatchKeyEvent(event);
}
/**
* Sets the width percentage to inset the transient taskbar's background from the left and from
* the right.
*/
public void setBackgroundHorizontalInsets(float insetPercentage) {
mBackgroundRenderer.setBackgroundHorizontalInsets(insetPercentage);
invalidate();
}
}

View File

@@ -183,6 +183,15 @@ public class TaskbarDragLayerController implements TaskbarControllers.LoggableTa
mLastSetBackgroundAlpha * (1 - mBgOffset.value));
}
/**
* Sets the width percentage to inset the transient taskbar's background from the left and from
* the right.
*/
public void setBackgroundHorizontalInsets(float insetPercentage) {
mTaskbarDragLayer.setBackgroundHorizontalInsets(insetPercentage);
}
@Override
public void dumpLogs(String prefix, PrintWriter pw) {
pw.println(prefix + "TaskbarDragLayerController:");

View File

@@ -33,11 +33,14 @@ import java.io.PrintWriter;
public class TaskbarUnfoldAnimationController implements
TaskbarControllers.LoggableTaskbarController {
private static final float MAX_WIDTH_INSET_FRACTION = 0.035f;
private final ScopedUnfoldTransitionProgressProvider mScopedUnfoldTransitionProgressProvider;
private final NaturalRotationUnfoldProgressProvider mNaturalUnfoldTransitionProgressProvider;
private final UnfoldMoveFromCenterAnimator mMoveFromCenterAnimator;
private final TransitionListener mTransitionListener = new TransitionListener();
private TaskbarViewController mTaskbarViewController;
private TaskbarDragLayerController mTaskbarDragLayerController;
public TaskbarUnfoldAnimationController(BaseTaskbarContext context,
ScopedUnfoldTransitionProgressProvider source,
@@ -63,6 +66,7 @@ public class TaskbarUnfoldAnimationController implements
mTaskbarViewController.addOneTimePreDrawListener(() ->
mScopedUnfoldTransitionProgressProvider.setReadyToHandleTransition(true));
mNaturalUnfoldTransitionProgressProvider.addCallback(mTransitionListener);
mTaskbarDragLayerController = taskbarControllers.taskbarDragLayerController;
}
/**
@@ -99,11 +103,14 @@ public class TaskbarUnfoldAnimationController implements
public void onTransitionFinished() {
mMoveFromCenterAnimator.onTransitionFinished();
mMoveFromCenterAnimator.clearRegisteredViews();
mTaskbarDragLayerController.setBackgroundHorizontalInsets(0f);
}
@Override
public void onTransitionProgress(float progress) {
mMoveFromCenterAnimator.onTransitionProgress(progress);
float insetPercentage = (1 - progress) * MAX_WIDTH_INSET_FRACTION;
mTaskbarDragLayerController.setBackgroundHorizontalInsets(insetPercentage);
}
}
}