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

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

Merge "Add Z scaling during unfold to launcher"

parents b70131e1 12131a40
Loading
Loading
Loading
Loading
+31 −0
Original line number Original line Diff line number Diff line
@@ -15,9 +15,14 @@
 */
 */
package com.android.quickstep.util;
package com.android.quickstep.util;


import static com.android.launcher3.LauncherAnimUtils.SCALE_INDEX_UNFOLD_ANIMATION;
import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY_FACTORY;
import static com.android.launcher3.Utilities.comp;
import static com.android.launcher3.Utilities.comp;


import android.annotation.Nullable;
import android.annotation.Nullable;
import android.util.FloatProperty;
import android.util.MathUtils;
import android.view.View;
import android.view.WindowManager;
import android.view.WindowManager;
import android.view.WindowManagerGlobal;
import android.view.WindowManagerGlobal;


@@ -39,6 +44,8 @@ public class LauncherUnfoldAnimationController {
    // Percentage of the width of the quick search bar that will be reduced
    // Percentage of the width of the quick search bar that will be reduced
    // from the both sides of the bar when progress is 0
    // from the both sides of the bar when progress is 0
    private static final float MAX_WIDTH_INSET_FRACTION = 0.15f;
    private static final float MAX_WIDTH_INSET_FRACTION = 0.15f;
    private static final FloatProperty<View> UNFOLD_SCALE_PROPERTY =
            SCALE_PROPERTY_FACTORY.get(SCALE_INDEX_UNFOLD_ANIMATION);


    private final Launcher mLauncher;
    private final Launcher mLauncher;


@@ -62,6 +69,8 @@ public class LauncherUnfoldAnimationController {
        // Animated in all orientations
        // Animated in all orientations
        mProgressProvider.addCallback(new UnfoldMoveFromCenterWorkspaceAnimator(launcher,
        mProgressProvider.addCallback(new UnfoldMoveFromCenterWorkspaceAnimator(launcher,
                windowManager));
                windowManager));
        mProgressProvider
                .addCallback(new LauncherScaleAnimationListener());


        // Animated only in natural orientation
        // Animated only in natural orientation
        mNaturalOrientationProgressProvider
        mNaturalOrientationProgressProvider
@@ -120,4 +129,26 @@ public class LauncherUnfoldAnimationController {
            }
            }
        }
        }
    }
    }

    private class LauncherScaleAnimationListener implements TransitionProgressListener {

        @Override
        public void onTransitionStarted() {
        }

        @Override
        public void onTransitionFinished() {
            setScale(1);
        }

        @Override
        public void onTransitionProgress(float progress) {
            setScale(MathUtils.constrainedMap(0.85f, 1, 0, 1, progress));
        }

        private void setScale(float value) {
            UNFOLD_SCALE_PROPERTY.setValue(mLauncher.getWorkspace(), value);
            UNFOLD_SCALE_PROPERTY.setValue(mLauncher.getHotseat(), value);
        }
    }
}
}
+7 −3
Original line number Original line Diff line number Diff line
@@ -15,7 +15,8 @@
 */
 */
package com.android.quickstep.util;
package com.android.quickstep.util;


import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY;
import static com.android.launcher3.LauncherAnimUtils.SCALE_INDEX_REVEAL_ANIM;
import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY_FACTORY;
import static com.android.launcher3.LauncherState.BACKGROUND_APP;
import static com.android.launcher3.LauncherState.BACKGROUND_APP;
import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.anim.PropertySetter.NO_ANIM_PROPERTY_SETTER;
import static com.android.launcher3.anim.PropertySetter.NO_ANIM_PROPERTY_SETTER;
@@ -27,6 +28,7 @@ import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.ObjectAnimator;
import android.util.FloatProperty;
import android.view.View;
import android.view.View;


