summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/LauncherStateTransitionAnimation.java
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2016-02-10 12:26:23 -0800
committerSunny Goyal <sunnygoyal@google.com>2016-02-10 12:27:51 -0800
commit7c50b31f57e3e3ec1f433d243afe05554dcaf977 (patch)
treeb244d7b5cf1d0c7e753fb3f6751c4108cd87d0a5 /src/com/android/launcher3/LauncherStateTransitionAnimation.java
parent323117ca37483c2adcd14b9969e2a36ea57a9d6a (diff)
parent3826bab27ef3e7608aba112bd0f5ce2e7c3eac5b (diff)
downloadandroid_packages_apps_Trebuchet-7c50b31f57e3e3ec1f433d243afe05554dcaf977.tar.gz
android_packages_apps_Trebuchet-7c50b31f57e3e3ec1f433d243afe05554dcaf977.tar.bz2
android_packages_apps_Trebuchet-7c50b31f57e3e3ec1f433d243afe05554dcaf977.zip
resolve merge conflicts of 3826bab27e to ub-launcher3-calgary.
Change-Id: I14ff2d67de4ba97628bdf651602724f9f4989173
Diffstat (limited to 'src/com/android/launcher3/LauncherStateTransitionAnimation.java')
-rw-r--r--src/com/android/launcher3/LauncherStateTransitionAnimation.java171
1 files changed, 54 insertions, 117 deletions
diff --git a/src/com/android/launcher3/LauncherStateTransitionAnimation.java b/src/com/android/launcher3/LauncherStateTransitionAnimation.java
index 668e021c6..54945be3d 100644
--- a/src/com/android/launcher3/LauncherStateTransitionAnimation.java
+++ b/src/com/android/launcher3/LauncherStateTransitionAnimation.java
@@ -82,13 +82,18 @@ import java.util.HashMap;
*/
public class LauncherStateTransitionAnimation {
+ private static final float FINAL_REVEAL_ALPHA_FOR_WIDGETS = 0.3f;
+
/**
* Private callbacks made during transition setup.
*/
- static abstract class PrivateTransitionCallbacks {
- float getMaterialRevealViewFinalAlpha(View revealView) {
- return 0;
+ private static class PrivateTransitionCallbacks {
+ private final float materialRevealViewFinalAlpha;
+
+ PrivateTransitionCallbacks(float revealAlpha) {
+ materialRevealViewFinalAlpha = revealAlpha;
}
+
float getMaterialRevealViewStartFinalRadius() {
return 0;
}
@@ -99,7 +104,7 @@ public class LauncherStateTransitionAnimation {
void onTransitionComplete() {}
}
- public static final String TAG = "LauncherStateTransitionAnimation";
+ public static final String TAG = "LSTAnimation";
// Flags to determine how to set the layers on views before the transition animation
public static final int BUILD_LAYER = 0;
@@ -123,11 +128,7 @@ public class LauncherStateTransitionAnimation {
final boolean animated, final boolean startSearchAfterTransition) {
final AllAppsContainerView toView = mLauncher.getAppsView();
final View buttonView = mLauncher.getAllAppsButton();
- PrivateTransitionCallbacks cb = new PrivateTransitionCallbacks() {
- @Override
- public float getMaterialRevealViewFinalAlpha(View revealView) {
- return 1f;
- }
+ PrivateTransitionCallbacks cb = new PrivateTransitionCallbacks(1f) {
@Override
public float getMaterialRevealViewStartFinalRadius() {
int allAppsButtonSize = mLauncher.getDeviceProfile().allAppsButtonVisualSize;
@@ -154,8 +155,7 @@ public class LauncherStateTransitionAnimation {
};
// Only animate the search bar if animating from spring loaded mode back to all apps
mCurrentAnimation = startAnimationToOverlay(fromWorkspaceState,
- Workspace.State.NORMAL_HIDDEN, buttonView, toView, toView.getContentView(),
- toView.getRevealView(), toView.getSearchBarView(), animated, cb);
+ Workspace.State.NORMAL_HIDDEN, buttonView, toView, animated, cb);
}
/**
@@ -165,15 +165,9 @@ public class LauncherStateTransitionAnimation {
final boolean animated) {
final WidgetsContainerView toView = mLauncher.getWidgetsView();
final View buttonView = mLauncher.getWidgetsButton();
- PrivateTransitionCallbacks cb = new PrivateTransitionCallbacks() {
- @Override
- public float getMaterialRevealViewFinalAlpha(View revealView) {
- return 0.3f;
- }
- };
mCurrentAnimation = startAnimationToOverlay(fromWorkspaceState,
- Workspace.State.OVERVIEW_HIDDEN, buttonView, toView, toView.getContentView(),
- toView.getRevealView(), null, animated, cb);
+ Workspace.State.OVERVIEW_HIDDEN, buttonView, toView, animated,
+ new PrivateTransitionCallbacks(FINAL_REVEAL_ALPHA_FOR_WIDGETS));
}
/**
@@ -205,16 +199,15 @@ public class LauncherStateTransitionAnimation {
* Creates and starts a new animation to a particular overlay view.
*/
@SuppressLint("NewApi")
- private AnimatorSet startAnimationToOverlay(final Workspace.State fromWorkspaceState,
- final Workspace.State toWorkspaceState, final View buttonView, final View toView,
- final View contentView, final View revealView, final View overlaySearchBarView,
+ private AnimatorSet startAnimationToOverlay(
+ final Workspace.State fromWorkspaceState, final Workspace.State toWorkspaceState,
+ final View buttonView, final BaseContainerView toView,
final boolean animated, final PrivateTransitionCallbacks pCb) {
final AnimatorSet animation = LauncherAnimUtils.createAnimatorSet();
final Resources res = mLauncher.getResources();
final boolean material = Utilities.ATLEAST_LOLLIPOP;
final int revealDuration = res.getInteger(R.integer.config_overlayRevealTime);
- final int itemsAlphaStagger =
- res.getInteger(R.integer.config_overlayItemsAlphaStagger);
+ final int itemsAlphaStagger = res.getInteger(R.integer.config_overlayItemsAlphaStagger);
final View fromView = mLauncher.getWorkspace();
@@ -226,11 +219,15 @@ public class LauncherStateTransitionAnimation {
// Cancel the current animation
cancelAnimation();
- playCommonTransitionAnimations(fromWorkspaceState, toWorkspaceState, fromView, toView,
- overlaySearchBarView, animated, initialized, animation, revealDuration, layerViews);
+ playCommonTransitionAnimations(toWorkspaceState, fromView, toView,
+ animated, initialized, animation, revealDuration, layerViews);
+
+ final View contentView = toView.getContentView();
if (animated && initialized) {
// Setup the reveal view animation
+ final View revealView = toView.getRevealView();
+
int width = revealView.getMeasuredWidth();
int height = revealView.getMeasuredHeight();
float revealRadius = (float) Math.hypot(width / 2, height / 2);
@@ -244,9 +241,9 @@ public class LauncherStateTransitionAnimation {
final float revealViewToXDrift;
final float revealViewToYDrift;
if (material) {
- int[] buttonViewToPanelDelta = Utilities.getCenterDeltaInScreenSpace(revealView,
- buttonView, null);
- revealViewToAlpha = pCb.getMaterialRevealViewFinalAlpha(revealView);
+ int[] buttonViewToPanelDelta = Utilities.getCenterDeltaInScreenSpace(
+ revealView, buttonView, null);
+ revealViewToAlpha = pCb.materialRevealViewFinalAlpha;
revealViewToYDrift = buttonViewToPanelDelta[1];
revealViewToXDrift = buttonViewToPanelDelta[0];
} else {
@@ -271,15 +268,6 @@ public class LauncherStateTransitionAnimation {
layerViews.put(revealView, BUILD_AND_SET_LAYER);
animation.play(panelAlphaAndDrift);
- if (overlaySearchBarView != null) {
- overlaySearchBarView.setAlpha(0f);
- ObjectAnimator searchBarAlpha = ObjectAnimator.ofFloat(overlaySearchBarView, "alpha", 0f, 1f);
- searchBarAlpha.setDuration(revealDuration / 2);
- searchBarAlpha.setInterpolator(new AccelerateInterpolator(1.5f));
- layerViews.put(overlaySearchBarView, BUILD_AND_SET_LAYER);
- animation.play(searchBarAlpha);
- }
-
// Setup the animation for the content view
contentView.setVisibility(View.VISIBLE);
contentView.setAlpha(0f);
@@ -398,8 +386,8 @@ public class LauncherStateTransitionAnimation {
/**
* Plays animations used by various transitions.
*/
- private void playCommonTransitionAnimations(Workspace.State fromWorkspaceState,
- Workspace.State toWorkspaceState, View fromView, View toView, View overlaySearchBarView,
+ private void playCommonTransitionAnimations(
+ Workspace.State toWorkspaceState, View fromView, View toView,
boolean animated, boolean initialized, AnimatorSet animation, int revealDuration,
HashMap<View, Integer> layerViews) {
// Create the workspace animation.
@@ -408,8 +396,10 @@ public class LauncherStateTransitionAnimation {
animated, layerViews);
// Animate the search bar
- startWorkspaceSearchBarAnimation(animation, fromWorkspaceState, toWorkspaceState,
- animated ? revealDuration : 0, overlaySearchBarView);
+ final SearchDropTargetBar.State toSearchBarState =
+ toWorkspaceState.getSearchDropTargetBarState();
+ mLauncher.getSearchDropTargetBar().animateToState(toSearchBarState,
+ animated ? revealDuration : 0, animation);
if (animated && initialized) {
// Play the workspace animation
@@ -446,12 +436,8 @@ public class LauncherStateTransitionAnimation {
final Workspace.State toWorkspaceState, final boolean animated,
final Runnable onCompleteRunnable) {
AllAppsContainerView appsView = mLauncher.getAppsView();
- PrivateTransitionCallbacks cb = new PrivateTransitionCallbacks() {
- @Override
- float getMaterialRevealViewFinalAlpha(View revealView) {
- // No alpha anim from all apps
- return 1f;
- }
+ // No alpha anim from all apps
+ PrivateTransitionCallbacks cb = new PrivateTransitionCallbacks(1f) {
@Override
float getMaterialRevealViewStartFinalRadius() {
int allAppsButtonSize = mLauncher.getDeviceProfile().allAppsButtonVisualSize;
@@ -479,9 +465,8 @@ public class LauncherStateTransitionAnimation {
};
// Only animate the search bar if animating to spring loaded mode from all apps
mCurrentAnimation = startAnimationToWorkspaceFromOverlay(fromWorkspaceState, toWorkspaceState,
- mLauncher.getAllAppsButton(), appsView, appsView.getContentView(),
- appsView.getRevealView(), appsView.getSearchBarView(), animated,
- onCompleteRunnable, cb);
+ mLauncher.getAllAppsButton(), appsView,
+ animated, onCompleteRunnable, cb);
}
/**
@@ -491,11 +476,8 @@ public class LauncherStateTransitionAnimation {
final Workspace.State toWorkspaceState, final boolean animated,
final Runnable onCompleteRunnable) {
final WidgetsContainerView widgetsView = mLauncher.getWidgetsView();
- PrivateTransitionCallbacks cb = new PrivateTransitionCallbacks() {
- @Override
- float getMaterialRevealViewFinalAlpha(View revealView) {
- return 0.3f;
- }
+ PrivateTransitionCallbacks cb =
+ new PrivateTransitionCallbacks(FINAL_REVEAL_ALPHA_FOR_WIDGETS) {
@Override
public AnimatorListenerAdapter getMaterialRevealViewAnimatorListener(
final View revealView, final View widgetsButtonView) {
@@ -507,10 +489,10 @@ public class LauncherStateTransitionAnimation {
};
}
};
- mCurrentAnimation = startAnimationToWorkspaceFromOverlay(fromWorkspaceState,
- toWorkspaceState, mLauncher.getWidgetsButton(), widgetsView,
- widgetsView.getContentView(), widgetsView.getRevealView(), null, animated,
- onCompleteRunnable, cb);
+ mCurrentAnimation = startAnimationToWorkspaceFromOverlay(
+ fromWorkspaceState, toWorkspaceState,
+ mLauncher.getWidgetsButton(), widgetsView,
+ animated, onCompleteRunnable, cb);
}
/**
@@ -528,8 +510,8 @@ public class LauncherStateTransitionAnimation {
// Cancel the current animation
cancelAnimation();
- playCommonTransitionAnimations(fromWorkspaceState, toWorkspaceState, fromWorkspace, null,
- null, animated, animated, animation, revealDuration, layerViews);
+ playCommonTransitionAnimations(toWorkspaceState, fromWorkspace, null,
+ animated, animated, animation, revealDuration, layerViews);
if (animated) {
dispatchOnLauncherTransitionPrepare(fromWorkspace, animated, true);
@@ -597,10 +579,10 @@ public class LauncherStateTransitionAnimation {
/**
* Creates and starts a new animation to the workspace.
*/
- private AnimatorSet startAnimationToWorkspaceFromOverlay(final Workspace.State fromWorkspaceState,
- final Workspace.State toWorkspaceState, final View buttonView,
- final View fromView, final View contentView, final View revealView,
- final View overlaySearchBarView, final boolean animated, final Runnable onCompleteRunnable,
+ private AnimatorSet startAnimationToWorkspaceFromOverlay(
+ final Workspace.State fromWorkspaceState, final Workspace.State toWorkspaceState,
+ final View buttonView, final BaseContainerView fromView,
+ final boolean animated, final Runnable onCompleteRunnable,
final PrivateTransitionCallbacks pCb) {
final AnimatorSet animation = LauncherAnimUtils.createAnimatorSet();
final Resources res = mLauncher.getResources();
@@ -619,10 +601,13 @@ public class LauncherStateTransitionAnimation {
// Cancel the current animation
cancelAnimation();
- playCommonTransitionAnimations(fromWorkspaceState, toWorkspaceState, fromView, toView,
- overlaySearchBarView, animated, initialized, animation, revealDuration, layerViews);
+ playCommonTransitionAnimations(toWorkspaceState, fromView, toView,
+ animated, initialized, animation, revealDuration, layerViews);
if (animated && initialized) {
+ final View revealView = fromView.getRevealView();
+ final View contentView = fromView.getContentView();
+
// hideAppsCustomizeHelper is called in some cases when it is already hidden
// don't perform all these no-op animations. In particularly, this was causing
// the all-apps button to pop in and out.
@@ -670,7 +655,7 @@ public class LauncherStateTransitionAnimation {
// Setup animation for the reveal panel alpha
final float revealViewToAlpha = !material ? 0f :
- pCb.getMaterialRevealViewFinalAlpha(revealView);
+ pCb.materialRevealViewFinalAlpha;
if (revealViewToAlpha != 1f) {
ObjectAnimator panelAlpha = ObjectAnimator.ofFloat(revealView, "alpha",
1f, revealViewToAlpha);
@@ -698,16 +683,6 @@ public class LauncherStateTransitionAnimation {
itemsAlpha.setInterpolator(decelerateInterpolator);
animation.play(itemsAlpha);
- if (overlaySearchBarView != null) {
- overlaySearchBarView.setAlpha(1f);
- ObjectAnimator searchAlpha = ObjectAnimator.ofFloat(overlaySearchBarView, "alpha", 1f, 0f);
- searchAlpha.setDuration(revealDuration / 2);
- searchAlpha.setInterpolator(new AccelerateInterpolator(1.5f));
- searchAlpha.setStartDelay(material ? 0 : itemsAlphaStagger + SINGLE_FRAME_DELAY);
- layerViews.put(overlaySearchBarView, BUILD_AND_SET_LAYER);
- animation.play(searchAlpha);
- }
-
if (material) {
// Animate the all apps button
float finalRadius = pCb.getMaterialRevealViewStartFinalRadius();
@@ -753,9 +728,6 @@ public class LauncherStateTransitionAnimation {
contentView.setTranslationY(0);
contentView.setAlpha(1);
}
- if (overlaySearchBarView != null) {
- overlaySearchBarView.setAlpha(1f);
- }
// This can hold unnecessary references to views.
cleanupAnimation();
@@ -810,41 +782,6 @@ public class LauncherStateTransitionAnimation {
}
/**
- * Coordinates the workspace search bar animation along with the launcher state animation.
- */
- private void startWorkspaceSearchBarAnimation(AnimatorSet animation,
- final Workspace.State fromWorkspaceState, final Workspace.State toWorkspaceState, int duration,
- View overlaySearchBar) {
- final SearchDropTargetBar.State toSearchBarState =
- toWorkspaceState.getSearchDropTargetBarState();
-
- if (overlaySearchBar != null) {
- if (mLauncher.launcherCallbacksProvidesSearch()) {
- if ((toWorkspaceState == Workspace.State.NORMAL) &&
- (fromWorkspaceState == Workspace.State.NORMAL_HIDDEN)) {
- // If we are transitioning from the overlay to the workspace, then show the
- // workspace search bar immediately and let the overlay search bar fade out on
- // top
- mLauncher.getSearchDropTargetBar().animateToState(toSearchBarState, 0);
- return;
- } else if (fromWorkspaceState == Workspace.State.NORMAL) {
- // If we are transitioning from the workspace to the overlay, then keep the
- // workspace search bar visible until the overlay search bar fades in on top
- animation.addListener(new AnimatorListenerAdapter() {
- @Override
- public void onAnimationEnd(Animator animation) {
- mLauncher.getSearchDropTargetBar().animateToState(toSearchBarState, 0);
- }
- });
- return;
- }
- }
- }
- // Fallback to the default search bar animation otherwise
- mLauncher.getSearchDropTargetBar().animateToState(toSearchBarState, duration);
- }
-
- /**
* Dispatches the prepare-transition event to suitable views.
*/
void dispatchOnLauncherTransitionPrepare(View v, boolean animated, boolean toWorkspace) {