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

Commit 6ec11da6 authored by David Lin's avatar David Lin Committed by Android (Google) Code Review
Browse files

Merge "Fix flickering issues with divider during split animation" into 24D1-dev

parents c44c004e fe9a7f3f
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -27,6 +27,8 @@ public class PhoneSplitToConfirmTimings
    public int getPlaceholderIconFadeInEnd() { return 133; }
    public int getStagedRectSlideStart() { return 0; }
    public int getStagedRectSlideEnd() { return 333; }
    public int getBackingScrimFadeInStart() { return 0; }
    public int getBackingScrimFadeInEnd() { return 266; }

    public int getDuration() { return PHONE_CONFIRM_DURATION; }
}
+27 −34
Original line number Diff line number Diff line
@@ -275,48 +275,41 @@ class SplitAnimationController(val splitSelectStateController: SplitSelectStateC
    }

    /**
     * Creates and returns a view to fade in at .4 animation progress and adds it to the provided
     * [pendingAnimation]. Assumes that animation will be the final split placeholder launch anim.
     *
     * [secondPlaceholderEndingBounds] refers to the second placeholder view that gets added on
     * screen, not the logical second app.
     * For landscape it's the left app and for portrait the top one.
     * Creates and returns a fullscreen scrim to fade in behind the split confirm animation, and
     * adds it to the provided [pendingAnimation].
     */
    fun addDividerPlaceholderViewToAnim(pendingAnimation: PendingAnimation,
    fun addScrimBehindAnim(
        pendingAnimation: PendingAnimation,
        launcher: StatefulActivity<*>,
                                        secondPlaceholderEndingBounds: Rect,
                                        context: Context) : View {
        val mSplitDividerPlaceholderView = View(context)
        context: Context
    ): View {
        val scrim = View(context)
        val recentsView = launcher.getOverviewPanel<RecentsView<*, *>>()
        val dp : com.android.launcher3.DeviceProfile = launcher.getDeviceProfile()
        // Add it before/under the most recently added first floating taskView
        val firstAddedSplitViewIndex: Int = launcher.getDragLayer().indexOfChild(
                recentsView.splitSelectController.firstFloatingTaskView)
        launcher.getDragLayer().addView(mSplitDividerPlaceholderView, firstAddedSplitViewIndex)
        val lp = mSplitDividerPlaceholderView.layoutParams as InsettableFrameLayout.LayoutParams
        launcher.getDragLayer().addView(scrim, firstAddedSplitViewIndex)
        // Make the scrim fullscreen
        val lp = scrim.layoutParams as InsettableFrameLayout.LayoutParams
        lp.topMargin = 0
        lp.height = dp.heightPx
        lp.width = dp.widthPx

        scrim.alpha = 0f
        scrim.setBackgroundColor(launcher.resources.getColor(R.color.taskbar_background_dark))
        val timings = AnimUtils.getDeviceSplitToConfirmTimings(dp.isTablet) as SplitToConfirmTimings
        pendingAnimation.setViewAlpha(
            scrim,
            1f,
            Interpolators.clampToProgress(
                timings.backingScrimFadeInterpolator,
                timings.backingScrimFadeInStartOffset,
                timings.backingScrimFadeInEndOffset
            )
        )

        if (dp.isLeftRightSplit) {
            lp.height = secondPlaceholderEndingBounds.height()
            lp.width = launcher.resources
                    .getDimensionPixelSize(R.dimen.split_divider_handle_region_height)
            mSplitDividerPlaceholderView.translationX = secondPlaceholderEndingBounds.right - lp.width / 2f
            mSplitDividerPlaceholderView.translationY = 0f
        } else {
            lp.height = launcher.resources
                    .getDimensionPixelSize(R.dimen.split_divider_handle_region_height)
            lp.width = secondPlaceholderEndingBounds.width()
            mSplitDividerPlaceholderView.translationY = secondPlaceholderEndingBounds.top - lp.height / 2f
            mSplitDividerPlaceholderView.translationX = 0f
        }

        mSplitDividerPlaceholderView.alpha = 0f
        mSplitDividerPlaceholderView.setBackgroundColor(launcher.resources
                .getColor(R.color.taskbar_background_dark))
        val timings = AnimUtils.getDeviceSplitToConfirmTimings(dp.isTablet)
        pendingAnimation.setViewAlpha(mSplitDividerPlaceholderView, 1f,
                Interpolators.clampToProgress(timings.stagedRectScaleXInterpolator, 0.4f, 1f))
        return mSplitDividerPlaceholderView
        return scrim
    }

    /** Does not play any animation if user is not currently in split selection state. */
+10 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.quickstep.util;

import static com.android.app.animation.Interpolators.EMPHASIZED;
import static com.android.app.animation.Interpolators.LINEAR;

import android.view.animation.Interpolator;

@@ -31,6 +32,8 @@ abstract class SplitToConfirmTimings implements SplitAnimationTimings {
    abstract public int getPlaceholderIconFadeInEnd();
    abstract public int getStagedRectSlideStart();
    abstract public int getStagedRectSlideEnd();
    abstract public int getBackingScrimFadeInStart();
    abstract public int getBackingScrimFadeInEnd();

    // Common timings
    public int getInstructionsFadeStart() { return 0; }
@@ -39,6 +42,7 @@ abstract class SplitToConfirmTimings implements SplitAnimationTimings {
    public Interpolator getStagedRectYInterpolator() { return EMPHASIZED; }
    public Interpolator getStagedRectScaleXInterpolator() { return EMPHASIZED; }
    public Interpolator getStagedRectScaleYInterpolator() { return EMPHASIZED; }
    public Interpolator getBackingScrimFadeInterpolator() { return LINEAR; }

    abstract public int getDuration();

@@ -48,4 +52,10 @@ abstract class SplitToConfirmTimings implements SplitAnimationTimings {
    public float getInstructionsFadeEndOffset() {
        return (float) getInstructionsFadeEnd() / getDuration();
    }
    public float getBackingScrimFadeInStartOffset() {
        return (float) getBackingScrimFadeInStart() / getDuration();
    }
    public float getBackingScrimFadeInEndOffset() {
        return (float) getBackingScrimFadeInEnd() / getDuration();
    }
}
+3 −4
Original line number Diff line number Diff line
@@ -163,9 +163,8 @@ public class SplitToWorkspaceController {
                new RectF(firstTaskStartingBounds), firstTaskEndingBounds,
                false /* fadeWithThumbnail */, true /* isStagedTask */);

        View mSplitDividerPlaceholderView = recentsView.getSplitSelectController()
                .getSplitAnimationController().addDividerPlaceholderViewToAnim(pendingAnimation,
                        mLauncher, secondTaskEndingBounds, view.getContext());
        View backingScrim = recentsView.getSplitSelectController().getSplitAnimationController()
                .addScrimBehindAnim(pendingAnimation, mLauncher, view.getContext());

        FloatingTaskView secondFloatingTaskView = FloatingTaskView.getFloatingTaskView(mLauncher,
                view, bitmap, icon, secondTaskStartingBounds);
@@ -197,7 +196,7 @@ public class SplitToWorkspaceController {
            private void cleanUp() {
                mLauncher.getDragLayer().removeView(firstFloatingTaskView);
                mLauncher.getDragLayer().removeView(secondFloatingTaskView);
                mLauncher.getDragLayer().removeView(mSplitDividerPlaceholderView);
                mLauncher.getDragLayer().removeView(backingScrim);
                mController.getSplitAnimationController().removeSplitInstructionsView(mLauncher);
                mController.resetState();
            }
+2 −0
Original line number Diff line number Diff line
@@ -27,6 +27,8 @@ public class TabletSplitToConfirmTimings
    public int getPlaceholderIconFadeInEnd() { return 250; }
    public int getStagedRectSlideStart() { return 0; }
    public int getStagedRectSlideEnd() { return 500; }
    public int getBackingScrimFadeInStart() { return 0; }
    public int getBackingScrimFadeInEnd() { return 400; }

    public int getDuration() { return TABLET_CONFIRM_DURATION; }
}
Loading