Merge "Fix bug # 3370739 - wallpaper overscroll doesn't work with non-static wallpapers" into honeycomb
This commit is contained in:
commit
e1dc51bce0
1 file changed
+15
-7
@@ -666,19 +666,27 @@ public class Workspace extends SmoothPagedView
|
|||||||
int wallpaperTravelWidth = (int) (display.getWidth() *
|
int wallpaperTravelWidth = (int) (display.getWidth() *
|
||||||
wallpaperTravelToScreenWidthRatio(display.getWidth(), display.getHeight()));
|
wallpaperTravelToScreenWidthRatio(display.getWidth(), display.getHeight()));
|
||||||
|
|
||||||
// Account for overscroll: you only see the absolute edge of the wallpaper if
|
|
||||||
// you overscroll as far as you can in landscape mode
|
|
||||||
int overscrollOffset = (int) (maxOverScroll() * display.getWidth());
|
|
||||||
float overscrollRatio = overscrollOffset / (float) getScrollRange();
|
|
||||||
int scrollRangeWithOverscroll = getScrollRange() + 2 * overscrollOffset;
|
|
||||||
|
|
||||||
// Set wallpaper offset steps (1 / (number of screens - 1))
|
// Set wallpaper offset steps (1 / (number of screens - 1))
|
||||||
// We have 3 vertical offset states (centered, and then top/bottom aligned
|
// We have 3 vertical offset states (centered, and then top/bottom aligned
|
||||||
// for all apps/customize)
|
// for all apps/customize)
|
||||||
mWallpaperManager.setWallpaperOffsetSteps(1.0f / (getChildCount() - 1), 1.0f / (3 - 1));
|
mWallpaperManager.setWallpaperOffsetSteps(1.0f / (getChildCount() - 1), 1.0f / (3 - 1));
|
||||||
|
|
||||||
|
int scrollRange = getScrollRange();
|
||||||
|
float scrollProgressOffset = 0;
|
||||||
|
|
||||||
|
// Account for overscroll: you only see the absolute edge of the wallpaper if
|
||||||
|
// you overscroll as far as you can in landscape mode. Only do this for static wallpapers
|
||||||
|
// because live wallpapers (and probably 3rd party wallpaper providers) rely on the offset
|
||||||
|
// being even intervals from 0 to 1 (eg [0, 0.25, 0.5, 0.75, 1])
|
||||||
|
final boolean isStaticWallpaper = (mWallpaperManager.getWallpaperInfo() == null);
|
||||||
|
if (isStaticWallpaper) {
|
||||||
|
int overscrollOffset = (int) (maxOverScroll() * display.getWidth());
|
||||||
|
scrollProgressOffset += overscrollOffset / (float) getScrollRange();
|
||||||
|
scrollRange += 2 * overscrollOffset;
|
||||||
|
}
|
||||||
|
|
||||||
float scrollProgress =
|
float scrollProgress =
|
||||||
mScrollX / (float) scrollRangeWithOverscroll + overscrollRatio;
|
mScrollX / (float) scrollRange + scrollProgressOffset;
|
||||||
float offsetInDips = wallpaperTravelWidth * scrollProgress +
|
float offsetInDips = wallpaperTravelWidth * scrollProgress +
|
||||||
(mWallpaperWidth - wallpaperTravelWidth) / 2;
|
(mWallpaperWidth - wallpaperTravelWidth) / 2;
|
||||||
float offset = offsetInDips / (float) mWallpaperWidth;
|
float offset = offsetInDips / (float) mWallpaperWidth;
|
||||||
|
|||||||
Reference in new issue
Block a user