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

Commit 13e9b9f8 authored by Jon Miranda's avatar Jon Miranda
Browse files

Translate the taskbar icons to match nav handle shape.

- We need to reset icon alignment whenever icon layout bound
  changes. This fixes the issue where we build an icon
  alignment animator before any of the views are laid out.
- Separated animation logic between.
  createTransientAnimToIsStashed and createAnimToIsStashed
* The values still require a bit more tuning but this gets us
  a lot closer to spec for many of the motion polish.

Bug: 267806083
Bug: 246634367
Bug: 246635237
Test: manual
Change-Id: Id122134b22ef4e418ce632e4a8137239dc8bb313
parent 202c68c8
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@ package com.android.launcher3.taskbar;

import static com.android.launcher3.taskbar.TaskbarStashController.FLAG_IN_APP;
import static com.android.launcher3.taskbar.TaskbarStashController.FLAG_IN_STASHED_LAUNCHER_STATE;
import static com.android.launcher3.taskbar.TaskbarStashController.TASKBAR_STASH_DURATION;

import android.animation.Animator;

@@ -93,7 +92,8 @@ public class FallbackTaskbarUIController extends TaskbarUIController {
    }

    private void animateToRecentsState(RecentsState toState) {
        Animator anim = createAnimToRecentsState(toState, TASKBAR_STASH_DURATION);
        Animator anim = createAnimToRecentsState(toState,
                mControllers.taskbarStashController.getStashDuration());
        if (anim != null) {
            anim.start();
        }
+5 −0
Original line number Diff line number Diff line
@@ -393,6 +393,11 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
        mLauncher.launchSplitTasks(taskView, groupTask);
    }

    @Override
    protected void onIconLayoutBoundsChanged() {
        mTaskbarLauncherStateController.resetIconAlignment();
    }

    @Override
    public void dumpLogs(String prefix, PrintWriter pw) {
        super.dumpLogs(prefix, pw);
+12 −2
Original line number Diff line number Diff line
@@ -38,7 +38,6 @@ import com.android.launcher3.util.Executors;
import com.android.launcher3.util.MultiPropertyFactory;
import com.android.launcher3.util.MultiValueAlpha;
import com.android.systemui.shared.navigationbar.RegionSamplingHelper;
import com.android.systemui.shared.system.QuickStepContract;

import java.io.PrintWriter;

@@ -152,6 +151,14 @@ public class StashedHandleViewController implements TaskbarControllers.LoggableT
        }
    }

    /**
     * Returns the stashed handle bounds.
     * @param out The destination rect.
     */
    public void getStashedHandleBounds(Rect out) {
        out.set(mStashedHandleBounds);
    }

    private void initRegionSampler() {
        mRegionSamplingHelper = new RegionSamplingHelper(mStashedHandleView,
                new RegionSamplingHelper.SamplingCallback() {
@@ -194,16 +201,19 @@ public class StashedHandleViewController implements TaskbarControllers.LoggableT
     */
    public Animator createRevealAnimToIsStashed(boolean isStashed) {
        Rect visualBounds = new Rect(mControllers.taskbarViewController.getIconLayoutBounds());
        float startRadius = mStashedHandleRadius;

        if (DisplayController.isTransientTaskbar(mActivity)) {
            // Account for the full visual height of the transient taskbar.
            int heightDiff = (mTaskbarSize - visualBounds.height()) / 2;
            visualBounds.top -= heightDiff;
            visualBounds.bottom += heightDiff;

            startRadius = visualBounds.height() / 2f;
        }

        final RevealOutlineAnimation handleRevealProvider = new RoundedRectRevealOutlineProvider(
                mStashedHandleRadius, mStashedHandleRadius, visualBounds, mStashedHandleBounds);
                startRadius, mStashedHandleRadius, visualBounds, mStashedHandleBounds);

        boolean isReversed = !isStashed;
        boolean changingDirection = mWasLastRevealAnimReversed != isReversed;
+9 −6
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.graphics.Color
import android.graphics.Paint
import android.graphics.Path
import com.android.launcher3.R
import com.android.launcher3.Utilities.mapRange
import com.android.launcher3.Utilities.mapToRange
import com.android.launcher3.anim.Interpolators
import com.android.launcher3.icons.GraphicsUtils.setColorAlphaBound
@@ -51,6 +52,9 @@ class TaskbarBackgroundRenderer(context: TaskbarActivityContext) {
    private val invertedLeftCornerPath: Path = Path()
    private val invertedRightCornerPath: Path = Path()

    private val stashedHandleWidth =
        context.resources.getDimensionPixelSize(R.dimen.taskbar_stashed_handle_width)

    init {
        paint.color = context.getColor(R.color.taskbar_background)
        paint.flags = Paint.ANTI_ALIAS_FLAG
@@ -111,12 +115,11 @@ class TaskbarBackgroundRenderer(context: TaskbarActivityContext) {
            canvas.drawPath(invertedRightCornerPath, paint)
        } else {
            // Approximates the stash/unstash animation to transform the background.
            val scaleFactor = backgroundHeight / maxBackgroundHeight
            val width = transientBackgroundBounds.width()
            val widthScale = mapToRange(scaleFactor, 0f, 1f, 0.2f, 1f, Interpolators.LINEAR)
            val newWidth = widthScale * width
            val delta = width - newWidth
            canvas.translate(0f, bottomMargin * ((1f - scaleFactor) / 2f))
            val progress = backgroundHeight / maxBackgroundHeight
            val fullWidth = transientBackgroundBounds.width()
            val newWidth = mapRange(progress, stashedHandleWidth.toFloat(), fullWidth.toFloat())
            val delta = fullWidth - newWidth
            canvas.translate(0f, bottomMargin * ((1f - progress) / 2f))

            // Draw shadow.
            val shadowAlpha =
+23 −7
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@ package com.android.launcher3.taskbar;

import static com.android.launcher3.taskbar.TaskbarStashController.FLAG_IN_APP;
import static com.android.launcher3.taskbar.TaskbarStashController.FLAG_IN_STASHED_LAUNCHER_STATE;
import static com.android.launcher3.taskbar.TaskbarStashController.TASKBAR_STASH_DURATION;
import static com.android.launcher3.taskbar.TaskbarViewController.ALPHA_INDEX_HOME;
import static com.android.systemui.animation.Interpolators.EMPHASIZED;

@@ -41,6 +40,7 @@ import com.android.launcher3.statemanager.StateManager;
import com.android.launcher3.uioverrides.QuickstepLauncher;
import com.android.launcher3.uioverrides.states.OverviewState;
import com.android.launcher3.util.MultiPropertyFactory.MultiProperty;
import com.android.launcher3.util.window.RefreshRateTracker;
import com.android.quickstep.RecentsAnimationCallbacks;
import com.android.quickstep.RecentsAnimationController;
import com.android.quickstep.views.RecentsView;
@@ -139,8 +139,7 @@ import java.util.StringJoiner;
        mIconAlphaForHome = mControllers.taskbarViewController
                .getTaskbarIconAlpha().get(ALPHA_INDEX_HOME);

        mIconAlignment.finishAnimation();
        onIconAlignmentRatioChanged();
        resetIconAlignment();

        mLauncher.getStateManager().addStateListener(mStateListener);

@@ -234,7 +233,7 @@ import java.util.StringJoiner;
    }

    public void applyState() {
        applyState(TASKBAR_STASH_DURATION);
        applyState(mControllers.taskbarStashController.getStashDuration());
    }

    public void applyState(long duration) {
@@ -242,7 +241,7 @@ import java.util.StringJoiner;
    }

    public Animator applyState(boolean start) {
        return applyState(TASKBAR_STASH_DURATION, start);
        return applyState(mControllers.taskbarStashController.getStashDuration(), start);
    }

    public Animator applyState(long duration, boolean start) {
@@ -329,8 +328,17 @@ import java.util.StringJoiner;
                        + mTaskbarBackgroundAlpha.value
                        + " -> " + backgroundAlpha + ": " + duration);
            }
            animatorSet.play(mTaskbarBackgroundAlpha.animateToValue(backgroundAlpha)
                    .setDuration(duration));

            Animator taskbarBackgroundAlpha = mTaskbarBackgroundAlpha
                    .animateToValue(backgroundAlpha)
                    .setDuration(duration);
            // Add a single frame delay to the taskbar bg to avoid too many moving parts during the
            // app launch animation.
            taskbarBackgroundAlpha.setStartDelay(
                    (hasAnyFlag(changedFlags, FLAG_RESUMED) && !goingToLauncher)
                            ? RefreshRateTracker.getSingleFrameMs(mLauncher)
                            : 0);
            animatorSet.play(taskbarBackgroundAlpha);
        }

        float cornerRoundness = goingToLauncher ? 0 : 1;
@@ -433,6 +441,14 @@ import java.util.StringJoiner;
        return (mState & FLAGS_LAUNCHER) != 0;
    }

    /**
     * Resets and updates the icon alignment.
     */
    protected void resetIconAlignment() {
        mIconAlignment.finishAnimation();
        onIconAlignmentRatioChanged();
    }

    private void onIconAlignmentRatioChanged() {
        float currentValue = mIconAlphaForHome.getValue();
        boolean taskbarWillBeVisible = mIconAlignment.value < 1;
Loading