From db364379312e56a3a3905a54d0de783062a92a73 Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Wed, 26 Oct 2016 19:12:47 -0700 Subject: Moving saving state transtion listener logic to individual views Change-Id: If5402b6961d7d6be0c50778f27a8746ed6f1bbfb --- src/com/android/launcher3/Launcher.java | 5 +- .../LauncherStateTransitionAnimation.java | 250 ++++----------------- .../android/launcher3/LauncherTransitionable.java | 27 --- .../android/launcher3/PinchAnimationManager.java | 2 +- .../android/launcher3/PinchToOverviewListener.java | 4 +- src/com/android/launcher3/Workspace.java | 67 +++--- .../WorkspaceStateTransitionAnimation.java | 6 + .../launcher3/allapps/AllAppsContainerView.java | 27 +-- 8 files changed, 93 insertions(+), 295 deletions(-) delete mode 100644 src/com/android/launcher3/LauncherTransitionable.java (limited to 'src/com') diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 0a5d44e20..f7d1f4a7e 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -2951,10 +2951,9 @@ public class Launcher extends Activity } if (toState == State.APPS) { - mStateTransitionAnimation.startAnimationToAllApps(mWorkspace.getState(), animated, - focusSearchBar); + mStateTransitionAnimation.startAnimationToAllApps(animated, focusSearchBar); } else { - mStateTransitionAnimation.startAnimationToWidgets(mWorkspace.getState(), animated); + mStateTransitionAnimation.startAnimationToWidgets(animated); } // Change the state *after* we've called all the transition code diff --git a/src/com/android/launcher3/LauncherStateTransitionAnimation.java b/src/com/android/launcher3/LauncherStateTransitionAnimation.java index 7e842645b..19cc0fbe5 100644 --- a/src/com/android/launcher3/LauncherStateTransitionAnimation.java +++ b/src/com/android/launcher3/LauncherStateTransitionAnimation.java @@ -23,13 +23,13 @@ import android.animation.ObjectAnimator; import android.animation.PropertyValuesHolder; import android.animation.TimeInterpolator; import android.animation.ValueAnimator; -import android.annotation.SuppressLint; import android.annotation.TargetApi; import android.content.res.Resources; import android.os.Build; import android.util.Log; import android.view.View; import android.view.animation.AccelerateInterpolator; +import android.view.animation.Animation; import android.view.animation.DecelerateInterpolator; import com.android.launcher3.allapps.AllAppsContainerView; @@ -135,7 +135,7 @@ public class LauncherStateTransitionAnimation { * @param startSearchAfterTransition Immediately starts app search after the transition to * All Apps is completed. */ - public void startAnimationToAllApps(final Workspace.State fromWorkspaceState, + public void startAnimationToAllApps( final boolean animated, final boolean startSearchAfterTransition) { final AllAppsContainerView toView = mLauncher.getAppsView(); final View buttonView = mLauncher.getStartViewForAllAppsRevealAnimation(); @@ -170,18 +170,17 @@ public class LauncherStateTransitionAnimation { animType = PULLUP; } // Only animate the search bar if animating from spring loaded mode back to all apps - startAnimationToOverlay(fromWorkspaceState, + startAnimationToOverlay( Workspace.State.NORMAL_HIDDEN, buttonView, toView, animated, animType, cb); } /** * Starts an animation to the widgets view. */ - public void startAnimationToWidgets(final Workspace.State fromWorkspaceState, - final boolean animated) { + public void startAnimationToWidgets(final boolean animated) { final WidgetsContainerView toView = mLauncher.getWidgetsView(); final View buttonView = mLauncher.getWidgetsButton(); - startAnimationToOverlay(fromWorkspaceState, + startAnimationToOverlay( Workspace.State.OVERVIEW_HIDDEN, buttonView, toView, animated, CIRCULAR_REVEAL, new PrivateTransitionCallbacks(FINAL_REVEAL_ALPHA_FOR_WIDGETS){ @Override @@ -224,9 +223,8 @@ public class LauncherStateTransitionAnimation { /** * Creates and starts a new animation to a particular overlay view. */ - @SuppressLint("NewApi") private void startAnimationToOverlay( - final Workspace.State fromWorkspaceState, final Workspace.State toWorkspaceState, + final Workspace.State toWorkspaceState, final View buttonView, final BaseContainerView toView, final boolean animated, int animType, final PrivateTransitionCallbacks pCb) { final AnimatorSet animation = LauncherAnimUtils.createAnimatorSet(); @@ -237,8 +235,6 @@ public class LauncherStateTransitionAnimation { final int itemsAlphaStagger = res.getInteger(R.integer.config_overlayItemsAlphaStagger); - final View fromView = mLauncher.getWorkspace(); - final AnimationLayerSet layerViews = new AnimationLayerSet(); // If for some reason our views aren't initialized, don't animate @@ -248,7 +244,7 @@ public class LauncherStateTransitionAnimation { cancelAnimation(); final View contentView = toView.getContentView(); - playCommonTransitionAnimations(toWorkspaceState, fromView, toView, + playCommonTransitionAnimations(toWorkspaceState, animated, initialized, animation, layerViews); if (!animated || !initialized) { if (FeatureFlags.LAUNCHER3_ALL_APPS_PULL_UP && @@ -264,13 +260,6 @@ public class LauncherStateTransitionAnimation { // Show the content view contentView.setVisibility(View.VISIBLE); - - dispatchOnLauncherTransitionPrepare(fromView, animated, false); - dispatchOnLauncherTransitionStart(fromView, animated, false); - dispatchOnLauncherTransitionEnd(fromView, animated, false); - dispatchOnLauncherTransitionPrepare(toView, animated, false); - dispatchOnLauncherTransitionStart(toView, animated, false); - dispatchOnLauncherTransitionEnd(toView, animated, false); pCb.onTransitionComplete(); return; } @@ -355,9 +344,6 @@ public class LauncherStateTransitionAnimation { animation.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { - dispatchOnLauncherTransitionEnd(fromView, animated, false); - dispatchOnLauncherTransitionEnd(toView, animated, false); - // Hide the reveal view revealView.setVisibility(View.INVISIBLE); @@ -368,31 +354,11 @@ public class LauncherStateTransitionAnimation { }); - // Dispatch the prepare transition signal - dispatchOnLauncherTransitionPrepare(fromView, animated, false); - dispatchOnLauncherTransitionPrepare(toView, animated, false); - - final AnimatorSet stateAnimation = animation; - final Runnable startAnimRunnable = new Runnable() { - public void run() { - // Check that mCurrentAnimation hasn't changed while - // we waited for a layout/draw pass - if (mCurrentAnimation != stateAnimation) - return; - dispatchOnLauncherTransitionStart(fromView, animated, false); - dispatchOnLauncherTransitionStart(toView, animated, false); - - // Focus the new view - toView.requestFocus(); - - stateAnimation.start(); - } - }; toView.bringToFront(); toView.setVisibility(View.VISIBLE); animation.addListener(layerViews); - toView.post(startAnimRunnable); + toView.post(new StartAnimRunnable(animation, toView)); mCurrentAnimation = animation; } else if (animType == PULLUP) { // We are animating the content view alpha, so ensure we have a layer for it @@ -401,32 +367,13 @@ public class LauncherStateTransitionAnimation { animation.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { - dispatchOnLauncherTransitionEnd(fromView, animated, false); - dispatchOnLauncherTransitionEnd(toView, animated, false); cleanupAnimation(); pCb.onTransitionComplete(); } }); boolean shouldPost = mAllAppsController.animateToAllApps(animation, revealDurationSlide); - dispatchOnLauncherTransitionPrepare(fromView, animated, false); - dispatchOnLauncherTransitionPrepare(toView, animated, false); - - final AnimatorSet stateAnimation = animation; - final Runnable startAnimRunnable = new Runnable() { - public void run() { - // Check that mCurrentAnimation hasn't changed while - // we waited for a layout/draw pass - if (mCurrentAnimation != stateAnimation) - return; - - dispatchOnLauncherTransitionStart(fromView, animated, false); - dispatchOnLauncherTransitionStart(toView, animated, false); - - toView.requestFocus(); - stateAnimation.start(); - } - }; + Runnable startAnimRunnable = new StartAnimRunnable(animation, toView); mCurrentAnimation = animation; mCurrentAnimation.addListener(layerViews); if (shouldPost) { @@ -441,7 +388,7 @@ public class LauncherStateTransitionAnimation { * Plays animations used by various transitions. */ private void playCommonTransitionAnimations( - Workspace.State toWorkspaceState, View fromView, View toView, + Workspace.State toWorkspaceState, boolean animated, boolean initialized, AnimatorSet animation, AnimationLayerSet layerViews) { // Create the workspace animation. @@ -454,36 +401,16 @@ public class LauncherStateTransitionAnimation { if (workspaceAnim != null) { animation.play(workspaceAnim); } - // Dispatch onLauncherTransitionStep() as the animation interpolates. - animation.play(dispatchOnLauncherTransitionStepAnim(fromView, toView)); } } - /** - * Returns an Animator that calls {@link #dispatchOnLauncherTransitionStep(View, float)} on - * {@param fromView} and {@param toView} as the animation interpolates. - * - * This is a bit hacky: we create a dummy ValueAnimator just for the AnimatorUpdateListener. - */ - private Animator dispatchOnLauncherTransitionStepAnim(final View fromView, final View toView) { - ValueAnimator updateAnimator = ValueAnimator.ofFloat(0, 1); - updateAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { - @Override - public void onAnimationUpdate(ValueAnimator animation) { - dispatchOnLauncherTransitionStep(fromView, animation.getAnimatedFraction()); - dispatchOnLauncherTransitionStep(toView, animation.getAnimatedFraction()); - } - }); - return updateAnimator; - } - /** * Starts an animation to the workspace from the apps view. */ private void startAnimationToWorkspaceFromAllApps(final Workspace.State fromWorkspaceState, final Workspace.State toWorkspaceState, final boolean animated, int type, final Runnable onCompleteRunnable) { - AllAppsContainerView appsView = mLauncher.getAppsView(); + final AllAppsContainerView appsView = mLauncher.getAppsView(); // No alpha anim from all apps PrivateTransitionCallbacks cb = new PrivateTransitionCallbacks(1f) { @Override @@ -513,6 +440,7 @@ public class LauncherStateTransitionAnimation { @Override void onTransitionComplete() { mLauncher.getUserEventDispatcher().resetElapsedContainerMillis(); + appsView.reset(); } }; // Only animate the search bar if animating to spring loaded mode from all apps @@ -564,34 +492,13 @@ public class LauncherStateTransitionAnimation { // Cancel the current animation cancelAnimation(); - boolean multiplePagesVisible = toWorkspaceState.hasMultipleVisiblePages; - - playCommonTransitionAnimations(toWorkspaceState, fromWorkspace, null, - animated, animated, animation, layerViews); - + playCommonTransitionAnimations(toWorkspaceState, animated, animated, animation, layerViews); mLauncher.getUserEventDispatcher().resetElapsedContainerMillis(); if (animated) { - dispatchOnLauncherTransitionPrepare(fromWorkspace, animated, multiplePagesVisible); - - final AnimatorSet stateAnimation = animation; - final Runnable startAnimRunnable = new Runnable() { - @TargetApi(Build.VERSION_CODES.LOLLIPOP) - public void run() { - // Check that mCurrentAnimation hasn't changed while - // we waited for a layout/draw pass - if (mCurrentAnimation != stateAnimation) - return; - - dispatchOnLauncherTransitionStart(fromWorkspace, animated, true); - stateAnimation.start(); - } - }; animation.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { - dispatchOnLauncherTransitionEnd(fromWorkspace, animated, true); - // Run any queued runnables if (onCompleteRunnable != null) { onCompleteRunnable.run(); @@ -601,14 +508,10 @@ public class LauncherStateTransitionAnimation { cleanupAnimation(); } }); - stateAnimation.addListener(layerViews); - fromWorkspace.post(startAnimRunnable); + animation.addListener(layerViews); + fromWorkspace.post(new StartAnimRunnable(animation, null)); mCurrentAnimation = animation; } else /* if (!animated) */ { - dispatchOnLauncherTransitionPrepare(fromWorkspace, animated, multiplePagesVisible); - dispatchOnLauncherTransitionStart(fromWorkspace, animated, true); - dispatchOnLauncherTransitionEnd(fromWorkspace, animated, true); - // Run any queued runnables if (onCompleteRunnable != null) { onCompleteRunnable.run(); @@ -646,9 +549,7 @@ public class LauncherStateTransitionAnimation { // Cancel the current animation cancelAnimation(); - boolean multiplePagesVisible = toWorkspaceState.hasMultipleVisiblePages; - - playCommonTransitionAnimations(toWorkspaceState, fromView, toView, + playCommonTransitionAnimations(toWorkspaceState, animated, initialized, animation, layerViews); if (!animated || !initialized) { if (FeatureFlags.LAUNCHER3_ALL_APPS_PULL_UP && @@ -656,12 +557,6 @@ public class LauncherStateTransitionAnimation { mAllAppsController.finishPullDown(); } fromView.setVisibility(View.GONE); - dispatchOnLauncherTransitionPrepare(fromView, animated, multiplePagesVisible); - dispatchOnLauncherTransitionStart(fromView, animated, true); - dispatchOnLauncherTransitionEnd(fromView, animated, true); - dispatchOnLauncherTransitionPrepare(toView, animated, multiplePagesVisible); - dispatchOnLauncherTransitionStart(toView, animated, true); - dispatchOnLauncherTransitionEnd(toView, animated, true); pCb.onTransitionComplete(); // Run any queued runnables @@ -774,16 +669,10 @@ public class LauncherStateTransitionAnimation { } } - dispatchOnLauncherTransitionPrepare(fromView, animated, multiplePagesVisible); - dispatchOnLauncherTransitionPrepare(toView, animated, multiplePagesVisible); - animation.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { fromView.setVisibility(View.GONE); - dispatchOnLauncherTransitionEnd(fromView, animated, true); - dispatchOnLauncherTransitionEnd(toView, animated, true); - // Run any queued runnables if (onCompleteRunnable != null) { onCompleteRunnable.run(); @@ -802,23 +691,9 @@ public class LauncherStateTransitionAnimation { } }); - final AnimatorSet stateAnimation = animation; - final Runnable startAnimRunnable = new Runnable() { - @TargetApi(Build.VERSION_CODES.LOLLIPOP) - public void run() { - // Check that mCurrentAnimation hasn't changed while - // we waited for a layout/draw pass - if (mCurrentAnimation != stateAnimation) - return; - - dispatchOnLauncherTransitionStart(fromView, animated, false); - dispatchOnLauncherTransitionStart(toView, animated, false); - stateAnimation.start(); - } - }; mCurrentAnimation = animation; mCurrentAnimation.addListener(layerViews); - fromView.post(startAnimRunnable); + fromView.post(new StartAnimRunnable(animation, null)); } else if (animType == PULLUP) { // We are animating the content view alpha, so ensure we have a layer for it layerViews.addView(contentView); @@ -833,8 +708,6 @@ public class LauncherStateTransitionAnimation { @Override public void onAnimationEnd(Animator animation) { if (canceled) return; - dispatchOnLauncherTransitionEnd(fromView, animated, true); - dispatchOnLauncherTransitionEnd(toView, animated, true); // Run any queued runnables if (onCompleteRunnable != null) { onCompleteRunnable.run(); @@ -847,26 +720,7 @@ public class LauncherStateTransitionAnimation { }); boolean shouldPost = mAllAppsController.animateToWorkspace(animation, revealDurationSlide); - // Dispatch the prepare transition signal - dispatchOnLauncherTransitionPrepare(fromView, animated, multiplePagesVisible); - dispatchOnLauncherTransitionPrepare(toView, animated, multiplePagesVisible); - - final AnimatorSet stateAnimation = animation; - final Runnable startAnimRunnable = new Runnable() { - public void run() { - // Check that mCurrentAnimation hasn't changed while - // we waited for a layout/draw pass - if (mCurrentAnimation != stateAnimation) - return; - - dispatchOnLauncherTransitionStart(fromView, animated, false); - dispatchOnLauncherTransitionStart(toView, animated, false); - - // Focus the new view - toView.requestFocus(); - stateAnimation.start(); - } - }; + Runnable startAnimRunnable = new StartAnimRunnable(animation, toView); mCurrentAnimation = animation; mCurrentAnimation.addListener(layerViews); if (shouldPost) { @@ -878,52 +732,6 @@ public class LauncherStateTransitionAnimation { return; } - /** - * Dispatches the prepare-transition event to suitable views. - */ - void dispatchOnLauncherTransitionPrepare(View v, boolean animated, - boolean multiplePagesVisible) { - if (v instanceof LauncherTransitionable) { - ((LauncherTransitionable) v).onLauncherTransitionPrepare(mLauncher, animated, - multiplePagesVisible); - } - } - - /** - * Dispatches the start-transition event to suitable views. - */ - void dispatchOnLauncherTransitionStart(View v, boolean animated, boolean toWorkspace) { - if (v instanceof LauncherTransitionable) { - ((LauncherTransitionable) v).onLauncherTransitionStart(mLauncher, animated, - toWorkspace); - } - - // Update the workspace transition step as well - dispatchOnLauncherTransitionStep(v, 0f); - } - - /** - * Dispatches the step-transition event to suitable views. - */ - void dispatchOnLauncherTransitionStep(View v, float t) { - if (v instanceof LauncherTransitionable) { - ((LauncherTransitionable) v).onLauncherTransitionStep(mLauncher, t); - } - } - - /** - * Dispatches the end-transition event to suitable views. - */ - void dispatchOnLauncherTransitionEnd(View v, boolean animated, boolean toWorkspace) { - if (v instanceof LauncherTransitionable) { - ((LauncherTransitionable) v).onLauncherTransitionEnd(mLauncher, animated, - toWorkspace); - } - - // Update the workspace transition step as well - dispatchOnLauncherTransitionStep(v, 1f); - } - /** * Cancels the current animation. */ @@ -938,4 +746,26 @@ public class LauncherStateTransitionAnimation { @Thunk void cleanupAnimation() { mCurrentAnimation = null; } + + private class StartAnimRunnable implements Runnable { + + private final AnimatorSet mAnim; + private final View mViewToFocus; + + public StartAnimRunnable(AnimatorSet anim, View viewToFocus) { + mAnim = anim; + mViewToFocus = viewToFocus; + } + + @Override + public void run() { + if (mCurrentAnimation != mAnim) { + return; + } + if (mViewToFocus != null) { + mViewToFocus.requestFocus(); + } + mAnim.start(); + } + } } diff --git a/src/com/android/launcher3/LauncherTransitionable.java b/src/com/android/launcher3/LauncherTransitionable.java deleted file mode 100644 index b97aaec7d..000000000 --- a/src/com/android/launcher3/LauncherTransitionable.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2015 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.launcher3; - -/** - * An interface to get callbacks during a launcher transition. - */ -public interface LauncherTransitionable { - void onLauncherTransitionPrepare(Launcher l, boolean animated, boolean multiplePagesVisible); - void onLauncherTransitionStart(Launcher l, boolean animated, boolean toWorkspace); - void onLauncherTransitionStep(Launcher l, float t); - void onLauncherTransitionEnd(Launcher l, boolean animated, boolean toWorkspace); -} diff --git a/src/com/android/launcher3/PinchAnimationManager.java b/src/com/android/launcher3/PinchAnimationManager.java index 3cc0f7d3f..c1d60fd02 100644 --- a/src/com/android/launcher3/PinchAnimationManager.java +++ b/src/com/android/launcher3/PinchAnimationManager.java @@ -108,7 +108,7 @@ public class PinchAnimationManager { public void onAnimationEnd(Animator animation) { mIsAnimating = false; thresholdManager.reset(); - mWorkspace.onLauncherTransitionEnd(mLauncher, false, true); + mWorkspace.onEndStateTransition(); } }); animator.setDuration(duration).start(); diff --git a/src/com/android/launcher3/PinchToOverviewListener.java b/src/com/android/launcher3/PinchToOverviewListener.java index 66209bfa1..42515d1fc 100644 --- a/src/com/android/launcher3/PinchToOverviewListener.java +++ b/src/com/android/launcher3/PinchToOverviewListener.java @@ -112,7 +112,7 @@ public class PinchToOverviewListener extends ScaleGestureDetector.SimpleOnScaleG mInterpolator = mWorkspace.isInOverviewMode() ? new LogDecelerateInterpolator(100, 0) : new LogAccelerateInterpolator(100, 0); mPinchStarted = true; - mWorkspace.onLauncherTransitionPrepare(mLauncher, false, true); + mWorkspace.onPrepareStateTransition(true); return true; } @@ -142,7 +142,7 @@ public class PinchToOverviewListener extends ScaleGestureDetector.SimpleOnScaleG mThresholdManager); } else { mThresholdManager.reset(); - mWorkspace.onLauncherTransitionEnd(mLauncher, false, true); + mWorkspace.onEndStateTransition(); } mPinchStarted = false; mPinchCanceled = false; diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index 95a5ee29f..0dd762f1f 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -48,6 +48,7 @@ import android.view.View; import android.view.ViewDebug; import android.view.ViewGroup; import android.view.accessibility.AccessibilityManager; +import android.view.animation.Animation.AnimationListener; import android.view.animation.DecelerateInterpolator; import android.view.animation.Interpolator; import android.widget.TextView; @@ -96,7 +97,7 @@ import java.util.HashSet; */ public class Workspace extends PagedView implements DropTarget, DragSource, DragScroller, View.OnTouchListener, - DragController.DragListener, LauncherTransitionable, ViewGroup.OnHierarchyChangeListener, + DragController.DragListener, ViewGroup.OnHierarchyChangeListener, Insettable, DropTargetSource { private static final String TAG = "Launcher.Workspace"; @@ -2048,6 +2049,20 @@ public class Workspace extends PagedView mOnStateChangeListener.prepareStateChange(toState, animated ? workspaceAnim : null); } + onPrepareStateTransition(mState.hasMultipleVisiblePages); + + StateTransitionListener listener = new StateTransitionListener(); + if (animated) { + ValueAnimator stepAnimator = ValueAnimator.ofFloat(0, 1); + stepAnimator.addListener(listener); + + workspaceAnim.play(stepAnimator); + workspaceAnim.addListener(listener); + } else { + listener.onAnimationStart(null); + listener.onAnimationEnd(null); + } + return workspaceAnim; } @@ -2100,9 +2115,7 @@ public class Workspace extends PagedView } } - @Override - public void onLauncherTransitionPrepare(Launcher l, boolean animated, - boolean multiplePagesVisible) { + public void onPrepareStateTransition(boolean multiplePagesVisible) { mIsSwitchingState = true; mTransitionProgress = 0; @@ -2115,32 +2128,12 @@ public class Workspace extends PagedView hideCustomContentIfNecessary(); } - @Override - public void onLauncherTransitionStart(Launcher l, boolean animated, boolean toWorkspace) { - if (mPageIndicator != null) { - boolean isNewStateSpringLoaded = mState == State.SPRING_LOADED; - mPageIndicator.setShouldAutoHide(!isNewStateSpringLoaded); - if (isNewStateSpringLoaded) { - // Show the page indicator at the same time as the rest of the transition. - showPageIndicatorAtCurrentScroll(); - } - } - } - - @Override - public void onLauncherTransitionStep(Launcher l, float t) { - mTransitionProgress = t; - } - - @Override - public void onLauncherTransitionEnd(Launcher l, boolean animated, boolean toWorkspace) { + public void onEndStateTransition() { mIsSwitchingState = false; updateChildrenLayersEnabled(false); showCustomContentIfNecessary(); mForceDrawAdjacentPages = false; - if (mState == State.SPRING_LOADED) { - showPageIndicatorAtCurrentScroll(); - } + mTransitionProgress = 1; } void updateCustomContentVisibility() { @@ -4275,4 +4268,26 @@ public class Workspace extends PagedView public static final boolean isQsbContainerPage(int pageNo) { return pageNo == 0; } + + private class StateTransitionListener extends AnimatorListenerAdapter + implements AnimatorUpdateListener { + @Override + public void onAnimationUpdate(ValueAnimator anim) { + mTransitionProgress = anim.getAnimatedFraction(); + } + + @Override + public void onAnimationStart(Animator animation) { + if (mState == State.SPRING_LOADED) { + // Show the page indicator at the same time as the rest of the transition. + showPageIndicatorAtCurrentScroll(); + } + mTransitionProgress = 0; + } + + @Override + public void onAnimationEnd(Animator animation) { + onEndStateTransition(); + } + } } diff --git a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java index 1cf4b39f5..1f36468a7 100644 --- a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java +++ b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java @@ -421,6 +421,11 @@ public class WorkspaceStateTransitionAnimation { canceled = true; } + @Override + public void onAnimationStart(Animator animation) { + mWorkspace.getPageIndicator().setShouldAutoHide(!states.stateIsSpringLoaded); + } + @Override public void onAnimationEnd(Animator animation) { mStateAnimator = null; @@ -434,6 +439,7 @@ public class WorkspaceStateTransitionAnimation { } else { overviewPanel.setAlpha(finalOverviewPanelAlpha); AlphaUpdateListener.updateVisibility(overviewPanel, accessibilityEnabled); + mWorkspace.getPageIndicator().setShouldAutoHide(!states.stateIsSpringLoaded); qsbAlphaAnimation.end(); mWorkspace.createHotseatAlphaAnimator(finalHotseatAlpha).end(); diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java index c65a803c2..176540d93 100644 --- a/src/com/android/launcher3/allapps/AllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java @@ -43,7 +43,6 @@ import com.android.launcher3.ExtendedEditText; import com.android.launcher3.Insettable; import com.android.launcher3.ItemInfo; import com.android.launcher3.Launcher; -import com.android.launcher3.LauncherTransitionable; import com.android.launcher3.R; import com.android.launcher3.Utilities; import com.android.launcher3.config.FeatureFlags; @@ -63,8 +62,7 @@ import java.util.List; * The all apps view container. */ public class AllAppsContainerView extends BaseContainerView implements DragSource, - LauncherTransitionable, View.OnLongClickListener, AllAppsSearchBarController.Callbacks, - Insettable { + View.OnLongClickListener, AllAppsSearchBarController.Callbacks, Insettable { private final Launcher mLauncher; private final AlphabeticalAppsList mApps; @@ -444,29 +442,6 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc } } - @Override - public void onLauncherTransitionPrepare(Launcher l, boolean animated, - boolean multiplePagesVisible) { - // Do nothing - } - - @Override - public void onLauncherTransitionStart(Launcher l, boolean animated, boolean toWorkspace) { - // Do nothing - } - - @Override - public void onLauncherTransitionStep(Launcher l, float t) { - // Do nothing - } - - @Override - public void onLauncherTransitionEnd(Launcher l, boolean animated, boolean toWorkspace) { - if (toWorkspace) { - reset(); - } - } - @Override public void onSearchResult(String query, ArrayList apps) { if (apps != null) { -- cgit v1.2.3