diff options
-rw-r--r-- | res/values/config.xml | 12 | ||||
-rw-r--r-- | src/com/android/launcher2/AppsCustomizePagedView.java | 10 | ||||
-rw-r--r-- | src/com/android/launcher2/Launcher.java | 20 | ||||
-rw-r--r-- | src/com/android/launcher2/Workspace.java | 64 |
4 files changed, 63 insertions, 43 deletions
diff --git a/res/values/config.xml b/res/values/config.xml index f9adaf0dd..ff8dede18 100644 --- a/res/values/config.xml +++ b/res/values/config.xml @@ -23,12 +23,14 @@ <!-- Fade/zoom in/out duration & scale in the AllApps transition. Note: This should be less than the workspaceShrinkTime as they happen together. --> - <integer name="config_appsCustomizeZoomInTime">800</integer> - <integer name="config_appsCustomizeZoomOutTime">800</integer> - <integer name="config_appsCustomizeZoomScaleFactor">20</integer> - <integer name="config_appsCustomizeFadeInTime">280</integer> - <integer name="config_appsCustomizeFadeOutTime">500</integer> + <integer name="config_appsCustomizeZoomInTime">700</integer> + <integer name="config_appsCustomizeZoomOutTime">700</integer> + <integer name="config_appsCustomizeZoomScaleFactor">7</integer> + <integer name="config_appsCustomizeFadeInTime">250</integer> + <integer name="config_appsCustomizeFadeOutTime">200</integer> <integer name="config_appsCustomizeWorkspaceShrinkTime">300</integer> + <integer name="config_appsCustomizeWorkspaceAnimationStagger">40</integer> + <integer name="config_workspaceAppsCustomizeAnimationStagger">100</integer> <!-- Tab transition animation duration --> <integer name="config_tabTransitionDuration">250</integer> diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java index 9512e245f..6640f045f 100644 --- a/src/com/android/launcher2/AppsCustomizePagedView.java +++ b/src/com/android/launcher2/AppsCustomizePagedView.java @@ -192,11 +192,11 @@ 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 = 3500; + private static float CAMERA_DISTANCE = 6500; private static float TRANSITION_SCALE_FACTOR = 0.74f; - private static float TRANSITION_PIVOT = 0.75f; - private static float TRANSITION_MAX_ROTATION = 26f; - private static final boolean PERFORM_OVERSCROLL_ROTATION = false; + private static float TRANSITION_PIVOT = 0.65f; + private static float TRANSITION_MAX_ROTATION = 22; + private static final boolean PERFORM_OVERSCROLL_ROTATION = true; private AccelerateInterpolator mAlphaInterpolator = new AccelerateInterpolator(0.9f); // Previews & outlines @@ -1183,7 +1183,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen } protected void overScroll(float amount) { - dampedOverScroll(amount); + acceleratedOverScroll(amount); } /** diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java index 532926a45..28fdb90d3 100644 --- a/src/com/android/launcher2/Launcher.java +++ b/src/com/android/launcher2/Launcher.java @@ -75,10 +75,11 @@ import android.view.MenuItem; import android.view.MotionEvent; import android.view.Surface; import android.view.View; -import android.view.View.OnLongClickListener; import android.view.ViewGroup; import android.view.WindowManager; +import android.view.View.OnLongClickListener; import android.view.accessibility.AccessibilityEvent; +import android.view.animation.AccelerateDecelerateInterpolator; import android.view.animation.DecelerateInterpolator; import android.view.inputmethod.InputMethodManager; import android.widget.Advanceable; @@ -708,7 +709,7 @@ public final class Launcher extends Activity // Setup the workspace mWorkspace.setHapticFeedbackEnabled(false); mWorkspace.setOnLongClickListener(this); - mWorkspace.setup(this, dragController); + mWorkspace.setup(dragController); dragController.addDragListener(mWorkspace); // Get the search/delete bar @@ -2088,7 +2089,6 @@ public final class Launcher extends Activity * @param scaleFactor The scale factor used for the zoom */ private void setPivotsForZoom(View view, State state, float scaleFactor) { - final int height = view.getHeight(); view.setPivotX(view.getWidth() / 2.0f); view.setPivotY(view.getHeight() / 2.0f); } @@ -2115,12 +2115,14 @@ public final class Launcher extends Activity final int fadeDuration = res.getInteger(R.integer.config_appsCustomizeFadeInTime); final float scale = (float) res.getInteger(R.integer.config_appsCustomizeZoomScaleFactor); final View toView = mAppsCustomizeTabHost; + final int startDelay = + res.getInteger(R.integer.config_workspaceAppsCustomizeAnimationStagger); setPivotsForZoom(toView, toState, scale); // Shrink workspaces away if going to AppsCustomize from workspace mWorkspace.changeState(Workspace.State.SMALL, animated); - hideHotseat(animated); + //hideHotseat(animated); if (animated) { final ValueAnimator scaleAnim = ValueAnimator.ofFloat(0f, 1f).setDuration(duration); @@ -2144,6 +2146,7 @@ public final class Launcher extends Activity toView.setFastAlpha(a * 0f + b * 1f); } }); + alphaAnim.setStartDelay(startDelay); alphaAnim.start(); if (toView instanceof LauncherTransitionable) { @@ -2182,13 +2185,13 @@ public final class Launcher extends Activity } } + @Override public void onAnimationCancel(Animator animation) { animationCancelled = true; } }); // toView should appear right at the end of the workspace shrink animation - final int startDelay = 0; if (mStateAnimation != null) mStateAnimation.cancel(); mStateAnimation = new AnimatorSet(); @@ -2250,7 +2253,7 @@ public final class Launcher extends Activity }); final ValueAnimator alphaAnim = ValueAnimator.ofFloat(0f, 1f); alphaAnim.setDuration(res.getInteger(R.integer.config_appsCustomizeFadeOutTime)); - alphaAnim.setInterpolator(new DecelerateInterpolator(1.5f)); + alphaAnim.setInterpolator(new AccelerateDecelerateInterpolator()); alphaAnim.addUpdateListener(new LauncherAnimatorUpdateListener() { public void onAnimationUpdate(float a, float b) { // don't need to invalidate because we do so above @@ -2284,7 +2287,10 @@ public final class Launcher extends Activity } void showWorkspace(boolean animated) { - mWorkspace.changeState(Workspace.State.NORMAL, animated); + Resources res = getResources(); + int stagger = res.getInteger(R.integer.config_appsCustomizeWorkspaceAnimationStagger); + + mWorkspace.changeState(Workspace.State.NORMAL, animated, stagger); if (mState == State.APPS_CUSTOMIZE) { closeAllApps(animated); } diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java index 6f952fa8d..e57cc6b3c 100644 --- a/src/com/android/launcher2/Workspace.java +++ b/src/com/android/launcher2/Workspace.java @@ -17,12 +17,12 @@ package com.android.launcher2; import android.animation.Animator; -import android.animation.Animator.AnimatorListener; import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorSet; import android.animation.ObjectAnimator; import android.animation.TimeInterpolator; import android.animation.ValueAnimator; +import android.animation.Animator.AnimatorListener; import android.animation.ValueAnimator.AnimatorUpdateListener; import android.app.AlertDialog; import android.app.WallpaperManager; @@ -83,6 +83,7 @@ public class Workspace extends SmoothPagedView // 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 float CAMERA_DISTANCE = 6500; private static final int CHILDREN_OUTLINE_FADE_OUT_DELAY = 0; private static final int CHILDREN_OUTLINE_FADE_OUT_DURATION = 375; @@ -187,6 +188,10 @@ public class Workspace extends SmoothPagedView WallpaperOffsetInterpolator mWallpaperOffset; boolean mUpdateWallpaperOffsetImmediately = false; private Runnable mDelayedResizeRunnable; + private int mDisplayWidth; + private int mDisplayHeight; + private boolean mIsStaticWallpaper; + private int mWallpaperTravelWidth; // Variables relating to the creation of user folders by hovering shortcuts over shortcuts private static final int FOLDER_CREATION_TIMEOUT = 250; @@ -300,6 +305,7 @@ public class Workspace extends SmoothPagedView LauncherModel.updateWorkspaceLayoutCells(cellCountX, cellCountY); setHapticFeedbackEnabled(false); + mLauncher = (Launcher) context; initWorkspace(); // Disable multitouch across the workspace/all apps/customize tray @@ -355,6 +361,11 @@ public class Workspace extends SmoothPagedView mSnapVelocity = 600; mWallpaperOffset = new WallpaperOffsetInterpolator(); + Display display = mLauncher.getWindowManager().getDefaultDisplay(); + mDisplayWidth = display.getWidth(); + mDisplayHeight = display.getHeight(); + mWallpaperTravelWidth = (int) (mDisplayWidth * + wallpaperTravelToScreenWidthRatio(mDisplayWidth, mDisplayHeight)); } @Override @@ -610,6 +621,7 @@ public class Workspace extends SmoothPagedView protected void onPageBeginMoving() { super.onPageBeginMoving(); + mIsStaticWallpaper = mWallpaperManager.getWallpaperInfo() == null; if (isHardwareAccelerated()) { updateChildrenLayersEnabled(); @@ -700,9 +712,8 @@ public class Workspace extends SmoothPagedView } protected void setWallpaperDimension() { - Display display = mLauncher.getWindowManager().getDefaultDisplay(); DisplayMetrics displayMetrics = new DisplayMetrics(); - display.getRealMetrics(displayMetrics); + mLauncher.getWindowManager().getDefaultDisplay().getRealMetrics(displayMetrics); final int maxDim = Math.max(displayMetrics.widthPixels, displayMetrics.heightPixels); final int minDim = Math.min(displayMetrics.widthPixels, displayMetrics.heightPixels); @@ -731,13 +742,11 @@ public class Workspace extends SmoothPagedView } private float wallpaperOffsetForCurrentScroll() { - Display display = mLauncher.getWindowManager().getDefaultDisplay(); - final boolean isStaticWallpaper = (mWallpaperManager.getWallpaperInfo() == null); + final boolean isStaticWallpaper = mIsStaticWallpaper; // The wallpaper travel width is how far, from left to right, the wallpaper will move // at this orientation (for example, in portrait mode we don't move all the way to the // edges of the wallpaper, or otherwise the parallax effect would be too strong) - int wallpaperTravelWidth = (int) (display.getWidth() * - wallpaperTravelToScreenWidthRatio(display.getWidth(), display.getHeight())); + int wallpaperTravelWidth = mWallpaperTravelWidth; if (!isStaticWallpaper) { wallpaperTravelWidth = mWallpaperWidth; } @@ -760,7 +769,7 @@ public class Workspace extends SmoothPagedView // because live wallpapers (and probably 3rd party wallpaper providers) rely on the offset // being even intervals from 0 to 1 (eg [0, 0.25, 0.5, 0.75, 1]) if (isStaticWallpaper) { - int overScrollOffset = (int) (maxOverScroll() * display.getWidth()); + int overScrollOffset = (int) (maxOverScroll() * mDisplayWidth); scrollProgressOffset += overScrollOffset / (float) getScrollRange(); scrollRange += 2 * overScrollOffset; } @@ -872,8 +881,7 @@ public class Workspace extends SmoothPagedView mIsMovingFast = false; return false; } - Display display = mLauncher.getWindowManager().getDefaultDisplay(); - boolean isLandscape = display.getWidth() > display.getHeight(); + boolean isLandscape = mDisplayWidth > mDisplayHeight; long currentTime = System.currentTimeMillis(); long timeSinceLastUpdate = currentTime - mLastWallpaperOffsetUpdateTime; @@ -1100,16 +1108,17 @@ public class Workspace extends SmoothPagedView // If the current page (i) is being over scrolled, we use a different // set of rules for setting the background alpha multiplier. - if ((mScrollX < 0 && i == 0) || (mScrollX > mMaxScrollX && - i == getChildCount() -1 )) { - cl.setBackgroundAlphaMultiplier( - overScrollBackgroundAlphaInterpolator(Math.abs(scrollProgress))); - mOverScrollPageIndex = i; - } else if (mOverScrollPageIndex != i) { - cl.setBackgroundAlphaMultiplier( - backgroundAlphaInterpolator(Math.abs(scrollProgress))); + if (!isSmall()) { + if ((mScrollX < 0 && i == 0) || (mScrollX > mMaxScrollX && + i == getChildCount() -1 )) { + cl.setBackgroundAlphaMultiplier( + overScrollBackgroundAlphaInterpolator(Math.abs(scrollProgress))); + mOverScrollPageIndex = i; + } else if (mOverScrollPageIndex != i) { + cl.setBackgroundAlphaMultiplier( + backgroundAlphaInterpolator(Math.abs(scrollProgress))); + } } - cl.setTranslationX(translationX); cl.setRotationY(rotation); } @@ -1132,7 +1141,7 @@ public class Workspace extends SmoothPagedView cl.setOverScrollAmount(Math.abs(scrollProgress), index == 0); float translationX = index == 0 ? mScrollX : - (mMaxScrollX - mScrollX); float rotation = - WORKSPACE_OVERSCROLL_ROTATION * scrollProgress; - cl.setCameraDistance(mDensity * 6500); + cl.setCameraDistance(mDensity * CAMERA_DISTANCE); cl.setPivotX(cl.getMeasuredWidth() * (index == 0 ? 0.75f : 0.25f)); cl.setTranslationX(translationX); cl.setRotationY(rotation); @@ -1476,6 +1485,10 @@ public class Workspace extends SmoothPagedView } void changeState(final State state, boolean animated) { + changeState(state, animated, 0); + } + + void changeState(final State state, boolean animated, int delay) { if (mFirstLayout) { // (mFirstLayout == "first layout has not happened yet") // cancel any pending shrinks that were set earlier @@ -1492,7 +1505,7 @@ public class Workspace extends SmoothPagedView setCurrentPage((mNextPage != INVALID_PAGE) ? mNextPage : mCurrentPage); float finalScaleFactor = 1.0f; - float finalBackgroundAlpha = 0.0f; + float finalBackgroundAlpha = (state == State.SPRING_LOADED) ? 1.0f : 0f; boolean normalState = false; State oldState = mState; mState = state; @@ -1500,7 +1513,6 @@ public class Workspace extends SmoothPagedView if (state != State.NORMAL) { finalScaleFactor = mSpringLoadedShrinkFactor - (state == State.SMALL ? 0.1f : 0); - finalBackgroundAlpha = 1.0f; if (oldState == State.NORMAL && state == State.SMALL) { zoomIn = false; if (animated) { @@ -1509,6 +1521,7 @@ public class Workspace extends SmoothPagedView setLayoutScale(finalScaleFactor); updateChildrenLayersEnabled(); } else { + finalBackgroundAlpha = 1.0f; setLayoutScale(finalScaleFactor); } } else { @@ -1637,6 +1650,7 @@ public class Workspace extends SmoothPagedView }); mAnimator.playTogether(animWithInterpolator, rotationAnim); + mAnimator.setStartDelay(delay); // If we call this when we're not animated, onAnimationEnd is never called on // the listener; make sure we only use the listener when we're actually animating mAnimator.addListener(mChangeStateAnimationListener); @@ -2729,8 +2743,7 @@ public class Workspace extends SmoothPagedView public void getHitRect(Rect outRect) { // We want the workspace to have the whole area of the display (it will find the correct // cell layout to drop to in the existing drag/drop logic. - final Display d = mLauncher.getWindowManager().getDefaultDisplay(); - outRect.set(0, 0, d.getWidth(), d.getHeight()); + outRect.set(0, 0, mDisplayWidth, mDisplayHeight); } /** @@ -2981,8 +2994,7 @@ public class Workspace extends SmoothPagedView pixelX, pixelY, spanX, spanY, recycle); } - void setup(Launcher launcher, DragController dragController) { - mLauncher = launcher; + void setup(DragController dragController) { mSpringLoadedDragController = new SpringLoadedDragController(mLauncher); mDragController = dragController; |