Merge "optimizing transitions in Launcher" into honeycomb

This commit is contained in:
Michael Jurka authored and Android (Google) Code Review committed 2011-02-03 12:47:53 -08:00
commit 4fcae11dca
4 files changed
+243 -93

No files matched your search

+16
View File
@@ -803,6 +803,10 @@ public class CellLayout extends ViewGroup {
return mBackgroundAlpha; return mBackgroundAlpha;
} }
public void setFastBackgroundAlpha(float alpha) {
mBackgroundAlpha = alpha;
}
public void setBackgroundAlphaMultiplier(float multiplier) { public void setBackgroundAlphaMultiplier(float multiplier) {
mBackgroundAlphaMultiplier = multiplier; mBackgroundAlphaMultiplier = multiplier;
} }
@@ -829,6 +833,11 @@ public class CellLayout extends ViewGroup {
super.setAlpha(alpha); super.setAlpha(alpha);
} }
public void setFastAlpha(float alpha) {
setFastChildrenAlpha(alpha);
super.setFastAlpha(alpha);
}
private void setChildrenAlpha(float alpha) { private void setChildrenAlpha(float alpha) {
final int childCount = getChildCount(); final int childCount = getChildCount();
for (int i = 0; i < childCount; i++) { for (int i = 0; i < childCount; i++) {
@@ -836,6 +845,13 @@ public class CellLayout extends ViewGroup {
} }
} }
private void setFastChildrenAlpha(float alpha) {
final int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
getChildAt(i).setFastAlpha(alpha);
}
}
public View getChildAt(int x, int y) { public View getChildAt(int x, int y) {
return mChildren.getChildAt(x, y); return mChildren.getChildAt(x, y);
} }
+59 -27
View File
@@ -17,13 +17,10 @@
package com.android.launcher2; package com.android.launcher2;
import java.io.DataInputStream; import com.android.common.Search;
import java.io.DataOutputStream; import com.android.launcher.R;
import java.io.FileNotFoundException; import com.android.launcher2.CustomizePagedView.CustomizationType;
import java.io.IOException; import com.android.launcher2.Workspace.ShrinkState;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import android.animation.Animator; import android.animation.Animator;
import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorListenerAdapter;
@@ -31,6 +28,7 @@ import android.animation.AnimatorSet;
import android.animation.ObjectAnimator; import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder; import android.animation.PropertyValuesHolder;
import android.animation.ValueAnimator; import android.animation.ValueAnimator;
import android.animation.ValueAnimator.AnimatorUpdateListener;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.Dialog; import android.app.Dialog;
@@ -106,10 +104,13 @@ import android.widget.Toast;
import android.widget.TabHost.OnTabChangeListener; import android.widget.TabHost.OnTabChangeListener;
import android.widget.TabHost.TabContentFactory; import android.widget.TabHost.TabContentFactory;
import com.android.common.Search; import java.io.DataInputStream;
import com.android.launcher.R; import java.io.DataOutputStream;
import com.android.launcher2.CustomizePagedView.CustomizationType; import java.io.FileNotFoundException;
import com.android.launcher2.Workspace.ShrinkState; import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
/** /**
@@ -2674,22 +2675,36 @@ public final class Launcher extends Activity
} }
if (animated) { if (animated) {
ValueAnimator scaleAnim = ObjectAnimator.ofPropertyValuesHolder(toView, final float oldScaleX = toView.getScaleX();
PropertyValuesHolder.ofFloat("scaleX", scale, 1.0f), final float oldScaleY = toView.getScaleY();
PropertyValuesHolder.ofFloat("scaleY", scale, 1.0f));
scaleAnim.setDuration(duration); ValueAnimator scaleAnim = ValueAnimator.ofFloat(0f, 1f).setDuration(duration);
scaleAnim.setInterpolator(new Workspace.ZoomOutInterpolator());
scaleAnim.addUpdateListener(new AnimatorUpdateListener() {
public void onAnimationUpdate(ValueAnimator animation) {
final float b = (Float) animation.getAnimatedValue();
final float a = 1f - b;
((View) toView.getParent()).fastInvalidate();
toView.setFastScaleX(a * oldScaleX + b * 1f);
toView.setFastScaleY(a * oldScaleY + b * 1f);
}
});
if (toAllApps) { if (toAllApps) {
toView.setAlpha(0f); toView.setAlpha(0f);
ObjectAnimator alphaAnim = ObjectAnimator.ofPropertyValuesHolder(toView, ValueAnimator alphaAnim = ValueAnimator.ofFloat(0f, 1f).setDuration(duration);
PropertyValuesHolder.ofFloat("alpha", 1.0f));
alphaAnim.setInterpolator(new DecelerateInterpolator(1.0f)); alphaAnim.setInterpolator(new DecelerateInterpolator(1.0f));
alphaAnim.setDuration(duration); alphaAnim.addUpdateListener(new AnimatorUpdateListener() {
public void onAnimationUpdate(ValueAnimator animation) {
final float b = (Float) animation.getAnimatedValue();
final float a = 1f - b;
// don't need to invalidate because we do so above
toView.setFastAlpha(a * 0f + b * 1f);
}
});
alphaAnim.start(); alphaAnim.start();
} }
scaleAnim.setInterpolator(new Workspace.ZoomOutInterpolator());
// Only use hardware layers in portrait mode, they don't give any gains in landscape // Only use hardware layers in portrait mode, they don't give any gains in landscape
if (mWorkspace.getWidth() < mWorkspace.getHeight()) { if (mWorkspace.getWidth() < mWorkspace.getHeight()) {
toView.setLayerType(View.LAYER_TYPE_HARDWARE, null); toView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
@@ -2760,7 +2775,7 @@ public final class Launcher extends Activity
res.getInteger(R.integer.config_allAppsZoomOutTime) : res.getInteger(R.integer.config_allAppsZoomOutTime) :
res.getInteger(R.integer.config_customizeZoomOutTime); res.getInteger(R.integer.config_customizeZoomOutTime);
float scaleFactor = fromAllApps ? final float scaleFactor = fromAllApps ?
(float) res.getInteger(R.integer.config_allAppsZoomScaleFactor) : (float) res.getInteger(R.integer.config_allAppsZoomScaleFactor) :
(float) res.getInteger(R.integer.config_customizeZoomScaleFactor); (float) res.getInteger(R.integer.config_customizeZoomScaleFactor);
@@ -2778,16 +2793,33 @@ public final class Launcher extends Activity
if (animated) { if (animated) {
if (mStateAnimation != null) mStateAnimation.cancel(); if (mStateAnimation != null) mStateAnimation.cancel();
mStateAnimation = new AnimatorSet(); mStateAnimation = new AnimatorSet();
ValueAnimator scaleAnim = ObjectAnimator.ofPropertyValuesHolder(fromView,
PropertyValuesHolder.ofFloat("scaleX", scaleFactor),
PropertyValuesHolder.ofFloat("scaleY", scaleFactor));
scaleAnim.setDuration(duration);
scaleAnim.setInterpolator(new Workspace.ZoomInInterpolator());
ValueAnimator alphaAnim = ObjectAnimator.ofPropertyValuesHolder(fromView, final float oldScaleX = fromView.getScaleX();
PropertyValuesHolder.ofFloat("alpha", 1.0f, 0.0f)); final float oldScaleY = fromView.getScaleY();
ValueAnimator scaleAnim = ValueAnimator.ofFloat(0f, 1f).setDuration(duration);
scaleAnim.setInterpolator(new Workspace.ZoomInInterpolator());
scaleAnim.addUpdateListener(new AnimatorUpdateListener() {
public void onAnimationUpdate(ValueAnimator animation) {
final float b = (Float) animation.getAnimatedValue();
final float a = 1f - b;
((View)fromView.getParent()).fastInvalidate();
fromView.setFastScaleX(a * oldScaleX + b * scaleFactor);
fromView.setFastScaleY(a * oldScaleY + b * scaleFactor);
}
});
ValueAnimator alphaAnim = ValueAnimator.ofFloat(0f, 1f);
alphaAnim.setDuration(res.getInteger(R.integer.config_allAppsFadeOutTime)); alphaAnim.setDuration(res.getInteger(R.integer.config_allAppsFadeOutTime));
alphaAnim.setInterpolator(new DecelerateInterpolator(2.0f)); alphaAnim.setInterpolator(new DecelerateInterpolator(2.0f));
alphaAnim.addUpdateListener(new AnimatorUpdateListener() {
public void onAnimationUpdate(ValueAnimator animation) {
final float b = (Float) animation.getAnimatedValue();
final float a = 1f - b;
// don't need to invalidate because we do so above
fromView.setFastAlpha(a * 1f + b * 0f);
}
});
fromView.setLayerType(View.LAYER_TYPE_HARDWARE, null); fromView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
alphaAnim.addListener(new AnimatorListenerAdapter() { alphaAnim.addListener(new AnimatorListenerAdapter() {
@Override @Override
+4 -3
View File
@@ -16,6 +16,8 @@
package com.android.launcher2; package com.android.launcher2;
import com.android.launcher.R;
import android.animation.ObjectAnimator; import android.animation.ObjectAnimator;
import android.content.Context; import android.content.Context;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
@@ -30,8 +32,7 @@ import android.os.HandlerThread;
import android.os.Message; import android.os.Message;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.widget.Checkable; import android.widget.Checkable;
import android.widget.TextView;
import com.android.launcher.R;
@@ -39,7 +40,7 @@ import com.android.launcher.R;
* An icon on a PagedView, specifically for items in the launcher's paged view (with compound * An icon on a PagedView, specifically for items in the launcher's paged view (with compound
* drawables on the top). * drawables on the top).
*/ */
public class PagedViewIcon extends CachedTextView implements Checkable { public class PagedViewIcon extends TextView implements Checkable {
private static final String TAG = "PagedViewIcon"; private static final String TAG = "PagedViewIcon";
// holographic outline // holographic outline
+164 -63
View File
@@ -1363,24 +1363,24 @@ public class Workspace extends SmoothPagedView
float totalWidth = screenCount * scaledPageWidth + (screenCount - 1) * extraScaledSpacing; float totalWidth = screenCount * scaledPageWidth + (screenCount - 1) * extraScaledSpacing;
boolean isPortrait = getMeasuredHeight() > getMeasuredWidth(); boolean isPortrait = getMeasuredHeight() > getMeasuredWidth();
float newY = (isPortrait ? float y = (isPortrait ?
getResources().getDimension(R.dimen.allAppsSmallScreenVerticalMarginPortrait) : getResources().getDimension(R.dimen.allAppsSmallScreenVerticalMarginPortrait) :
getResources().getDimension(R.dimen.allAppsSmallScreenVerticalMarginLandscape)); getResources().getDimension(R.dimen.allAppsSmallScreenVerticalMarginLandscape));
float finalAlpha = 1.0f; float finalAlpha = 1.0f;
float extraShrinkFactor = 1.0f; float extraShrinkFactor = 1.0f;
if (shrinkState == ShrinkState.BOTTOM_VISIBLE) { if (shrinkState == ShrinkState.BOTTOM_VISIBLE) {
newY = screenHeight - newY - scaledPageHeight; y = screenHeight - y - scaledPageHeight;
} else if (shrinkState == ShrinkState.BOTTOM_HIDDEN) { } else if (shrinkState == ShrinkState.BOTTOM_HIDDEN) {
// We shrink and disappear to nothing in the case of all apps // We shrink and disappear to nothing in the case of all apps
// (which is when we shrink to the bottom) // (which is when we shrink to the bottom)
newY = screenHeight - newY - scaledPageHeight; y = screenHeight - y - scaledPageHeight;
finalAlpha = 0.0f; finalAlpha = 0.0f;
} else if (shrinkState == ShrinkState.MIDDLE) { } else if (shrinkState == ShrinkState.MIDDLE) {
newY = screenHeight / 2 - scaledPageHeight / 2; y = screenHeight / 2 - scaledPageHeight / 2;
finalAlpha = 1.0f; finalAlpha = 1.0f;
} else if (shrinkState == ShrinkState.TOP) { } else if (shrinkState == ShrinkState.TOP) {
newY = (isPortrait ? y = (isPortrait ?
getResources().getDimension(R.dimen.customizeSmallScreenVerticalMarginPortrait) : getResources().getDimension(R.dimen.customizeSmallScreenVerticalMarginPortrait) :
getResources().getDimension(R.dimen.customizeSmallScreenVerticalMarginLandscape)); getResources().getDimension(R.dimen.customizeSmallScreenVerticalMarginLandscape));
} }
@@ -1396,18 +1396,34 @@ public class Workspace extends SmoothPagedView
// At the same time, the screens become greyed/dimmed // At the same time, the screens become greyed/dimmed
// newX is initialized to the left-most position of the centered screens // newX is initialized to the left-most position of the centered screens
float newX = mScroller.getFinalX() + screenWidth / 2 - totalWidth / 2; float x = mScroller.getFinalX() + screenWidth / 2 - totalWidth / 2;
// We are going to scale about the center of the view, so we need to adjust the positions // We are going to scale about the center of the view, so we need to adjust the positions
// of the views accordingly // of the views accordingly
newX -= (pageWidth - scaledPageWidth) / 2.0f; x -= (pageWidth - scaledPageWidth) / 2.0f;
newY -= (pageHeight - scaledPageHeight) / 2.0f; y -= (pageHeight - scaledPageHeight) / 2.0f;
if (mAnimator != null) { if (mAnimator != null) {
mAnimator.cancel(); mAnimator.cancel();
} }
mAnimator = new AnimatorSet(); mAnimator = new AnimatorSet();
final float[] oldXs = new float[getChildCount()];
final float[] oldYs = new float[getChildCount()];
final float[] oldScaleXs = new float[getChildCount()];
final float[] oldScaleYs = new float[getChildCount()];
final float[] oldBackgroundAlphas = new float[getChildCount()];
final float[] oldAlphas = new float[getChildCount()];
final float[] oldRotationYs = new float[getChildCount()];
final float[] newXs = new float[getChildCount()];
final float[] newYs = new float[getChildCount()];
final float[] newScaleXs = new float[getChildCount()];
final float[] newScaleYs = new float[getChildCount()];
final float[] newBackgroundAlphas = new float[getChildCount()];
final float[] newAlphas = new float[getChildCount()];
final float[] newRotationYs = new float[getChildCount()];
for (int i = 0; i < screenCount; i++) { for (int i = 0; i < screenCount; i++) {
final CellLayout cl = (CellLayout) getChildAt(i); final CellLayout cl = (CellLayout) getChildAt(i);
@@ -1415,33 +1431,33 @@ public class Workspace extends SmoothPagedView
float rotationScaleX = (float) (1.0f / Math.cos(Math.PI * rotation / 180.0f)); float rotationScaleX = (float) (1.0f / Math.cos(Math.PI * rotation / 180.0f));
float rotationScaleY = getYScaleForScreen(i); float rotationScaleY = getYScaleForScreen(i);
if (animated) { oldAlphas[i] = cl.getAlpha();
ObjectAnimator animWithInterpolator = ObjectAnimator.ofPropertyValuesHolder(cl, newAlphas[i] = finalAlpha;
PropertyValuesHolder.ofFloat("x", newX), if (animated && !(oldAlphas[i] == 0f && newAlphas[i] == 0f)) {
PropertyValuesHolder.ofFloat("y", newY), oldXs[i] = cl.getX();
PropertyValuesHolder.ofFloat("scaleX", oldYs[i] = cl.getY();
SHRINK_FACTOR * rotationScaleX * extraShrinkFactor), oldScaleXs[i] = cl.getScaleX();
PropertyValuesHolder.ofFloat("scaleY", oldScaleYs[i] = cl.getScaleY();
SHRINK_FACTOR * rotationScaleY * extraShrinkFactor), oldBackgroundAlphas[i] = cl.getBackgroundAlpha();
PropertyValuesHolder.ofFloat("backgroundAlpha", finalAlpha), oldRotationYs[i] = cl.getRotationY();
PropertyValuesHolder.ofFloat("alpha", finalAlpha), newXs[i] = x;
PropertyValuesHolder.ofFloat("rotationY", rotation)); newYs[i] = y;
newScaleXs[i] = SHRINK_FACTOR * rotationScaleX * extraShrinkFactor;
animWithInterpolator.setDuration(duration); newScaleYs[i] = SHRINK_FACTOR * rotationScaleY * extraShrinkFactor;
animWithInterpolator.setInterpolator(mZoomOutInterpolator); newBackgroundAlphas[i] = finalAlpha;
mAnimator.playTogether(animWithInterpolator); newRotationYs[i] = rotation;
} else { } else {
cl.setX((int)newX); cl.setX((int)x);
cl.setY((int)newY); cl.setY((int)y);
cl.setScaleX(SHRINK_FACTOR * rotationScaleX * extraShrinkFactor); cl.setScaleX(SHRINK_FACTOR * rotationScaleX * extraShrinkFactor);
cl.setScaleY(SHRINK_FACTOR * rotationScaleY * extraShrinkFactor); cl.setScaleY(SHRINK_FACTOR * rotationScaleY * extraShrinkFactor);
cl.setBackgroundAlpha(finalAlpha); cl.setBackgroundAlpha(finalAlpha);
cl.setAlpha(finalAlpha); cl.setAlpha(finalAlpha);
cl.setRotationY(rotation); cl.setRotationY(rotation);
mShrinkAnimationListener.onAnimationEnd(null); if (!animated) mShrinkAnimationListener.onAnimationEnd(null);
} }
// increment newX for the next screen // increment newX for the next screen
newX += scaledPageWidth + extraScaledSpacing; x += scaledPageWidth + extraScaledSpacing;
} }
float wallpaperOffset = 0.5f; float wallpaperOffset = 0.5f;
@@ -1471,21 +1487,46 @@ public class Workspace extends SmoothPagedView
break; break;
} }
setLayoutScale(1.0f);
if (animated) { if (animated) {
mWallpaperOffset.setHorizontalCatchupConstant(0.46f); mWallpaperOffset.setHorizontalCatchupConstant(0.46f);
mWallpaperOffset.setOverrideHorizontalCatchupConstant(true); mWallpaperOffset.setOverrideHorizontalCatchupConstant(true);
}
setLayoutScale(1.0f);
if (animated) {
mSyncWallpaperOffsetWithScroll = false; mSyncWallpaperOffsetWithScroll = false;
ObjectAnimator wallpaperAnim = ObjectAnimator.ofPropertyValuesHolder(this,
PropertyValuesHolder.ofFloat("verticalWallpaperOffset", wallpaperOffset),
PropertyValuesHolder.ofFloat("horizontalWallpaperOffset", 0.5f));
mAnimator.play(wallpaperAnim);
wallpaperAnim.setDuration(duration); ValueAnimator animWithInterpolator =
wallpaperAnim.setInterpolator(mZoomOutInterpolator); ValueAnimator.ofFloat(0f, 1f).setDuration(duration);
animWithInterpolator.setInterpolator(mZoomOutInterpolator);
final float oldHorizontalWallpaperOffset = getHorizontalWallpaperOffset();
final float oldVerticalWallpaperOffset = getVerticalWallpaperOffset();
final float newHorizontalWallpaperOffset = 0.5f;
final float newVerticalWallpaperOffset = wallpaperOffset;
animWithInterpolator.addUpdateListener(new AnimatorUpdateListener() {
public void onAnimationUpdate(ValueAnimator animation) {
fastInvalidate();
final float b = (Float) animation.getAnimatedValue();
final float a = 1f - b;
setHorizontalWallpaperOffset(
a * oldHorizontalWallpaperOffset + b * newHorizontalWallpaperOffset);
setVerticalWallpaperOffset(
a * oldVerticalWallpaperOffset + b * newVerticalWallpaperOffset);
for (int i = 0; i < screenCount; i++) {
if (oldAlphas[i] == 0f && newAlphas[i] == 0f) continue;
final CellLayout cl = (CellLayout) getChildAt(i);
cl.fastInvalidate();
cl.setFastX(a * oldXs[i] + b * newXs[i]);
cl.setFastY(a * oldYs[i] + b * newYs[i]);
cl.setFastScaleX(a * oldScaleXs[i] + b * newScaleXs[i]);
cl.setFastScaleY(a * oldScaleYs[i] + b * newScaleYs[i]);
cl.setFastBackgroundAlpha(
a * oldBackgroundAlphas[i] + b * newBackgroundAlphas[i]);
cl.setFastAlpha(a * oldAlphas[i] + b * newAlphas[i]);
cl.setFastRotationY(a * oldRotationYs[i] + b * newRotationYs[i]);
}
}
});
mAnimator.playTogether(animWithInterpolator);
mAnimator.addListener(mShrinkAnimationListener); mAnimator.addListener(mShrinkAnimationListener);
mAnimator.start(); mAnimator.start();
} else { } else {
@@ -1687,6 +1728,23 @@ public class Workspace extends SmoothPagedView
final int duration = getResources().getInteger(R.integer.config_workspaceUnshrinkTime); final int duration = getResources().getInteger(R.integer.config_workspaceUnshrinkTime);
final float[] oldTranslationXs = new float[getChildCount()];
final float[] oldTranslationYs = new float[getChildCount()];
final float[] oldScaleXs = new float[getChildCount()];
final float[] oldScaleYs = new float[getChildCount()];
final float[] oldBackgroundAlphas = new float[getChildCount()];
final float[] oldBackgroundAlphaMultipliers = new float[getChildCount()];
final float[] oldAlphas = new float[getChildCount()];
final float[] oldRotationYs = new float[getChildCount()];
final float[] newTranslationXs = new float[getChildCount()];
final float[] newTranslationYs = new float[getChildCount()];
final float[] newScaleXs = new float[getChildCount()];
final float[] newScaleYs = new float[getChildCount()];
final float[] newBackgroundAlphas = new float[getChildCount()];
final float[] newBackgroundAlphaMultipliers = new float[getChildCount()];
final float[] newAlphas = new float[getChildCount()];
final float[] newRotationYs = new float[getChildCount()];
for (int i = 0; i < screenCount; i++) { for (int i = 0; i < screenCount; i++) {
final CellLayout cl = (CellLayout)getChildAt(i); final CellLayout cl = (CellLayout)getChildAt(i);
float finalAlphaValue = (i == mCurrentPage) ? 1.0f : 0.0f; float finalAlphaValue = (i == mCurrentPage) ? 1.0f : 0.0f;
@@ -1703,25 +1761,24 @@ public class Workspace extends SmoothPagedView
float translation = getOffsetXForRotation(rotation, cl.getWidth(), cl.getHeight()); float translation = getOffsetXForRotation(rotation, cl.getWidth(), cl.getHeight());
if (animated) { oldAlphas[i] = cl.getAlpha();
ObjectAnimator animWithInterpolator = ObjectAnimator.ofPropertyValuesHolder(cl, newAlphas[i] = finalAlphaValue;
PropertyValuesHolder.ofFloat("translationX", translation), if (animated && !(oldAlphas[i] == 0f && newAlphas[i] == 0f)) {
PropertyValuesHolder.ofFloat("translationY", 0.0f), oldTranslationXs[i] = cl.getTranslationX();
PropertyValuesHolder.ofFloat("scaleX", finalScaleFactor), oldTranslationYs[i] = cl.getTranslationY();
PropertyValuesHolder.ofFloat("scaleY", finalScaleFactor), oldScaleXs[i] = cl.getScaleX();
PropertyValuesHolder.ofFloat("backgroundAlpha", finalBackgroundAlpha), oldScaleYs[i] = cl.getScaleY();
PropertyValuesHolder.ofFloat("backgroundAlphaMultiplier", oldBackgroundAlphas[i] = cl.getBackgroundAlpha();
finalAlphaMultiplierValue), oldBackgroundAlphaMultipliers[i] = cl.getBackgroundAlphaMultiplier();
PropertyValuesHolder.ofFloat("alpha", finalAlphaValue)); oldRotationYs[i] = cl.getRotationY();
animWithInterpolator.setDuration(duration);
animWithInterpolator.setInterpolator(mZoomInInterpolator);
ObjectAnimator rotationAnim = ObjectAnimator.ofPropertyValuesHolder(cl, newTranslationXs[i] = translation;
PropertyValuesHolder.ofFloat("rotationY", rotation)); newTranslationYs[i] = 0f;
rotationAnim.setDuration(duration); newScaleXs[i] = finalScaleFactor;
rotationAnim.setInterpolator(new DecelerateInterpolator(2.0f)); newScaleYs[i] = finalScaleFactor;
newBackgroundAlphas[i] = finalBackgroundAlpha;
mAnimator.playTogether(animWithInterpolator, rotationAnim); newBackgroundAlphaMultipliers[i] = finalAlphaMultiplierValue;
newRotationYs[i] = rotation;
} else { } else {
cl.setTranslationX(translation); cl.setTranslationX(translation);
cl.setTranslationY(0.0f); cl.setTranslationY(0.0f);
@@ -1731,7 +1788,7 @@ public class Workspace extends SmoothPagedView
cl.setBackgroundAlphaMultiplier(finalAlphaMultiplierValue); cl.setBackgroundAlphaMultiplier(finalAlphaMultiplierValue);
cl.setAlpha(finalAlphaValue); cl.setAlpha(finalAlphaValue);
cl.setRotationY(rotation); cl.setRotationY(rotation);
mUnshrinkAnimationListener.onAnimationEnd(null); if (!animated) mUnshrinkAnimationListener.onAnimationEnd(null);
} }
} }
Display display = mLauncher.getWindowManager().getDefaultDisplay(); Display display = mLauncher.getWindowManager().getDefaultDisplay();
@@ -1765,15 +1822,59 @@ public class Workspace extends SmoothPagedView
break; break;
} }
if (animated) { if (animated) {
ObjectAnimator wallpaperAnim = ObjectAnimator.ofPropertyValuesHolder(this, ValueAnimator animWithInterpolator =
PropertyValuesHolder.ofFloat( ValueAnimator.ofFloat(0f, 1f).setDuration(duration);
"verticalWallpaperOffset", 0.5f), animWithInterpolator.setInterpolator(mZoomInInterpolator);
PropertyValuesHolder.ofFloat(
"horizontalWallpaperOffset", wallpaperOffsetForCurrentScroll()));
wallpaperAnim.setDuration(duration);
wallpaperAnim.setInterpolator(mZoomInInterpolator);
mAnimator.play(wallpaperAnim);
final float oldHorizontalWallpaperOffset = getHorizontalWallpaperOffset();
final float oldVerticalWallpaperOffset = getVerticalWallpaperOffset();
final float newHorizontalWallpaperOffset = wallpaperOffsetForCurrentScroll();
final float newVerticalWallpaperOffset = 0.5f;
animWithInterpolator.addUpdateListener(new AnimatorUpdateListener() {
public void onAnimationUpdate(ValueAnimator animation) {
fastInvalidate();
final float b = (Float) animation.getAnimatedValue();
final float a = 1f - b;
setHorizontalWallpaperOffset(
a * oldHorizontalWallpaperOffset + b * newHorizontalWallpaperOffset);
setVerticalWallpaperOffset(
a * oldVerticalWallpaperOffset + b * newVerticalWallpaperOffset);
for (int i = 0; i < screenCount; i++) {
if (oldAlphas[i] == 0f && newAlphas[i] == 0f) continue;
final CellLayout cl = (CellLayout) getChildAt(i);
cl.fastInvalidate();
cl.setFastTranslationX(
a * oldTranslationXs[i] + b * newTranslationXs[i]);
cl.setFastTranslationY(
a * oldTranslationYs[i] + b * newTranslationYs[i]);
cl.setFastScaleX(a * oldScaleXs[i] + b * newScaleXs[i]);
cl.setFastScaleY(a * oldScaleYs[i] + b * newScaleYs[i]);
cl.setFastBackgroundAlpha(
a * oldBackgroundAlphas[i] + b * newBackgroundAlphas[i]);
cl.setBackgroundAlphaMultiplier(a * oldBackgroundAlphaMultipliers[i] +
b * newBackgroundAlphaMultipliers[i]);
cl.setFastAlpha(a * oldAlphas[i] + b * newAlphas[i]);
}
}
});
ValueAnimator rotationAnim =
ValueAnimator.ofFloat(0f, 1f).setDuration(duration);
rotationAnim.setInterpolator(new DecelerateInterpolator(2.0f));
rotationAnim.addUpdateListener(new AnimatorUpdateListener() {
public void onAnimationUpdate(ValueAnimator animation) {
// don't invalidate workspace because we did it above
final float b = (Float) animation.getAnimatedValue();
final float a = 1f - b;
for (int i = 0; i < screenCount; i++) {
if (oldAlphas[i] == 0f && newAlphas[i] == 0f) continue;
final CellLayout cl = (CellLayout) getChildAt(i);
cl.setFastRotationY(a * oldRotationYs[i] + b * newRotationYs[i]);
}
}
});
mAnimator.playTogether(animWithInterpolator, rotationAnim);
// If we call this when we're not animated, onAnimationEnd is never called on // 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 // the listener; make sure we only use the listener when we're actually animating
mAnimator.addListener(mUnshrinkAnimationListener); mAnimator.addListener(mUnshrinkAnimationListener);