diff options
author | Winson Chung <winsonc@google.com> | 2013-01-30 12:01:02 -0800 |
---|---|---|
committer | Winson Chung <winsonc@google.com> | 2013-02-04 16:35:52 -0800 |
commit | 52aee60edcfe5a16e16523c1a4241ac4d8b3672d (patch) | |
tree | 1c203c41ac86a272a0762bdf2f9e25f7dac9f62b /src/com/android/launcher2/AppsCustomizePagedView.java | |
parent | 05713af127d765cc28a8b2fd548a90347c90d6cb (diff) | |
download | android_packages_apps_Trebuchet-52aee60edcfe5a16e16523c1a4241ac4d8b3672d.tar.gz android_packages_apps_Trebuchet-52aee60edcfe5a16e16523c1a4241ac4d8b3672d.tar.bz2 android_packages_apps_Trebuchet-52aee60edcfe5a16e16523c1a4241ac4d8b3672d.zip |
Adding RTL paging.
Change-Id: Ic27d499cb76c7c30da37ed93f5372dd8441118b7
Diffstat (limited to 'src/com/android/launcher2/AppsCustomizePagedView.java')
-rw-r--r-- | src/com/android/launcher2/AppsCustomizePagedView.java | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java index bfc2db02c..a9f7faf8c 100644 --- a/src/com/android/launcher2/AppsCustomizePagedView.java +++ b/src/com/android/launcher2/AppsCustomizePagedView.java @@ -1344,6 +1344,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen // In apps customize, we have a scrolling effect which emulates pulling cards off of a stack. @Override protected void screenScrolled(int screenCenter) { + final boolean isRtl = isLayoutRtl(); super.screenScrolled(screenCenter); for (int i = 0; i < getChildCount(); i++) { @@ -1351,19 +1352,28 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen if (v != null) { float scrollProgress = getScrollProgress(screenCenter, v, i); - float interpolatedProgress = - mZInterpolator.getInterpolation(Math.abs(Math.min(scrollProgress, 0))); + float interpolatedProgress; + float translationX; + float maxScrollProgress = Math.max(0, scrollProgress); + float minScrollProgress = Math.min(0, scrollProgress); + + if (isRtl) { + translationX = maxScrollProgress * v.getMeasuredWidth(); + interpolatedProgress = mZInterpolator.getInterpolation(Math.abs(maxScrollProgress)); + } else { + translationX = minScrollProgress * v.getMeasuredWidth(); + interpolatedProgress = mZInterpolator.getInterpolation(Math.abs(minScrollProgress)); + } float scale = (1 - interpolatedProgress) + interpolatedProgress * TRANSITION_SCALE_FACTOR; - float translationX = Math.min(0, scrollProgress) * v.getMeasuredWidth(); float alpha; - - if (scrollProgress < 0) { - alpha = scrollProgress < 0 ? mAlphaInterpolator.getInterpolation( - 1 - Math.abs(scrollProgress)) : 1.0f; + if (isRtl && (scrollProgress > 0)) { + alpha = mAlphaInterpolator.getInterpolation(1 - Math.abs(maxScrollProgress)); + } else if (!isRtl && (scrollProgress < 0)) { + alpha = mAlphaInterpolator.getInterpolation(1 - Math.abs(scrollProgress)); } else { - // On large screens we need to fade the page as it nears its leftmost position + // On large screens we need to fade the page as it nears its leftmost position alpha = mLeftScreenAlphaInterpolator.getInterpolation(1 - scrollProgress); } @@ -1372,17 +1382,21 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen int pageHeight = v.getMeasuredHeight(); if (PERFORM_OVERSCROLL_ROTATION) { - if (i == 0 && scrollProgress < 0) { + float xPivot = isRtl ? 1f - TRANSITION_PIVOT : TRANSITION_PIVOT; + boolean isOverscrollingFirstPage = isRtl ? scrollProgress > 0 : scrollProgress < 0; + boolean isOverscrollingLastPage = isRtl ? scrollProgress < 0 : scrollProgress > 0; + + if (i == 0 && isOverscrollingFirstPage) { // Overscroll to the left - v.setPivotX(TRANSITION_PIVOT * pageWidth); + v.setPivotX(xPivot * pageWidth); v.setRotationY(-TRANSITION_MAX_ROTATION * scrollProgress); scale = 1.0f; alpha = 1.0f; // On the first page, we don't want the page to have any lateral motion translationX = 0; - } else if (i == getChildCount() - 1 && scrollProgress > 0) { + } else if (i == getChildCount() - 1 && isOverscrollingLastPage) { // Overscroll to the right - v.setPivotX((1 - TRANSITION_PIVOT) * pageWidth); + v.setPivotX((1 - xPivot) * pageWidth); v.setRotationY(-TRANSITION_MAX_ROTATION * scrollProgress); scale = 1.0f; alpha = 1.0f; |