summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/LauncherStateTransitionAnimation.java
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2016-01-29 13:14:14 -0800
committerSunny Goyal <sunnygoyal@google.com>2016-02-08 14:55:22 -0800
commit0ac7ede56afebe4401c0636196f5844be573ad68 (patch)
treec4bdfce0b5f788880354845ab51ae293bd608d1b /src/com/android/launcher3/LauncherStateTransitionAnimation.java
parent0e0498031092488ff166145c12ce36cc0a80c490 (diff)
downloadandroid_packages_apps_Trebuchet-0ac7ede56afebe4401c0636196f5844be573ad68.tar.gz
android_packages_apps_Trebuchet-0ac7ede56afebe4401c0636196f5844be573ad68.tar.bz2
android_packages_apps_Trebuchet-0ac7ede56afebe4401c0636196f5844be573ad68.zip
Merging search bar with all apps
Change-Id: I78577124cd3c05d52669c3e52b0294d6eb1d194d
Diffstat (limited to 'src/com/android/launcher3/LauncherStateTransitionAnimation.java')
-rw-r--r--src/com/android/launcher3/LauncherStateTransitionAnimation.java153
1 files changed, 49 insertions, 104 deletions
diff --git a/src/com/android/launcher3/LauncherStateTransitionAnimation.java b/src/com/android/launcher3/LauncherStateTransitionAnimation.java
index 83b12a99d..30cae3114 100644
--- a/src/com/android/launcher3/LauncherStateTransitionAnimation.java
+++ b/src/com/android/launcher3/LauncherStateTransitionAnimation.java
@@ -80,13 +80,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;
}
@@ -97,7 +102,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;
@@ -121,11 +126,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;
@@ -152,8 +153,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);
}
/**
@@ -164,15 +164,9 @@ public class LauncherStateTransitionAnimation {
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));
}
/**
@@ -200,16 +194,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();
@@ -227,13 +220,17 @@ public class LauncherStateTransitionAnimation {
animated, layerViews);
// Animate the search bar
- startWorkspaceSearchBarAnimation(animation, fromWorkspaceState, toWorkspaceState,
- animated ? revealDuration : 0, overlaySearchBarView);
+ startWorkspaceSearchBarAnimation(
+ toWorkspaceState, animated ? revealDuration : 0, animation);
Animator updateTransitionStepAnim = dispatchOnLauncherTransitionStepAnim(fromView, toView);
+ 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);
@@ -247,9 +244,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 {
@@ -274,15 +271,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);
@@ -430,12 +418,8 @@ public class LauncherStateTransitionAnimation {
final Workspace.State toWorkspaceState, final int toWorkspacePage,
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;
@@ -463,9 +447,8 @@ public class LauncherStateTransitionAnimation {
};
// Only animate the search bar if animating to spring loaded mode from all apps
mCurrentAnimation = startAnimationToWorkspaceFromOverlay(fromWorkspaceState, toWorkspaceState,
- toWorkspacePage, mLauncher.getAllAppsButton(), appsView, appsView.getContentView(),
- appsView.getRevealView(), appsView.getSearchBarView(), animated,
- onCompleteRunnable, cb);
+ toWorkspacePage, mLauncher.getAllAppsButton(), appsView,
+ animated, onCompleteRunnable, cb);
}
/**
@@ -475,11 +458,8 @@ public class LauncherStateTransitionAnimation {
final Workspace.State toWorkspaceState, final int toWorkspacePage,
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) {
@@ -491,19 +471,20 @@ public class LauncherStateTransitionAnimation {
};
}
};
- mCurrentAnimation = startAnimationToWorkspaceFromOverlay(fromWorkspaceState,
- toWorkspaceState, toWorkspacePage, mLauncher.getWidgetsButton(), widgetsView,
- widgetsView.getContentView(), widgetsView.getRevealView(), null, animated,
- onCompleteRunnable, cb);
+ mCurrentAnimation = startAnimationToWorkspaceFromOverlay(
+ fromWorkspaceState, toWorkspaceState,
+ toWorkspacePage, mLauncher.getWidgetsButton(), widgetsView,
+ animated, onCompleteRunnable, cb);
}
/**
* Creates and starts a new animation to the workspace.
*/
- private AnimatorSet startAnimationToWorkspaceFromOverlay(final Workspace.State fromWorkspaceState,
- final Workspace.State toWorkspaceState, final int toWorkspacePage, 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 int toWorkspacePage,
+ 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();
@@ -528,8 +509,8 @@ public class LauncherStateTransitionAnimation {
toWorkspacePage, animated, layerViews);
// Animate the search bar
- startWorkspaceSearchBarAnimation(animation, fromWorkspaceState, toWorkspaceState,
- animated ? revealDuration : 0, overlaySearchBarView);
+ startWorkspaceSearchBarAnimation(
+ toWorkspaceState, animated ? revealDuration : 0, animation);
Animator updateTransitionStepAnim = dispatchOnLauncherTransitionStepAnim(fromView, toView);
@@ -540,6 +521,8 @@ public class LauncherStateTransitionAnimation {
}
animation.play(updateTransitionStepAnim);
+ 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
@@ -588,7 +571,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);
@@ -616,16 +599,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();
@@ -671,9 +644,6 @@ public class LauncherStateTransitionAnimation {
contentView.setTranslationY(0);
contentView.setAlpha(1);
}
- if (overlaySearchBarView != null) {
- overlaySearchBarView.setAlpha(1f);
- }
// This can hold unnecessary references to views.
cleanupAnimation();
@@ -729,36 +699,11 @@ 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) {
+ private void startWorkspaceSearchBarAnimation(
+ final Workspace.State toWorkspaceState, int duration, AnimatorSet animation) {
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);
+ mLauncher.getSearchDropTargetBar().animateToState(toSearchBarState, duration, animation);
}
/**