summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Cohen <adamcohen@google.com>2011-09-23 16:40:06 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-09-23 16:40:06 -0700
commit0a92bda3a43ca271ce56aa811865d217511f7653 (patch)
treebf761acfe9169f6048b7ae0b85bcefc38e03ac0e
parenta41585663ef22a6f6517765561c5a3651f1c5a71 (diff)
parenta64718061a46e3982e35547e675244642bb82860 (diff)
downloadandroid_packages_apps_Trebuchet-0a92bda3a43ca271ce56aa811865d217511f7653.tar.gz
android_packages_apps_Trebuchet-0a92bda3a43ca271ce56aa811865d217511f7653.tar.bz2
android_packages_apps_Trebuchet-0a92bda3a43ca271ce56aa811865d217511f7653.zip
Merge "Restore gingerbread-style wallpaper parallax" into ics-factoryrom
-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 {