diff options
-rw-r--r-- | res/drawable-xlarge/home_screen_bg.9.png | bin | 0 -> 557 bytes | |||
-rw-r--r-- | src/com/android/launcher2/CellLayout.java | 44 | ||||
-rw-r--r-- | src/com/android/launcher2/Dimmable.java | 6 | ||||
-rw-r--r-- | src/com/android/launcher2/DimmableAppWidgetHostView.java | 58 | ||||
-rw-r--r-- | src/com/android/launcher2/DimmableBubbleTextView.java | 57 | ||||
-rw-r--r-- | src/com/android/launcher2/PagedView.java | 21 | ||||
-rw-r--r-- | src/com/android/launcher2/SmoothPagedView.java | 58 | ||||
-rw-r--r-- | src/com/android/launcher2/Workspace.java | 146 |
8 files changed, 267 insertions, 123 deletions
diff --git a/res/drawable-xlarge/home_screen_bg.9.png b/res/drawable-xlarge/home_screen_bg.9.png Binary files differnew file mode 100644 index 000000000..d939d5c1b --- /dev/null +++ b/res/drawable-xlarge/home_screen_bg.9.png diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java index a55990b1e..08560e930 100644 --- a/src/com/android/launcher2/CellLayout.java +++ b/src/com/android/launcher2/CellLayout.java @@ -42,7 +42,7 @@ import android.view.animation.LayoutAnimationController; import java.util.Arrays; -public class CellLayout extends ViewGroup { +public class CellLayout extends ViewGroup implements Dimmable { static final String TAG = "CellLayout"; private int mCellWidth; @@ -75,8 +75,10 @@ public class CellLayout extends ViewGroup { private float mBackgroundAlpha; private final Rect mBackgroundLayoutRect = new Rect(); + private Drawable mBackground; - private Drawable mBackgroundHover; + private Drawable mBackgroundMini; + private Drawable mBackgroundMiniHover; // If we're actively dragging something over this screen and it's small, // mHover is true private boolean mHover = false; @@ -137,10 +139,12 @@ public class CellLayout extends ViewGroup { if (LauncherApplication.isScreenXLarge()) { final Resources res = getResources(); - mBackground = res.getDrawable(R.drawable.mini_home_screen_bg); + mBackgroundMini = getResources().getDrawable(R.drawable.mini_home_screen_bg); + mBackgroundMini.setFilterBitmap(true); + mBackground = getResources().getDrawable(R.drawable.home_screen_bg); mBackground.setFilterBitmap(true); - mBackgroundHover = res.getDrawable(R.drawable.mini_home_screen_bg_hover); - mBackgroundHover.setFilterBitmap(true); + mBackgroundMiniHover = getResources().getDrawable(R.drawable.mini_home_screen_bg_hover); + mBackgroundMiniHover.setFilterBitmap(true); mDragRectDrawable = res.getDrawable(R.drawable.rounded_rect_green); mCrosshairsDrawable = res.getDrawable(R.drawable.gardening_crosshairs); @@ -176,7 +180,14 @@ public class CellLayout extends ViewGroup { @Override public void dispatchDraw(Canvas canvas) { if (mBackgroundAlpha > 0.0f) { - final Drawable bg = mHover ? mBackgroundHover : mBackground; + Drawable bg; + if (mHover && getScaleX() < 0.5f) { + bg = mBackgroundMiniHover; + } else if (getScaleX() < 0.5f) { + bg = mBackgroundMini; + } else { + bg = mBackground; + } bg.setAlpha((int) (mBackgroundAlpha * 255)); bg.draw(canvas); } @@ -228,6 +239,20 @@ public class CellLayout extends ViewGroup { } } + public void setDimmableProgress(float progress) { + for (int i = 0; i < getChildCount(); i++) { + Dimmable d = (Dimmable) getChildAt(i); + d.setDimmableProgress(progress); + } + } + + public float getDimmableProgress() { + if (getChildCount() > 0) { + return ((Dimmable) getChildAt(0)).getDimmableProgress(); + } + return 0.0f; + } + @Override public void cancelLongPress() { super.cancelLongPress(); @@ -581,8 +606,11 @@ public class CellLayout extends ViewGroup { if (mBackground != null) { mBackground.setBounds(mBackgroundLayoutRect); } - if (mBackgroundHover != null) { - mBackgroundHover.setBounds(mBackgroundLayoutRect); + if (mBackgroundMiniHover != null) { + mBackgroundMiniHover.setBounds(mBackgroundLayoutRect); + } + if (mBackgroundMini != null) { + mBackgroundMini.setBounds(mBackgroundLayoutRect); } } diff --git a/src/com/android/launcher2/Dimmable.java b/src/com/android/launcher2/Dimmable.java new file mode 100644 index 000000000..df43b3c8e --- /dev/null +++ b/src/com/android/launcher2/Dimmable.java @@ -0,0 +1,6 @@ +package com.android.launcher2; + +public interface Dimmable { + public void setDimmableProgress(float progress); + public float getDimmableProgress(); +} diff --git a/src/com/android/launcher2/DimmableAppWidgetHostView.java b/src/com/android/launcher2/DimmableAppWidgetHostView.java index b5ec8cd08..1f512a3f9 100644 --- a/src/com/android/launcher2/DimmableAppWidgetHostView.java +++ b/src/com/android/launcher2/DimmableAppWidgetHostView.java @@ -21,52 +21,21 @@ import com.android.launcher.R; import android.content.Context; import android.graphics.Bitmap; import android.graphics.Canvas; -import android.graphics.Color; import android.graphics.Paint; import android.graphics.PorterDuff; import android.view.View; -public class DimmableAppWidgetHostView extends LauncherAppWidgetHostView { +public class DimmableAppWidgetHostView extends LauncherAppWidgetHostView implements Dimmable { public DimmableAppWidgetHostView(Context context) { super(context); mPaint.setFilterBitmap(true); } private final Paint mPaint = new Paint(); - private int mAlpha; - private int mDimmedAlpha; private Bitmap mDimmedView; private Canvas mDimmedViewCanvas; private boolean isDimmedViewUpdatePass; - - private static float cubic(float r) { - return (float) (Math.pow(r-1, 3) + 1); - } - - /** - * Returns the interpolated holographic highlight alpha for the effect we want when scrolling - * pages. - */ - public static float highlightAlphaInterpolator(float r) { - final float pivot = 0.3f; - if (r < pivot) { - return Math.max(0.5f, 0.65f*cubic(r/pivot)); - } else { - return Math.min(1.0f, 0.65f*cubic(1 - (r-pivot)/(1-pivot))); - } - } - - /** - * Returns the interpolated view alpha for the effect we want when scrolling pages. - */ - public static float viewAlphaInterpolator(float r) { - final float pivot = 0.6f; - if (r < pivot) { - return r/pivot; - } else { - return 1.0f; - } - } + private float mDimmableProgress; private void setChildAlpha(float alpha) { if (getChildCount() > 0) { @@ -83,20 +52,18 @@ public class DimmableAppWidgetHostView extends LauncherAppWidgetHostView { setChildAlpha(getAlpha()); } - @Override + //@Override public boolean onSetAlpha(int alpha) { super.onSetAlpha(alpha); return true; } - @Override - public void setAlpha(float alpha) { - final float viewAlpha = viewAlphaInterpolator(alpha); - final float dimmedAlpha = highlightAlphaInterpolator(alpha); - mAlpha = (int) (viewAlpha * 255); - mDimmedAlpha = (int) (dimmedAlpha * 255); - super.setAlpha(viewAlpha); - setChildAlpha(viewAlpha); + public void setDimmableProgress(float progress) { + mDimmableProgress = progress; + } + + public float getDimmableProgress() { + return mDimmableProgress; } private void updateDimmedView() { @@ -113,13 +80,14 @@ public class DimmableAppWidgetHostView extends LauncherAppWidgetHostView { int dimmedColor = getContext().getResources().getColor(R.color.dimmed_view_color); mDimmedViewCanvas.drawColor(dimmedColor, PorterDuff.Mode.SRC_IN); isDimmedViewUpdatePass = false; + invalidate(); } @Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { super.onLayout(changed, left, top, right, bottom); - if (mDimmedView == null && mDimmedAlpha > 0.0f) { + if (mDimmedView == null && mDimmableProgress > 0.0f) { updateDimmedView(); } } @@ -134,9 +102,9 @@ public class DimmableAppWidgetHostView extends LauncherAppWidgetHostView { canvas.restore(); setAlpha(alpha); } else { - if (mDimmedView != null && mDimmedAlpha > 0) { + if (mDimmedView != null && mDimmableProgress > 0) { // draw the dimmed version of this widget - mPaint.setAlpha(mDimmedAlpha); + mPaint.setAlpha((int) (mDimmableProgress * 255)); canvas.drawBitmap(mDimmedView, 0, 0, mPaint); } diff --git a/src/com/android/launcher2/DimmableBubbleTextView.java b/src/com/android/launcher2/DimmableBubbleTextView.java index 66cc97a1b..cb3b8efd6 100644 --- a/src/com/android/launcher2/DimmableBubbleTextView.java +++ b/src/com/android/launcher2/DimmableBubbleTextView.java @@ -21,18 +21,17 @@ import com.android.launcher.R; import android.content.Context; import android.graphics.Bitmap; import android.graphics.Canvas; -import android.graphics.Color; import android.graphics.Paint; import android.graphics.PorterDuff; import android.util.AttributeSet; -public class DimmableBubbleTextView extends BubbleTextView { +public class DimmableBubbleTextView extends BubbleTextView implements Dimmable { private Paint mDimmedPaint = new Paint(); private int mAlpha; - private int mDimmedAlpha; private Bitmap mDimmedView; private Canvas mDimmedViewCanvas; private boolean isDimmedViewUpdatePass; + private float mDimmableProgress; public DimmableBubbleTextView(Context context) { super(context); @@ -49,48 +48,12 @@ public class DimmableBubbleTextView extends BubbleTextView { mDimmedPaint.setFilterBitmap(true); } - private static float cubic(float r) { - return (float) (Math.pow(r-1, 3) + 1); + public void setDimmableProgress(float progress) { + mDimmableProgress = progress; } - /** - * Returns the interpolated holographic highlight alpha for the effect we want when scrolling - * pages. - */ - public static float highlightAlphaInterpolator(float r) { - final float pivot = 0.3f; - if (r < pivot) { - return Math.max(0.5f, 0.65f*cubic(r/pivot)); - } else { - return Math.min(1.0f, 0.65f*cubic(1 - (r-pivot)/(1-pivot))); - } - } - - /** - * Returns the interpolated view alpha for the effect we want when scrolling pages. - */ - public static float viewAlphaInterpolator(float r) { - final float pivot = 0.6f; - if (r < pivot) { - return r/pivot; - } else { - return 1.0f; - } - } - - @Override - public boolean onSetAlpha(int alpha) { - super.onSetAlpha(alpha); - return true; - } - - @Override - public void setAlpha(float alpha) { - final float viewAlpha = viewAlphaInterpolator(alpha); - final float dimmedAlpha = highlightAlphaInterpolator(alpha); - mAlpha = (int) (viewAlpha * 255); - mDimmedAlpha = (int) (dimmedAlpha * 255); - super.setAlpha(viewAlpha); + public float getDimmableProgress() { + return mDimmableProgress; } @Override @@ -124,13 +87,11 @@ public class DimmableBubbleTextView extends BubbleTextView { super.setAlpha(alpha); canvas.restore(); } else { - if (mAlpha > 0) { - super.onDraw(canvas); - } + super.onDraw(canvas); } - if (mDimmedView != null && mDimmedAlpha > 0) { - mDimmedPaint.setAlpha(mDimmedAlpha); + if (mDimmedView != null && mDimmableProgress > 0) { + mDimmedPaint.setAlpha((int) (mDimmableProgress * 255)); canvas.drawBitmap(mDimmedView, mScrollX, mScrollY, mDimmedPaint); } } diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java index 5aec48ebe..a1b1e08ba 100644 --- a/src/com/android/launcher2/PagedView.java +++ b/src/com/android/launcher2/PagedView.java @@ -73,11 +73,13 @@ public abstract class PagedView extends ViewGroup { private float mDownMotionX; private float mLastMotionX; private float mLastMotionY; + private int mLastScreenCenter = -1; protected final static int TOUCH_STATE_REST = 0; protected final static int TOUCH_STATE_SCROLLING = 1; protected final static int TOUCH_STATE_PREV_PAGE = 2; protected final static int TOUCH_STATE_NEXT_PAGE = 3; + protected final static float ALPHA_QUANTIZE_LEVEL = 0.01f; protected int mTouchState = TOUCH_STATE_REST; @@ -367,7 +369,6 @@ public abstract class PagedView extends ViewGroup { if (mDirtyPageAlpha || (mTouchState == TOUCH_STATE_SCROLLING) || !mScroller.isFinished()) { int halfScreenSize = getMeasuredWidth() / 2; int screenCenter = mScrollX + halfScreenSize; - final int childCount = getChildCount(); for (int i = 0; i < childCount; ++i) { View layout = (View) getChildAt(i); @@ -391,6 +392,12 @@ public abstract class PagedView extends ViewGroup { dimAlpha = Math.max(0.0f, Math.min(1.0f, (dimAlpha * dimAlpha))); float alpha = 1.0f - dimAlpha; + if (alpha < ALPHA_QUANTIZE_LEVEL) { + alpha = 0.0f; + } else if (alpha > 1.0f - ALPHA_QUANTIZE_LEVEL) { + alpha = 1.0f; + } + if (Float.compare(alpha, layout.getAlpha()) != 0) { layout.setAlpha(alpha); } @@ -400,9 +407,19 @@ public abstract class PagedView extends ViewGroup { } } + protected void screenScrolled(int screenCenter) { + } + @Override protected void dispatchDraw(Canvas canvas) { - updateAdjacentPagesAlpha(); + int halfScreenSize = getMeasuredWidth() / 2; + int screenCenter = mScrollX + halfScreenSize; + + if (screenCenter != mLastScreenCenter) { + screenScrolled(screenCenter); + updateAdjacentPagesAlpha(); + mLastScreenCenter = screenCenter; + } // Find out which screens are visible; as an optimization we only call draw on them // As an optimization, this code assumes that all pages have the same width as the 0th diff --git a/src/com/android/launcher2/SmoothPagedView.java b/src/com/android/launcher2/SmoothPagedView.java index 5f80f2587..56037ffb8 100644 --- a/src/com/android/launcher2/SmoothPagedView.java +++ b/src/com/android/launcher2/SmoothPagedView.java @@ -26,11 +26,15 @@ public abstract class SmoothPagedView extends PagedView { private static final float SMOOTHING_SPEED = 0.75f; private static final float SMOOTHING_CONSTANT = (float) (0.016 / Math.log(SMOOTHING_SPEED)); + private float mBaseLineFlingVelocity; + private float mFlingVelocityInfluence; - private static final float BASELINE_FLING_VELOCITY = 2500.f; - private static final float FLING_VELOCITY_INFLUENCE = 0.4f; + static final int OVERSHOOT_MODE = 0; + static final int QUINTIC_MODE = 1; - private WorkspaceOvershootInterpolator mScrollInterpolator; + int mScrollMode; + + private Interpolator mScrollInterpolator; private static class WorkspaceOvershootInterpolator implements Interpolator { private static final float DEFAULT_TENSION = 1.3f; @@ -56,6 +60,16 @@ public abstract class SmoothPagedView extends PagedView { } } + private static class QuinticInterpolator implements Interpolator { + public QuinticInterpolator() { + } + + public float getInterpolation(float t) { + t -= 1.0f; + return t*t*t*t*t + 1; + } + } + /** * Used to inflate the Workspace from XML. * @@ -83,14 +97,27 @@ public abstract class SmoothPagedView extends PagedView { mDeferScrollUpdate = true; } + protected int getScrollMode() { + return OVERSHOOT_MODE; + } + /** * Initializes various states for this workspace. */ @Override protected void init() { super.init(); - mScrollInterpolator = new WorkspaceOvershootInterpolator(); - // overwrite the previous mScroller + + mScrollMode = getScrollMode(); + if (mScrollMode == QUINTIC_MODE) { + mBaseLineFlingVelocity = 700.0f; + mFlingVelocityInfluence = 0.8f; + mScrollInterpolator = new QuinticInterpolator(); + } else { // QUINTIC_MODE + mBaseLineFlingVelocity = 2500.0f; + mFlingVelocityInfluence = 0.4f; + mScrollInterpolator = new WorkspaceOvershootInterpolator(); + } mScroller = new Scroller(getContext(), mScrollInterpolator); } @@ -112,25 +139,32 @@ public abstract class SmoothPagedView extends PagedView { final int screenDelta = Math.max(1, Math.abs(whichPage - mCurrentPage)); final int newX = getChildOffset(whichPage) - getRelativeChildOffset(whichPage); final int delta = newX - mScrollX; - int duration = (screenDelta + 1) * 100; + int duration; + if (mScrollMode == OVERSHOOT_MODE) { + duration = (screenDelta + 1) * 100; + } else { // QUINTIC_MODE + duration = Math.round(Math.abs(delta) * 0.6f); + } if (!mScroller.isFinished()) { mScroller.abortAnimation(); } - if (settle) { - mScrollInterpolator.setDistance(screenDelta); - } else { - mScrollInterpolator.disableSettle(); + if (mScrollMode == OVERSHOOT_MODE) { + if (settle) { + ((WorkspaceOvershootInterpolator) mScrollInterpolator).setDistance(screenDelta); + } else { + ((WorkspaceOvershootInterpolator) mScrollInterpolator).disableSettle(); + } } velocity = Math.abs(velocity); if (velocity > 0) { - duration += (duration / (velocity / BASELINE_FLING_VELOCITY)) - * FLING_VELOCITY_INFLUENCE; + duration += (duration / (velocity / mBaseLineFlingVelocity)) * mFlingVelocityInfluence; } else { duration += 100; } + snapToPage(whichPage, delta, duration); } diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java index dc5853fe1..d80edae8f 100644 --- a/src/com/android/launcher2/Workspace.java +++ b/src/com/android/launcher2/Workspace.java @@ -33,7 +33,9 @@ import android.content.pm.PackageManager; import android.content.pm.ProviderInfo; import android.content.res.Resources; import android.content.res.TypedArray; +import android.graphics.Camera; import android.graphics.Canvas; +import android.graphics.Color; import android.graphics.Matrix; import android.graphics.Rect; import android.graphics.drawable.Drawable; @@ -63,8 +65,8 @@ public class Workspace extends SmoothPagedView // customization mode private static final float SHRINK_FACTOR = 0.16f; - // The maximum Y rotation to apply to the mini home screens - private static final float MINI_PAGE_MAX_ROTATION = 25.0f; + // Y rotation to apply to the workspace screens + private static final float WORKSPACE_ROTATION = 12.5f; // These are extra scale factors to apply to the mini home screens // so as to achieve the desired transform @@ -72,6 +74,18 @@ public class Workspace extends SmoothPagedView private static final float EXTRA_SCALE_FACTOR_1 = 1.0f; private static final float EXTRA_SCALE_FACTOR_2 = 1.08f; + private static final int BACKGROUND_FADE_OUT_DELAY = 300; + private static final int BACKGROUND_FADE_OUT_DURATION = 300; + private static final int BACKGROUND_FADE_IN_DURATION = 100; + + static final int SCROLL_RIGHT = 0; + static final int SCROLL_LEFT = 1; + + // These animators are used to fade the + private ObjectAnimator<Float> mBackgroundFadeIn; + private ObjectAnimator<Float> mBackgroundFadeOut; + private float mBackgroundAlpha = 0; + private enum ShrinkPosition { SHRINK_TO_TOP, SHRINK_TO_MIDDLE, SHRINK_TO_BOTTOM }; private final WallpaperManager mWallpaperManager; @@ -180,6 +194,15 @@ public class Workspace extends SmoothPagedView } @Override + protected int getScrollMode() { + if (LauncherApplication.isScreenXLarge()) { + return SmoothPagedView.QUINTIC_MODE; + } else { + return SmoothPagedView.OVERSHOOT_MODE; + } + } + + @Override public void addView(View child, int index, LayoutParams params) { if (!(child instanceof CellLayout)) { throw new IllegalArgumentException("A Workspace can only have CellLayout children."); @@ -382,12 +405,14 @@ public class Workspace extends SmoothPagedView enableChildrenCache(mCurrentPage - 1, mCurrentPage + 1); } } + showOutlines(); } protected void pageEndMoving() { if (!LauncherApplication.isScreenXLarge()) { clearChildrenCache(); } + hideOutlines(); } @Override @@ -424,6 +449,99 @@ public class Workspace extends SmoothPagedView } } + private float getScaleXForRotation(float degrees) { + return (float) (1.0f / Math.cos(Math.PI * degrees / 180.0f)); + } + + public void showOutlines() { + if (mBackgroundFadeOut != null) mBackgroundFadeOut.cancel(); + if (mBackgroundFadeIn != null) mBackgroundFadeIn.cancel(); + mBackgroundFadeIn = new ObjectAnimator<Float>(BACKGROUND_FADE_IN_DURATION, this, + new PropertyValuesHolder<Float>("backgroundAlpha", 1.0f)); + mBackgroundFadeIn.start(); + } + + public void hideOutlines() { + if (mBackgroundFadeIn != null) mBackgroundFadeIn.cancel(); + if (mBackgroundFadeOut != null) mBackgroundFadeOut.cancel(); + mBackgroundFadeOut = new ObjectAnimator<Float>(BACKGROUND_FADE_OUT_DURATION, this, + new PropertyValuesHolder<Float>("backgroundAlpha", 0.0f)); + mBackgroundFadeOut.setStartDelay(BACKGROUND_FADE_OUT_DELAY); + mBackgroundFadeOut.start(); + } + + public void setBackgroundAlpha(float alpha) { + mBackgroundAlpha = alpha; + for (int i = 0; i < getChildCount(); i++) { + CellLayout cl = (CellLayout) getChildAt(i); + cl.setBackgroundAlpha(alpha); + } + } + + public float getBackgroundAlpha() { + return mBackgroundAlpha; + } + + @Override + protected void screenScrolled(int screenCenter) { + View cur = getChildAt(mCurrentPage); + View toRight = getChildAt(mCurrentPage + 1); + View toLeft = getChildAt(mCurrentPage - 1); + + for (int i = 0; i < mCurrentPage - 1; i++) { + View v = getChildAt(i); + if (v != null) { + v.setRotationY(WORKSPACE_ROTATION); + v.setScaleX(getScaleXForRotation(WORKSPACE_ROTATION)); + } + } + for (int i = mCurrentPage + 1; i < getChildCount(); i++) { + View v = getChildAt(i); + if (v != null) { + v.setRotationY(-WORKSPACE_ROTATION); + v.setScaleX(getScaleXForRotation(-WORKSPACE_ROTATION)); + } + } + + int pageWidth = cur.getMeasuredWidth(); + int delta = screenCenter - (mCurrentPage * pageWidth + pageWidth / 2 + + getRelativeChildOffset(0)); + + float scrollProgress = Math.abs(delta/(pageWidth*1.0f)); + int scrollDirection = delta > 0 ? SCROLL_LEFT : SCROLL_RIGHT; + + float rotation; + + if (scrollDirection == SCROLL_RIGHT) { + rotation = -scrollProgress * WORKSPACE_ROTATION; + cur.setRotationY(rotation); + cur.setScaleX(getScaleXForRotation(rotation)); + if (toLeft != null) { + rotation = WORKSPACE_ROTATION * (1 - scrollProgress); + toLeft.setRotationY(rotation); + toLeft.setScaleX(getScaleXForRotation(rotation)); + } + if (toRight != null) { + toRight.setRotationY(-WORKSPACE_ROTATION); + toRight.setScaleX(getScaleXForRotation(WORKSPACE_ROTATION)); + } + } else { + rotation = scrollProgress * WORKSPACE_ROTATION; + cur.setRotationY(rotation); + cur.setScaleX(getScaleXForRotation(rotation)); + + if (toRight != null) { + rotation = -WORKSPACE_ROTATION * (1 - scrollProgress); + toRight.setRotationY(rotation); + toRight.setScaleX(getScaleXForRotation(rotation)); + } + if (toLeft != null) { + toLeft.setRotationY(WORKSPACE_ROTATION); + toLeft.setScaleX(getScaleXForRotation(WORKSPACE_ROTATION)); + } + } + } + protected void onAttachedToWindow() { super.onAttachedToWindow(); computeScroll(); @@ -624,7 +742,7 @@ public class Workspace extends SmoothPagedView for (int i = 0; i < screenCount; i++) { CellLayout cl = (CellLayout) getChildAt(i); - float rotation = (-i + 2) * MINI_PAGE_MAX_ROTATION / 2.0f; + float rotation = (-i + 2) * WORKSPACE_ROTATION; float rotationScaleX = (float) (1.0f / Math.cos(Math.PI * rotation / 180.0f)); float rotationScaleY = getYScaleForScreen(i); @@ -636,14 +754,16 @@ public class Workspace extends SmoothPagedView new PropertyValuesHolder<Float>("scaleX", SHRINK_FACTOR * rotationScaleX), new PropertyValuesHolder<Float>("scaleY", SHRINK_FACTOR * rotationScaleY), new PropertyValuesHolder<Float>("backgroundAlpha", 1.0f), + new PropertyValuesHolder<Float>("dimmableProgress", 1.0f), new PropertyValuesHolder<Float>("alpha", 0.0f), new PropertyValuesHolder<Float>("rotationY", rotation)).start(); } else { cl.setX((int)newX); cl.setY((int)newY); - cl.setScaleX(SHRINK_FACTOR); - cl.setScaleY(SHRINK_FACTOR); + cl.setScaleX(SHRINK_FACTOR * rotationScaleX); + cl.setScaleY(SHRINK_FACTOR * rotationScaleY); cl.setBackgroundAlpha(1.0f); + cl.setDimmableProgress(1.0f); cl.setAlpha(0.0f); cl.setRotationY(rotation); } @@ -696,6 +816,14 @@ public class Workspace extends SmoothPagedView for (int i = 0; i < screenCount; i++) { final CellLayout cl = (CellLayout)getChildAt(i); float finalAlphaValue = (i == mCurrentPage) ? 1.0f : 0.0f; + float rotation = 0.0f; + + if (i < mCurrentPage) { + rotation = WORKSPACE_ROTATION; + } else if (i > mCurrentPage) { + rotation = -WORKSPACE_ROTATION; + } + if (animated) { s.playTogether( new ObjectAnimator<Float>(duration, cl, "translationX", 0.0f), @@ -704,15 +832,17 @@ public class Workspace extends SmoothPagedView new ObjectAnimator<Float>(duration, cl, "scaleY", 1.0f), new ObjectAnimator<Float>(duration, cl, "backgroundAlpha", 0.0f), new ObjectAnimator<Float>(duration, cl, "alpha", finalAlphaValue), - new ObjectAnimator<Float>(duration, cl, "rotationY", 0.0f)); + new ObjectAnimator<Float>(duration, cl, "dimmableProgress", 0.0f), + new ObjectAnimator<Float>(duration, cl, "rotationY", rotation)); } else { cl.setTranslationX(0.0f); cl.setTranslationY(0.0f); cl.setScaleX(1.0f); cl.setScaleY(1.0f); cl.setBackgroundAlpha(0.0f); - cl.setAlpha(1.0f); - cl.setRotationY(0.0f); + cl.setDimmableProgress(0.0f); + cl.setAlpha(finalAlphaValue); + cl.setRotationY(rotation); } } s.addListener(mUnshrinkAnimationListener); |