diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2015-04-15 13:15:06 -0700 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2015-04-15 13:54:27 -0700 |
commit | 3fa3c127618ed928179be1bac138466d0e2bbce8 (patch) | |
tree | 6a05df442b346848a9126edb5880f4f15e8f8d28 | |
parent | 6da9c32204347d0980d3e76a5ff03bc3431b49a7 (diff) | |
download | android_packages_apps_Trebuchet-3fa3c127618ed928179be1bac138466d0e2bbce8.tar.gz android_packages_apps_Trebuchet-3fa3c127618ed928179be1bac138466d0e2bbce8.tar.bz2 android_packages_apps_Trebuchet-3fa3c127618ed928179be1bac138466d0e2bbce8.zip |
Fixing pallpaper parallex in rtl.
The rtl mode, the first screen should correspond to the last
opage offset (since page offset are always defined as
left-to-right)
Change-Id: Ie31139166bd71c423c63968760493ec572af81e9
-rw-r--r-- | src/com/android/launcher3/Workspace.java | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index 91739711b..043ecb075 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -1410,7 +1410,22 @@ public class Workspace extends SmoothPagedView } private float wallpaperOffsetForCurrentScroll() { + // TODO: do different behavior if it's a live wallpaper? + // Don't use up all the wallpaper parallax until you have at least + // MIN_PARALLAX_PAGE_SPAN pages + int numScrollingPages = getNumScreensExcludingEmptyAndCustom(); + int parallaxPageSpan; + if (mWallpaperIsLiveWallpaper) { + parallaxPageSpan = numScrollingPages - 1; + } else { + parallaxPageSpan = Math.max(MIN_PARALLAX_PAGE_SPAN, numScrollingPages - 1); + } + mNumPagesForWallpaperParallax = parallaxPageSpan; + if (getChildCount() <= 1) { + if (isLayoutRtl()) { + return 1 - 1.0f/mNumPagesForWallpaperParallax; + } return 0; } @@ -1430,28 +1445,20 @@ public class Workspace extends SmoothPagedView if (scrollRange == 0) { return 0; } else { - // TODO: do different behavior if it's a live wallpaper? // Sometimes the left parameter of the pages is animated during a layout transition; // this parameter offsets it to keep the wallpaper from animating as well int adjustedScroll = getScrollX() - firstPageScrollX - getLayoutTransitionOffsetForPage(0); float offset = Math.min(1, adjustedScroll / (float) scrollRange); offset = Math.max(0, offset); - // Don't use up all the wallpaper parallax until you have at least - // MIN_PARALLAX_PAGE_SPAN pages - int numScrollingPages = getNumScreensExcludingEmptyAndCustom(); - int parallaxPageSpan; - if (mWallpaperIsLiveWallpaper) { - parallaxPageSpan = numScrollingPages - 1; - } else { - parallaxPageSpan = Math.max(MIN_PARALLAX_PAGE_SPAN, numScrollingPages - 1); - } - mNumPagesForWallpaperParallax = parallaxPageSpan; // On RTL devices, push the wallpaper offset to the right if we don't have enough // pages (ie if numScrollingPages < MIN_PARALLAX_PAGE_SPAN) - int padding = isLayoutRtl() ? parallaxPageSpan - numScrollingPages + 1 : 0; - return offset * (padding + numScrollingPages - 1) / parallaxPageSpan; + if (!mWallpaperIsLiveWallpaper && numScrollingPages < MIN_PARALLAX_PAGE_SPAN + && isLayoutRtl()) { + return offset * (parallaxPageSpan - numScrollingPages + 1) / parallaxPageSpan; + } + return offset * (numScrollingPages - 1) / parallaxPageSpan; } } |