summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2018-05-22 11:20:16 -0700
committerSunny Goyal <sunnygoyal@google.com>2018-05-22 11:40:58 -0700
commit0bd0244a73cc0b6dc40156fd707f402bb53d5dba (patch)
treefbc095ea389cae698f5e4ea1bbea5c46a45b62aa
parent8417a7b5140bf6dd27702331e787887a7b8c2e3d (diff)
downloadandroid_packages_apps_Trebuchet-0bd0244a73cc0b6dc40156fd707f402bb53d5dba.tar.gz
android_packages_apps_Trebuchet-0bd0244a73cc0b6dc40156fd707f402bb53d5dba.tar.bz2
android_packages_apps_Trebuchet-0bd0244a73cc0b6dc40156fd707f402bb53d5dba.zip
Reset the vertical progress when the discovery bounce is closed
Since discovery bounce runs on absolute values, it can sometime leave the vertical progress at an old value, if it is closed after the state change. Also simplifying discovery bounce animation to use xml everytime. Bug: 80099242 Change-Id: Iebc249dd02f474cbed85b695eeeb8c2bf60b935d
-rw-r--r--proguard.flags6
-rw-r--r--src/com/android/launcher3/allapps/DiscoveryBounce.java75
2 files changed, 45 insertions, 36 deletions
diff --git a/proguard.flags b/proguard.flags
index e9f6db462..555d13e44 100644
--- a/proguard.flags
+++ b/proguard.flags
@@ -120,6 +120,12 @@
*;
}
+# Discovery bounce animation
+-keep class com.android.launcher3.allapps.DiscoveryBounce$VerticalProgressWrapper {
+ public void setProgress(float);
+ public float getProgress();
+}
+
# BUG(70852369): Surpress additional warnings after changing from Proguard to R8
-dontwarn android.app.**
-dontwarn android.view.**
diff --git a/src/com/android/launcher3/allapps/DiscoveryBounce.java b/src/com/android/launcher3/allapps/DiscoveryBounce.java
index e1cd06a8b..a0a79c87d 100644
--- a/src/com/android/launcher3/allapps/DiscoveryBounce.java
+++ b/src/com/android/launcher3/allapps/DiscoveryBounce.java
@@ -24,14 +24,9 @@ import static com.android.launcher3.userevent.nano.LauncherLogProto.ContainerTyp
import android.animation.Animator;
import android.animation.AnimatorInflater;
import android.animation.AnimatorListenerAdapter;
-import android.animation.Keyframe;
-import android.animation.ObjectAnimator;
-import android.animation.PropertyValuesHolder;
-import android.animation.TimeInterpolator;
import android.app.ActivityManager;
import android.os.Handler;
import android.view.MotionEvent;
-import android.view.animation.PathInterpolator;
import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.Launcher;
@@ -52,21 +47,21 @@ public class DiscoveryBounce extends AbstractFloatingView {
private final Launcher mLauncher;
private final Animator mDiscoBounceAnimation;
- public DiscoveryBounce(Launcher launcher, Animator animator) {
+ public DiscoveryBounce(Launcher launcher, float delta) {
super(launcher, null);
mLauncher = launcher;
-
- mDiscoBounceAnimation = animator;
AllAppsTransitionController controller = mLauncher.getAllAppsController();
- mDiscoBounceAnimation.setTarget(controller);
- mDiscoBounceAnimation.addListener(controller.getProgressAnimatorListener());
+ 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());
}
@Override
@@ -102,6 +97,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));
}
}
@@ -115,6 +113,12 @@ public class DiscoveryBounce extends AbstractFloatingView {
return (type & TYPE_ON_BOARD_POPUP) != 0;
}
+ private void show(int containerType) {
+ mIsOpen = true;
+ mLauncher.getDragLayer().addView(this);
+ mLauncher.getUserEventDispatcher().logActionBounceTip(containerType);
+ }
+
public static void showForHomeIfNeeded(Launcher launcher) {
showForHomeIfNeeded(launcher, true);
}
@@ -133,11 +137,7 @@ public class DiscoveryBounce extends AbstractFloatingView {
return;
}
- DiscoveryBounce view = new DiscoveryBounce(launcher,
- AnimatorInflater.loadAnimator(launcher, R.animator.discovery_bounce));
- view.mIsOpen = true;
- launcher.getDragLayer().addView(view);
- launcher.getUserEventDispatcher().logActionBounceTip(HOTSEAT);
+ new DiscoveryBounce(launcher, 0).show(HOTSEAT);
}
public static void showForOverviewIfNeeded(Launcher launcher) {
@@ -164,26 +164,29 @@ public class DiscoveryBounce extends AbstractFloatingView {
return;
}
- float verticalProgress = OVERVIEW.getVerticalProgress(launcher);
-
- TimeInterpolator pathInterpolator = new PathInterpolator(0.35f, 0, 0.5f, 1);
- Keyframe keyframe3 = Keyframe.ofFloat(0.423f, verticalProgress - (1 - 0.9738f));
- keyframe3.setInterpolator(pathInterpolator);
- Keyframe keyframe4 = Keyframe.ofFloat(0.754f, verticalProgress);
- keyframe4.setInterpolator(pathInterpolator);
-
- PropertyValuesHolder propertyValuesHolder = PropertyValuesHolder.ofKeyframe("progress",
- Keyframe.ofFloat(0, verticalProgress),
- Keyframe.ofFloat(0.246f, verticalProgress), keyframe3, keyframe4,
- Keyframe.ofFloat(1f, verticalProgress));
- ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(null,
- new PropertyValuesHolder[]{propertyValuesHolder});
- animator.setDuration(2166);
- animator.setRepeatCount(5);
-
- DiscoveryBounce view = new DiscoveryBounce(launcher, animator);
- view.mIsOpen = true;
- launcher.getDragLayer().addView(view);
- launcher.getUserEventDispatcher().logActionBounceTip(PREDICTION);
+ new DiscoveryBounce(launcher, (1 - OVERVIEW.getVerticalProgress(launcher)))
+ .show(PREDICTION);
+ }
+
+ /**
+ * A wrapper around {@link AllAppsTransitionController} allowing a fixed shift in the value.
+ */
+ public static class VerticalProgressWrapper {
+
+ private final float mDelta;
+ private final AllAppsTransitionController mController;
+
+ private VerticalProgressWrapper(AllAppsTransitionController controller, float delta) {
+ mController = controller;
+ mDelta = delta;
+ }
+
+ public float getProgress() {
+ return mController.getProgress() + mDelta;
+ }
+
+ public void setProgress(float progress) {
+ mController.setProgress(progress - mDelta);
+ }
}
}