Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a3a85040 authored by Shivangi Dubey's avatar Shivangi Dubey Committed by Android (Google) Code Review
Browse files

Merge "Transient Taskbar's Background animation" into udc-dev

parents 42dcf69c 4c38fada
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -55,6 +55,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()
@@ -166,12 +167,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
    }
+9 −0
Original line number Diff line number Diff line
@@ -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();
    }
}
+9 −0
Original line number Diff line number Diff line
@@ -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:");
+7 −0
Original line number Diff line number Diff line
@@ -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);
        }
    }
}