diff options
author | Patrick Dubroy <dubroy@google.com> | 2010-08-04 16:02:59 -0700 |
---|---|---|
committer | Patrick Dubroy <dubroy@google.com> | 2010-08-04 18:00:58 -0700 |
commit | 7247f6315baf16eacb3286f21bd80321385c1def (patch) | |
tree | 6e0d6f5c0c0b5005ae40e6391f0df2ca9342ee02 /src/com/android/launcher2/Workspace.java | |
parent | 8335a24a6b7ae061e1f141dfa5ae20df64deb7cb (diff) | |
download | android_packages_apps_Trebuchet-7247f6315baf16eacb3286f21bd80321385c1def.tar.gz android_packages_apps_Trebuchet-7247f6315baf16eacb3286f21bd80321385c1def.tar.bz2 android_packages_apps_Trebuchet-7247f6315baf16eacb3286f21bd80321385c1def.zip |
Move all apps to the new animation framework, and some other all apps changes
Change-Id: Ib4c827966423d76e62db24036bbca0cd6ee46b95
Diffstat (limited to 'src/com/android/launcher2/Workspace.java')
-rw-r--r-- | src/com/android/launcher2/Workspace.java | 64 |
1 files changed, 26 insertions, 38 deletions
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java index 15b12b7d8..35a767d9e 100644 --- a/src/com/android/launcher2/Workspace.java +++ b/src/com/android/launcher2/Workspace.java @@ -17,12 +17,13 @@ package com.android.launcher2; import com.android.launcher.R; -import com.android.launcher2.CellLayout.LayoutParams; import android.animation.Animatable; +import android.animation.Animatable.AnimatableListener; +import android.animation.Animator; +import android.animation.Animator.AnimatorUpdateListener; import android.animation.PropertyAnimator; import android.animation.Sequencer; -import android.animation.Animatable.AnimatableListener; import android.app.WallpaperManager; import android.appwidget.AppWidgetManager; import android.appwidget.AppWidgetProviderInfo; @@ -31,6 +32,7 @@ import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.content.pm.ProviderInfo; +import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.Canvas; import android.graphics.Paint; @@ -46,14 +48,12 @@ import android.view.MotionEvent; import android.view.VelocityTracker; import android.view.View; import android.view.ViewConfiguration; -import android.view.ViewDebug; import android.view.ViewGroup; import android.view.ViewParent; import android.view.animation.Animation; -import android.view.animation.AnimationUtils; +import android.view.animation.Animation.AnimationListener; import android.view.animation.Interpolator; import android.view.animation.RotateAnimation; -import android.view.animation.Animation.AnimationListener; import android.widget.Scroller; import android.widget.TextView; import android.widget.Toast; @@ -1087,11 +1087,12 @@ public class Workspace extends ViewGroup // we use this to shrink the workspace for the all apps view and the customize view private void shrink(boolean shrinkToTop, boolean animated) { mIsSmall = true; + final Resources res = getResources(); final int screenWidth = getWidth(); final int screenHeight = getHeight(); - final int scaledScreenWidth = (int)(SHRINK_FACTOR*screenWidth); - final int scaledScreenHeight = (int)(SHRINK_FACTOR*screenHeight); - final float scaledSpacing = getResources().getDimension(R.dimen.smallScreenSpacing); + final int scaledScreenWidth = (int) (SHRINK_FACTOR * screenWidth); + final int scaledScreenHeight = (int) (SHRINK_FACTOR * screenHeight); + final float scaledSpacing = res.getDimension(R.dimen.smallScreenSpacing); final int screenCount = getChildCount(); float totalWidth = screenCount * scaledScreenWidth + (screenCount - 1) * scaledSpacing; @@ -1110,21 +1111,13 @@ public class Workspace extends ViewGroup for (int i = 0; i < screenCount; i++) { CellLayout cl = (CellLayout) getChildAt(i); if (animated) { - PropertyAnimator translateX = new PropertyAnimator( - 500, cl, "x", cl.getX(), (int) newX); - PropertyAnimator translateY = new PropertyAnimator( - 500, cl, "y", cl.getY(), (int) newY); - PropertyAnimator scaleX = new PropertyAnimator( - 500, cl, "scaleX", cl.getScaleX(), SHRINK_FACTOR); - PropertyAnimator scaleY = new PropertyAnimator( - 500, cl, "scaleY", cl.getScaleY(), SHRINK_FACTOR); - PropertyAnimator alpha = new PropertyAnimator( - 500, cl, "dimmedBitmapAlpha", cl.getDimmedBitmapAlpha(), 1.0f); - Sequencer.Builder b = s.play(translateX); - b.with(translateY); - b.with(scaleX); - b.with(scaleY); - b.with(alpha); + final int duration = res.getInteger(R.integer.config_workspaceShrinkTime); + s.playTogether( + new PropertyAnimator(duration, cl, "x", newX), + new PropertyAnimator(duration, cl, "y", newY), + new PropertyAnimator(duration, cl, "scaleX", SHRINK_FACTOR), + new PropertyAnimator(duration, cl, "scaleY", SHRINK_FACTOR), + new PropertyAnimator(duration, cl, "dimmedBitmapAlpha", 1.0f)); } else { cl.setX((int)newX); cl.setY((int)newY); @@ -1137,7 +1130,7 @@ public class Workspace extends ViewGroup cl.setOnInterceptTouchListener(this); } setChildrenDrawnWithCacheEnabled(true); - s.start(); + if (animated) s.start(); } // We call this when we trigger an unshrink by clicking on the CellLayout cl @@ -1168,20 +1161,15 @@ public class Workspace extends ViewGroup Sequencer s = new Sequencer(); final int screenCount = getChildCount(); for (int i = 0; i < screenCount; i++) { - CellLayout cl = (CellLayout)getChildAt(i); - int x = screenWidth * i; - - PropertyAnimator translateX = new PropertyAnimator(500, cl, "x", cl.getX(), x); - PropertyAnimator translateY = new PropertyAnimator(500, cl, "y", cl.getY(), 0); - PropertyAnimator scaleX = new PropertyAnimator(500, cl, "scaleX", cl.getScaleX(), 1.0f); - PropertyAnimator scaleY = new PropertyAnimator(500, cl, "scaleY", cl.getScaleY(), 1.0f); - PropertyAnimator alpha = new PropertyAnimator( - 500, cl, "dimmedBitmapAlpha", cl.getDimmedBitmapAlpha(), 0.0f); - Sequencer.Builder b = s.play(translateX); - b.with(translateY); - b.with(scaleX); - b.with(scaleY); - b.with(alpha); + final CellLayout cl = (CellLayout)getChildAt(i); + final int duration = + getResources().getInteger(R.integer.config_workspaceUnshrinkTime); + s.playTogether( + new PropertyAnimator(duration, cl, "x", (float) screenWidth * i), + new PropertyAnimator(duration, cl, "y", 0.0f), + new PropertyAnimator(duration, cl, "scaleX", 1.0f), + new PropertyAnimator(duration, cl, "scaleY", cl.getScaleY(), 1.0f), + new PropertyAnimator(duration, cl, "dimmedBitmapAlpha", 0.0f)); } s.addListener(mUnshrinkAnimationListener); s.start(); |