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

Commit 21f3d770 authored by Jagrut Desai's avatar Jagrut Desai Committed by Android (Google) Code Review
Browse files

Merge "Taskbar Pinning Animation Improvements" into main

parents 8424eed9 a3d3c069
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -456,6 +456,10 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
        return mTransientTaskbarBounds;
    }

    protected float getCurrentTaskbarWidth() {
        return mControllers.taskbarViewController.getCurrentVisualTaskbarWidth();
    }

    @Override
    public StatsLogManager getStatsLogManager() {
        // Used to mock, can't mock a default interface method directly
+1 −6
Original line number Diff line number Diff line
@@ -203,12 +203,7 @@ class TaskbarBackgroundRenderer(private val context: TaskbarActivityContext) {
        val newBackgroundHeight =
            mapRange(progress, backgroundHeightWhileAnimating, maxTransientTaskbarHeight)
        val fullWidth = transientBackgroundBounds.width()

        // .9f is here to restrict min width of the background while animating, so transient
        // background keeps it pill shape until animation end.
        val animationWidth =
            if (DisplayController.isTransientTaskbar(context)) fullWidth.toFloat() * .9f
            else fullWidth.toFloat()
        val animationWidth = context.currentTaskbarWidth
        val backgroundWidthWhileAnimating =
            if (isAnimatingPinning) animationWidth else stashedHandleWidth.toFloat()

+3 −1
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.annotation.SuppressLint
import android.view.View
import androidx.annotation.VisibleForTesting
import androidx.core.animation.doOnEnd
import com.android.app.animation.Interpolators
import com.android.launcher3.LauncherPrefs
import com.android.launcher3.LauncherPrefs.Companion.TASKBAR_PINNING
import com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_DIVIDER_MENU_CLOSE
@@ -106,6 +107,7 @@ class TaskbarPinningController(private val context: TaskbarActivityContext) :
            taskbarViewController.taskbarIconTranslationXForPinning.animateToValue(animateToValue)
        )

        animatorSet.interpolator = Interpolators.EMPHASIZED
        return animatorSet
    }

@@ -129,6 +131,6 @@ class TaskbarPinningController(private val context: TaskbarActivityContext) :
    companion object {
        const val PINNING_PERSISTENT = 1f
        const val PINNING_TRANSIENT = 0f
        const val PINNING_ANIMATION_DURATION = 500L
        const val PINNING_ANIMATION_DURATION = 600L
    }
}
+25 −0
Original line number Diff line number Diff line
@@ -159,6 +159,8 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
    private final int mTransientIconSize;
    private final int mPersistentIconSize;

    private final float mTaskbarLeftRightMargin;

    public TaskbarViewController(TaskbarActivityContext activity, TaskbarView taskbarView) {
        mActivity = activity;
        mTransientTaskbarDp = mActivity.getTransientTaskbarDeviceProfile();
@@ -184,6 +186,9 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
            mTaskbarThemedIconsBackgroundColor = ColorUtils.HSLToColor(colorHSL);
        }
        mIsRtl = Utilities.isRtl(mTaskbarView.getResources());
        mTaskbarLeftRightMargin = mActivity.getResources().getDimensionPixelSize(
                R.dimen.transient_taskbar_padding);

    }

    public void init(TaskbarControllers controllers) {
@@ -391,6 +396,26 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
        }
    }

    /**
     * Calculates visual taskbar view width.
     */
    public float getCurrentVisualTaskbarWidth() {
        if (mTaskbarView.getIconViews().length == 0) {
            return 0;
        }

        View[] iconViews = mTaskbarView.getIconViews();

        int leftIndex = mActivity.getDeviceProfile().isQsbInline && !mIsRtl ? 1 : 0;
        int rightIndex = mActivity.getDeviceProfile().isQsbInline && mIsRtl
                ? iconViews.length - 2
                : iconViews.length - 1;

        float left = iconViews[leftIndex].getX();
        float right = iconViews[rightIndex].getRight() + iconViews[rightIndex].getTranslationX();

        return right - left + (2 * mTaskbarLeftRightMargin);
    }

    /**
     * Sets the translation of the TaskbarView during the swipe up gesture.