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

Commit eeaba090 authored by Sunny Goyal's avatar Sunny Goyal Committed by Android (Google) Code Review
Browse files

Merge "Relying on the controller state instead of animator state for icon...

Merge "Relying on the controller state instead of animator state for icon alignment" into tm-qpr-dev
parents 71370c58 774dcd06
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -355,6 +355,11 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
        mTaskbarLauncherStateController.applyState();
    }

    @Override
    public boolean isIconAlignedWithHotseat() {
        return mTaskbarLauncherStateController.isIconAlignedWithHotseat();
    }

    @Override
    public void dumpLogs(String prefix, PrintWriter pw) {
        super.dumpLogs(prefix, pw);
+19 −14
Original line number Diff line number Diff line
@@ -38,9 +38,8 @@ import com.android.launcher3.Utilities;
import com.android.launcher3.anim.AnimatorListeners;
import com.android.launcher3.statemanager.StateManager;
import com.android.launcher3.uioverrides.QuickstepLauncher;
import com.android.launcher3.util.MultiPropertyFactory.MultiProperty;
import com.android.launcher3.uioverrides.states.OverviewState;
import com.android.launcher3.util.MultiValueAlpha;
import com.android.launcher3.util.MultiPropertyFactory.MultiProperty;
import com.android.quickstep.AnimatedFloat;
import com.android.quickstep.RecentsAnimationCallbacks;
import com.android.quickstep.RecentsAnimationController;
@@ -251,17 +250,7 @@ import java.util.StringJoiner;

    private Animator onStateChangeApplied(int changedFlags, long duration, boolean start) {
        boolean goingToLauncher = isInLauncher();
        final float toAlignment;
        if (goingToLauncher) {
            boolean isInStashedState = mLauncherState.isTaskbarStashed(mLauncher);
            boolean willStashVisually = isInStashedState
                    && mControllers.taskbarStashController.supportsVisualStashing();
            boolean isTaskbarAlignedWithHotseat =
                    mLauncherState.isTaskbarAlignedWithHotseat(mLauncher);
            toAlignment = isTaskbarAlignedWithHotseat && !willStashVisually ? 1 : 0;
        } else {
            toAlignment = 0;
        }
        final float toAlignment = isIconAlignedWithHotseat() ? 1 : 0;
        if (DEBUG) {
            Log.d(TAG, "onStateChangeApplied - mState: " + getStateString(mState)
                    + ", changedFlags: " + getStateString(changedFlags)
@@ -357,6 +346,22 @@ import java.util.StringJoiner;
        return mLauncherState.isTaskbarAlignedWithHotseat(mLauncher);
    }

    /**
     * Returns if icons should be aligned to hotseat in the current transition
     */
    public boolean isIconAlignedWithHotseat() {
        if (isInLauncher()) {
            boolean isInStashedState = mLauncherState.isTaskbarStashed(mLauncher);
            boolean willStashVisually = isInStashedState
                    && mControllers.taskbarStashController.supportsVisualStashing();
            boolean isTaskbarAlignedWithHotseat =
                    mLauncherState.isTaskbarAlignedWithHotseat(mLauncher);
            return isTaskbarAlignedWithHotseat && !willStashVisually;
        } else {
            return false;
        }
    }

    private void playStateTransitionAnim(AnimatorSet animatorSet, long duration,
            boolean committed) {
        boolean isInStashedState = mLauncherState.isTaskbarStashed(mLauncher);
@@ -395,7 +400,7 @@ import java.util.StringJoiner;
                || (!taskbarWillBeVisible && Float.compare(currentValue, 0) != 0);

        mControllers.taskbarViewController.setLauncherIconAlignment(
                mIconAlignment.value, mIconAlignment.getEndValue(), mLauncher.getDeviceProfile());
                mIconAlignment.value, mLauncher.getDeviceProfile());
        mControllers.navbarButtonsViewController.updateTaskbarAlignment(mIconAlignment.value);
        // Switch taskbar and hotseat in last frame
        updateIconAlphaForHome(taskbarWillBeVisible ? 1 : 0);
+7 −0
Original line number Diff line number Diff line
@@ -114,6 +114,13 @@ public class TaskbarUIController {
                || mControllers.navbarButtonsViewController.isEventOverAnyItem(ev);
    }

    /**
     * Returns true if icons should be aligned to hotseat in the current transition.
     */
    public boolean isIconAlignedWithHotseat() {
        return false;
    }

    @CallSuper
    protected void dumpLogs(String prefix, PrintWriter pw) {
        pw.println(String.format(
+4 −6
Original line number Diff line number Diff line
@@ -280,10 +280,9 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
     *                       0 => not aligned
     *                       1 => fully aligned
     */
    public void setLauncherIconAlignment(float alignmentRatio, Float endAlignment,
            DeviceProfile launcherDp) {
    public void setLauncherIconAlignment(float alignmentRatio, DeviceProfile launcherDp) {
        if (mIconAlignControllerLazy == null) {
            mIconAlignControllerLazy = createIconAlignmentController(launcherDp, endAlignment);
            mIconAlignControllerLazy = createIconAlignmentController(launcherDp);
        }
        mIconAlignControllerLazy.setPlayFraction(alignmentRatio);
        if (alignmentRatio <= 0 || alignmentRatio >= 1) {
@@ -295,8 +294,7 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
    /**
     * Creates an animation for aligning the taskbar icons with the provided Launcher device profile
     */
    private AnimatorPlaybackController createIconAlignmentController(DeviceProfile launcherDp,
            Float endAlignment) {
    private AnimatorPlaybackController createIconAlignmentController(DeviceProfile launcherDp) {
        mOnControllerPreCreateCallback.run();
        PendingAnimation setter = new PendingAnimation(100);
        DeviceProfile taskbarDp = mActivity.getDeviceProfile();
@@ -322,7 +320,7 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
        setter.addOnFrameListener(anim -> mActivity.setTaskbarWindowHeight(
                anim.getAnimatedFraction() > 0 ? expandedHeight : collapsedHeight));

        boolean isToHome = endAlignment != null && endAlignment == 1;
        boolean isToHome = mControllers.uiController.isIconAlignedWithHotseat();
        for (int i = 0; i < mTaskbarView.getChildCount(); i++) {
            View child = mTaskbarView.getChildAt(i);
            int positionInHotseat;
+0 −20
Original line number Diff line number Diff line
@@ -98,15 +98,6 @@ public class AnimatedFloat {
        }
    }

    /**
     * Starts the animation.
     */
    public void startAnimation() {
        if (mValueAnimator != null) {
            mValueAnimator.start();
        }
    }

    public void cancelAnimation() {
        if (mValueAnimator != null) {
            mValueAnimator.cancel();
@@ -119,10 +110,6 @@ public class AnimatedFloat {
        }
    }

    public ObjectAnimator getCurrentAnimation() {
        return mValueAnimator;
    }

    public boolean isAnimating() {
        return mValueAnimator != null;
    }
@@ -140,11 +127,4 @@ public class AnimatedFloat {
    public boolean isSettledOnValue(float endValue) {
        return !isAnimating() && value == endValue;
    }

    /**
     * Returns the value we are animating to, or {@code null} if we are not currently animating.
     */
    public Float getEndValue() {
        return mEndValue;
    }
}