diff options
author | Adam Cohen <adamcohen@google.com> | 2011-10-25 14:36:40 -0700 |
---|---|---|
committer | Adam Cohen <adamcohen@google.com> | 2011-10-25 14:37:45 -0700 |
commit | 2591f6a5202664faf8cde2b68361e3842ce76ba9 (patch) | |
tree | fdbf4241544e217fa49b89ed39b1e93cc6b71bab /src/com/android/launcher2 | |
parent | f060868dd6ca8fb2f199fefd5cbb19a75ac2c108 (diff) | |
download | android_packages_apps_Trebuchet-2591f6a5202664faf8cde2b68361e3842ce76ba9.tar.gz android_packages_apps_Trebuchet-2591f6a5202664faf8cde2b68361e3842ce76ba9.tar.bz2 android_packages_apps_Trebuchet-2591f6a5202664faf8cde2b68361e3842ce76ba9.zip |
Fixing AppsCustomize paging effect on tablet
Change-Id: I9ec1faeb4efa1b3db338bf47dceee72befbc682e
Diffstat (limited to 'src/com/android/launcher2')
-rw-r--r-- | src/com/android/launcher2/AppsCustomizePagedView.java | 16 | ||||
-rw-r--r-- | src/com/android/launcher2/PagedView.java | 14 |
2 files changed, 26 insertions, 4 deletions
diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java index d8ff73c04..f5142bfa6 100644 --- a/src/com/android/launcher2/AppsCustomizePagedView.java +++ b/src/com/android/launcher2/AppsCustomizePagedView.java @@ -31,11 +31,11 @@ import android.content.res.Configuration; import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.Bitmap; -import android.graphics.Bitmap.Config; import android.graphics.Canvas; import android.graphics.PorterDuff; import android.graphics.Rect; import android.graphics.RectF; +import android.graphics.Bitmap.Config; import android.graphics.drawable.Drawable; import android.os.AsyncTask; import android.os.Process; @@ -47,6 +47,8 @@ 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.GridLayout; import android.widget.ImageView; import android.widget.Toast; @@ -218,6 +220,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen private static float TRANSITION_MAX_ROTATION = 22; private static final boolean PERFORM_OVERSCROLL_ROTATION = true; private AccelerateInterpolator mAlphaInterpolator = new AccelerateInterpolator(0.9f); + private DecelerateInterpolator mLeftScreenAlphaInterpolator = new DecelerateInterpolator(4); // Previews & outlines ArrayList<AppsCustomizeAsyncTask> mRunningTasks; @@ -262,7 +265,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen // (top + bottom) mWidgetPreviewIconPaddedDimension = (int) (mAppIconSize * (1 + (2 * sWidgetPreviewIconPaddingPercentage))); - mFadeInAdjacentScreens = LauncherApplication.isScreenLarge(); + mFadeInAdjacentScreens = false; } @Override @@ -1218,8 +1221,15 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen interpolatedProgress * TRANSITION_SCALE_FACTOR; float translationX = Math.min(0, scrollProgress) * v.getMeasuredWidth(); - float alpha = scrollProgress < 0 ? mAlphaInterpolator.getInterpolation( + 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); + } v.setCameraDistance(mDensity * CAMERA_DISTANCE); int pageWidth = v.getMeasuredWidth(); diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java index 7be19bf23..3d2deb8f1 100644 --- a/src/com/android/launcher2/PagedView.java +++ b/src/com/android/launcher2/PagedView.java @@ -102,6 +102,7 @@ public abstract class PagedView extends ViewGroup { protected final static float ALPHA_QUANTIZE_LEVEL = 0.0001f; protected int mTouchState = TOUCH_STATE_REST; + protected boolean mForceScreenScrolled = false; protected OnLongClickListener mLongClickListener; @@ -672,14 +673,25 @@ public abstract class PagedView extends ViewGroup { } @Override + protected void onViewAdded(View child) { + super.onViewAdded(child); + + // This ensures that when children are added, they get the correct transforms / alphas + // in accordance with any scroll effects. + mForceScreenScrolled = true; + invalidate(); + } + + @Override protected void dispatchDraw(Canvas canvas) { int halfScreenSize = getMeasuredWidth() / 2; int screenCenter = mScrollX + halfScreenSize; - if (screenCenter != mLastScreenCenter) { + if (screenCenter != mLastScreenCenter || mForceScreenScrolled) { screenScrolled(screenCenter); updateAdjacentPagesAlpha(); mLastScreenCenter = screenCenter; + mForceScreenScrolled = false; } // Find out which screens are visible; as an optimization we only call draw on them |