Wallpaper preview parallax matches the actual wallpaper's.

Cherry picking the following changes from ub-launcher3-master:
Change-Id: I41c5bbbfdabfeb4e20d77e9b5804842a03211edf
Change-Id: I69afa3f8cc59c77e9c4c25e29e8db8c4beb87462
Change-Id: I82b7ba506d51ee4b3812af5fbdf95d3303b37aef
Change-Id: Id7c2b5483c5535d59be2f8a459ce7788e3c8318a

Bug: 23568800
Change-Id: I343169b9fdc5ceaab3d4b39044627d78b7267868
This commit is contained in:
Tony Wickham
2015-09-09 18:21:49 -07:00
parent 01251b0dc4
commit 3e776a87dc
8 changed files with 141 additions and 56 deletions

View File

@@ -1410,7 +1410,7 @@ public class Workspace extends PagedView
return false;
}
private float wallpaperOffsetForCurrentScroll() {
public float wallpaperOffsetForScroll(int scroll) {
// 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
@@ -1449,7 +1449,7 @@ public class Workspace extends PagedView
// 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);
scroll - firstPageScrollX - getLayoutTransitionOffsetForPage(0);
float offset = Math.min(1, adjustedScroll / (float) scrollRange);
offset = Math.max(0, offset);
@@ -1463,6 +1463,10 @@ public class Workspace extends PagedView
}
}
private float wallpaperOffsetForCurrentScroll() {
return wallpaperOffsetForScroll(getScrollX());
}
private int numEmptyScreensToIgnore() {
int numScrollingPages = getChildCount() - numCustomPages();
if (numScrollingPages >= MIN_PARALLAX_PAGE_SPAN && hasExtraEmptyScreen()) {