import com.android.launcher3.BaseQuickstepLauncher;
import com.android.launcher3.BaseQuickstepLauncher;
@@ -49,6 +51,8 @@ public class WorkspaceRevealAnim {


    // Should be used for animations running alongside this WorkspaceRevealAnim.
    // Should be used for animations running alongside this WorkspaceRevealAnim.
    public static final int DURATION_MS = 350;
    public static final int DURATION_MS = 350;
    private static final FloatProperty<View> REVEAL_SCALE_PROPERTY =
            SCALE_PROPERTY_FACTORY.get(SCALE_INDEX_REVEAL_ANIM);


    private final float mScaleStart;
    private final float mScaleStart;
    private final AnimatorSet mAnimators = new AnimatorSet();
    private final AnimatorSet mAnimators = new AnimatorSet();
@@ -90,7 +94,7 @@ public class WorkspaceRevealAnim {
    }
    }


    private void addRevealAnimatorsForView(View v) {
    private void addRevealAnimatorsForView(View v) {
        ObjectAnimator scale = ObjectAnimator.ofFloat(v, SCALE_PROPERTY, mScaleStart, 1f);
        ObjectAnimator scale = ObjectAnimator.ofFloat(v, REVEAL_SCALE_PROPERTY, mScaleStart, 1f);
        scale.setDuration(DURATION_MS);
        scale.setDuration(DURATION_MS);
        scale.setInterpolator(Interpolators.DECELERATED_EASE);
        scale.setInterpolator(Interpolators.DECELERATED_EASE);
        mAnimators.play(scale);
        mAnimators.play(scale);
@@ -103,7 +107,7 @@ public class WorkspaceRevealAnim {
        mAnimators.addListener(new AnimatorListenerAdapter() {
        mAnimators.addListener(new AnimatorListenerAdapter() {
            @Override
            @Override
            public void onAnimationEnd(Animator animation) {
            public void onAnimationEnd(Animator animation) {
                SCALE_PROPERTY.set(v, 1f);
                REVEAL_SCALE_PROPERTY.set(v, 1f);
                v.setAlpha(1f);
                v.setAlpha(1f);
            }
            }
        });
        });
+1 −0
Original line number Original line Diff line number Diff line
@@ -21,6 +21,7 @@ import com.android.launcher3.Utilities;
/**
/**
 * Animation to animate in a workspace during the unlock transition.
 * Animation to animate in a workspace during the unlock transition.
 */
 */
// TODO(b/219444608): use SCALE_PROPERTY_FACTORY once the scale is reset to 1.0 after unlocking.
public class WorkspaceUnlockAnim {
public class WorkspaceUnlockAnim {
    /** Scale for the workspace icons at the beginning of the animation. */
    /** Scale for the workspace icons at the beginning of the animation. */
    private static final float START_SCALE = 0.9f;
    private static final float START_SCALE = 0.9f;
+21 −0
Original line number Original line Diff line number Diff line
@@ -27,6 +27,8 @@ import android.util.IntProperty;
import android.view.View;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.view.ViewGroup.LayoutParams;


import com.android.launcher3.util.MultiScalePropertyFactory;

public class LauncherAnimUtils {
public class LauncherAnimUtils {
    /**
    /**
     * Durations for various state animations. These are not defined in resources to allow
     * Durations for various state animations. These are not defined in resources to allow
@@ -64,6 +66,25 @@ public class LauncherAnimUtils {
                }
                }
            };
            };


    /**
     * Property to set the scale of workspace and hotseat. The value is based on a combination
     * of all the ones set, to have a smooth experience even in the case of overlapping scaling
     * animation.
     */
    public static final MultiScalePropertyFactory<View> SCALE_PROPERTY_FACTORY =
            new MultiScalePropertyFactory<View>("scale_property") {
                @Override
                protected void apply(View view, float scale) {
                    view.setScaleX(scale);
                    view.setScaleY(scale);
                }
            };

    public static final int SCALE_INDEX_UNFOLD_ANIMATION = 1;
    public static final int SCALE_INDEX_UNLOCK_ANIMATION = 2;
    public static final int SCALE_INDEX_WORKSPACE_STATE = 3;
    public static final int SCALE_INDEX_REVEAL_ANIM = 4;

    /** Increase the duration if we prevented the fling, as we are going against a high velocity. */
    /** Increase the duration if we prevented the fling, as we are going against a high velocity. */
    public static int blockedFlingDurationFactor(float velocity) {
    public static int blockedFlingDurationFactor(float velocity) {
        return (int) Utilities.boundToRange(Math.abs(velocity) / 2, 2f, 6f);
        return (int) Utilities.boundToRange(Math.abs(velocity) / 2, 2f, 6f);
+11 −5
Original line number Original line Diff line number Diff line
@@ -18,7 +18,8 @@ package com.android.launcher3;


import static androidx.dynamicanimation.animation.DynamicAnimation.MIN_VISIBLE_CHANGE_SCALE;
import static androidx.dynamicanimation.animation.DynamicAnimation.MIN_VISIBLE_CHANGE_SCALE;


import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY;
import static com.android.launcher3.LauncherAnimUtils.SCALE_INDEX_WORKSPACE_STATE;
import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY_FACTORY;
import static com.android.launcher3.LauncherAnimUtils.VIEW_ALPHA;
import static com.android.launcher3.LauncherAnimUtils.VIEW_ALPHA;
import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_X;
import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_X;
import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_Y;
import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_Y;
@@ -42,6 +43,7 @@ import static com.android.launcher3.states.StateAnimationConfig.ANIM_WORKSPACE_T
import static com.android.launcher3.states.StateAnimationConfig.SKIP_SCRIM;
import static com.android.launcher3.states.StateAnimationConfig.SKIP_SCRIM;


import android.animation.ValueAnimator;
import android.animation.ValueAnimator;
import android.util.FloatProperty;
import android.view.View;
import android.view.View;
import android.view.animation.Interpolator;
import android.view.animation.Interpolator;


@@ -62,6 +64,9 @@ import com.android.systemui.plugins.ResourceProvider;
 */
 */
public class WorkspaceStateTransitionAnimation {
public class WorkspaceStateTransitionAnimation {


    private static final FloatProperty<View> WORKSPACE_STATE_SCALE_PROPERTY =
            SCALE_PROPERTY_FACTORY.get(SCALE_INDEX_WORKSPACE_STATE);

    private final Launcher mLauncher;
    private final Launcher mLauncher;
    private final Workspace mWorkspace;
    private final Workspace mWorkspace;


@@ -117,7 +122,8 @@ public class WorkspaceStateTransitionAnimation {
            ((PendingAnimation) propertySetter).add(getSpringScaleAnimator(mLauncher,
            ((PendingAnimation) propertySetter).add(getSpringScaleAnimator(mLauncher,
                    mWorkspace, mNewScale));
                    mWorkspace, mNewScale));
        } else {
        } else {
            propertySetter.setFloat(mWorkspace, SCALE_PROPERTY, mNewScale, scaleInterpolator);
            propertySetter.setFloat(mWorkspace, WORKSPACE_STATE_SCALE_PROPERTY, mNewScale,
                    scaleInterpolator);
        }
        }


        mWorkspace.setPivotToScaleWithSelf(hotseat);
        mWorkspace.setPivotToScaleWithSelf(hotseat);
@@ -128,7 +134,7 @@ public class WorkspaceStateTransitionAnimation {
        } else {
        } else {
            Interpolator hotseatScaleInterpolator = config.getInterpolator(ANIM_HOTSEAT_SCALE,
            Interpolator hotseatScaleInterpolator = config.getInterpolator(ANIM_HOTSEAT_SCALE,
                    scaleInterpolator);
                    scaleInterpolator);
            propertySetter.setFloat(hotseat, SCALE_PROPERTY, hotseatScale,
            propertySetter.setFloat(hotseat, WORKSPACE_STATE_SCALE_PROPERTY, hotseatScale,
                    hotseatScaleInterpolator);
                    hotseatScaleInterpolator);
        }
        }


@@ -205,9 +211,9 @@ public class WorkspaceStateTransitionAnimation {
                .setDampingRatio(damping)
                .setDampingRatio(damping)
                .setMinimumVisibleChange(MIN_VISIBLE_CHANGE_SCALE)
                .setMinimumVisibleChange(MIN_VISIBLE_CHANGE_SCALE)
                .setEndValue(scale)
                .setEndValue(scale)
                .setStartValue(SCALE_PROPERTY.get(v))
                .setStartValue(WORKSPACE_STATE_SCALE_PROPERTY.get(v))
                .setStartVelocity(velocityPxPerS)
                .setStartVelocity(velocityPxPerS)
                .build(v, SCALE_PROPERTY);
                .build(v, WORKSPACE_STATE_SCALE_PROPERTY);


    }
    }
}
}
 No newline at end of file
Loading