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

Commit 92d4086f authored by Jonathan Miranda's avatar Jonathan Miranda Committed by Android (Google) Code Review
Browse files

Merge "Fix bug where icon remains invisible after returning home." into ub-launcher3-master

parents 5e1ecf6d ad7e30f5
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -395,8 +395,8 @@ public class NoButtonQuickSwitchTouchController implements TouchController,
            updateNonOverviewAnim(targetState, new AnimatorSetBuilder(), 0 /* animComponents */);
            nonOverviewAnim = mNonOverviewAnim.getAnimationPlayer();

            new StaggeredWorkspaceAnim(mLauncher, null, velocity.y,
                    false /* animateOverviewScrim */).start();
            new StaggeredWorkspaceAnim(mLauncher, velocity.y, false /* animateOverviewScrim */)
                    .start();
        } else {
            boolean canceled = targetState == NORMAL;
            if (canceled) {
+2 −2
Original line number Diff line number Diff line
@@ -191,8 +191,8 @@ public final class LauncherActivityInterface implements BaseActivityInterface<La

            @Override
            public void playAtomicAnimation(float velocity) {
                new StaggeredWorkspaceAnim(launcher, workspaceView, velocity,
                        true /* animateOverviewScrim */).start();
                new StaggeredWorkspaceAnim(launcher, velocity, true /* animateOverviewScrim */)
                        .start();
            }
        };
    }
+2 −36
Original line number Diff line number Diff line
@@ -28,8 +28,6 @@ import android.animation.ObjectAnimator;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.Nullable;

import com.android.launcher3.CellLayout;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Launcher;
@@ -43,7 +41,6 @@ import com.android.launcher3.anim.AnimatorSetBuilder;
import com.android.launcher3.anim.PropertySetter;
import com.android.launcher3.anim.SpringAnimationBuilder;
import com.android.launcher3.graphics.OverviewScrim;
import com.android.launcher3.views.IconLabelDotView;
import com.android.quickstep.views.RecentsView;

/**
@@ -64,20 +61,12 @@ public class StaggeredWorkspaceAnim {
    private final float mVelocity;
    private final float mSpringTransY;

    // The original view of the {@link FloatingIconView}.
    private final View mOriginalView;

    private final AnimatorSet mAnimators = new AnimatorSet();

    /**
     * @param floatingViewOriginalView The FloatingIconView's original view.
     */
    public StaggeredWorkspaceAnim(Launcher launcher, @Nullable View floatingViewOriginalView,
            float velocity, boolean animateOverviewScrim) {
    public StaggeredWorkspaceAnim(Launcher launcher, float velocity, boolean animateOverviewScrim) {
        prepareToAnimate(launcher);

        mVelocity = velocity;
        mOriginalView = floatingViewOriginalView;

        // Scale the translationY based on the initial velocity to better sync the workspace items
        // with the floating view.
@@ -198,35 +187,12 @@ public class StaggeredWorkspaceAnim {
        springTransY.setStartDelay(startDelay);
        mAnimators.play(springTransY);

        ObjectAnimator alpha = getAlphaAnimator(v, startDelay);
        if (v == mOriginalView) {
            // For IconLabelDotViews, we just want the label to fade in.
            // Icon, badge, and dots will animate in separately (controlled via FloatingIconView)
            if (v instanceof IconLabelDotView) {
                alpha.addListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationStart(Animator animation) {
                        IconLabelDotView view = (IconLabelDotView) v;
                        view.setIconVisible(false);
                        view.setForceHideDot(true);
                    }
                });
            } else {
                return;
            }
        }

        v.setAlpha(0);
        mAnimators.play(alpha);
    }

    private ObjectAnimator getAlphaAnimator(View v, long startDelay) {
        ObjectAnimator alpha = ObjectAnimator.ofFloat(v, View.ALPHA, 0f, 1f);
        alpha.setInterpolator(LINEAR);
        alpha.setDuration(ALPHA_DURATION_MS);
        alpha.setStartDelay(startDelay);
        return alpha;

        mAnimators.play(alpha);
    }

    private void addScrimAnimationForState(Launcher launcher, LauncherState state, long duration) {
+15 −12
Original line number Diff line number Diff line
@@ -560,7 +560,7 @@ public class FloatingIconView extends View implements
     * Checks if the icon result is loaded. If true, we set the icon immediately. Else, we add a
     * callback to set the icon once the icon result is loaded.
     */
    private void checkIconResult(View originalView, boolean isOpening) {
    private void checkIconResult(View originalView) {
        CancellationSignal cancellationSignal = new CancellationSignal();

        if (mIconLoadResult == null) {
@@ -572,9 +572,7 @@ public class FloatingIconView extends View implements
            if (mIconLoadResult.isIconLoaded) {
                setIcon(originalView, mIconLoadResult.drawable, mIconLoadResult.badge,
                        mIconLoadResult.iconOffset);
                if (isOpening) {
                hideOriginalView(originalView);
                }
            } else {
                mIconLoadResult.onIconLoaded = () -> {
                    if (cancellationSignal.isCanceled()) {
@@ -585,10 +583,7 @@ public class FloatingIconView extends View implements
                            mIconLoadResult.iconOffset);

                    setVisibility(VISIBLE);
                    if (isOpening) {
                        // Delay swapping views until the icon is loaded to prevent a flash.
                    hideOriginalView(originalView);
                    }
                };
                mLoadIconSignal = cancellationSignal;
            }
@@ -596,9 +591,9 @@ public class FloatingIconView extends View implements
    }

    private void hideOriginalView(View originalView) {
        if (originalView instanceof BubbleTextView) {
            ((BubbleTextView) originalView).setIconVisible(false);
            ((BubbleTextView) originalView).setForceHideDot(true);
        if (originalView instanceof IconLabelDotView) {
            ((IconLabelDotView) originalView).setIconVisible(false);
            ((IconLabelDotView) originalView).setForceHideDot(true);
        } else {
            originalView.setVisibility(INVISIBLE);
        }
@@ -674,6 +669,9 @@ public class FloatingIconView extends View implements
    }

    public void fastFinish() {
        if (mLoadIconSignal != null) {
            mLoadIconSignal.cancel();
        }
        if (mEndRunnable != null) {
            mEndRunnable.run();
            mEndRunnable = null;
@@ -689,6 +687,10 @@ public class FloatingIconView extends View implements
        if (mIconLoadResult != null && mIconLoadResult.isIconLoaded) {
            setVisibility(View.VISIBLE);
        }
        if (!mIsOpening) {
            // When closing an app, we want the item on the workspace to be invisible immediately
            hideOriginalView(mOriginalIcon);
        }
    }

    @Override
@@ -798,7 +800,7 @@ public class FloatingIconView extends View implements
        // Must be called after the fastFinish listener and end runnable is created so that
        // the icon is not left in a hidden state.
        if (shouldLoadIcon) {
            view.checkIconResult(originalView, isOpening);
            view.checkIconResult(originalView);
        }

        return view;
@@ -842,6 +844,7 @@ public class FloatingIconView extends View implements
                @Override
                public void onAnimationStart(Animator animation) {
                    btv.setIconVisible(true);
                    btv.setForceHideDot(true);
                }
            });
            fade.play(ObjectAnimator.ofInt(btv.getIcon(), DRAWABLE_ALPHA, 0, 255));