diff options
author | Nicolo' Mazzucato <nicomazz@google.com> | 2022-02-07 20:36:35 +0100 |
---|---|---|
committer | Nicolo' Mazzucato <nicomazz@google.com> | 2022-02-15 17:02:36 +0100 |
commit | 12131a40fef26c56e2443d532cfefdd85d35e142 (patch) | |
tree | b71d987218133b8ec710a962980784c46d3e361d /quickstep | |
parent | bf96683e46a2c5c09ed6b84115f71881dd4c67ff (diff) | |
download | Launcher3-12131a40fef26c56e2443d532cfefdd85d35e142.tar.gz |
Add Z scaling during unfold to launcher
The unfold progresses are mapped to 0.85 - 1 range and set as a scale for launcher.
In case of multiple scale animations for workspace and hotseat, they are combined using MultiScaleProperty (e.g. opening an app while unfolding/going to all apps while unfolding). Note that this is a pretty difficult scenario to be in. If that happens, we multiply all values and bound the result between the max and min values.
Bug: 217368525
Test: atest MultiScalePropertyTest and manually
Change-Id: I6131c39f36deade0b7280c72edda2d72045344e9
Diffstat (limited to 'quickstep')
3 files changed, 39 insertions, 3 deletions
diff --git a/quickstep/src/com/android/quickstep/util/LauncherUnfoldAnimationController.java b/quickstep/src/com/android/quickstep/util/LauncherUnfoldAnimationController.java index 6b6bd6a8b3..333df10dde 100644 --- a/quickstep/src/com/android/quickstep/util/LauncherUnfoldAnimationController.java +++ b/quickstep/src/com/android/quickstep/util/LauncherUnfoldAnimationController.java @@ -15,9 +15,14 @@ */ 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 android.annotation.Nullable; +import android.util.FloatProperty; +import android.util.MathUtils; +import android.view.View; import android.view.WindowManager; import android.view.WindowManagerGlobal; @@ -39,6 +44,8 @@ public class LauncherUnfoldAnimationController { // Percentage of the width of the quick search bar that will be reduced // from the both sides of the bar when progress is 0 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; @@ -62,6 +69,8 @@ public class LauncherUnfoldAnimationController { // Animated in all orientations mProgressProvider.addCallback(new UnfoldMoveFromCenterWorkspaceAnimator(launcher, windowManager)); + mProgressProvider + .addCallback(new LauncherScaleAnimationListener()); // Animated only in natural orientation 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); + } + } } diff --git a/quickstep/src/com/android/quickstep/util/WorkspaceRevealAnim.java b/quickstep/src/com/android/quickstep/util/WorkspaceRevealAnim.java index 7ae6cb7661..8659b687c3 100644 --- a/quickstep/src/com/android/quickstep/util/WorkspaceRevealAnim.java +++ b/quickstep/src/com/android/quickstep/util/WorkspaceRevealAnim.java @@ -15,7 +15,8 @@ */ 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.NORMAL; 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.AnimatorSet; import android.animation.ObjectAnimator; +import android.util.FloatProperty; import android.view.View; import com.android.launcher3.BaseQuickstepLauncher; @@ -49,6 +51,8 @@ public class WorkspaceRevealAnim { // Should be used for animations running alongside this WorkspaceRevealAnim. 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 AnimatorSet mAnimators = new AnimatorSet(); @@ -90,7 +94,7 @@ public class WorkspaceRevealAnim { } 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.setInterpolator(Interpolators.DECELERATED_EASE); mAnimators.play(scale); @@ -103,7 +107,7 @@ public class WorkspaceRevealAnim { mAnimators.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { - SCALE_PROPERTY.set(v, 1f); + REVEAL_SCALE_PROPERTY.set(v, 1f); v.setAlpha(1f); } }); diff --git a/quickstep/src/com/android/quickstep/util/WorkspaceUnlockAnim.java b/quickstep/src/com/android/quickstep/util/WorkspaceUnlockAnim.java index b01447ed27..aa3f0d7860 100644 --- a/quickstep/src/com/android/quickstep/util/WorkspaceUnlockAnim.java +++ b/quickstep/src/com/android/quickstep/util/WorkspaceUnlockAnim.java @@ -21,6 +21,7 @@ import com.android.launcher3.Utilities; /** * 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 { /** Scale for the workspace icons at the beginning of the animation. */ private static final float START_SCALE = 0.9f; |