summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAdam Cohen <adamcohen@google.com>2011-10-25 16:24:26 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-10-25 16:24:26 -0700
commit89024e04ab9c78b7e5cf1699f16d813377b480f1 (patch)
tree0381ab21171c905b1432ad5bfe0939dd5c3b878b /src
parent2dac580d5288067061fc6d598072050be4263df7 (diff)
parent2591f6a5202664faf8cde2b68361e3842ce76ba9 (diff)
downloadandroid_packages_apps_Trebuchet-89024e04ab9c78b7e5cf1699f16d813377b480f1.tar.gz
android_packages_apps_Trebuchet-89024e04ab9c78b7e5cf1699f16d813377b480f1.tar.bz2
android_packages_apps_Trebuchet-89024e04ab9c78b7e5cf1699f16d813377b480f1.zip
Merge "Fixing AppsCustomize paging effect on tablet" into ics-mr1
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher2/AppsCustomizePagedView.java16
-rw-r--r--src/com/android/launcher2/PagedView.java14
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