summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authornebkat <nebkat@teamhacksung.org>2012-01-22 18:28:15 +0000
committernebkat <nebkat@teamhacksung.org>2012-01-22 18:28:15 +0000
commit106e8752b40c35a2df333a3f0454de012149309d (patch)
tree4abd64be7d4ffb64c907df61352baf1af3164c16 /src
parent3b6f9e9d9086332e15e588aa1e8c57f06f35720c (diff)
downloadandroid_packages_apps_Trebuchet-106e8752b40c35a2df333a3f0454de012149309d.tar.gz
android_packages_apps_Trebuchet-106e8752b40c35a2df333a3f0454de012149309d.tar.bz2
android_packages_apps_Trebuchet-106e8752b40c35a2df333a3f0454de012149309d.zip
Workspace: Rotate Up/Down Transition
Change-Id: I13c457d11d05a09863368b15bc78701f2edf870e
Diffstat (limited to 'src')
-rw-r--r--src/com/cyanogenmod/trebuchet/Launcher.java17
-rw-r--r--src/com/cyanogenmod/trebuchet/Workspace.java86
2 files changed, 93 insertions, 10 deletions
diff --git a/src/com/cyanogenmod/trebuchet/Launcher.java b/src/com/cyanogenmod/trebuchet/Launcher.java
index 1206ec1c7..8d460c848 100644
--- a/src/com/cyanogenmod/trebuchet/Launcher.java
+++ b/src/com/cyanogenmod/trebuchet/Launcher.java
@@ -2301,8 +2301,14 @@ public final class Launcher extends Activity
setPivotsForZoom(toView, scale);
+ Workspace.TransitionEffect transitionEffect = mWorkspace.getTransitionEffect();
+ final boolean animateWorkspace = transitionEffect != Workspace.TransitionEffect.RotateUp &&
+ transitionEffect != Workspace.TransitionEffect.RotateDown;
+
// Shrink workspaces away if going to AppsCustomize from workspace
- mWorkspace.changeState(Workspace.State.SMALL, animated);
+ if (animateWorkspace) {
+ mWorkspace.changeState(Workspace.State.SMALL, animated);
+ }
if (animated) {
final ValueAnimator scaleAnim = ValueAnimator.ofFloat(0f, 1f).setDuration(duration);
@@ -2485,7 +2491,14 @@ public final class Launcher extends Activity
Resources res = getResources();
int stagger = res.getInteger(R.integer.config_appsCustomizeWorkspaceAnimationStagger);
- mWorkspace.changeState(Workspace.State.NORMAL, animated, stagger);
+ Workspace.TransitionEffect transitionEffect = mWorkspace.getTransitionEffect();
+ final boolean animateWorkspace = (transitionEffect != Workspace.TransitionEffect.RotateUp &&
+ transitionEffect != Workspace.TransitionEffect.RotateDown) || mWorkspace.getState() != Workspace.State.SMALL;
+
+ if (animateWorkspace) {
+ mWorkspace.changeState(Workspace.State.NORMAL, animated, stagger);
+ }
+
if (mState != State.WORKSPACE) {
mWorkspace.setVisibility(View.VISIBLE);
hideAppsCustomizeHelper(animated, false);
diff --git a/src/com/cyanogenmod/trebuchet/Workspace.java b/src/com/cyanogenmod/trebuchet/Workspace.java
index af55dda0f..5d56cad4d 100644
--- a/src/com/cyanogenmod/trebuchet/Workspace.java
+++ b/src/com/cyanogenmod/trebuchet/Workspace.java
@@ -91,6 +91,7 @@ public class Workspace extends PagedView
// 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;
@@ -229,6 +230,7 @@ public class Workspace extends PagedView
private float[] mOldBackgroundAlphas;
private float[] mOldBackgroundAlphaMultipliers;
private float[] mOldAlphas;
+ private float[] mOldRotations;
private float[] mOldRotationYs;
private float[] mNewTranslationXs;
private float[] mNewTranslationYs;
@@ -237,6 +239,7 @@ public class Workspace extends PagedView
private float[] mNewBackgroundAlphas;
private float[] mNewBackgroundAlphaMultipliers;
private float[] mNewAlphas;
+ private float[] mNewRotations;
private float[] mNewRotationYs;
private float mTransitionProgress;
@@ -245,6 +248,8 @@ public class Workspace extends PagedView
Tablet,
ZoomIn,
ZoomOut,
+ RotateUp,
+ RotateDown,
CubeIn,
CubeOut,
Stack
@@ -404,6 +409,14 @@ public class Workspace extends PagedView
}
}
+ public TransitionEffect getTransitionEffect() {
+ return mTransitionEffect;
+ }
+
+ public State getState() {
+ return mState;
+ }
+
public void onDragStart(DragSource source, Object info, int dragAction) {
mIsDragOccuring = true;
updateChildrenLayersEnabled();
@@ -1278,6 +1291,37 @@ public class Workspace extends PagedView
}
}
+ 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;
+ float translationX = cl.getMeasuredWidth() * scrollProgress;
+
+ float rotatePoint =
+ (cl.getMeasuredWidth() * 0.5f) /
+ (float) Math.tan(Math.toRadians((double) (WORKSPACE_ROTATION_ANGLE * 0.5f)));
+
+ cl.setPivotX(cl.getMeasuredWidth() * 0.5f);
+ if (up) {
+ cl.setPivotY(-rotatePoint);
+ } else {
+ cl.setPivotY(cl.getMeasuredHeight() + rotatePoint);
+ }
+
+ cl.setRotation(rotation);
+ cl.setFastTranslationX(translationX);
+ if (mFadeInAdjacentScreens && !isSmall()) {
+ float alpha = 1 - Math.abs(scrollProgress);
+ cl.setFastAlpha(alpha);
+ }
+ cl.fastInvalidate();
+ }
+ }
+ }
+
private void screenScrolledCube(int screenScroll, boolean in) {
for (int i = 0; i < getChildCount(); i++) {
CellLayout cl = (CellLayout) getPageAt(i);
@@ -1415,6 +1459,12 @@ public class Workspace extends PagedView
case ZoomOut:
screenScrolledZoom(screenScroll, false);
break;
+ case RotateUp:
+ screenScrolledRotate(screenScroll, true);
+ break;
+ case RotateDown:
+ screenScrolledRotate(screenScroll, false);
+ break;
case CubeIn:
screenScrolledCube(screenScroll, true);
break;
@@ -1765,6 +1815,7 @@ public class Workspace extends PagedView
mOldBackgroundAlphas = new float[childCount];
mOldBackgroundAlphaMultipliers = new float[childCount];
mOldAlphas = new float[childCount];
+ mOldRotations = new float[childCount];
mOldRotationYs = new float[childCount];
mNewTranslationXs = new float[childCount];
mNewTranslationYs = new float[childCount];
@@ -1773,6 +1824,7 @@ public class Workspace extends PagedView
mNewBackgroundAlphas = new float[childCount];
mNewBackgroundAlphaMultipliers = new float[childCount];
mNewAlphas = new float[childCount];
+ mNewRotations = new float[childCount];
mNewRotationYs = new float[childCount];
}
@@ -1842,6 +1894,7 @@ public class Workspace extends PagedView
for (int i = 0; i < getChildCount(); i++) {
final CellLayout cl = (CellLayout) getPageAt(i);
float rotation = 0f;
+ float rotationY = 0f;
float initialAlpha = cl.getAlpha();
float finalAlphaMultiplierValue = 1f;
float finalAlpha = (!mFadeInAdjacentScreens || stateIsSpringLoaded ||
@@ -1864,9 +1917,9 @@ public class Workspace extends PagedView
// Update the rotation of the screen
if (mTransitionEffect == TransitionEffect.Tablet || stateIsSmall || stateIsSpringLoaded) {
if (i < mCurrentPage) {
- rotation = WORKSPACE_ROTATION;
+ rotationY = WORKSPACE_ROTATION;
} else if (i > mCurrentPage) {
- rotation = -WORKSPACE_ROTATION;
+ rotationY = -WORKSPACE_ROTATION;
}
}
@@ -1885,7 +1938,23 @@ public class Workspace extends PagedView
if ((mTransitionEffect == TransitionEffect.Tablet && stateIsNormal) ||
(LauncherApplication.isScreenLarge() && (stateIsSmall || stateIsSpringLoaded))) {
- translationX = getOffsetXForRotation(rotation, cl.getWidth(), cl.getHeight());
+ translationX = getOffsetXForRotation(rotationY, cl.getWidth(), cl.getHeight());
+ }
+
+ if (stateIsNormal && (mTransitionEffect == TransitionEffect.RotateUp ||
+ mTransitionEffect == TransitionEffect.RotateDown)) {
+ rotation = (mTransitionEffect == TransitionEffect.RotateUp ? WORKSPACE_ROTATION_ANGLE : -WORKSPACE_ROTATION_ANGLE) *
+ Math.abs(mCurrentPage - i);
+ }
+
+ 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);
}
mOldAlphas[i] = initialAlpha;
@@ -1897,6 +1966,7 @@ public class Workspace extends PagedView
mOldScaleYs[i] = cl.getScaleY();
mOldBackgroundAlphas[i] = cl.getBackgroundAlpha();
mOldBackgroundAlphaMultipliers[i] = cl.getBackgroundAlphaMultiplier();
+ mOldRotations[i] = cl.getRotation();
mOldRotationYs[i] = cl.getRotationY();
mNewTranslationXs[i] = translationX;
@@ -1905,7 +1975,8 @@ public class Workspace extends PagedView
mNewScaleYs[i] = finalScaleFactor;
mNewBackgroundAlphas[i] = finalBackgroundAlpha;
mNewBackgroundAlphaMultipliers[i] = finalAlphaMultiplierValue;
- mNewRotationYs[i] = rotation;
+ mNewRotations[i] = rotation;
+ mNewRotationYs[i] = rotationY;
} else {
cl.setTranslationX(translationX);
cl.setTranslationY(translationY);
@@ -1914,12 +1985,10 @@ public class Workspace extends PagedView
cl.setBackgroundAlpha(finalBackgroundAlpha);
cl.setBackgroundAlphaMultiplier(finalAlphaMultiplierValue);
cl.setAlpha(finalAlpha);
- cl.setRotationY(rotation);
+ cl.setRotation(rotation);
+ cl.setRotationY(rotationY);
mChangeStateAnimationListener.onAnimationEnd(null);
}
- cl.setCameraDistance(1280 * mDensity);
- cl.setPivotX(cl.getMeasuredWidth() * 0.5f);
- cl.setPivotY(cl.getMeasuredHeight() * 0.5f);
}
if (animated) {
@@ -1981,6 +2050,7 @@ public class Workspace extends PagedView
}
for (int i = 0; i < getChildCount(); i++) {
final CellLayout cl = (CellLayout) getPageAt(i);
+ cl.setRotation(a * mOldRotations[i] + b * mNewRotations[i]);
cl.setFastRotationY(a * mOldRotationYs[i] + b * mNewRotationYs[i]);
}
}