Merge "Updating bounce animation to move hotseat instead of all-apps" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
380afd86ab
@@ -20,16 +20,17 @@ import static com.android.launcher3.LauncherState.NORMAL;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorInflater;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.os.Handler;
|
||||
import android.os.UserManager;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
|
||||
import com.android.launcher3.AbstractFloatingView;
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.LauncherState;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.anim.AnimatorListeners;
|
||||
import com.android.launcher3.statemanager.StateManager.StateListener;
|
||||
import com.android.launcher3.util.OnboardingPrefs;
|
||||
|
||||
@@ -53,21 +54,15 @@ public class DiscoveryBounce extends AbstractFloatingView {
|
||||
public void onStateTransitionComplete(LauncherState finalState) {}
|
||||
};
|
||||
|
||||
public DiscoveryBounce(Launcher launcher, float delta) {
|
||||
public DiscoveryBounce(Launcher launcher) {
|
||||
super(launcher, null);
|
||||
mLauncher = launcher;
|
||||
AllAppsTransitionController controller = mLauncher.getAllAppsController();
|
||||
|
||||
mDiscoBounceAnimation =
|
||||
AnimatorInflater.loadAnimator(launcher, R.animator.discovery_bounce);
|
||||
mDiscoBounceAnimation.setTarget(new VerticalProgressWrapper(controller, delta));
|
||||
mDiscoBounceAnimation.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
handleClose(false);
|
||||
}
|
||||
});
|
||||
mDiscoBounceAnimation.addListener(controller.getProgressAnimatorListener());
|
||||
mDiscoBounceAnimation.setTarget(new VerticalProgressWrapper(
|
||||
launcher.getHotseat(), mLauncher.getDragLayer().getHeight()));
|
||||
mDiscoBounceAnimation.addListener(AnimatorListeners.forEndCallback(this::handleClose));
|
||||
launcher.getStateManager().addStateListener(mStateListener);
|
||||
}
|
||||
|
||||
@@ -104,9 +99,9 @@ public class DiscoveryBounce extends AbstractFloatingView {
|
||||
if (mIsOpen) {
|
||||
mIsOpen = false;
|
||||
mLauncher.getDragLayer().removeView(this);
|
||||
// Reset the all-apps progress to what ever it was previously.
|
||||
mLauncher.getAllAppsController().setProgress(mLauncher.getStateManager()
|
||||
.getState().getVerticalProgress(mLauncher));
|
||||
// Reset the translation to what ever it was previously.
|
||||
mLauncher.getHotseat().setTranslationY(mLauncher.getStateManager().getState()
|
||||
.getHotseatScaleAndTranslation(mLauncher).translationY);
|
||||
mLauncher.getStateManager().removeStateListener(mStateListener);
|
||||
}
|
||||
}
|
||||
@@ -141,29 +136,28 @@ public class DiscoveryBounce extends AbstractFloatingView {
|
||||
return;
|
||||
}
|
||||
onboardingPrefs.incrementEventCount(OnboardingPrefs.HOME_BOUNCE_COUNT);
|
||||
|
||||
new DiscoveryBounce(launcher, 0).show();
|
||||
new DiscoveryBounce(launcher).show();
|
||||
}
|
||||
|
||||
/**
|
||||
* A wrapper around {@link AllAppsTransitionController} allowing a fixed shift in the value.
|
||||
* A wrapper around hotseat animator allowing a fixed shift in the value.
|
||||
*/
|
||||
public static class VerticalProgressWrapper {
|
||||
|
||||
private final float mDelta;
|
||||
private final AllAppsTransitionController mController;
|
||||
private final View mView;
|
||||
private final float mLimit;
|
||||
|
||||
private VerticalProgressWrapper(AllAppsTransitionController controller, float delta) {
|
||||
mController = controller;
|
||||
mDelta = delta;
|
||||
private VerticalProgressWrapper(View view, float limit) {
|
||||
mView = view;
|
||||
mLimit = limit;
|
||||
}
|
||||
|
||||
public float getProgress() {
|
||||
return mController.getProgress() + mDelta;
|
||||
return 1 + mView.getTranslationY() / mLimit;
|
||||
}
|
||||
|
||||
public void setProgress(float progress) {
|
||||
mController.setProgress(progress - mDelta);
|
||||
mView.setTranslationY(mLimit * (progress - 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user