summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichael Jurka <mikejurka@google.com>2011-09-22 14:39:16 -0700
committerMichael Jurka <mikejurka@google.com>2011-09-23 16:23:41 -0700
commita64718061a46e3982e35547e675244642bb82860 (patch)
tree92c30b32f6c715f451756f46c97213f9c087ac30 /src
parent90d2721c9d78ece0f94643a0d6a0128a027ff9d5 (diff)
downloadandroid_packages_apps_Trebuchet-a64718061a46e3982e35547e675244642bb82860.tar.gz
android_packages_apps_Trebuchet-a64718061a46e3982e35547e675244642bb82860.tar.bz2
android_packages_apps_Trebuchet-a64718061a46e3982e35547e675244642bb82860.zip
Restore gingerbread-style wallpaper parallax
Change-Id: I687b725f13053726569543a82df77d4a80aa907e
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher2/Workspace.java29
1 files changed, 22 insertions, 7 deletions
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index f61f7e7c2..2ef3c7499 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -111,6 +111,7 @@ public class Workspace extends SmoothPagedView
private final WallpaperManager mWallpaperManager;
private IBinder mWindowToken;
+ private static final float WALLPAPER_SCREENS_SPAN = 1.5f;
private int mDefaultPage;
@@ -725,8 +726,13 @@ public class Workspace extends SmoothPagedView
// We need to ensure that there is enough extra space in the wallpaper for the intended
// parallax effects
- mWallpaperWidth = (int) (maxDim * wallpaperTravelToScreenWidthRatio(maxDim, minDim));
- mWallpaperHeight = (int)(maxDim * wallpaperTravelToScreenHeightRatio(maxDim, minDim));
+ if (LauncherApplication.isScreenLarge()) {
+ mWallpaperWidth = (int) (maxDim * wallpaperTravelToScreenWidthRatio(maxDim, minDim));
+ mWallpaperHeight = (int)(maxDim * wallpaperTravelToScreenHeightRatio(maxDim, minDim));
+ } else {
+ mWallpaperWidth = (int) (minDim * WALLPAPER_SCREENS_SPAN);
+ mWallpaperHeight = maxDim;
+ }
new Thread("setWallpaperDimension") {
public void run() {
mWallpaperManager.suggestDesiredDimensions(mWallpaperWidth, mWallpaperHeight);
@@ -748,19 +754,24 @@ public class Workspace extends SmoothPagedView
}
private float wallpaperOffsetForCurrentScroll() {
+ final boolean overScrollWallpaper = LauncherApplication.isScreenLarge();
final boolean isStaticWallpaper = mIsStaticWallpaper;
// The wallpaper travel width is how far, from left to right, the wallpaper will move
// at this orientation (for example, 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 = mWallpaperTravelWidth;
- if (!isStaticWallpaper) {
+ if (!overScrollWallpaper || !isStaticWallpaper) {
wallpaperTravelWidth = mWallpaperWidth;
}
// Set wallpaper offset steps (1 / (number of screens - 1))
// We have 3 vertical offset states (centered, and then top/bottom aligned
// for all apps/customize)
- mWallpaperManager.setWallpaperOffsetSteps(1.0f / (getChildCount() - 1), 1.0f / (3 - 1));
+ if (LauncherApplication.isScreenLarge()) {
+ mWallpaperManager.setWallpaperOffsetSteps(1.0f / (getChildCount() - 1), 1.0f / (3 - 1));
+ } else {
+ mWallpaperManager.setWallpaperOffsetSteps(1.0f / (getChildCount() - 1), 1.0f);
+ }
// For the purposes of computing the scrollRange and overScrollOffset, we ignore
// assume that mLayoutScale is 1. This means that when we're in spring-loaded mode,
@@ -774,14 +785,14 @@ public class Workspace extends SmoothPagedView
// you over scroll 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])
- if (isStaticWallpaper) {
+ if (isStaticWallpaper && overScrollWallpaper) {
int overScrollOffset = (int) (maxOverScroll() * mDisplayWidth);
scrollProgressOffset += overScrollOffset / (float) getScrollRange();
scrollRange += 2 * overScrollOffset;
}
// Again, we adjust the wallpaper offset to be consistent between values of mLayoutScale
- boolean overScrollWallpaper = LauncherApplication.isScreenLarge();
+
float adjustedScrollX = overScrollWallpaper ?
mScrollX : Math.max(0, Math.min(mScrollX, mMaxScrollX));
adjustedScrollX *= mWallpaperScrollRatio;
@@ -867,6 +878,8 @@ public class Workspace extends SmoothPagedView
float mVerticalCatchupConstant = 0.35f;
public WallpaperOffsetInterpolator() {
+ mVerticalWallpaperOffset = LauncherApplication.isScreenLarge() ? 0.5f : 0f;
+ mFinalVerticalWallpaperOffset = LauncherApplication.isScreenLarge() ? 0.5f : 0f;
}
public void setOverrideHorizontalCatchupConstant(boolean override) {
@@ -918,7 +931,9 @@ public class Workspace extends SmoothPagedView
float vOffsetDelta = mFinalVerticalWallpaperOffset - mVerticalWallpaperOffset;
boolean jumpToFinalValue = Math.abs(hOffsetDelta) < UPDATE_THRESHOLD &&
Math.abs(vOffsetDelta) < UPDATE_THRESHOLD;
- if (jumpToFinalValue) {
+
+ // Don't have any lag between workspace and wallpaper on non-large devices
+ if (!LauncherApplication.isScreenLarge() || jumpToFinalValue) {
mHorizontalWallpaperOffset = mFinalHorizontalWallpaperOffset;
mVerticalWallpaperOffset = mFinalVerticalWallpaperOffset;
} else {