From 0bbacc705cc7c11608549b5408e05a3c1726d074 Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Mon, 23 Apr 2018 11:30:36 -0700 Subject: [PATCH] Moving some swipe up complete logic to when the handler is completed. Bug: 76449024 Change-Id: I136e665495ab7164c79e1dfa0ef61090ba50fc7a --- .../quickstep/ActivityControlHelper.java | 13 +-------- .../WindowTransformSwipeHandler.java | 7 ++--- .../launcher3/allapps/DiscoveryBounce.java | 28 +++++++++++++++++++ .../states/InternalStateHandler.java | 8 ++++++ 4 files changed, 40 insertions(+), 16 deletions(-) diff --git a/quickstep/src/com/android/quickstep/ActivityControlHelper.java b/quickstep/src/com/android/quickstep/ActivityControlHelper.java index b784c033f3..84d97a9266 100644 --- a/quickstep/src/com/android/quickstep/ActivityControlHelper.java +++ b/quickstep/src/com/android/quickstep/ActivityControlHelper.java @@ -79,8 +79,6 @@ public interface ActivityControlHelper { ActivityInitListener createActivityInitListener(BiPredicate onInitListener); - void onOverviewShown(T activity); - @Nullable T getCreatedActivity(); @@ -150,6 +148,7 @@ public interface ActivityControlHelper { public void onSwipeUpComplete(Launcher activity) { // Re apply state in case we did something funky during the transition. activity.getStateManager().reapplyState(); + DiscoveryBounce.showForOverviewIfNeeded(activity); } @Override @@ -213,11 +212,6 @@ public interface ActivityControlHelper { return new LauncherInitListener(onInitListener); } - @Override - public void onOverviewShown(Launcher launcher) { - DiscoveryBounce.showForOverviewIfNeeded(launcher); - } - @Nullable @Override public Launcher getCreatedActivity() { @@ -372,11 +366,6 @@ public interface ActivityControlHelper { return new RecentsActivityTracker(onInitListener); } - @Override - public void onOverviewShown(RecentsActivity activity) { - // Do nothing. - } - @Nullable @Override public RecentsActivity getCreatedActivity() { diff --git a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java index 248aa41818..7b09b8ffee 100644 --- a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java +++ b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java @@ -694,9 +694,6 @@ public class WindowTransformSwipeHandler { // If we haven't posted the transition end runnable, run it now finishTransitionRunnable.run(); } - RecentsModel.getInstance(mContext).onOverviewShown(false, TAG); - mActivityControlHelper.onOverviewShown(mActivity); - doLogGesture(true /* toLauncher */); } private void setupLauncherUiAfterSwipeUpAnimation() { @@ -708,9 +705,11 @@ public class WindowTransformSwipeHandler { // Animate the first icon. mRecentsView.setFirstTaskIconScaledDown(false /* isScaledDown */, true /* animate */); - mRecentsView.setSwipeDownShouldLaunchApp(true); + RecentsModel.getInstance(mContext).onOverviewShown(false, TAG); + + doLogGesture(true /* toLauncher */); reset(); } diff --git a/src/com/android/launcher3/allapps/DiscoveryBounce.java b/src/com/android/launcher3/allapps/DiscoveryBounce.java index 0ce33bcc68..f73916c54c 100644 --- a/src/com/android/launcher3/allapps/DiscoveryBounce.java +++ b/src/com/android/launcher3/allapps/DiscoveryBounce.java @@ -27,6 +27,7 @@ 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; @@ -34,12 +35,15 @@ import com.android.launcher3.AbstractFloatingView; import com.android.launcher3.Launcher; import com.android.launcher3.R; import com.android.launcher3.compat.UserManagerCompat; +import com.android.launcher3.states.InternalStateHandler; /** * Abstract base class of floating view responsible for showing discovery bounce animation */ public class DiscoveryBounce extends AbstractFloatingView { + private static final long DELAY_MS = 200; + public static final String HOME_BOUNCE_SEEN = "launcher.apps_view_shown"; public static final String SHELF_BOUNCE_SEEN = "launcher.shelf_bounce_seen"; @@ -102,6 +106,10 @@ public class DiscoveryBounce extends AbstractFloatingView { } public static void showForHomeIfNeeded(Launcher launcher) { + showForHomeIfNeeded(launcher, true); + } + + private static void showForHomeIfNeeded(Launcher launcher, boolean withDelay) { if (!launcher.isInState(NORMAL) || launcher.getSharedPrefs().getBoolean(HOME_BOUNCE_SEEN, false) || AbstractFloatingView.getTopOpenView(launcher) != null @@ -110,6 +118,11 @@ public class DiscoveryBounce extends AbstractFloatingView { return; } + if (withDelay) { + new Handler().postDelayed(() -> showForHomeIfNeeded(launcher, false), DELAY_MS); + return; + } + DiscoveryBounce view = new DiscoveryBounce(launcher, AnimatorInflater.loadAnimator(launcher, R.animator.discovery_bounce)); view.mIsOpen = true; @@ -117,7 +130,13 @@ public class DiscoveryBounce extends AbstractFloatingView { } public static void showForOverviewIfNeeded(Launcher launcher) { + showForOverviewIfNeeded(launcher, true); + } + + private static void showForOverviewIfNeeded(Launcher launcher, boolean withDelay) { if (!launcher.isInState(OVERVIEW) + || !launcher.hasBeenResumed() + || launcher.isForceInvisible() || launcher.getDeviceProfile().isVerticalBarLayout() || launcher.getSharedPrefs().getBoolean(SHELF_BOUNCE_SEEN, false) || UserManagerCompat.getInstance(launcher).isDemoUser() @@ -125,6 +144,15 @@ public class DiscoveryBounce extends AbstractFloatingView { return; } + if (withDelay) { + new Handler().postDelayed(() -> showForOverviewIfNeeded(launcher, false), DELAY_MS); + return; + } else if (InternalStateHandler.hasPending() + || AbstractFloatingView.getTopOpenView(launcher) != null) { + // TODO: Move these checks to the top and call this method after invalidate handler. + return; + } + float verticalProgress = OVERVIEW.getVerticalProgress(launcher); TimeInterpolator pathInterpolator = new PathInterpolator(0.35f, 0, 0.5f, 1); diff --git a/src/com/android/launcher3/states/InternalStateHandler.java b/src/com/android/launcher3/states/InternalStateHandler.java index 0a2c3e4fa1..cf7c6ba398 100644 --- a/src/com/android/launcher3/states/InternalStateHandler.java +++ b/src/com/android/launcher3/states/InternalStateHandler.java @@ -60,6 +60,10 @@ public abstract class InternalStateHandler extends Binder { return sScheduler.clearReference(this); } + public static boolean hasPending() { + return sScheduler.hasPending(); + } + public static boolean handleCreate(Launcher launcher, Intent intent) { return handleIntent(launcher, intent, false, false); } @@ -132,5 +136,9 @@ public abstract class InternalStateHandler extends Binder { } return false; } + + public boolean hasPending() { + return mPendingHandler.get() != null; + } } } \ No newline at end of file