summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichael Jurka <mikejurka@google.com>2012-01-23 07:24:27 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-01-23 07:24:27 -0800
commit28c1854896bfd39d850d4ad562361fcc1651516c (patch)
treeaa6fe7496182560e2c76428a5cb654fe7c0a7968 /src
parent3bc21c35fa167ac233e19df0c9a01b0a07173ed8 (diff)
parent9433fa7ebad74320e39bfac6161a68bc850fe161 (diff)
downloadandroid_packages_apps_Trebuchet-28c1854896bfd39d850d4ad562361fcc1651516c.tar.gz
android_packages_apps_Trebuchet-28c1854896bfd39d850d4ad562361fcc1651516c.tar.bz2
android_packages_apps_Trebuchet-28c1854896bfd39d850d4ad562361fcc1651516c.zip
Merge "Speed up All Apps -> Workspace transition"
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher2/AppsCustomizeTabHost.java7
-rw-r--r--src/com/android/launcher2/Launcher.java79
-rw-r--r--src/com/android/launcher2/PagedView.java2
-rw-r--r--src/com/android/launcher2/SearchDropTargetBar.java12
-rw-r--r--src/com/android/launcher2/Workspace.java64
5 files changed, 88 insertions, 76 deletions
diff --git a/src/com/android/launcher2/AppsCustomizeTabHost.java b/src/com/android/launcher2/AppsCustomizeTabHost.java
index 023946b26..caababa8e 100644
--- a/src/com/android/launcher2/AppsCustomizeTabHost.java
+++ b/src/com/android/launcher2/AppsCustomizeTabHost.java
@@ -347,9 +347,8 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
/* LauncherTransitionable overrides */
@Override
- public void onLauncherTransitionStart(Launcher l, Animator animation, boolean toWorkspace) {
+ public void onLauncherTransitionStart(Launcher l, boolean animated, boolean toWorkspace) {
mInTransition = true;
- boolean animated = (animation != null);
mContent.setVisibility(VISIBLE);
@@ -372,9 +371,9 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
}
@Override
- public void onLauncherTransitionEnd(Launcher l, Animator animation, boolean toWorkspace) {
+ public void onLauncherTransitionEnd(Launcher l, boolean animated, boolean toWorkspace) {
mInTransition = false;
- if (animation != null) {
+ if (animated) {
setLayerType(LAYER_TYPE_NONE, null);
}
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index ab2578066..2b9130262 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -2158,6 +2158,18 @@ public final class Launcher extends Activity
}
}
+ private void dispatchOnLauncherTransitionStart(View v, boolean animated, boolean toWorkspace) {
+ if (v instanceof LauncherTransitionable) {
+ ((LauncherTransitionable) v).onLauncherTransitionStart(this, animated, toWorkspace);
+ }
+ }
+
+ private void dispatchOnLauncherTransitionEnd(View v, boolean animated, boolean toWorkspace) {
+ if (v instanceof LauncherTransitionable) {
+ ((LauncherTransitionable) v).onLauncherTransitionEnd(this, animated, toWorkspace);
+ }
+ }
+
/**
* Things to test when changing the following seven functions.
* - Home from workspace
@@ -2203,7 +2215,7 @@ public final class Launcher extends Activity
* Assumes that the view to show is anchored at either the very top or very bottom
* of the screen.
*/
- private void showAppsCustomizeHelper(boolean animated, final boolean springLoaded) {
+ private void showAppsCustomizeHelper(final boolean animated, final boolean springLoaded) {
if (mStateAnimation != null) {
mStateAnimation.cancel();
mStateAnimation = null;
@@ -2214,6 +2226,7 @@ public final class Launcher extends Activity
final int duration = res.getInteger(R.integer.config_appsCustomizeZoomInTime);
final int fadeDuration = res.getInteger(R.integer.config_appsCustomizeFadeInTime);
final float scale = (float) res.getInteger(R.integer.config_appsCustomizeZoomScaleFactor);
+ final View fromView = mWorkspace;
final View toView = mAppsCustomizeTabHost;
final int startDelay =
res.getInteger(R.integer.config_workspaceAppsCustomizeAnimationStagger);
@@ -2260,10 +2273,8 @@ public final class Launcher extends Activity
}
@Override
public void onAnimationEnd(Animator animation) {
- if (toView instanceof LauncherTransitionable) {
- ((LauncherTransitionable) toView).onLauncherTransitionEnd(instance,
- scaleAnim, false);
- }
+ dispatchOnLauncherTransitionEnd(fromView, animated, false);
+ dispatchOnLauncherTransitionEnd(toView, animated, false);
if (!springLoaded && !LauncherApplication.isScreenLarge()) {
// Hide the workspace scrollbar
@@ -2286,14 +2297,14 @@ public final class Launcher extends Activity
}
boolean delayAnim = false;
- LauncherTransitionable lt = (LauncherTransitionable) toView;
final ViewTreeObserver observer;
- lt.onLauncherTransitionStart(instance, mStateAnimation, false);
+ dispatchOnLauncherTransitionStart(fromView, animated, false);
+ dispatchOnLauncherTransitionStart(toView, animated, false);
// If any of the objects being animated haven't been measured/laid out
// yet, delay the animation until we get a layout pass
- if ((lt.getContent().getMeasuredWidth() == 0) ||
+ if ((((LauncherTransitionable) toView).getContent().getMeasuredWidth() == 0) ||
(mWorkspace.getMeasuredWidth() == 0) ||
(toView.getMeasuredWidth() == 0)) {
observer = mWorkspace.getViewTreeObserver();
@@ -2332,16 +2343,16 @@ public final class Launcher extends Activity
toView.setScaleY(1.0f);
toView.setVisibility(View.VISIBLE);
toView.bringToFront();
- if (toView instanceof LauncherTransitionable) {
- ((LauncherTransitionable) toView).onLauncherTransitionStart(instance, null, false);
- ((LauncherTransitionable) toView).onLauncherTransitionEnd(instance, null, false);
-
- if (!springLoaded && !LauncherApplication.isScreenLarge()) {
- // Hide the workspace scrollbar
- mWorkspace.hideScrollingIndicator(true);
- hideDockDivider();
- }
+
+ if (!springLoaded && !LauncherApplication.isScreenLarge()) {
+ // Hide the workspace scrollbar
+ mWorkspace.hideScrollingIndicator(true);
+ hideDockDivider();
}
+ dispatchOnLauncherTransitionStart(fromView, animated, false);
+ dispatchOnLauncherTransitionEnd(fromView, animated, false);
+ dispatchOnLauncherTransitionStart(toView, animated, false);
+ dispatchOnLauncherTransitionEnd(toView, animated, false);
updateWallpaperVisibility(false);
}
}
@@ -2352,13 +2363,12 @@ public final class Launcher extends Activity
* @param animated If true, the transition will be animated.
*/
private void hideAppsCustomizeHelper(
- State toState, boolean animated, final boolean springLoaded) {
+ State toState, final boolean animated, final boolean springLoaded) {
if (mStateAnimation != null) {
mStateAnimation.cancel();
mStateAnimation = null;
}
Resources res = getResources();
- final Launcher instance = this;
final int duration = res.getInteger(R.integer.config_appsCustomizeZoomOutTime);
final int fadeOutDuration =
@@ -2366,6 +2376,7 @@ public final class Launcher extends Activity
final float scaleFactor = (float)
res.getInteger(R.integer.config_appsCustomizeZoomScaleFactor);
final View fromView = mAppsCustomizeTabHost;
+ final View toView = mWorkspace;
Animator workspaceAnim = null;
if (toState == State.WORKSPACE) {
@@ -2396,24 +2407,22 @@ public final class Launcher extends Activity
.setDuration(fadeOutDuration);
alphaAnim.setInterpolator(new AccelerateDecelerateInterpolator());
- if (fromView instanceof LauncherTransitionable) {
- ((LauncherTransitionable) fromView).onLauncherTransitionStart(instance, alphaAnim,
- true);
- }
- alphaAnim.addListener(new AnimatorListenerAdapter() {
+ mStateAnimation = new AnimatorSet();
+
+ dispatchOnLauncherTransitionStart(fromView, animated, true);
+ dispatchOnLauncherTransitionStart(toView, animated, true);
+
+ mStateAnimation.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
updateWallpaperVisibility(true);
fromView.setVisibility(View.GONE);
- if (fromView instanceof LauncherTransitionable) {
- ((LauncherTransitionable) fromView).onLauncherTransitionEnd(instance,
- alphaAnim, true);
- }
+ dispatchOnLauncherTransitionEnd(fromView, animated, true);
+ dispatchOnLauncherTransitionEnd(toView, animated, true);
mWorkspace.hideScrollingIndicator(false);
}
});
- mStateAnimation = new AnimatorSet();
mStateAnimation.playTogether(scaleAnim, alphaAnim);
if (workspaceAnim != null) {
mStateAnimation.play(workspaceAnim);
@@ -2421,10 +2430,10 @@ public final class Launcher extends Activity
mStateAnimation.start();
} else {
fromView.setVisibility(View.GONE);
- if (fromView instanceof LauncherTransitionable) {
- ((LauncherTransitionable) fromView).onLauncherTransitionStart(instance, null, true);
- ((LauncherTransitionable) fromView).onLauncherTransitionEnd(instance, null, true);
- }
+ dispatchOnLauncherTransitionStart(fromView, animated, false);
+ dispatchOnLauncherTransitionEnd(fromView, animated, false);
+ dispatchOnLauncherTransitionStart(toView, animated, false);
+ dispatchOnLauncherTransitionEnd(toView, animated, false);
mWorkspace.hideScrollingIndicator(false);
}
}
@@ -3366,6 +3375,6 @@ public final class Launcher extends Activity
interface LauncherTransitionable {
View getContent();
- void onLauncherTransitionStart(Launcher l, Animator animation, boolean toWorkspace);
- void onLauncherTransitionEnd(Launcher l, Animator animation, boolean toWorkspace);
+ void onLauncherTransitionStart(Launcher l, boolean animated, boolean toWorkspace);
+ void onLauncherTransitionEnd(Launcher l, boolean animated, boolean toWorkspace);
}
diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java
index acfce1f6b..903169f6f 100644
--- a/src/com/android/launcher2/PagedView.java
+++ b/src/com/android/launcher2/PagedView.java
@@ -1682,6 +1682,7 @@ public abstract class PagedView extends ViewGroup {
if (mHasScrollIndicator && mScrollIndicator == null) {
ViewGroup parent = (ViewGroup) getParent();
mScrollIndicator = (View) (parent.findViewById(R.id.paged_view_indicator));
+ mScrollIndicator.setLayerType(View.LAYER_TYPE_HARDWARE, null);
mHasScrollIndicator = mScrollIndicator != null;
if (mHasScrollIndicator) {
mScrollIndicator.setVisibility(View.VISIBLE);
@@ -1807,7 +1808,6 @@ public abstract class PagedView extends ViewGroup {
indicatorPos += indicatorCenterOffset;
}
mScrollIndicator.setTranslationX(indicatorPos);
- mScrollIndicator.invalidate();
}
public void showScrollIndicatorTrack() {
diff --git a/src/com/android/launcher2/SearchDropTargetBar.java b/src/com/android/launcher2/SearchDropTargetBar.java
index 3a7f24b09..03ca38fb4 100644
--- a/src/com/android/launcher2/SearchDropTargetBar.java
+++ b/src/com/android/launcher2/SearchDropTargetBar.java
@@ -129,14 +129,26 @@ public class SearchDropTargetBar extends FrameLayout implements DragController.D
@Override
public void onAnimationStart(Animator animation) {
mQSBSearchBar.setVisibility(View.VISIBLE);
+ mQSBSearchBar.setLayerType(View.LAYER_TYPE_HARDWARE, null);
+ }
+
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ mQSBSearchBar.setLayerType(View.LAYER_TYPE_NONE, null);
}
});
mQSBSearchBarFadeOutAnim = ObjectAnimator.ofFloat(mQSBSearchBar, "alpha", 0f);
mQSBSearchBarFadeOutAnim.setDuration(sTransitionOutDuration);
mQSBSearchBarFadeOutAnim.addListener(new AnimatorListenerAdapter() {
@Override
+ public void onAnimationStart(Animator animation) {
+ mQSBSearchBar.setLayerType(View.LAYER_TYPE_HARDWARE, null);
+ }
+
+ @Override
public void onAnimationEnd(Animator animation) {
mQSBSearchBar.setVisibility(View.INVISIBLE);
+ mQSBSearchBar.setLayerType(View.LAYER_TYPE_NONE, null);
}
});
}
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 6fb664a05..4ecc1a528 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -78,7 +78,7 @@ import java.util.List;
*/
public class Workspace extends SmoothPagedView
implements DropTarget, DragSource, DragScroller, View.OnTouchListener,
- DragController.DragListener {
+ DragController.DragListener, LauncherTransitionable {
@SuppressWarnings({"UnusedDeclaration"})
private static final String TAG = "Launcher.Workspace";
@@ -160,8 +160,6 @@ public class Workspace extends SmoothPagedView
private State mState = State.NORMAL;
private boolean mIsSwitchingState = false;
- private AnimatorListener mChangeStateAnimationListener;
-
boolean mAnimatingViewIntoPlace = false;
boolean mIsDragOccuring = false;
boolean mChildrenLayersEnabled = true;
@@ -392,20 +390,6 @@ public class Workspace extends SmoothPagedView
// In this case, we will skip drawing background protection
}
- mChangeStateAnimationListener = new AnimatorListenerAdapter() {
- @Override
- public void onAnimationStart(Animator animation) {
- mIsSwitchingState = true;
- }
-
- @Override
- public void onAnimationEnd(Animator animation) {
- mIsSwitchingState = false;
- mWallpaperOffset.setOverrideHorizontalCatchupConstant(false);
- updateChildrenLayersEnabled();
- }
- };
-
mWallpaperOffset = new WallpaperOffsetInterpolator();
Display display = mLauncher.getWindowManager().getDefaultDisplay();
mDisplayWidth = display.getWidth();
@@ -1635,26 +1619,10 @@ public class Workspace extends SmoothPagedView
cl.setBackgroundAlphaMultiplier(finalAlphaMultiplierValue);
cl.setAlpha(finalAlpha);
cl.setRotationY(rotation);
- mChangeStateAnimationListener.onAnimationEnd(null);
}
}
if (animated) {
- anim.addListener(new AnimatorListenerAdapter() {
- @Override
- public void onAnimationEnd(android.animation.Animator animation) {
- // The above code to determine initialAlpha and finalAlpha will ensure that only
- // the current page is visible during (and subsequently, after) the transition
- // animation. If fade adjacent pages is disabled, then re-enable the page
- // visibility after the transition animation.
- if (!mFadeInAdjacentScreens && stateIsNormal && oldStateIsSmall) {
- for (int i = 0; i < getChildCount(); i++) {
- final CellLayout cl = (CellLayout) getChildAt(i);
- cl.setAlpha(1f);
- }
- }
- }
- });
for (int index = 0; index < getChildCount(); index++) {
final int i = index;
final CellLayout cl = (CellLayout) getChildAt(i);
@@ -1710,9 +1678,6 @@ public class Workspace extends SmoothPagedView
}
}
anim.setStartDelay(delay);
- // If we call this when we're not animated, onAnimationEnd is never called on
- // the listener; make sure we only use the listener when we're actually animating
- anim.addListener(mChangeStateAnimationListener);
}
if (stateIsSpringLoaded) {
@@ -1728,6 +1693,33 @@ public class Workspace extends SmoothPagedView
return anim;
}
+ @Override
+ public void onLauncherTransitionStart(Launcher l, boolean animated, boolean toWorkspace) {
+ mIsSwitchingState = true;
+ }
+
+ @Override
+ public void onLauncherTransitionEnd(Launcher l, boolean animated, boolean toWorkspace) {
+ mIsSwitchingState = false;
+ mWallpaperOffset.setOverrideHorizontalCatchupConstant(false);
+ updateChildrenLayersEnabled();
+ // The code in getChangeStateAnimation to determine initialAlpha and finalAlpha will ensure
+ // ensure that only the current page is visible during (and subsequently, after) the
+ // transition animation. If fade adjacent pages is disabled, then re-enable the page
+ // visibility after the transition animation.
+ if (!mFadeInAdjacentScreens) {
+ for (int i = 0; i < getChildCount(); i++) {
+ final CellLayout cl = (CellLayout) getChildAt(i);
+ cl.setAlpha(1f);
+ }
+ }
+ }
+
+ @Override
+ public View getContent() {
+ return this;
+ }
+
/**
* Draw the View v into the given Canvas.
*