diff options
author | Michael Jurka <mikejurka@google.com> | 2012-02-29 14:34:33 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-02-29 14:34:33 -0800 |
commit | b8fffe76399653c423e2195990b2ebfb15139ac4 (patch) | |
tree | 8b27ca651de4c99574b6627d48e441cf4a39ed4f | |
parent | 71d764f7ed56e5780156a42accb72355eed2bc9c (diff) | |
parent | 9551537718c191a829fd285890833225c023203d (diff) | |
download | packages_apps_trebuchet-b8fffe76399653c423e2195990b2ebfb15139ac4.zip packages_apps_trebuchet-b8fffe76399653c423e2195990b2ebfb15139ac4.tar.gz packages_apps_trebuchet-b8fffe76399653c423e2195990b2ebfb15139ac4.tar.bz2 |
Merge "Fix wallpaper offsets for live wallpapers on tablet"
-rw-r--r-- | src/com/android/launcher2/Workspace.java | 42 |
1 files changed, 17 insertions, 25 deletions
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java index 0893017..0624d74 100644 --- a/src/com/android/launcher2/Workspace.java +++ b/src/com/android/launcher2/Workspace.java @@ -191,6 +191,7 @@ public class Workspace extends SmoothPagedView private Runnable mDelayedResizeRunnable; private int mDisplayWidth; private int mDisplayHeight; + private boolean mIsStaticWallpaper; private int mWallpaperTravelWidth; // Variables relating to the creation of user folders by hovering shortcuts over shortcuts @@ -711,6 +712,7 @@ public class Workspace extends SmoothPagedView // Only show page outlines as we pan if we are on large screen if (LauncherApplication.isScreenLarge()) { showOutlines(); + mIsStaticWallpaper = mWallpaperManager.getWallpaperInfo() == null; } // If we are not fading in adjacent screens, we still need to restore the alpha in case the @@ -821,28 +823,7 @@ public class Workspace extends SmoothPagedView }.start(); } - public void setVerticalWallpaperOffset(float offset) { - mWallpaperOffset.setFinalY(offset); - } - public float getVerticalWallpaperOffset() { - return mWallpaperOffset.getCurrY(); - } - public void setHorizontalWallpaperOffset(float offset) { - mWallpaperOffset.setFinalX(offset); - } - public float getHorizontalWallpaperOffset() { - return mWallpaperOffset.getCurrX(); - } - private float wallpaperOffsetForCurrentScroll() { - // The wallpaper travel width is how far, from left to right, the wallpaper will move - // at this orientation. On tablets in portrait mode we don't move all the way to the - // edges of the wallpaper, or otherwise the parallax effect would be too strong. - int wallpaperTravelWidth = mWallpaperWidth; - if (LauncherApplication.isScreenLarge()) { - wallpaperTravelWidth = mWallpaperTravelWidth; - } - // Set wallpaper offset steps (1 / (number of screens - 1)) mWallpaperManager.setWallpaperOffsetSteps(1.0f / (getChildCount() - 1), 1.0f); @@ -860,11 +841,22 @@ public class Workspace extends SmoothPagedView float scrollProgress = adjustedScrollX / (float) scrollRange; - float offsetInDips = wallpaperTravelWidth * scrollProgress + - (mWallpaperWidth - wallpaperTravelWidth) / 2; // center it - float offset = offsetInDips / (float) mWallpaperWidth; - return offset; + + if (LauncherApplication.isScreenLarge() && mIsStaticWallpaper) { + // The wallpaper travel width is how far, from left to right, the wallpaper will move + // at this orientation. On tablets in portrait mode we don't move all the way to the + // edges of the wallpaper, or otherwise the parallax effect would be too strong. + int wallpaperTravelWidth = Math.min(mWallpaperTravelWidth, mWallpaperWidth); + + float offsetInDips = wallpaperTravelWidth * scrollProgress + + (mWallpaperWidth - wallpaperTravelWidth) / 2; // center it + float offset = offsetInDips / (float) mWallpaperWidth; + return offset; + } else { + return scrollProgress; + } } + private void syncWallpaperOffsetWithScroll() { final boolean enableWallpaperEffects = isHardwareAccelerated(); if (enableWallpaperEffects) { |