summaryrefslogtreecommitdiffstats
path: root/src/com/cyanogenmod
diff options
context:
space:
mode:
authornebkat <nebkat@teamhacksung.org>2012-12-15 19:59:45 +0000
committernebkat <nebkat@teamhacksung.org>2012-12-15 22:49:06 +0000
commit11b11c53a8638cbb0d26d7f55ca3d367b30f0cb2 (patch)
treee8be41c12621d1d93e55f9d37fa030ee21a16dbc /src/com/cyanogenmod
parentbbf4dd7599f8b60e48937cf16c9b1466f5466e97 (diff)
downloadandroid_packages_apps_Trebuchet-11b11c53a8638cbb0d26d7f55ca3d367b30f0cb2.tar.gz
android_packages_apps_Trebuchet-11b11c53a8638cbb0d26d7f55ca3d367b30f0cb2.tar.bz2
android_packages_apps_Trebuchet-11b11c53a8638cbb0d26d7f55ca3d367b30f0cb2.zip
Transition Effects
Change-Id: I9191cad9ad9950144fffd75e5140ae11759eecc8
Diffstat (limited to 'src/com/cyanogenmod')
-rw-r--r--src/com/cyanogenmod/trebuchet/AppsCustomizePagedView.java334
-rw-r--r--src/com/cyanogenmod/trebuchet/PagedView.java30
-rw-r--r--src/com/cyanogenmod/trebuchet/Workspace.java556
-rw-r--r--src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java16
4 files changed, 810 insertions, 126 deletions
diff --git a/src/com/cyanogenmod/trebuchet/AppsCustomizePagedView.java b/src/com/cyanogenmod/trebuchet/AppsCustomizePagedView.java
index ad16d90a4..5726ca255 100644
--- a/src/com/cyanogenmod/trebuchet/AppsCustomizePagedView.java
+++ b/src/com/cyanogenmod/trebuchet/AppsCustomizePagedView.java
@@ -53,6 +53,7 @@ import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
+import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
@@ -296,12 +297,29 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
// Relating to the scroll and overscroll effects
Workspace.ZInterpolator mZInterpolator = new Workspace.ZInterpolator(0.5f);
private static float CAMERA_DISTANCE = 6500;
- private static float TRANSITION_SCALE_FACTOR = 0.74f;
- private static float TRANSITION_PIVOT = 0.65f;
- private static float TRANSITION_MAX_ROTATION = 22;
- private static final boolean PERFORM_OVERSCROLL_ROTATION = true;
+ private static final float TRANSITION_SCALE_FACTOR = 0.74f;
+ private static final float TRANSITION_PIVOT = 0.65f;
+ private static final float TRANSITION_MAX_ROTATION = 22;
+ private static final float TRANSITION_SCREEN_ROTATION = 12.5f;
+ private boolean mScrollTransformsDirty = false;
+ private boolean mOverscrollTransformsDirty = false;
private AccelerateInterpolator mAlphaInterpolator = new AccelerateInterpolator(0.9f);
private DecelerateInterpolator mLeftScreenAlphaInterpolator = new DecelerateInterpolator(4);
+ public enum TransitionEffect {
+ Standard,
+ Tablet,
+ ZoomIn,
+ ZoomOut,
+ RotateUp,
+ RotateDown,
+ Spin,
+ Flip,
+ CubeIn,
+ CubeOut,
+ Stack,
+ Accordian
+ }
+ private TransitionEffect mTransitionEffect = TransitionEffect.Standard;
// Previews & outlines
ArrayList<AppsCustomizeAsyncTask> mRunningTasks;
@@ -356,17 +374,24 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
mCanvas = new Canvas();
mRunningTasks = new ArrayList<AppsCustomizeAsyncTask>();
+ mHandleFadeInAdjacentScreens = true;
+
+ Resources resources = context.getResources();
+
// Preferences
mJoinWidgetsApps = PreferencesProvider.Interface.Drawer.getJoinWidgetsApps(context);
+ mTransitionEffect = PreferencesProvider.Interface.Drawer.Scrolling.getTransitionEffect(context,
+ resources.getString(R.string.config_drawerDefaultTransitionEffect));
+ mFadeInAdjacentScreens = PreferencesProvider.Interface.Drawer.Scrolling.getFadeInAdjacentScreens(context);
mShowScrollingIndicator = PreferencesProvider.Interface.Drawer.Indicator.getShowScrollingIndicator(context);
mFadeScrollingIndicator = PreferencesProvider.Interface.Drawer.Indicator.getFadeScrollingIndicator(context);
+
if (!mShowScrollingIndicator) {
disableScrollingIndicator();
}
// Save the default widget preview background
- Resources resources = context.getResources();
mAppIconSize = resources.getDimensionPixelSize(R.dimen.app_icon_size);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.AppsCustomizePagedView, 0, 0);
@@ -1759,25 +1784,123 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
return getChildCount() - index - 1;
}
- // In apps customize, we have a scrolling effect which emulates pulling cards off of a stack.
- @Override
- protected void screenScrolled(int screenCenter) {
- super.screenScrolled(screenCenter);
+ private void screenScrolledStandard(int screenScroll) {
+ for (int i = 0; i < getChildCount(); i++) {
+ View v = getPageAt(i);
+ if (v != null) {
+ float scrollProgress = getScrollProgress(screenScroll, v, i);
+ if (mFadeInAdjacentScreens) {
+ float alpha = 1 - Math.abs(scrollProgress);
+ v.setAlpha(alpha);
+ }
+ }
+ }
+ }
+
+ private void screenScrolledTablet(int screenScroll) {
+ for (int i = 0; i < getChildCount(); i++) {
+ View v = getPageAt(i);
+ if (v != null) {
+ float scrollProgress = getScrollProgress(screenScroll, v, i);
+ float rotation = TRANSITION_SCREEN_ROTATION * scrollProgress;
+ float translationX = mLauncher.getWorkspace().getOffsetXForRotation(rotation, v.getWidth(), v.getHeight());
+
+ v.setTranslationX(translationX);
+ v.setRotationY(rotation);
+ if (mFadeInAdjacentScreens) {
+ float alpha = 1 - Math.abs(scrollProgress);
+ v.setAlpha(alpha);
+ }
+ }
+ }
+ }
+
+ private void screenScrolledZoom(int screenScroll, boolean in) {
+ for (int i = 0; i < getChildCount(); i++) {
+ View v = getPageAt(i);
+ if (v != null) {
+ float scrollProgress = getScrollProgress(screenScroll, v, i);
+ float scale = 1.0f + (in ? -0.2f : 0.1f) * Math.abs(scrollProgress);
+
+ // Extra translation to account for the increase in size
+ if (!in) {
+ float translationX = v.getMeasuredWidth() * 0.1f * -scrollProgress;
+ v.setTranslationX(translationX);
+ }
+
+ v.setScaleX(scale);
+ v.setScaleY(scale);
+ if (mFadeInAdjacentScreens) {
+ float alpha = 1 - Math.abs(scrollProgress);
+ v.setAlpha(alpha);
+ }
+ }
+ }
+ }
+
+ private void screenScrolledRotate(int screenScroll, boolean up) {
for (int i = 0; i < getChildCount(); i++) {
View v = getPageAt(i);
if (v != null) {
- float scrollProgress = getScrollProgress(screenCenter, v, i);
+ float scrollProgress = getScrollProgress(screenScroll, v, i);
+ float rotation =
+ (up ? TRANSITION_SCREEN_ROTATION : -TRANSITION_SCREEN_ROTATION) * scrollProgress;
+ float translationX = v.getMeasuredWidth() * scrollProgress;
+
+ float rotatePoint =
+ (v.getMeasuredWidth() * 0.5f) /
+ (float) Math.tan(Math.toRadians((double) (TRANSITION_SCREEN_ROTATION * 0.5f)));
+
+ v.setPivotX(v.getMeasuredWidth() * 0.5f);
+ if (up) {
+ v.setPivotY(-rotatePoint);
+ } else {
+ v.setPivotY(v.getMeasuredHeight() + rotatePoint);
+ }
+ v.setRotation(rotation);
+ v.setTranslationX(translationX);
+ if (mFadeInAdjacentScreens) {
+ float alpha = 1 - Math.abs(scrollProgress);
+ v.setAlpha(alpha);
+ }
+ }
+ }
+ }
+
+ private void screenScrolledCube(int screenScroll, boolean in) {
+ for (int i = 0; i < getChildCount(); i++) {
+ View v = getPageAt(i);
+ if (v != null) {
+ float scrollProgress = getScrollProgress(screenScroll, v, i);
+ float rotation = (in ? 90.0f : -90.0f) * scrollProgress;
+ float alpha = 1 - Math.abs(scrollProgress);
+
+ if (in) {
+ v.setCameraDistance(mDensity * CAMERA_DISTANCE);
+ }
+
+ v.setPivotX(scrollProgress < 0 ? 0 : v.getMeasuredWidth());
+ v.setPivotY(v.getMeasuredHeight() * 0.5f);
+ v.setRotationY(rotation);
+ v.setAlpha(alpha);
+ }
+ }
+ }
+
+ private void screenScrolledStack(int screenScroll) {
+ for (int i = 0; i < getChildCount(); i++) {
+ View v = getPageAt(i);
+ if (v != null) {
+ float scrollProgress = getScrollProgress(screenScroll, v, i);
float interpolatedProgress =
mZInterpolator.getInterpolation(Math.abs(Math.min(scrollProgress, 0)));
- float scale = (1 - interpolatedProgress) +
- interpolatedProgress * TRANSITION_SCALE_FACTOR;
+ float scale = (1 - interpolatedProgress) + interpolatedProgress * 0.76f;
float translationX = Math.min(0, scrollProgress) * v.getMeasuredWidth();
-
float alpha;
- if (scrollProgress < 0) {
+ if (!LauncherApplication.isScreenLarge() || scrollProgress < 0) {
alpha = scrollProgress < 0 ? mAlphaInterpolator.getInterpolation(
1 - Math.abs(scrollProgress)) : 1.0f;
} else {
@@ -1785,34 +1908,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
alpha = mLeftScreenAlphaInterpolator.getInterpolation(1 - scrollProgress);
}
- v.setCameraDistance(mDensity * CAMERA_DISTANCE);
- int pageWidth = v.getMeasuredWidth();
- int pageHeight = v.getMeasuredHeight();
-
- if (PERFORM_OVERSCROLL_ROTATION) {
- if (i == 0 && scrollProgress < 0) {
- // Overscroll to the left
- v.setPivotX(TRANSITION_PIVOT * pageWidth);
- v.setRotationY(-TRANSITION_MAX_ROTATION * scrollProgress);
- scale = 1.0f;
- alpha = 1.0f;
- // On the first page, we don't want the page to have any lateral motion
- translationX = 0;
- } else if (i == getChildCount() - 1 && scrollProgress > 0) {
- // Overscroll to the right
- v.setPivotX((1 - TRANSITION_PIVOT) * pageWidth);
- v.setRotationY(-TRANSITION_MAX_ROTATION * scrollProgress);
- scale = 1.0f;
- alpha = 1.0f;
- // On the last page, we don't want the page to have any lateral motion.
- translationX = 0;
- } else {
- v.setPivotY(pageHeight / 2.0f);
- v.setPivotX(pageWidth / 2.0f);
- v.setRotationY(0f);
- }
- }
-
v.setTranslationX(translationX);
v.setScaleX(scale);
v.setScaleY(scale);
@@ -1820,7 +1915,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
// If the view has 0 alpha, we set it to be invisible so as to prevent
// it from accepting touches
- if (alpha == 0) {
+ if (alpha <= 0) {
v.setVisibility(INVISIBLE);
} else if (v.getVisibility() != VISIBLE) {
v.setVisibility(VISIBLE);
@@ -1829,6 +1924,159 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
}
}
+
+ private void screenScrolledAccordian(int screenScroll) {
+ for (int i = 0; i < getChildCount(); i++) {
+ View v = getPageAt(i);
+ if (v != null) {
+ float scrollProgress = getScrollProgress(screenScroll, v, i);
+ float scale = 1.0f - Math.abs(scrollProgress);
+
+ v.setPivotX(scrollProgress < 0 ? 0 : v.getMeasuredWidth());
+ v.setScaleX(scale);
+
+ if (mFadeInAdjacentScreens) {
+ float alpha = 1 - Math.abs(scrollProgress);
+ v.setAlpha(alpha);
+ }
+ }
+ }
+ }
+
+ private void screenScrolledSpin(int screenScroll) {
+ for (int i = 0; i < getChildCount(); i++) {
+ View v = getPageAt(i);
+ if (v != null) {
+ float scrollProgress = getScrollProgress(screenScroll, v, i);
+ float rotation = 180.0f * scrollProgress;
+
+ v.setRotation(rotation);
+
+ if (getMeasuredHeight() > getMeasuredWidth()) {
+ float translationX =
+ (getMeasuredHeight() - getMeasuredWidth()) / 2.0f * -scrollProgress;
+ v.setTranslationX(translationX);
+ }
+
+ if (mFadeInAdjacentScreens) {
+ float alpha = 1 - Math.abs(scrollProgress);
+ v.setAlpha(alpha);
+ }
+ }
+ }
+ }
+
+ private void screenScrolledFlip(int screenScroll) {
+ for (int i = 0; i < getChildCount(); i++) {
+ View v = getPageAt(i);
+ if (v != null) {
+ float scrollProgress = getScrollProgress(screenScroll, v, i);
+ float rotation = -180.0f * scrollProgress;
+
+ if (scrollProgress >= -0.5f && scrollProgress <= 0.5f) {
+ v.setPivotX(v.getMeasuredWidth() * 0.5f);
+ v.setPivotY(v.getMeasuredHeight() * 0.5f);
+ v.setRotationY(rotation);
+ v.setTranslationX(v.getMeasuredWidth() * scrollProgress);
+ if (v.getVisibility() != VISIBLE) {
+ v.setVisibility(VISIBLE);
+ }
+ if (mFadeInAdjacentScreens) {
+ float alpha = 1 - Math.abs(scrollProgress);
+ v.setAlpha(alpha);
+ }
+ } else {
+ v.setVisibility(INVISIBLE);
+ }
+ }
+ }
+ }
+
+ // Transition effects
+ @Override
+ protected void screenScrolled(int screenScroll) {
+ super.screenScrolled(screenScroll);
+
+ boolean isInOverscroll = mOverScrollX < 0 || mOverScrollX > mMaxScrollX;
+ if (isInOverscroll && !mOverscrollTransformsDirty) {
+ mScrollTransformsDirty = true;
+ }
+ if (!isInOverscroll || mScrollTransformsDirty) {
+ // Limit the "normal" effects to mScrollX/Y
+ int scroll = mScrollX;
+ // Reset transforms when we aren't in overscroll
+ if (mOverscrollTransformsDirty) {
+ mOverscrollTransformsDirty = false;
+ View v0 = getPageAt(0);
+ View v1 = getPageAt(getChildCount() - 1);
+ v0.setTranslationX(0);
+ v1.setTranslationX(0);
+ v0.setRotationY(0);
+ v1.setRotationY(0);
+ v0.setCameraDistance(mDensity * 1280);
+ v1.setCameraDistance(mDensity * 1280);
+ v0.setPivotX(v0.getMeasuredWidth() / 2);
+ v1.setPivotX(v1.getMeasuredWidth() / 2);
+ v0.setPivotY(v0.getMeasuredHeight() / 2);
+ v1.setPivotY(v1.getMeasuredHeight() / 2);
+ }
+ switch (mTransitionEffect) {
+ case Standard:
+ screenScrolledStandard(scroll);
+ break;
+ case Tablet:
+ screenScrolledTablet(scroll);
+ break;
+ case ZoomIn:
+ screenScrolledZoom(scroll, true);
+ break;
+ case ZoomOut:
+ screenScrolledZoom(scroll, false);
+ break;
+ case RotateUp:
+ screenScrolledRotate(scroll, true);
+ break;
+ case RotateDown:
+ screenScrolledRotate(scroll, false);
+ break;
+ case Spin:
+ screenScrolledSpin(scroll);
+ break;
+ case Flip:
+ screenScrolledFlip(scroll);
+ break;
+ case CubeIn:
+ screenScrolledCube(scroll, true);
+ break;
+ case CubeOut:
+ screenScrolledCube(scroll, false);
+ break;
+ case Stack:
+ screenScrolledStack(scroll);
+ break;
+ case Accordian:
+ screenScrolledAccordian(scroll);
+ break;
+ }
+ mScrollTransformsDirty = false;
+ }
+
+ if (isInOverscroll) {
+ int index = mOverScrollX < 0 ? 0 : getChildCount() - 1;
+ View v = getPageAt(index);
+ if (v != null) {
+ float scrollProgress = getScrollProgress(screenScroll, v, index);
+ float rotation = - TRANSITION_MAX_ROTATION * scrollProgress;
+ v.setCameraDistance(mDensity * CAMERA_DISTANCE);
+ v.setPivotX(v.getMeasuredWidth() * (index == 0 ? TRANSITION_PIVOT : 1 - TRANSITION_PIVOT));
+ v.setPivotY(v.getMeasuredHeight() * 0.5f);
+ v.setRotationY(rotation);
+ v.setTranslationX(0);
+ mOverscrollTransformsDirty = true;
+ }
+ }
+ }
+
protected void overScroll(float amount) {
acceleratedOverScroll(amount);
}
diff --git a/src/com/cyanogenmod/trebuchet/PagedView.java b/src/com/cyanogenmod/trebuchet/PagedView.java
index 39f245f66..ec4a5fa00 100644
--- a/src/com/cyanogenmod/trebuchet/PagedView.java
+++ b/src/com/cyanogenmod/trebuchet/PagedView.java
@@ -99,7 +99,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
protected float mLastMotionXRemainder;
protected float mLastMotionY;
protected float mTotalMotionX;
- private int mLastScreenCenter = -1;
+ private int mLastScreenScroll = -1;
private int[] mChildOffsets;
private int[] mChildRelativeOffsets;
private int[] mChildOffsetsWithLayoutScale;
@@ -158,6 +158,9 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
// If true, modify alpha of neighboring pages as user scrolls left/right
protected boolean mFadeInAdjacentScreens = true;
+ // If true, mFadeInAdjacentScreens will be handled manually
+ protected boolean mHandleFadeInAdjacentScreens = false;
+
// It true, use a different slop parameter (pagingTouchSlop = 2 * touchSlop) for deciding
// to switch to a new page
protected boolean mUsePagingTouchSlop = true;
@@ -655,17 +658,17 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
}
}
- protected void screenScrolled(int screenCenter) {
+ protected void screenScrolled(int screenScroll) {
if (isScrollingIndicatorEnabled()) {
updateScrollingIndicator();
}
boolean isInOverscroll = mOverScrollX < 0 || mOverScrollX > mMaxScrollX;
- if (mFadeInAdjacentScreens && !isInOverscroll) {
+ if (mFadeInAdjacentScreens && !isInOverscroll && !mHandleFadeInAdjacentScreens) {
for (int i = 0; i < getChildCount(); i++) {
View child = getChildAt(i);
if (child != null) {
- float scrollProgress = getScrollProgress(screenCenter, child, i);
+ float scrollProgress = getScrollProgress(screenScroll, child, i);
float alpha = 1 - Math.abs(scrollProgress);
child.setAlpha(alpha);
}
@@ -780,22 +783,17 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
}
protected boolean shouldDrawChild(View child) {
- return child.getAlpha() > 0;
+ return child.getAlpha() > 0 && child.getVisibility() == VISIBLE;
}
@Override
protected void dispatchDraw(Canvas canvas) {
- int halfScreenSize = getMeasuredWidth() / 2;
- // mOverScrollX is equal to getScrollX() when we're within the normal scroll range.
- // Otherwise it is equal to the scaled overscroll position.
- int screenCenter = mOverScrollX + halfScreenSize;
-
- if (screenCenter != mLastScreenCenter || mForceScreenScrolled) {
+ if (mOverScrollX != mLastScreenScroll || mForceScreenScrolled) {
// set mForceScreenScrolled before calling screenScrolled so that screenScrolled can
// set it for the next frame
mForceScreenScrolled = false;
- screenScrolled(screenCenter);
- mLastScreenCenter = screenCenter;
+ screenScrolled(mOverScrollX);
+ mLastScreenScroll = mOverScrollX;
}
// Find out which screens are visible; as an optimization we only call draw on them
@@ -1094,12 +1092,12 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
}
}
- protected float getScrollProgress(int screenCenter, View v, int page) {
+ protected float getScrollProgress(int screenScroll, View v, int page) {
final int halfScreenSize = getMeasuredWidth() / 2;
int totalDistance = getScaledMeasuredWidth(v) + mPageSpacing;
- int delta = screenCenter - (getChildOffset(page) -
- getRelativeChildOffset(page) + halfScreenSize);
+ int delta = screenScroll - (getChildOffset(page) -
+ getRelativeChildOffset(page));
float scrollProgress = delta / (totalDistance * 1.0f);
scrollProgress = Math.min(scrollProgress, 1.0f);
diff --git a/src/com/cyanogenmod/trebuchet/Workspace.java b/src/com/cyanogenmod/trebuchet/Workspace.java
index 379b0fc38..e7f846dc4 100644
--- a/src/com/cyanogenmod/trebuchet/Workspace.java
+++ b/src/com/cyanogenmod/trebuchet/Workspace.java
@@ -34,6 +34,7 @@ import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
+import android.graphics.Camera;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
@@ -55,6 +56,7 @@ import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
+import android.view.animation.AccelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
import android.widget.ImageView;
@@ -82,7 +84,10 @@ public class Workspace extends SmoothPagedView
private static final String TAG = "Launcher.Workspace";
// Y rotation to apply to the workspace screens
+ private static final float WORKSPACE_ROTATION = 12.5f;
private static final float WORKSPACE_OVERSCROLL_ROTATION = 24f;
+ private static final float WORKSPACE_ROTATION_ANGLE = 12.5f;
+ private static float CAMERA_DISTANCE = 6500;
private static final int CHILDREN_OUTLINE_FADE_OUT_DELAY = 0;
private static final int CHILDREN_OUTLINE_FADE_OUT_DURATION = 375;
@@ -92,6 +97,9 @@ public class Workspace extends SmoothPagedView
private static final int ADJACENT_SCREEN_DROP_DURATION = 300;
private static final int FLING_THRESHOLD_VELOCITY = 500;
+ // Pivot point for rotate anim
+ private float mRotatePivotPoint = -1;
+
// These animators are used to fade the children's outlines
private ObjectAnimator mChildrenOutlineFadeInAnimation;
private ObjectAnimator mChildrenOutlineFadeOutAnimation;
@@ -188,9 +196,14 @@ public class Workspace extends SmoothPagedView
private final int[] mTempXY = new int[2];
private int[] mTempVisiblePagesRange = new int[2];
private float mOverscrollFade = 0;
- private boolean mOverscrollTransformsSet;
+ private boolean mScrollTransformsDirty = false;
+ private boolean mOverscrollTransformsDirty = false;
public static final int DRAG_BITMAP_PADDING = 2;
- private boolean mWorkspaceFadeInAdjacentScreens;
+
+ // Camera and Matrix used to determine the final position of a neighboring CellLayout
+ private final Matrix mMatrix = new Matrix();
+ private final Camera mCamera = new Camera();
+ private final float mTempFloat2[] = new float[2];
enum WallpaperVerticalOffset { TOP, MIDDLE, BOTTOM };
int mWallpaperWidth;
@@ -267,6 +280,22 @@ public class Workspace extends SmoothPagedView
private float[] mNewRotationYs;
private float mTransitionProgress;
+ public enum TransitionEffect {
+ Standard,
+ Tablet,
+ ZoomIn,
+ ZoomOut,
+ RotateUp,
+ RotateDown,
+ Spin,
+ Flip,
+ CubeIn,
+ CubeOut,
+ Stack,
+ Accordian
+ }
+ private TransitionEffect mTransitionEffect = TransitionEffect.Standard;
+
private final Runnable mBindPages = new Runnable() {
@Override
public void run() {
@@ -315,7 +344,7 @@ public class Workspace extends SmoothPagedView
mLauncher = (Launcher) context;
final Resources res = getResources();
- mFadeInAdjacentScreens = false;
+ mHandleFadeInAdjacentScreens = true;
mWallpaperManager = WallpaperManager.getInstance(context);
int cellCountX = DEFAULT_CELL_COUNT_X;
@@ -365,15 +394,17 @@ public class Workspace extends SmoothPagedView
mShowSearchBar = PreferencesProvider.Interface.Homescreen.getShowSearchBar(context);
mResizeAnyWidget = PreferencesProvider.Interface.Homescreen.getResizeAnyWidget(context);
mHideIconLabels = PreferencesProvider.Interface.Homescreen.getHideIconLabels(context);
+ mTransitionEffect = PreferencesProvider.Interface.Homescreen.Scrolling.getTransitionEffect(context,
+ res.getString(R.string.config_workspaceDefaultTransitionEffect));
mScrollWallpaper = PreferencesProvider.Interface.Homescreen.Scrolling.getScrollWallpaper(context);
mWallpaperHack = PreferencesProvider.Interface.Homescreen.Scrolling.getWallpaperHack(context);
- mShowScrollingIndicator = PreferencesProvider.Interface.Homescreen.Indicator.getShowScrollingIndicator(context);
- mFadeScrollingIndicator = PreferencesProvider.Interface.Homescreen.Indicator.getFadeScrollingIndicator(context);
- mShowDockDivider = PreferencesProvider.Interface.Homescreen.Indicator.getShowDockDivider(context);
mShowOutlines = PreferencesProvider.Interface.Homescreen.Scrolling.getShowOutlines(context,
res.getBoolean(R.bool.config_workspaceDefaultShowOutlines));
mFadeInAdjacentScreens = PreferencesProvider.Interface.Homescreen.Scrolling.getFadeInAdjacentScreens(context,
res.getBoolean(R.bool.config_workspaceDefualtFadeInAdjacentScreens));
+ mShowScrollingIndicator = PreferencesProvider.Interface.Homescreen.Indicator.getShowScrollingIndicator(context);
+ mFadeScrollingIndicator = PreferencesProvider.Interface.Homescreen.Indicator.getFadeScrollingIndicator(context);
+ mShowDockDivider = PreferencesProvider.Interface.Homescreen.Indicator.getShowDockDivider(context);
initWorkspace();
checkWallpaper();
@@ -868,7 +899,7 @@ public class Workspace extends SmoothPagedView
// If we are not fading in adjacent screens, we still need to restore the alpha in case the
// user scrolls while we are transitioning (should not affect dispatchDraw optimizations)
- if (!mWorkspaceFadeInAdjacentScreens) {
+ if (!mFadeInAdjacentScreens) {
for (int i = 0; i < getChildCount(); ++i) {
((CellLayout) getPageAt(i)).setShortcutAndWidgetAlpha(1f);
}
@@ -1298,6 +1329,31 @@ public class Workspace extends SmoothPagedView
return mBackgroundAlpha;
}
+ /**
+ * Due to 3D transformations, if two CellLayouts are theoretically touching each other,
+ * on the xy plane, when one is rotated along the y-axis, the gap between them is perceived
+ * as being larger. This method computes what offset the rotated view should be translated
+ * in order to minimize this perceived gap.
+ * @param degrees Angle of the view
+ * @param width Width of the view
+ * @param height Height of the view
+ * @return Offset to be used in a View.setTranslationX() call
+ */
+ protected float getOffsetXForRotation(float degrees, int width, int height) {
+ mMatrix.reset();
+ mCamera.save();
+ mCamera.rotateY(Math.abs(degrees));
+ mCamera.getMatrix(mMatrix);
+ mCamera.restore();
+
+ mMatrix.preTranslate(-width * 0.5f, -height * 0.5f);
+ mMatrix.postTranslate(width * 0.5f, height * 0.5f);
+ mTempFloat2[0] = width;
+ mTempFloat2[1] = height;
+ mMatrix.mapPoints(mTempFloat2);
+ return (width - mTempFloat2[0]) * (degrees > 0.0f ? 1.0f : -1.0f);
+ }
+
float backgroundAlphaInterpolator(float r) {
float pivotA = 0.1f;
float pivotB = 0.4f;
@@ -1322,72 +1378,338 @@ public class Workspace extends SmoothPagedView
return Math.min(r / threshold, 1.0f);
}
- private void updatePageAlphaValues(int screenCenter) {
- boolean isInOverscroll = mOverScrollX < 0 || mOverScrollX > mMaxScrollX;
- if (mWorkspaceFadeInAdjacentScreens &&
- mState == State.NORMAL &&
- !mIsSwitchingState &&
- !isInOverscroll) {
- for (int i = 0; i < getChildCount(); i++) {
- CellLayout child = (CellLayout) getChildAt(i);
- if (child != null) {
- float scrollProgress = getScrollProgress(screenCenter, child, i);
- float alpha = 1 - Math.abs(scrollProgress);
- child.getShortcutsAndWidgets().setAlpha(alpha);
- if (!mIsDragOccuring) {
- child.setBackgroundAlphaMultiplier(
- backgroundAlphaInterpolator(Math.abs(scrollProgress)));
- } else {
- child.setBackgroundAlphaMultiplier(1f);
- }
+ private void setChildrenBackgroundAlphaMultipliers(float a) {
+ for (int i = 0; i < getChildCount(); i++) {
+ CellLayout child = (CellLayout) getChildAt(i);
+ child.setBackgroundAlphaMultiplier(a);
+ }
+ }
+
+ private void screenScrolledStandard(int screenScroll) {
+ for (int i = 0; i < getChildCount(); i++) {
+ CellLayout cl = (CellLayout) getPageAt(i);
+ if (cl != null) {
+ float scrollProgress = getScrollProgress(screenScroll, cl, i);
+ if (mFadeInAdjacentScreens && !isSmall()) {
+ setCellLayoutFadeAdjacent(cl, scrollProgress);
}
}
}
}
- private void setChildrenBackgroundAlphaMultipliers(float a) {
+ private void screenScrolledTablet(int screenScroll) {
for (int i = 0; i < getChildCount(); i++) {
- CellLayout child = (CellLayout) getChildAt(i);
- child.setBackgroundAlphaMultiplier(a);
+ CellLayout cl = (CellLayout) getPageAt(i);
+ if (cl != null) {
+ float scrollProgress = getScrollProgress(screenScroll, cl, i);
+ float rotation = WORKSPACE_ROTATION * scrollProgress;
+ float translationX = getOffsetXForRotation(rotation, cl.getWidth(), cl.getHeight());
+
+ cl.setTranslationX(translationX);
+ cl.setRotationY(rotation);
+ if (mFadeInAdjacentScreens && !isSmall()) {
+ setCellLayoutFadeAdjacent(cl, scrollProgress);
+ }
+ }
}
+ invalidate();
}
- @Override
- protected void screenScrolled(int screenCenter) {
- super.screenScrolled(screenCenter);
+ private void screenScrolledZoom(int screenScroll, boolean in) {
+ for (int i = 0; i < getChildCount(); i++) {
+ CellLayout cl = (CellLayout) getPageAt(i);
+ if (cl != null) {
+ float scrollProgress = getScrollProgress(screenScroll, cl, i);
+ float scale = 1.0f + (in ? -0.2f : 0.1f) * Math.abs(scrollProgress);
+
+ // Extra translation to account for the increase in size
+ if (!in) {
+ float translationX = cl.getMeasuredWidth() * 0.1f * -scrollProgress;
+ cl.setTranslationX(translationX);
+ }
- updatePageAlphaValues(screenCenter);
- enableHwLayersOnVisiblePages();
+ cl.setScaleX(scale);
+ cl.setScaleY(scale);
+ if (mFadeInAdjacentScreens && !isSmall()) {
+ setCellLayoutFadeAdjacent(cl, scrollProgress);
+ }
+ }
+ }
+ }
+
+ private void screenScrolledRotate(int screenScroll, boolean up) {
+ for (int i = 0; i < getChildCount(); i++) {
+ CellLayout cl = (CellLayout) getPageAt(i);
+ if (cl != null) {
+ float scrollProgress = getScrollProgress(screenScroll, cl, i);
+ float rotation =
+ (up ? WORKSPACE_ROTATION_ANGLE : -WORKSPACE_ROTATION_ANGLE) * scrollProgress;
+
+ if (mRotatePivotPoint < 0) {
+ mRotatePivotPoint =
+ (cl.getMeasuredWidth() * 0.5f) /
+ (float) Math.tan(Math.toRadians((double) (WORKSPACE_ROTATION_ANGLE * 0.5f)));
+ }
+
+ cl.setPivotX(cl.getMeasuredWidth() * 0.5f);
+ cl.setPivotY(cl.getMeasuredHeight() * 0.5f);
+
+ float translationX = cl.getMeasuredWidth() * scrollProgress;
+ float translationY = 0.0f;
+
+ translationX += (up ? -1.0f : 1.0f) *
+ Math.sin(Math.toRadians((double) rotation)) * (mRotatePivotPoint + cl.getMeasuredHeight() * 0.5f);
+ translationY += (up ? -1.0f : 1.0f) *
+ (1.0f - Math.cos(Math.toRadians((double) rotation))) * (mRotatePivotPoint + cl.getMeasuredHeight() * 0.5f);
+
+ cl.setRotation(rotation);
+ cl.setTranslationX(translationX);
+ cl.setTranslationY(translationY);
+ if (mFadeInAdjacentScreens && !isSmall()) {
+ setCellLayoutFadeAdjacent(cl, scrollProgress);
+ }
+ }
+ }
+ }
- if (mOverScrollX < 0 || mOverScrollX > mMaxScrollX) {
- int index = mOverScrollX < 0 ? 0 : getChildCount() - 1;
- CellLayout cl = (CellLayout) getChildAt(index);
- if (getChildCount() > 1) {
- float scrollProgress = getScrollProgress(screenCenter, cl, index);
- cl.setOverScrollAmount(Math.abs(scrollProgress), index == 0);
- float rotation = - WORKSPACE_OVERSCROLL_ROTATION * scrollProgress;
+ private void screenScrolledCube(int screenScroll, boolean in) {
+ for (int i = 0; i < getChildCount(); i++) {
+ CellLayout cl = (CellLayout) getPageAt(i);
+ if (cl != null) {
+ float scrollProgress = getScrollProgress(screenScroll, cl, i);
+ float rotation = (in ? 90.0f : -90.0f) * scrollProgress;
+ float scale = 1.0f - Math.abs(scrollProgress) * 0.2f;
+
+ if (in) {
+ cl.setCameraDistance(mDensity * CAMERA_DISTANCE);
+ cl.setPivotX(scrollProgress < 0 ? 0 : cl.getMeasuredWidth());
+ } else {
+ cl.setScaleX(scale);
+ cl.setScaleY(scale);
+ cl.setPivotX(scrollProgress * cl.getMeasuredWidth() * 0.5f + cl.getMeasuredWidth() * 0.5f);
+ }
+ cl.setPivotY(cl.getMeasuredHeight() * 0.5f);
cl.setRotationY(rotation);
- setFadeForOverScroll(Math.abs(scrollProgress));
- if (!mOverscrollTransformsSet) {
- mOverscrollTransformsSet = true;
- cl.setCameraDistance(mDensity * mCameraDistance);
- cl.setPivotX(cl.getMeasuredWidth() * (index == 0 ? 0.75f : 0.25f));
+ setCellLayoutFadeAdjacent(cl, scrollProgress);
+ }
+ }
+ }
+
+ private void screenScrolledStack(int screenScroll) {
+ for (int i = 0; i < getChildCount(); i++) {
+ CellLayout cl = (CellLayout) getPageAt(i);
+ if (cl != null) {
+ float scrollProgress = getScrollProgress(screenScroll, cl, i);
+ float interpolatedProgress =
+ mZInterpolator.getInterpolation(Math.abs(Math.min(scrollProgress, 0)));
+ float scale = (1 - interpolatedProgress) + interpolatedProgress * 0.76f;
+ float translationX = Math.min(0, scrollProgress) * cl.getMeasuredWidth();
+ float alpha;
+
+ if (!LauncherApplication.isScreenLarge() || scrollProgress < 0) {
+ alpha = scrollProgress < 0 ? mAlphaInterpolator.getInterpolation(
+ 1 - Math.abs(scrollProgress)) : 1.0f;
+ } else {
+ // On large screens we need to fade the page as it nears its leftmost position
+ alpha = mLeftScreenAlphaInterpolator.getInterpolation(1 - scrollProgress);
+ }
+
+ cl.setTranslationX(translationX);
+ cl.setScaleX(scale);
+ cl.setScaleY(scale);
+ cl.setAlpha(alpha);
+
+ // If the view has 0 alpha, we set it to be invisible so as to prevent
+ // it from accepting touches
+ if (alpha <= 0) {
+ cl.setVisibility(INVISIBLE);
+ } else if (cl.getVisibility() != VISIBLE) {
+ cl.setVisibility(VISIBLE);
+ }
+ }
+ }
+ invalidate();
+ }
+
+ private void screenScrolledAccordian(int screenScroll) {
+ for (int i = 0; i < getChildCount(); i++) {
+ CellLayout cl = (CellLayout) getPageAt(i);
+ if (cl != null) {
+ float scrollProgress = getScrollProgress(screenScroll, cl, i);
+ float scaleX = 1.0f - Math.abs(scrollProgress);
+
+ cl.setPivotX(scrollProgress < 0 ? 0 : cl.getMeasuredWidth());
+ cl.setScaleX(scaleX);
+ if (scaleX == 0.0f) {
+ cl.setVisibility(INVISIBLE);
+ } else if (cl.getVisibility() != VISIBLE) {
+ cl.setVisibility(VISIBLE);
+ }
+ if (mFadeInAdjacentScreens && !isSmall()) {
+ setCellLayoutFadeAdjacent(cl, scrollProgress);
+ }
+ }
+ }
+ }
+
+ private void screenScrolledSpin(int screenScroll) {
+ for (int i = 0; i < getChildCount(); i++) {
+ CellLayout cl = (CellLayout) getPageAt(i);
+ if (cl != null) {
+ float scrollProgress = getScrollProgress(screenScroll, cl, i);
+ float rotation = 180.0f * scrollProgress;
+
+ if (getMeasuredHeight() > getMeasuredWidth()) {
+ float translationX = (getMeasuredHeight() - getMeasuredWidth()) / 2.0f * -scrollProgress;
+ cl.setTranslationX(translationX);
+ }
+
+ cl.setRotation(rotation);
+
+ if (mFadeInAdjacentScreens && !isSmall()) {
+ setCellLayoutFadeAdjacent(cl, scrollProgress);
+ }
+ }
+ }
+ }
+
+ private void screenScrolledFlip(int screenScroll) {
+ for (int i = 0; i < getChildCount(); i++) {
+ CellLayout cl = (CellLayout) getPageAt(i);
+ if (cl != null) {
+ float scrollProgress = getScrollProgress(screenScroll, cl, i);
+ float rotation = -180.0f * scrollProgress;
+
+ if (scrollProgress >= -0.5f && scrollProgress <= 0.5f) {
+ cl.setCameraDistance(mDensity * CAMERA_DISTANCE);
+ cl.setTranslationX(cl.getMeasuredWidth() * scrollProgress);
+ cl.setPivotX(cl.getMeasuredWidth() * 0.5f);
cl.setPivotY(cl.getMeasuredHeight() * 0.5f);
- cl.setOverscrollTransformsDirty(true);
+ cl.setRotationY(rotation);
+ if (cl.getVisibility() != VISIBLE) {
+ cl.setVisibility(VISIBLE);
+ }
+ if (mFadeInAdjacentScreens && !isSmall()) {
+ setCellLayoutFadeAdjacent(cl, scrollProgress);
+ }
+ } else {
+ cl.setVisibility(INVISIBLE);
+ }
+ }
+ }
+ invalidate();
+ }
+
+ @Override
+ protected void screenScrolled(int screenScroll) {
+ super.screenScrolled(screenScroll);
+ enableHwLayersOnVisiblePages();
+
+ if (isSwitchingState()) return;
+ if (isSmall()) {
+ for (int i = 0; i < getChildCount(); i++) {
+ CellLayout cl = (CellLayout) getPageAt(i);
+ if (cl != null) {
+ float scrollProgress = getScrollProgress(screenScroll, cl, i);
+ float rotation = WORKSPACE_ROTATION * scrollProgress;
+ float translationX = getOffsetXForRotation(rotation, cl.getWidth(), cl.getHeight());
+
+ cl.setTranslationX(translationX);
+ cl.setRotationY(rotation);
}
}
} else {
- if (mOverscrollFade != 0) {
- setFadeForOverScroll(0);
+ boolean isInOverscroll = mOverScrollX < 0 || mOverScrollX > mMaxScrollX;
+
+ if (isInOverscroll && !mOverscrollTransformsDirty) {
+ mScrollTransformsDirty = true;
}
- if (mOverscrollTransformsSet) {
- mOverscrollTransformsSet = false;
- ((CellLayout) getChildAt(0)).resetOverscrollTransforms();
- ((CellLayout) getChildAt(getChildCount() - 1)).resetOverscrollTransforms();
+ if (!isInOverscroll || mScrollTransformsDirty) {
+ // Limit the "normal" effects to mScrollX
+ int scroll = mScrollX;
+
+ if (mOverscrollFade != 0) {
+ setFadeForOverScroll(0);
+ }
+ if (mOverscrollTransformsDirty) {
+ mOverscrollTransformsDirty = false;
+ ((CellLayout) getChildAt(0)).resetOverscrollTransforms();
+ ((CellLayout) getChildAt(getChildCount() - 1)).resetOverscrollTransforms();
+ }
+
+ switch (mTransitionEffect) {
+ case Standard:
+ screenScrolledStandard(scroll);
+ break;
+ case Tablet:
+ screenScrolledTablet(scroll);
+ break;
+ case ZoomIn:
+ screenScrolledZoom(scroll, true);
+ break;
+ case ZoomOut:
+ screenScrolledZoom(scroll, false);
+ break;
+ case RotateUp:
+ screenScrolledRotate(scroll, true);
+ break;
+ case RotateDown:
+ screenScrolledRotate(scroll, false);
+ break;
+ case Spin:
+ screenScrolledSpin(scroll);
+ break;
+ case Flip:
+ screenScrolledFlip(scroll);
+ break;
+ case CubeIn:
+ screenScrolledCube(scroll, true);
+ break;
+ case CubeOut:
+ screenScrolledCube(scroll, false);
+ break;
+ case Stack:
+ screenScrolledStack(scroll);
+ break;
+ case Accordian:
+ screenScrolledAccordian(scroll);
+ break;
+ }
+ mScrollTransformsDirty = false;
+ }
+
+ if (isInOverscroll) {
+ int index = mOverScrollX < 0 ? 0 : getChildCount() - 1;
+ CellLayout cl = (CellLayout) getChildAt(index);
+ if (getChildCount() > 1) {
+ float scrollProgress = getScrollProgress(screenScroll, cl, index);
+ cl.setOverScrollAmount(Math.abs(scrollProgress), index == 0);
+ float rotation = - WORKSPACE_OVERSCROLL_ROTATION * scrollProgress;
+ cl.setRotationY(rotation);
+ setFadeForOverScroll(Math.abs(scrollProgress));
+ if (!mOverscrollTransformsDirty) {
+ mOverscrollTransformsDirty = true;
+ cl.setCameraDistance(mDensity * mCameraDistance);
+ cl.setPivotX(cl.getMeasuredWidth() * (index == 0 ? 0.75f : 0.25f));
+ cl.setPivotY(cl.getMeasuredHeight() * 0.5f);
+ cl.setOverscrollTransformsDirty(true);
+ }
+ }
}
}
}
+ private void setCellLayoutFadeAdjacent(CellLayout child, float scrollProgress) {
+ float alpha = 1 - Math.abs(scrollProgress);
+ child.getShortcutsAndWidgets().setAlpha(alpha);
+ if (!mIsDragOccuring) {
+ child.setBackgroundAlphaMultiplier(
+ backgroundAlphaInterpolator(Math.abs(scrollProgress)));
+ } else {
+ child.setBackgroundAlphaMultiplier(1f);
+ }
+ }
+
@Override
protected void overScroll(float amount) {
acceleratedOverScroll(amount);
@@ -1673,16 +1995,18 @@ public class Workspace extends SmoothPagedView
}
private final ZoomInInterpolator mZoomInInterpolator = new ZoomInInterpolator();
+ private final ZInterpolator mZInterpolator = new ZInterpolator(0.5f);
+ private AccelerateInterpolator mAlphaInterpolator = new AccelerateInterpolator(0.9f);
+ private DecelerateInterpolator mLeftScreenAlphaInterpolator = new DecelerateInterpolator(4);
- /*
- *
- * We call these methods (onDragStartedWithItemSpans/onDragStartedWithSize) whenever we
- * start a drag in Launcher, regardless of whether the drag has ever entered the Workspace
- *
- * These methods mark the appropriate pages as accepting drops (which alters their visual
- * appearance).
- *
- */
+ /**
+ * We call these methods (onDragStartedWithItemSpans/onDragStartedWithSize) whenever we
+ * start a drag in Launcher, regardless of whether the drag has ever entered the Workspace
+ *
+ * These methods mark the appropriate pages as accepting drops (which alters their visual
+ * appearance).
+ *
+ */
public void onDragStartedWithItem(View v) {
final Canvas canvas = new Canvas();
@@ -1750,8 +2074,6 @@ public class Workspace extends SmoothPagedView
final boolean stateIsSmall = (state == State.SMALL);
float finalScaleFactor = 1.0f;
float finalBackgroundAlpha = stateIsSpringLoaded ? 1.0f : 0f;
- float translationX = 0;
- float translationY = 0;
boolean zoomIn = true;
if (state != State.NORMAL) {
@@ -1775,11 +2097,111 @@ public class Workspace extends SmoothPagedView
getResources().getInteger(R.integer.config_appsCustomizeWorkspaceShrinkTime);
for (int i = 0; i < getChildCount(); i++) {
final CellLayout cl = (CellLayout) getChildAt(i);
- float finalAlpha = (!mWorkspaceFadeInAdjacentScreens || stateIsSpringLoaded ||
+ float rotation = 0f;
+ float rotationY = 0f;
+ float translationX = 0f;
+ float translationY = 0f;
+ float scale = finalScaleFactor;
+ float finalAlpha = (!mFadeInAdjacentScreens || stateIsSpringLoaded ||
(i == mCurrentPage)) ? 1f : 0f;
float currentAlpha = cl.getShortcutsAndWidgets().getAlpha();
float initialAlpha = currentAlpha;
+ // Tablet effect
+ if (mTransitionEffect == TransitionEffect.Tablet || stateIsSmall || stateIsSpringLoaded) {
+ translationX = getOffsetXForRotation(rotationY, cl.getWidth(), cl.getHeight());
+ if (i < mCurrentPage) {
+ rotationY = WORKSPACE_ROTATION;
+ } else if (i > mCurrentPage) {
+ rotationY = -WORKSPACE_ROTATION;
+ }
+ }
+
+ // Zoom Effects
+ if ((mTransitionEffect == TransitionEffect.ZoomIn ||
+ mTransitionEffect == TransitionEffect.ZoomOut) && stateIsNormal) {
+ if (i != mCurrentPage) {
+ scale = (mTransitionEffect == TransitionEffect.ZoomIn ? 0.5f : 1.1f);
+ }
+ }
+
+ // Stack Effect
+ if (mTransitionEffect == TransitionEffect.Stack) {
+ if (stateIsSpringLoaded) {
+ cl.setVisibility(VISIBLE);
+ } else if (stateIsNormal) {
+ if (i <= mCurrentPage) {
+ cl.setVisibility(VISIBLE);
+ } else {
+ cl.setVisibility(INVISIBLE);
+ }
+ }
+ }
+
+
+ // Flip Effect
+ if (mTransitionEffect == TransitionEffect.Flip) {
+ if (stateIsSpringLoaded) {
+ cl.setVisibility(VISIBLE);
+ } else if (stateIsNormal) {
+ if (i == mCurrentPage) {
+ cl.setVisibility(VISIBLE);
+ } else {
+ cl.setVisibility(INVISIBLE);
+ }
+ }
+ }
+
+ // Rotate Effects
+ if ((mTransitionEffect == TransitionEffect.RotateUp ||
+ mTransitionEffect == TransitionEffect.RotateDown) && stateIsNormal) {
+ boolean up = mTransitionEffect == TransitionEffect.RotateUp;
+ rotation = (up ? WORKSPACE_ROTATION_ANGLE : -WORKSPACE_ROTATION_ANGLE) * Math.max(-1.0f, Math.min(1.0f , mCurrentPage - i));
+ translationX = cl.getMeasuredWidth() * (Math.max(-1.0f, Math.min(1.0f, i - mCurrentPage))) +
+ (up ? -1.0f : 1.0f) * (float) Math.sin(Math.toRadians((double) rotation)) *
+ (mRotatePivotPoint + cl.getMeasuredHeight() * 0.5f);
+ translationY += (up ? -1.0f : 1.0f) * (1.0f - Math.cos(Math.toRadians((double) rotation))) *
+ (mRotatePivotPoint + cl.getMeasuredHeight() * 0.5f);
+ }
+
+ // Cube Effects
+ if ((mTransitionEffect == TransitionEffect.CubeIn || mTransitionEffect == TransitionEffect.CubeOut) && stateIsNormal) {
+ if (i < mCurrentPage) {
+ rotationY = mTransitionEffect == TransitionEffect.CubeOut ? -90.0f : 90.0f;
+ } else if (i > mCurrentPage) {
+ rotationY = mTransitionEffect == TransitionEffect.CubeOut ? 90.0f : -90.0f;
+ }
+ }
+
+ // Accordian Effect
+ if (mTransitionEffect == TransitionEffect.Accordian) {
+ if (stateIsSpringLoaded) {
+ cl.setVisibility(VISIBLE);
+ } else if (stateIsNormal) {
+ if (i == mCurrentPage) {
+ cl.setVisibility(VISIBLE);
+ } else {
+ cl.setVisibility(INVISIBLE);
+ }
+ }
+ }
+
+ if (stateIsSmall || stateIsSpringLoaded) {
+ cl.setCameraDistance(1280 * mDensity);
+ cl.setPivotX(cl.getMeasuredWidth() * 0.5f);
+ cl.setPivotY(cl.getMeasuredHeight() * 0.5f);
+ }
+
+ if (stateIsSmall || stateIsSpringLoaded) {
+ cl.setCameraDistance(1280 * mDensity);
+ if (mTransitionEffect == TransitionEffect.RotateUp ||
+ mTransitionEffect == TransitionEffect.RotateDown) {
+ cl.setTranslationX(0.0f);
+ }
+ cl.setPivotX(cl.getMeasuredWidth() * 0.5f);
+ cl.setPivotY(cl.getMeasuredHeight() * 0.5f);
+ }
+
// Determine the pages alpha during the state transition
if ((oldStateIsSmall && stateIsNormal) ||
(oldStateIsNormal && stateIsSmall)) {
@@ -1805,8 +2227,8 @@ public class Workspace extends SmoothPagedView
mNewTranslationXs[i] = translationX;
mNewTranslationYs[i] = translationY;
- mNewScaleXs[i] = finalScaleFactor;
- mNewScaleYs[i] = finalScaleFactor;
+ mNewScaleXs[i] = scale;
+ mNewScaleYs[i] = scale;
mNewBackgroundAlphas[i] = finalBackgroundAlpha;
} else {
cl.setTranslationX(translationX);
@@ -1905,7 +2327,7 @@ public class Workspace extends SmoothPagedView
// 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 (!mWorkspaceFadeInAdjacentScreens) {
+ if (!mFadeInAdjacentScreens) {
for (int i = 0; i < getChildCount(); i++) {
final CellLayout cl = (CellLayout) getChildAt(i);
cl.setShortcutAndWidgetAlpha(1f);
diff --git a/src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java b/src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java
index 6e4f536b7..8109289bb 100644
--- a/src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java
+++ b/src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java
@@ -78,6 +78,11 @@ public final class PreferencesProvider {
return preferences.getBoolean("ui_homescreen_general_hide_icon_labels", false);
}
public static class Scrolling {
+ public static Workspace.TransitionEffect getTransitionEffect(Context context, String def) {
+ final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0);
+ return Workspace.TransitionEffect.valueOf(
+ preferences.getString("ui_homescreen_scrolling_transition_effect", def));
+ }
public static boolean getScrollWallpaper(Context context) {
final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0);
return preferences.getBoolean("ui_homescreen_scrolling_scroll_wallpaper", true);
@@ -116,6 +121,17 @@ public final class PreferencesProvider {
final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0);
return preferences.getBoolean("ui_drawer_widgets_join_apps", true);
}
+ public static class Scrolling {
+ public static AppsCustomizePagedView.TransitionEffect getTransitionEffect(Context context, String def) {
+ final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0);
+ return AppsCustomizePagedView.TransitionEffect.valueOf(
+ preferences.getString("ui_drawer_scrolling_transition_effect", def));
+ }
+ public static boolean getFadeInAdjacentScreens(Context context) {
+ final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0);
+ return preferences.getBoolean("ui_drawer_scrolling_fade_adjacent_screens", false);
+ }
+ }
public static class Indicator {
public static boolean getShowScrollingIndicator(Context context) {
final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0);