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

Commit 4ab6254b authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Adding some state for fallback recents View" into ub-launcher3-qt-dev

parents 8d19146b 9d8b1376
Loading
Loading
Loading
Loading
+24 −6
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ package com.android.quickstep;

import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.quickstep.SysUINavigationMode.Mode.NO_BUTTON;
import static com.android.quickstep.fallback.FallbackRecentsView.ZOOM_PROGRESS;
import static com.android.quickstep.views.RecentsView.CONTENT_ALPHA;

import android.animation.Animator;
@@ -33,6 +34,7 @@ import com.android.launcher3.DeviceProfile;
import com.android.launcher3.anim.AnimationSuccessListener;
import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.userevent.nano.LauncherLogProto;
import com.android.quickstep.fallback.FallbackRecentsView;
import com.android.quickstep.util.LayoutUtils;
import com.android.quickstep.util.RemoteAnimationTargetSet;
import com.android.quickstep.views.RecentsView;
@@ -120,11 +122,14 @@ public final class FallbackActivityControllerHelper implements
            return (transitionLength) -> { };
        }

        RecentsView rv = activity.getOverviewPanel();
        FallbackRecentsView rv = activity.getOverviewPanel();
        rv.setContentAlpha(0);
        rv.getClearAllButton().setVisibilityAlpha(0);
        rv.setDisallowScrollToClearAll(true);

        boolean fromState = !animateActivity;
        rv.setInOverviewState(fromState);

        return new AnimationFactory() {

            boolean isAnimatingToRecents = false;
@@ -141,15 +146,28 @@ public final class FallbackActivityControllerHelper implements

            @Override
            public void createActivityController(long transitionLength) {
                if (!isAnimatingToRecents) {
                    return;
                AnimatorSet animatorSet = new AnimatorSet();
                if (isAnimatingToRecents) {
                    ObjectAnimator anim = ObjectAnimator.ofFloat(rv, CONTENT_ALPHA, 0, 1);
                    anim.setDuration(transitionLength).setInterpolator(LINEAR);
                    animatorSet.play(anim);
                }

                ObjectAnimator anim = ObjectAnimator.ofFloat(rv, CONTENT_ALPHA, 0, 1);
                ObjectAnimator anim = ObjectAnimator.ofFloat(rv, ZOOM_PROGRESS, 1, 0);
                anim.setDuration(transitionLength).setInterpolator(LINEAR);
                AnimatorSet animatorSet = new AnimatorSet();
                animatorSet.play(anim);
                callback.accept(AnimatorPlaybackController.wrap(animatorSet, transitionLength));

                AnimatorPlaybackController controller =
                        AnimatorPlaybackController.wrap(animatorSet, transitionLength);

                // Since we are changing the start position of the UI, reapply the state, at the end
                controller.setEndAction(() -> {
                    boolean endState = true;
                    rv.setInOverviewState(controller.getInterpolatedProgress() > 0.5 ?
                                    endState : fromState);
                });

                callback.accept(controller);
            }
        };
    }
+8 −1
Original line number Diff line number Diff line
@@ -125,7 +125,14 @@ public final class RecentsActivity extends BaseRecentsActivity {
            @Override
            public void onCreateAnimation(RemoteAnimationTargetCompat[] targetCompats,
                    AnimationResult result) {
                result.setAnimation(composeRecentsLaunchAnimator(taskView, targetCompats));
                AnimatorSet anim = composeRecentsLaunchAnimator(taskView, targetCompats);
                anim.addListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        mFallbackRecentsView.resetViewUI();
                    }
                });
                result.setAnimation(anim);
            }
        };
        return ActivityOptionsCompat.makeRemoteAnimation(new RemoteAnimationAdapterCompat(
+68 −0
Original line number Diff line number Diff line
@@ -15,19 +15,45 @@
 */
package com.android.quickstep.fallback;

import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.util.FloatProperty;
import android.view.View;

import com.android.launcher3.DeviceProfile;
import com.android.launcher3.LauncherState.ScaleAndTranslation;
import com.android.launcher3.Utilities;
import com.android.quickstep.RecentsActivity;
import com.android.quickstep.util.LayoutUtils;
import com.android.quickstep.views.RecentsView;
import com.android.quickstep.views.TaskView;

public class FallbackRecentsView extends RecentsView<RecentsActivity> {

    public static final FloatProperty<FallbackRecentsView> ZOOM_PROGRESS =
            new FloatProperty<FallbackRecentsView> ("zoomInProgress") {

                @Override
                public void setValue(FallbackRecentsView view, float value) {
                    view.setZoomProgress(value);
                }

                @Override
                public Float get(FallbackRecentsView view) {
                    return view.mZoomInProgress;
                }
            };

    private float mZoomInProgress = 0;
    private boolean mInOverviewState = true;

    private float mZoomScale = 1f;
    private float mZoomTranslationY = 0f;

    public FallbackRecentsView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }
@@ -71,4 +97,46 @@ public class FallbackRecentsView extends RecentsView<RecentsActivity> {
        // Just use the activity task size for multi-window as well.
        return false;
    }

    public void resetViewUI() {
        setZoomProgress(0);
        resetTaskVisuals();
    }

    public void setInOverviewState(boolean inOverviewState) {
        if (mInOverviewState != inOverviewState) {
            mInOverviewState = inOverviewState;
            if (mInOverviewState) {
                resetTaskVisuals();
            } else {
                setZoomProgress(1);
            }
        }
    }

    @Override
    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
        super.onLayout(changed, left, top, right, bottom);

        if (getTaskViewCount() == 0) {
            mZoomScale = 1f;
            mZoomTranslationY = 0f;
        } else {
            TaskView dummyTask = getTaskViewAt(0);
            ScaleAndTranslation sat = getTempClipAnimationHelper()
                    .updateForFullscreenOverview(dummyTask)
                    .getScaleAndTranslation();
            mZoomScale = sat.scale;
            mZoomTranslationY = sat.translationY;
        }

        setZoomProgress(mZoomInProgress);
    }

    public void setZoomProgress(float progress) {
        mZoomInProgress = progress;
        SCALE_PROPERTY.set(this, Utilities.mapRange(mZoomInProgress, 1, mZoomScale));
        TRANSLATION_Y.set(this, Utilities.mapRange(mZoomInProgress, 0, mZoomTranslationY));
        FULLSCREEN_PROGRESS.set(this, mZoomInProgress);
    }
}