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

Commit 1c581c6d authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Bug fix: QSB sometimes gets stuck to transparent.

 At some places, we were calling removeAllListeners before calling cancel
 on an animation. AnimationListeners are also used to track states, and
 removing listeners before canceling will prevent onAnimationEnd to be
 called, thus preventing state cleanup.
 PinchAnimationManager was causing ZeroAlphaAnimatorListener to be removing
 from Qsb alpha animation, making the MultiStateAlphaController think there
 is a zeroAlpha animation running.

> Removing all instances of removeAllListeners
> Updating various affected listeners to handle onAnimatinoCancel
> Fixing WorkspaceStateTransitionAnimation, which was animation QSB alpha
  on page scroll index

Bug: 31910152
Change-Id: Ie7f31b67d4c502badcdd41f7b04867d1f35f5d27
parent feba90fe
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -364,7 +364,6 @@ public class FastBitmapDrawable extends Drawable {

    private AnimatorSet cancelAnimator(AnimatorSet animator) {
        if (animator != null) {
            animator.removeAllListeners();
            animator.cancel();
        }
        return null;
+10 −2
Original line number Diff line number Diff line
@@ -215,10 +215,19 @@ public class PinchAnimationManager {
            view.setVisibility(View.VISIBLE);
        } else {
            animator.addListener(new AnimatorListenerAdapter() {
                private boolean mCancelled = false;

                @Override
                public void onAnimationCancel(Animator animation) {
                    mCancelled = true;
                }

                @Override
                public void onAnimationEnd(Animator animation) {
                    if (!mCancelled) {
                        view.setVisibility(View.INVISIBLE);
                    }
                }
            });
        }
        startAnimator(index, animator, THRESHOLD_ANIM_DURATION);
@@ -226,7 +235,6 @@ public class PinchAnimationManager {

    private void startAnimator(int index, Animator animator, long duration) {
        if (mAnimators[index] != null) {
            mAnimators[index].removeAllListeners();
            mAnimators[index].cancel();
        }
        mAnimators[index] = animator;
+3 −4
Original line number Diff line number Diff line
@@ -356,7 +356,8 @@ public class WorkspaceStateTransitionAnimation {
                cl.setShortcutAndWidgetAlpha(finalAlpha);
            }

            if (Workspace.isQsbContainerPage(i)) {
            if (Workspace.isQsbContainerPage(i) &&
                    states.stateIsNormal && mWorkspaceFadeInAdjacentScreens) {
                if (animated) {
                    Animator anim = mWorkspace.mQsbAlphaController
                            .animateAlphaAtIndex(finalAlpha, Workspace.QSB_ALPHA_INDEX_PAGE_SCROLL);
@@ -372,8 +373,6 @@ public class WorkspaceStateTransitionAnimation {

        final ViewGroup overviewPanel = mLauncher.getOverviewPanel();

        final View qsbContainer = mLauncher.getQsbContainer();

        Animator qsbAlphaAnimation = mWorkspace.mQsbAlphaController
                .animateAlphaAtIndex(finalQsbAlpha, Workspace.QSB_ALPHA_INDEX_STATE_CHANGE);

@@ -395,7 +394,7 @@ public class WorkspaceStateTransitionAnimation {
            // For animation optimization, we may need to provide the Launcher transition
            // with a set of views on which to force build and manage layers in certain scenarios.
            layerViews.addView(overviewPanel);
            layerViews.addView(qsbContainer);
            layerViews.addView(mLauncher.getQsbContainer());
            layerViews.addView(mLauncher.getHotseat());
            layerViews.addView(mWorkspace.getPageIndicator());

+0 −1
Original line number Diff line number Diff line
@@ -188,7 +188,6 @@ public class AllAppsBackgroundDrawable extends Drawable {

    private ObjectAnimator cancelAnimator(ObjectAnimator animator) {
        if (animator != null) {
            animator.removeAllListeners();
            animator.cancel();
        }
        return null;
+22 −14
Original line number Diff line number Diff line
@@ -72,18 +72,6 @@ public class PageIndicatorDots extends PageIndicator {
        }
    };

    /**
     * Listener for keep running the animation until the final state is reached.
     */
    private final AnimatorListenerAdapter mAnimCycleListener = new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            mAnimator = null;
            animateToPosition(mFinalPosition);
        }
    };

    private final Paint mCirclePaint;
    private final float mDotRadius;
    private final int mActiveColor;
@@ -163,7 +151,7 @@ public class PageIndicatorDots extends PageIndicator {
            float positionForThisAnim = mCurrentPosition > mFinalPosition ?
                    mCurrentPosition - SHIFT_PER_ANIMATION : mCurrentPosition + SHIFT_PER_ANIMATION;
            mAnimator = ObjectAnimator.ofFloat(this, CURRENT_POSITION, positionForThisAnim);
            mAnimator.addListener(mAnimCycleListener);
            mAnimator.addListener(new AnimationCycleListener());
            mAnimator.setDuration(ANIMATION_DURATION);
            mAnimator.start();
        }
@@ -171,7 +159,6 @@ public class PageIndicatorDots extends PageIndicator {

    public void stopAllAnimations() {
        if (mAnimator != null) {
            mAnimator.removeAllListeners();
            mAnimator.cancel();
            mAnimator = null;
        }
@@ -326,4 +313,25 @@ public class PageIndicatorDots extends PageIndicator {
            }
        }
    }

    /**
     * Listener for keep running the animation until the final state is reached.
     */
    private class AnimationCycleListener extends AnimatorListenerAdapter {

        private boolean mCancelled = false;

        @Override
        public void onAnimationCancel(Animator animation) {
            mCancelled = true;
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            if (!mCancelled) {
                mAnimator = null;
                animateToPosition(mFinalPosition);
            }
        }
    }
}