summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichael Jurka <mikejurka@google.com>2012-02-29 14:13:01 -0800
committerMichael Jurka <mikejurka@google.com>2012-02-29 14:19:33 -0800
commit9551537718c191a829fd285890833225c023203d (patch)
treeb99e5b5ed238cba255845656f56af4d08aad5d51 /src
parenta95d329dea8c1aa09f50cc7ca897f454b161a454 (diff)
downloadandroid_packages_apps_Trebuchet-9551537718c191a829fd285890833225c023203d.tar.gz
android_packages_apps_Trebuchet-9551537718c191a829fd285890833225c023203d.tar.bz2
android_packages_apps_Trebuchet-9551537718c191a829fd285890833225c023203d.zip
Fix wallpaper offsets for live wallpapers on tablet
we were giving values that weren't an even fraction (ie n/4 where n = the screen # we're on) and therefore live wallpapers couldn't tell when we were fully settled on one of the workspace screens Bug# 6029132
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher2/Workspace.java42
1 files changed, 17 insertions, 25 deletions
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index c9898c8fe..672a284c3 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -190,6 +190,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
@@ -700,6 +701,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
@@ -810,28 +812,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);
@@ -849,11 +830,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) {